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
|
/////////////////////////////////////////////////////////////
// //
// 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_LSMNEIGHBOURTABLE_H
#define ESYS_LSMNEIGHBOURTABLE_H
#include <Foundation/BoundingBox.h>
#include <Foundation/StlIterator.h>
#include <Geometry/Vec3L.h>
#include <vector>
#include <algorithm>
#include <boost/shared_array.hpp>
namespace esys
{
namespace lsm
{
/**
*
*/
template <class TmplParticle>
class NeighbourTable
{
public:
typedef TmplParticle Particle;
typedef std::vector<Particle *> ParticleVector;
NeighbourTable(const BoundingBox &bBox, double gridSpacing);
NeighbourTable(const NeighbourTable &nTable);
virtual ~NeighbourTable();
void clear();
double getGridSpacing() const;
void resize(const BoundingBox &bBox, double gridSpacing);
const Vec3L &getDimensions() const;
const BoundingBox &getBBox() const;
const Vec3 &getMinPt() const;
/**
* Return the number of particles inserted into this table.
*/
size_t size() const;
int getScalarIndex(int xIdx, int yIdx, int zIdx) const;
int getScalarIndex(const Vec3L &index) const;
int getScalarIndex(const Vec3 &pt) const;
const Vec3L &getMinVecIndex() const;
const Vec3L &getMaxVecIndex() const;
Vec3L getVecIndex(const Vec3 &pt) const;
ParticleVector getNeighbourVector(const Vec3 &pt, double radius) const;
ParticleVector getUniqueNeighbourVector(const Vec3 &pt, double radius) const;
ParticleVector getNeighbourVector(const Vec3 &pt) const;
void insert(Particle *pParticle);
void insert(Particle &particle);
typedef ForwardIterator<ParticleVector> ParticleIterator;
typedef ForwardConstIterator<ParticleVector> ParticleConstIterator;
ParticleIterator getParticleIterator();
ParticleConstIterator getParticleIterator() const;
protected:
void insertInTable(Particle *pParticle, const Vec3L &minIdx, const Vec3L &maxIdx);
void addInserted(Particle *pParticle);
int getNumCells() const;
ParticleVector getInsertedParticles() const;
void clearAndRecomputeGrid(const BoundingBox &bBox, double gridSpacing);
private:
typedef boost::shared_array<ParticleVector> ParticleVectorArrayPtr;
Vec3L m_dimensions;
Vec3L m_minIndex;
Vec3L m_maxIndex;
double m_gridSpacing;
BoundingBox m_bBox;
ParticleVector m_insertedParticles;
ParticleVectorArrayPtr m_tablePtr;
};
}
}
#include "Geometry/NeighbourTable.hpp"
#endif
|