Changeset 2727


Ignore:
Timestamp:
Nov 19, 2009, 11:31:43 AM (15 years ago)
Author:
strk
Message:

Don't force heap-allocation of vectors for finding/labeling edge rings

Location:
trunk/source
Files:
2 edited

Legend:

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

    r2726 r2727  
    144144         *      the list of start edges for the edgeRings to convert.
    145145         *
    146          * TODO: take ringEdges by ref
    147146         */
    148147        void convertMaximalToMinimalEdgeRings(
    149                         std::vector<PolygonizeDirectedEdge*> *ringEdges);
     148                        std::vector<PolygonizeDirectedEdge*> &ringEdges);
    150149
    151150        /**
     
    164163
    165164        /**
    166          * @param dirEdges a List of the DirectedEdges in the graph
    167          * @return a List of DirectedEdges, one for each edge ring found
    168          */
    169         static std::vector<PolygonizeDirectedEdge*>* findLabeledEdgeRings(
    170                         std::vector<planargraph::DirectedEdge*> &dirEdges);
     165         * Finds and labels all edgerings in the graph.
     166         *
     167         * The edge rings are labelling with unique integers.
     168         * The labelling allows detecting cut edges.
     169         *
     170         * @param dirEdgesIn  a list of the DirectedEdges in the graph
     171         * @param dirEdgesOut each ring found will be pushed here
     172         */
     173        static void findLabeledEdgeRings(
     174                        std::vector<planargraph::DirectedEdge*> &dirEdgesIn,
     175                        std::vector<PolygonizeDirectedEdge*> &dirEdgesOut);
    171176
    172177        static void label(std::vector<planargraph::DirectedEdge*> &dirEdges, long label);
  • trunk/source/operation/polygonize/PolygonizeGraph.cpp

    r2726 r2727  
    172172void
    173173PolygonizeGraph::convertMaximalToMinimalEdgeRings(
    174                 std::vector<PolygonizeDirectedEdge*> *ringEdges)
     174                std::vector<PolygonizeDirectedEdge*> &ringEdges)
    175175{
    176176        typedef std::vector<Node*> IntersectionNodes;
     
    178178
    179179        IntersectionNodes intNodes;
    180         for(RingEdges::size_type i=0, in=ringEdges->size();
     180        for(RingEdges::size_type i=0, in=ringEdges.size();
    181181                        i<in; ++i)
    182182        {
    183                 PolygonizeDirectedEdge *de=(*ringEdges)[i];
     183                PolygonizeDirectedEdge *de = ringEdges[i];
    184184                long label=de->getLabel();
    185185                findIntersectionNodes(de, label, intNodes);
     
    225225        // clear labels of all edges in graph
    226226        label(dirEdges, -1);
    227         std::vector<PolygonizeDirectedEdge*> *maximalRings=findLabeledEdgeRings(dirEdges);
     227        std::vector<PolygonizeDirectedEdge*> maximalRings;
     228        findLabeledEdgeRings(dirEdges, maximalRings);
    228229        convertMaximalToMinimalEdgeRings(maximalRings);
    229         delete maximalRings;
     230        maximalRings.clear(); // not needed anymore
    230231
    231232        // find all edgerings
     
    240241}
    241242
    242 /**
    243 *
    244 * @param dirEdges a List of the DirectedEdges in the graph
    245 * @return a List of DirectedEdges, one for each edge ring found
    246 */
    247 std::vector<PolygonizeDirectedEdge*>*
    248 PolygonizeGraph::findLabeledEdgeRings(std::vector<DirectedEdge*> &dirEdges)
    249 {
    250         std::vector<PolygonizeDirectedEdge*> *edgeRingStarts=new std::vector<PolygonizeDirectedEdge*>();
     243/* static private */
     244void
     245PolygonizeGraph::findLabeledEdgeRings(std::vector<DirectedEdge*> &dirEdges,
     246                std::vector<PolygonizeDirectedEdge*> &edgeRingStarts)
     247{
    251248        // label the edge rings formed
    252249        long currLabel=1;
     
    256253                if (de->isMarked()) continue;
    257254                if (de->getLabel() >= 0) continue;
    258                 edgeRingStarts->push_back(de);
     255                edgeRingStarts.push_back(de);
    259256                std::vector<DirectedEdge*> *edges=findDirEdgesInRing(de);
    260257                label(*edges, currLabel);
     
    262259                ++currLabel;
    263260        }
    264         return edgeRingStarts;
    265261}
    266262
     
    275271
    276272        // label the current set of edgerings
    277         delete findLabeledEdgeRings(dirEdges);
     273        std::vector<PolygonizeDirectedEdge*> junk;
     274        findLabeledEdgeRings(dirEdges, junk);
     275        junk.clear(); // not needed anymore
    278276
    279277        /*
Note: See TracChangeset for help on using the changeset viewer.