ESyS-Particle
2.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
IntersectionVolCalculator.h
Go to the documentation of this file.
1
2
// //
3
// Copyright (c) 2003-2013 by The University of Queensland //
4
// Earth Systems Science Computational Centre (ESSCC) //
5
// http://www.uq.edu.au/esscc //
6
// //
7
// Primary Business: Brisbane, Queensland, Australia //
8
// Licensed under the Open Software License version 3.0 //
9
// http://www.opensource.org/licenses/osl-3.0.php //
10
// //
12
13
14
#ifndef ESYS_LSM_IMPLINTERSECTIONVOLCALCULATOR_H
15
#define ESYS_LSM_IMPLINTERSECTIONVOLCALCULATOR_H
16
17
#include <math.h>
18
19
namespace
esys
20
{
21
namespace
lsm
22
{
23
namespace
impl
24
{
25
double
square
(
double
val);
26
27
template
<
int
tmplDim,
typename
TmplVec>
28
class
DimBasicBox
29
{
30
public
:
31
typedef
TmplVec
Vec
;
32
DimBasicBox
(
const
Vec
&minPt,
const
Vec
&maxPt);
33
34
const
Vec
&
getMinPt
()
const
;
35
36
const
Vec
&
getMaxPt
()
const
;
37
38
double
getVolume
()
const
;
39
40
template
<
typename
TmplSphere>
41
bool
intersectsWith
(
const
TmplSphere &sphere)
const
;
42
43
bool
intersectsWith
(
const
Vec
&pt)
const
;
44
45
template
<
typename
TmplSphere>
46
bool
contains
(
const
TmplSphere &sphere)
const
;
47
48
private
:
49
Vec
m_minPt
;
50
Vec
m_maxPt
;
51
};
52
53
template
<
int
tmplDim,
typename
TmplVec>
54
class
DimPlane
55
{
56
public
:
57
typedef
TmplVec
Vec
;
58
59
static
double
norm
(
const
Vec
&pt);
60
61
static
double
dot
(
const
Vec
&p1,
const
Vec
&p2);
62
63
DimPlane
();
64
65
DimPlane
(
const
Vec
&normal,
const
Vec
&pt);
66
67
DimPlane
(
const
DimPlane
&plane);
68
69
DimPlane
&
operator=
(
const
DimPlane
&plane);
70
71
double
getSignedDistanceTo
(
const
Vec
&pt)
const
;
72
73
double
getDistanceTo
(
const
Vec
&pt)
const
;
74
75
const
Vec
&
getNormal
()
const
;
76
77
private
:
78
Vec
m_normal
;
79
Vec
m_pt
;
80
double
m_invNormalNorm
;
81
};
82
83
template
<
int
tmplDim,
typename
TmplVec>
84
class
DimBasicSphere
85
{
86
public
:
87
typedef
TmplVec
Vec
;
88
typedef
DimPlane<tmplDim, Vec>
Plane
;
89
90
static
const
double
FOUR_THIRDS_PI
;
91
static
const
double
ONE_THIRD_PI
;
92
93
DimBasicSphere
();
94
95
DimBasicSphere
(
const
Vec
¢rePt,
double
radius);
96
97
DimBasicSphere
(
const
DimBasicSphere
&sphere);
98
99
DimBasicSphere
&
operator=
(
const
DimBasicSphere
&sphere);
100
101
double
getRadius
()
const
;
102
103
const
Vec
&
getCentre
()
const
;
104
105
double
getVolume
()
const
;
106
107
double
getVolume
(
const
Vec
&minPt,
const
Vec
&maxPt,
const
int
dimX = 0,
const
int
dimY = 1)
const
;
108
109
bool
intersectsWith
(
const
Vec
&pt)
const
;
110
111
double
getSegmentVolume
(
const
Plane
&plane)
const
;
112
113
private
:
114
Vec
m_centre
;
115
double
m_radius
;
116
};
117
118
template
<
int
tmplDim,
typename
TmplVec>
119
class
IntersectionVolCalculator
120
{
121
public
:
122
typedef
TmplVec
Vec
;
123
typedef
DimBasicSphere<tmplDim,Vec>
BasicSphere
;
124
typedef
DimBasicBox<tmplDim,Vec>
BasicBox
;
125
typedef
DimPlane<tmplDim,Vec>
Plane
;
126
127
static
Vec
getNormal
(
int
dim);
128
129
static
Vec
getNegNormal
(
int
dim);
130
131
class
VolumeSphere
132
{
133
public
:
134
VolumeSphere
();
135
136
VolumeSphere
(
const
BasicSphere
&sphere);
137
138
VolumeSphere
(
const
VolumeSphere
&sphere);
139
140
VolumeSphere
&
operator=
(
const
VolumeSphere
&sphere);
141
142
double
getRadius
()
const
;
143
144
const
Vec
&
getCentre
()
const
;
145
146
double
getVolume
()
const
;
147
148
double
getVolume
(
const
Vec
&minPt,
const
Vec
&maxPt,
const
int
dimX = 0,
const
int
dimY = 1)
const
;
149
150
double
calcVolume
()
const
;
151
152
bool
intersectsWith
(
const
Vec
&pt)
const
;
153
154
double
getSegmentVolume
(
const
Plane
&plane)
const
;
155
156
private
:
157
BasicSphere
m_sphere
;
158
double
m_volume
;
159
};
160
161
class
Vertex
162
{
163
public
:
164
Vertex
();
165
166
Vertex
(
const
Vec
&pt);
167
168
Vertex
(
const
Vertex
&vtx);
169
170
Vertex
&
operator=
(
const
Vertex
&vtx);
171
172
const
Vec
&
getPoint
()
const
;
173
174
void
setPoint
(
const
Vec
&pt);
175
176
private
:
177
Vec
m_pt
;
178
};
179
180
class
VertexBox
:
public
BasicBox
181
{
182
public
:
183
VertexBox
(
const
BasicBox
&box);
184
185
VertexBox
(
const
VertexBox
&box);
186
187
VertexBox
&
operator=
(
const
VertexBox
&box);
188
189
void
createVertices
();
190
191
const
Vertex
&
getVertex
(
int
i)
const
;
192
193
static
int
getNumVertices
();
194
195
private
:
196
static
const
int
s_numVertices
= ((tmplDim == 2) ? 4 : 8);
197
Vertex
m_vertexArray
[
s_numVertices
];
198
};
199
200
IntersectionVolCalculator
(
const
BasicBox
&box);
201
202
const
VolumeSphere
&
getSphere
()
const
;
203
204
void
setSphere
(
const
BasicSphere
&sphere);
205
206
const
BasicBox
&
getBox
()
const
;
207
208
const
VertexBox
&
getVertexBox
()
const
;
209
210
static
Vec
componentMin
(
const
Vec
&p1,
const
Vec
&p2);
211
212
static
Vec
componentMax
(
const
Vec
&p1,
const
Vec
&p2);
213
214
double
getInsidePointVolume
(
const
Vec
&pt)
const
;
215
216
double
getTwoPlaneVolume
(
const
Vec
&pt,
const
int
orientDim)
const
;
217
218
double
getOutsidePointVolume
(
const
Vec
&pt)
const
;
219
220
double
getVolume
(
const
Vertex
&vtx);
221
222
double
getVertexVolume
(
const
BasicSphere
&sphere);
223
224
bool
sphereContainsBox
(
const
BasicSphere
&sphere)
const
;
225
226
double
getVolume
(
const
BasicSphere
&sphere);
227
228
private
:
229
VolumeSphere
m_sphere
;
230
VertexBox
m_box
;
231
};
232
}
233
}
234
}
235
236
#include "
Geometry/IntersectionVolCalculator.hpp
"
237
238
#endif
Geometry
IntersectionVolCalculator.h
Generated on Mon May 6 2013 23:26:29 for ESyS-Particle by
1.8.3.1