00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GEOS_GEOMGRAPH_NODE_H
00023 #define GEOS_GEOMGRAPH_NODE_H
00024
00025 #include <geos/export.h>
00026 #include <geos/geomgraph/GraphComponent.h>
00027 #include <geos/geom/Coordinate.h>
00028
00029 #ifndef NDEBUG
00030 #include <geos/geomgraph/EdgeEndStar.h>
00031 #include <geos/geomgraph/EdgeEnd.h>
00032 #endif // ndef NDEBUG
00033
00034 #include <geos/inline.h>
00035
00036 #include <cassert>
00037 #include <string>
00038
00039
00040 namespace geos {
00041 namespace geom {
00042 class IntersectionMatrix;
00043 }
00044 namespace geomgraph {
00045 class Node;
00046 class EdgeEndStar;
00047 class EdgeEnd;
00048 class Label;
00049 class NodeFactory;
00050 }
00051 }
00052
00053 namespace geos {
00054 namespace geomgraph {
00055
00056 class GEOS_DLL Node: public GraphComponent {
00057 using GraphComponent::setLabel;
00058
00059 public:
00060
00061 friend std::ostream& operator<< (std::ostream& os, const Node& node);
00062
00063 Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
00064
00065 virtual ~Node();
00066
00067 virtual const geom::Coordinate& getCoordinate() const;
00068
00069 virtual EdgeEndStar* getEdges();
00070
00071 virtual bool isIsolated() const;
00072
00076 virtual void add(EdgeEnd *e);
00077
00078 virtual void mergeLabel(const Node& n);
00079
00087 virtual void mergeLabel(const Label& label2);
00088
00089 virtual void setLabel(int argIndex, int onLocation);
00090
00095 virtual void setLabelBoundary(int argIndex);
00096
00105 virtual int computeMergedLocation(const Label* label2, int eltIndex);
00106
00107 virtual std::string print();
00108
00109 virtual const std::vector<double> &getZ() const;
00110
00111 virtual void addZ(double);
00112
00124 virtual bool isIncidentEdgeInResult() const;
00125
00126 protected:
00127
00128 void testInvariant() const;
00129
00130 geom::Coordinate coord;
00131
00132 EdgeEndStar* edges;
00133
00137 virtual void computeIM(geom::IntersectionMatrix* ) {};
00138
00139 private:
00140
00141 std::vector<double> zvals;
00142
00143 double ztot;
00144
00145 };
00146
00147 std::ostream& operator<< (std::ostream& os, const Node& node);
00148
00149 inline void
00150 Node::testInvariant() const
00151 {
00152 #ifndef NDEBUG
00153 if (edges)
00154 {
00155
00156
00157 for (EdgeEndStar::iterator
00158 it=edges->begin(), itEnd=edges->end();
00159 it != itEnd; it++)
00160 {
00161 EdgeEnd* e=*it;
00162 assert(e);
00163 assert(e->getCoordinate().equals2D(coord));
00164 }
00165 }
00166
00167 #if 0 // We can't rely on numerical stability with FP computations
00168
00169 double ztot_check=0.0;
00170 for (std::vector<double>::const_iterator
00171 i = zvals.begin(), e = zvals.end();
00172 i != e;
00173 i++)
00174 {
00175 ztot_check += *i;
00176 }
00177 assert(ztot_check == ztot);
00178 #endif // 0
00179
00180 #endif
00181 }
00182
00183
00184 }
00185 }
00186
00187
00188
00189
00190
00191 #endif // ifndef GEOS_GEOMGRAPH_NODE_H
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215