ESyS-Particle  4.0.1
ParticleCollection.h
1 
2 // //
3 // Copyright (c) 2003-2011 by The University of Queensland //
4 // Earth Systems Science Computational Centre (ESSCC) //
5 // http://www.uq.edu.au/esscc //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 #ifndef ESYS_LSMPARTICLECOLLECTION_H
14 #define ESYS_LSMPARTICLECOLLECTION_H
15 
16 #include "Foundation/BoundingBox.h"
17 #include "Foundation/StlIterator.h"
18 #include "Geometry/Vec3L.h"
19 
20 #include <boost/shared_ptr.hpp>
21 #include <boost/pool/object_pool.hpp>
22 
23 #include <vector>
24 #include <float.h>
25 
26 namespace esys
27 {
28  namespace lsm
29  {
33  template <typename TmplParticle>
35  {
36  public:
37  typedef TmplParticle Particle;
38  typedef boost::object_pool<Particle> ParticlePool;
39  typedef boost::shared_ptr<ParticlePool> ParticlePoolPtr;
40 
41  private:
42  typedef std::vector<Particle *> ParticleVector;
45 
46  public:
47 
49  {
50  public:
51  typedef Particle& value_type;
53  : VectorIterator(it)
54  {
55  }
56 
57  value_type next()
58  {
59  return *(VectorIterator::next());
60  }
61 
62  value_type current() const
63  {
64  return *(VectorIterator::current());
65  }
66  };
67 
69  {
70  public:
71  typedef const Particle& value_type;
74  {
75  }
76 
79  {
80  }
81 
82  value_type next()
83  {
84  return *(VectorConstIterator::next());
85  }
86 
87  value_type current() const
88  {
89  return *(VectorConstIterator::current());
90  }
91  };
92 
94 
95  ParticleCollection(ParticlePoolPtr particlePoolPtr);
96 
98 
99  ParticleCollection &operator=(const ParticleCollection &p);
100 
101  virtual ~ParticleCollection();
102 
103  int getNumParticles() const;
104 
105  BoundingBox getParticleBBox() const;
106 
107  ParticleIterator getParticleIterator()
108  {
109  return ParticleIterator(VectorIterator(m_particleVector));
110  }
111 
112  ParticleConstIterator getParticleIterator() const
113  {
114  return ParticleConstIterator(VectorConstIterator(m_particleVector));
115  }
116 
122  void translateBy(const Vec3 &vec);
123 
131  void rotate(const Vec3 &rotation, const Vec3 &posn);
132 
138  void incrementIdBy(typename Particle::Id idIncr);
139 
144  void insertRef(Particle &p);
145 
151  Particle &createParticle(const Particle &p);
152 
153  protected:
158  void noCheckInsertRef(Particle &p);
159 
160  private:
161  ParticlePoolPtr m_particlePoolPtr;
162  ParticleVector m_particleVector;
163  };
164  };
165 };
166 
167 #include "Geometry/ParticleCollection.hpp"
168 
169 #endif