00001 #include <set>
00002 #include "verification.hpp"
00003 #include "coloring.hpp"
00004 #include "grid.hpp"
00005
00006 using namespace Arak;
00007
00008 void CriticalStatsEstimator::update(const Coloring& c) {
00009 n++;
00010 sumIntVertices += c.numVertices(Coloring::Vertex::INTERIOR);
00011 sumIntEdges += c.numInteriorEdges();
00012 for (int i = 0; i < 4; i++) {
00013 Coloring::VertexHandle vh = c.getVertex(Coloring::Vertex::CORNER, i);
00014 vh = vh->getNextBdEdge()->getNextVertex();
00015 while (vh->type() != Coloring::Vertex::CORNER) {
00016 sumBdVertices[i]++;
00017 vh = vh->getNextBdEdge()->getNextVertex();
00018 }
00019 }
00020 typedef const Coloring::InteriorEdgeIndex Index;
00021 typedef Index::ConstLineCellIterator Iterator;
00022 typedef const Index::Cell Cell;
00023 typedef Cell::ItemList::const_iterator EdgeIterator;
00024 Index& index = c.getInteriorEdgeIndex();
00025 std::set<Coloring::IntEdgeHandle> counted;
00026 for (unsigned int i = 0; i < testSegments.size(); i++) {
00027 const Geometry::Segment& s = testSegments[i];
00028 counted.clear();
00029 Iterator it(index, s.source(), s.target(), Iterator::SEGMENT()), end;
00030 while (it != end) {
00031 Cell& cell = *it;
00032 const Cell::ItemList& edges = cell.getItemList();
00033 for (EdgeIterator jt = edges.begin(); jt != edges.end(); jt++) {
00034 const Coloring::IntEdgeHandle e = *jt;
00035 if ((counted.find(e) == counted.end()) &&
00036 e->crosses(s.source(), s.target()))
00037 counted.insert(e);
00038 }
00039 ++it;
00040 }
00041 sumCrossings[i] += counted.size();
00042 }
00043 }
00044
00045