ESyS-Particle  2.3.2
RandomBoxPacker.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_LSMRANDOMBOXPACKER_H
15 #define ESYS_LSMRANDOMBOXPACKER_H
16 
17 #include "Foundation/console.h"
18 #include "Foundation/Rng.h"
20 #include "Geometry/SphereFitter.h"
21 #include "Geometry/Plane3D.h"
22 
23 #include <vector>
24 #include <boost/shared_ptr.hpp>
25 
26 namespace esys
27 {
28  namespace lsm
29  {
30  template <typename TmplFitterTraits>
32  {
33  public:
34  typedef TmplFitterTraits FitterTraits;
35  typedef typename FitterTraits::Plane3D Plane3D;
37  typedef typename FitterTraits::Packer Packer;
38  typedef typename Packer::Particle Particle;
40 
41  class FitTraits
42  {
43  public:
44  typedef Packer Validator;
45  typedef typename Packer::Particle Particle;
47  typedef typename FitterTraits::Plane3D Plane3D;
48  };
49 
51  typedef boost::shared_ptr<Fitter> FitterPtr;
52  typedef std::vector<FitterPtr> FitterPtrVector;
58 
60  Packer &packer,
61  int maxInsertionFailures,
62  const PlaneVector &fitPlaneVector
63  );
64 
66 
67  int getMaxInsertionFailures() const;
68 
69  const FitterPtrVector &getFitterPtrVector() const;
70 
72 
73  const PlaneVector &getFitPlaneVector() const;
74 
75  const Packer &getPacker() const;
76 
77  Packer &getPacker();
78 
79  Plane3D getClosestFitPlane(const Particle &particle) const;
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 RandomBoxPacker : 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  typedef std::vector<Plane3D> PlaneVector;
126 
128  {
129  public:
133  };
135 
137  ParticleGeneratorPtr particleGeneratorPtr,
138  ParticlePoolPtr particlePoolPtr,
139  NTablePtr nTablePtr,
140  const BoundingBox &bBox,
141  const BoolVector &periodicDimensions,
142  double tolerance,
143  double cubicPackRadius,
144  int maxInsertionFailures
145  );
146 
148  ParticleGeneratorPtr particleGeneratorPtr,
149  ParticlePoolPtr particlePoolPtr,
150  NTablePtr nTablePtr,
151  const BoundingBox &bBox,
152  const BoolVector &periodicDimensions,
153  double tolerance,
154  double cubicPackRadius,
155  int maxInsertionFailures,
156  const PlaneVector &fitPlaneVector
157  );
158 
159  virtual ~RandomBoxPacker();
160 
162 
163  bool particleIsValid(const Particle &particle) const;
164 
165  virtual void generate();
166 
167  double getRandom(double min, double max) const;
168 
169  Vec3 getRandomPoint() const;
170 
171  ParticleVector getClosestNeighbours(const Particle& particle, int numClosest);
172 
173  int getMaxInsertionFailures() const;
174 
175  void generateRandomFill();
176 
177  const PlaneVector &getFitPlaneVector() const;
178 
179  Plane3D getClosestFitPlane(const Particle &particle) const;
180 
181  private:
184  };
185  }
186 }
187 
189 
190 #endif