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