GranOO  3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
BWDelaunay.hpp
Go to the documentation of this file.
1 // This file is part of GranOO, a workbench for DEM simulation.
2 //
3 // Author(s) : - Damien Andre IRCER/UNILIM, Limoges France
4 // <damien.andre@unilim.fr>
5 // - Jean-luc Charles Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
6 // <jean-luc.charles@ensam.eu>
7 // - Jeremie Girardot Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
8 // <jeremie.girardot@ensam.eu>
9 // - Cedric Hubert LAMIH/UPHF, Valenciennes France
10 // <cedric.hubert@uphf.fr>
11 // - Ivan Iordanoff Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
12 // <ivan.iordanoff@ensam.eu>
13 //
14 // Copyright (C) 2008-2019 D. Andre, JL. Charles, J. Girardot, C. Hubert, I. Iordanoff
15 //
16 // This program is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 // This program is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this program. If not, see <http://www.gnu.org/licenses/>.
28 
29 #ifndef BWDelaunay_H
30 #define BWDelaunay_H
31 
32 #include <vector>
33 #include <string>
34 
35 class BWDelaunay {
36 
37 public:
41  BWDelaunay(const std::vector<double> &points);
42 
43 public:
47  void set_vertices(const std::vector<double> &points);
48 
52  void tetrahedralize();
53 
57  unsigned int vertex_number() {
58  return (unsigned int)(_vertices.size()/3);
59  };
60 
66  inline const double *vertex_ptr(unsigned int vertexIndex) const {
67  return &(_vertices[3*vertexIndex]);
68  };
69 
73  unsigned int edge_number() {
74  return (unsigned int)(_edgesToVertex.size()/2);
75  };
76 
80  inline const unsigned int *edge_ptr(unsigned int edgeIndex) const {
81  return &(_edgesToVertex[2*edgeIndex]);
82  };
83 
88  void export_to_mesh_file(std::string filePath);
89 
90 private:
96  unsigned int new_tetrahedron();
97 
103  unsigned int new_tetrahedron(unsigned int v0Index, unsigned int v1Index, unsigned int v2Index, unsigned int v3Index);
104 
108  void delete_tetrahedron(unsigned int tetIndex);
109 
113  void tetrahedron_circum_centre(double (&centre)[3], unsigned int tetIndex);
114 
119  bool is_point_inside_tet_circumsphere(unsigned int pointIndex, unsigned int tetIndex);
120 
125  bool is_virtual_tetrahedron(unsigned int tetIndex);
126 
127 private:
131  static const unsigned int NotInList = (unsigned int)(-1);
132 
133 private:
137  std::vector<double> _vertices;
138 
142  std::vector<unsigned int> _virtualVertices;
143 
147  std::vector<unsigned int> _tetToVertex;
148 
152  std::vector<unsigned int> _tetToTet;
153 
157  std::vector<unsigned int> _nextTetrahedron;
158 
162  std::vector<unsigned int> _edgesToVertex;
163 
167  std::vector<double> _circumRadii;
168 
172  std::vector<double> _circumCentres;
173 
177  unsigned int _firstFreeTetIndex;
178 
182  double _minPoint[3];
183 
187  double _midPoint[3];
188 
192  double _maxPoint[3];
193 };
194 
195 
196 
197 #endif
Definition: BWDelaunay.hpp:35
void export_to_mesh_file(std::string filePath)
Exports the tetrahedralization to a Gmsh .mesh file, containing the vertices, edges and tetrahedra.
Definition: BWDelaunay.cpp:461
unsigned int new_tetrahedron()
Creates a new empty tetrahedron.
Definition: BWDelaunay.cpp:302
BWDelaunay(const std::vector< double > &points)
instanciate a new Bowyer-Watson Delaunay triangulation with given points.
Definition: BWDelaunay.cpp:41
unsigned int vertex_number()
Definition: BWDelaunay.hpp:57
std::vector< double > _circumRadii
The radii of the tetrahedra circumspheres.
Definition: BWDelaunay.hpp:167
void delete_tetrahedron(unsigned int tetIndex)
Deletes the tetrahedron with index tetIndex.
Definition: BWDelaunay.cpp:373
std::vector< unsigned int > _edgesToVertex
The relationship between tetrahedra edges and their vertices index.
Definition: BWDelaunay.hpp:162
std::vector< unsigned int > _tetToVertex
The relationship between tetrahedra and their vertices index.
Definition: BWDelaunay.hpp:147
void set_vertices(const std::vector< double > &points)
Set the points to be triangulated.
Definition: BWDelaunay.cpp:49
double _maxPoint[3]
The max point of the vertices bounding box.
Definition: BWDelaunay.hpp:192
std::vector< double > _vertices
The list of vertices coordinates in the tetrahedralization.
Definition: BWDelaunay.hpp:137
unsigned int edge_number()
Definition: BWDelaunay.hpp:73
const double * vertex_ptr(unsigned int vertexIndex) const
Allows to get a vertex coordinates array from its index in the _vertices vector.
Definition: BWDelaunay.hpp:66
std::vector< unsigned int > _nextTetrahedron
A vector containing the list of empty spaces in the _tetToVertex vector.
Definition: BWDelaunay.hpp:157
std::vector< unsigned int > _tetToTet
The adjacency relationship between tetrahedra.
Definition: BWDelaunay.hpp:152
void tetrahedralize()
Perform the tetrahedralization on the given set of points.
Definition: BWDelaunay.cpp:77
bool is_virtual_tetrahedron(unsigned int tetIndex)
Definition: BWDelaunay.cpp:285
double _minPoint[3]
The min corner of the vertices bounding box.
Definition: BWDelaunay.hpp:182
static const unsigned int NotInList
A flag to determine if an index is in a list.
Definition: BWDelaunay.hpp:131
bool is_point_inside_tet_circumsphere(unsigned int pointIndex, unsigned int tetIndex)
Definition: BWDelaunay.cpp:396
void tetrahedron_circum_centre(double(&centre)[3], unsigned int tetIndex)
Computes the coordinates of the centre of the circumsphere related to tetrahedron with index tetIndex...
Definition: BWDelaunay.cpp:405
std::vector< unsigned int > _virtualVertices
The list of virtual vertices coordinates in the tetrahedralization.
Definition: BWDelaunay.hpp:142
std::vector< double > _circumCentres
The centre coordinates of the tetrahedra circumspheres.
Definition: BWDelaunay.hpp:172
const unsigned int * edge_ptr(unsigned int edgeIndex) const
Definition: BWDelaunay.hpp:80
unsigned int _firstFreeTetIndex
The index of the first available space in the _tetToVertex vector.
Definition: BWDelaunay.hpp:177
double _midPoint[3]
The mid of the vertices bounding box.
Definition: BWDelaunay.hpp:187