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
geometry
ssChordIntersector.h
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright (c) 2005 MAK Technologies, Inc.
3
** All rights reserved.
4
******************************************************************************/
5
/******************************************************************************
6
** $RCSfile: ssChordIntersector.h,v $ $Revision: 1.6 $ $State: Exp $
7
******************************************************************************/
8
#ifndef ssChordIntersector_H_
9
#define ssChordIntersector_H_
10
11
#include <vlutil/vlConfig.h>
12
#include <vlutil/vlPrint.h>
13
14
#include "
geometry/spatialSubdivision.h
"
15
#include "
geometry/ssFunctor.h
"
16
#include "
geometry/ssExtentIntersector.h
"
17
18
#include "
geometry/chord.h
"
19
#include "
geometry/point.h
"
20
#include "
geometry/plane.h
"
21
#include "
geometry/extent.h
"
22
23
25
// Note: Must use this macro to get around issues with VC 6.0 vs .Net/gcc.
26
// 6.0 complains if you use the typename qualifier outside of a class definition,
27
// but it is incorrect to not specify that the cell type is a type when using it
28
// as a template parameter.
30
#ifdef DtSPATIAL_SUB_CELL_TYPE
31
#undef DtSPATIAL_SUB_CELL_TYPE
32
#endif
33
34
#if _MSC_VER == 1200 // Visual Studio 6.0
35
#define DtSPATIAL_SUB_CELL_TYPE DtSpatialSubdivision< T >::DtSpatialSubCellType
36
#else
37
#define DtSPATIAL_SUB_CELL_TYPE typename DtSpatialSubdivision< T >::DtSpatialSubCellType
38
#endif
39
40
41
42
//
43
// The DtSsChordIntersector is *solely* responsible for intersecting a DtChord and a
44
// DtSpatialSubdivision together. It does not know what to do with the intersection
45
// results, nor does it rely on the specific contents of the spatial subdivision.
46
//
47
// This is one of the basic SS intersection classes provided by the toolkit.
48
//
49
template
<
typename
T>
50
class
DtSsChordIntersector
51
{
52
public
:
53
54
// Constructor
55
DtSsChordIntersector
();
56
57
// Destructor
58
virtual
~DtSsChordIntersector
();
59
60
// Intersects the specified chord and spatial subdivision together.
61
// @returns A boolean indicating whether or not the chord intersected the
62
// spatial subdivision at all.
63
// @note Technically, this returns true if the chord's @b extent intersects
64
// the spatial subdivision at all. It does not do a true mathematical
65
// intersection of the chord and the SS.
66
virtual
bool
intersect
(
const
DtChord
& chord,
DtSpatialSubdivision< T >
& spatialSubdivision)
const
;
67
68
// Intersects the specified chord and spatial subdivision together. Applies
69
// the functor to the intersection results, in order, until the functor
70
// is done processing (returns true).
71
//
72
// @returns A boolean indicating whether or not the chord intersected the
73
// spatial subdivision or not. Has nothing to do with the functor's success
74
// or failure in its own processing.
75
//
76
// @note Unlike the above intersection function, this function only returns
77
// true if the chord intersected the SS, not just the chord's extent. And the
78
// functor is applied to the cells in the SS in the order that the chord intersects
79
// them.
80
//
81
virtual
bool
intersect
(
const
DtChord
& chord,
82
DtSpatialSubdivision< T >
& spatialSubdivision,
83
DtSsFunctor<const DtChord, DtSPATIAL_SUB_CELL_TYPE >
& functor)
const
;
84
85
protected
:
86
87
// Trims the specified chord to the spatial subdivision.
88
bool
trimChordToSubdivision
(
const
DtChord
& chord,
89
const
DtSpatialSubdivision<T>
& spatialSubdivision,
90
int
xIndexStart,
int
yIndexStart,
int
zIndexStart,
91
int
xIndexEnd,
int
yIndexEnd,
int
zIndexEnd,
92
double
& tMin,
double
& tMax)
const
;
93
94
// A utility function used when trimming the chord to the spatial subdivision.
95
// Given the specified chord, the specified starting/ending indices - in a single
96
// dimension, the min and max planes in that dimension, and the actual starting
97
// and ending indices, it computes the minimum and maximum time along the chord
98
// in the specified dimension (basically when along the chord it intersects
99
// the min and max planes.
100
//
101
// @returns a boolean indicating whether or not any part of the chord is inside
102
// the specified planes. If the chord lies before the minPlane or after the maxPlane,
103
// then the function returns false.
104
bool
trimChordInSingleDimension
(
const
DtChord
& chord,
105
int
minIndex,
int
maxIndex,
DtPlane
& minPlane,
DtPlane
& maxPlane,
106
int
indexStart,
int
indexEnd,
double
& tMin,
double
& tMax)
const
;
107
108
// Performs a recursive intersection of the chord with the spatial subdivision,
109
// starting in the specified cell. Intersects the chord with the initial cell,
110
// and then, if the functor is not done processing, creates a new chord from the
111
// intersection point of the chord and the cell wall, and the endpoint of the
112
// chord, and continues traversing/intersecting with that chord until no more
113
// of the chord lies in the spatial subdivision or is entirely contained within
114
// a single cell.
115
//
116
//@returns A boolean indicating whether or not the intersection succeeded or not.
117
bool
intersectStartingIn
(
const
DtChord
& chord,
118
DtSpatialSubdivision< T >
& spatialSubdivision,
119
int
xIndexStart,
int
yIndexStart,
int
zIndexStart,
120
int
xIndexEnd,
int
yIndexEnd,
int
zIndexEnd,
121
DtSsFunctor<const DtChord, DtSPATIAL_SUB_CELL_TYPE >
& functor)
const
;
122
123
// A utility function used in determining chord traversal in the x, y, z dimensions.
124
// If the start is greater than the end, then we are traversing backwards in
125
// the dimension. If the start is less than the end, then we are traversing
126
// forwards in the dimension.
127
// Specifically if the
128
// start < end, then direction = 1
129
// start > end, then direction = -1
130
// start == end, then direction = 0
131
int
getRelativeDirection
(
int
start,
int
end)
const
;
132
133
// A utility function used in determining chord traversal. This function
134
// determines the nearest time along the chord until it intersects a cell wall
135
// in the spatial subdivision, given the starting indices and the directions
136
// of traversal in the different dimensions.
137
void
determineDirectionOfTraversal
(
const
DtChord
& chord,
138
DtSpatialSubdivision<T>
& spatialSubdivision,
139
double
& nearestTime,
double
& cellTime,
int
* offsetToNext,
140
int
xDir,
int
yDir,
int
zDir,
141
int
xIndexStart,
int
yIndexStart,
int
zIndexStart)
const
;
142
143
private
:
144
// Copy constructor & Assignment operator - not implemented
145
DtSsChordIntersector
(
const
DtSsChordIntersector
& orig);
146
DtSsChordIntersector
&
operator=
(
const
DtSsChordIntersector
& orig);
147
148
};
149
150
#define SSCHORDINTERSECTOR_HEADER
151
#include "geometry/ssChordIntersector.inl"
152
#undef SSCHORDINTERSECTOR_HEADER
153
154
#ifdef DtSPATIAL_SUB_CELL_TYPE
155
#undef DtSPATIAL_SUB_CELL_TYPE
156
#endif
157
158
#endif
Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (
www.mak.com
)