VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vectorNetwork.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1999 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: vecNetwrk.h,v $ $Revision: 1.35 $ $State: Exp $
7 *********************************************************************/
8 #ifndef vectorNetwork_H_
9 #define vectorNetwork_H_
10 
11 #include "gdb/gdbDefines.h"
12 #include "gdb/terrainFeature.h"
13 #include "gdb/pointQuadtreeNode.h"
14 #include "gdb/segmentMxCifTree.h"
16 #include "geometry/surface.h"
19 #include <vlutil/vlConfig.h>
20 #include <list>
21 #include <vector>
22 
23 
24 //forward declarations
25 class DtNetworkSegment;
26 class DtNetworkEdge;
27 class DtNetworkNode;
33 
34 
35 //
36 // DtVectorNetwork is used to represent networks of vector data.
38 {
39 public:
40 
41  typedef std::vector<DtNetworkNode*> DtNodeContainer;
42  typedef DtNodeContainer::iterator DtNodeIter;
43  typedef DtNodeContainer::const_iterator DtNodeConstIter;
44 
45  typedef std::vector<DtNetworkEdge*> DtEdgeContainer;
46  typedef DtEdgeContainer::iterator DtEdgeIter;
47  typedef DtEdgeContainer::const_iterator DtEdgeConstIter;
48 
49 
50  // constructor
52 
53  // destructor
54  virtual ~DtVectorNetwork();
55 
56 private:
57  // copy constructor - not implemented
58  DtVectorNetwork(const DtVectorNetwork& orig);
59 
60  // assignment operator - not implemented
61  DtVectorNetwork& operator=(const DtVectorNetwork& orig);
62 
63 public:
64 
65  virtual DtSpecificationManager& specificationManager();
66  virtual const DtSpecificationManager& specificationManager() const;
67  virtual void setSpecificationManager(const DtSpecificationManager& specManager);
68 
69  // \return The number of nodes
70  // \note This \b includes nodes set as removed!
71  virtual unsigned int numNodes() const;
72 
73  // \return The number of nodes not set as removed.
74  virtual unsigned int numUnremovedNodes() const;
75 
76  // \return The maximum number of nodes
77  virtual unsigned int maxNumNodes() const;
78 
79  // Expands the vector network to contain at least the specified number of
80  // network nodes.
81  virtual bool extendMaxNumNodesTo(unsigned int val);
82 
83  // add/remove a new node
84  typedef std::vector<DtNetworkElement*> DtElementContainer;
85  typedef DtElementContainer::iterator DtElementIter;
86  typedef DtElementContainer::const_iterator DtElementConstIter;
87 
88  // Removes all the elements in the specified container.
89  // \return A boolean indicating whether or not all of the specified elements
90  // could be removed or not.
91  // \note The elements \b must be owned by this vector network.
92  //
93  // \implementation Currently, the elements are not removed, but are actually
94  // set to be removed, and thus ignored by vector network queries and the
95  // terrain writer.
96  virtual bool removeElements(DtElementContainer& elementsToRemove);
97 
98  // Removes the specified network elements from the vector network. See the
99  // removeElements function for more information about the behavior when
100  // removing different types of elements.
101  //
102  // \return A boolean indicating whether or the specified element could be
103  // removed or not.
104  //
105  // \note The element \b must be owned by this vector network.
106  //
107  // \see removeElements
108  virtual bool removeElement(DtNetworkElement* elementToRemove);
109 
110  virtual DtNetworkNode* newNode();
111 
112  // expands the vector network's extent to include the specified
113  // node and adds the node to the vector network's quadtree.
114  // Only necessary to call this when adding a new node to an existing
115  // vector network, as calculate extent will also accomplish the same
116  // goals.
117  virtual void addOn(DtNetworkNode& node);
118 
119  // Sets the removed flag of the node so that it will not affect calculations.
120  virtual void setAsRemoved(DtNetworkElement& elementToSet, bool onOff = true) const;
121 
122  // get a pointer to an existing node
123  virtual const DtNetworkNode* node(unsigned int val) const;
124  virtual DtNetworkNode* node(unsigned int val);
125 
126  // get/add/remove a new segment
127  virtual void addOn(DtNetworkSegment& segment);
128 
129  // \return The number of edges
130  // \note This \b includes edges marked as removed!
131  virtual unsigned int numEdges() const;
132 
133  // \return The number of edges, excluding edges set as removed.
134  virtual unsigned int numUnremovedEdges() const;
135 
136  // get the maximum number of edges
137  virtual unsigned int maxNumEdges() const;
138 
139  // extend the maximum number of edges
140  virtual bool extendMaxNumEdgesTo(unsigned int val);
141 
142  // get a new edge
143  virtual DtNetworkEdge* newEdge();
144 
145  // get a pointer to an edge
146  virtual const DtNetworkEdge* edge(unsigned int val) const;
147  virtual DtNetworkEdge* edge(unsigned int val);
148 
149  // determine the extent of the network
150  virtual DtExtent extent() const;
151 
152  // modify extent to include all points in the vector network
153  virtual void expandExtent(DtExtent& otherExt) const;
154 
155  // In order to hide the implementation details, wrap the underlying structures'
156  // containers in new typedefs.
160 
164 
165  // collect all nodes that are validated by the metric
166  virtual void collectAllNodes(DtNetworkNodeMetric& metric,
167  DtPtrConstNodeContainer& nodeContainer) const;
168  virtual void collectAllNodes(DtNetworkNodeMetric& metric,
169  DtPtrNodeContainer& nodeContainer);
170 
171  // find the best valid node in the tree as measured by the metric
172  virtual const DtNetworkNode* findBestNode(DtNetworkNodeMetric& metric) const;
173 
174  // In order to hide the implementation details, wrap the underlying structures'
175  // containers in new typedefs.
179 
183 
184  // collect all segments that are validated by the metric
185  virtual void collectAllSegments(DtNetworkSegmentMetric& metric,
186  DtPtrConstSegmentContainer& segmentContainer) const;
187  virtual void collectAllSegments(DtNetworkSegmentMetric& metric,
188  DtPtrSegmentContainer& segmentContainer);
189 
190  // find the best valid segment in the tree as measured by the metric
191  virtual const DtNetworkSegment* findBestSegment(DtNetworkSegmentMetric& metric) const;
192 
193  // collect all areas in the network as measured by the metrics
194  typedef std::list<const DtNetworkElement*> DtPtrConstAreaContainer;
195  typedef std::list<DtNetworkElement*> DtPtrAreaContainer;
196 
197  virtual void collectAllAreas(DtNetworkAreaMetric& areaMetric,
198  DtPtrConstAreaContainer& networkElementList) const;
199  virtual void collectAllAreas(DtNetworkAreaMetric& areaMetric,
200  DtPtrAreaContainer& networkElementList);
201 
202  // find the best area in the network as measured by the metrics
203  virtual const DtNetworkNode* findBestArea(DtNetworkAreaMetric& areaMetric) const;
204 
205  // collect all features in the range and returns a list ordered by relevance / distance,
206  // where relevance is defined by its location against other features in the same location
207  // and return true if it found something.
208  // example: a bridge is more relevant than a river under it.
209  // User is responsible for deleting each entry in the list
210  virtual bool intersectVectors(const DtPoint& p,
211  DtList& list,
212  const DtVectorNetworkRecord& record);
213 
214  // find the best feature in the range and return true if it found something.
215  // example: a bridge is more relevant than a river under it.
216  virtual bool intersectVectors(const DtPoint& p,
217  DtVectorNetworkIntersectionRecord& intersectionRecord,
218  const DtVectorNetworkRecord& record);
219 
220  // collect all features in the range of the segment defined by p1 and p2
221  // and returns a list ordered by distance,
222  // and return true if it found something.
223  // User is responsible for deleting each entry in the list
224  virtual bool intersectVectors(const DtPoint& p1,
225  const DtPoint& p2,
226  DtList& list,
227  const DtVectorNetworkRecord& record,
228  const DtTerrainDatabase& terrainDatabase);
229 
230  // collect all features in the range of the segment defined by p1 and p2
231  // and returns a vectorNetworkIntersectionRecordList ordered by distance,
232  // and return true if it found something.
233  // User is responsible for allocating and deallocating the
234  // vectorNetworkIntersectionRecordList
235  virtual bool intersectVectors(const DtPoint& p1,
236  const DtPoint& p2,
237  DtVectorNetworkIntersectionRecordList& vectorNetworkIntersectionRecordList,
238  const DtVectorNetworkRecord& record,
239  const DtTerrainDatabase& terrainDatabase);
240 
241  // find if there is any feature in the range and return true if it found something.
242  virtual bool intersectVectors(const DtPoint& p1,
243  const DtPoint& p2,
244  DtVectorNetworkIntersectionRecord& intersectionRecord,
245  const DtVectorNetworkRecord& record,
246  const DtTerrainDatabase& terrainDatabase);
247 
248  // debugging aid
249  virtual void dump(int indent_level) const;
250 
251  // debugging aid... dumps the vector network structure into a GraphViz
252  // format file
253  virtual void dump(const char* filename, DtString indent="") const;
254 
255  // Return the minimum terrain file version number that this Node can be
256  // saved in.
257  virtual DtTerrainFileVersionNumber minSaveVersion() const;
258 
259  // calculate and set the extent of the network
260  virtual void calcExtent();
261 
262  // Merges this vector network with the specified vector network.
263  // Adjusts such things as specification IDs as appropriate.
264  // Returns true if the merge was successful.
265  virtual bool merge(const DtVectorNetwork& networkToMerge, bool connectEdges = true);
266 
267 
268  virtual void connectEdges(unsigned int startingNodeIndex,
269  unsigned int startingEdgeIndex);
270 
271  // Calls above connectEdges function with 0 for starting indices in order
272  // to process all nodes and edges
273  virtual void connectEdges();
274 
275  // Copies the nodes in the input network into the network.
276  // The specification ID Map specifies the offsets for each
277  // original specification ID to its copy in this network's
278  // specification manager.
279  //
280  // Returns true if the copying was successful.
281  // Returns false otherwise.
282  virtual bool copyNodes(const DtVectorNetwork& inputNetwork,
283  DtSpecificationID* specificationIDMap);
284 
285  // Same as the above function ,but assumes that the specification
286  // IDs of the copied nodes are the same as the input nodes.
287  // NOTE: only useful for copying nodes into an empty network
288  virtual bool copyNodes(const DtVectorNetwork& inputNetwork);
289 
290  virtual bool copyEdges(const DtVectorNetwork& inputNetwork,
291  DtSpecificationID* specificationIDMap);
292 
293  // this method joints all edges beyond iiStart to the node if
294  // appropriate (called from connectWithNodes). Looks for edges that could
295  // be connected and connects them. Very expensive (n-cubed for number
296  // of edges in db).
297  virtual void joinEdges(unsigned int nodeIndex,
298  unsigned int startingEdgeIndex);
299  virtual void joinEdges(DtNetworkNode& node,
300  unsigned int startingEdgeIndex);
301 
302  // Returns true if the network contains no data
303  // (i.e. no nodes or edges, the specification manager is empty
304  // etc. )
305  virtual bool isEmpty() const;
306 
307  // check validity of the network
308  virtual bool validity(bool removeInvalidSegments = false, bool* segmentsRemoved = 0);
309 
310  virtual int sizeInBytes() const;
311 
312  // These check if the specification id exists, if not add to specMgr
313  virtual DtSpecificationID riverSpecificationId();
314  virtual DtSpecificationID interchangeSpecificationId();
315  virtual DtSpecificationID bridgeSpecificationId();
316 
317  virtual Coordinate_System* coordinateSystem();
318  virtual Coordinate_System* coordinateSystem() const;
319  virtual void setCoordinateSystem(Coordinate_System* cs);
320 
324  virtual void transformTo(Coordinate_System* newCoordSys, const DtVector* offset=0);
325 
326 protected:
327 
328  // Removes the specified point feature from the vector network.
329  // \return A boolean indicating success or failure
330  virtual bool removePointFeature(DtNetworkElement* pointFeatureToRemove);
331  virtual bool removeLinearFeature(DtNetworkElement* linearFeatureToRemove);
332  virtual bool removeArealFeature(DtNetworkElement* arealFeatureToRemove);
333 
334  virtual bool removeNode(DtNetworkNode* nodeToRemove);
335  virtual bool removeEdge(DtNetworkEdge* edgeToRemove);
336 
337  virtual bool testInvariant() const;
338 
339 
340  virtual bool intersectInfoList(const DtPoint& p,
341  std::list<DtNetworkElement*>& list,
342  const DtVectorNetworkRecord& record);
343 
344  virtual bool intersectInfo(const DtPoint& p,
345  const DtNetworkSpecificationElement*& element,
346  const DtVectorNetworkRecord& record);
347 
348  virtual const DtNetworkNode* betterFeature(const DtNetworkNode* node1,
349  const DtNetworkNode* node2) const;
350 
351  // Dumps the specification manager's structure into a GraphViz format file
352  virtual void dumpSpecs(FILE* fp, DtString indent="") const;
353 
354  // Dumps the node structure into a GraphViz format file
355  virtual void dumpNodes(FILE* fp, DtString indent="") const;
356 
357  // Dumps the edge structure into a GraphViz format file
358  virtual void dumpEdges(FILE* fp, DtString indent="") const;
359 
360 protected:
361 
362  // These specifications are used in planarization.
366 
370 
371  unsigned int myMaxNumNodes;
372  unsigned int myMaxNumEdges;
373 
376 
379 
381 
384 };
385 
386 #endif

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)