• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

Node.h

00001 /**********************************************************************
00002  * $Id: Node.h 2557 2009-06-08 09:30:55Z strk $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
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 rev. 1.7 (JTS-1.10)
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 // Forward declarations
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 { // geos.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* /*im*/) {};
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                 // Each EdgeEnd in the star has this Node's 
00156                 // coordinate as first coordinate
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         // ztot is the sum of doubnle sin zvals vector
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 } // namespace geos.geomgraph
00185 } // namespace geos
00186 
00187 //#ifdef GEOS_INLINE
00188 //# include "geos/geomgraph/Node.inl"
00189 //#endif
00190 
00191 #endif // ifndef GEOS_GEOMGRAPH_NODE_H
00192 
00193 /**********************************************************************
00194  * $Log$
00195  * Revision 1.6  2006/06/01 11:49:36  strk
00196  * Reduced installed headers form geomgraph namespace
00197  *
00198  * Revision 1.5  2006/04/27 15:15:06  strk
00199  * Z check removed from invariant tester to avoid aborts due to differences in FP computations.
00200  *
00201  * Revision 1.4  2006/04/07 16:01:51  strk
00202  * Port info, doxygen comments, testInvariant(), many assertionss, handling of
00203  * the NULL EdgeEndStar member
00204  *
00205  * Revision 1.3  2006/03/24 09:52:41  strk
00206  * USE_INLINE => GEOS_INLINE
00207  *
00208  * Revision 1.2  2006/03/15 16:27:54  strk
00209  * operator<< for Node class
00210  *
00211  * Revision 1.1  2006/03/09 16:46:49  strk
00212  * geos::geom namespace definition, first pass at headers split
00213  *
00214  **********************************************************************/
00215 

Generated on Thu Jul 22 2010 for GEOS by  doxygen 1.7.1