Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

SegmentNodeList.h

00001 /**********************************************************************
00002  * $Id: SegmentNodeList.h 2556 2009-06-06 22:22:28Z strk $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2006      Refractions Research Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************
00015  *
00016  * Last port: noding/SegmentNodeList.java rev. 1.8 (JTS-1.10)
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef GEOS_NODING_SEGMENTNODELIST_H
00021 #define GEOS_NODING_SEGMENTNODELIST_H
00022 
00023 #include <geos/export.h>
00024 
00025 #include <geos/inline.h>
00026 
00027 #include <cassert>
00028 #include <iostream>
00029 #include <vector>
00030 #include <set>
00031 
00032 #include <geos/noding/SegmentNode.h> // for composition
00033 
00034 // Forward declarations
00035 namespace geos {
00036         namespace geom {
00037                 class CoordinateSequence;
00038         }
00039         namespace noding {
00040                 class SegmentString;
00041                 class NodedSegmentString;
00042         }
00043 }
00044 
00045 namespace geos {
00046 namespace noding { // geos::noding
00047 
00052 class GEOS_DLL SegmentNodeList {
00053 private:
00054         std::set<SegmentNode*,SegmentNodeLT> nodeMap;
00055 
00056         // the parent edge
00057         const NodedSegmentString& edge; 
00058 
00059         // This vector is here to keep track of created splitEdges
00060         std::vector<SegmentString*> splitEdges;
00061 
00062         // This vector is here to keep track of created Coordinates
00063         std::vector<geom::CoordinateSequence*> splitCoordLists;
00064 
00071         void checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges);
00072 
00079         SegmentString* createSplitEdge(SegmentNode *ei0, SegmentNode *ei1);
00080 
00089         void addCollapsedNodes();
00090 
00095         void findCollapsesFromExistingVertices(
00096                         std::vector<size_t>& collapsedVertexIndexes);
00097 
00105         void findCollapsesFromInsertedNodes(
00106                 std::vector<size_t>& collapsedVertexIndexes);
00107 
00108         bool findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1,
00109                 size_t& collapsedVertexIndex);
00110 public:
00111 
00112         friend std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
00113 
00114         typedef std::set<SegmentNode*,SegmentNodeLT> container;
00115         typedef container::iterator iterator;
00116         typedef container::const_iterator const_iterator;
00117 
00118         SegmentNodeList(const NodedSegmentString* newEdge): edge(*newEdge) {}
00119 
00120         SegmentNodeList(const NodedSegmentString& newEdge): edge(newEdge) {}
00121 
00122         const NodedSegmentString& getEdge() const { return edge; }
00123 
00124         // TODO: Is this a final class ?
00125         // Should remove the virtual in that case
00126         virtual ~SegmentNodeList();
00127 
00138         SegmentNode* add(const geom::Coordinate& intPt, size_t segmentIndex);
00139 
00140         SegmentNode* add(const geom::Coordinate *intPt, size_t segmentIndex) {
00141                 return add(*intPt, segmentIndex);
00142         }
00143 
00144         /*
00145          * returns the set of SegmentNodes
00146          */
00147         //replaces iterator()
00148         // TODO: obsolete this function
00149         std::set<SegmentNode*,SegmentNodeLT>* getNodes() { return &nodeMap; }
00150 
00152         size_t size() const { return nodeMap.size(); }
00153 
00154         container::iterator begin() { return nodeMap.begin(); }
00155         container::const_iterator begin() const { return nodeMap.begin(); }
00156         container::iterator end() { return nodeMap.end(); }
00157         container::const_iterator end() const { return nodeMap.end(); }
00158 
00162         void addEndpoints();
00163 
00170         void addSplitEdges(std::vector<SegmentString*>& edgeList);
00171 
00172         void addSplitEdges(std::vector<SegmentString*>* edgeList) {
00173                 assert(edgeList);
00174                 addSplitEdges(*edgeList);
00175         }
00176 
00177         //string print();
00178 };
00179 
00180 std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
00181 
00182 } // namespace geos::noding
00183 } // namespace geos
00184 
00185 //#ifdef GEOS_INLINE
00186 //# include "geos/noding/SegmentNodeList.inl"
00187 //#endif
00188 
00189 #endif
00190 
00191 /**********************************************************************
00192  * $Log$
00193  * Revision 1.4  2006/06/12 11:29:23  strk
00194  * unsigned int => size_t
00195  *
00196  * Revision 1.3  2006/05/04 07:41:56  strk
00197  * const-correct size() method for SegmentNodeList
00198  *
00199  * Revision 1.2  2006/03/24 09:52:41  strk
00200  * USE_INLINE => GEOS_INLINE
00201  *
00202  * Revision 1.1  2006/03/09 16:46:49  strk
00203  * geos::geom namespace definition, first pass at headers split
00204  *
00205  **********************************************************************/
00206 

Generated on Thu Jun 11 06:17:01 2009 for GEOS by  doxygen 1.4.4