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

NodedSegmentString.h

00001 /**********************************************************************
00002  * $Id: NodedSegmentString.h 2320 2009-04-08 09:42:55Z 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  *
00017  * Last port: noding/NodedSegmentString.java rev. 1.2 (JTS-1.9)
00018  *
00019  **********************************************************************/
00020 
00021 #ifndef GEOS_NODING_NODEDSEGMENTSTRING_H
00022 #define GEOS_NODING_NODEDSEGMENTSTRING_H
00023 
00024 #include <geos/noding/NodableSegmentString.h> // for inheritance
00025 #include <geos/geom/CoordinateSequence.h> // for inlines
00026 #include <geos/algorithm/LineIntersector.h>
00027 #include <geos/noding/SegmentNode.h>
00028 #include <geos/noding/SegmentNodeList.h>
00029 #include <geos/noding/SegmentString.h>
00030 //#include <geos/noding/Octant.h>
00031 #include <geos/geom/Coordinate.h>
00032 
00033 //using namespace 
00034 
00035 namespace geos {
00036 namespace noding { // geos::noding
00037 
00050 class NodedSegmentString : public NodableSegmentString 
00051 {
00052 public:
00053 
00054         static void getNodedSubstrings(SegmentString::ConstVect* segStrings,
00055                         SegmentString::NonConstVect* resultEdgelist)
00056         {
00057                 for (size_t i=0, n=segStrings->size(); i<n; i++)
00058                 {
00059                         NodedSegmentString * nss = (NodedSegmentString *)((*segStrings)[i]);
00060                         nss->getNodeList().addSplitEdges( resultEdgelist);
00061                 }
00062         }
00063 
00064         static void getNodedSubstrings(
00065                         const SegmentString::NonConstVect& segStrings,
00066                         SegmentString::NonConstVect* resultEdgeList);
00067 
00069         static SegmentString::NonConstVect* getNodedSubstrings(
00070                         const SegmentString::NonConstVect& segStrings);
00071 
00072 
00082         NodedSegmentString(geom::CoordinateSequence *newPts,
00083                         const void* newContext)
00084                 :
00085                 NodableSegmentString(newContext),
00086                 nodeList(this),
00087                 pts(newPts)
00088         { }
00089 
00090         ~NodedSegmentString()
00091         { }
00092 
00102         SegmentNode * addIntersectionNode( geom::Coordinate * intPt, size_t segmentIndex) 
00103         {
00104                 size_t normalizedSegmentIndex = segmentIndex;
00105 
00106                 // normalize the intersection point location
00107                 size_t nextSegIndex = normalizedSegmentIndex + 1;
00108                 if (nextSegIndex < size()) 
00109                 {
00110                         const geom::Coordinate &nextPt = getCoordinate( nextSegIndex);
00111 
00112                         // Normalize segment index if intPt falls on vertex
00113                         // The check for point equality is 2D only - Z values are ignored
00114                         if ( intPt->equals2D( nextPt )) 
00115                         {
00116                                 normalizedSegmentIndex = nextSegIndex;
00117                         }
00118                 }
00119 
00120                 // Add the intersection point to edge intersection list.
00121                 SegmentNode * ei = getNodeList().add( *intPt, normalizedSegmentIndex);
00122                 return ei;
00123         }
00124 
00125         SegmentNodeList& getNodeList();
00126 
00127         const SegmentNodeList& getNodeList() const;
00128 
00129         virtual unsigned int size() const
00130         {
00131                 return pts->size();
00132         }
00133 
00134         virtual const geom::Coordinate& getCoordinate(unsigned int i) const;
00135 
00136         virtual geom::CoordinateSequence* getCoordinates() const;
00137 
00138         virtual bool isClosed() const;
00139 
00140         virtual std::ostream& print(std::ostream& os) const;
00141 
00142 
00150         int getSegmentOctant(unsigned int index) const;
00151 
00157         void addIntersections(algorithm::LineIntersector *li,
00158                         unsigned int segmentIndex, int geomIndex);
00159 
00167         void addIntersection(algorithm::LineIntersector *li,
00168                         unsigned int segmentIndex,
00169                         int geomIndex, int intIndex);
00170 
00178         void addIntersection(const geom::Coordinate& intPt,
00179                         unsigned int segmentIndex);
00180 
00181 
00182 private:
00183 
00184         SegmentNodeList nodeList;
00185 
00186         geom::CoordinateSequence *pts;
00187 
00188 };
00189 
00190 } // namespace geos::noding
00191 } // namespace geos
00192 
00193 #endif // GEOS_NODING_NODEDSEGMENTSTRING_H
00194 /**********************************************************************
00195  * $Log$
00196  **********************************************************************/
00197 

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