ESyS-Particle  2.3.2
RandomSpherePacker.h
Go to the documentation of this file.
1 
2 // //
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_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