GEOS: SegmentNodeList.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

# SegmentNodeList.h

    00001 /**********************************************************************
    00002  * $Id: SegmentNodeList.h 3255 2011-03-01 17:56:10Z mloskot $
    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 #ifdef _MSC_VER
    00035 #pragma warning(push)
    00036 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
    00037 #endif
    00038
    00039 // Forward declarations
    00040 namespace geos {
    00041         namespace geom {
    00042                 class CoordinateSequence;
    00043         }
    00044         namespace noding {
    00045                 class SegmentString;
    00046                 class NodedSegmentString;
    00047         }
    00048 }
    00049
    00050 namespace geos {
    00051 namespace noding { // geos::noding
    00052
    00057 class GEOS_DLL SegmentNodeList {
    00058 private:
    00059         std::set<SegmentNode*,SegmentNodeLT> nodeMap;
    00060
    00061         // the parent edge
    00062         const NodedSegmentString& edge;
    00063
    00064         // This vector is here to keep track of created splitEdges
    00065         std::vector<SegmentString*> splitEdges;
    00066
    00067         // This vector is here to keep track of created Coordinates
    00068         std::vector<geom::CoordinateSequence*> splitCoordLists;
    00069
    00076         void checkSplitEdgesCorrectness(std::vector<SegmentString*>& splitEdges);
    00077
    00084         SegmentString* createSplitEdge(SegmentNode *ei0, SegmentNode *ei1);
    00085
    00094         void addCollapsedNodes();
    00095
    00100         void findCollapsesFromExistingVertices(
    00101                         std::vector<std::size_t>& collapsedVertexIndexes);
    00102
    00110         void findCollapsesFromInsertedNodes(
    00111                 std::vector<std::size_t>& collapsedVertexIndexes);
    00112
    00113         bool findCollapseIndex(SegmentNode& ei0, SegmentNode& ei1,
    00114                 size_t& collapsedVertexIndex);
    00115
    00116     // Declare type as noncopyable
    00117     SegmentNodeList(const SegmentNodeList& other);
    00118     SegmentNodeList& operator=(const SegmentNodeList& rhs);
    00119
    00120 public:
    00121
    00122         friend std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
    00123
    00124         typedef std::set<SegmentNode*,SegmentNodeLT> container;
    00125         typedef container::iterator iterator;
    00126         typedef container::const_iterator const_iterator;
    00127
    00128         SegmentNodeList(const NodedSegmentString* newEdge): edge(*newEdge) {}
    00129
    00130         SegmentNodeList(const NodedSegmentString& newEdge): edge(newEdge) {}
    00131
    00132         const NodedSegmentString& getEdge() const { return edge; }
    00133
    00134         // TODO: Is this a final class ?
    00135         // Should remove the virtual in that case
    00136         virtual ~SegmentNodeList();
    00137
    00148         SegmentNode* add(const geom::Coordinate& intPt, std::size_t segmentIndex);
    00149
    00150         SegmentNode* add(const geom::Coordinate *intPt, std::size_t segmentIndex) {
    00151                 return add(*intPt, segmentIndex);
    00152         }
    00153
    00154         /*
    00155          * returns the set of SegmentNodes
    00156          */
    00157         //replaces iterator()
    00158         // TODO: obsolete this function
    00159         std::set<SegmentNode*,SegmentNodeLT>* getNodes() { return &nodeMap; }
    00160
    00162         size_t size() const { return nodeMap.size(); }
    00163
    00164         container::iterator begin() { return nodeMap.begin(); }
    00165         container::const_iterator begin() const { return nodeMap.begin(); }
    00166         container::iterator end() { return nodeMap.end(); }
    00167         container::const_iterator end() const { return nodeMap.end(); }
    00168
    00172         void addEndpoints();
    00173
    00180         void addSplitEdges(std::vector<SegmentString*>& edgeList);
    00181
    00182         void addSplitEdges(std::vector<SegmentString*>* edgeList) {
    00183                 assert(edgeList);
    00184                 addSplitEdges(*edgeList);
    00185         }
    00186
    00187         //string print();
    00188 };
    00189
    00190 std::ostream& operator<< (std::ostream& os, const SegmentNodeList& l);
    00191
    00192 } // namespace geos::noding
    00193 } // namespace geos
    00194
    00195 #ifdef _MSC_VER
    00196 #pragma warning(pop)
    00197 #endif
    00198
    00199 //#ifdef GEOS_INLINE
    00200 //# include "geos/noding/SegmentNodeList.inl"
    00201 //#endif
    00202
    00203 #endif
    00204
    00205 /**********************************************************************
    00206  * $Log$
    00207  * Revision 1.4  2006/06/12 11:29:23  strk
    00208  * unsigned int => size_t
    00209  *
    00210  * Revision 1.3  2006/05/04 07:41:56  strk
    00211  * const-correct size() method for SegmentNodeList
    00212  *
    00213  * Revision 1.2  2006/03/24 09:52:41  strk
    00214  * USE_INLINE => GEOS_INLINE
    00215  *
    00216  * Revision 1.1  2006/03/09 16:46:49  strk
    00217  * geos::geom namespace definition, first pass at headers split
    00218  *
    00219  **********************************************************************/
    00220