GenGeo  1.1
MNTable3D.h
Go to the documentation of this file.
1 
2 // //
3 // Copyright (c) 2007-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 #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 
50 using std::vector;
51 using std::map;
52 using std::pair;
53 
54 
61 class MNTable3D
62 {
63  public: // types
64  typedef pair<int,int> bond;
65 
66  protected:
68  map<int,set<bond> > m_bonds;
70  Vector3 m_min_pt, m_max_pt; // original min/max point
71  double m_celldim;
72  int m_nx,m_ny,m_nz;
73  unsigned int m_ngroups;
74  static int s_output_style;
75  static double s_small_value;
77  // bounding box handling
82 
83  virtual int getIndex(const Vector3&) const;
84  inline int idx(int i,int j, int k) const{return i*m_ny*m_nz+j*m_nz+k;};
85  void WriteAsVtkXml(ostream&) const;
86  virtual void set_x_circ();
87  virtual void set_y_circ();
88  virtual void set_z_circ();
90 
91  public:
92  MNTable3D();
93  MNTable3D(const Vector3&,const Vector3&,double,unsigned int);
94  virtual ~MNTable3D();
95 
96  bool insertFromRawFile(const string&,double,double);
97  virtual bool insert(const Sphere&,unsigned int);
98  virtual bool insertChecked(const Sphere&,unsigned int,double=s_small_value);
99  virtual bool checkInsertable(const Sphere&,unsigned int);
100  void GrowNGroups(unsigned int);
101  const multimap<double,const Sphere*> getSpheresClosestTo(const Vector3&,unsigned int) const;
102  const multimap<double,const Sphere*> getSpheresFromGroupNear(const Vector3&,double,int) const;
103  const vector<const Sphere*> getAllSpheresFromGroup(int) const;
104  const Sphere* getClosestSphereFromGroup(const Sphere&,int) const;
105  int getTagOfClosestSphereFromGroup(const Sphere&,int) const;
106  const Sphere* getClosestSphereFromGroup(const Sphere&,int,double,double,double) const;
107  int getTagOfClosestSphereFromGroup(const Sphere&,int,double,double,double) const;
108  void tagParticlesAlongPlane(const Plane&,double,int,unsigned int);
109  void tagParticlesAlongPlaneWithMask(const Plane&,double,int,int,unsigned int);
110  void tagParticlesInSphere(const Sphere&,int,unsigned int);
111  void tagParticlesInGroupNT(int tag,int gid){tagParticlesInGroup(tag,gid,-1);};
112  void tagParticlesInGroup(int,int,int);
113  void tagParticlesToClosest(int,int);
114  void tagParticlesToClosestAnisotropic(int,int,double,double,double);
115  void removeParticlesWithTag(int,unsigned int);
116  void removeParticlesWithTagMask(unsigned int,int,int);
117  void removeParticlesInVolume(AVolume3D*, int, bool);
118  void removeParticlesInGroup(unsigned int);
119  void tagParticlesAlongJoints(const TriPatchSet&,double,int, int, unsigned int);
120  void tagParticlesInVolume(const AVolume&,int,unsigned int);
122 
123  // bbx handling
124  virtual void calculateTightBoundingBox();
125  void setBoundingBoxTracking(bool);
126 
127  boost::python::list getSphereListFromGroup(int) const;
128  boost::python::list getSphereListDist(const Vector3&, double, int) const;
129  virtual void generateBonds(int,double,int);
130  virtual void generateClusterBonds(int,double,int,int);
131  virtual void generateBondsWithJointSet(const TriPatchSet&,int,double,int);
132  virtual void generateBondsTagged(int,double,int,int,int);
133  virtual void generateRandomBonds(int,double,double,int,int,int);
134 
135  void insertBond(int,int,int);
136 
137 
138 
139  // output
140  double getSumVolume(int);
141  friend ostream& operator << (ostream&,const MNTable3D&);
142  static void SetOutputStyle(int);
143  void SetOutputPrecision(int);
144  void SetWriteTightBoundingBox(bool);
145  void write(char *filename, int outputStyle);
146 };
147 #endif // __MNTABLE_H