GEOS 3.3.4

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

- File List

geomgraph/NodeMap.h
1 /**********************************************************************
2 * $Id: NodeMap.h 2958 2010-03-29 11:29:40Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2005-2006 Refractions Research Inc.
8 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************
16 *
17 * Last port: geomgraph/NodeMap.java rev. 1.3 (JTS-1.10)
18 *
19 **********************************************************************/
20
21
22 #ifndef GEOS_GEOMGRAPH_NODEMAP_H
23 #define GEOS_GEOMGRAPH_NODEMAP_H
24
25 #include <geos/export.h>
26 #include <map>
27 #include <vector>
28 #include <string>
29
30 #include <geos/geom/Coordinate.h> // for CoordinateLessThen
31 #include <geos/geomgraph/Node.h> // for testInvariant
32
33 #include <geos/inline.h>
34
35 #ifdef _MSC_VER
36 #pragma warning(push)
37 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
38 #endif
39
40 // Forward declarations
41 namespace geos {
42 namespace geomgraph {
43 class Node;
44 class EdgeEnd;
45 class NodeFactory;
46 }
47 }
48
49 namespace geos {
50 namespace geomgraph { // geos.geomgraph
51
52 class GEOS_DLL NodeMap{
53 public:
54
55 typedef std::map<geom::Coordinate*,Node*,geom::CoordinateLessThen> container;
56
57 typedef container::iterator iterator;
58
59 typedef container::const_iterator const_iterator;
60
61 typedef std::pair<geom::Coordinate*,Node*> pair;
62
63 container nodeMap;
64
65 const NodeFactory &nodeFact;
66
70 NodeMap(const NodeFactory &newNodeFact);
71
72 virtual ~NodeMap();
73
74 Node* addNode(const geom::Coordinate& coord);
75
76 Node* addNode(Node *n);
77
78 void add(EdgeEnd *e);
79
80 Node *find(const geom::Coordinate& coord) const;
81
82 const_iterator begin() const { return nodeMap.begin(); }
83
84 const_iterator end() const { return nodeMap.end(); }
85
86 iterator begin() { return nodeMap.begin(); }
87
88 iterator end() { return nodeMap.end(); }
89
90 void getBoundaryNodes(int geomIndex,
91 std::vector<Node*>&bdyNodes) const;
92
93 std::string print() const;
94
95 void testInvariant()
96 {
97 #ifndef NDEBUG
98 // Each Coordinate key is a pointer inside the Node value
99 for (iterator it=begin(), itEnd=end(); it != itEnd; ++it)
100 {
101 pair p = *it;
102 geomgraph::Node* n = p.second;
103 geom::Coordinate* c = const_cast<geom::Coordinate*>(
104 &(n->getCoordinate())
105 );
106 assert(p.first == c);
107 }
108 #endif
109 }
110
111 private:
112
113 // Declare type as noncopyable
114 NodeMap(const NodeMap& other);
115 NodeMap& operator=(const NodeMap& rhs);
116 };
117
118 } // namespace geos.geomgraph
119 } // namespace geos
120
121 //#ifdef GEOS_INLINE
122 //# include "geos/geomgraph/NodeMap.inl"
123 //#endif
124
125 #ifdef _MSC_VER
126 #pragma warning(pop)
127 #endif
128
129 #endif // ifndef GEOS_GEOMGRAPH_NODEMAP_H
130
131 /**********************************************************************
132 * $Log$
133 * Revision 1.3 2006/05/04 12:54:26 strk
134 * Added invariant tester for NodeMap class, fixed comment about ownership of NodeFactory
135 *
136 * Revision 1.2 2006/03/24 09:52:41 strk
137 * USE_INLINE => GEOS_INLINE
138 *
139 * Revision 1.1 2006/03/09 16:46:49 strk
140 * geos::geom namespace definition, first pass at headers split
141 *
142 **********************************************************************/
143