/* * Finds and removes all cut edges from the graph. * @return a list of the LineString forming the removed cut edges */ vector<const LineString*> * PolygonizeGraph::deleteCutEdges() { computeNextCWEdges(); // label the current set of edgerings delete findLabeledEdgeRings(dirEdges); /* * Cut Edges are edges where both dirEdges have the same label. * Delete them, and record them */ vector<const LineString*> *cutLines=new vector<const LineString*>(); for(int i=0;i<(int)dirEdges->size();i++) { PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)(*dirEdges)[i]; if (de->isMarked()) continue; PolygonizeDirectedEdge *sym=(PolygonizeDirectedEdge*) de->getSym(); if (de->getLabel()==sym->getLabel()) { de->setMarked(true); sym->setMarked(true); // save the line as a cut edge PolygonizeEdge *e=(PolygonizeEdge*) de->getEdge(); cutLines->push_back(e->getLine()); } } return cutLines; }
/** * Computes the EdgeRings formed by the edges in this graph. * @return a list of the EdgeRing found by the polygonization process. */ vector<polygonizeEdgeRing*>* PolygonizeGraph::getEdgeRings() { // maybe could optimize this, since most of these pointers should // be set correctly already // by deleteCutEdges() computeNextCWEdges(); // clear labels of all edges in graph label(dirEdges,-1); vector<PolygonizeDirectedEdge*> *maximalRings=findLabeledEdgeRings(dirEdges); convertMaximalToMinimalEdgeRings(maximalRings); delete maximalRings; // find all edgerings vector<polygonizeEdgeRing*> *edgeRingList=new vector<polygonizeEdgeRing*>(); for(int i=0;i<(int)dirEdges->size();i++) { PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)(*dirEdges)[i]; if (de->isMarked()) continue; if (de->isInRing()) continue; polygonizeEdgeRing *er=findEdgeRing(de); edgeRingList->push_back(er); } return edgeRingList; }
/* public */ void PolygonizeGraph::getEdgeRings(std::vector<EdgeRing*>& edgeRingList) { // maybe could optimize this, since most of these pointers should // be set correctly already // by deleteCutEdges() computeNextCWEdges(); // clear labels of all edges in graph label(dirEdges, -1); std::vector<PolygonizeDirectedEdge*> maximalRings; findLabeledEdgeRings(dirEdges, maximalRings); convertMaximalToMinimalEdgeRings(maximalRings); maximalRings.clear(); // not needed anymore // find all edgerings for(unsigned int i=0; i<dirEdges.size(); ++i) { PolygonizeDirectedEdge *de=(PolygonizeDirectedEdge*)dirEdges[i]; if (de->isMarked()) continue; if (de->isInRing()) continue; EdgeRing *er=findEdgeRing(de); edgeRingList.push_back(er); } }
void PolygonizeGraph::computeNextCWEdges() { vector<planarNode*> *pns=getNodes(); // set the next pointers for the edges around each node for(int i=0;i<(int)pns->size();i++) { planarNode *node=(*pns)[i]; computeNextCWEdges(node); } delete pns; }
void PolygonizeGraph::computeNextCWEdges() { typedef std::vector<Node*> Nodes; Nodes pns; getNodes(pns); // set the next pointers for the edges around each node for(Nodes::size_type i=0, in=pns.size(); i<in; ++i) { Node *node=pns[i]; computeNextCWEdges(node); } }
/* public */ void PolygonizeGraph::deleteCutEdges(std::vector<const LineString*> &cutLines) { computeNextCWEdges(); typedef std::vector<PolygonizeDirectedEdge*> DirEdges; // label the current set of edgerings DirEdges junk; findLabeledEdgeRings(dirEdges, junk); junk.clear(); // not needed anymore /* * Cut Edges are edges where both dirEdges have the same label. * Delete them, and record them */ for (DirEdges::size_type i=0, in=dirEdges.size(); i<in; ++i) { DirectedEdge *de_ = dirEdges[i]; #ifdef GEOS_CAST_PARANOIA assert(dynamic_cast<PolygonizeDirectedEdge*>(de_)); #endif PolygonizeDirectedEdge *de = static_cast<PolygonizeDirectedEdge*>(de_); if (de->isMarked()) continue; DirectedEdge *sym_ = de->getSym(); #ifdef GEOS_CAST_PARANOIA assert(dynamic_cast<PolygonizeDirectedEdge*>(sym_)); #endif PolygonizeDirectedEdge *sym = static_cast<PolygonizeDirectedEdge*>(sym_); if (de->getLabel()==sym->getLabel()) { de->setMarked(true); sym->setMarked(true); // save the line as a cut edge Edge *e_ = de->getEdge(); #ifdef GEOS_CAST_PARANOIA assert(dynamic_cast<PolygonizeEdge*>(e_)); #endif PolygonizeEdge *e = static_cast<PolygonizeEdge*>(e_); cutLines.push_back(e->getLine()); } } }