1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2011 by The University of Queensland //
// Earth Systems Science Computational Centre (ESSCC) //
// http://www.uq.edu.au/esscc //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.opensource.org/licenses/osl-3.0.php //
// //
/////////////////////////////////////////////////////////////
#ifndef ESYS_LSMSPHERENEIGHBOURS_H
#define ESYS_LSMSPHERENEIGHBOURS_H
#include "Geometry/CircularNeighbourTable.h"
#include "Geometry/BasicInteraction.h"
#include <boost/shared_ptr.hpp>
#include <boost/pool/object_pool.hpp>
#include <set>
#include <vector>
#include <float.h>
namespace esys
{
namespace lsm
{
/**
*
*/
template <typename TmplSphere, typename TmplIdPairVector>
class SphereNeighbours
{
public:
typedef int Id;
typedef TmplSphere Sphere;
typedef TmplIdPairVector IdPairVector;
typedef typename IdPairVector::value_type IdPair;
class Cmp
{
public:
bool operator()(const IdPair &c1, const IdPair &c2) const
{
return
(
(c1.first < c2.first)
||
(
(c1.first == c2.first)
&&
(
(c1.second < c2.second)
)
)
);
}
bool operator()(const IdPair *c1, const IdPair *c2) const
{
return (*this)(*c1, *c2);
}
};
public:
typedef std::set<IdPair *,Cmp> IdPairSet;
typedef std::set<const IdPair *,Cmp> ConstIdPairSet;
typedef std::vector<Sphere *> SphereVector;
typedef CircularNeighbourTable<Sphere> NTable;
typedef typename NTable::ParticleIterator SphereIterator;
typedef typename NTable::ParticleConstIterator SphereConstIterator;
public:
typedef typename NTable::BoolVector BoolVector;
SphereNeighbours(
double maxDist,
const BoundingBox &bBox = BoundingBox(Vec3(-10,-10,-10), Vec3(10,10,10)),
const BoolVector &circDimensions = BoolVector(3, false)
);
~SphereNeighbours();
int getNumSpheres() const;
int getNumIdPairs() const;
double getMinRadius() const;
double getMaxRadius() const;
SphereConstIterator getSphereIterator() const;
BoundingBox getSphereBBox() const;
template<typename TmplSphereIterator>
IdPairVector getNeighbours(TmplSphereIterator it);
typedef ForwardConstIterator<IdPairSet> IdPairConstIterator;
class ConstIterator : public IdPairConstIterator
{
public:
typedef const IdPair& value_type;
typedef const IdPair& reference;
ConstIterator(const IdPairSet &set)
: IdPairConstIterator(set)
{
}
value_type next()
{
return *(IdPairConstIterator::next());
}
value_type current() const
{
return *(IdPairConstIterator::current());
}
};
typedef ConstIterator Iterator;
Iterator getIterator() const
{
return Iterator(m_connectionSet);
}
protected:
void insert(Sphere &p);
const IdPair &createIdPair(const Sphere &p1, const Sphere &p2);
private:
typedef boost::shared_ptr<NTable> NTablePtr;
typedef boost::object_pool<IdPair> IdPairPool;
typedef boost::shared_ptr<IdPairPool> IdPairPoolPtr;
IdPairPoolPtr m_connectionPoolPtr;
IdPairSet m_connectionSet;
NTablePtr m_nTablePtr;
double m_minRadius;
double m_maxRadius;
double m_maxDist;
Vec3 m_minPt;
Vec3 m_maxPt;
};
}
}
#include "Geometry/SphereNeighbours.hpp"
#endif
|