cpe::mesh Class Reference

Container class for a generic mesh with normal, color, texture, ... More...

+ Collaboration diagram for cpe::mesh:

Public Member Functions

const vec3vertex (const unsigned int &index) const
 Accessor to the vertex value. More...
 
vec3vertex (const unsigned int &index)
 Accessor to the vertex value. More...
 
const vec3vertex_of_polygon (const unsigned int &index_polygon, const unsigned int &index_vertex) const
 Accessor to the vertex value. More...
 
vec3vertex_of_polygon (const unsigned int &index_polygon, const unsigned int &index_vertex)
 Accessor to the vertex value. More...
 
const vec3normal (const unsigned int &index) const
 Accessor to the normal value. More...
 
vec3normal (const unsigned int &index)
 Accessor to the normal value. More...
 
const vec3color (const unsigned int &index) const
 Accessor to the color value. More...
 
vec3color (const unsigned int &index)
 Accessor to the color value. More...
 
const int & connectivity (const unsigned int &index) const
 Accessor to the connectivity value. More...
 
int & connectivity (const unsigned int &index)
 Accessor to the connectivity value. More...
 
const vec2texture (const unsigned int &index) const
 Accessor to the uv-texture value. More...
 
vec2texture (const unsigned int &index)
 Accessor to the uv-texture value. More...
 
const std::vector< vec3 > & get_vertices () const
 return internal vertices vector More...
 
const std::vector< vec3 > & get_normal () const
 return internal normal vector More...
 
const std::vector< vec3 > & get_color () const
 return internal color vector More...
 
const std::vector< int > & get_connectivity () const
 return internal connectivity vector More...
 
const std::vector< vec2 > & get_texture () const
 return internal uv texture vector More...
 
std::vector< vec3 > & get_vertices ()
 return internal vertices vector More...
 
std::vector< vec3 > & get_normal ()
 return internal normal vector More...
 
std::vector< vec3 > & get_color ()
 return internal color vector More...
 
std::vector< int > & get_connectivity ()
 return internal connectivity vector More...
 
std::vector< vec2 > & get_texture ()
 return internal uv texture vector More...
 
void add_vertex (const vec3 &vertex_to_add)
 Add a vertex to the mesh. More...
 
void add_texture (const vec2 &texture_to_add)
 Add a texture to the mesh. More...
 
void add_triangle (const int u0, const int u1, const int u2)
 Add a triangle to the mesh. More...
 
unsigned int number_of_triangle () const
 get the number of triangle More...
 
unsigned int number_of_vertices () const
 get the number of vertices More...
 
void fill_color (const vec3 &c)
 fill mesh with constant color More...
 
void fill_color_xyz ()
 fill mesh with color depending of (x,y,z)-coordinates More...
 
void fill_color_normal ()
 fill mesh with color depending of normal orientation More...
 
void compute_normal ()
 Compute a per-vertex normal and fill the internal vector. More...
 
void normal_inversion ()
 Inverse the direction of the normal. More...
 
std::vector< vec3get_normal_per_vertex () const
 get the vector per vertex More...
 
std::vector< vec3get_normal_per_polygon () const
 get the vector per polygon More...
 
meshoperator+= (const vec3 &x)
 internal translation More...
 
meshoperator-= (const vec3 &x)
 internal translation More...
 
meshoperator*= (const float &s)
 uniform scaling More...
 
void scale (const float &sx, const float &sy, const float &sz)
 scale the mesh with anisotropical values More...
 
void auto_scale (const float &scale=1.0)
 Set vertices to fit in scalex[-1,1]x[-1,1]. More...
 
void apply (const cpe::matrix3 R)
 Apply matrix to every vertices. More...
 
void load_file (const std::string &filename)
 load a off file More...
 

Private Attributes

std::vector< vec3v_vertices
 internal vertices storage More...
 
std::vector< vec3v_normal
 internal normal storage More...
 
std::vector< vec3v_color
 internal color storage More...
 
std::vector< vec2v_texture
 internal texture coordinate storage More...
 
std::vector< int > v_connectivity
 internal connectivity storage More...
 

Friends

mesh operator+ (const vec3 &x, const mesh &m)
 translation More...
 
mesh operator+ (const mesh &m, const vec3 &x)
 translation More...
 
mesh operator- (const mesh &m, const vec3 &x)
 translation More...
 
mesh operator* (const float &s, const mesh &m)
 uniform scaling More...
 
mesh operator* (const mesh &m, const float &s)
 uniform scaling More...
 

Detailed Description

Container class for a generic mesh with normal, color, texture, ...

Member Function Documentation

void cpe::mesh::add_texture ( const vec2 texture_to_add)

Add a texture to the mesh.

References v_texture.

Referenced by cpe::mesh_io::load_obj_file().

void cpe::mesh::add_triangle ( const int  u0,
const int  u1,
const int  u2 
)

Add a triangle to the mesh.

References v_connectivity.

Referenced by cpe::mesh_io::load_obj_file().

void cpe::mesh::add_vertex ( const vec3 vertex_to_add)

Add a vertex to the mesh.

References v_vertices.

Referenced by cpe::mesh_io::load_obj_file().

void cpe::mesh::apply ( const cpe::matrix3  R)

Apply matrix to every vertices.

References v_vertices.

void cpe::mesh::auto_scale ( const float &  scale = 1.0)

Set vertices to fit in scalex[-1,1]x[-1,1].

z-coordinate is set to start at -1 Auto fit the unit square ((-1,-1,1),(-1,1,1),(1,-1,1),(1,1,1))

References v_vertices, cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().

+ Here is the call graph for this function:

const vec3 & cpe::mesh::color ( const unsigned int &  index) const

Accessor to the color value.

References v_color.

Referenced by cpe::render_engine::render().

vec3 & cpe::mesh::color ( const unsigned int &  index)

Accessor to the color value.

References v_color.

void cpe::mesh::compute_normal ( )

Compute a per-vertex normal and fill the internal vector.

References get_normal_per_vertex(), and v_normal.

+ Here is the call graph for this function:

const int & cpe::mesh::connectivity ( const unsigned int &  index) const

Accessor to the connectivity value.

References v_color, and v_connectivity.

Referenced by cpe::render_engine::render().

int & cpe::mesh::connectivity ( const unsigned int &  index)

Accessor to the connectivity value.

References v_color, and v_connectivity.

void cpe::mesh::fill_color ( const vec3 c)

fill mesh with constant color

References v_color, and v_vertices.

void cpe::mesh::fill_color_normal ( )

fill mesh with color depending of normal orientation

References v_color, v_normal, v_vertices, cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().

+ Here is the call graph for this function:

void cpe::mesh::fill_color_xyz ( )

fill mesh with color depending of (x,y,z)-coordinates

References v_color, v_vertices, cpe::vec3::x(), cpe::vec3::y(), and cpe::vec3::z().

+ Here is the call graph for this function:

const std::vector< vec3 > & cpe::mesh::get_color ( ) const

return internal color vector

References v_color.

std::vector< vec3 > & cpe::mesh::get_color ( )

return internal color vector

References v_color.

const std::vector< int > & cpe::mesh::get_connectivity ( ) const

return internal connectivity vector

References v_connectivity.

Referenced by cpe::mesh_io::load_off_file().

std::vector< int > & cpe::mesh::get_connectivity ( )

return internal connectivity vector

References v_connectivity.

const std::vector< vec3 > & cpe::mesh::get_normal ( ) const

return internal normal vector

References v_normal.

std::vector< vec3 > & cpe::mesh::get_normal ( )

return internal normal vector

References v_normal.

std::vector< vec3 > cpe::mesh::get_normal_per_polygon ( ) const

get the vector per polygon

References v_connectivity, and v_vertices.

Referenced by get_normal_per_vertex().

std::vector< vec3 > cpe::mesh::get_normal_per_vertex ( ) const

get the vector per vertex

References get_normal_per_polygon(), cpe::vec3::normalized(), v_connectivity, and v_vertices.

Referenced by compute_normal().

+ Here is the call graph for this function:

const std::vector< vec2 > & cpe::mesh::get_texture ( ) const

return internal uv texture vector

References v_texture.

std::vector< vec2 > & cpe::mesh::get_texture ( )

return internal uv texture vector

References v_texture.

const std::vector< vec3 > & cpe::mesh::get_vertices ( ) const

return internal vertices vector

References v_vertices.

Referenced by cpe::mesh_io::load_off_file().

std::vector< vec3 > & cpe::mesh::get_vertices ( )

return internal vertices vector

References v_vertices.

void cpe::mesh::load_file ( const std::string &  filename)

load a off file

References cpe::mesh_io::load_obj_file(), and cpe::mesh_io::load_off_file().

+ Here is the call graph for this function:

const vec3 & cpe::mesh::normal ( const unsigned int &  index) const

Accessor to the normal value.

References v_normal.

Referenced by cpe::render_engine::render().

vec3 & cpe::mesh::normal ( const unsigned int &  index)

Accessor to the normal value.

References v_normal.

void cpe::mesh::normal_inversion ( )

Inverse the direction of the normal.

References v_normal.

unsigned int cpe::mesh::number_of_triangle ( ) const

get the number of triangle

References v_connectivity.

Referenced by cpe::render_engine::render().

unsigned int cpe::mesh::number_of_vertices ( ) const

get the number of vertices

References v_vertices.

mesh & cpe::mesh::operator*= ( const float &  s)

uniform scaling

References v_vertices.

mesh & cpe::mesh::operator+= ( const vec3 x)

internal translation

References v_vertices.

mesh & cpe::mesh::operator-= ( const vec3 x)

internal translation

References v_vertices.

void cpe::mesh::scale ( const float &  sx,
const float &  sy,
const float &  sz 
)

scale the mesh with anisotropical values

References v_vertices.

const vec2 & cpe::mesh::texture ( const unsigned int &  index) const

Accessor to the uv-texture value.

References v_texture.

vec2 & cpe::mesh::texture ( const unsigned int &  index)

Accessor to the uv-texture value.

References v_texture.

const vec3 & cpe::mesh::vertex ( const unsigned int &  index) const

Accessor to the vertex value.

References v_vertices.

Referenced by cpe::render_engine::render().

vec3 & cpe::mesh::vertex ( const unsigned int &  index)

Accessor to the vertex value.

References v_vertices.

const vec3 & cpe::mesh::vertex_of_polygon ( const unsigned int &  index_polygon,
const unsigned int &  index_vertex 
) const

Accessor to the vertex value.

References v_connectivity, and v_vertices.

vec3 & cpe::mesh::vertex_of_polygon ( const unsigned int &  index_polygon,
const unsigned int &  index_vertex 
)

Accessor to the vertex value.

References v_connectivity, and v_vertices.

Friends And Related Function Documentation

mesh operator* ( const float &  s,
const mesh m 
)
friend

uniform scaling

mesh operator* ( const mesh m,
const float &  s 
)
friend

uniform scaling

mesh operator+ ( const vec3 x,
const mesh m 
)
friend

translation

mesh operator+ ( const mesh m,
const vec3 x 
)
friend

translation

mesh operator- ( const mesh m,
const vec3 x 
)
friend

translation

Member Data Documentation

std::vector<vec3> cpe::mesh::v_color
private

internal color storage

Referenced by color(), connectivity(), fill_color(), fill_color_normal(), fill_color_xyz(), and get_color().

std::vector<int> cpe::mesh::v_connectivity
private
std::vector<vec3> cpe::mesh::v_normal
private

internal normal storage

Referenced by compute_normal(), fill_color_normal(), get_normal(), normal(), and normal_inversion().

std::vector<vec2> cpe::mesh::v_texture
private

internal texture coordinate storage

Referenced by add_texture(), get_texture(), and texture().


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