57 #ifndef __EXPORTERT_HH__ 58 #define __EXPORTERT_HH__ 67 #include <OpenMesh/Core/System/config.h> 68 #include <OpenMesh/Core/Geometry/VectorT.hh> 69 #include <OpenMesh/Core/Utils/GenProg.hh> 70 #include <OpenMesh/Core/Utils/vector_cast.hh> 71 #include <OpenMesh/Core/Utils/color_cast.hh> 72 #include <OpenMesh/Core/IO/exporter/BaseExporter.hh> 92 ExporterT(
const Mesh& _mesh) : mesh_(_mesh) {}
104 return (mesh_.has_vertex_normals()
106 :
Vec3f(0.0f, 0.0f, 0.0f));
111 return (mesh_.has_vertex_colors()
112 ? color_cast<
Vec3uc>(mesh_.color(_vh))
118 return (mesh_.has_vertex_colors()
119 ? color_cast<
Vec4uc>(mesh_.color(_vh))
125 return (mesh_.has_vertex_colors()
126 ? color_cast<
Vec3ui>(mesh_.color(_vh))
132 return (mesh_.has_vertex_colors()
133 ? color_cast<
Vec4ui>(mesh_.color(_vh))
139 return (mesh_.has_vertex_colors()
140 ? color_cast<
Vec3f>(mesh_.color(_vh))
146 return (mesh_.has_vertex_colors()
147 ? color_cast<
Vec4f>(mesh_.color(_vh))
148 :
Vec4f(0, 0, 0, 0));
153 #if defined(OM_CC_GCC) && (OM_CC_VERSION<30000) 157 if (mesh_.has_vertex_texcoords2D())
158 return vector_cast<Vec2f>(mesh_.texcoord2D(_vh));
159 return Vec2f(0.0f, 0.0f);
161 return (mesh_.has_vertex_texcoords2D()
163 :
Vec2f(0.0f, 0.0f));
169 return (mesh_.has_halfedge_texcoords2D()
171 :
Vec2f(0.0f, 0.0f));
178 return (mesh_.has_edge_colors()
179 ? color_cast<
Vec3uc>(mesh_.color(_eh))
185 return (mesh_.has_edge_colors()
186 ? color_cast<
Vec4uc>(mesh_.color(_eh))
192 return (mesh_.has_edge_colors()
193 ? color_cast<
Vec3ui>(mesh_.color(_eh))
199 return (mesh_.has_edge_colors()
200 ? color_cast<
Vec4ui>(mesh_.color(_eh))
206 return (mesh_.has_vertex_colors()
207 ? color_cast<
Vec3f>(mesh_.color(_eh))
213 return (mesh_.has_vertex_colors()
214 ? color_cast<
Vec4f>(mesh_.color(_eh))
215 :
Vec4f(0, 0, 0, 0));
221 std::vector<VertexHandle>& _vhandles)
const 223 unsigned int count(0);
225 for (
typename Mesh::CFVIter fv_it=mesh_.cfv_iter(_fh); fv_it.is_valid(); ++fv_it)
227 _vhandles.push_back(*fv_it);
233 unsigned int get_face_texcoords(std::vector<Vec2f>& _hehandles)
const 235 unsigned int count(0);
237 for(
typename Mesh::CHIter he_it=mesh_.halfedges_begin();
238 he_it != mesh_.halfedges_end(); ++he_it)
240 _hehandles.push_back(vector_cast<Vec2f>(mesh_.texcoord2D( *he_it)));
249 typename Mesh::ConstFaceHalfedgeIter fh_it;
250 for(fh_it = mesh_.cfh_iter(_fh); fh_it.is_valid();++fh_it)
252 if(mesh_.to_vertex_handle(*fh_it) == _vh)
260 return (mesh_.has_face_normals()
262 :
Vec3f(0.0f, 0.0f, 0.0f));
267 return (mesh_.has_face_colors()
268 ? color_cast<
Vec3uc>(mesh_.color(_fh))
274 return (mesh_.has_face_colors()
275 ? color_cast<
Vec4uc>(mesh_.color(_fh))
281 return (mesh_.has_face_colors()
282 ? color_cast<
Vec3ui>(mesh_.color(_fh))
288 return (mesh_.has_face_colors()
289 ? color_cast<
Vec4ui>(mesh_.color(_fh))
295 return (mesh_.has_vertex_colors()
296 ? color_cast<
Vec3f>(mesh_.color(_fh))
302 return (mesh_.has_vertex_colors()
303 ? color_cast<
Vec4f>(mesh_.color(_fh))
304 :
Vec4f(0, 0, 0, 0));
307 virtual const BaseKernel* kernel() {
return &mesh_; }
311 size_t n_vertices()
const {
return mesh_.n_vertices(); }
312 size_t n_faces()
const {
return mesh_.n_faces(); }
313 size_t n_edges()
const {
return mesh_.n_edges(); }
317 bool is_triangle_mesh()
const 318 {
return Mesh::is_triangles(); }
320 bool has_vertex_normals()
const {
return mesh_.has_vertex_normals(); }
321 bool has_vertex_colors()
const {
return mesh_.has_vertex_colors(); }
322 bool has_vertex_texcoords()
const {
return mesh_.has_vertex_texcoords2D(); }
323 bool has_edge_colors()
const {
return mesh_.has_edge_colors(); }
324 bool has_face_normals()
const {
return mesh_.has_face_normals(); }
325 bool has_face_colors()
const {
return mesh_.has_face_colors(); }
VectorT< float, 4 > Vec4f
4-float vector
Definition: Vector11T.hh:830
VectorT< unsigned int, 3 > Vec3ui
3-int unsigned vector
Definition: Vector11T.hh:809
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
void vector_cast(const src_t &_src, dst_t &_dst, GenProg::Int2Type< n >)
Cast vector type to another vector type by copying the vector elements.
Definition: vector_cast.hh:86
VectorT< float, 2 > Vec2f
2-float vector
Definition: Vector11T.hh:794
This class template provides an exporter module for OpenMesh meshes.
Definition: ExporterT.hh:87
Handle for a halfedge entity.
Definition: Handles.hh:132
This class provides low-level property management like adding/removing properties and access to prope...
Definition: BaseKernel.hh:102
Handle for a face entity.
Definition: Handles.hh:146
VectorT< float, 3 > Vec3f
3-float vector
Definition: Vector11T.hh:811
Base class for exporter modules.
Definition: BaseExporter.hh:89
Handle for a vertex entity.
Definition: Handles.hh:125
HalfedgeHandle getHeh(FaceHandle _fh, VertexHandle _vh) const
getHeh returns the HalfEdgeHandle that belongs to the face specified by _fh and has a toVertexHandle ...
Definition: ExporterT.hh:247
VectorT< unsigned char, 4 > Vec4uc
4-byte unsigned vector
Definition: Vector11T.hh:820
VectorT< unsigned int, 4 > Vec4ui
4-int unsigned vector
Definition: Vector11T.hh:828
Handle for a edge entity.
Definition: Handles.hh:139
VectorT< unsigned char, 3 > Vec3uc
3-byte unsigned vector
Definition: Vector11T.hh:801