50 #ifndef __EXPORTERT_HH__
51 #define __EXPORTERT_HH__
60 #include <OpenMesh/Core/System/config.h>
61 #include <OpenMesh/Core/Geometry/VectorT.hh>
62 #include <OpenMesh/Core/Utils/GenProg.hh>
63 #include <OpenMesh/Core/Utils/vector_cast.hh>
64 #include <OpenMesh/Core/Utils/color_cast.hh>
65 #include <OpenMesh/Core/IO/exporter/BaseExporter.hh>
85 ExporterT(
const Mesh& _mesh) : mesh_(_mesh) {}
97 return (mesh_.has_vertex_normals()
99 : Vec3f(0.0f, 0.0f, 0.0f));
104 return (mesh_.has_vertex_colors()
105 ? color_cast<Vec3uc>(mesh_.color(_vh))
111 return (mesh_.has_vertex_colors()
112 ? color_cast<Vec4uc>(mesh_.color(_vh))
113 : Vec4uc(0, 0, 0, 0));
118 return (mesh_.has_vertex_colors()
119 ? color_cast<Vec3ui>(mesh_.color(_vh))
125 return (mesh_.has_vertex_colors()
126 ? color_cast<Vec4ui>(mesh_.color(_vh))
127 : Vec4ui(0, 0, 0, 0));
132 return (mesh_.has_vertex_colors()
133 ? color_cast<Vec3f>(mesh_.color(_vh))
139 return (mesh_.has_vertex_colors()
140 ? color_cast<Vec4f>(mesh_.color(_vh))
141 : Vec4f(0, 0, 0, 0));
146 #if defined(OM_CC_GCC) && (OM_CC_VERSION<30000)
150 if (mesh_.has_vertex_texcoords2D())
151 return vector_cast<Vec2f>(mesh_.texcoord2D(_vh));
152 return Vec2f(0.0f, 0.0f);
154 return (mesh_.has_vertex_texcoords2D()
156 : Vec2f(0.0f, 0.0f));
164 return (mesh_.has_edge_colors()
165 ? color_cast<Vec3uc>(mesh_.color(_eh))
171 return (mesh_.has_edge_colors()
172 ? color_cast<Vec4uc>(mesh_.color(_eh))
173 : Vec4uc(0, 0, 0, 0));
178 return (mesh_.has_edge_colors()
179 ? color_cast<Vec3ui>(mesh_.color(_eh))
185 return (mesh_.has_edge_colors()
186 ? color_cast<Vec4ui>(mesh_.color(_eh))
187 : Vec4ui(0, 0, 0, 0));
192 return (mesh_.has_vertex_colors()
193 ? color_cast<Vec3f>(mesh_.color(_eh))
199 return (mesh_.has_vertex_colors()
200 ? color_cast<Vec4f>(mesh_.color(_eh))
201 : Vec4f(0, 0, 0, 0));
207 std::vector<VertexHandle>& _vhandles)
const
209 unsigned int count(0);
211 for (
typename Mesh::CFVIter fv_it=mesh_.cfv_iter(_fh); fv_it.is_valid(); ++fv_it)
213 _vhandles.push_back(*fv_it);
221 return (mesh_.has_face_normals()
223 : Vec3f(0.0f, 0.0f, 0.0f));
228 return (mesh_.has_face_colors()
229 ? color_cast<Vec3uc>(mesh_.color(_fh))
235 return (mesh_.has_face_colors()
236 ? color_cast<Vec4uc>(mesh_.color(_fh))
237 : Vec4uc(0, 0, 0, 0));
242 return (mesh_.has_face_colors()
243 ? color_cast<Vec3ui>(mesh_.color(_fh))
249 return (mesh_.has_face_colors()
250 ? color_cast<Vec4ui>(mesh_.color(_fh))
251 : Vec4ui(0, 0, 0, 0));
256 return (mesh_.has_vertex_colors()
257 ? color_cast<Vec3f>(mesh_.color(_fh))
263 return (mesh_.has_vertex_colors()
264 ? color_cast<Vec4f>(mesh_.color(_fh))
265 : Vec4f(0, 0, 0, 0));
268 virtual const BaseKernel* kernel() {
return &mesh_; }
272 size_t n_vertices()
const {
return mesh_.n_vertices(); }
273 size_t n_faces()
const {
return mesh_.n_faces(); }
274 size_t n_edges()
const {
return mesh_.n_edges(); }
278 bool is_triangle_mesh()
const
279 {
return Mesh::is_triangles(); }
281 bool has_vertex_normals()
const {
return mesh_.has_vertex_normals(); }
282 bool has_vertex_colors()
const {
return mesh_.has_vertex_colors(); }
283 bool has_vertex_texcoords()
const {
return mesh_.has_vertex_texcoords2D(); }
284 bool has_edge_colors()
const {
return mesh_.has_edge_colors(); }
285 bool has_face_normals()
const {
return mesh_.has_face_normals(); }
286 bool has_face_colors()
const {
return mesh_.has_face_colors(); }
vector_caster< dst_t, src_t >::return_type vector_cast(const src_t &_src)
Cast vector type to another vector type by copying the vector elements.
Definition: vector_cast.hh:170
This class template provides an exporter module for OpenMesh meshes.
Definition: ExporterT.hh:80
Handle for a edge entity.
Definition: Handles.hh:128
Handle for a face entity.
Definition: Handles.hh:135
Base class for exporter modules.
Definition: BaseExporter.hh:82
This class provides the basic property management like adding/removing properties and access to prope...
Definition: BaseKernel.hh:91
Handle for a vertex entity.
Definition: Handles.hh:114