Go to the documentation of this file.
28 template<
typename TmplTraits>
31 int maxInsertionFailures,
36 m_maxInsertionFailures(maxInsertionFailures),
39 m_next(
Fitter::getInvalidParticle()),
46 std::string(
"isValid method returns true for INVALID particle:")
54 template<
typename TmplTraits>
57 return m_maxInsertionFailures;
60 template<
typename TmplTraits>
67 template<
typename TmplTraits>
74 template<
typename TmplTraits>
81 template<
typename TmplTraits>
87 if (getPacker().is2d())
97 m_fitterPtrVector = fitters;
100 template<
typename TmplTraits>
104 return m_fitterPtrVector;
107 template<
typename TmplTraits>
111 return m_fitterPtrVector;
114 template<
typename TmplTraits>
117 return getPacker().getRandomPoint();
120 template<
typename TmplTraits>
126 return getPacker().getCandidateParticle(point);
129 template<
typename TmplTraits>
136 return getPacker().getClosestNeighbours(particle, numClosest);
139 template<
typename TmplTraits>
143 m_next = Fitter::getInvalidParticle();
144 if (m_lastFailCount < getMaxInsertionFailures())
149 Particle particle = Fitter::getInvalidParticle();
153 while ((!fitParticle.isValid()) && (numFails < getMaxInsertionFailures()))
155 particle = getCandidateParticle(getRandomPoint());
156 neighbours = getClosestNeighbours(particle, 4);
159 typename FitterPtrVector::iterator it = getFitterPtrVector().begin();
161 (it != getFitterPtrVector().end())
163 (!fitParticle.isValid())
168 fitParticle = (*it)->getFitParticle(particle, neighbours, plane);
172 m_lastFailCount = numFails;
173 m_successCount += ((fitParticle.isValid()) ? 1 : 0);
174 m_next = fitParticle;
179 template<
typename TmplTraits>
182 return (m_next.isValid() || generateNext().isValid());
185 template<
typename TmplTraits>
189 if (!(m_next.isValid()))
194 m_next = Fitter::getInvalidParticle();
198 template<
typename TmplTraits>
202 <<
"BoundingSphere: minPt = " << getPacker().getBBox().getMinPt()
203 <<
", maxPt = " << getPacker().getBBox().getMaxPt() <<
"\n"
204 <<
"BoundingSphere: sizes = " << getPacker().getBBox().getSizes() <<
"\n";
207 typename FitterPtrVector::iterator it = getFitterPtrVector().begin();
208 (it != getFitterPtrVector().end());
213 console.
Info() <<
"Total successful fits = " << m_successCount <<
"\n";
242 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
249 double cubicPackRadius,
250 int maxInsertionFailures,
254 particleGeneratorPtr,
257 do2d ? bSphere.get2dBBox() : bSphere.
getBBox(),
263 m_maxInsertionFailures(maxInsertionFailures)
267 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
272 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
280 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
290 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
295 getRandom(this->
getBBox().getMinPt().X(), this->
getBBox().getMaxPt().X()),
296 getRandom(this->
getBBox().getMinPt().Y(), this->
getBBox().getMaxPt().Y()),
297 getRandom(this->
getBBox().getMinPt().Z(), this->
getBBox().getMaxPt().Z())
301 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
309 this->getNTable().getUniqueNeighbourVector(
311 this->getParticleGenerator().getMaxFitRadius() + this->getTolerance()
314 neighbourVector.begin(),
315 neighbourVector.end(),
319 if (
static_cast<int>(neighbourVector.size()) > numClosest) {
320 neighbourVector.erase(
321 neighbourVector.begin() + numClosest,
322 neighbourVector.end()
326 return neighbourVector;
329 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
336 this->getParticleGenerator().isValidFitRadius(particle.getRad())
338 particleFitsInBSphereWithNeighbours(particle)
342 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
345 return m_maxInsertionFailures;
348 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
354 getMaxInsertionFailures(),
360 this->createAndInsertParticle(p);
365 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
372 getBSphere().contains(
378 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
386 particleFitsInBSphere(particle)
388 this->particleFitsWithNeighbours(particle)
392 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
398 this->getCandidateParticle(pointIt.
next(), this->getCubicPackingRadius());
399 if (particleFitsInBSphereWithNeighbours(candidate)) {
400 this->createAndInsertParticle(candidate);
405 template <
typename TPartGen,
template <
typename TTPartGen>
class TCubicPackWrap>
408 generateCubicPackingInSphere();
409 generateRandomFill();
DefaultUniformRng s_zeroOneUniform(0.0, 1.0)
Definition: Rng.h:77
Definition: ParticleComparer.h:23
bool particleFitsInBSphereWithNeighbours(const Particle &particle) const
Definition: RandomSpherePacker.hpp:380
bool particleIsValid(const Particle &particle) const
Definition: RandomSpherePacker.hpp:330
Particle getCandidateParticle(const Vec3 &point)
Definition: RandomSpherePacker.hpp:122
virtual void generate()
Definition: RandomSpherePacker.hpp:406
Particle & generateNext()
Definition: RandomSpherePacker.hpp:141
void initialiseFitterPtrVector()
Definition: RandomSpherePacker.hpp:83
Console & Info()
set verbose level of next message to "inf"
std::vector< FitterPtr > FitterPtrVector
Definition: RandomSpherePacker.h:54
Definition: SphereFitter.h:461
const Packer & getPacker() const
Definition: RandomSpherePacker.hpp:62
Inherited::ParticleGeneratorPtr ParticleGeneratorPtr
Definition: RandomSpherePacker.h:118
NTable::ParticleVector ParticleVector
Definition: RandomSpherePacker.h:122
bool particleFitsInBSphere(const Particle &particle) const
Definition: RandomSpherePacker.hpp:367
TmplCubicBoxPackerWrap< TmplParticleGenerator >::CubicBoxPackerBase Inherited
Definition: RandomSpherePacker.h:116
bool hasNext()
Definition: RandomSpherePacker.hpp:180
Definition: BoundingSphere.h:28
const FitterPtrVector & getFitterPtrVector() const
Definition: RandomSpherePacker.hpp:109
Particle m_next
Definition: RandomSpherePacker.h:103
Inherited::NTablePtr NTablePtr
Definition: RandomSpherePacker.h:121
Definition: SphereFitter.h:30
Definition: RandomSpherePacker.h:34
boost::shared_ptr< ParticleFitter > FitterPtr
Definition: RandomBlockGenerator.h:30
FitterTraits::Packer Packer
Definition: RandomSpherePacker.h:39
Definition: CheckPointable.cpp:17
void logInfo()
Definition: RandomSpherePacker.hpp:199
Inherited::Particle Particle
Definition: RandomSpherePacker.h:119
std::string toString(const TmplData &data)
Definition: StringUtil.h:128
Definition: SphereFitter.h:192
ParticleVector getClosestNeighbours(const Particle &particle, int numClosest)
Definition: RandomSpherePacker.hpp:303
RandomSpherePacker(ParticleGeneratorPtr particleGeneratorPtr, ParticlePoolPtr particlePoolPtr, NTablePtr nTablePtr, const BoundingSphere &bSphere, double tolerance, double cubicPackRadius, int maxInsertionFailures, bool do2d)
Definition: RandomSpherePacker.hpp:243
Definition: SphereFitter.h:278
SphereFittedPIterator(Packer &packer, int maxInsertionFailures, const BoundingSphere &bSphere)
Definition: RandomSpherePacker.hpp:29
double getRandom(double min, double max) const
Definition: RandomSpherePacker.hpp:282
std::vector< bool > BoolVector
Definition: BlockGenerator.h:28
virtual ~RandomSpherePacker()
Definition: RandomSpherePacker.hpp:268
int getMaxInsertionFailures() const
Definition: RandomSpherePacker.hpp:55
Vec3 getRandomPoint() const
Definition: RandomSpherePacker.hpp:115
bool hasNext() const
Definition: GridIterator.h:207
void generateRandomFill()
Definition: RandomSpherePacker.hpp:349
Definition: ParticleFitter.h:109
Vec3 getRandomPoint() const
Definition: RandomSpherePacker.hpp:291
void generateCubicPackingInSphere()
Definition: RandomSpherePacker.hpp:393
Particle next()
Definition: RandomSpherePacker.hpp:187
Vec3 next()
Definition: GridIterator.h:255
Console console
Definition: console.cpp:25
const BoundingSphere & getBSphere() const
Definition: RandomSpherePacker.hpp:76
Definition: SphereFitter.h:362
const BoundingSphere & getBSphere() const
Definition: RandomSpherePacker.hpp:274
Packer::ParticleVector ParticleVector
Definition: RandomSpherePacker.h:41
BoundingBox getBBox(const std::string &arg)
Definition: Main.cpp:24
Definition: GridIterator.h:29
Packer::Particle Particle
Definition: RandomSpherePacker.h:40
int getMaxInsertionFailures() const
Definition: RandomSpherePacker.hpp:343
ParticleVector getClosestNeighbours(const Particle &particle, int numClosest)
Definition: RandomSpherePacker.hpp:131
FitterTraits::Plane3D Plane
Definition: RandomSpherePacker.h:37
Inherited::ParticlePoolPtr ParticlePoolPtr
Definition: RandomSpherePacker.h:124