[geos-commits] r2730 - in trunk/source:
headers/geos/operation/polygonize operation/polygonize
svn_geos at osgeo.org
svn_geos at osgeo.org
Thu Nov 19 15:29:04 EST 2009
Author: strk
Date: 2009-11-19 15:29:01 -0500 (Thu, 19 Nov 2009)
New Revision: 2730
Modified:
trunk/source/headers/geos/operation/polygonize/PolygonizeGraph.h
trunk/source/operation/polygonize/PolygonizeGraph.cpp
trunk/source/operation/polygonize/Polygonizer.cpp
Log:
Don't force heap allocation of std::vector in PolygonizeGraph when deleting dangles (moved allocation higher, in Polygonizer, so needs a second pass)
Modified: trunk/source/headers/geos/operation/polygonize/PolygonizeGraph.h
===================================================================
--- trunk/source/headers/geos/operation/polygonize/PolygonizeGraph.h 2009-11-19 20:20:29 UTC (rev 2729)
+++ trunk/source/headers/geos/operation/polygonize/PolygonizeGraph.h 2009-11-19 20:29:01 UTC (rev 2730)
@@ -122,9 +122,10 @@
* In order to handle large recursion depths efficiently,
* an explicit recursion stack is used
*
- * @return a List containing the LineStrings that formed dangles
+ * @param dangleLines : the LineStrings that formed dangles will
+ * be push_back'ed here
*/
- std::vector<const geom::LineString*>* deleteDangles();
+ void deleteDangles(std::vector<const geom::LineString*> &dangleLines);
private:
Modified: trunk/source/operation/polygonize/PolygonizeGraph.cpp
===================================================================
--- trunk/source/operation/polygonize/PolygonizeGraph.cpp 2009-11-19 20:20:29 UTC (rev 2729)
+++ trunk/source/operation/polygonize/PolygonizeGraph.cpp 2009-11-19 20:29:01 UTC (rev 2730)
@@ -440,21 +440,11 @@
return er;
}
-/**
- * Marks all edges from the graph which are "dangles".
- * Dangles are which are incident on a node with degree 1.
- * This process is recursive, since removing a dangling edge
- * may result in another edge becoming a dangle.
- * In order to handle large recursion depths efficiently,
- * an explicit recursion stack is used
- *
- * @return a List containing the LineStrings that formed dangles
- */
-std::vector<const LineString*>*
-PolygonizeGraph::deleteDangles()
+/* public */
+void
+PolygonizeGraph::deleteDangles(std::vector<const LineString*>& dangleLines)
{
std::vector<Node*> *nodesToRemove=findNodesOfDegree(1);
- std::vector<const LineString*> *dangleLines=new std::vector<const LineString*>();
std::vector<Node*> nodeStack;
for(int i=0;i<(int)nodesToRemove->size();i++) {
nodeStack.push_back((*nodesToRemove)[i]);
@@ -475,14 +465,13 @@
sym->setMarked(true);
// save the line as a dangle
PolygonizeEdge *e=(PolygonizeEdge*) de->getEdge();
- dangleLines->push_back(e->getLine());
+ dangleLines.push_back(e->getLine());
Node *toNode=de->getToNode();
// add the toNode to the list to be processed, if it is now a dangle
if (getDegreeNonDeleted(toNode)==1)
nodeStack.push_back(toNode);
}
}
- return dangleLines;
}
} // namespace geos.operation.polygonize
Modified: trunk/source/operation/polygonize/Polygonizer.cpp
===================================================================
--- trunk/source/operation/polygonize/Polygonizer.cpp 2009-11-19 20:20:29 UTC (rev 2729)
+++ trunk/source/operation/polygonize/Polygonizer.cpp 2009-11-19 20:29:01 UTC (rev 2730)
@@ -234,7 +234,9 @@
// if no geometries were supplied it's possible graph could be null
if (graph==NULL) return;
- dangles=graph->deleteDangles();
+ // TODO: drop this heap allocation
+ dangles = new std::vector<const LineString*>();
+ graph->deleteDangles(*dangles);
// TODO: drop this heap allocation
cutEdges = new std::vector<const LineString*>();
More information about the geos-commits
mailing list