GEOS: Node.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# Node.h

    00001 /**********************************************************************
    00002  * $Id: Node.h 1986 2007-06-08 15:27:42Z 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.6 (JTS-1.7)
    00018  *
    00019  **********************************************************************/
    00020
    00021
    00022 #ifndef GEOS_GEOMGRAPH_NODE_H
    00023 #define GEOS_GEOMGRAPH_NODE_H
    00024
    00025 #include <geos/geomgraph/GraphComponent.h> // for inheritance
    00026 #include <geos/geom/Coordinate.h> // for member
    00027
    00028 #ifndef NDEBUG
    00029 #include <geos/geomgraph/EdgeEndStar.h> // for testInvariant
    00030 #include <geos/geomgraph/EdgeEnd.h> // for testInvariant
    00031 #endif // ndef NDEBUG
    00032
    00033 #include <geos/inline.h>
    00034
    00035 #include <cassert>
    00036 #include <string>
    00037
    00038 // Forward declarations
    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 { // geos.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* /*im*/) {};
    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                 // Each EdgeEnd in the star has this Node's
    00155                 // coordinate as first coordinate
    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         // ztot is the sum of doubnle sin zvals vector
    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 } // namespace geos.geomgraph
    00184 } // namespace geos
    00185
    00186 //#ifdef GEOS_INLINE
    00187 //# include "geos/geomgraph/Node.inl"
    00188 //#endif
    00189
    00190 #endif // ifndef GEOS_GEOMGRAPH_NODE_H
    00191
    00192 /**********************************************************************
    00193  * $Log$
    00194  * Revision 1.6  2006/06/01 11:49:36  strk
    00195  * Reduced installed headers form geomgraph namespace
    00196  *
    00197  * Revision 1.5  2006/04/27 15:15:06  strk
    00198  * Z check removed from invariant tester to avoid aborts due to differences in FP computations.
    00199  *
    00200  * Revision 1.4  2006/04/07 16:01:51  strk
    00201  * Port info, doxygen comments, testInvariant(), many assertionss, handling of
    00202  * the NULL EdgeEndStar member
    00203  *
    00204  * Revision 1.3  2006/03/24 09:52:41  strk
    00205  * USE_INLINE => GEOS_INLINE
    00206  *
    00207  * Revision 1.2  2006/03/15 16:27:54  strk
    00208  * operator<< for Node class
    00209  *
    00210  * Revision 1.1  2006/03/09 16:46:49  strk
    00211  * geos::geom namespace definition, first pass at headers split
    00212  *
    00213  **********************************************************************/
    00214