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

Node.h

00001 /**********************************************************************
00002  * $Id: Node.h 2958 2010-03-29 11:29:40Z mloskot $
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 #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 
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* /*im*/) {};
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                 // Each EdgeEnd in the star has this Node's 
00161                 // coordinate as first coordinate
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         // ztot is the sum of doubnle sin zvals vector
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 } // namespace geos.geomgraph
00190 } // namespace geos
00191 
00192 //#ifdef GEOS_INLINE
00193 //# include "geos/geomgraph/Node.inl"
00194 //#endif
00195 
00196 #ifdef _MSC_VER
00197 #pragma warning(pop)
00198 #endif
00199 
00200 #endif // ifndef GEOS_GEOMGRAPH_NODE_H
00201 
00202 /**********************************************************************
00203  * $Log$
00204  * Revision 1.6  2006/06/01 11:49:36  strk
00205  * Reduced installed headers form geomgraph namespace
00206  *
00207  * Revision 1.5  2006/04/27 15:15:06  strk
00208  * Z check removed from invariant tester to avoid aborts due to differences in FP computations.
00209  *
00210  * Revision 1.4  2006/04/07 16:01:51  strk
00211  * Port info, doxygen comments, testInvariant(), many assertionss, handling of
00212  * the NULL EdgeEndStar member
00213  *
00214  * Revision 1.3  2006/03/24 09:52:41  strk
00215  * USE_INLINE => GEOS_INLINE
00216  *
00217  * Revision 1.2  2006/03/15 16:27:54  strk
00218  * operator<< for Node class
00219  *
00220  * Revision 1.1  2006/03/09 16:46:49  strk
00221  * geos::geom namespace definition, first pass at headers split
00222  *
00223  **********************************************************************/
00224 

Generated on Mon Jul 30 2012 19:12:26 for GEOS by  doxygen 1.7.2