VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
gdbNode.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1998 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: gdbNode.h,v $ $Revision: 1.27 $ $State: Exp $
7 *********************************************************************/
8 #ifndef gdbNode_H_
9 #define gdbNode_H_
10 
11 // include files
12 #include "gdb/gdbDefines.h"
13 #include "gdb/memoryManageable.h"
14 #include "gdb/terrainReader.h"
17 #include <vlutil/vlConfig.h>
18 #include <vlutil/vlList.h>
19 #include <set>
20 #include <stdio.h>
21 
22 // forward declarations
23 class DtList;
24 class DtPoint;
25 class DtChord;
26 class DtChordBundle;
30 class DtExtent;
31 class DtColorCountRecord;
32 class DtTerrainDatabase;
33 class DtMemoryManager;
34 class DtSimpleList;
35 class DtSphere;
37 
38 //
39 // DtGdbNode is the basic component of a GDB terrain
40 // database and represents a section of the terrain such as
41 // a polygon, grid, feature, or a collection of such items.
42 // It is an abstract base class. All node types
43 // of the GDB are subclassed from this class.
45 {
46 public:
47 
49  {
50  NULL_NODE = -1,
51  GRIDPOST_LIST = 0, // = 0
52  VERTEX_LIST, // = 1
53  GROUP, // = 2
57  GRID, // = 6
62  BUILDING, // = 11
63  TREE, // = 12
65  FILE_NODE, // = 14
66  REF_GROUP, // = 15
69  };
70 
71 
72  // The Intersect Record Type flag indicates the kind of data requested from
73  // a call to one of the intersect functions.
75  {
76  // NO_DATA returns only a bool indication that an intersection was
77  // found.
78  IRT_NO_DATA = 0,
79 
80  // IPOINT is like IRT_NO_DATA, but also returns the closest intersection
81  // point as a DtPoint, the associated "time" value, and the
82  // surface type.
83  IRT_IPOINT = 0x01,
84 
85  // INORMAL is like IRT_NO_DATA, but also returns the normal as a
86  // DtWorldCoordVector.
87  IRT_INORMAL = 0x02,
88 
89  // IPOLYGON is like IRT_NO_DATA, but also returns a copy of the polygon that
90  // was hit.
91  IRT_IPOLYGON = 0x04,
92 
93  // ALL_DATA_TERRAIN requests that all possible data be returned from the terrain node
94  IRT_ALL_DATA_TERRAIN = 0x07,
95 
96  // VECTOR_DATA is like IRT_NO_DATA, but also returns information about the best
97  // intersection in the vector network using only XY coords of the first point the chord
98  IRT_VECTOR_DATA_INPOINT = 0x10,
99 
100  // VECTOR_DATA is like IRT_NO_DATA, but also returns information about all intersections
101  // against the vector network XY coords of the first point the chord
102  IRT_VECTOR_DATA_ALONG_CHORD = 0x20,
103 
104  // ALL_DATA requests that all possible data be returned from the terrain node and the info
105  // in the point from vector network
106  IRT_ALL_DATA_INPOINT = 0x17,
107 
108  // ALL_DATA requests that all possible data be returned from the terrain node and from the
109  // vector network along the chord.
110  IRT_ALL_DATA_ALONG_CHORD = 0x27
111 
112  };
113 
114  // destructor
115  virtual ~DtGdbNode();
116 
117  // assignment operator
118  DtGdbNode& operator=(const DtGdbNode& orig);
119 
120  // Provides information on the type of the subclassed node.
121  virtual DtGdbNodeType type(void) const = 0;
122 
123  // Prints out information contained in the node.
124  // There is apparently a problem with consistency of argument
125  // to this function.
126  virtual void dump(int indentLevel) const = 0;
127 
128  // Return the minimum terrain file version number that this Node can be
129  // saved in.
130  virtual DtTerrainFileVersionNumber minSaveVersion() const;
131 
132  // Redefines input argument extent such that it encompasses
133  // the contents of the DtGdbNode object. Nodes that represent
134  // geometric objects should redefine this. By default, it returns
135  // the input argument, unchanged.
136  virtual void expandExtent(DtExtent& extent) const;
137 
138  // Recomputes the extent of node if it has one
139  virtual void recomputeExtent();
140 
141  // Node applies the transformation matrix to itself and any possible
142  // children as appropriate. The flag specifies whether or not to
143  // create new vertices for the transformed vertices instead of
144  // just modifying existing vertices.
145  virtual bool applyTransform(const DtHomogeneousTransformMatrix& matrix,
146  bool createNewVertices);
147 
148  // process the polygons included in the node that fall within the input
149  // extent, and update the color count in the colorCountRecord which is
150  // an in-out parameter.
151  virtual void countPolyColors(DtColorCountRecord& cr,const DtExtent& e) const;
152 
153  // reduce the node to a more compact representation.
154  virtual DtGdbNode* reduce(int& numReductions);
155 
156  // repeatedly invoke the reduce function until no further reduction is
157  // possible.
158  virtual DtGdbNode* persistentReduce();
159 
160  // check the validity of the node
161  virtual bool sanityCheck() const;
162 
163  // Computes the intersection of terrain section represented by
164  // DtGdbNode object and a chord. Returns the intersection point
165  // and a parametric value.
166  virtual bool intersect(const DtChord& chord, DtPoint& intersectionPoint,
167  double& intersectionTime) const;
168 
169  // Computes the intersection of terrain section represented by DtGdbNode
170  // object and a chord. In addition to the intersection point and a
171  // parametric value, optionally computes and returns surface description
172  // for the intersecting surface, and normal. Identifies the lowest level
173  // intersecting polygon. This function will only replace the contents of
174  // the intersection record if it finds an intersection with a smaller
175  // intersectionTime value.
176  virtual bool intersect(const DtChord& chord, DtChordIntersectionRecord& record,
177  DtIntersectRecordType irtFlag) const;
178 
179  // Tests for intersection between the terrain represented by this node
180  // and the specified sphere.
181  // \return True if an intersection occurs.
182  // If irtFlag is IRT_IPOLYGON or higher, a list of all the intersected
183  // polygons is returned inside the record.
184  virtual bool intersect(const DtSphere& sphere, DtSphereIntersectionRecord& record,
185  DtIntersectRecordType irtFlag) const;
186 
187  // Computes the list of all intersections of a chord with terrain section
188  // represented by DtGdbNode. Adds to a list of DtChordIntersectionRecords
189  // sorted by distance along the chord. Returns false if no intersections
190  // exist. Note that passing an irtFlag value of IRT_NO_DATA will probably
191  // never return more than one intersection.
192  virtual bool allIntersectsAlongChord(const DtChord& chord,
193  DtChordIntersectRecordList& intList, DtIntersectRecordType irtFlag) const;
194 
195  // Computes the intersection of terrain section represented by DtGdbNode
196  // object and a bundle of chords. The returned record list is a a DtList of
197  // DtChordIntersectionRecords (one for each chord) each of which must be
198  // created and deleted by the caller. The irtFlag value specifies which
199  // data should be calculated and returned for each intersection point. The
200  // return value of this function is the number of the chords that had any
201  // intersections with the terrain. This function will only replace the
202  // contents of the intersection records if it finds an intersection with a
203  // smaller intersectionTime value.
204  virtual int intersectBundle(const DtChordBundle& chordBundle,
205  DtList& recordList, DtIntersectRecordType irtFlag) const;
206 
207  // Computes the list of all intersections of each of a bundle of chords
208  // with terrain section represented by DtGdbNode. For each chord in the
209  // bundle, adds to a matching DtChordIntersectRecordList sorted by distance
210  // along the chord. The caller is responsible for creating and deleting
211  // the DtChordIntersectRecordLists in the intListList DtList. The return
212  // value of this function is the number of the chords that had any
213  // intersections with the terrain. Note that passing an irtFlag value of
214  // IRT_NO_DATA will probably never return more than one intersection per
215  // chord.
216  virtual int allIntersectsAlongChordBundle(const DtChordBundle& chordBundle,
217  DtList& intListList, DtIntersectRecordType irtFlag) const;
218 
219  // The DtFoundInstancesContainer is the container of pointers to DtGdbNode
220  // instances filled in by the allInstancesOf function.
221  typedef std::set<DtGdbNode*> DtFoundInstancesContainer;
222  typedef DtFoundInstancesContainer::iterator DtFoundInstancesIter;
223  typedef DtFoundInstancesContainer::const_iterator DtFoundInstancesConstIter;
224 
225  typedef std::set<const DtGdbNode*> DtFoundInstancesConstContainer;
226  typedef DtFoundInstancesConstContainer::iterator DtConstFoundInstancesIter;
227  typedef DtFoundInstancesConstContainer::const_iterator DtConstFoundInstancesConstIter;
228 
229  // Finds all instances of node type searchType in the tree including and
230  // below this node. This default method only includes the current node,
231  // and is overwritten in derived classes as appropriate.
232  virtual void allInstancesOf(const DtGdbNodeType searchType,
233  DtFoundInstancesContainer& foundInstances,
234  bool recurseIntoCoordSysNodes = false);
235 
236  virtual void allInstancesOf(const DtGdbNodeType searchType,
237  DtFoundInstancesConstContainer& foundInstances,
238  bool recurseIntoCoordSysNodes = false) const;
239 
240  virtual void allInstancesOf(const DtGdbNodeType searchType,
241  DtFoundInstancesContainer& foundInstances,
242  bool recurseIntoCoordSysNodes,
243  DtGdbNodeEvaluationFunctor& functor);
244 
245  virtual void allInstancesOf(const DtGdbNodeType searchType,
246  DtFoundInstancesConstContainer& foundInstances,
247  bool recurseIntoCoordSysNodes,
248  DtGdbNodeEvaluationFunctor& functor) const;
249 
250 
251  // Finds and removes all instances of node type searchType in the tree
252  // below this node.
253  virtual void purgeAllInstancesOf(const DtGdbNodeType searchType);
254 
255  // Finds and removes all instances of every node type in the tree below
256  // this node; deletes the nodes if they are not memory managed. It returns
257  // this.
258  virtual DtGdbNode* purgeAll();
259 
260  // Find the parent (if it exists of child in the tree under the node)
261  virtual DtGdbNode* parent(DtGdbNode *child);
262 
263  // remove the child (if it is) from this node
264  virtual DtGdbNode* removeChild(DtGdbNode *child);
265 
266  // Finds and replaces all three-sided polygons with triangles
267  // in the tree below this node.
268  virtual void polygonToTriangle(DtMemoryManager* memMgr,
269  unsigned int& numIndConverted,
270  unsigned int& numIndTotal);
271 
272  // Load in all external DtFileNode files. Returns the number of databases
273  // that were just loaded.
274  virtual unsigned int loadAllExternalFiles() const;
275 
276  // Unload all external DtFileNode files. Returns the number of databases
277  // that were unloaded.
278  virtual unsigned int unloadAllExternalFiles() const;
279 
280  virtual int sizeInBytes() const = 0;
281 
282 protected:
283 
284  // constructors are protected as this is an
285  // abstract base class.
286  DtGdbNode();
287 
288  // copy constructor
289  DtGdbNode(const DtGdbNode& orig);
290 
291  DtGdbNode* myOwner; // pointer to the node's owner
292 
293 };
294 #endif
295 

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)