4 #include <cgv/math/fvec.h>
5 #include <cgv/math/fmat.h>
6 #include <cgv/utils/file.h>
7 #include <cgv/media/illum/textured_surface_material.h>
8 #include <cgv/media/axis_aligned_box.h>
9 #include <cgv/media/colored_model.h>
11 #include "../lib_begin.h"
18 class simple_mesh_obj_reader;
33 std::vector<idx_type> position_indices;
34 std::vector<idx_type> normal_indices;
35 std::vector<idx_type> tex_coord_indices;
36 std::vector<idx_type> faces;
37 std::vector<idx_type> group_indices;
38 std::vector<std::string> group_names;
39 std::vector<idx_type> material_indices;
40 std::vector<mat_type> materials;
85 const std::string&
group_name(
size_t i)
const {
return group_names[i]; }
87 std::string&
group_name(
size_t i) {
return group_names[i]; }
95 void revert_face_orientation();
97 void sort_faces(std::vector<idx_type>& perm,
bool by_group =
true,
bool by_material =
true)
const;
99 void merge_indices(std::vector<idx_type>& vertex_indices, std::vector<vec3i>& unique_triples,
bool* include_tex_coords_ptr = 0,
bool* include_normals_ptr = 0)
const;
101 void extract_triangle_element_buffer(
const std::vector<idx_type>& vertex_indices, std::vector<idx_type>& triangle_element_buffer,
102 const std::vector<idx_type>* face_perm_ptr = 0, std::vector<vec3i>* material_group_start_ptr = 0)
const;
104 void extract_wireframe_element_buffer(
const std::vector<idx_type>& vertex_indices, std::vector<idx_type>& edge_element_buffer)
const;
106 void compute_inv(std::vector<uint32_t>& inv, std::vector<uint32_t>* p2c_ptr = 0, std::vector<uint32_t>* next_ptr = 0, std::vector<uint32_t>* prev_ptr = 0);
108 uint32_t compute_c2e(
const std::vector<uint32_t>& inv, std::vector<uint32_t>& c2e, std::vector<uint32_t>* e2c_ptr = 0);
110 void compute_c2f(std::vector<uint32_t>& c2f);
114 template <
typename T =
float>
135 friend class simple_mesh_obj_reader<T>;
136 std::vector<vec3> positions;
137 std::vector<vec3> normals;
138 std::vector<vec2> tex_coords;
145 simple_mesh(
const std::string& conway_notation =
"");
155 vec3& position(idx_type pi) {
return positions[pi]; }
156 const vec3& position(idx_type pi)
const {
return positions[pi]; }
157 const std::vector<vec3>& get_positions()
const {
return positions; }
163 idx_type get_nr_normals()
const {
return idx_type(normals.size()); }
164 vec3& normal(idx_type ni) {
return normals[ni]; }
165 const vec3& normal(idx_type ni)
const {
return normals[ni]; }
171 idx_type get_nr_tex_coords()
const {
return idx_type(tex_coords.size()); }
172 vec2& tex_coord(idx_type ti) {
return tex_coords[ti]; }
173 const vec2& tex_coord(idx_type ti)
const {
return tex_coords[ti]; }
175 void compute_face_normals();
179 void truncate(T lambda = 0.33333f);
181 void snub(T lambda = 0.33333f);
185 void gyro(T lambda = 0.3333f);
191 void construct_conway_polyhedron(
const std::string& conway_notation);
194 box_type compute_box()
const;
196 void compute_vertex_normals();
198 bool read(
const std::string& file_name);
200 bool write(
const std::string& file_name)
const;
202 unsigned extract_vertex_attribute_buffer(
203 const std::vector<idx_type>& vertex_indices,
204 const std::vector<vec3i>& unique_triples,
205 bool include_tex_coords,
bool include_normals,
206 std::vector<T>& attrib_buffer,
bool *include_colors_ptr = 0)
const;
208 void transform(
const mat3& linear_transformation,
const vec3& translation);
210 void transform(
const mat3& linear_transform,
const vec3& translation,
const mat3& inverse_linear_transform);
217 #include <cgv/config/lib_end.h>
matrix of fixed size dimensions
Definition: fmat.h:23
unsigned int uint32_type
this type provides an 32 bit unsigned integer type
Definition: standard_types.h:20
simple class to hold the material properties of a phong material
Definition: textured_surface_material.h:15
the cgv namespace
Definition: vr_calib.cxx:9