ESyS-Particle
2.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
RandomSpherePacker.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_LSMRANDOMSPHEREPACKER_H
15
#define ESYS_LSMRANDOMSPHEREPACKER_H
16
17
#include "
Foundation/console.h
"
18
#include "
Foundation/Rng.h
"
19
#include "
Foundation/BoundingSphere.h
"
20
#include "
Geometry/CubicBoxPacker.h
"
21
#include "
Geometry/SphereFitter.h
"
22
#include "
Geometry/Plane3D.h
"
23
24
25
#include <vector>
26
#include <boost/shared_ptr.hpp>
27
28
namespace
esys
29
{
30
namespace
lsm
31
{
32
template
<
typename
TmplFitterTraits>
33
class
SphereFittedPIterator
34
{
35
public
:
36
typedef
TmplFitterTraits
FitterTraits
;
37
typedef
typename
FitterTraits::Plane3D
Plane
;
38
typedef
typename
FitterTraits::PlaneVector
PlaneVector
;
39
typedef
typename
FitterTraits::Packer
Packer
;
40
typedef
typename
Packer::Particle
Particle
;
41
typedef
typename
Packer::ParticleVector
ParticleVector
;
42
43
class
FitTraits
44
{
45
public
:
46
typedef
Packer
Validator
;
47
typedef
typename
Packer::Particle
Particle
;
48
typedef
typename
Packer::ParticleVector
ParticleVector
;
49
typedef
typename
FitterTraits::Plane3D
Plane3D
;
50
};
51
52
typedef
SphereFitter<FitTraits>
Fitter
;
53
typedef
boost::shared_ptr<Fitter>
FitterPtr
;
54
typedef
std::vector<FitterPtr>
FitterPtrVector
;
55
typedef
MoveToSurfaceFitter<FitTraits>
Move2SurfaceFitter
;
56
typedef
ThreeDSphereFitter<FitTraits>
ThreeDFitter
;
57
typedef
TwoDSphereFitter<FitTraits>
TwoDSFitter
;
58
typedef
TwoDSphereSphereFitter<FitTraits>
TwoDSSphereFitter
;
59
typedef
ThreeDSphereSphereFitter<FitTraits>
ThreeDSSphereFitter
;
60
61
SphereFittedPIterator
(
62
Packer
&packer,
63
int
maxInsertionFailures,
64
const
BoundingSphere
&bSphere
65
);
66
67
void
initialiseFitterPtrVector
();
68
69
const
BoundingSphere
&
getBSphere
()
const
;
70
71
int
getMaxInsertionFailures
()
const
;
72
73
const
FitterPtrVector
&
getFitterPtrVector
()
const
;
74
75
FitterPtrVector
&
getFitterPtrVector
();
76
77
const
Packer
&
getPacker
()
const
;
78
79
Packer
&
getPacker
();
80
81
double
getRandom
(
double
min,
double
max)
const
;
82
83
Vec3
getRandomPoint
()
const
;
84
85
Particle
getCandidateParticle
(
const
Vec3
&point);
86
87
ParticleVector
getClosestNeighbours
(
const
Particle
& particle,
int
numClosest);
88
89
Particle
&
generateNext
();
90
91
bool
hasNext
();
92
93
Particle
next
();
94
95
void
logInfo
();
96
97
private
:
98
Packer
*
m_pPacker
;
99
FitterPtrVector
m_fitterPtrVector
;
100
int
m_maxInsertionFailures
;
101
int
m_lastFailCount
;
102
int
m_successCount
;
103
Particle
m_next
;
104
BoundingSphere
m_bSphere
;
105
};
106
110
template
<
typename
TmplParticleGenerator,
template
<
typename
TmplPartGen>
class
TmplCubicBoxPackerWrap>
111
class
RandomSpherePacker
:
public
TmplCubicBoxPackerWrap<TmplParticleGenerator>::CubicBoxPackerBase
112
{
113
public
:
114
typedef
115
typename
TmplCubicBoxPackerWrap<TmplParticleGenerator>::CubicBoxPackerBase
116
Inherited
;
117
typedef
typename
Inherited::ParticleGenerator
ParticleGenerator
;
118
typedef
typename
Inherited::ParticleGeneratorPtr
ParticleGeneratorPtr
;
119
typedef
typename
Inherited::Particle
Particle
;
120
typedef
typename
Inherited::NTable
NTable
;
121
typedef
typename
Inherited::NTablePtr
NTablePtr
;
122
typedef
typename
NTable::ParticleVector
ParticleVector
;
123
typedef
typename
Inherited::ParticlePool
ParticlePool
;
124
typedef
typename
Inherited::ParticlePoolPtr
ParticlePoolPtr
;
125
126
class
StufferTraits
127
{
128
public
:
129
typedef
RandomSpherePacker
Packer
;
130
typedef
esys::lsm::Plane3D
Plane3D
;
131
typedef
std::vector<Plane3D>
PlaneVector
;
132
};
133
typedef
SphereFittedPIterator<StufferTraits>
StuffedParticleIterator
;
134
135
RandomSpherePacker
(
136
ParticleGeneratorPtr
particleGeneratorPtr,
137
ParticlePoolPtr
particlePoolPtr,
138
NTablePtr
nTablePtr,
139
const
BoundingSphere
&bSphere,
140
double
tolerance,
141
double
cubicPackRadius,
142
int
maxInsertionFailures,
143
bool
do2d
144
);
145
146
virtual
~RandomSpherePacker
();
147
148
const
BoundingSphere
&
getBSphere
()
const
;
149
150
bool
particleIsValid
(
const
Particle
&particle)
const
;
151
152
double
getRandom
(
double
min,
double
max)
const
;
153
154
Vec3
getRandomPoint
()
const
;
155
156
ParticleVector
getClosestNeighbours
(
const
Particle
& particle,
int
numClosest);
157
158
int
getMaxInsertionFailures
()
const
;
159
160
bool
particleFitsInBSphere
(
const
Particle
&particle)
const
;
161
162
bool
particleFitsInBSphereWithNeighbours
(
const
Particle
&particle)
const
;
163
164
void
generateCubicPackingInSphere
();
165
166
void
generateRandomFill
();
167
168
virtual
void
generate
();
169
170
private
:
171
BoundingSphere
m_bSphere
;
172
int
m_maxInsertionFailures
;
173
};
174
}
175
}
176
177
#include "
Geometry/RandomSpherePacker.hpp
"
178
179
#endif
Geometry
RandomSpherePacker.h
Generated on Mon May 6 2013 23:26:29 for ESyS-Particle by
1.8.3.1