VR-Forces 4.0.4 Class Documentation
include/gdb/vecNetwTool.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2006 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: vecNetwTool.h,v $ $Revision: 1.26 $ $State: Exp $
00007 *******************************************************************************/
00008 
00009 // \file vecNetwTool.h
00010 // \brief Contains the DtVectorNetworkTool class declaration.
00011 
00012 
00013 #ifndef vecNetwTool_H_
00014 #define vecNetwTool_H_
00015 
00016 #include "gdb/gdbDefines.h"
00017 #include <vlutil/vlList.h>
00018 #include <list>
00019 
00020 class DtNetworkNode;
00021 class DtNetworkSegment;
00022 class DtNetworkEdge;
00023 class DtVectorNetwork;
00024 class DtPoint;
00025 class DtTerrainDatabase;
00026 class DtSegmentMxCifTree;
00027 
00029 class DT_DLL_gdb DtVectorNetworkTool
00030 {
00031 public:
00032 
00033    typedef std::list<const DtNetworkEdge*> DtNetworkEdgeContainer;
00034    typedef DtNetworkEdgeContainer::iterator DtNetworkEdgeIter;
00035    typedef DtNetworkEdgeContainer::const_iterator DtNetworkEdgeConstIter;
00036 
00037    // default constructor 
00038    DtVectorNetworkTool();
00039 
00040    // destructor
00041    virtual ~DtVectorNetworkTool();
00042 
00043    // Constructs a non-intersecting network from a given vector network, detecting and
00044    // eliminating places in which edges cross one another.  Returns true if
00045    // valid network. Only detects intersections between linear features of 
00046    // MAK GROUP MAK010 and MAK030, water features and roads.  
00047    // \note Because it only detects linear features (DtFeatureType == 1), only
00048    // rivers and road intersections should be detected and fixed.
00049    //
00050    // inputNetwork:  vector network that may contain crossing edges
00051    // outputNetwork: vector network in which edges have been eliminated by
00052    //                inserting new nodes and edges at the intersection points.  
00053    //                Caller must allocate outputNetwork outside of this call.
00054    //                *Assumes* that the output network is an *empty* network.
00055    //
00056    // tolerance:     the tolerance to use when deciding if edges intersect or 
00057    //                points are equal
00058    // excessiveEdgeCount:  if the network contains more than this number of edges at any time,
00059    //                      it stops planarizing for memory and performance reasons.
00060    //
00061    // @note: sets the myTolerance and myExcessiveEdgeCount member variables.
00062    //       
00063    virtual bool planarizeNetwork(DtVectorNetwork& inputNetwork, 
00064                                  DtVectorNetwork& outputNetwork,
00065                                  DtReal tolerance,
00066                                  unsigned int excessiveEdgeCount);
00067 
00068    // Clips all vector data to the extent specified by the two points.  
00069    // Assumes that the output vector network is an *empty* network.
00070    // The inputNetwork is converted to Geodetic *if* it comes in Geocentric. 
00071    // It is not restored back to Geocentric.
00072    virtual bool clipNetwork(DtVectorNetwork& inputNetwork, 
00073                             DtVectorNetwork& outputNetwork,
00074                             const DtPoint& southWestPoint,
00075                             const DtPoint& northEastPoint);
00076 
00077    virtual int sizeInBytes() const;
00078 
00079 private:
00080 
00081    // copy constructor - not implemented
00082    DtVectorNetworkTool(const DtVectorNetworkTool& orig);
00083 
00084    // assignment operator  - not implemented
00085    DtVectorNetworkTool& operator=(const DtVectorNetworkTool& orig);
00086 
00087 protected:
00088 
00089    // add connectivity to the existing vector data
00090    // could be faster, (called from planarizeNetwork()).
00091    // breaks all of the edges.  Very expensive.
00092    virtual void buildConnectivity(const DtVectorNetwork& inputNetwork, 
00093                                   DtVectorNetwork& outputNetwork,
00094                                   unsigned int numNodes);
00095 
00096    // connect all the edges with appropriate nodes
00097    // finds broken edges and connects them with new nodes.
00098    // Very expensive (n-squared for number of edges).
00099    virtual void buildEdges(const DtNetworkEdgeContainer& processedEdges,
00100                            DtVectorNetwork& network);
00101 
00102    // This method takes all the edges in inputNetwork and splits them at 
00103    // intersections.  It returns the remaining edges in processedEdgeList.  
00104    // Called from buildConnectivity.  
00105    //
00106    // \return True if successful and false if not.
00107    virtual bool deIntersectEdges(std::list<DtNetworkEdge*>& unprocessedEdges,
00108       DtVectorNetwork& outputNetwork, DtNetworkEdgeContainer& processedEdgeList);
00109 
00110    // split an edge into two.  splitEdge1 and splitEdge2 return the
00111    // two new edges.
00112    virtual void splitEdge(const DtNetworkEdge& edge1, const DtNetworkSegment& seg1,
00113       DtReal splitX, DtReal splitY, DtReal splitZ, DtNetworkEdge*& splitEdge1, 
00114       DtNetworkEdge*& splitEdge2);
00115 
00116    // --------------------------------------------------------
00117    // functions to create temporary nodes, segments, and edges
00118    // --------------------------------------------------------
00119 
00120    // allocate a new edge and put it on the list for later deletion
00121    virtual DtNetworkEdge* newEdgeToDelete();
00122 
00123    // allocate a new edge; user must handle deletion
00124    virtual DtNetworkEdge* newEdge();
00125 
00126    // allocate a new edge and put it on the list for later deletion
00127    // copy over essential properties
00128    virtual DtNetworkEdge* newEdgeToDelete(const DtNetworkEdge& edge);
00129 
00130    // allocate a new edge; user must handle deletion
00131    // copy over essential properties
00132    virtual DtNetworkEdge* newEdge(const DtNetworkEdge& edge);
00133 
00134    // Deletes every element in myEdgeListToBeDeleted.  
00135    // Called from planarizeNetwork to 
00136    // clean up all the temporary edges created while
00137    // splitting the intersecting vectors.
00138    void deleteAllocatedEdges();
00139 
00140    bool buildNetworkFromEdges(const DtNetworkEdgeContainer& edges,
00141                               DtVectorNetwork& outputNetwork);
00142 
00143    bool calculateArealCentroids(DtVectorNetwork& vectorNetwork);
00144 
00145    bool clipEdges(const DtVectorNetwork& inputNetwork, 
00146                   DtNetworkEdgeContainer& croppedEdges, 
00147                   const DtPoint& southWestPoint, 
00148                   const DtPoint& northEastPoint, DtVectorNetwork& clippedVectorNetwork);
00149 
00150    bool clipNodes(const DtVectorNetwork& inputNetwork,
00151                   DtVectorNetwork& outputNetwork,
00152                   const DtPoint& southWestPoint, 
00153                   const DtPoint& northEastPoint);
00154 
00155    // Clips the specified node to the specified extent.
00156    // If the node lies within the extent, a copy of the node 
00157    // is added to the specified vector network. 
00158    // Otherwise, nothing is added.
00159    // NOTE:  Returns false only if an error occurred during clipping,
00160    //        not if the node was entirely clipped out.
00161    virtual bool clipNode(const DtNetworkNode& node, 
00162                          const DtPoint& southWestPoint,
00163                          const DtPoint& northEastPoint,
00164                          DtVectorNetwork& clippedVectorNetwork);
00165 
00166    // Used by clipArea and clipEdge to actually do the clipping of
00167    // the edge or area.
00168    // isClosedNetwork specifies whether the edge is actually an area (closed edge)
00169    // The specificationID is the ID of the specification associated with the edge
00170    // in its vector network's specification manager.
00171    //
00172    // Returns false if the network element was not added to the 
00173    // network for any reason, including an error.
00174    virtual bool clipNetworkElement(const DtNetworkEdge& edgeToClip, 
00175       const DtPoint& southWestPoint, const DtPoint& northEastPoint,
00176       DtNetworkEdgeContainer& clippedEdges, bool isClosedNetwork,
00177       DtVectorNetwork& clippedVectorNetwork);
00178 
00179    virtual bool clipLinearFeature(const DtNetworkEdge& edgeToClip, 
00180       const DtPoint& southWestPoint, const DtPoint& northEastPoint,
00181       DtNetworkEdgeContainer& clippedEdges, DtVectorNetwork& clippedVectorNetwork);
00182 
00183    virtual bool clipArealFeature(const DtNetworkEdge& edgeToClip, 
00184       const DtPoint& southWestPoint, const DtPoint& northEastPoint,
00185       DtNetworkEdgeContainer& clippedArealFeature, DtVectorNetwork& clippedVectorNetwork);
00186 
00187    // Function to manipulate points, determining if they are in the area of interest, moved to 
00188    // the closest location in the area (cropping) and to calculate the extent for area features,
00189    virtual bool isInArea(const DtPoint& point,
00190                          const DtPoint& southWestPoint,
00191                          const DtPoint& northEastPoint);
00192    
00193    // Determines if the specified point is in an area.  If not, it clips it to the area
00194    // in the direction of nextPoint.
00195    virtual DtPoint moveInArea(const DtPoint& point, 
00196                               const DtPoint& nextPoint,
00197                               const DtPoint& southWestPoint,
00198                               const DtPoint& northEastPoint);
00199 
00200    virtual void updateExtent(const DtPoint& point, DtPoint& minPoint, DtPoint& maxPoint);
00201    virtual void calculateExtent(const DtNetworkEdge& edge, DtPoint& minPoint, DtPoint& maxPoint);
00202 
00203    // Iterates over the segments in the given DtNetworkEdge and adds them to
00204    // the given DtSegmentMxCifTree
00205    void addEdgeToSegmentTree(const DtNetworkEdge& edgeToAdd, 
00206       DtSegmentMxCifTree& segmentTree) const;
00207 
00208    // Iterates over the segments in the given DtNetworkEdge and removes them 
00209    // from the given DtSegmentMxCifTree
00210    void removeEdgeFromSegmentTree(const DtNetworkEdge& edgeToRemove, 
00211       DtSegmentMxCifTree& segmentTree) const;
00212 
00213 
00214    virtual bool testInvariant() const;
00215 
00216 protected:
00217 
00218    std::list<DtNetworkEdge*>      myEdges;
00219    
00220    // The following is the tolerance used to assess equality of points
00221    DtReal    myTolerance;
00222    // The following is the excessive edge count for the graph.  If the
00223    // number of edges exceeds this value, the conversion stops.
00224    DtU32     myExcessiveEdgeCount;
00225 };
00226 
00227 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)