ESyS-Particle  2.3.2
SphereNeighbours.h
Go to the documentation of this file.
1 
2 // //
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 
94 
95  BoundingBox getSphereBBox() const;
96 
97  template<typename TmplSphereIterator>
98  IdPairVector getNeighbours(TmplSphereIterator it);
99 
101 
103  {
104  public:
105  typedef const IdPair& value_type;
106  typedef const IdPair& reference;
108  : IdPairConstIterator(set)
109  {
110  }
111 
113  {
114  return *(IdPairConstIterator::next());
115  }
116 
118  {
119  return *(IdPairConstIterator::current());
120  }
121  };
122  typedef ConstIterator Iterator;
123 
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 
142  double m_minRadius;
143  double m_maxRadius;
144  double m_maxDist;
147  };
148  }
149 }
150 
152 
153 #endif