ESyS-Particle  2.3
IntersectionVolCalculator.h
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2014 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
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>
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;
81  };
82 
83  template <int tmplDim, typename TmplVec>
85  {
86  public:
87  typedef TmplVec Vec;
89 
90  static const double FOUR_THIRDS_PI;
91  static const double ONE_THIRD_PI;
92 
94 
95  DimBasicSphere(const Vec &centrePt, 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>
120  {
121  public:
122  typedef TmplVec Vec;
126 
127  static Vec getNormal(int dim);
128 
129  static Vec getNegNormal(int dim);
130 
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);
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 
237 
238 #endif
double m_volume
Definition: IntersectionVolCalculator.h:158
VolumeSphere & operator=(const VolumeSphere &sphere)
Definition: IntersectionVolCalculator.hpp:495
const Vec & getCentre() const
Definition: IntersectionVolCalculator.hpp:512
static const int s_numVertices
Definition: IntersectionVolCalculator.h:196
VolumeSphere()
Definition: IntersectionVolCalculator.hpp:469
double getDistanceTo(const Vec &pt) const
Definition: IntersectionVolCalculator.hpp:176
Definition: IntersectionVolCalculator.h:28
double getRadius() const
Definition: IntersectionVolCalculator.hpp:223
static Vec componentMin(const Vec &p1, const Vec &p2)
Definition: IntersectionVolCalculator.hpp:699
double getVolume(const Vertex &vtx)
Definition: IntersectionVolCalculator.hpp:1102
Definition: IntersectionVolCalculator.h:161
double getSignedDistanceTo(const Vec &pt) const
Definition: IntersectionVolCalculator.hpp:166
TmplVec Vec
Definition: IntersectionVolCalculator.h:57
double m_invNormalNorm
Definition: IntersectionVolCalculator.h:80
Vertex & operator=(const Vertex &vtx)
Definition: IntersectionVolCalculator.hpp:569
VolumeSphere m_sphere
Definition: IntersectionVolCalculator.h:229
static double dot(const Vec &p1, const Vec &p2)
Definition: IntersectionVolCalculator.hpp:125
DimPlane< tmplDim, Vec > Plane
Definition: IntersectionVolCalculator.h:88
bool intersectsWith(const TmplSphere &sphere) const
Definition: IntersectionVolCalculator.hpp:62
DimBasicSphere< tmplDim, Vec > BasicSphere
Definition: IntersectionVolCalculator.h:123
DimPlane & operator=(const DimPlane &plane)
Definition: IntersectionVolCalculator.hpp:157
const Vec & getCentre() const
Definition: IntersectionVolCalculator.hpp:230
void createVertices()
Definition: IntersectionVolCalculator.hpp:625
double getVolume() const
Definition: IntersectionVolCalculator.hpp:50
BasicSphere m_sphere
Definition: IntersectionVolCalculator.h:157
static const double ONE_THIRD_PI
Definition: IntersectionVolCalculator.h:91
Definition: CheckPointable.cpp:16
const BasicBox & getBox() const
Definition: IntersectionVolCalculator.hpp:685
Vertex()
Definition: IntersectionVolCalculator.hpp:553
const VolumeSphere & getSphere() const
Definition: IntersectionVolCalculator.hpp:670
DimBasicBox< tmplDim, Vec > BasicBox
Definition: IntersectionVolCalculator.h:124
static const double FOUR_THIRDS_PI
Definition: IntersectionVolCalculator.h:90
bool contains(const TmplSphere &sphere) const
Definition: IntersectionVolCalculator.hpp:94
void setSphere(const BasicSphere &sphere)
Definition: IntersectionVolCalculator.hpp:676
Vec m_pt
Definition: IntersectionVolCalculator.h:177
Vec m_maxPt
Definition: IntersectionVolCalculator.h:50
bool intersectsWith(const Vec &pt) const
Definition: IntersectionVolCalculator.hpp:541
TmplVec Vec
Definition: IntersectionVolCalculator.h:122
const Vec & getNormal() const
Definition: IntersectionVolCalculator.hpp:182
Definition: IntersectionVolCalculator.h:131
Vec m_minPt
Definition: IntersectionVolCalculator.h:49
static double norm(const Vec &pt)
Definition: IntersectionVolCalculator.hpp:114
const Vec & getPoint() const
Definition: IntersectionVolCalculator.hpp:577
const Vec & getMaxPt() const
Definition: IntersectionVolCalculator.hpp:44
double getVolume() const
Definition: IntersectionVolCalculator.hpp:518
double getTwoPlaneVolume(const Vec &pt, const int orientDim) const
Definition: IntersectionVolCalculator.hpp:887
Definition: IntersectionVolCalculator.h:180
Vertex m_vertexArray[s_numVertices]
Definition: IntersectionVolCalculator.h:197
double getSegmentVolume(const Plane &plane) const
Definition: IntersectionVolCalculator.hpp:423
double getSegmentVolume(const Plane &plane) const
Definition: IntersectionVolCalculator.hpp:547
VertexBox m_box
Definition: IntersectionVolCalculator.h:230
double getVolume() const
Definition: IntersectionVolCalculator.hpp:236
const VertexBox & getVertexBox() const
Definition: IntersectionVolCalculator.hpp:692
DimBasicSphere & operator=(const DimBasicSphere &sphere)
Definition: IntersectionVolCalculator.hpp:215
DimPlane< tmplDim, Vec > Plane
Definition: IntersectionVolCalculator.h:125
IntersectionVolCalculator(const BasicBox &box)
Definition: IntersectionVolCalculator.hpp:660
Vec m_normal
Definition: IntersectionVolCalculator.h:78
Definition: IntersectionVolCalculator.h:54
DimBasicSphere()
Definition: IntersectionVolCalculator.hpp:194
TmplVec Vec
Definition: IntersectionVolCalculator.h:31
double getVertexVolume(const BasicSphere &sphere)
Definition: IntersectionVolCalculator.hpp:1119
const Vertex & getVertex(int i) const
Definition: IntersectionVolCalculator.hpp:648
DimPlane()
Definition: IntersectionVolCalculator.hpp:136
TmplVec Vec
Definition: IntersectionVolCalculator.h:87
static Vec componentMax(const Vec &p1, const Vec &p2)
Definition: IntersectionVolCalculator.hpp:714
Definition: IntersectionVolCalculator.h:84
DimBasicBox(const Vec &minPt, const Vec &maxPt)
Definition: IntersectionVolCalculator.hpp:31
double calcVolume() const
Definition: IntersectionVolCalculator.hpp:535
const Vec & getMinPt() const
Definition: IntersectionVolCalculator.hpp:38
static Vec getNormal(int dim)
Definition: IntersectionVolCalculator.hpp:452
Definition: IntersectionVolCalculator.h:119
Vec m_pt
Definition: IntersectionVolCalculator.h:79
Vec m_centre
Definition: IntersectionVolCalculator.h:114
static Vec getNegNormal(int dim)
Definition: IntersectionVolCalculator.hpp:461
bool intersectsWith(const Vec &pt) const
Definition: IntersectionVolCalculator.hpp:412
VertexBox(const BasicBox &box)
Definition: IntersectionVolCalculator.hpp:589
VertexBox & operator=(const VertexBox &box)
Definition: IntersectionVolCalculator.hpp:612
static int getNumVertices()
Definition: IntersectionVolCalculator.hpp:654
double square(double val)
Definition: IntersectionVolCalculator.hpp:25
double getRadius() const
Definition: IntersectionVolCalculator.hpp:505
double getInsidePointVolume(const Vec &pt) const
Definition: IntersectionVolCalculator.hpp:728
bool sphereContainsBox(const BasicSphere &sphere) const
Definition: IntersectionVolCalculator.hpp:1148
void setPoint(const Vec &pt)
Definition: IntersectionVolCalculator.hpp:583
double m_radius
Definition: IntersectionVolCalculator.h:115
double getOutsidePointVolume(const Vec &pt) const
Definition: IntersectionVolCalculator.hpp:986