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();