VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
group.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1999 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: group.h,v $ $Revision: 1.24 $ $State: Exp $
7 *********************************************************************/
8 
9 #ifndef group_H_
10 #define group_H_
11 
12 #include "gdb/gdbDefines.h"
13 #include "gdb/gdbNode.h"
14 #include "geometry/extent.h"
16 #include <vlutil/vlConfig.h>
17 #include <list>
18 #include <vector>
19 #include <set>
20 
21 // forward declarations
22 class DtChordBundle;
23 
24 // class DtGroup:
25 //
26 // DtGroup represents a container of DtGdbNodes.
27 //
29 {
30 public:
31 
32  typedef std::vector<DtGdbNode*> DtGroupChildren;
33  typedef const std::vector<DtGdbNode*> DtConstGroupChildren;
34  typedef std::vector<DtGdbNode*>::iterator DtGroupChildrenIter;
35  typedef std::vector<DtGdbNode*>::const_iterator DtGroupChildrenConstIter;
36 
37  // default constructor
38  DtGroup();
39 
40  // destructor
41  virtual ~DtGroup();
42 
43  // copy constructor
44  DtGroup(const DtGroup& orig);
45 
46  // assignment operator
47  DtGroup& operator=(const DtGroup& orig);
48 
49  // returns the type of gdb node
50  virtual DtGdbNodeType type() const;
51 
52  // Non-virtual to allow inlining. Very frequently called.
53  // Returns the extent of the group
54  DtExtent extent() const;
55 
56  // returns the group's child nodes.
57  virtual DtGroupChildren& children();
58  virtual DtConstGroupChildren& children() const;
59 
60  // process the polygons included in the node that fall within the input
61  // extent, and update the color count in the colorCountRecord which is
62  // an in-out parameter.
63  virtual void countPolyColors(DtColorCountRecord& cr,const DtExtent& e) const;
64 
65  // redefine extent to include all components of the group
66  virtual void expandExtent(DtExtent& extent) const;
67 
68  // Forces all children to recalculate their extents, and then recomputes
69  // the extent for the group using the new extents
70  virtual void recomputeExtent();
71 
72  // compute the intersection point of chord and the group.
73  virtual bool intersect(const DtChord& chord,
74  DtPoint& intersectionPoint, double& t) const;
75 
76  // Computes the intersection of the terrain section represented by the
77  // group components and a chord. In addition to the intersection point and
78  // a parametric value, optionally computes and returns surface description
79  // for the intersecting surface, and normal. Identifies the lowest level
80  // intersecting polygon. This function will only replace the contents of
81  // the intersection record if it finds an intersection with a smaller
82  // intersectionTime value.
83  virtual bool intersect(const DtChord& chord,
84  DtChordIntersectionRecord& record, DtIntersectRecordType irtFlag) const;
85 
86  // Tests for intersection between the terrain represented by this node
87  // and the specified sphere.
88  // \return True if an intersection occurs.
89  // \note irtFlag is ignored for now.
90  virtual bool intersect(const DtSphere& sphere, DtSphereIntersectionRecord& record,
91  DtIntersectRecordType irtFlag) const;
92 
93  // Computes the list of all intersections of a chord with the terrain
94  // section represented by the group components. Adds to a list of
95  // DtChordIntersectionRecords sorted by distance along the chord. Returns
96  // false if no intersections exist.
97  virtual bool allIntersectsAlongChord(const DtChord& chord,
99  DtIntersectRecordType irtFlag) const;
100 
101  // Computes the intersection of terrain section represented by the group
102  // components and a bundle of chords. The
103  // returned record list is a a DtList of DtChordIntersectionRecords (one
104  // for each chord) each of which must be created and deleted by the caller.
105  // The irtFlag value specifies which data should be calculated and returned
106  // for each intersection point. The return value of this function is the
107  // number of the chords that had any intersections with the terrain. This
108  // function will only replace the contents of the intersection records if
109  // it finds an intersection with a smaller intersectionTime value.
110  virtual int intersectBundle(const DtChordBundle& chordBundle,
111  DtList& recordList, DtIntersectRecordType irtFlag) const;
112 
113  // Computes the list of all intersections of each of a bundle of chords
114  // with the terrain section represented by the group components. For each
115  // chord in the bundle, adds to a matching DtChordIntersectRecordList
116  // sorted by distance along the chord. The caller is responsible for
117  // creating and deleting the DtChordIntersectRecordLists in the intListList
118  // DtList. The return value of this function is the number of the chords
119  // that had any intersections with the terrain. Note that passing an
120  // irtFlag value of IRT_NO_DATA will probably never return more than one
121  // intersection per chord.
122  virtual int allIntersectsAlongChordBundle(const DtChordBundle& chordBundle,
123  DtList& intListList, DtIntersectRecordType irtFlag) const;
124 
125  // add a node to the group
126  // If for some reason, it cannot add the child due to lack of memory, it
127  // throws a std::bad_alloc exception
128  // \throws std::bad_alloc
129  virtual void addChild(DtGdbNode* newNode);
130  virtual void addChildIfNonNull(DtGdbNode* newNode);
131  virtual void addChildToStart(DtGdbNode* newNode);
132 
133  // collapses any coordinate system nodes below this node
134  // matrix is the transform matrix to apply to children of the node
135  // - contains transformation necessary to go from child coords all
136  // the way back out to world coordinates
137  virtual bool applyTransform(const DtHomogeneousTransformMatrix& matrix,
138  bool createNewVertices);
139 
140  // Reconstitute the group after each child is reduced, eliminating
141  // child nodes that reduce to null.
142  virtual void reduceChildren(int& numReductions);
143 
144  // reduce the group object to eliminate redundant nodes.
145  virtual DtGdbNode* reduce(int& numReductions);
146 
147  // check the object to ensure it is valid.
148  virtual bool sanityCheck() const;
149 
150  // prints out the contents of the object
151  virtual void dump(int indentLevel) const;
152 
153  // Return the minimum terrain file version number that this Node can be
154  // saved in.
156 
157  // Finds all instances of node type searchType in the tree including and
158  // below this node.
159  virtual void allInstancesOf(const DtGdbNodeType searchType,
160  DtFoundInstancesContainer& foundInstances,
161  bool recurseIntoCoordSysNodes = false);
162 
163  virtual void allInstancesOf(const DtGdbNodeType searchType,
164  DtFoundInstancesConstContainer& foundInstances,
165  bool recurseIntoCoordSysNodes = false) const;
166 
167  virtual void allInstancesOf(const DtGdbNodeType searchType,
168  DtFoundInstancesContainer& foundInstances, bool recurseIntoCoordSysNodes,
169  DtGdbNodeEvaluationFunctor& functor);
170 
171  virtual void allInstancesOf(const DtGdbNodeType searchType,
172  DtFoundInstancesConstContainer& foundInstances, bool recurseIntoCoordSysNodes,
173  DtGdbNodeEvaluationFunctor& functor) const;
174 
175  // Finds and removes all instances of node type searchType in the tree
176  // below this node.
177  virtual void purgeAllInstancesOf(const DtGdbNodeType searchType);
178 
179  // Finds and removes all instances of every node type in the tree below
180  // this node; deletes the nodes if they are not memory managed. It returns
181  // this.
182  virtual DtGdbNode* purgeAll();
183 
184  //Finds and replaces all three-sided polygons with triangles
185  //in the tree below this node.
186  virtual void polygonToTriangle(DtMemoryManager* memMgr,
187  unsigned int& numIndConverted, unsigned int& numIndTotal);
188 
189  // Load in all external DtFileNode files. Returns the number of databases
190  // that were just loaded.
191  virtual unsigned int loadAllExternalFiles() const;
192 
193  // Unload all external DtFileNode files. Returns the number of databases
194  // that were unloaded.
195  virtual unsigned int unloadAllExternalFiles() const;
196 
197  // This method returns a balanced-tree. branching is the maximum
198  // branching factor, and bushiness is the number of leaves in the last
199  // group. This function leaves the old tree intact.
200  virtual DtGroup* balanced(unsigned int branching, unsigned int bushiness);
201 
202  // This method returns a balanced-tree. branching is the maximum
203  // branching factor, and bushiness is the number of leaves in the last
204  // group. This function purges the groups in the old tree.
205  virtual DtGroup* balancedAndPurged(unsigned int branching, unsigned int bushiness);
206 
207  // Find the parent (if it exists of child in the tree under the node)
208  virtual DtGdbNode* parent(DtGdbNode *child);
209 
210  // remove the child (if it is) from this node
211  virtual DtGdbNode* removeChild(DtGdbNode *child);
212 
213  virtual void computeExtent();
214 
215  virtual int sizeInBytes() const;
216 
217 protected:
218 
219  // Deletes a node iff it is not memory managed.
220  virtual void purge(DtGdbNode* node);
221 
222  virtual void dumpComponents(int indentLevel) const;
223 
224  virtual void reduceChildrenAux(DtGroupChildren& nodesToBeReduced,
225  std::list<DtGdbNode*>& nodesAlreadyReduced,
226  int& numReductions);
227 
228 protected:
229 
232 };
233 
235 {
236  return DtGdbNode::GROUP;
237 }
238 
239 inline DtExtent DtGroup::extent() const
240 {
241  return myExtent;
242 }
243 
245 {
246  return myNodes;
247 }
248 
250 {
251  return myNodes;
252 }
253 
254 #endif
255 

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)