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 #ifdef _MSC_VER
00040 #pragma warning(push)
00041 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00042 #endif
00043
00044
00045 namespace geos {
00046 namespace geom {
00047 class IntersectionMatrix;
00048 }
00049 namespace geomgraph {
00050 class Node;
00051 class EdgeEndStar;
00052 class EdgeEnd;
00053 class Label;
00054 class NodeFactory;
00055 }
00056 }
00057
00058 namespace geos {
00059 namespace geomgraph {
00060
00061 class GEOS_DLL Node: public GraphComponent {
00062 using GraphComponent::setLabel;
00063
00064 public:
00065
00066 friend std::ostream& operator<< (std::ostream& os, const Node& node);
00067
00068 Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
00069
00070 virtual ~Node();
00071
00072 virtual const geom::Coordinate& getCoordinate() const;
00073
00074 virtual EdgeEndStar* getEdges();
00075
00076 virtual bool isIsolated() const;
00077
00081 virtual void add(EdgeEnd *e);
00082
00083 virtual void mergeLabel(const Node& n);
00084
00092 virtual void mergeLabel(const Label& label2);
00093
00094 virtual void setLabel(int argIndex, int onLocation);
00095
00100 virtual void setLabelBoundary(int argIndex);
00101
00110 virtual int computeMergedLocation(const Label* label2, int eltIndex);
00111
00112 virtual std::string print();
00113
00114 virtual const std::vector<double> &getZ() const;
00115
00116 virtual void addZ(double);
00117
00129 virtual bool isIncidentEdgeInResult() const;
00130
00131 protected:
00132
00133 void testInvariant() const;
00134
00135 geom::Coordinate coord;
00136
00137 EdgeEndStar* edges;
00138
00142 virtual void computeIM(geom::IntersectionMatrix* ) {};
00143
00144 private:
00145
00146 std::vector<double> zvals;
00147
00148 double ztot;
00149
00150 };
00151
00152 std::ostream& operator<< (std::ostream& os, const Node& node);
00153
00154 inline void
00155 Node::testInvariant() const
00156 {
00157 #ifndef NDEBUG
00158 if (edges)
00159 {
00160
00161
00162 for (EdgeEndStar::iterator
00163 it=edges->begin(), itEnd=edges->end();
00164 it != itEnd; it++)
00165 {
00166 EdgeEnd* e=*it;
00167 assert(e);
00168 assert(e->getCoordinate().equals2D(coord));
00169 }
00170 }
00171
00172 #if 0 // We can't rely on numerical stability with FP computations
00173
00174 double ztot_check=0.0;
00175 for (std::vector<double>::const_iterator
00176 i = zvals.begin(), e = zvals.end();
00177 i != e;
00178 i++)
00179 {
00180 ztot_check += *i;
00181 }
00182 assert(ztot_check == ztot);
00183 #endif // 0
00184
00185 #endif
00186 }
00187
00188
00189 }
00190 }
00191
00192
00193
00194
00195
00196 #ifdef _MSC_VER
00197 #pragma warning(pop)
00198 #endif
00199
00200 #endif // ifndef GEOS_GEOMGRAPH_NODE_H
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224