VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
networkEdge.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2006 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: netwrkEdge.h,v $ $Revision: 1.26 $ $State: Exp $
7 *******************************************************************************/
8 #ifndef networkEdge_H_
9 #define networkEdge_H_
10 
11 #include "gdb/gdbDefines.h"
12 #include "gdb/networkSegment.h"
14 #include <assert.h>
15 #include <vlutil/vlConfig.h>
16 #include <geometry/extent.h>
17 #include <vector>
18 #include <list>
19 #include <memory>
20 
21 class DtNetworkNode;
22 class DtNetworkSegmentIterator;
24 
25 //
26 // DtNetworkEdge represents a section of a network built using a series
27 // of points that does not intersect any other part of the network.
29 {
30 public:
31 
32  typedef std::vector<DtPoint> DtPointContainer;
33  typedef DtPointContainer::iterator DtPointIter;
34  typedef DtPointContainer::const_iterator DtPointConstIter;
35  typedef DtPointContainer::reverse_iterator DtPointReverseIter;
36  typedef DtPointContainer::const_reverse_iterator DtPointConstReverseIter;
37 
38  typedef std::list<DtNetworkSegment*> DtSegmentContainer;
39  typedef DtSegmentContainer::iterator DtSegmentIter;
40  typedef DtSegmentContainer::const_iterator DtSegmentConstIter;
41  typedef DtSegmentContainer::reverse_iterator DtSegmentReverseIter;
42  typedef DtSegmentContainer::const_reverse_iterator DtSegmentConstReverseIter;
43 
45  {
47  DtBackward
48  };
49 
51  {
53  BI_DIRECTIONAL // default
54  };
55 
56  // default constructor
57  DtNetworkEdge();
58 
59  // destructor
60  // \note Upon destruction, all connected nodes are notified
61  // that they are no longer connected to the edge.
62  virtual ~DtNetworkEdge();
63 
64 private:
65  // copy constructor - not implemented
66  DtNetworkEdge(const DtNetworkEdge& orig);
67 
68  // assignment operator - not implemented
70 
71 public:
72  // \return the DtString "DtNetworkEdge"
73  virtual DtString type();
74 
75  // \return the number of points in the edge.
76  unsigned int numPoints() const;
77 
78  // \return the directionality of the road. If the road is bidirectional,
79  // and the user respects this, then only forward iterators over the segments
80  // may be created. If the edge is bi-directional or if the user ignores
81  // directionality, then both forward and backward iterators may be created.
82  // \note The forward direction is defined as the direction from the starting
83  // point of the edge to the endpoint.
84  // \note Forward and Backward can also be thought of as Right and Left as they would
85  // appear to an observer
86  void setDirectionality(DtDirectionality directionality);
87  DtDirectionality directionality() const;
88 
89 
90  // Return auto pointers to edge traversers for this edge.
91  // \param respectDirectionality If this is true, the traverser will *not* be created for
92  // one way streets if the desired direction is backwards.
93  // \note Forward can be described as the direction from the starting
94  // point of the edge to the end point.
95  // \note If no parameters are supplied, a Forward traverser is returned (should never fail).
96  std::unique_ptr<DtNetworkEdgeTraverser> createEdgeTraverser();
97  std::unique_ptr<DtNetworkEdgeTraverser> createEdgeTraverser(DtTraversalDirection traversalDirection,
98  bool respectDirectionality);
99 
100  std::unique_ptr<const DtNetworkEdgeTraverser> createEdgeTraverser() const;
101  std::unique_ptr<const DtNetworkEdgeTraverser> createEdgeTraverser(DtTraversalDirection traversalDirection,
102  bool respectDirectionality) const;
103 
104  // \return the length of the edge, as a sum of the lengths of the
105  // segments comprising the edge.
106  virtual double length() const;
107  // Computes the closest point on the edge to another point
108  // \param pointOut the computed closest point
109  // \param distance the computed distance
110  virtual void closestPoint(const DtPoint& pointIn,
111  DtPoint& pointOut,
112  double& distance) const;
113 
114  // Computes the distance from the edge to a point.
115  // \return the closest distance to the specified point.
116  virtual double distanceToPoint(const DtPoint& point) const;
117 
118 
119  // Calculates the intersection of the projections onto the x-y plane
120  // of this edge and the specified segment.
121  //
122  // \param seg the segment to test for intersections
123  // \return a boolean signifying whether or not any intersection occurred.
124  virtual bool xyIntersects(const DtNetworkSegment& seg) const;
125 
126 
127  // The same as the above function, but also calculates the specified
128  // values.
129  // \param seg the segment to test for intersections.
130  // \param thisSeg a reference to the segment on this edge, if any, that
131  // intersects the specified segment.
132  // \param distanceSquared the distance between the segment and the edge squared.
133  // \param thisX
134  // \param thisY These hold the closest points on this edge
135  // \param otherX
136  // \param otherY These hold the closest points on the network segment
137  virtual bool xyIntersects(const DtNetworkSegment& seg,
138  const DtNetworkSegment*& thisSeg,
139  double& distanceSquared,
140  double& thisX,
141  double& thisY,
142  double& otherX,
143  double& otherY) const;
144 
145  // Calculates the intersection of the projections onto the x-y plane
146  // of this edge and the specified edge.
147  //
148  // \param edge the edge to test for intersections
149  // \param thisSeg a reference to the segment on this edge that intersects the
150  // specified edge, if any.
151  // \param otherSeg a reference to the segment on the specified edge that
152  // intersects this edge, if any.
153  // \return a boolean signifying whether or not any intersection occurred.
154  virtual bool xyIntersects(const DtNetworkEdge& edge,
155  const DtNetworkSegment*& thisSeg,
156  const DtNetworkSegment*& otherSeg) const;
157 
158  // The same as the above function, but also calculates the specified
159  // values.
160  // \param edge the edge to test for intersections
161  // \param thisSeg a reference to the segment on this edge that intersects the
162  // specified edge, if any.
163  // \param otherSeg a reference to the segment on the specified edge that
164  // intersects this edge, if any.
165  // \param distanceSquared the distance between the edge and the edge squared.
166  // \param thisX
167  // \param thisY these hold the closest points on this edge
168  // \param otherX
169  // \param otherY these hold the closest points on the edge
170  virtual bool xyIntersects(const DtNetworkEdge& edge,
171  const DtNetworkSegment*& thisSeg,
172  const DtNetworkSegment*& otherSeg,
173  double& distanceSquared,
174  double& thisX,
175  double& thisY,
176  double& otherX,
177  double& otherY) const;
178 
179  // get/set start and end nodes
180  // \note must be the same location as the
181  // start and end points of the edge.
182  //
183  // \see startPoint()
184  // \see endPoint()
185  virtual DtNetworkNode* startNode() const;
186  // \note If there is an existing start node, it is
187  // notified of being replaced by another node.
188  virtual void setStartNode(DtNetworkNode* node);
189  virtual DtNetworkNode* endNode() const;
190  // \note If there is an existing end node, it is
191  // notified of being replaced by another node.
192  virtual void setEndNode(DtNetworkNode* node);
193 
194  // If the specified node is either start, end, or both,
195  // the associated member is set to 0 to remove the
196  // connection to the node.
197  // \note Used by nodes to remove themselves from edges
198  // when they are deleted. Edges may need to respond by
199  // creating/setting another node if appropriate.
200  virtual void removeConnection(DtNetworkNode* node);
201 
202  // \return the first and last endpoints respectively
203  virtual DtPoint endpoint0() const;
204  virtual DtPoint endpoint1() const;
205 
206  virtual bool pointInEdge(const DtPoint& point) const;
207  virtual bool addPoint(const DtPoint& newPoint);
208  virtual bool addPointToStart(const DtPoint& newPoint);
209 
210  // Returns the point at the particular index
211  const DtPoint& point(int i) const;
212  DtPoint& point(int i);
213 
214  // \return the extent of the edge
215  virtual DtExtent extent() const;
216 
217  // \return an actual iterator, const or non-const, to the beginning or
218  // the end of the list of segments
219  // \note These give *direct* access to the edges segments, regardless of
220  // directionality!
221  DtPointIter pointsBegin();
222  DtPointConstIter pointsBegin() const;
223 
224  DtPointIter pointsEnd();
225  DtPointConstIter pointsEnd() const;
226 
227  // \return a reverse iterator, const or non-const, to the beginning or
228  // the end of the segments
229  // \note These give *direct* access to the edges segments, regardless of
230  // directionality!
231  DtPointReverseIter rPointsBegin();
232  DtPointConstReverseIter rPointsBegin() const;
233 
234  DtPointReverseIter rPointsEnd();
235  DtPointConstReverseIter rPointsEnd() const;
236 
237 
238  // Returns a new segment in the edge.
239  // \note If this edge is associated with a vector network,
240  // the segment is owned by the vector network. Otherwise,
241  // it is owned by the edge.
242  DtNetworkSegment* newSegment();
243 
244  // \return an actual iterator, const or non-const, to the beginning or
245  // the end of the list of segments
246  // \note These give *direct* access to the edges segments, regardless of
247  // directionality!
248  DtSegmentIter segmentsBegin();
249  DtSegmentConstIter segmentsBegin() const;
250 
251  DtSegmentIter segmentsEnd();
252  DtSegmentConstIter segmentsEnd() const;
253 
254  // \return a reverse iterator, const or non-const, to the beginning or
255  // the end of the segments
256  // \note These give *direct* access to the edges segments, regardless of
257  // directionality!
258  DtSegmentReverseIter rSegmentsBegin();
259  DtSegmentConstReverseIter rSegmentsBegin() const;
260 
261  DtSegmentReverseIter rSegmentsEnd();
262  DtSegmentConstReverseIter rSegmentsEnd() const;
263 
264  virtual void setVectorNetwork(DtVectorNetwork* vectorNetwork);
265  virtual DtVectorNetwork* vectorNetwork() const;
266 
267  // Returns references to the lists of points and segments contained
268  // in the edge
269  // \note Users should almost never need to use these functions, and should
270  // be very careful when doing so as these functions may lead to corruption
271  // of the edge instance.
272  DtPointContainer& points();
273  const DtPointContainer& points() const;
274  DtSegmentContainer& segments();
275  const DtSegmentContainer& segments() const;
276 
277  virtual int sizeInBytes() const;
278 
279 protected:
280  bool testInvariant() const;
281 
285  // edge owns these segments and is responsible for deleting them.
287 
288  // Does not own the nodes, and should never delete them
291 
292  double myLength;
293 };
294 
295 // For backwards compatibility - remove later.
300 
301 inline const DtPoint& DtNetworkEdge::point(int i) const
302 {
303  return myPoints[i];
304 }
305 
307 {
308  return myPoints[i];
309 }
310 
311 #endif
DtSegmentContainer::iterator DtSegmentIter
Definition: networkEdge.h:39
DtPointContainer myPoints
Definition: networkEdge.h:284
Definition: networkSpecificationElement.h:32
DtNetworkEdge::DtSegmentConstReverseIter DtNetworkSegmentConstReverseIter
Definition: networkEdge.h:299
std::vector< DtPoint > DtPointContainer
Definition: networkEdge.h:32
Definition: networkEdgeTraverser.h:31
DtPointContainer::const_iterator DtPointConstIter
Definition: networkEdge.h:34
Definition: networkSegment.h:26
DtNetworkSpecificationElement & operator=(const DtNetworkSpecificationElement &orig)
DtPointContainer::reverse_iterator DtPointReverseIter
Definition: networkEdge.h:35
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
DtSegmentContainer mySegments
Definition: networkEdge.h:286
DtSegmentContainer::const_reverse_iterator DtSegmentConstReverseIter
Definition: networkEdge.h:42
#define DT_DLL_gdb
Definition: gdbDefines.h:25
double myLength
Definition: networkEdge.h:292
DtNetworkEdge::DtSegmentReverseIter DtNetworkSegmentReverseIter
Definition: networkEdge.h:298
DtSegmentContainer::const_iterator DtSegmentConstIter
Definition: networkEdge.h:40
DtDirectionality
Definition: networkEdge.h:50
Definition: networkEdge.h:52
DtNetworkEdge::DtSegmentConstIter DtNetworkSegmentConstIter
Definition: networkEdge.h:297
Definition: networkNode.h:38
DtTraversalDirection
Definition: networkEdge.h:44
DT_DLL_VRVCORE double distance(const makVrv::DtCoordinateSystem &, const DtVector &from, const DtVector &to)
Returns the distance from the two points. Coordinates are in local database coordinates The coordinat...
std::list< DtNetworkSegment * > DtSegmentContainer
Definition: networkEdge.h:38
DtNetworkNode * myEndNode
Definition: networkEdge.h:290
const DtPoint & point(int i) const
Definition: networkEdge.h:301
Definition: networkEdge.h:46
DtNetworkNode * myStartNode
Definition: networkEdge.h:289
DtPointContainer::const_reverse_iterator DtPointConstReverseIter
Definition: networkEdge.h:36
Definition: networkEdge.h:28
DtVectorNetwork * myVectorNetwork
Definition: networkEdge.h:282
Contains the declaration of the DtExtent class.
DtSegmentContainer::reverse_iterator DtSegmentReverseIter
Definition: networkEdge.h:41
DT_DLL_VRVCORE double length(const makVrv::DtCoordinateSystem &, const std::vector< DtVector > &vertices)
Returns the total distance of a segmented line defined by the provided vector of vertices. Coordinates are in local database coordinates. The coordinate system is used to convert between the local database coordinates and geocentric. All distance is in 2D – the Z value is ignored.
virtual DtString type()=0
DtNetworkEdge::DtSegmentIter DtNetworkSegmentIter
Definition: networkEdge.h:296
DtDirectionality myDirectionality
Definition: networkEdge.h:283
Definition: point.h:34
DtPointContainer::iterator DtPointIter
Definition: networkEdge.h:33
Definition: vectorNetwork.h:37

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)