VR-Forces 4.1.1 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
include
gdb
basePoly.h
Go to the documentation of this file.
1
/*********************************************************************
2
** Copyright (c) 1998 MAK Technologies, Inc.
3
** All rights reserved.
4
*********************************************************************/
5
/*********************************************************************
6
** $RCSfile: basePoly.h,v $ $Revision: 1.26 $ $State: Exp $
7
*********************************************************************/
8
#ifndef basePoly_H_
9
#define basePoly_H_
10
11
#include "
gdb/gdbDefines.h
"
12
#include "
gdb/allPoly.h
"
13
#include "
geometry/plane.h
"
14
#include "
geometry/tdbextent.h
"
15
#include <matrix/vlVector.h>
16
17
// forward declarations
18
class
DtList;
19
class
DtChordBundle
;
20
class
DtSurface
;
21
class
DtTerrainDatabase
;
22
23
// class DtBasePolygon:
24
//
25
// DtBasePolygon is an abstract base class for representing
26
// polygons. A polygon consists of a sequence of vertices in
27
// counter-clockwise order. It is assumed that all the
28
// vertices (if more than 3) are coplanar.
29
class
DT_DLL_gdb
DtBasePolygon
:
public
DtAllTypesPolygon
30
{
31
public
:
32
// Destructor
33
virtual
~
DtBasePolygon
();
34
35
protected
:
36
// Constructor is protected as this is an abstract
37
// base class.
38
DtBasePolygon
();
39
40
// Additional constructor
41
DtBasePolygon
(
unsigned
int
numVertices);
42
43
// Copy constructor
44
DtBasePolygon
(
const
DtBasePolygon
& orig);
45
46
// Assignment operator
47
DtBasePolygon
&
operator=
(
const
DtBasePolygon
& orig);
48
49
public
:
50
51
// mutator function
52
virtual
void
setNumberOfVertices(
unsigned
int
n);
53
54
//accessor functions
55
virtual
unsigned
int
numberOfVertices
()
const
;
56
57
// Calls initPlaneAndExtent to force the polygon
58
// to recompute the extent.
59
virtual
void
recomputeExtent
();
60
61
// initialization function
62
virtual
void
initPlaneAndExtent();
63
64
// @return The plane through the polygon
65
virtual
DtPlane
plane()
const
;
66
67
// @return The extent of polygon
68
// @note Non-virtual to allow inlining. Very frequently called.
69
DtExtent
extent()
const
;
70
71
// returns normal to polygon
72
virtual
DtVector
normal
()
const
;
73
74
// for edge, plane, and normal.
75
virtual
bool
getEdge
(
DtChord
& edge,
int
edgeNumber)
const
;
76
virtual
void
getPlane(
DtPlane
& plane)
const
;
77
virtual
void
getNormal
(
DtVector
& normal)
const
;
78
79
// if the polygon falls within the input
80
// extent, update the color count in the colorCountRecord which is
81
// an in-out parameter.
82
virtual
void
countPolyColors
(
DtColorCountRecord
& cr,
const
DtExtent
& e)
const
;
83
84
//geometric functions
85
86
//redefine other extent to include all the vertices of the
87
//polygon.
88
virtual
void
expandExtent
(
DtExtent
& otherExtent)
const
;
89
90
// computes the intersection of chord with polygon; returns
91
// intersection point.
92
// \param chordToTest The chord to test for intersection.
93
// \param intersectionPoint The intersection point, if one occurred.
94
// \param intersectionTime The time along the chord of the intersection. Only set if an intersection occured.
95
// \return A boolean indicating whether or not an intersection occurred.
96
virtual
bool
intersect
(
const
DtChord
& chordToTest,
DtPoint
& intersectionPoint,
97
double
& intersectionTime)
const
;
98
99
// Computes the intersection of the polygon and a chord. In addition to the
100
// intersection point and a parametric value, optionally computes and
101
// returns surface description for the intersecting surface, and
102
// normal. Identifies the lowest level intersecting polygon. This function
103
// will only replace the contents of the intersection record if it finds an
104
// intersection with a smaller intersectionTime value.
105
virtual
bool
intersect
(
106
const
DtChord
& chord,
107
DtChordIntersectionRecord
& record,
108
DtIntersectRecordType
irtFlag)
const
;
109
110
// Computes the intersection of terrain section represented by the polygon
111
// and a bundle of chords. The returned record list is a a DtList of
112
// DtChordIntersectionRecords (one for each chord) each of which must be
113
// created and deleted by the caller. The irtFlag value specifies which
114
// data should be calculated and returned for each intersection point. The
115
// return value of this function is the number of the chords that had any
116
// intersections with the terrain. This function will only replace the
117
// contents of the intersection records if it finds an intersection with a
118
// smaller intersectionTime value.
119
virtual
int
intersectBundle
(
120
const
DtChordBundle
& chordBundle,
121
DtList& recordList,
122
DtIntersectRecordType
irtFlag)
const
;
123
124
// Computes the list of all intersections of each of a bundle of chords
125
// with the polygon. For each chord in the bundle, adds to a matching
126
// DtChordIntersectRecordList sorted by distance along the chord. The
127
// caller is responsible for creating and deleting the
128
// DtChordIntersectRecordLists in the intListList DtList. The return value
129
// of this function is the number of the chords that had any intersections
130
// with the terrain. Note that passing an irtFlag value of IRT_NO_DATA
131
// will probably never return more than one intersection per chord.
132
virtual
int
allIntersectsAlongChordBundle
(
133
const
DtChordBundle
& chordBundle,
134
DtList& intListList,
135
DtIntersectRecordType
irtFlag)
const
;
136
137
// \copydoc DtGdbNode::intersect(const DtSphere& sphere,
138
// DtSphereIntersectionRecord& record, DtIntersectRecordType irtFlag)
139
virtual
bool
intersect
(
const
DtSphere
& sphere,
DtSphereIntersectionRecord
& record,
140
DtIntersectRecordType
irtFlag)
const
;
141
142
//accessor functions
143
virtual
bool
getVertex
(
DtPoint
& retVal,
unsigned
int
i)
const
= 0;
144
virtual
const
DtPoint
&
getVertex
(
unsigned
int
i)
const
= 0;
145
virtual
bool
getSurface
(
DtSurface
& s)
const
= 0;
146
virtual
const
DtSurface
&
getSurface
()
const
= 0;
147
virtual
bool
setSurface
(
const
DtSurface
& newSurface) = 0;
148
149
// determine if a given point is inside the polygon.
150
virtual
bool
pointInPolygon
(
const
DtPoint
&
point
)
const
;
151
152
// Finds the point on the specified chord that is closest to this
153
// polygon, and returns it in closestPoint.
154
// \return Distance squared to the found point.
155
// If cutoffDistance is specified (> 0), the first point found within
156
// this distance will be returned, even if it is not the closest point.
157
// This may cut down significantly on the calculation when the actual
158
// closest point is not required.
159
virtual
double
closestPointOnChordToPolygon
(
const
DtChord
& chord,
160
DtPoint
& closestPoint,
double
cutoffDistance = 0.)
const
;
161
162
// determine the minimum and maximum z-values among the
163
// vertices in the polygon.
164
virtual
double
minZ
()
const
;
165
virtual
double
maxZ
()
const
;
166
167
// KLUDGE -- have different max # of verts per type of poly -- JM
168
virtual
bool
isFull()
const
= 0;
169
170
virtual
int
sizeInBytes
()
const
= 0;
171
172
protected
:
173
bool
testInvariant()
const
;
174
175
// compute twice the area of the triangle formed by a, b, c,
176
// as the magnitude of the cross product (b-a)X(c-a).
177
virtual
double
computeTwiceArea(
178
const
DtPoint
& a,
179
const
DtPoint
& b,
180
const
DtPoint
& c)
const
;
181
182
protected
:
183
184
unsigned
int
myNumberOfVertices
;
185
bool
myInitialized
;
// used to determine if plane and extent have
186
// been computed.
187
DtPlane
myPlane
;
188
DtExtent
myExtent
;
189
};
190
191
inline
double
DtBasePolygon::minZ
()
const
192
{
193
return
myExtent
.
minZ
();
194
}
195
196
inline
double
DtBasePolygon::maxZ
()
const
197
{
198
return
myExtent
.
maxZ
();
199
}
200
201
inline
unsigned
int
DtBasePolygon::numberOfVertices
()
const
202
{
203
return
myNumberOfVertices
;
204
}
205
206
inline
void
DtBasePolygon::setNumberOfVertices
(
unsigned
int
n)
207
{
208
myNumberOfVertices
= n;
209
}
210
211
inline
DtPlane
DtBasePolygon::plane
()
const
212
{
213
return
myPlane
;
214
}
215
216
inline
DtExtent
DtBasePolygon::extent
()
const
217
{
218
return
myExtent
;
219
}
220
221
inline
DtVector
DtBasePolygon::normal
()
const
222
{
223
return
plane
().
normal
();
224
}
225
226
#endif
Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (
www.mak.com
)