VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
grid.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1999 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: grid.h,v $ $Revision: 1.8 $ $State: Exp $
7 *********************************************************************/
8 
9 #ifndef grid_H_
10 #define grid_H_
11 
12 // include files
13 #include "gdb/gdbDefines.h"
14 #include "gdb/gdbNode.h"
15 
16 #include "geometry/point.h"
17 #include "geometry/extent.h"
18 #include "gdb/surfaceManager.h"
19 
20 // forward declarations
21 class DtGridPostList;
22 class DtSurface;
23 class DtTriangleIndirect;
24 
25 
26 //
27 //
28 // class DtGrid:
29 //
30 // DtGrid is used to represent a section of the terrain using
31 // elevations and soiltypes in a grid. This is used to import
32 // ctdb databases that combine patches that are gridded with
33 // those that are TINned.
34 //
35 //
36 class DT_DLL_gdb DtGrid : public DtGdbNode
37 {
38 public:
39 
40  // default constructor
41  DtGrid();
42 
43  // additional constructor
44  DtGrid(DtGridPostList* gplist,
45  int nwide,
46  int nhigh,
47  int startGpIndex,
48  DtTerrainDatabase* terrainDatabase);
49 
50  // destructor
51  virtual ~DtGrid();
52 
53  // initialize object parameters
54  virtual void init(DtGridPostList* gplist,
55  int nwide,
56  int nhigh,
57  int startGpIndex,
58  DtTerrainDatabase* terrainDatabase);
59 
60  // returns type of gdb node
61  virtual DtGdbNode::DtGdbNodeType type() const;
62 
63  //returns the width of the grid measured in number of posts.
64  virtual int width() const;
65 
66  //returns the height of the grid measured in number of posts.
67  virtual int height() const;
68 
69  // returns the starting post index of the grid with reference to its
70  // grid post list.
71  virtual int startingGridPostIndex() const;
72 
73  //returns pointer to gridpost list associated with the grid.
74  virtual DtGridPostList* gridPostList() const;
75 
76  // returns the number of posts on this grid
77  virtual int numberOfPosts() const;
78 
79  // returns the extent of the grid in 3-dimensions
80  virtual const DtExtent& extent() const;
81 
82  // given the post number on this grid, return the corresponding
83  // post number in the associated grid post list.
84  virtual int gridPostIndex(int postIndex) const;
85 
86  // returns the index in the grid post list that corresponds
87  // to a post col intervals to the East, and row intervals to the
88  // North from the starting post on this grid.
89  virtual int gridPostIndex(int col, int row) const;
90 
91  // return the bottom left vertex of grid
92  virtual const DtVertex& bottomLeftVertex() const;
93 
94  // return the top right vertex of grid
95  virtual const DtVertex& topRightVertex() const;
96 
97  // process the polygons included in the node that fall within the input
98  // extent, and update the color count in the colorCountRecord which is
99  // an in-out parameter.
100  virtual void countPolyColors(DtColorCountRecord& cr,const DtExtent& e) const;
101 
102  // reduce the grid object to two DtTriangleIndirects if the height and surface
103  // are uniform across the grid.Otherwise, return the grid unaltered.
104  virtual DtGdbNode* reduce(int& numReductions);
105 
106  // expand the input extent to include all of the terrain
107  // represented by the grid.
108  virtual void expandExtent(DtExtent& extent) const;
109 
110  // determines the intersection of chord with the terrain
111  // section represented by the grid.
112  virtual bool intersect(const DtChord& chord,
113  DtPoint& intersectionPoint,
114  double& intersectionTime) const;
115 
116  // Computes the intersection of the terrain section represented by the grid
117  // and a chord. In addition to the intersection point and a parametric
118  // value, optionally computes and returns surface description for the
119  // intersecting surface, and normal. Identifies the lowest level
120  // intersecting polygon. This function will only replace the contents of
121  // the intersection record if it finds an intersection with a smaller
122  // intersectionTime value.
123  virtual bool intersect(const DtChord& chord,
124  DtChordIntersectionRecord& record, DtIntersectRecordType irtFlag) const;
125 
126  // Computes the list of all intersections of a chord with terrain section
127  // represented by the DtGrid. Adds to a list of DtChordIntersectionRecords
128  // sorted by distance along the chord. Returns false if no intersections
129  // exist.
130  virtual bool allIntersectsAlongChord(const DtChord& chord,
132  DtIntersectRecordType irtFlag) const;
133 
134  // Computes the intersection of terrain section represented by the terrain
135  // section represented by the grid and a bundle of chords. The returned
136  // record list is a a DtList of DtChordIntersectionRecords (one for each
137  // chord) each of which must be created and deleted by the caller. The
138  // irtFlag value specifies which data should be calculated and returned for
139  // each intersection point. The return value of this function is the
140  // number of the chords that had any intersections with the terrain. This
141  // function will only replace the contents of the intersection records if
142  // it finds an intersection with a smaller intersectionTime value.
143  virtual int intersectBundle(const DtChordBundle& chordBundle,
144  DtList& recordList, DtIntersectRecordType irtFlag) const;
145 
146  // Computes the list of all intersections of each of a bundle of chords
147  // with the grid. For each chord in the bundle, adds to a matching
148  // DtChordIntersectRecordList sorted by distance along the chord. The
149  // caller is responsible for creating and deleting the
150  // DtChordIntersectRecordLists in the intListList DtList. The return value
151  // of this function is the number of the chords that had any intersections
152  // with the terrain. Note that passing an irtFlag value of IRT_NO_DATA
153  // will probably never return more than one intersection per chord.
154  virtual int allIntersectsAlongChordBundle(const DtChordBundle& chordBundle,
155  DtList& intListList, DtIntersectRecordType irtFlag) const;
156 
157  // returns the vertices of a grid triangle in vertices v0, v1,
158  // and v2, given its enumeration. The vertices are in counter-
159  // clockwise order.
160  virtual bool getTriangleVertices(int polyNum,
161  DtPoint& v0,
162  DtPoint& v1,
163  DtPoint& v2,
164  DtSurface& triSurface) const;
165 
166  // returns true if all of the posts have the same elevation
167  // and soiltype is uniform.The uniform height is returned in h,
168  // and a poinetr to the uniform surface is returned in s.
169  virtual bool isUniformHeightAndSurface(DtSurfaceID& surfID,
170  double& h) const;
171 
172  // returns true if all of the posts have the same
173  // soiltype. The ID of the uniform surface is returned in surfID.
174  virtual bool isUniformSurface(DtSurfaceID& surfID) const;
175 
176  // given polyNum, construct and return the triangle indexed by
177  // polynum.
178 // virtual bool reconstructPoly(int polynum, DtPolygonImmediate& poly) const;
179 
180  // prints the contents of the object
181  virtual void dump(int indentLevel) const;
182 
183  virtual int sizeInBytes() const;
184 
185 protected:
186 
187  // copy constructor
188  DtGrid(const DtGrid& orig);
189 
190  // assignment operator
191  DtGrid& operator=(const DtGrid& orig);
192 
193  // initialization
194  virtual void init();
195 
196  // given an extent, compute the smallest subgrid that overlaps
197  // the extent in x and y dimensions.
198  virtual void computeOverlappingSubGrid(const DtExtent& chordExtent,
199  int& minPostNum, int& maxPostNum) const;
200 
201  // given a chord and a post number, return the segment of the chord
202  // that overlaps the post.
203  virtual void getChordSegment(const DtChord& chord, int postNum,
204  DtChord& chordSegment) const;
205 
206  // given a point in 3-space, determine if the point lies
207  // directly above(below) the square area associated with
208  // a post.
209  virtual bool pointProjectsOntoPost(const DtPoint& p,
210  int PostNum) const;
211 
212  // determines if chord intersects a grid triangle; returns intersection
213  // point and parametric value, if intersection exists.
214  virtual bool intersects(const DtChord& chord,
215  int polyNum,
216  DtPoint& intersectionPoint,
217  double& intersectionTime) const;
218 
219  // determines if chord intersects a grid triangle; returns intersection
220  // record, if intersection exists.
221  virtual bool intersects(const DtChord& chord,
222  int polyNum,
225 
226 
227 protected:
228 
229  // Terrain database which holds pointers to the vertex and surface managers
230  // as well as the memory manager.
232 
237 
241 };
242 
246 
247 // returns the type of gdb node
249 {
250  return DtGdbNode::GRID;
251 }
252 
253 // returns the number of posts in the grid
254 inline int DtGrid::numberOfPosts(void) const
255 {
256  return (myNumWide * myNumHigh);
257 }
258 
259 // return the bottom left vertex of grid
260 inline const DtVertex& DtGrid::bottomLeftVertex() const
261 {
262  return myBottomLeftVertex;
263 }
264 
265 // return the top right vertex of grid
266 inline const DtVertex& DtGrid::topRightVertex() const
267 {
268  return(myTopRightVertex);
269 }
270 
271 //returns the width of the grid measured in number of posts.
272 inline int DtGrid::width() const
273 {
274  return myNumWide;
275 }
276 
277 //returns the height of the grid measured in number of posts.
278 inline int DtGrid::height() const
279 {
280  return myNumHigh;
281 }
282 
283 // returns the starting post index of the grid with reference to its
284 // grid post list.
286 {
288 }
289 
290 //returns pointer to gridpost list associated with the grid.
292 {
293  return myGridPostList;
294 }
295 
296 // returns the extent of the grid
297 inline const DtExtent& DtGrid::extent() const
298 {
299  return myExtent;
300 }
301 
302 #endif
DtTerrainDatabase * myTerrainDb
Definition: grid.h:231
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
Definition: chordIntersectionRecord.h:23
DtVertex myTopRightVertex
Definition: grid.h:240
Definition: colorCountRecord.h:21
Definition: triangleIndirect.h:31
Definition: chordIntersectRecordList.h:29
int myNumWide
Definition: grid.h:234
DtGdbNodeType
Definition: gdbNode.h:48
Definition: gdbNode.h:44
virtual int width() const
Definition: grid.h:272
virtual bool intersect(const DtChord &chord, DtPoint &intersectionPoint, double &intersectionTime) const
virtual void expandExtent(DtExtent &extent) const
virtual void countPolyColors(DtColorCountRecord &cr, const DtExtent &e) const
virtual int numberOfPosts() const
Definition: grid.h:254
virtual int sizeInBytes() const =0
Definition: gdbNode.h:57
DtIntersectRecordType
Definition: gdbNode.h:74
DtGridPostList * myGridPostList
Definition: grid.h:233
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
virtual const DtExtent & extent() const
Definition: grid.h:297
Definition: surface.h:179
#define DT_DLL_gdb
Definition: gdbDefines.h:25
Definition: gridPostList.h:51
DtVertex myBottomLeftVertex
Definition: grid.h:239
virtual int startingGridPostIndex() const
Definition: grid.h:285
virtual bool allIntersectsAlongChord(const DtChord &chord, DtChordIntersectRecordList &intList, DtIntersectRecordType irtFlag) const
virtual int height() const
Definition: grid.h:278
virtual const DtVertex & bottomLeftVertex() const
Definition: grid.h:260
virtual DtGridPostList * gridPostList() const
Definition: grid.h:291
virtual DtGdbNode::DtGdbNodeType type() const
*/
Definition: grid.h:248
Definition: gdbNode.h:94
Definition: chordBundle.h:29
virtual DtGdbNode * reduce(int &numReductions)
unsigned int DtSurfaceID
Definition: surfaceManager.h:25
DtExtent myExtent
Definition: grid.h:238
int myNumHigh
Definition: grid.h:235
virtual int allIntersectsAlongChordBundle(const DtChordBundle &chordBundle, DtList &intListList, DtIntersectRecordType irtFlag) const
int myStartingGridpostIndex
Definition: grid.h:236
Contains the declaration of the DtExtent class.
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
Definition: grid.h:36
virtual const DtVertex & topRightVertex() const
Definition: grid.h:266
Definition: terrainDatabase.h:148
DT_DLL_vrfutil bool intersects(const DtVector &localPoint1, const DtVector &localPoint2, const DtLocalVertexList &localVertexList, const Coordinate_System &coordinateSystem)
Returns true if the line segment localPoint1-localPoint2 intersects.
DtGdbNode & operator=(const DtGdbNode &orig)
virtual void dump(int indentLevel) const =0
virtual DtGdbNodeType type(void) const =0
virtual int intersectBundle(const DtChordBundle &chordBundle, DtList &recordList, DtIntersectRecordType irtFlag) const
Definition: point.h:34

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)