ESyS-Particle  2.3
SphereNeighbours.h
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2014 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
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 
14 #ifndef ESYS_LSMSPHERENEIGHBOURS_H
15 #define ESYS_LSMSPHERENEIGHBOURS_H
16 
19 
20 #include <boost/shared_ptr.hpp>
21 #include <boost/pool/object_pool.hpp>
22 
23 #include <set>
24 #include <vector>
25 #include <float.h>
26 
27 namespace esys
28 {
29  namespace lsm
30  {
34  template <typename TmplSphere, typename TmplIdPairVector>
36  {
37  public:
38  typedef int Id;
39  typedef TmplSphere Sphere;
40  typedef TmplIdPairVector IdPairVector;
41  typedef typename IdPairVector::value_type IdPair;
42 
43  class Cmp
44  {
45  public:
46  bool operator()(const IdPair &c1, const IdPair &c2) const
47  {
48  return
49  (
50  (c1.first < c2.first)
51  ||
52  (
53  (c1.first == c2.first)
54  &&
55  (
56  (c1.second < c2.second)
57  )
58  )
59  );
60  }
61  bool operator()(const IdPair *c1, const IdPair *c2) const
62  {
63  return (*this)(*c1, *c2);
64  }
65  };
66  public:
67  typedef std::set<IdPair *,Cmp> IdPairSet;
68  typedef std::set<const IdPair *,Cmp> ConstIdPairSet;
69  typedef std::vector<Sphere *> SphereVector;
73 
74  public:
75  typedef typename NTable::BoolVector BoolVector;
76 
78  double maxDist,
79  const BoundingBox &bBox = BoundingBox(Vec3(-10,-10,-10), Vec3(10,10,10)),
80  const BoolVector &circDimensions = BoolVector(3, false)
81  );
82 
84 
85  int getNumSpheres() const;
86 
87  int getNumIdPairs() const;
88 
89  double getMinRadius() const;
90 
91  double getMaxRadius() const;
92 
93  SphereConstIterator getSphereIterator() const;
94 
95  BoundingBox getSphereBBox() const;
96 
97  template<typename TmplSphereIterator>
98  IdPairVector getNeighbours(TmplSphereIterator it);
99 
101 
102  class ConstIterator : public IdPairConstIterator
103  {
104  public:
105  typedef const IdPair& value_type;
106  typedef const IdPair& reference;
107  ConstIterator(const IdPairSet &set)
108  : IdPairConstIterator(set)
109  {
110  }
111 
112  value_type next()
113  {
114  return *(IdPairConstIterator::next());
115  }
116 
117  value_type current() const
118  {
119  return *(IdPairConstIterator::current());
120  }
121  };
122  typedef ConstIterator Iterator;
123 
124  Iterator getIterator() const
125  {
126  return Iterator(m_connectionSet);
127  }
128 
129  protected:
130  void insert(Sphere &p);
131 
132  const IdPair &createIdPair(const Sphere &p1, const Sphere &p2);
133 
134  private:
135  typedef boost::shared_ptr<NTable> NTablePtr;
136  typedef boost::object_pool<IdPair> IdPairPool;
137  typedef boost::shared_ptr<IdPairPool> IdPairPoolPtr;
138 
139  IdPairPoolPtr m_connectionPoolPtr;
140  IdPairSet m_connectionSet;
141  NTablePtr m_nTablePtr;
142  double m_minRadius;
143  double m_maxRadius;
144  double m_maxDist;
147  };
148  }
149 }
150 
152 
153 #endif
int Id
Definition: SphereNeighbours.h:38
Vec3 m_maxPt
Definition: SphereNeighbours.h:146
Definition: StlIterator.h:26
reference next()
Definition: StlIterator.h:112
NTable::BoolVector BoolVector
Definition: SphereNeighbours.h:75
Definition: SphereNeighbours.h:43
const IdPair & value_type
Definition: SphereNeighbours.h:105
std::set< IdPair *, Cmp > IdPairSet
Definition: SphereNeighbours.h:67
IdPairSet m_connectionSet
Definition: SphereNeighbours.h:140
double m_minRadius
Definition: SphereNeighbours.h:142
Definition: vec3.h:46
~SphereNeighbours()
Definition: SphereNeighbours.hpp:59
IdPairPoolPtr m_connectionPoolPtr
Definition: SphereNeighbours.h:139
const IdPair & createIdPair(const Sphere &p1, const Sphere &p2)
Definition: SphereNeighbours.hpp:96
boost::shared_ptr< IdPairPool > IdPairPoolPtr
Definition: SphereNeighbours.h:137
TmplSphere Sphere
Definition: SphereNeighbours.h:39
CircularNeighbourTable< Sphere > NTable
Definition: SphereNeighbours.h:70
int getNumSpheres() const
Definition: SphereNeighbours.hpp:64
Definition: CheckPointable.cpp:16
double getMaxRadius() const
Definition: SphereNeighbours.hpp:82
Vec3 m_minPt
Definition: SphereNeighbours.h:145
SphereConstIterator getSphereIterator() const
Definition: SphereNeighbours.hpp:89
value_type next()
Definition: SphereNeighbours.h:112
std::vector< Sphere * > SphereVector
Definition: SphereNeighbours.h:69
int getNumIdPairs() const
Definition: SphereNeighbours.hpp:70
3D bounding box
Definition: BoundingBox.h:27
double m_maxDist
Definition: SphereNeighbours.h:144
Definition: SphereNeighbours.h:102
Definition: SphereNeighbours.h:35
NTable::ParticleIterator SphereIterator
Definition: SphereNeighbours.h:71
reference current() const
Definition: StlIterator.h:105
NTable::ParticleConstIterator SphereConstIterator
Definition: SphereNeighbours.h:72
TmplIdPairVector IdPairVector
Definition: SphereNeighbours.h:40
ConstIterator(const IdPairSet &set)
Definition: SphereNeighbours.h:107
value_type current() const
Definition: SphereNeighbours.h:117
std::vector< bool > BoolVector
Definition: CircularNeighbourTable.h:42
BoundingBox getSphereBBox() const
Definition: SphereNeighbours.hpp:271
void insert(Sphere &p)
Definition: SphereNeighbours.hpp:240
Definition: StlIterator.h:29
std::set< const IdPair *, Cmp > ConstIdPairSet
Definition: SphereNeighbours.h:68
Definition: CircularNeighbourTable.h:33
ConstIterator Iterator
Definition: SphereNeighbours.h:122
bool operator()(const IdPair *c1, const IdPair *c2) const
Definition: SphereNeighbours.h:61
double m_maxRadius
Definition: SphereNeighbours.h:143
IdPairVector::value_type IdPair
Definition: SphereNeighbours.h:41
const IdPair & reference
Definition: SphereNeighbours.h:106
ForwardConstIterator< IdPairSet > IdPairConstIterator
Definition: SphereNeighbours.h:100
boost::object_pool< IdPair > IdPairPool
Definition: SphereNeighbours.h:136
Iterator getIterator() const
Definition: SphereNeighbours.h:124
NTablePtr m_nTablePtr
Definition: SphereNeighbours.h:141
double getMinRadius() const
Definition: SphereNeighbours.hpp:76
boost::shared_ptr< NTable > NTablePtr
Definition: SphereNeighbours.h:135
SphereNeighbours(double maxDist, const BoundingBox &bBox=BoundingBox(Vec3(-10,-10,-10), Vec3(10, 10, 10)), const BoolVector &circDimensions=BoolVector(3, false))
Definition: SphereNeighbours.hpp:23
IdPairVector getNeighbours(TmplSphereIterator it)
Definition: SphereNeighbours.hpp:137
bool operator()(const IdPair &c1, const IdPair &c2) const
Definition: SphereNeighbours.h:46