ESyS-Particle  2.3.4
RandomSpherePacker.h
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 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.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 
14 #ifndef ESYS_LSMRANDOMSPHEREPACKER_H
15 #define ESYS_LSMRANDOMSPHEREPACKER_H
16 
17 #include "Foundation/console.h"
18 #include "Foundation/Rng.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>
34  {
35  public:
36  typedef TmplFitterTraits FitterTraits;
37  typedef typename FitterTraits::Plane3D Plane;
39  typedef typename FitterTraits::Packer Packer;
40  typedef typename Packer::Particle Particle;
42 
43  class FitTraits
44  {
45  public:
46  typedef Packer Validator;
47  typedef typename Packer::Particle Particle;
49  typedef typename FitterTraits::Plane3D Plane3D;
50  };
51 
53  typedef boost::shared_ptr<Fitter> FitterPtr;
54  typedef std::vector<FitterPtr> FitterPtrVector;
60 
62  Packer &packer,
63  int maxInsertionFailures,
64  const BoundingSphere &bSphere
65  );
66 
68 
69  const BoundingSphere &getBSphere() const;
70 
71  int getMaxInsertionFailures() const;
72 
73  const FitterPtrVector &getFitterPtrVector() const;
74 
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 
90 
91  bool hasNext();
92 
93  Particle next();
94 
95  void logInfo();
96 
97  private:
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
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;
123  typedef typename Inherited::ParticlePool ParticlePool;
124  typedef typename Inherited::ParticlePoolPtr ParticlePoolPtr;
125 
127  {
128  public:
131  typedef std::vector<Plane3D> PlaneVector;
132  };
134 
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 
165 
166  void generateRandomFill();
167 
168  virtual void generate();
169 
170  private:
173  };
174  }
175 }
176 
178 
179 #endif
esys::lsm::SphereFittedPIterator::FitTraits::Plane3D
FitterTraits::Plane3D Plane3D
Definition: RandomSpherePacker.h:49
esys::lsm::RandomSpherePacker::particleFitsInBSphereWithNeighbours
bool particleFitsInBSphereWithNeighbours(const Particle &particle) const
Definition: RandomSpherePacker.hpp:380
esys::lsm::RandomSpherePacker::particleIsValid
bool particleIsValid(const Particle &particle) const
Definition: RandomSpherePacker.hpp:330
esys::lsm::SphereFittedPIterator::getCandidateParticle
Particle getCandidateParticle(const Vec3 &point)
Definition: RandomSpherePacker.hpp:122
esys::lsm::RandomSpherePacker::generate
virtual void generate()
Definition: RandomSpherePacker.hpp:406
esys::lsm::SphereFittedPIterator::m_pPacker
Packer * m_pPacker
Definition: RandomSpherePacker.h:98
esys::lsm::SphereFittedPIterator::generateNext
Particle & generateNext()
Definition: RandomSpherePacker.hpp:141
Plane3D.h
esys::lsm::SphereFittedPIterator::initialiseFitterPtrVector
void initialiseFitterPtrVector()
Definition: RandomSpherePacker.hpp:83
Rng.h
CubicBoxPacker.h
esys::lsm::SphereFittedPIterator::FitterPtrVector
std::vector< FitterPtr > FitterPtrVector
Definition: RandomSpherePacker.h:54
esys::lsm::ThreeDSphereSphereFitter
Definition: SphereFitter.h:461
esys::lsm::SphereFittedPIterator::Move2SurfaceFitter
MoveToSurfaceFitter< FitTraits > Move2SurfaceFitter
Definition: RandomSpherePacker.h:55
esys::lsm::SphereFittedPIterator::getPacker
const Packer & getPacker() const
Definition: RandomSpherePacker.hpp:62
esys::lsm::RandomSpherePacker::ParticleGeneratorPtr
Inherited::ParticleGeneratorPtr ParticleGeneratorPtr
Definition: RandomSpherePacker.h:118
esys::lsm::RandomSpherePacker::ParticleVector
NTable::ParticleVector ParticleVector
Definition: RandomSpherePacker.h:122
esys::lsm::RandomSpherePacker::particleFitsInBSphere
bool particleFitsInBSphere(const Particle &particle) const
Definition: RandomSpherePacker.hpp:367
esys::lsm::Plane3D
::Plane3D Plane3D
Definition: Plane3D.h:60
esys::lsm::SphereFittedPIterator::PlaneVector
FitterTraits::PlaneVector PlaneVector
Definition: RandomSpherePacker.h:38
esys::lsm::RandomSpherePacker::Inherited
TmplCubicBoxPackerWrap< TmplParticleGenerator >::CubicBoxPackerBase Inherited
Definition: RandomSpherePacker.h:116
esys::lsm::SphereFittedPIterator::ThreeDFitter
ThreeDSphereFitter< FitTraits > ThreeDFitter
Definition: RandomSpherePacker.h:56
esys::lsm::SphereFittedPIterator::hasNext
bool hasNext()
Definition: RandomSpherePacker.hpp:180
console.h
esys::lsm::SphereFittedPIterator::FitTraits::Validator
Packer Validator
Definition: RandomSpherePacker.h:46
esys::lsm::RandomSpherePacker::StufferTraits::PlaneVector
std::vector< Plane3D > PlaneVector
Definition: RandomSpherePacker.h:131
esys::lsm::BoundingSphere
Definition: BoundingSphere.h:28
esys::lsm::SphereFittedPIterator::getFitterPtrVector
const FitterPtrVector & getFitterPtrVector() const
Definition: RandomSpherePacker.hpp:109
esys::lsm::SphereFittedPIterator::m_next
Particle m_next
Definition: RandomSpherePacker.h:103
esys::lsm::SphereFittedPIterator::m_successCount
int m_successCount
Definition: RandomSpherePacker.h:102
esys::lsm::SphereFittedPIterator::FitTraits::ParticleVector
Packer::ParticleVector ParticleVector
Definition: RandomSpherePacker.h:48
esys::lsm::RandomSpherePacker::NTablePtr
Inherited::NTablePtr NTablePtr
Definition: RandomSpherePacker.h:121
esys::lsm::SphereFitter
Definition: SphereFitter.h:30
esys::lsm::PlaneVector
std::vector< Plane3D > PlaneVector
Definition: GougeBlock3D.h:32
esys::lsm::RandomSpherePacker::StufferTraits::Packer
RandomSpherePacker Packer
Definition: RandomSpherePacker.h:129
esys::lsm::SphereFittedPIterator
Definition: RandomSpherePacker.h:34
esys::lsm::SphereFittedPIterator::Packer
FitterTraits::Packer Packer
Definition: RandomSpherePacker.h:39
esys::lsm::RandomSpherePacker::m_maxInsertionFailures
int m_maxInsertionFailures
Definition: RandomSpherePacker.h:172
esys
Definition: CheckPointable.cpp:17
esys::lsm::RandomSpherePacker::StuffedParticleIterator
SphereFittedPIterator< StufferTraits > StuffedParticleIterator
Definition: RandomSpherePacker.h:133
esys::lsm::RandomSpherePacker
Definition: RandomSpherePacker.h:112
esys::lsm::SphereFittedPIterator::logInfo
void logInfo()
Definition: RandomSpherePacker.hpp:199
RandomSpherePacker.h
esys::lsm::RandomSpherePacker::ParticlePool
Inherited::ParticlePool ParticlePool
Definition: RandomSpherePacker.h:123
esys::lsm::SphereFittedPIterator::FitterTraits
TmplFitterTraits FitterTraits
Definition: RandomSpherePacker.h:36
SphereFitter.h
esys::lsm::RandomSpherePacker::Particle
Inherited::Particle Particle
Definition: RandomSpherePacker.h:119
esys::lsm::ThreeDSphereFitter
Definition: SphereFitter.h:192
esys::lsm::RandomSpherePacker::getClosestNeighbours
ParticleVector getClosestNeighbours(const Particle &particle, int numClosest)
Definition: RandomSpherePacker.hpp:303
RandomSpherePacker.hpp
esys::lsm::SphereFittedPIterator::FitTraits::Particle
Packer::Particle Particle
Definition: RandomSpherePacker.h:47
esys::lsm::RandomSpherePacker::RandomSpherePacker
RandomSpherePacker(ParticleGeneratorPtr particleGeneratorPtr, ParticlePoolPtr particlePoolPtr, NTablePtr nTablePtr, const BoundingSphere &bSphere, double tolerance, double cubicPackRadius, int maxInsertionFailures, bool do2d)
Definition: RandomSpherePacker.hpp:243
esys::lsm::SphereFittedPIterator::m_maxInsertionFailures
int m_maxInsertionFailures
Definition: RandomSpherePacker.h:100
esys::lsm::TwoDSphereFitter
Definition: SphereFitter.h:278
esys::lsm::SphereFittedPIterator::getRandom
double getRandom(double min, double max) const
esys::lsm::SphereFittedPIterator::ThreeDSSphereFitter
ThreeDSphereSphereFitter< FitTraits > ThreeDSSphereFitter
Definition: RandomSpherePacker.h:59
BoundingSphere.h
esys::lsm::SphereFittedPIterator::SphereFittedPIterator
SphereFittedPIterator(Packer &packer, int maxInsertionFailures, const BoundingSphere &bSphere)
Definition: RandomSpherePacker.hpp:29
esys::lsm::RandomSpherePacker::getRandom
double getRandom(double min, double max) const
Definition: RandomSpherePacker.hpp:282
esys::lsm::SphereFittedPIterator::FitterPtr
boost::shared_ptr< Fitter > FitterPtr
Definition: RandomSpherePacker.h:53
Vec3
Definition: vec3.h:47
esys::lsm::RandomSpherePacker::~RandomSpherePacker
virtual ~RandomSpherePacker()
Definition: RandomSpherePacker.hpp:268
esys::lsm::RandomSpherePacker::m_bSphere
BoundingSphere m_bSphere
Definition: RandomSpherePacker.h:171
esys::lsm::SphereFittedPIterator::getMaxInsertionFailures
int getMaxInsertionFailures() const
Definition: RandomSpherePacker.hpp:55
esys::lsm::SphereFittedPIterator::TwoDSSphereFitter
TwoDSphereSphereFitter< FitTraits > TwoDSSphereFitter
Definition: RandomSpherePacker.h:58
esys::lsm::SphereFittedPIterator::Fitter
SphereFitter< FitTraits > Fitter
Definition: RandomSpherePacker.h:52
esys::lsm::SphereFittedPIterator::getRandomPoint
Vec3 getRandomPoint() const
Definition: RandomSpherePacker.hpp:115
esys::lsm::RandomSpherePacker::StufferTraits
Definition: RandomSpherePacker.h:127
esys::lsm::Packer::Particle
ParticleCollection::Particle Particle
Definition: Packer.h:38
esys::lsm::SphereFittedPIterator::m_fitterPtrVector
FitterPtrVector m_fitterPtrVector
Definition: RandomSpherePacker.h:99
esys::lsm::RandomSpherePacker::StufferTraits::Plane3D
esys::lsm::Plane3D Plane3D
Definition: RandomSpherePacker.h:130
esys::lsm::RandomSpherePacker::generateRandomFill
void generateRandomFill()
Definition: RandomSpherePacker.hpp:349
esys::lsm::MoveToSurfaceFitter
Definition: ParticleFitter.h:109
esys::lsm::SphereFittedPIterator::m_bSphere
BoundingSphere m_bSphere
Definition: RandomSpherePacker.h:104
esys::lsm::RandomSpherePacker::NTable
Inherited::NTable NTable
Definition: RandomSpherePacker.h:120
esys::lsm::SphereFittedPIterator::m_lastFailCount
int m_lastFailCount
Definition: RandomSpherePacker.h:101
ParticleVector
std::vector< SimpleParticle > ParticleVector
Definition: SimpleNTable3D.h:22
esys::lsm::RandomSpherePacker::getRandomPoint
Vec3 getRandomPoint() const
Definition: RandomSpherePacker.hpp:291
esys::lsm::RandomSpherePacker::generateCubicPackingInSphere
void generateCubicPackingInSphere()
Definition: RandomSpherePacker.hpp:393
esys::lsm::SphereFittedPIterator::next
Particle next()
Definition: RandomSpherePacker.hpp:187
esys::lsm::SphereFittedPIterator::getBSphere
const BoundingSphere & getBSphere() const
Definition: RandomSpherePacker.hpp:76
esys::lsm::TwoDSphereSphereFitter
Definition: SphereFitter.h:362
esys::lsm::RandomSpherePacker::getBSphere
const BoundingSphere & getBSphere() const
Definition: RandomSpherePacker.hpp:274
esys::lsm::SphereFittedPIterator::ParticleVector
Packer::ParticleVector ParticleVector
Definition: RandomSpherePacker.h:41
esys::lsm::SphereFittedPIterator::TwoDSFitter
TwoDSphereFitter< FitTraits > TwoDSFitter
Definition: RandomSpherePacker.h:57
esys::lsm::SphereFittedPIterator::Particle
Packer::Particle Particle
Definition: RandomSpherePacker.h:40
esys::lsm::RandomSpherePacker::ParticleGenerator
Inherited::ParticleGenerator ParticleGenerator
Definition: RandomSpherePacker.h:117
esys::lsm::RandomSpherePacker::getMaxInsertionFailures
int getMaxInsertionFailures() const
Definition: RandomSpherePacker.hpp:343
esys::lsm::SphereFittedPIterator::getClosestNeighbours
ParticleVector getClosestNeighbours(const Particle &particle, int numClosest)
Definition: RandomSpherePacker.hpp:131
esys::lsm::SphereFittedPIterator::Plane
FitterTraits::Plane3D Plane
Definition: RandomSpherePacker.h:37
esys::lsm::RandomSpherePacker::ParticlePoolPtr
Inherited::ParticlePoolPtr ParticlePoolPtr
Definition: RandomSpherePacker.h:124
esys::lsm::SphereFittedPIterator::FitTraits
Definition: RandomSpherePacker.h:44