Changeset 2730


Ignore:
Timestamp:
Nov 19, 2009, 12:29:01 PM (15 years ago)
Author:
strk
Message:

Don't force heap allocation of std::vector in PolygonizeGraph when deleting dangles (moved allocation higher, in Polygonizer, so needs a second pass)

Location:
trunk/source
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/headers/geos/operation/polygonize/PolygonizeGraph.h

    r2729 r2730  
    123123         * an explicit recursion stack is used
    124124         *
    125          * @return a List containing the LineStrings that formed dangles
    126          */
    127         std::vector<const geom::LineString*>* deleteDangles();
     125         * @param dangleLines : the LineStrings that formed dangles will
     126         *                      be push_back'ed here
     127         */
     128        void deleteDangles(std::vector<const geom::LineString*> &dangleLines);
    128129
    129130private:
  • trunk/source/operation/polygonize/PolygonizeGraph.cpp

    r2729 r2730  
    441441}
    442442
    443 /**
    444  * Marks all edges from the graph which are "dangles".
    445  * Dangles are which are incident on a node with degree 1.
    446  * This process is recursive, since removing a dangling edge
    447  * may result in another edge becoming a dangle.
    448  * In order to handle large recursion depths efficiently,
    449  * an explicit recursion stack is used
    450  *
    451  * @return a List containing the LineStrings that formed dangles
    452  */
    453 std::vector<const LineString*>*
    454 PolygonizeGraph::deleteDangles()
     443/* public */
     444void
     445PolygonizeGraph::deleteDangles(std::vector<const LineString*>& dangleLines)
    455446{
    456447        std::vector<Node*> *nodesToRemove=findNodesOfDegree(1);
    457         std::vector<const LineString*> *dangleLines=new std::vector<const LineString*>();
    458448        std::vector<Node*> nodeStack;
    459449        for(int i=0;i<(int)nodesToRemove->size();i++) {
     
    476466                        // save the line as a dangle
    477467                        PolygonizeEdge *e=(PolygonizeEdge*) de->getEdge();
    478                         dangleLines->push_back(e->getLine());
     468                        dangleLines.push_back(e->getLine());
    479469                        Node *toNode=de->getToNode();
    480470                        // add the toNode to the list to be processed, if it is now a dangle
     
    483473                }
    484474        }
    485         return dangleLines;
    486475}
    487476
  • trunk/source/operation/polygonize/Polygonizer.cpp

    r2728 r2730  
    235235        if (graph==NULL) return;
    236236
    237         dangles=graph->deleteDangles();
     237        // TODO: drop this heap allocation
     238        dangles = new std::vector<const LineString*>();
     239        graph->deleteDangles(*dangles);
    238240
    239241        // TODO: drop this heap allocation
Note: See TracChangeset for help on using the changeset viewer.