VR-Forces 4.6.1 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
triangleIndirect.h
Go to the documentation of this file.
1
/*********************************************************************
2
** Copyright (c) 2000 MaK Technologies, Inc.
3
** All rights reserved.
4
*********************************************************************/
5
/*********************************************************************
6
** $RCSfile: triInd.h,v $ $Revision: 1.25 $ $State: Exp $
7
*********************************************************************/
8
9
#ifndef triangleIndirect_H_
10
#define triangleIndirect_H_
11
12
#include "
gdb/gdbDefines.h
"
13
#include "
gdb/baseTriangle.h
"
14
#include "
gdb/vertexManager.h
"
15
#include "
gdb/surfaceManager.h
"
16
#include "
geometry/point.h
"
17
18
#include <vlutil/vlPrint.h>
19
#include <assert.h>
20
21
// forward declarations
22
class
DtSurfaceManager
;
23
class
DtPolygonIndirect
;
24
25
26
// class DtTriangleIndirect:
27
//
28
// DtTriangleIndirect allows for the specification of the
29
// vertices of a polygon as indices into a vertex Manager.
30
31
class
DT_DLL_gdb
DtTriangleIndirect
:
public
DtBaseTriangle
32
{
33
public
:
34
35
// constructor using a polygon indirect.
36
DtTriangleIndirect
(
const
DtPolygonIndirect
*
const
poly);
37
38
// constructor with vertex IDs, vertex manager, surface manager,
39
// and surface ID
40
DtTriangleIndirect
(
DtVertexManager
*
const
vertManager,
41
const
DtVertexID
vertID0,
42
const
DtVertexID
vertID1,
43
const
DtVertexID
vertID2,
44
DtSurfaceManager
*
const
surfMgr,
45
const
DtSurfaceID
surfID);
46
47
// destructor
48
virtual
~
DtTriangleIndirect
();
49
50
// copy constructor
51
DtTriangleIndirect
(
const
DtTriangleIndirect
& orig);
52
53
// assignment operator
54
DtTriangleIndirect
&
operator=
(
const
DtTriangleIndirect
& orig);
55
56
// computes the intersection of chord with polygon; returns
57
// intersection point.
58
virtual
bool
intersect
(
const
DtChord
& chord,
59
DtPoint
& intersectionPoint,
60
double
& t)
const
;
61
62
// Since this class only overrides one of the intersection functions,
63
// specify that its using the base classes to prevent hiding.
64
using
DtBaseTriangle::intersect
;
65
using
DtBaseTriangle::intersectBundle
;
66
using
DtBaseTriangle::allIntersectsAlongChordBundle
;
67
68
// returns extent of the triangle
69
inline
DtExtent
extent
()
const
;
70
71
// vertex accessors
72
inline
DtPoint
& vertex0();
73
inline
const
DtPoint
& vertex0()
const
;
74
75
inline
DtPoint
& vertex1();
76
inline
const
DtPoint
& vertex1()
const
;
77
78
inline
DtPoint
& vertex2();
79
inline
const
DtPoint
& vertex2()
const
;
80
81
virtual
bool
getVertex
(
DtPoint
& retVal,
unsigned
int
localIndex)
const
;
82
const
DtPoint
&
getVertex
(
unsigned
int
localIndex)
const
;
83
84
// Requires index be a valid localIndex into the list of vertex IDs.
85
virtual
DtVertexID
getVertexID(
unsigned
int
localIndex)
const
;
86
87
virtual
void
setVertex(
unsigned
int
localIndex,
DtVertexID
vertexID);
88
89
// get the surface associated with the triangle
90
virtual
bool
getSurface
(
DtSurface
& s)
const
;
91
const
DtSurface
&
getSurface
()
const
;
92
93
// get the surface ID associated with the triangle
94
virtual
DtSurfaceID
getSurfaceID()
const
;
95
96
// set the surface associated with the triangle
97
// If the ID is a valid surface ID, then it sets the
98
// surface and returns true. If the ID is invalid,
99
// the it returns false and does NOT set the surface.
100
virtual
bool
setSurface
(
DtSurfaceID
surfaceID);
101
102
// Sets the surface of the associated triangle.
103
// \return A boolean indicating whether or not the surface could be set.
104
// \note \b Implementation \b detail! - Does not add the surface if it already
105
// exists in the surface manager.
106
virtual
bool
setSurface
(
const
DtSurface
& newSurface);
107
108
// get the vertex Manager associated with the polygon
109
inline
virtual
DtVertexManager
*
const
vertexManager()
const
;
110
111
// get a pointer to the the surface Manager associated with the triangle
112
inline
virtual
DtSurfaceManager
*
const
surfaceManager()
const
;
113
114
// debugging aid function
115
virtual
void
dump
(
int
indentLevel)
const
;
116
117
// Applies the specified transform to its vertices. If the flag
118
// is true, will create new vertices instead of modifying existing
119
// ones. Returns false if the transformation fails for any reason.
120
virtual
bool
applyTransform
(
const
DtHomogeneousTransformMatrix
& matrix,
121
bool
createNewVertices);
122
123
// Unsafe public functions: These functions expose the internals of
124
// the object.They are unsafe in that, should the implementation change,
125
// these functions are not guaranteed to stay the same. Any use of these
126
// functions assumes the risk they will be broken by future changes to the
127
// internals of this class
128
129
// default constructor
130
DtTriangleIndirect
();
131
132
// constructor with vertex indices and vertex manager to
133
// index into
134
DtTriangleIndirect
(
DtVertexManager
* vertMgr,
135
const
DtVertexID
ind0,
136
const
DtVertexID
ind1,
137
const
DtVertexID
ind2);
138
139
// returns type of gdb node
140
virtual
DtGdbNode::DtGdbNodeType
type
()
const
;
141
142
// set the vertex Manager associated with the polygon
143
// Requires that the specified vertex manager is not 0.
144
virtual
void
setVertexManager(
DtVertexManager
*
const
vertManager);
145
146
// set the pointer to the surface Manager associated with the triangle
147
// Requires that the specified surface manager is not 0.
148
virtual
void
setSurfaceManager(
DtSurfaceManager
*
const
surfManager);
149
150
virtual
int
sizeInBytes
()
const
;
151
152
protected
:
153
154
virtual
bool
testInvariant()
const
;
155
156
DtSurfaceID
mySurfaceID
;
157
DtSurfaceManager
*
mySurfaceManager
;
158
DtVertexManager
*
myVertexManager
;
159
DtVertexID
myVertexIDs[3];
// an array of size 3 to hold the indices.
160
};
161
163
// Functions below do NOT test for invariancy
164
// and may corrupt the triangle if not used properly
166
inline
DtPoint
&
DtTriangleIndirect::vertex0
()
167
{
168
return
myVertexManager
->
vertex
(
myVertexIDs
[0]);
169
}
170
171
inline
const
DtPoint
&
DtTriangleIndirect::vertex0
()
const
172
{
173
return
myVertexManager
->
vertex
(
myVertexIDs
[0]);
174
}
175
176
177
inline
DtPoint
&
DtTriangleIndirect::vertex1
()
178
{
179
return
myVertexManager
->
vertex
(
myVertexIDs
[1]);
180
}
181
182
inline
const
DtPoint
&
DtTriangleIndirect::vertex1
()
const
183
{
184
return
myVertexManager
->
vertex
(
myVertexIDs
[1]);
185
}
186
187
188
inline
DtPoint
&
DtTriangleIndirect::vertex2
()
189
{
190
return
myVertexManager
->
vertex
(
myVertexIDs
[2]);
191
}
192
193
inline
const
DtPoint
&
DtTriangleIndirect::vertex2
()
const
194
{
195
return
myVertexManager
->
vertex
(
myVertexIDs
[2]);
196
}
197
198
inline
DtExtent
DtTriangleIndirect::extent
()
const
199
{
200
DtExtent
expandedExtent(
vertex0
(),
vertex1
());
201
expandedExtent.
expandToInclude
(
vertex2
());
202
return
expandedExtent;
203
}
204
205
inline
DtVertexManager
*
const
DtTriangleIndirect::vertexManager
()
const
206
{
207
return
myVertexManager
;
208
}
209
210
211
inline
DtSurfaceManager
*
const
DtTriangleIndirect::surfaceManager
()
const
212
{
213
return
mySurfaceManager
;
214
}
215
216
217
inline
DtGdbNode::DtGdbNodeType
DtTriangleIndirect::type
()
const
218
{
219
return
DtGdbNode::TRIANGLE_INDIRECT
;
220
}
221
222
inline
DtVertexID
DtTriangleIndirect::getVertexID
(
unsigned
int
index)
const
223
{
224
assert(index <= 2);
225
return
myVertexIDs
[index];
226
}
227
228
inline
const
DtPoint
&
DtTriangleIndirect::getVertex
(
unsigned
int
localIndex)
const
229
{
230
return
myVertexManager
->
vertex
(
myVertexIDs
[localIndex]);
231
}
232
233
inline
DtSurfaceID
DtTriangleIndirect::getSurfaceID
()
const
234
{
235
return
mySurfaceID
;
236
}
237
238
inline
void
DtTriangleIndirect::setSurfaceManager
(
DtSurfaceManager
* surfMgr)
239
{
240
assert(surfMgr != 0);
241
mySurfaceManager
= surfMgr;
242
// every polygon is created with a surface type of 0
243
// as soon as there is a surface manager, add 1 to the polygon count of this
244
// surface
245
mySurfaceManager
->
updateSurfaceTerrainElementMap
(
mySurfaceID
, 1);
246
}
247
248
inline
void
DtTriangleIndirect::setVertexManager
(
DtVertexManager
* vertManager)
249
{
250
assert(vertManager != 0);
251
myVertexManager
= vertManager;
252
}
253
254
inline
void
DtTriangleIndirect::setVertex
(
unsigned
int
localIndex,
DtVertexID
vertexIndex)
255
{
256
assert(localIndex <= 2);
257
assert(
myVertexManager
->
isValidID
(vertexIndex));
258
if
(localIndex <= 2)
259
{
260
myVertexIDs
[localIndex] = vertexIndex;
261
}
262
else
263
{
264
DtWarn(
"Warning: DtTriangleIndirect::setVertex -- "
265
"bad localIndex %d\n"
, localIndex);
266
}
267
}
268
269
inline
const
DtSurface
&
DtTriangleIndirect::getSurface
()
const
270
{
271
return
mySurfaceManager
->
surface
(
mySurfaceID
);
272
}
273
274
#endif
Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (
www.mak.com
)