• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

NodeMap.h

00001 /**********************************************************************
00002  * $Id: NodeMap.h 2773 2009-12-03 19:36:17Z 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 // Forward declarations
00036 namespace geos {
00037         namespace geomgraph {
00038                 class Node;
00039                 class EdgeEnd;
00040                 class NodeFactory;
00041         }
00042 }
00043 
00044 namespace geos {
00045 namespace geomgraph { // geos.geomgraph
00046 
00047 class GEOS_DLL NodeMap{
00048 public:
00049 
00050         typedef std::map<geom::Coordinate*,Node*,geom::CoordinateLessThen> container;
00051 
00052         typedef container::iterator iterator;
00053 
00054         typedef container::const_iterator const_iterator;
00055 
00056         typedef std::pair<geom::Coordinate*,Node*> pair;
00057 
00058         container nodeMap;
00059 
00060         const NodeFactory &nodeFact;
00061 
00065         NodeMap(const NodeFactory &newNodeFact);
00066 
00067         virtual ~NodeMap();
00068 
00069         Node* addNode(const geom::Coordinate& coord);
00070 
00071         Node* addNode(Node *n);
00072 
00073         void add(EdgeEnd *e);
00074 
00075         Node *find(const geom::Coordinate& coord) const;
00076 
00077         const_iterator begin() const { return nodeMap.begin(); }
00078 
00079         const_iterator end() const { return nodeMap.end(); }
00080 
00081         iterator begin() { return nodeMap.begin(); }
00082 
00083         iterator end() { return nodeMap.end(); }
00084 
00085         void getBoundaryNodes(int geomIndex,
00086                 std::vector<Node*>&bdyNodes) const;
00087 
00088         std::string print() const;
00089 
00090         void testInvariant()
00091         {
00092 #ifndef NDEBUG
00093                 // Each Coordinate key is a pointer inside the Node value
00094                 for (iterator it=begin(), itEnd=end(); it != itEnd; ++it)
00095                 {
00096                         pair p = *it;
00097                         geomgraph::Node* n = p.second;
00098                         geom::Coordinate* c = const_cast<geom::Coordinate*>(
00099                                 &(n->getCoordinate())
00100                         );
00101                         assert(p.first == c);
00102                 }
00103 #endif
00104         }
00105 
00106 private:
00107 
00108     // Declare type as noncopyable
00109     NodeMap(const NodeMap& other);
00110     NodeMap& operator=(const NodeMap& rhs);
00111 };
00112 
00113 } // namespace geos.geomgraph
00114 } // namespace geos
00115 
00116 //#ifdef GEOS_INLINE
00117 //# include "geos/geomgraph/NodeMap.inl"
00118 //#endif
00119 
00120 #endif // ifndef GEOS_GEOMGRAPH_NODEMAP_H
00121 
00122 /**********************************************************************
00123  * $Log$
00124  * Revision 1.3  2006/05/04 12:54:26  strk
00125  * Added invariant tester for NodeMap class, fixed comment about ownership of NodeFactory
00126  *
00127  * Revision 1.2  2006/03/24 09:52:41  strk
00128  * USE_INLINE => GEOS_INLINE
00129  *
00130  * Revision 1.1  2006/03/09 16:46:49  strk
00131  * geos::geom namespace definition, first pass at headers split
00132  *
00133  **********************************************************************/
00134 

Generated on Thu Jul 22 2010 for GEOS by  doxygen 1.7.1