| 1 |
///////////////////////////////////////////////////////////// |
| 2 |
// // |
| 3 |
// Copyright (c) 2007-2017 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.apache.org/licenses/LICENSE-2.0 // |
| 10 |
// // |
| 11 |
///////////////////////////////////////////////////////////// |
| 12 |
|
| 13 |
#ifndef __MNTABLE3D_H |
| 14 |
#define __MNTABLE3D_H |
| 15 |
|
| 16 |
// --- STL includes --- |
| 17 |
#include <boost/python.hpp> |
| 18 |
#include <vector> |
| 19 |
#include <map> |
| 20 |
#include <string> |
| 21 |
#include <set> |
| 22 |
|
| 23 |
using std::vector; |
| 24 |
using std::map; |
| 25 |
using std::multimap; |
| 26 |
using std::string; |
| 27 |
using std::set; |
| 28 |
|
| 29 |
|
| 30 |
// --- IO includes --- |
| 31 |
#include <iostream> |
| 32 |
|
| 33 |
using std::ostream; |
| 34 |
|
| 35 |
// --- Project includes --- |
| 36 |
#include "MNTCell.h" |
| 37 |
#include "AVolume3D.h" |
| 38 |
#include "AVolume.h" |
| 39 |
#include "geometry/Sphere.h" |
| 40 |
#include "util/vector3.h" |
| 41 |
#include "geometry/Plane.h" |
| 42 |
#include "JointSet.h" |
| 43 |
#include "TriPatchSet.h" |
| 44 |
|
| 45 |
// --- STL includes --- |
| 46 |
#include <vector> |
| 47 |
#include <map> |
| 48 |
#include <utility> |
| 49 |
#include <string> |
| 50 |
|
| 51 |
using std::vector; |
| 52 |
using std::map; |
| 53 |
using std::pair; |
| 54 |
using std::string; |
| 55 |
|
| 56 |
/*! |
| 57 |
\class MNTable3D |
| 58 |
\brief Multi-group Neighbour table |
| 59 |
|
| 60 |
Neighbour table supporting multiple tagged groups of particles |
| 61 |
*/ |
| 62 |
class MNTable3D |
| 63 |
{ |
| 64 |
public: // types |
| 65 |
typedef pair<int,int> bond; |
| 66 |
|
| 67 |
protected: |
| 68 |
MNTCell* m_data; |
| 69 |
map<int,set<bond> > m_bonds; |
| 70 |
Vector3 m_origin; //!< origin |
| 71 |
Vector3 m_min_pt, m_max_pt; // original min/max point |
| 72 |
double m_celldim; //!< cell size |
| 73 |
int m_nx,m_ny,m_nz; //!< number of cells in x-, y- and z-direction |
| 74 |
unsigned int m_ngroups; |
| 75 |
static int s_output_style; |
| 76 |
static double s_small_value; |
| 77 |
int m_x_periodic,m_y_periodic,m_z_periodic; |
| 78 |
// bounding box handling |
| 79 |
bool m_bbx_tracking; //!< if true, bbx is updated for each insert operation |
| 80 |
bool m_has_tight_bbx; //!< true if a tight bounding box has been calculated |
| 81 |
bool m_write_tight_bbx; //!< if true, tight bbx is written instead of min/max |
| 82 |
Vector3 m_min_tbbx, m_max_tbbx; //!< corner points of tight bounding box |
| 83 |
|
| 84 |
virtual int getIndex(const Vector3&) const; |
| 85 |
inline int idx(int i,int j, int k) const{return i*m_ny*m_nz+j*m_nz+k;}; |
| 86 |
void WriteAsVtkXml(ostream&) const; |
| 87 |
virtual void set_x_circ(); |
| 88 |
virtual void set_y_circ(); |
| 89 |
virtual void set_z_circ(); |
| 90 |
int m_write_prec; //!< precision (nr. of significant digits) for file output |
| 91 |
|
| 92 |
// blocked output handling |
| 93 |
bool m_is_writing_blocks; |
| 94 |
string m_outfilename; |
| 95 |
string m_temp_bondfilename; |
| 96 |
std::ios::pos_type m_np_write_pos; |
| 97 |
unsigned int m_block_particles_written; |
| 98 |
unsigned int m_block_bonds_written; |
| 99 |
|
| 100 |
public: |
| 101 |
MNTable3D(); |
| 102 |
MNTable3D(const Vector3&,const Vector3&,double,unsigned int); |
| 103 |
virtual ~MNTable3D(); |
| 104 |
|
| 105 |
bool insertFromRawFile(const string&,double,double); |
| 106 |
virtual bool insert(const Sphere&,unsigned int); |
| 107 |
virtual bool insertChecked(const Sphere&,unsigned int,double=s_small_value); |
| 108 |
virtual bool checkInsertable(const Sphere&,unsigned int); |
| 109 |
void GrowNGroups(unsigned int); |
| 110 |
const multimap<double,const Sphere*> getSpheresClosestTo(const Vector3&,unsigned int) const; |
| 111 |
const multimap<double,const Sphere*> getSpheresFromGroupNear(const Vector3&,double,int) const; |
| 112 |
const vector<const Sphere*> getAllSpheresFromGroup(int) const; |
| 113 |
const Sphere* getClosestSphereFromGroup(const Sphere&,int) const; |
| 114 |
int getTagOfClosestSphereFromGroup(const Sphere&,int) const; |
| 115 |
const Sphere* getClosestSphereFromGroup(const Sphere&,int,double,double,double) const; |
| 116 |
int getTagOfClosestSphereFromGroup(const Sphere&,int,double,double,double) const; |
| 117 |
void tagParticlesAlongPlane(const Plane&,double,int,unsigned int); |
| 118 |
void tagParticlesAlongPlaneWithMask(const Plane&,double,int,int,unsigned int); |
| 119 |
void tagParticlesInSphere(const Sphere&,int,unsigned int); |
| 120 |
void tagParticlesInGroupNT(int tag,int gid){tagParticlesInGroup(tag,gid,-1);}; |
| 121 |
void tagParticlesInGroup(int,int,int); |
| 122 |
void tagParticlesToClosest(int,int); |
| 123 |
void tagParticlesToClosestAnisotropic(int,int,double,double,double); |
| 124 |
void removeParticlesWithTag(int,unsigned int); |
| 125 |
void removeParticlesWithTagMask(unsigned int,int,int); |
| 126 |
void removeParticlesInVolume(AVolume3D*, int, bool); |
| 127 |
void removeParticlesInGroup(unsigned int); |
| 128 |
void tagParticlesAlongJoints(const TriPatchSet&,double,int, int, unsigned int); |
| 129 |
void tagParticlesInVolume(const AVolume&,int,unsigned int); |
| 130 |
void renumberParticlesContinuous(); |
| 131 |
|
| 132 |
// bbx handling |
| 133 |
virtual void calculateTightBoundingBox(); |
| 134 |
void setBoundingBoxTracking(bool); |
| 135 |
|
| 136 |
boost::python::list getSphereListFromGroup(int) const; |
| 137 |
boost::python::list getSphereListDist(const Vector3&, double, int) const; |
| 138 |
virtual void generateBonds(int,double,int); |
| 139 |
virtual void generateClusterBonds(int,double,int,int); |
| 140 |
virtual void generateBondsWithJointSet(const TriPatchSet&,int,double,int); |
| 141 |
virtual void generateBondsTagged(int,double,int,int,int); |
| 142 |
virtual void generateRandomBonds(int,double,double,int,int,int); |
| 143 |
virtual void removeBonds(); |
| 144 |
|
| 145 |
void insertBond(int,int,int); |
| 146 |
|
| 147 |
// output |
| 148 |
double getSumVolume(int); |
| 149 |
friend ostream& operator << (ostream&,const MNTable3D&); |
| 150 |
static void SetOutputStyle(int); |
| 151 |
void SetOutputPrecision(int); |
| 152 |
void SetWriteTightBoundingBox(bool); |
| 153 |
void write(char *filename, int outputStyle); |
| 154 |
|
| 155 |
// block writing |
| 156 |
void initBlockWriting(const string&); |
| 157 |
void writeBlock(const Vector3&,const Vector3&); |
| 158 |
void writeBondsBlocked(); |
| 159 |
void finishBlockWriting(); |
| 160 |
}; |
| 161 |
#endif // __MNTABLE_H |