14 #ifndef ESYS_LSMRANDOMBOXPACKER_H
15 #define ESYS_LSMRANDOMBOXPACKER_H
17 #include "Foundation/console.h"
18 #include "Foundation/Rng.h"
19 #include "Geometry/CubicBoxPacker.h"
20 #include "Geometry/SphereFitter.h"
21 #include "Geometry/Plane.h"
24 #include <boost/shared_ptr.hpp>
30 template <
typename TmplFitterTraits>
34 typedef TmplFitterTraits FitterTraits;
35 typedef typename FitterTraits::Plane Plane;
36 typedef typename FitterTraits::PlaneVector PlaneVector;
37 typedef typename FitterTraits::Packer Packer;
38 typedef typename Packer::Particle Particle;
39 typedef typename Packer::ParticleVector ParticleVector;
44 typedef Packer Validator;
45 typedef typename Packer::Particle Particle;
46 typedef typename Packer::ParticleVector ParticleVector;
47 typedef typename FitterTraits::Plane Plane;
51 typedef boost::shared_ptr<Fitter> FitterPtr;
52 typedef std::vector<FitterPtr> FitterPtrVector;
61 int maxInsertionFailures,
62 const PlaneVector &fitPlaneVector
65 void initialiseFitterPtrVector();
67 int getMaxInsertionFailures()
const;
69 const FitterPtrVector &getFitterPtrVector()
const;
71 FitterPtrVector &getFitterPtrVector();
73 const PlaneVector &getFitPlaneVector()
const;
75 const Packer &getPacker()
const;
79 Plane getClosestFitPlane(
const Particle &particle)
const;
81 double getRandom(
double min,
double max)
const;
83 Vec3 getRandomPoint()
const;
85 Particle getCandidateParticle(
const Vec3 &point);
87 ParticleVector getClosestNeighbours(
const Particle& particle,
int numClosest);
89 Particle &generateNext();
99 PlaneVector m_fitPlaneVector;
100 int m_maxInsertionFailures;
104 FitterPtrVector m_fitterPtrVector;
110 template <
typename TmplParticleGenerator,
template <
typename TmplPartGen>
class TmplCubicBoxPackerWrap>
111 class RandomBoxPacker :
public TmplCubicBoxPackerWrap<TmplParticleGenerator>::CubicBoxPackerBase
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;
122 typedef typename NTable::ParticleVector ParticleVector;
123 typedef typename Inherited::ParticlePool ParticlePool;
124 typedef typename Inherited::ParticlePoolPtr ParticlePoolPtr;
125 typedef std::vector<Plane> PlaneVector;
131 typedef esys::lsm::Plane Plane;
132 typedef typename Packer::PlaneVector PlaneVector;
137 ParticleGeneratorPtr particleGeneratorPtr,
138 ParticlePoolPtr particlePoolPtr,
141 const BoolVector &periodicDimensions,
143 double cubicPackRadius,
144 int maxInsertionFailures
148 ParticleGeneratorPtr particleGeneratorPtr,
149 ParticlePoolPtr particlePoolPtr,
152 const BoolVector &periodicDimensions,
154 double cubicPackRadius,
155 int maxInsertionFailures,
156 const PlaneVector &fitPlaneVector
161 PlaneVector getDefaultFitPlaneVector()
const;
163 bool particleIsValid(
const Particle &particle)
const;
165 virtual void generate();
167 double getRandom(
double min,
double max)
const;
169 Vec3 getRandomPoint()
const;
171 ParticleVector getClosestNeighbours(
const Particle& particle,
int numClosest);
173 int getMaxInsertionFailures()
const;
175 void generateRandomFill();
177 const PlaneVector &getFitPlaneVector()
const;
179 Plane getClosestFitPlane(
const Particle &particle)
const;
182 PlaneVector m_fitPlaneVector;
183 int m_maxInsertionFailures;
188 #include "Geometry/RandomBoxPacker.hpp"