VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vectorNetworkTool.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2006 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: vecNetwTool.h,v $ $Revision: 1.26 $ $State: Exp $
7 *******************************************************************************/
8 
9 // \file vecNetwTool.h
10 // \brief Contains the DtVectorNetworkTool class declaration.
11 
12 
13 #ifndef vectorNetworkTool_H_
14 #define vectorNetworkTool_H_
15 
16 #include "gdb/gdbDefines.h"
17 #include <vlutil/vlList.h>
18 #include <list>
19 
20 class DtNetworkNode;
21 class DtNetworkSegment;
22 class DtNetworkEdge;
23 class DtVectorNetwork;
24 class DtPoint;
25 class DtTerrainDatabase;
26 class DtSegmentMxCifTree;
27 
30 {
31 public:
32 
33  typedef std::list<const DtNetworkEdge*> DtNetworkEdgeContainer;
34  typedef DtNetworkEdgeContainer::iterator DtNetworkEdgeIter;
35  typedef DtNetworkEdgeContainer::const_iterator DtNetworkEdgeConstIter;
36 
37  // default constructor
39 
40  // destructor
41  virtual ~DtVectorNetworkTool();
42 
43  // Constructs a non-intersecting network from a given vector network, detecting and
44  // eliminating places in which edges cross one another. Returns true if
45  // valid network. Only detects intersections between linear features of
46  // MAK GROUP MAK010 and MAK030, water features and roads.
47  // \note Because it only detects linear features (DtFeatureType == 1), only
48  // rivers and road intersections should be detected and fixed.
49  //
50  // inputNetwork: vector network that may contain crossing edges
51  // outputNetwork: vector network in which edges have been eliminated by
52  // inserting new nodes and edges at the intersection points.
53  // Caller must allocate outputNetwork outside of this call.
54  // *Assumes* that the output network is an *empty* network.
55  //
56  // tolerance: the tolerance to use when deciding if edges intersect or
57  // points are equal
58  // excessiveEdgeCount: if the network contains more than this number of edges at any time,
59  // it stops planarizing for memory and performance reasons.
60  //
61  // @note: sets the myTolerance and myExcessiveEdgeCount member variables.
62  //
63  virtual bool planarizeNetwork(DtVectorNetwork& inputNetwork,
64  DtVectorNetwork& outputNetwork,
65  DtReal tolerance,
66  unsigned int excessiveEdgeCount);
67 
68  // Clips all vector data to the extent specified by the two points.
69  // Assumes that the output vector network is an *empty* network.
70  // The inputNetwork is converted to Geodetic *if* it comes in Geocentric.
71  // It is not restored back to Geocentric.
72  virtual bool clipNetwork(DtVectorNetwork& inputNetwork,
73  DtVectorNetwork& outputNetwork,
74  const DtPoint& southWestPoint,
75  const DtPoint& northEastPoint);
76 
77  virtual int sizeInBytes() const;
78 
79 private:
80 
81  // copy constructor - not implemented
83 
84  // assignment operator - not implemented
85  DtVectorNetworkTool& operator=(const DtVectorNetworkTool& orig);
86 
87 protected:
88 
89  // add connectivity to the existing vector data
90  // could be faster, (called from planarizeNetwork()).
91  // breaks all of the edges. Very expensive.
92  virtual void buildConnectivity(const DtVectorNetwork& inputNetwork,
93  DtVectorNetwork& outputNetwork,
94  unsigned int numNodes);
95 
96  // connect all the edges with appropriate nodes
97  // finds broken edges and connects them with new nodes.
98  // Very expensive (n-squared for number of edges).
99  virtual void buildEdges(const DtNetworkEdgeContainer& processedEdges,
100  DtVectorNetwork& network);
101 
102  // This method takes all the edges in inputNetwork and splits them at
103  // intersections. It returns the remaining edges in processedEdgeList.
104  // Called from buildConnectivity.
105  //
106  // \return True if successful and false if not.
107  virtual bool deIntersectEdges(std::list<DtNetworkEdge*>& unprocessedEdges,
108  DtVectorNetwork& outputNetwork, DtNetworkEdgeContainer& processedEdgeList);
109 
110  // split an edge into two. splitEdge1 and splitEdge2 return the
111  // two new edges.
112  virtual void splitEdge(const DtNetworkEdge& edge1, const DtNetworkSegment& seg1,
113  DtReal splitX, DtReal splitY, DtReal splitZ, DtNetworkEdge*& splitEdge1,
114  DtNetworkEdge*& splitEdge2);
115 
116  // --------------------------------------------------------
117  // functions to create temporary nodes, segments, and edges
118  // --------------------------------------------------------
119 
120  // allocate a new edge and put it on the list for later deletion
121  virtual DtNetworkEdge* newEdgeToDelete();
122 
123  // allocate a new edge; user must handle deletion
124  virtual DtNetworkEdge* newEdge();
125 
126  // allocate a new edge and put it on the list for later deletion
127  // copy over essential properties
128  virtual DtNetworkEdge* newEdgeToDelete(const DtNetworkEdge& edge);
129 
130  // allocate a new edge; user must handle deletion
131  // copy over essential properties
132  virtual DtNetworkEdge* newEdge(const DtNetworkEdge& edge);
133 
134  // Deletes every element in myEdgeListToBeDeleted.
135  // Called from planarizeNetwork to
136  // clean up all the temporary edges created while
137  // splitting the intersecting vectors.
138  void deleteAllocatedEdges();
139 
140  bool buildNetworkFromEdges(const DtNetworkEdgeContainer& edges,
141  DtVectorNetwork& outputNetwork);
142 
143  bool calculateArealCentroids(DtVectorNetwork& vectorNetwork);
144 
145  bool clipEdges(const DtVectorNetwork& inputNetwork,
146  DtNetworkEdgeContainer& croppedEdges,
147  const DtPoint& southWestPoint,
148  const DtPoint& northEastPoint, DtVectorNetwork& clippedVectorNetwork);
149 
150  bool clipNodes(const DtVectorNetwork& inputNetwork,
151  DtVectorNetwork& outputNetwork,
152  const DtPoint& southWestPoint,
153  const DtPoint& northEastPoint);
154 
155  // Clips the specified node to the specified extent.
156  // If the node lies within the extent, a copy of the node
157  // is added to the specified vector network.
158  // Otherwise, nothing is added.
159  // NOTE: Returns false only if an error occurred during clipping,
160  // not if the node was entirely clipped out.
161  virtual bool clipNode(const DtNetworkNode& node,
162  const DtPoint& southWestPoint,
163  const DtPoint& northEastPoint,
164  DtVectorNetwork& clippedVectorNetwork);
165 
166  // Used by clipArea and clipEdge to actually do the clipping of
167  // the edge or area.
168  // isClosedNetwork specifies whether the edge is actually an area (closed edge)
169  // The specificationID is the ID of the specification associated with the edge
170  // in its vector network's specification manager.
171  //
172  // Returns false if the network element was not added to the
173  // network for any reason, including an error.
174  virtual bool clipNetworkElement(const DtNetworkEdge& edgeToClip,
175  const DtPoint& southWestPoint, const DtPoint& northEastPoint,
176  DtNetworkEdgeContainer& clippedEdges, bool isClosedNetwork,
177  DtVectorNetwork& clippedVectorNetwork);
178 
179  virtual bool clipLinearFeature(const DtNetworkEdge& edgeToClip,
180  const DtPoint& southWestPoint, const DtPoint& northEastPoint,
181  DtNetworkEdgeContainer& clippedEdges, DtVectorNetwork& clippedVectorNetwork);
182 
183  virtual bool clipArealFeature(const DtNetworkEdge& edgeToClip,
184  const DtPoint& southWestPoint, const DtPoint& northEastPoint,
185  DtNetworkEdgeContainer& clippedArealFeature, DtVectorNetwork& clippedVectorNetwork);
186 
187  // Function to manipulate points, determining if they are in the area of interest, moved to
188  // the closest location in the area (cropping) and to calculate the extent for area features,
189  virtual bool isInArea(const DtPoint& point,
190  const DtPoint& southWestPoint,
191  const DtPoint& northEastPoint);
192 
193  // Determines if the specified point is in an area. If not, it clips it to the area
194  // in the direction of nextPoint.
195  virtual DtPoint moveInArea(const DtPoint& point,
196  const DtPoint& nextPoint,
197  const DtPoint& southWestPoint,
198  const DtPoint& northEastPoint);
199 
200  virtual void updateExtent(const DtPoint& point, DtPoint& minPoint, DtPoint& maxPoint);
201  virtual void calculateExtent(const DtNetworkEdge& edge, DtPoint& minPoint, DtPoint& maxPoint);
202 
203  // Iterates over the segments in the given DtNetworkEdge and adds them to
204  // the given DtSegmentMxCifTree
205  void addEdgeToSegmentTree(const DtNetworkEdge& edgeToAdd,
206  DtSegmentMxCifTree& segmentTree) const;
207 
208  // Iterates over the segments in the given DtNetworkEdge and removes them
209  // from the given DtSegmentMxCifTree
210  void removeEdgeFromSegmentTree(const DtNetworkEdge& edgeToRemove,
211  DtSegmentMxCifTree& segmentTree) const;
212 
213 
214  virtual bool testInvariant() const;
215 
216 protected:
217 
218  std::list<DtNetworkEdge*> myEdges;
219 
220  // The following is the tolerance used to assess equality of points
221  DtReal myTolerance;
222  // The following is the excessive edge count for the graph. If the
223  // number of edges exceeds this value, the conversion stops.
225 };
226 
227 #endif
std::list< DtNetworkEdge * > myEdges
Definition: vectorNetworkTool.h:218
Definition: networkSegment.h:26
#define DT_DLL_gdb
Definition: gdbDefines.h:25
Definition: segmentMxCifTree.h:31
Definition: networkNode.h:38
DtReal myTolerance
Definition: vectorNetworkTool.h:221
Definition: networkEdge.h:28
DtNetworkEdgeContainer::const_iterator DtNetworkEdgeConstIter
Definition: vectorNetworkTool.h:35
DtU32 myExcessiveEdgeCount
Definition: vectorNetworkTool.h:224
DtNetworkEdgeContainer::iterator DtNetworkEdgeIter
Definition: vectorNetworkTool.h:34
std::list< const DtNetworkEdge * > DtNetworkEdgeContainer
Definition: vectorNetworkTool.h:33
Definition: terrainDatabase.h:148
DtVectorNetworkTool is a class for modifying DtVectorNetwork objects.
Definition: vectorNetworkTool.h:29
Definition: point.h:34
Definition: vectorNetwork.h:37

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)