OpenMEEG
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
OpenMEEG::Mesh Class Reference

Mesh class. More...

#include <mesh.h>

Inherits Triangles.

Public Types

typedef std::vector< Triangle * > VectPTriangle
 
typedef std::vector< Vertex * > VectPVertex
 
typedef VectPVertex::iterator vertex_iterator
 
typedef VectPVertex::const_iterator const_vertex_iterator
 
typedef
VectPVertex::const_reverse_iterator 
const_vertex_reverse_iterator
 

Public Member Functions

 Mesh ()
 default constructor More...
 
 Mesh (const unsigned &nv, const unsigned &nt)
 constructor from scratch (add vertices/triangles one by one) More...
 
 Mesh (const Mesh &m)
 constructor from another mesh More...
 
 Mesh (Vertices &av, const std::string name="")
 constructor using an outisde storage for vertices More...
 
 Mesh (std::string filename, const bool verbose=true, const std::string n="")
 constructor loading directly a mesh file named More...
 
 ~Mesh ()
 Destructor. More...
 
vertex_iterator vertex_begin ()
 
vertex_iterator vertex_end ()
 
size_t vertex_size () const
 
const_vertex_iterator vertex_begin () const
 
const_vertex_iterator vertex_end () const
 
const_vertex_reverse_iterator vertex_rbegin () const
 
const_vertex_reverse_iterator vertex_rend () const
 
std::string & name ()
 
const std::string & name () const
 
const VectPVertexvertices () const
 
size_t nb_vertices () const
 
size_t nb_triangles () const
 
Vertices all_vertices () const
 
size_t nb_all_vertices () const
 
void add_vertex (const Vertex &v)
 properly add vertex to the list. More...
 
*void info (const bool verbous=false) const
 Print info Print to std::cout some info about the mesh. More...
 
bool has_self_intersection () const
 check if the mesh self-intersects More...
 
bool intersection (const Mesh &) const
 check if the mesh intersects another mesh More...
 
bool has_correct_orientation () const
 check the local orientation of the mesh triangles More...
 
void build_mesh_vertices ()
 construct the list of the mesh vertices out of its triangles More...
 
void generate_indices ()
 generate indices (if allocate) More...
 
void update ()
 recompute triangles normals, area, and links More...
 
void merge (const Mesh &, const Mesh &)
 properly merge two meshes into one More...
 
void flip_triangles ()
 Flip all triangles. More...
 
void correct_local_orientation ()
 correct the local orientation of the mesh triangles More...
 
void correct_global_orientation ()
 correct the global orientation (if there is one) More...
 
double compute_solid_angle (const Vect3 &p) const
 Given a point p, it computes the solid angle. More...
 
const VectPTriangleget_triangles_for_vertex (const Vertex &V) const
 get the triangles associated with vertex V More...
 
VectPTriangle adjacent_triangles (const Triangle &) const
 get the adjacent triangles More...
 
Normal normal (const Vertex &v) const
 get the Normal at vertex More...
 
void laplacian (SymMatrix &A) const
 compute mesh laplacian More...
 
bool & outermost ()
 
const bool & outermost () const
 Returns True if it is an outermost mesh. More...
 
void smooth (const double &smoothing_intensity, const unsigned &niter)
 Smooth Mesh. More...
 
void gradient_norm2 (SymMatrix &A) const
 Compute the square norm of the surfacic gradient. More...
 
unsigned load (const std::string &filename, const bool &verbose=true, const bool &read_all=true)
 Read mesh from file. More...
 
unsigned load_tri (std::istream &, const bool &read_all=true)
 
unsigned load_tri (const std::string &, const bool &read_all=true)
 
unsigned load_bnd (std::istream &, const bool &read_all=true)
 
unsigned load_bnd (const std::string &, const bool &read_all=true)
 
unsigned load_off (std::istream &, const bool &read_all=true)
 
unsigned load_off (const std::string &, const bool &read_all=true)
 
unsigned load_mesh (std::istream &, const bool &read_all=true)
 
unsigned load_mesh (const std::string &, const bool &read_all=true)
 
template<typename T >
unsigned load_vtk (T, const bool &read_all=true)
 
template<typename T >
unsigned load_gifti (T, const bool &)
 
template<typename T >
void save_gifti (T) const
 
*void save (const std::string &filename) const
 Save mesh to file. More...
 
void save_vtk (const std::string &) const
 
void save_bnd (const std::string &) const
 
void save_tri (const std::string &) const
 
void save_off (const std::string &) const
 
void save_mesh (const std::string &) const
 
Meshoperator= (const Mesh &m)
 
const bool & current_barrier () const
 
bool & current_barrier ()
 
const bool & isolated () const
 
bool & isolated ()
 

Private Types

typedef std::map< std::pair
< const Vertex *, const Vertex * >
, int > 
EdgeMap
 map the edges with an unsigned More...
 

Private Member Functions

void destroy ()
 
void copy (const Mesh &)
 
const EdgeMap compute_edge_map () const
 
void orient_adjacent_triangles (std::stack< Triangle * > &t_stack, std::map< Triangle *, bool > &tri_reoriented)
 
bool triangle_intersection (const Triangle &, const Triangle &) const
 
Vect3 P1gradient (const Vect3 &p0, const Vect3 &p1, const Vect3 &p2) const
 P1gradient : aux function to compute the surfacic gradient. More...
 
double P0gradient_norm2 (const Triangle &t1, const Triangle &t2) const
 P0gradient_norm2 : aux function to compute the square norm of the surfacic gradient. More...
 

Private Attributes

std::string name_
 Name of the mesh. More...
 
std::map< const Vertex
*, VectPTriangle
links_
 links[&v] are the triangles that contain vertex v. More...
 
Verticesall_vertices_
 Pointer to all the vertices. More...
 
VectPVertex vertices_
 Vector of pointers to the mesh vertices. More...
 
bool outermost_
 Is it an outermost mesh ? (i.e does it touch the Air domain) More...
 
bool allocate_
 Are the vertices allocate within the mesh or shared ? More...
 
std::set< Vertexset_vertices_
 
bool current_barrier_
 handle multiple 0 conductivity domains More...
 
bool isolated_
 

Friends

std::istream & operator>> (std::istream &is, Mesh &m)
 insert a triangle into the mesh More...
 

Detailed Description

Mesh class.

Mesh is a collection of triangles

Definition at line 85 of file mesh.h.

Member Typedef Documentation

typedef std::vector<Triangle*> OpenMEEG::Mesh::VectPTriangle

Definition at line 88 of file mesh.h.

typedef std::vector<Vertex*> OpenMEEG::Mesh::VectPVertex

Definition at line 89 of file mesh.h.

typedef VectPVertex::iterator OpenMEEG::Mesh::vertex_iterator

Definition at line 90 of file mesh.h.

typedef VectPVertex::const_iterator OpenMEEG::Mesh::const_vertex_iterator

Definition at line 91 of file mesh.h.

typedef VectPVertex::const_reverse_iterator OpenMEEG::Mesh::const_vertex_reverse_iterator

Definition at line 92 of file mesh.h.

typedef std::map<std::pair<const Vertex *, const Vertex *>, int> OpenMEEG::Mesh::EdgeMap
private

map the edges with an unsigned

Definition at line 269 of file mesh.h.

Constructor & Destructor Documentation

OpenMEEG::Mesh::Mesh ( )
inline

default constructor

Definition at line 97 of file mesh.h.

OpenMEEG::Mesh::Mesh ( const unsigned &  nv,
const unsigned &  nt 
)
inline

constructor from scratch (add vertices/triangles one by one)

Parameters
nvallocate space for vertices
ntallocate space for triangles

Definition at line 103 of file mesh.h.

OpenMEEG::Mesh::Mesh ( const Mesh m)
inline

constructor from another mesh

Parameters
m

Definition at line 111 of file mesh.h.

OpenMEEG::Mesh::Mesh ( Vertices av,
const std::string  name = "" 
)
inline

constructor using an outisde storage for vertices

Parameters
avWhere to store vertices
nameMesh name

Definition at line 115 of file mesh.h.

OpenMEEG::Mesh::Mesh ( std::string  filename,
const bool  verbose = true,
const std::string  n = "" 
)
inline

constructor loading directly a mesh file named

Parameters
filename. Be verbose if
verboseis true. The mesh name is
n.

Definition at line 121 of file mesh.h.

OpenMEEG::Mesh::~Mesh ( )
inline

Destructor.

Definition at line 129 of file mesh.h.

Member Function Documentation

vertex_iterator OpenMEEG::Mesh::vertex_begin ( )
inline

Definition at line 133 of file mesh.h.

vertex_iterator OpenMEEG::Mesh::vertex_end ( )
inline

Definition at line 134 of file mesh.h.

size_t OpenMEEG::Mesh::vertex_size ( ) const
inline

Definition at line 136 of file mesh.h.

const_vertex_iterator OpenMEEG::Mesh::vertex_begin ( ) const
inline

Definition at line 138 of file mesh.h.

const_vertex_iterator OpenMEEG::Mesh::vertex_end ( ) const
inline

Definition at line 139 of file mesh.h.

const_vertex_reverse_iterator OpenMEEG::Mesh::vertex_rbegin ( ) const
inline

Definition at line 141 of file mesh.h.

const_vertex_reverse_iterator OpenMEEG::Mesh::vertex_rend ( ) const
inline

Definition at line 142 of file mesh.h.

std::string& OpenMEEG::Mesh::name ( )
inline
Returns
the mesh name

Definition at line 144 of file mesh.h.

const std::string& OpenMEEG::Mesh::name ( ) const
inline
Returns
the mesh name

Definition at line 145 of file mesh.h.

const VectPVertex& OpenMEEG::Mesh::vertices ( ) const
inline
Returns
the vector of pointers to the mesh vertices

Definition at line 147 of file mesh.h.

size_t OpenMEEG::Mesh::nb_vertices ( ) const
inline

Definition at line 148 of file mesh.h.

size_t OpenMEEG::Mesh::nb_triangles ( ) const
inline

Definition at line 149 of file mesh.h.

Vertices OpenMEEG::Mesh::all_vertices ( ) const
inline

Definition at line 151 of file mesh.h.

size_t OpenMEEG::Mesh::nb_all_vertices ( ) const
inline

Definition at line 152 of file mesh.h.

void OpenMEEG::Mesh::add_vertex ( const Vertex v)

properly add vertex to the list.

* void OpenMEEG::Mesh::info ( const bool  verbous = false) const

Print info Print to std::cout some info about the mesh.

Returns
void
See Also
bool OpenMEEG::Mesh::has_self_intersection ( ) const

check if the mesh self-intersects

bool OpenMEEG::Mesh::intersection ( const Mesh ) const

check if the mesh intersects another mesh

bool OpenMEEG::Mesh::has_correct_orientation ( ) const

check the local orientation of the mesh triangles

void OpenMEEG::Mesh::build_mesh_vertices ( )

construct the list of the mesh vertices out of its triangles

void OpenMEEG::Mesh::generate_indices ( )

generate indices (if allocate)

void OpenMEEG::Mesh::update ( )

recompute triangles normals, area, and links

void OpenMEEG::Mesh::merge ( const Mesh ,
const Mesh  
)

properly merge two meshes into one

void OpenMEEG::Mesh::flip_triangles ( )
inline

Flip all triangles.

Definition at line 173 of file mesh.h.

void OpenMEEG::Mesh::correct_local_orientation ( )

correct the local orientation of the mesh triangles

void OpenMEEG::Mesh::correct_global_orientation ( )

correct the global orientation (if there is one)

double OpenMEEG::Mesh::compute_solid_angle ( const Vect3 p) const

Given a point p, it computes the solid angle.

const VectPTriangle& OpenMEEG::Mesh::get_triangles_for_vertex ( const Vertex V) const

get the triangles associated with vertex V

Returns
the links
VectPTriangle OpenMEEG::Mesh::adjacent_triangles ( const Triangle ) const

get the adjacent triangles

Normal OpenMEEG::Mesh::normal ( const Vertex v) const

get the Normal at vertex

void OpenMEEG::Mesh::laplacian ( SymMatrix A) const

compute mesh laplacian

bool& OpenMEEG::Mesh::outermost ( )
inline

Definition at line 186 of file mesh.h.

const bool& OpenMEEG::Mesh::outermost ( ) const
inline

Returns True if it is an outermost mesh.

Definition at line 187 of file mesh.h.

void OpenMEEG::Mesh::smooth ( const double &  smoothing_intensity,
const unsigned &  niter 
)

Smooth Mesh.

Parameters
smoothing_intensity
niter
Returns
void
void OpenMEEG::Mesh::gradient_norm2 ( SymMatrix A) const

Compute the square norm of the surfacic gradient.

unsigned OpenMEEG::Mesh::load ( const std::string &  filename,
const bool &  verbose = true,
const bool &  read_all = true 
)

Read mesh from file.

Parameters
filenamecan be .vtk, .tri (ascii), .off .bnd or .mesh. Be verbose if
verboseis true. Id
read_allis false then it only returns the total number of vertices.
unsigned OpenMEEG::Mesh::load_tri ( std::istream &  ,
const bool &  read_all = true 
)
unsigned OpenMEEG::Mesh::load_tri ( const std::string &  ,
const bool &  read_all = true 
)
unsigned OpenMEEG::Mesh::load_bnd ( std::istream &  ,
const bool &  read_all = true 
)
unsigned OpenMEEG::Mesh::load_bnd ( const std::string &  ,
const bool &  read_all = true 
)
unsigned OpenMEEG::Mesh::load_off ( std::istream &  ,
const bool &  read_all = true 
)
unsigned OpenMEEG::Mesh::load_off ( const std::string &  ,
const bool &  read_all = true 
)
unsigned OpenMEEG::Mesh::load_mesh ( std::istream &  ,
const bool &  read_all = true 
)
unsigned OpenMEEG::Mesh::load_mesh ( const std::string &  ,
const bool &  read_all = true 
)
template<typename T >
unsigned OpenMEEG::Mesh::load_vtk ( ,
const bool &  read_all = true 
)
inline

Definition at line 222 of file mesh.h.

template<typename T >
unsigned OpenMEEG::Mesh::load_gifti ( ,
const bool &   
)
inline

Definition at line 233 of file mesh.h.

template<typename T >
void OpenMEEG::Mesh::save_gifti ( ) const
inline

Definition at line 238 of file mesh.h.

* void OpenMEEG::Mesh::save ( const std::string &  filename) const

Save mesh to file.

Parameters
filenamecan be .vtk, .tri (ascii), .bnd, .off or .mesh
void OpenMEEG::Mesh::save_vtk ( const std::string &  ) const
void OpenMEEG::Mesh::save_bnd ( const std::string &  ) const
void OpenMEEG::Mesh::save_tri ( const std::string &  ) const
void OpenMEEG::Mesh::save_off ( const std::string &  ) const
void OpenMEEG::Mesh::save_mesh ( const std::string &  ) const
Mesh& OpenMEEG::Mesh::operator= ( const Mesh m)
inline

Definition at line 257 of file mesh.h.

void OpenMEEG::Mesh::destroy ( )
private
void OpenMEEG::Mesh::copy ( const Mesh )
private
const EdgeMap OpenMEEG::Mesh::compute_edge_map ( ) const
private
void OpenMEEG::Mesh::orient_adjacent_triangles ( std::stack< Triangle * > &  t_stack,
std::map< Triangle *, bool > &  tri_reoriented 
)
private
bool OpenMEEG::Mesh::triangle_intersection ( const Triangle ,
const Triangle  
) const
private
Vect3 OpenMEEG::Mesh::P1gradient ( const Vect3 p0,
const Vect3 p1,
const Vect3 p2 
) const
inlineprivate

P1gradient : aux function to compute the surfacic gradient.

Definition at line 282 of file mesh.h.

double OpenMEEG::Mesh::P0gradient_norm2 ( const Triangle t1,
const Triangle t2 
) const
inlineprivate

P0gradient_norm2 : aux function to compute the square norm of the surfacic gradient.

Definition at line 286 of file mesh.h.

const bool& OpenMEEG::Mesh::current_barrier ( ) const
inline

Definition at line 301 of file mesh.h.

bool& OpenMEEG::Mesh::current_barrier ( )
inline

Definition at line 302 of file mesh.h.

const bool& OpenMEEG::Mesh::isolated ( ) const
inline

Definition at line 303 of file mesh.h.

bool& OpenMEEG::Mesh::isolated ( )
inline

Definition at line 304 of file mesh.h.

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  is,
Mesh m 
)
friend

insert a triangle into the mesh

Member Data Documentation

std::string OpenMEEG::Mesh::name_
private

Name of the mesh.

Definition at line 290 of file mesh.h.

std::map<const Vertex*,VectPTriangle> OpenMEEG::Mesh::links_
private

links[&v] are the triangles that contain vertex v.

Definition at line 291 of file mesh.h.

Vertices* OpenMEEG::Mesh::all_vertices_
private

Pointer to all the vertices.

Definition at line 292 of file mesh.h.

VectPVertex OpenMEEG::Mesh::vertices_
private

Vector of pointers to the mesh vertices.

Definition at line 293 of file mesh.h.

bool OpenMEEG::Mesh::outermost_
private

Is it an outermost mesh ? (i.e does it touch the Air domain)

Definition at line 294 of file mesh.h.

bool OpenMEEG::Mesh::allocate_
private

Are the vertices allocate within the mesh or shared ?

Definition at line 295 of file mesh.h.

std::set<Vertex> OpenMEEG::Mesh::set_vertices_
private

Definition at line 296 of file mesh.h.

bool OpenMEEG::Mesh::current_barrier_
private

handle multiple 0 conductivity domains

Definition at line 298 of file mesh.h.

bool OpenMEEG::Mesh::isolated_
private

Definition at line 299 of file mesh.h.


The documentation for this class was generated from the following file: