18 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
19 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::CubicBoxPacker(
20 ParticleGeneratorPtr particleGeneratorPtr,
21 ParticlePoolPtr particlePoolPtr,
23 const BoundingBox &bBox,
24 const BoolVector &periodicDimensions,
26 double cubicPackRadius
34 m_cubicPackRadius(cubicPackRadius),
35 m_particleGeneratorPtr(particleGeneratorPtr),
36 m_pParticleGenerator(particleGeneratorPtr.get())
40 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
41 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::~CubicBoxPacker()
45 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
46 const typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::ParticleGenerator &
47 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getParticleGenerator()
const
49 return *m_pParticleGenerator;
52 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
53 typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::ParticleGenerator &
54 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getParticleGenerator()
56 return *m_pParticleGenerator;
59 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
61 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::setParticleGenerator(
62 ParticleGenerator &particleGenerator
65 m_pParticleGenerator = &particleGenerator;
66 m_particleGeneratorPtr = ParticleGeneratorPtr();
69 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
71 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::setParticleGenerator(
72 ParticleGeneratorPtr particleGeneratorPtr
75 m_particleGeneratorPtr = particleGeneratorPtr;
76 m_pParticleGenerator = m_particleGeneratorPtr.get();
79 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
81 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getCubicPackingRadius()
const
83 return m_cubicPackRadius;
86 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
87 typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::Particle
88 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getCandidateParticle(
93 return getParticleGenerator().getParticle(point, radius);
96 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
97 typename CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::Particle
98 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::getCandidateParticle(
102 return getParticleGenerator().getParticle(point);
105 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
107 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::generateCubicPacking()
109 GridIterator pointIt = GridIterator(this->getBBox(), getCubicPackingRadius());
110 while (pointIt.hasNext()) {
111 const Particle candidate =
112 getCandidateParticle(pointIt.next(), getCubicPackingRadius());
113 if (this->particleFitsInBBoxWithNeighbours(candidate)) {
114 this->createAndInsertParticle(candidate);
119 template <
typename TmplParticleGenerator,
typename TmplBoxPackerBase>
121 CubicBoxPacker<TmplParticleGenerator,TmplBoxPackerBase>::generate()
123 generateCubicPacking();