VR-Forces Development_Version Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
gdb
baseTriangle.h
Go to the documentation of this file.
1
/*********************************************************************
2
** Copyright (c) 2000 MAK Technologies, Inc.
3
** All rights reserved.
4
*********************************************************************/
5
/*********************************************************************
6
** $RCSfile: baseTri.h,v $ $Revision: 1.21 $ $State: Exp $
7
*********************************************************************/
8
9
#ifndef baseTriangle_H_
10
#define baseTriangle_H_
11
12
#include "
gdb/gdbDefines.h
"
13
#include "
gdb/allTypesPolygon.h
"
14
#include "
geometry/extent.h
"
15
#include "
geometry/plane.h
"
16
#include "
geometry/surface.h
"
17
18
#include <matrix/vlVector.h>
19
20
// forward declarations
21
class
DtChordBundle
;
22
class
DtSurface
;
23
class
DtTerrainDatabase
;
24
25
// class DtBaseTriangle:
26
//
27
// DtBaseTriangle is an base class for triangles
28
class
DT_DLL_gdb
DtBaseTriangle
:
public
DtAllTypesPolygon
29
{
30
protected
:
31
//constructor is protected as this is an abstract
32
//base class.
33
DtBaseTriangle
();
34
35
// destructor
36
virtual
~
DtBaseTriangle
();
37
38
// copy constructor
39
DtBaseTriangle
(
const
DtBaseTriangle
& orig);
40
41
// assignment operator
42
DtBaseTriangle
&
operator=
(
const
DtBaseTriangle
& orig);
43
44
public
:
45
46
// number of vertices
47
virtual
unsigned
int
numberOfVertices
()
const
;
48
49
// returns plane through the triangle
50
virtual
DtPlane
plane()
const
;
51
52
// returns extent of the triangle
53
virtual
DtExtent
extent()
const
= 0;
54
55
// returns normal to the triangle
56
virtual
DtVector
normal
()
const
;
57
58
// for edge, plane, and normal.
59
virtual
bool
getEdge
(
DtChord
& edge,
int
edgeNumber)
const
;
60
virtual
void
getPlane(
DtPlane
& plane)
const
;
61
virtual
void
getNormal
(
DtVector
& normal)
const
;
62
63
//geometric functions
64
//redefine other extent to include all the vertices of the
65
//polygon.
66
virtual
void
expandExtent
(
DtExtent
& otherExtent)
const
;
67
68
// Computes the intersection of the specified chord with the triangle.
69
//
70
// \param chordToTest The chord to test for intersection.
71
// \param intersectionPoint The intersection point, if one occurred.
72
// \param intersectionTime The time along the chord of the intersection. Only set if an intersection occured.
73
// \return A boolean indicating whether or not an intersection occurred.
74
virtual
bool
intersect
(
const
DtChord
& chordToTest,
DtPoint
& intersectionPoint,
75
double
& intersectionTime)
const
;
76
77
// Computes the intersection of the polygon and a chord. In addition to the
78
// intersection point and a parametric value, optionally computes and
79
// returns surface description for the intersecting surface, and
80
// normal. Identifies the lowest level intersecting polygon. This function
81
// will only replace the contents of the intersection record if it finds an
82
// intersection with a smaller intersectionTime value.
83
virtual
bool
intersect
(
const
DtChord
& chord,
84
DtChordIntersectionRecord
& record,
85
DtIntersectRecordType
irtFlag)
const
;
86
87
// Computes the intersection of terrain section represented by the polygon
88
// and a bundle of chords. The returned record list is a a DtList of
89
// DtChordIntersectionRecords (one for each chord) each of which must be
90
// created and deleted by the caller. The irtFlag value specifies which
91
// data should be calculated and returned for each intersection point. The
92
// return value of this function is the number of the chords that had any
93
// intersections with the terrain. This function will only replace the
94
// contents of the intersection records if it finds an intersection with a
95
// smaller intersectionTime value.
96
virtual
int
intersectBundle
(
const
DtChordBundle
& chordBundle,
97
DtList& recordList,
98
DtIntersectRecordType
irtFlag)
const
;
99
100
// Computes the list of all intersections of each of a bundle of chords
101
// with the polygon. For each chord in the bundle, adds to a matching
102
// DtChordIntersectRecordList sorted by distance along the chord. The
103
// caller is responsible for creating and deleting the
104
// DtChordIntersectRecordLists in the intListList DtList. The return
105
// value of this function is the number of the chords that had any
106
// intersections with the terrain. Note that passing an irtFlag value of
107
// IRT_NO_DATA will probably never return more than one intersection per
108
// chord.
109
virtual
int
allIntersectsAlongChordBundle
(
const
DtChordBundle
& chordBundle,
110
DtList& intListList,
111
DtIntersectRecordType
irtFlag)
const
;
112
113
// \copydoc DtGdbNode::intersect(const DtSphere& sphere,
114
// DtSphereIntersectionRecord& record, DtIntersectRecordType irtFlag)
115
virtual
bool
intersect
(
const
DtSphere
& sphere,
DtSphereIntersectionRecord
& record,
116
DtIntersectRecordType
irtFlag)
const
;
117
118
119
120
// if the polygon falls within the input
121
// extent, update the color count in the colorCountRecord which is
122
// an in-out parameter.
123
virtual
void
countPolyColors
(
DtColorCountRecord
& cr,
const
DtExtent
& e)
const
;
124
125
//accessor functions
126
virtual
bool
getVertex
(
DtPoint
& retVal,
unsigned
int
i)
const
= 0;
127
virtual
const
DtPoint
&
getVertex
(
unsigned
int
i)
const
= 0;
128
129
// determine if a given point is inside the polygon.
130
virtual
bool
pointInPolygon
(
const
DtPoint
& point)
const
;
131
132
// Finds the point on the specified chord that is closest to this
133
// polygon, and returns it in closestPoint.
134
// \return Distance squared to the found point.
135
// If cutoffDistance is specified (> 0), the first point found within
136
// this distance will be returned, even if it is not the closest point.
137
// This may cut down significantly on the calculation when the actual
138
// closest point is not required.
139
virtual
double
closestPointOnChordToPolygon
(
const
DtChord
& chord,
140
DtPoint
& closestPoint,
double
cutoffDistance = 0.)
const
;
141
142
// determine the minimum and maximum z-values among the
143
// vertices in the polygon.
144
virtual
double
minZ
()
const
;
145
virtual
double
maxZ
()
const
;
146
147
// get the surface associated with the polygon
148
virtual
bool
getSurface
(
DtSurface
& surf)
const
= 0;
149
virtual
const
DtSurface
&
getSurface
()
const
= 0;
150
virtual
bool
setSurface
(
const
DtSurface
& newSurface) = 0;
151
152
virtual
int
sizeInBytes
()
const
= 0;
153
154
protected
:
155
// compute twice the area of the triangle formed by a, b, c,
156
// as the magnitude of the cross product (b-a)X(c-a).
157
// Won't be needed later.
158
virtual
double
computeTwiceArea(
const
DtPoint
& a,
159
const
DtPoint
& b,
const
DtPoint
& c)
const
;
160
};
161
162
163
inline
unsigned
int
DtBaseTriangle::numberOfVertices
()
const
164
{
165
return
3;
166
}
167
168
inline
double
DtBaseTriangle::minZ
()
const
169
{
170
return
extent
().
minZ
();
171
}
172
173
inline
double
DtBaseTriangle::maxZ
()
const
174
{
175
return
extent
().
maxZ
();
176
}
177
178
inline
DtPlane
DtBaseTriangle::plane
()
const
179
{
180
return
DtPlane
(
getVertex
(0),
getVertex
(1),
getVertex
(2));
181
}
182
183
inline
DtVector
DtBaseTriangle::normal
()
const
184
{
185
return
plane
().
normal
();
186
}
187
188
189
190
#endif
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
)