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

geomgraph/NodeMap.h

00001 /**********************************************************************
00002  * $Id: NodeMap.h 2958 2010-03-29 11:29:40Z mloskot $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2005-2006 Refractions Research Inc.
00008  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00009  *
00010  * This is free software; you can redistribute and/or modify it under
00011  * the terms of the GNU Lesser General Public Licence as published
00012  * by the Free Software Foundation. 
00013  * See the COPYING file for more information.
00014  *
00015  **********************************************************************
00016  *
00017  * Last port: geomgraph/NodeMap.java rev. 1.3 (JTS-1.10)
00018  *
00019  **********************************************************************/
00020 
00021 
00022 #ifndef GEOS_GEOMGRAPH_NODEMAP_H
00023 #define GEOS_GEOMGRAPH_NODEMAP_H
00024 
00025 #include <geos/export.h>
00026 #include <map>
00027 #include <vector>
00028 #include <string>
00029 
00030 #include <geos/geom/Coordinate.h> // for CoordinateLessThen
00031 #include <geos/geomgraph/Node.h> // for testInvariant
00032 
00033 #include <geos/inline.h>
00034 
00035 #ifdef _MSC_VER
00036 #pragma warning(push)
00037 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00038 #endif
00039 
00040 // Forward declarations
00041 namespace geos {
00042         namespace geomgraph {
00043                 class Node;
00044                 class EdgeEnd;
00045                 class NodeFactory;
00046         }
00047 }
00048 
00049 namespace geos {
00050 namespace geomgraph { // geos.geomgraph
00051 
00052 class GEOS_DLL NodeMap{
00053 public:
00054 
00055         typedef std::map<geom::Coordinate*,Node*,geom::CoordinateLessThen> container;
00056 
00057         typedef container::iterator iterator;
00058 
00059         typedef container::const_iterator const_iterator;
00060 
00061         typedef std::pair<geom::Coordinate*,Node*> pair;
00062 
00063         container nodeMap;
00064 
00065         const NodeFactory &nodeFact;
00066 
00070         NodeMap(const NodeFactory &newNodeFact);
00071 
00072         virtual ~NodeMap();
00073 
00074         Node* addNode(const geom::Coordinate& coord);
00075 
00076         Node* addNode(Node *n);
00077 
00078         void add(EdgeEnd *e);
00079 
00080         Node *find(const geom::Coordinate& coord) const;
00081 
00082         const_iterator begin() const { return nodeMap.begin(); }
00083 
00084         const_iterator end() const { return nodeMap.end(); }
00085 
00086         iterator begin() { return nodeMap.begin(); }
00087 
00088         iterator end() { return nodeMap.end(); }
00089 
00090         void getBoundaryNodes(int geomIndex,
00091                 std::vector<Node*>&bdyNodes) const;
00092 
00093         std::string print() const;
00094 
00095         void testInvariant()
00096         {
00097 #ifndef NDEBUG
00098                 // Each Coordinate key is a pointer inside the Node value
00099                 for (iterator it=begin(), itEnd=end(); it != itEnd; ++it)
00100                 {
00101                         pair p = *it;
00102                         geomgraph::Node* n = p.second;
00103                         geom::Coordinate* c = const_cast<geom::Coordinate*>(
00104                                 &(n->getCoordinate())
00105                         );
00106                         assert(p.first == c);
00107                 }
00108 #endif
00109         }
00110 
00111 private:
00112 
00113     // Declare type as noncopyable
00114     NodeMap(const NodeMap& other);
00115     NodeMap& operator=(const NodeMap& rhs);
00116 };
00117 
00118 } // namespace geos.geomgraph
00119 } // namespace geos
00120 
00121 //#ifdef GEOS_INLINE
00122 //# include "geos/geomgraph/NodeMap.inl"
00123 //#endif
00124 
00125 #ifdef _MSC_VER
00126 #pragma warning(pop)
00127 #endif
00128 
00129 #endif // ifndef GEOS_GEOMGRAPH_NODEMAP_H
00130 
00131 /**********************************************************************
00132  * $Log$
00133  * Revision 1.3  2006/05/04 12:54:26  strk
00134  * Added invariant tester for NodeMap class, fixed comment about ownership of NodeFactory
00135  *
00136  * Revision 1.2  2006/03/24 09:52:41  strk
00137  * USE_INLINE => GEOS_INLINE
00138  *
00139  * Revision 1.1  2006/03/09 16:46:49  strk
00140  * geos::geom namespace definition, first pass at headers split
00141  *
00142  **********************************************************************/
00143 

Generated on Tue Jun 5 14:58:08 2012 for GEOS by  doxygen 1.3.9.1