basic mesh class More...
Public Member Functions | |
mesh () | |
empty constructor | |
mesh (const std::pair< std::vector< double >, std::vector< unsigned int > > &input) | |
constructor from std::pair <vertex,connectivity> | |
v3 | get_vertex (const unsigned int &k_vertex) const |
get vertex k | |
v3 | get_vertex (const unsigned int &k_tri, const unsigned int &k_v) const |
get k_v (k_v in [0,2]) vertex of triangle k_tri | |
std::vector< unsigned int > | get_connectivity (const unsigned int &k_polygon) const |
get connectivity polygon (to do) | |
void | set_vertex (const unsigned int &k_vertex, const v3 &new_vertex) |
set a 3D vertex | |
void | set_connectivity (const unsigned int &k_polygon, const std::vector< unsigned int > &new_triangle) |
set connectivity | |
void | set_texture (const unsigned int &k_vertex, const double &tx, const double &ty) |
set texture for vertex k_vertex | |
double | get_texture_tx (const unsigned int &k_vertex) const |
get texture tx for vertex k_vertex | |
double | get_texture_ty (const unsigned int &k_vertex) const |
get texture ty for vertex k_vertex | |
void | add_vertex (const v3 &x) |
add a vertex in the mesh | |
void | add_vertex (const double &x, const double &y, const double &z) |
add a vertex in the mesh | |
void | add_triangle (const unsigned int &u0, const unsigned int &u1, const unsigned int &u2) |
add indices of a triangle in the mesh | |
unsigned int | vertex_number () const |
number of vertices | |
unsigned int | triangle_number () const |
number of triangles | |
std::map< int, std::list< int > > | ring () const |
build one ring | |
std::map< int, std::list< int > > | star () const |
build one star | |
std::vector< double > | normal_vertex () const |
compute per vertex normal | |
std::vector< double > | normal_polygon () const |
compute per polygon normal | |
void | inverse_triangle_order () |
swap triangle order (inverse normal direction) | |
const std::vector< double > & | get_vertex () const |
get internal vertex | |
std::vector< double > & | get_vertex () |
get internal vertex | |
const std::vector< unsigned int > & | get_connectivity () const |
get internal connectivity | |
std::vector< unsigned int > & | get_connectivity () |
get internal connectivity | |
const std::vector< double > & | get_texture () const |
get the internal vector of texture | |
std::vector< double > & | get_texture () |
get the internal vector of texture | |
void | assert_vertex (const unsigned int &k_vertex) const |
check vertex index are within the bounds | |
void | assert_connectivity (const unsigned int &k_connectivity) const |
check polygon index are within the bounds | |
void | save_off_file (const std::string &filename) const |
save mesh as off file | |
void | scale_unity () |
scale and translate the mesh to fit into the unit cube | |
void | scale (const double &value) |
scale the mesh | |
void | apply (const matrix3 &M) |
matrix multiplication | |
void | translate (const v3 &tr) |
translate | |
Static Public Member Functions | |
static mesh | load_off_file (const std::string &filename) |
load off file | |
Private Attributes | |
std::vector< double > | vertex |
vertex vector (size=3xN_vertex) | |
std::vector< unsigned int > | connectivity |
connectivity vector (only triangles) (size=3xN_poly) | |
std::vector< double > | texture |
texture vector (size=2xN_vertex) |
basic mesh class
cpe::mesh::mesh | ( | ) |
empty constructor
cpe::mesh::mesh | ( | const std::pair< std::vector< double >, std::vector< unsigned int > > & | input | ) |
constructor from std::pair <vertex,connectivity>
References connectivity, and vertex.
void cpe::mesh::add_triangle | ( | const unsigned int & | u0, | |
const unsigned int & | u1, | |||
const unsigned int & | u2 | |||
) |
add indices of a triangle in the mesh
References connectivity.
void cpe::mesh::add_vertex | ( | const double & | x, | |
const double & | y, | |||
const double & | z | |||
) |
add a vertex in the mesh
References vertex.
void cpe::mesh::add_vertex | ( | const v3 & | x | ) |
add a vertex in the mesh
References cpe::v3::x(), cpe::v3::y(), and cpe::v3::z().
void cpe::mesh::apply | ( | const matrix3 & | M | ) |
matrix multiplication
References vertex, vertex_number(), cpe::v3::x(), cpe::v3::y(), and cpe::v3::z().
Referenced by scene::load_model().
void cpe::mesh::assert_connectivity | ( | const unsigned int & | k_connectivity | ) | const |
check polygon index are within the bounds
References connectivity.
Referenced by get_connectivity(), get_vertex(), and set_connectivity().
void cpe::mesh::assert_vertex | ( | const unsigned int & | k_vertex | ) | const |
check vertex index are within the bounds
References vertex.
Referenced by get_vertex(), and set_vertex().
std::vector< unsigned int > & cpe::mesh::get_connectivity | ( | ) |
get internal connectivity
References connectivity.
const std::vector< unsigned int > & cpe::mesh::get_connectivity | ( | ) | const |
get internal connectivity
References connectivity.
std::vector< unsigned int > cpe::mesh::get_connectivity | ( | const unsigned int & | k_polygon | ) | const |
get connectivity polygon (to do)
References assert_connectivity(), and connectivity.
Referenced by cpe::opengl_drawer::draw_edges(), cpe::opengl_drawer::draw_per_polygon_normal(), cpe::opengl_drawer::draw_per_vertex_normal(), and cpe::mesh_io_off::save_mesh_io_off().
std::vector< double > & cpe::mesh::get_texture | ( | ) |
get the internal vector of texture
const std::vector< double > & cpe::mesh::get_texture | ( | ) | const |
get the internal vector of texture
Referenced by cpe::opengl_drawer::draw_per_polygon_normal(), cpe::opengl_drawer::draw_per_vertex_normal(), cpe::mesh_io_off::load_mesh_io_off(), and cpe::mesh_io_off::save_mesh_io_off().
double cpe::mesh::get_texture_tx | ( | const unsigned int & | k_vertex | ) | const |
get texture tx for vertex k_vertex
References cpe::string_converter::to_string().
Referenced by cpe::mesh_io_off::save_mesh_io_off().
double cpe::mesh::get_texture_ty | ( | const unsigned int & | k_vertex | ) | const |
get texture ty for vertex k_vertex
References cpe::string_converter::to_string().
Referenced by cpe::mesh_io_off::save_mesh_io_off().
std::vector< double > & cpe::mesh::get_vertex | ( | ) |
get internal vertex
References vertex.
const std::vector< double > & cpe::mesh::get_vertex | ( | ) | const |
v3 cpe::mesh::get_vertex | ( | const unsigned int & | k_tri, | |
const unsigned int & | k_v | |||
) | const |
get k_v (k_v in [0,2]) vertex of triangle k_tri
References assert_connectivity(), connectivity, get_vertex(), and cpe::string_converter::to_string().
v3 cpe::mesh::get_vertex | ( | const unsigned int & | k_vertex | ) | const |
get vertex k
References assert_vertex(), and vertex.
Referenced by cpe::opengl_drawer::draw_edges(), cpe::opengl_drawer::draw_normals(), cpe::opengl_drawer::draw_per_polygon_normal(), cpe::opengl_drawer::draw_per_vertex_normal(), and cpe::mesh_io_off::save_mesh_io_off().
void cpe::mesh::inverse_triangle_order | ( | ) |
swap triangle order (inverse normal direction)
References connectivity, and triangle_number().
mesh cpe::mesh::load_off_file | ( | const std::string & | filename | ) | [static] |
load off file
References cpe::mesh_io_off::load_mesh_io_off().
Referenced by scene::load_model().
std::vector< double > cpe::mesh::normal_polygon | ( | ) | const |
compute per polygon normal
References connectivity, triangle_number(), and vertex.
Referenced by normal_vertex().
std::vector< double > cpe::mesh::normal_vertex | ( | ) | const |
compute per vertex normal
References normal_polygon(), cpe::v3::normalized(), star(), vertex, and vertex_number().
Referenced by scene::creation_damier(), and scene::load_model().
std::map< int, std::list< int > > cpe::mesh::ring | ( | ) | const |
build one ring
References connectivity, and triangle_number().
void cpe::mesh::save_off_file | ( | const std::string & | filename | ) | const |
save mesh as off file
References cpe::mesh_io_off::save_mesh_io_off().
void cpe::mesh::scale | ( | const double & | value | ) |
void cpe::mesh::scale_unity | ( | ) |
scale and translate the mesh to fit into the unit cube
References vertex, and vertex_number().
Referenced by scene::creation_damier(), and scene::load_model().
void cpe::mesh::set_connectivity | ( | const unsigned int & | k_polygon, | |
const std::vector< unsigned int > & | new_triangle | |||
) |
set connectivity
References assert_connectivity(), and vertex.
void cpe::mesh::set_texture | ( | const unsigned int & | k_vertex, | |
const double & | tx, | |||
const double & | ty | |||
) |
set texture for vertex k_vertex
References cpe::string_converter::to_string().
void cpe::mesh::set_vertex | ( | const unsigned int & | k_vertex, | |
const v3 & | new_vertex | |||
) |
std::map< int, std::list< int > > cpe::mesh::star | ( | ) | const |
build one star
References connectivity, and triangle_number().
Referenced by normal_vertex().
void cpe::mesh::translate | ( | const v3 & | tr | ) |
translate
References vertex, vertex_number(), cpe::v3::x(), cpe::v3::y(), and cpe::v3::z().
Referenced by scene::load_model().
unsigned int cpe::mesh::triangle_number | ( | ) | const |
number of triangles
References connectivity.
Referenced by cpe::opengl_drawer::draw(), cpe::opengl_drawer::draw_edges(), cpe::opengl_drawer::draw_normals(), cpe::opengl_drawer::draw_per_polygon_normal(), cpe::opengl_drawer::draw_per_vertex_normal(), inverse_triangle_order(), normal_polygon(), ring(), cpe::mesh_io_off::save_mesh_io_off(), and star().
unsigned int cpe::mesh::vertex_number | ( | ) | const |
number of vertices
References vertex.
Referenced by apply(), cpe::opengl_drawer::draw(), cpe::opengl_drawer::draw_normals(), cpe::opengl_drawer::draw_per_polygon_normal(), cpe::opengl_drawer::draw_per_vertex_normal(), normal_vertex(), cpe::mesh_io_off::save_mesh_io_off(), scale_unity(), and translate().
std::vector<unsigned int> cpe::mesh::connectivity [private] |
connectivity vector (only triangles) (size=3xN_poly)
Referenced by add_triangle(), assert_connectivity(), get_connectivity(), get_vertex(), inverse_triangle_order(), mesh(), normal_polygon(), ring(), star(), and triangle_number().
std::vector<double> cpe::mesh::texture [private] |
texture vector (size=2xN_vertex)
std::vector<double> cpe::mesh::vertex [private] |
vertex vector (size=3xN_vertex)
Referenced by add_vertex(), apply(), assert_vertex(), get_vertex(), mesh(), normal_polygon(), normal_vertex(), scale(), scale_unity(), set_connectivity(), set_vertex(), translate(), and vertex_number().