59 #include <vtkPolyData.h>
60 #include <vtkPoints.h>
61 #include <vtkPolyDataReader.h>
62 #include <vtkXMLPolyDataReader.h>
63 #include <vtkDataReader.h>
64 #include <vtkCellArray.h>
65 #include <vtkCharArray.h>
66 #include <vtkPointData.h>
67 #include <vtkDataArray.h>
97 Mesh():
Triangles(), name_(
""), all_vertices_(0), outermost_(false), allocate_(false), current_barrier_(false), isolated_(false) { }
103 Mesh(
const unsigned& nv,
const unsigned& nt): name_(
""), outermost_(false), allocate_(true), current_barrier_(false), isolated_(false) {
105 all_vertices_->reserve(nv);
115 Mesh(
Vertices& av,
const std::string name =
""): name_(name), all_vertices_(&av), outermost_(false), allocate_(false), current_barrier_(false), isolated_(false) {
116 set_vertices_.insert(all_vertices_->begin(), all_vertices_->end());
121 Mesh(std::string filename,
const bool verbose=
true,
const std::string n=
""): name_(n), outermost_(false), allocate_(true), current_barrier_(false), isolated_(false) {
122 unsigned nb_v = load(filename,
false,
false);
124 load(filename, verbose);
144 std::string &
name() {
return name_; }
145 const std::string &
name()
const {
return name_; }
162 void info(
const bool verbous =
false)
const;
174 for (iterator tit = begin(); tit != end(); ++tit)
194 void smooth(
const double& smoothing_intensity,
const unsigned& niter);
206 unsigned load(
const std::string& filename,
const bool& verbose=
true,
const bool& read_all=
true);
207 unsigned load_tri(std::istream& ,
const bool& read_all =
true);
208 unsigned load_tri(
const std::string&,
const bool& read_all =
true);
209 unsigned load_bnd(std::istream& ,
const bool& read_all =
true);
210 unsigned load_bnd(
const std::string&,
const bool& read_all =
true);
211 unsigned load_off(std::istream& ,
const bool& read_all =
true);
212 unsigned load_off(
const std::string&,
const bool& read_all =
true);
213 unsigned load_mesh(std::istream& ,
const bool& read_all =
true);
214 unsigned load_mesh(
const std::string&,
const bool& read_all =
true);
217 unsigned load_vtk(std::istream& ,
const bool& read_all =
true);
218 unsigned load_vtk(
const std::string&,
const bool& read_all =
true);
219 unsigned get_data_from_vtk_reader(vtkPolyDataReader* vtkMesh,
const bool& read_all);
221 template <
typename T>
222 unsigned load_vtk(T,
const bool& read_all =
true) {
223 std::cerr <<
"You have to compile OpenMEEG with VTK to read VTK/VTP files. (specify USE_VTK to cmake)" << std::endl;
229 unsigned load_gifti(
const std::string&,
const bool& read_all =
true);
230 void save_gifti(
const std::string&)
const;
232 template <
typename T>
234 std::cerr <<
"You have to compile OpenMEEG with GIFTI to read GIFTI files" << std::endl;
237 template <
typename T>
239 std::cerr <<
"You have to compile OpenMEEG with GIFTI to read GIFTI files" << std::endl;
248 void save(
const std::string& filename)
const ;
269 typedef std::map<std::pair<const Vertex *, const Vertex *>,
int>
EdgeMap;
291 std::map<const Vertex*,VectPTriangle>
links_;
unsigned load_mesh(const std::string &, const bool &read_all=true)
void update()
recompute triangles normals, area, and links
std::vector< Triangle * > VectPTriangle
bool current_barrier_
handle multiple 0 conductivity domains
void laplacian(SymMatrix &A) const
compute mesh laplacian
unsigned load_vtk(T, const bool &read_all=true)
const_vertex_reverse_iterator vertex_rend() const
bool has_correct_orientation() const
check the local orientation of the mesh triangles
const bool & outermost() const
Returns True if it is an outermost mesh.
void correct_local_orientation()
correct the local orientation of the mesh triangles
Mesh(const unsigned &nv, const unsigned &nt)
constructor from scratch (add vertices/triangles one by one)
VectPVertex vertices_
Vector of pointers to the mesh vertices.
void save_off(const std::string &) const
VectPVertex::iterator vertex_iterator
bool allocate_
Are the vertices allocate within the mesh or shared ?
unsigned load_tri(const std::string &, const bool &read_all=true)
size_t vertex_size() const
void save_bnd(const std::string &) const
size_t nb_vertices() const
unsigned load_bnd(std::istream &, const bool &read_all=true)
size_t nb_all_vertices() const
unsigned load(const std::string &filename, const bool &verbose=true, const bool &read_all=true)
Read mesh from file.
Vect3 P1gradient(const Vect3 &p0, const Vect3 &p1, const Vect3 &p2) const
P1gradient : aux function to compute the surfacic gradient.
bool intersection(const Mesh &) const
check if the mesh intersects another mesh
unsigned load_off(const std::string &, const bool &read_all=true)
VectPVertex::const_iterator const_vertex_iterator
void smooth(const double &smoothing_intensity, const unsigned &niter)
Smooth Mesh.
bool outermost_
Is it an outermost mesh ? (i.e does it touch the Air domain)
unsigned load_mesh(std::istream &, const bool &read_all=true)
bool triangle_intersection(const Triangle &, const Triangle &) const
size_t nb_triangles() const
Normal normal(const Vertex &v) const
get the Normal at vertex
unsigned load_off(std::istream &, const bool &read_all=true)
void correct_global_orientation()
correct the global orientation (if there is one)
void merge(const Mesh &, const Mesh &)
properly merge two meshes into one
friend std::istream & operator>>(std::istream &is, Mesh &m)
insert a triangle into the mesh
vertex_iterator vertex_end()
void save_mesh(const std::string &) const
std::map< const Vertex *, VectPTriangle > links_
links[&v] are the triangles that contain vertex v.
bool has_self_intersection() const
check if the mesh self-intersects
Mesh(std::string filename, const bool verbose=true, const std::string n="")
constructor loading directly a mesh file named
void generate_indices()
generate indices (if allocate)
const std::string & name() const
Mesh(const Mesh &m)
constructor from another mesh
unsigned load_tri(std::istream &, const bool &read_all=true)
const EdgeMap compute_edge_map() const
const bool & current_barrier() const
double compute_solid_angle(const Vect3 &p) const
Given a point p, it computes the solid angle.
void save(const std::string &filename) const
Save mesh to file.
unsigned load_gifti(T, const bool &)
void build_mesh_vertices()
construct the list of the mesh vertices out of its triangles
void add_vertex(const Vertex &v)
properly add vertex to the list.
const VectPVertex & vertices() const
const_vertex_reverse_iterator vertex_rbegin() const
void info(const bool verbous=false) const
Print info Print to std::cout some info about the mesh.
std::set< Vertex > set_vertices_
const VectPTriangle & get_triangles_for_vertex(const Vertex &V) const
get the triangles associated with vertex V
std::string name_
Name of the mesh.
VectPVertex::const_reverse_iterator const_vertex_reverse_iterator
const bool & isolated() const
vertex_iterator vertex_begin()
Mesh()
default constructor
unsigned load_bnd(const std::string &, const bool &read_all=true)
std::vector< Vertex * > VectPVertex
VectPTriangle adjacent_triangles(const Triangle &) const
get the adjacent triangles
void save_tri(const std::string &) const
void gradient_norm2(SymMatrix &A) const
Compute the square norm of the surfacic gradient.
Mesh(Vertices &av, const std::string name="")
constructor using an outisde storage for vertices
Vertices all_vertices() const
const_vertex_iterator vertex_begin() const
double P0gradient_norm2(const Triangle &t1, const Triangle &t2) const
P0gradient_norm2 : aux function to compute the square norm of the surfacic gradient.
void orient_adjacent_triangles(std::stack< Triangle * > &t_stack, std::map< Triangle *, bool > &tri_reoriented)
std::map< std::pair< const Vertex *, const Vertex * >, int > EdgeMap
map the edges with an unsigned
void save_vtk(const std::string &) const
const_vertex_iterator vertex_end() const
Mesh & operator=(const Mesh &m)
void flip_triangles()
Flip all triangles.
Vertices * all_vertices_
Pointer to all the vertices.
std::vector< Vertex > Vertices
std::vector< Triangle > Triangles
std::vector< Mesh > Meshes
A vector of Mesh is called Meshes.