14 #ifndef ESYS_LSMRANDOMSPHEREPACKER_H
15 #define ESYS_LSMRANDOMSPHEREPACKER_H
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/Plane.h"
26 #include <boost/shared_ptr.hpp>
32 template <
typename TmplFitterTraits>
36 typedef TmplFitterTraits FitterTraits;
37 typedef typename FitterTraits::Plane 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;
46 typedef Packer Validator;
47 typedef typename Packer::Particle Particle;
48 typedef typename Packer::ParticleVector ParticleVector;
49 typedef typename FitterTraits::Plane Plane;
53 typedef boost::shared_ptr<Fitter> FitterPtr;
54 typedef std::vector<FitterPtr> FitterPtrVector;
63 int maxInsertionFailures,
67 void initialiseFitterPtrVector();
71 int getMaxInsertionFailures()
const;
73 const FitterPtrVector &getFitterPtrVector()
const;
75 FitterPtrVector &getFitterPtrVector();
77 const Packer &getPacker()
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 FitterPtrVector m_fitterPtrVector;
100 int m_maxInsertionFailures;
110 template <
typename TmplParticleGenerator,
template <
typename TmplPartGen>
class TmplCubicBoxPackerWrap>
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;
130 typedef esys::lsm::Plane Plane;
131 typedef std::vector<Plane> PlaneVector;
136 ParticleGeneratorPtr particleGeneratorPtr,
137 ParticlePoolPtr particlePoolPtr,
141 double cubicPackRadius,
142 int maxInsertionFailures,
150 bool particleIsValid(
const Particle &particle)
const;
152 double getRandom(
double min,
double max)
const;
154 Vec3 getRandomPoint()
const;
156 ParticleVector getClosestNeighbours(
const Particle& particle,
int numClosest);
158 int getMaxInsertionFailures()
const;
160 bool particleFitsInBSphere(
const Particle &particle)
const;
162 bool particleFitsInBSphereWithNeighbours(
const Particle &particle)
const;
164 void generateCubicPackingInSphere();
166 void generateRandomFill();
168 virtual void generate();
172 int m_maxInsertionFailures;
177 #include "Geometry/RandomSpherePacker.hpp"