Node.h

00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
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/Node.java r411 (JTS-1.12+)
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> // for inheritance
00027 #include <geos/geom/Coordinate.h> // for member
00028 
00029 #ifndef NDEBUG
00030 #include <geos/geomgraph/EdgeEndStar.h> // for testInvariant
00031 #include <geos/geomgraph/EdgeEnd.h> // for testInvariant
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 // Forward declarations
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 { // geos.geomgraph
00060 
00062 class GEOS_DLL Node: public GraphComponent {
00063 using GraphComponent::setLabel;
00064 
00065 public:
00066 
00067         friend std::ostream& operator<< (std::ostream& os, const Node& node);
00068 
00069         Node(const geom::Coordinate& newCoord, EdgeEndStar* newEdges);
00070 
00071         virtual ~Node();
00072 
00073         virtual const geom::Coordinate& getCoordinate() const;
00074 
00075         virtual EdgeEndStar* getEdges();
00076 
00077         virtual bool isIsolated() const;
00078 
00082         virtual void add(EdgeEnd *e);
00083 
00084         virtual void mergeLabel(const Node& n);
00085 
00093         virtual void mergeLabel(const Label& label2);
00094 
00095         virtual void setLabel(int argIndex, int onLocation);
00096 
00101         virtual void setLabelBoundary(int argIndex);
00102 
00111         virtual int computeMergedLocation(const Label& label2, int eltIndex);
00112 
00113         virtual std::string print();
00114 
00115         virtual const std::vector<double> &getZ() const;
00116 
00117         virtual void addZ(double);
00118 
00130         virtual bool isIncidentEdgeInResult() const;
00131 
00132 protected:
00133 
00134         void testInvariant() const;
00135 
00136         geom::Coordinate coord;
00137 
00138         EdgeEndStar* edges;
00139 
00143         virtual void computeIM(geom::IntersectionMatrix& /*im*/) {}
00144 
00145 private:
00146 
00147         std::vector<double> zvals;
00148 
00149         double ztot;
00150 
00151 };
00152 
00153 std::ostream& operator<< (std::ostream& os, const Node& node);
00154 
00155 inline void
00156 Node::testInvariant() const
00157 {
00158 #ifndef NDEBUG
00159         if (edges)
00160         {
00161                 // Each EdgeEnd in the star has this Node's 
00162                 // coordinate as first coordinate
00163                 for (EdgeEndStar::iterator
00164                                 it=edges->begin(), itEnd=edges->end();
00165                                 it != itEnd; it++) 
00166                 {
00167                         EdgeEnd* e=*it;
00168                         assert(e);
00169                         assert(e->getCoordinate().equals2D(coord));
00170                 }
00171         }
00172 
00173 #if 0 // We can't rely on numerical stability with FP computations
00174         // ztot is the sum of doubnle sin zvals vector
00175         double ztot_check=0.0;
00176         for (std::vector<double>::const_iterator 
00177                         i = zvals.begin(), e = zvals.end();
00178                         i != e;
00179                         i++)
00180         {
00181                 ztot_check += *i;
00182         }
00183         assert(ztot_check == ztot);
00184 #endif // 0
00185 
00186 #endif
00187 }
00188 
00189 
00190 } // namespace geos.geomgraph
00191 } // namespace geos
00192 
00193 //#ifdef GEOS_INLINE
00194 //# include "geos/geomgraph/Node.inl"
00195 //#endif
00196 
00197 #ifdef _MSC_VER
00198 #pragma warning(pop)
00199 #endif
00200 
00201 #endif // ifndef GEOS_GEOMGRAPH_NODE_H

Generated on 30 Dec 2015 for GEOS by  doxygen 1.4.7