VR-Forces 4.7 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
include
gdb
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,
131
DtChordIntersectRecordList
& intList,
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,
223
DtChordIntersectionRecord
& record,
224
DtIntersectRecordType
irtFlag =
DtGdbNode::IRT_ALL_DATA_TERRAIN
)
const
;
225
226
227
protected
:
228
229
// Terrain database which holds pointers to the vertex and surface managers
230
// as well as the memory manager.
231
DtTerrainDatabase
*
myTerrainDb
;
232
233
DtGridPostList
*
myGridPostList
;
234
int
myNumWide
;
235
int
myNumHigh
;
236
int
myStartingGridpostIndex
;
237
238
DtExtent
myExtent
;
239
DtVertex
myBottomLeftVertex
;
240
DtVertex
myTopRightVertex
;
241
};
242
246
247
// returns the type of gdb node
248
inline
DtGdbNode::DtGdbNodeType
DtGrid::type
()
const
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.
285
inline
int
DtGrid::startingGridPostIndex
()
const
286
{
287
return
myStartingGridpostIndex
;
288
}
289
290
//returns pointer to gridpost list associated with the grid.
291
inline
DtGridPostList
*
DtGrid::gridPostList
()
const
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
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
)