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_; }
156 void add_vertex(
const Vertex& v);
162 void info(
const bool verbous =
false)
const;
163 bool has_self_intersection()
const;
164 bool intersection(
const Mesh&)
const;
165 bool has_correct_orientation()
const;
166 void build_mesh_vertices();
167 void generate_indices();
169 void merge(
const Mesh&,
const Mesh&);
174 for (iterator tit = begin(); tit != end(); ++tit)
178 void correct_local_orientation();
179 void correct_global_orientation();
180 double compute_solid_angle(
const Vect3& p)
const;
181 const VectPTriangle& get_triangles_for_vertex(
const Vertex& V)
const;
182 VectPTriangle adjacent_triangles(
const Triangle&)
const;
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 ;
249 void save_vtk(
const std::string&)
const;
250 void save_bnd(
const std::string&)
const;
251 void save_tri(
const std::string&)
const;
252 void save_off(
const std::string&)
const;
253 void save_mesh(
const std::string&)
const;
269 typedef std::map<std::pair<const Vertex *, const Vertex *>,
int>
EdgeMap;
272 void copy(
const Mesh&);
276 const EdgeMap compute_edge_map()
const;
277 void orient_adjacent_triangles(std::stack<Triangle*>& t_stack,std::map<Triangle*,bool>& tri_reoriented);
291 std::map<const Vertex*,VectPTriangle>
links_;
const bool & isolated() const
std::vector< Vertex > Vertices
Vertices * all_vertices_
Pointer to all the vertices.
std::string name_
Name of the mesh.
bool current_barrier_
handle multiple 0 conductivity domains
size_t nb_vertices() const
size_t nb_all_vertices() const
std::istream & operator>>(std::istream &is, Conductivity< REP > &m)
const_vertex_reverse_iterator vertex_rend() const
std::set< Vertex > set_vertices_
vertex_iterator vertex_begin()
std::vector< Triangle > Triangles
VectPVertex::const_iterator const_vertex_iterator
Mesh(const unsigned &nv, const unsigned &nt)
constructor from scratch (add vertices/triangles one by one)
const bool & current_barrier() const
VectPVertex::const_reverse_iterator const_vertex_reverse_iterator
Mesh(const Mesh &m)
constructor from another mesh
std::vector< Mesh > Meshes
A vector of Mesh is called Meshes.
std::vector< Vertex * > VectPVertex
Vect3 P1gradient(const Vect3 &p0, const Vect3 &p1, const Vect3 &p2) const
P1gradient : aux function to compute the surfacic gradient.
vertex_iterator vertex_end()
size_t vertex_size() const
Mesh()
default constructor
size_t nb_triangles() const
std::map< const Vertex *, VectPTriangle > links_
links[&v] are the triangles that contain vertex v.
bool allocate_
Are the vertices allocate within the mesh or shared ?
Vertices all_vertices() const
unsigned load_vtk(T, const bool &read_all=true)
const_vertex_reverse_iterator vertex_rbegin() const
std::map< std::pair< const Vertex *, const Vertex * >, int > EdgeMap
map the edges with an unsigned
VectPVertex::iterator vertex_iterator
Mesh(std::string filename, const bool verbose=true, const std::string n="")
constructor loading directly a mesh file named
Mesh(Vertices &av, const std::string name="")
constructor using an outisde storage for vertices
VectPVertex vertices_
Vector of pointers to the mesh vertices.
unsigned load_gifti(T, const bool &)
Mesh & operator=(const Mesh &m)
double P0gradient_norm2(const Triangle &t1, const Triangle &t2) const
P0gradient_norm2 : aux function to compute the square norm of the surfacic gradient.
const bool & outermost() const
Returns True if it is an outermost mesh.
const VectPVertex & vertices() const
bool outermost_
Is it an outermost mesh ? (i.e does it touch the Air domain)
const_vertex_iterator vertex_end() const
const_vertex_iterator vertex_begin() const
std::vector< Triangle * > VectPTriangle
const std::string & name() const
void flip_triangles()
Flip all triangles.