cgv
|
coordinate type independent base class of simple mesh data structure that handles indices and colors. More...
#include <simple_mesh.h>
Public Types | |
enum class | attribute_type { begin =0 , position =0 , texcoords =1 , normal =2 , tangent =3 , color =4 , end =5 } |
different mesh attributes More... | |
enum | AttributeFlags { AF_position = 1 , AF_texcoords = 2 , AF_normal = 4 , AF_tangent = 8 , AF_color = 16 } |
typedef cgv::type::uint32_type | idx_type |
define index type | |
typedef cgv::math::fvec< idx_type, 2 > | idx2_type |
define index pair type | |
typedef cgv::math::fvec< idx_type, 3 > | idx3_type |
define index triple type | |
typedef cgv::math::fvec< idx_type, 4 > | idx4_type |
define index quadruple type | |
typedef illum::textured_surface_material | mat_type |
define material type | |
Public Member Functions | |
virtual bool | has_attribute (attribute_type attr) const =0 |
virtual const uint8_t * | get_attribute_ptr (attribute_type attr, idx_type ai=0) const =0 |
virtual size_t | get_attribute_size (attribute_type attr) const =0 |
virtual size_t | get_attribute_offset (attribute_type attr) const =0 |
simple_mesh_base () | |
default constructor | |
simple_mesh_base (const simple_mesh_base &smb) | |
copy constructor | |
simple_mesh_base (simple_mesh_base &&smb) | |
move constructor | |
simple_mesh_base & | operator= (const simple_mesh_base &smb) |
assignment operator | |
simple_mesh_base & | operator= (simple_mesh_base &&smb) |
move assignment operator | |
virtual idx_type | get_nr_positions () const =0 |
position count | |
virtual uint32_t | get_coord_size () const =0 |
return the size of one coordinate in bytes | |
idx_type | start_face () |
Create a new empty face to which new corners are added. | |
idx_type | new_corner (idx_type position_index, idx_type normal_index=-1, idx_type tex_coord_index=-1) |
Create a new corner with the given attributes. | |
idx_type | c2p (idx_type ci) const |
return position index of corner | |
idx_type | c2n (idx_type ci) const |
return normal index of corner | |
bool | has_normal_indices () const |
return whether normal indices are stored | |
idx_type | c2t (idx_type ci) const |
return texture index of corner | |
bool | has_tex_coord_indices () const |
return whether texture coordinate indices are stored | |
idx_type | get_nr_faces () const |
return the number of faces | |
idx_type | get_nr_corners () const |
return the number of corners | |
idx_type | begin_corner (idx_type fi) const |
Retrieve the vertex index of the first corner of a face. | |
idx_type | end_corner (idx_type fi) const |
Retrieve index of the vertex which follows the end corner of a face. | |
idx_type | face_degree (idx_type fi) const |
return number of edges/corners of face with index fi | |
size_t | get_nr_materials () const |
return number of materials in mesh | |
idx_type | new_material () |
add a new material and return its index | |
const mat_type & | get_material (size_t i) const |
return const reference to i-th material | |
mat_type & | ref_material (size_t i) |
return reference to i-th material | |
const idx_type & | material_index (idx_type fi) const |
return material index of given face | |
idx_type & | material_index (idx_type fi) |
return reference to material index of given face | |
size_t | get_nr_groups () const |
return number of face groups | |
const std::string & | group_name (size_t i) const |
return the name of the i-th face group | |
std::string & | group_name (size_t i) |
set a new group name | |
idx_type | new_group (const std::string &name) |
add a new group and return its index | |
const idx_type & | group_index (idx_type fi) const |
return group index of given face | |
idx_type & | group_index (idx_type fi) |
return reference to group index of given face | |
void | revert_face_orientation () |
revert face orientation | |
void | sort_faces (std::vector< idx_type > &perm, bool by_group=true, bool by_material=true) const |
Calculate a permutation of face indices which sorts them by group and/or material. | |
void | merge_indices (std::vector< idx_type > &vertex_indices, std::vector< idx4_type > &unique_tuples, bool *include_tex_coords_ptr=0, bool *include_normals_ptr=0, bool *include_tangents_ptr=0) const |
Transforms n individual vertex attribute indices into one list of unique index n-tuples. | |
void | extract_triangle_element_buffer (const std::vector< idx_type > &vertex_indices, std::vector< idx_type > &triangle_element_buffer, const std::vector< idx_type > *face_permutation_ptr=0, std::vector< idx3_type > *material_group_start_ptr=0) const |
Extract element array buffers for triangulation. | |
void | extract_wireframe_element_buffer (const std::vector< idx_type > &vertex_indices, std::vector< idx_type > &edge_element_buffer) const |
Extract element array buffers for edges in wireframe. | |
idx_type | extract_vertex_attribute_buffer_base (const std::vector< idx4_type > &unique_quadruples, AttributeFlags &flags, std::vector< uint8_t > &attrib_buffer) const |
extract vertex attribute buffer for the given flags and return size of vertex in bytes | |
idx_type | compute_inv (std::vector< idx_type > &inv, bool link_non_manifold_edges=false, std::vector< idx_type > *p2c_ptr=0, std::vector< idx_type > *next_ptr=0, std::vector< idx_type > *prev_ptr=0, std::vector< idx_type > *unmatched=0, std::vector< idx_type > *non_manifold=0, std::vector< idx_type > *unmatched_elements=0, std::vector< idx_type > *non_manifold_elements=0) const |
Do inverse matching of half-edges. | |
idx_type | compute_c2e (const std::vector< idx_type > &inv, std::vector< idx_type > &c2e, std::vector< idx_type > *e2c_ptr=0) const |
given the inv corners compute vector storing per corner the edge index and optionally per edge one corner index and return edge count (implementation assumes closed manifold connectivity) | |
void | compute_c2f (std::vector< idx_type > &c2f) const |
compute index vector with per corner its face index | |
![]() | |
colored_model () | |
construct colored model | |
colored_model (const colored_model &cm) | |
copy constructur | |
colored_model (colored_model &&cm) | |
move constructur | |
colored_model & | operator= (const colored_model &cm) |
assignment operator | |
colored_model & | operator= (colored_model &&cm) |
move assignment operator | |
virtual | ~colored_model () |
destruct colored model | |
bool | has_colors () const |
check whether colors have been allocated | |
void | set_color (size_t i, const void *col_ptr) |
set i-th color to color of type stored in storage | |
void | set_color (size_t i, const rgb &col) |
set i-th color from color of type rgb | |
void | set_color (size_t i, const rgb8 &col) |
set i-th color from color of type rgba | |
void | set_color (size_t i, const rgba &col) |
set i-th color from color of type rgb8 | |
void | set_color (size_t i, const rgba8 &col) |
set i-th color from color of type rgba8 | |
void | put_color (size_t i, void *col_ptr) const |
set color of type stored in storage to i-th color | |
void | put_color (size_t i, rgb &col) const |
set color of type rgb to i-th color | |
void | put_color (size_t i, rgba &col) const |
set color of type rgba to i-th color | |
void | put_color (size_t i, rgb8 &col) const |
set color of type rgb8 to i-th color | |
void | put_color (size_t i, rgba8 &col) const |
set color of type rgba8 to i-th color | |
size_t | get_nr_colors () const |
return number of allocated colors | |
void | resize_colors (size_t nr_colors) |
resize the color storage to given number of colors | |
size_t | get_color_size () const |
return the size of one allocated color in byte | |
ColorType | get_color_storage_type () const |
return storage type of colors, if no colors are allocated CT_RGBA8 is returned | |
const void * | get_color_data_ptr () const |
const void * | get_color_data_vector_ptr () const |
void * | ref_color_data_ptr () |
void * | ref_color_data_vector_ptr () |
void | ensure_colors (ColorType _color_type, size_t nr_colors=-1) |
ensure that colors are allocated and of given storage type | |
void | destruct_colors () |
destruct color storage | |
Static Public Member Functions | |
static std::string | get_attribute_name (attribute_type attr) |
static AttributeFlags | get_attribute_flag (attribute_type attr) |
Protected Attributes | |
std::vector< idx_type > | position_indices |
std::vector< idx_type > | tex_coord_indices |
std::vector< idx_type > | normal_indices |
std::vector< idx_type > | tangent_indices |
std::vector< idx_type > | faces |
std::vector< idx_type > | group_indices |
std::vector< std::string > | group_names |
std::vector< idx_type > | material_indices |
std::vector< mat_type > | materials |
![]() | |
abst_color_storage * | color_storage_ptr |
pointer to color storage | |
coordinate type independent base class of simple mesh data structure that handles indices and colors.
Definition at line 26 of file simple_mesh.h.
define index pair type
Definition at line 32 of file simple_mesh.h.
define index triple type
Definition at line 34 of file simple_mesh.h.
define index quadruple type
Definition at line 36 of file simple_mesh.h.
define index type
Definition at line 30 of file simple_mesh.h.
define material type
Definition at line 38 of file simple_mesh.h.
|
strong |
different mesh attributes
Definition at line 40 of file simple_mesh.h.
Enumerator | |
---|---|
AF_texcoords | vertex position |
AF_normal | texture coordinates |
AF_tangent | surface normal |
AF_color | tangent vectors for u coordinate |
Definition at line 44 of file simple_mesh.h.
cgv::media::mesh::simple_mesh_base::simple_mesh_base | ( | ) |
default constructor
Definition at line 25 of file simple_mesh.cxx.
cgv::media::mesh::simple_mesh_base::simple_mesh_base | ( | const simple_mesh_base & | smb | ) |
copy constructor
Definition at line 28 of file simple_mesh.cxx.
cgv::media::mesh::simple_mesh_base::simple_mesh_base | ( | simple_mesh_base && | smb | ) |
move constructor
Definition at line 40 of file simple_mesh.cxx.
Retrieve the vertex index of the first corner of a face.
[in] | fi | Which face of simple_mesh<T>faces. |
Definition at line 117 of file simple_mesh.h.
Referenced by compute_c2f(), compute_inv(), extract_triangle_element_buffer(), extract_wireframe_element_buffer(), and revert_face_orientation().
return normal index of corner
Definition at line 100 of file simple_mesh.h.
return position index of corner
Definition at line 98 of file simple_mesh.h.
Referenced by compute_inv().
return texture index of corner
Definition at line 104 of file simple_mesh.h.
simple_mesh_base::idx_type cgv::media::mesh::simple_mesh_base::compute_c2e | ( | const std::vector< idx_type > & | inv, |
std::vector< idx_type > & | c2e, | ||
std::vector< idx_type > * | e2c_ptr = 0 |
||
) | const |
given the inv corners compute vector storing per corner the edge index and optionally per edge one corner index and return edge count (implementation assumes closed manifold connectivity)
Definition at line 406 of file simple_mesh.cxx.
void cgv::media::mesh::simple_mesh_base::compute_c2f | ( | std::vector< idx_type > & | c2f | ) | const |
compute index vector with per corner its face index
Definition at line 424 of file simple_mesh.cxx.
References begin_corner(), end_corner(), get_nr_corners(), and get_nr_faces().
simple_mesh_base::idx_type cgv::media::mesh::simple_mesh_base::compute_inv | ( | std::vector< idx_type > & | inv, |
bool | link_non_manifold_edges = false , |
||
std::vector< idx_type > * | p2c_ptr = 0 , |
||
std::vector< idx_type > * | next_ptr = 0 , |
||
std::vector< idx_type > * | prev_ptr = 0 , |
||
std::vector< idx_type > * | unmatched = 0 , |
||
std::vector< idx_type > * | non_manifold = 0 , |
||
std::vector< idx_type > * | unmatched_elements = 0 , |
||
std::vector< idx_type > * | non_manifold_elements = 0 |
||
) | const |
Do inverse matching of half-edges.
For this corners are converted to the half - edges that point in winding order away from the corner. The inverse matching result is stored in the vector inv
with one index per corner. This index is -1 for unmatched half-edges and the index of the corner corresponding to matched half-edges. For non-manifold edges two strategies are supported: cyclic linking (link_non_manifold_edges
= true) or cutting into unmatched half-edges (link_non_manifold_edges
= false). The function fills the optionally provided vectors
p2c
... per position the index of one incident cornernext
... per corner the index of the next corner in the faceprev
... per corner the index of the prev corner in the faceunmatched
... corners with unmatched half-edgesnon_manifold
... one corner index per non-manifold edgeunmatched_elements
... position indices of unmatched half-edgesnon_manifold_elements
... position indices of non-manifold edges The function returns the number of interior manifold edges Definition at line 265 of file simple_mesh.cxx.
References begin_corner(), c2p(), end_corner(), get_nr_corners(), get_nr_faces(), and get_nr_positions().
Retrieve index of the vertex which follows the end corner of a face.
[in] | fi | Which face of simple_mesh<T>faces. |
Definition at line 124 of file simple_mesh.h.
Referenced by compute_c2f(), compute_inv(), extract_triangle_element_buffer(), extract_wireframe_element_buffer(), and revert_face_orientation().
void cgv::media::mesh::simple_mesh_base::extract_triangle_element_buffer | ( | const std::vector< idx_type > & | vertex_indices, |
std::vector< idx_type > & | triangle_element_buffer, | ||
const std::vector< idx_type > * | face_permutation_ptr = 0 , |
||
std::vector< idx3_type > * | material_group_start_ptr = 0 |
||
) | const |
Extract element array buffers for triangulation.
[in] | vertex_indices | Contains indices into a list of vertices. |
[out] | triangle_element_buffer | Stores the vertex indices which make up a triangulated mesh. |
[in] | face_permutation_ptr | If nullptr the faces will be traversed in successive fashion. Otherwise the given index-permutation is used. |
[out] | material_group_start_ptr | Will be filled with material group indices if not nullptr. |
Definition at line 164 of file simple_mesh.cxx.
References begin_corner(), end_corner(), and face_degree().
Referenced by cgv::render::mesh_render_info::construct_index_buffers().
simple_mesh_base::idx_type cgv::media::mesh::simple_mesh_base::extract_vertex_attribute_buffer_base | ( | const std::vector< idx4_type > & | unique_quadruples, |
AttributeFlags & | flags, | ||
std::vector< uint8_t > & | attrib_buffer | ||
) | const |
extract vertex attribute buffer for the given flags and return size of vertex in bytes
Definition at line 222 of file simple_mesh.cxx.
References AF_color, AF_normal, AF_tangent, AF_texcoords, cgv::media::colored_model::get_color_size(), get_coord_size(), and cgv::media::colored_model::has_colors().
Referenced by cgv::render::mesh_render_info::construct(), cgv::render::mesh_render_info::construct_dynamic(), and cgv::render::mesh_render_info::update_vbo().
void cgv::media::mesh::simple_mesh_base::extract_wireframe_element_buffer | ( | const std::vector< idx_type > & | vertex_indices, |
std::vector< idx_type > & | edge_element_buffer | ||
) | const |
Extract element array buffers for edges in wireframe.
[in] | vertex_indices | Contains indices into a list of vertices. |
[out] | edge_element_buffer | Stores the vertex indices which make up a wireframed mesh. |
Definition at line 194 of file simple_mesh.cxx.
References begin_corner(), and end_corner().
Referenced by cgv::render::mesh_render_info::construct_index_buffers().
return number of edges/corners of face with index fi
Definition at line 126 of file simple_mesh.h.
Referenced by extract_triangle_element_buffer().
|
static |
Definition at line 20 of file simple_mesh.cxx.
|
static |
Definition at line 15 of file simple_mesh.cxx.
|
pure virtual |
return the size of one coordinate in bytes
Implemented in cgv::media::mesh::simple_mesh< T >, cgv::media::mesh::simple_mesh< float >, and cgv::media::mesh::simple_mesh< T >.
Referenced by extract_vertex_attribute_buffer_base().
|
inline |
return const reference to i-th material
Definition at line 132 of file simple_mesh.h.
Referenced by cgv::render::mesh_render_info::construct_index_buffers().
|
inline |
return the number of corners
Definition at line 110 of file simple_mesh.h.
Referenced by compute_c2f(), compute_inv(), and cgv::media::mesh::simple_mesh< float >::extract_vertex_attribute_buffer().
|
inline |
return the number of faces
Definition at line 108 of file simple_mesh.h.
Referenced by compute_c2f(), compute_inv(), cgv::render::gl::gl_implicit_surface_drawable_base::draw(), cgv::render::gl::gl_implicit_surface_drawable_base::draw_implicit_surface(), and revert_face_orientation().
|
inline |
return number of face groups
Definition at line 140 of file simple_mesh.h.
Referenced by cgv::render::mesh_render_info::construct_index_buffers(), and sort_faces().
|
inline |
return number of materials in mesh
Definition at line 128 of file simple_mesh.h.
Referenced by cgv::render::mesh_render_info::construct_index_buffers(), and sort_faces().
|
pure virtual |
position count
Implemented in cgv::media::mesh::simple_mesh< T >, cgv::media::mesh::simple_mesh< float >, and cgv::media::mesh::simple_mesh< T >.
Referenced by compute_inv().
return reference to group index of given face
Definition at line 150 of file simple_mesh.h.
return group index of given face
Definition at line 148 of file simple_mesh.h.
Referenced by cgv::render::extract_mesh().
|
inline |
set a new group name
Definition at line 144 of file simple_mesh.h.
|
inline |
return the name of the i-th face group
Definition at line 142 of file simple_mesh.h.
|
inline |
return whether normal indices are stored
Definition at line 102 of file simple_mesh.h.
|
inline |
return whether texture coordinate indices are stored
Definition at line 106 of file simple_mesh.h.
return reference to material index of given face
Definition at line 138 of file simple_mesh.h.
return material index of given face
Definition at line 136 of file simple_mesh.h.
Referenced by cgv::render::extract_mesh().
void cgv::media::mesh::simple_mesh_base::merge_indices | ( | std::vector< idx_type > & | vertex_indices, |
std::vector< idx4_type > & | unique_tuples, | ||
bool * | include_tex_coords_ptr = 0 , |
||
bool * | include_normals_ptr = 0 , |
||
bool * | include_tangents_ptr = 0 |
||
) | const |
Transforms n individual vertex attribute indices into one list of unique index n-tuples.
Picture for example a cube where each quadratic face has a color. There would be only eight vertex positions. However, each of these vertices belongs to three faces and would therefore need to carry three distinct colors. To solve this issue all the unique combinations of attribute indicies get recorded into a list. The new face primitives are then referenced by indexing into this list of unique index n-tuples.
See https://www.opengl-tutorial.org/intermediate-tutorials/tutorial-9-vbo-indexing/ for further details.
[out] | vertex_indices | will be filled per corner with index into the unique tuple list. |
[out] | unique_tuples | will be filled with all the unique n-tuples. |
[in,out] | include_tex_coords_ptr | if nullptr then texture coordinates won't be included in the n-tuples. Otherwise the pointed to bool will be set to true if the mesh even contains texture coordinates or false if not. |
[in,out] | include_normals_ptr | if nullptr then normals won't be included in the n-tuples. Otherwise the pointed to bool will be set to true if the mesh even contains normals or false if not. |
[in,out] | include_tangents_ptr | if nullptr then tangents won't be included in the n-tuples. Otherwise the pointed to bool will be set to true if the mesh even contains texture coordinates or false if not. |
Definition at line 127 of file simple_mesh.cxx.
Referenced by cgv::render::mesh_render_info::construct_index_buffers().
simple_mesh_base::idx_type cgv::media::mesh::simple_mesh_base::new_corner | ( | idx_type | position_index, |
idx_type | normal_index = -1 , |
||
idx_type | tex_coord_index = -1 |
||
) |
Create a new corner with the given attributes.
[in] | position_index | the corner's position as index into an attribute vector |
[in] | normal_index | the corner's normal as index into an attribute vector, or -1 if no normal |
[in] | tex_coord_index | the corner's texture coordinate as index into an attribute vector, or -1 if no texture coordinate |
Definition at line 87 of file simple_mesh.cxx.
Referenced by cgv::media::mesh::simple_mesh< T >::ambo(), cgv::media::mesh::simple_mesh< T >::dual(), cgv::render::extract_mesh(), cgv::media::mesh::simple_mesh< T >::gyro(), cgv::media::mesh::simple_mesh< T >::join(), cgv::render::gl::gl_implicit_surface_drawable_base::new_polygon(), cgv::media::mesh::simple_mesh< T >::snub(), and cgv::media::mesh::simple_mesh< T >::truncate().
|
inline |
add a new group and return its index
Definition at line 146 of file simple_mesh.h.
Referenced by cgv::render::extract_mesh().
|
inline |
add a new material and return its index
Definition at line 130 of file simple_mesh.h.
Referenced by cgv::render::extract_mesh().
simple_mesh_base & cgv::media::mesh::simple_mesh_base::operator= | ( | const simple_mesh_base & | smb | ) |
assignment operator
Definition at line 52 of file simple_mesh.cxx.
References cgv::media::colored_model::operator=().
Referenced by cgv::media::mesh::simple_mesh< T >::operator=(), and cgv::media::mesh::simple_mesh< T >::operator=().
simple_mesh_base & cgv::media::mesh::simple_mesh_base::operator= | ( | simple_mesh_base && | smb | ) |
move assignment operator
Definition at line 65 of file simple_mesh.cxx.
References cgv::media::colored_model::operator=().
|
inline |
return reference to i-th material
Definition at line 134 of file simple_mesh.h.
Referenced by cgv::render::extract_mesh().
void cgv::media::mesh::simple_mesh_base::revert_face_orientation | ( | ) |
revert face orientation
Definition at line 97 of file simple_mesh.cxx.
References begin_corner(), end_corner(), and get_nr_faces().
void cgv::media::mesh::simple_mesh_base::sort_faces | ( | std::vector< idx_type > & | perm, |
bool | by_group = true , |
||
bool | by_material = true |
||
) | const |
Calculate a permutation of face indices which sorts them by group and/or material.
[out] | perm | The sorting permutation. |
[in] | by_group | True if the faces should be sorted by group, false otherwise. |
[in] | by_material | True if the faces should be sorted by material, false otherwise. |
Definition at line 115 of file simple_mesh.cxx.
References get_nr_groups(), and get_nr_materials().
Referenced by cgv::render::mesh_render_info::construct_index_buffers().
simple_mesh_base::idx_type cgv::media::mesh::simple_mesh_base::start_face | ( | ) |
Create a new empty face to which new corners are added.
Definition at line 78 of file simple_mesh.cxx.
Referenced by cgv::media::mesh::simple_mesh< T >::ambo(), cgv::media::mesh::simple_mesh< T >::dual(), cgv::render::extract_mesh(), cgv::media::mesh::simple_mesh< T >::gyro(), cgv::media::mesh::simple_mesh< T >::join(), cgv::render::gl::gl_implicit_surface_drawable_base::new_polygon(), cgv::media::mesh::simple_mesh< T >::snub(), and cgv::media::mesh::simple_mesh< T >::truncate().
|
protected |
Definition at line 62 of file simple_mesh.h.
|
protected |
Definition at line 63 of file simple_mesh.h.
|
protected |
Definition at line 64 of file simple_mesh.h.
|
protected |
Definition at line 65 of file simple_mesh.h.
|
protected |
Definition at line 66 of file simple_mesh.h.
|
protected |
Definition at line 60 of file simple_mesh.h.
|
protected |
Definition at line 58 of file simple_mesh.h.
|
protected |
Definition at line 61 of file simple_mesh.h.
|
protected |
Definition at line 59 of file simple_mesh.h.