1 /* ========================================================================= * 2 * * 3 * OpenMesh * 4 * Copyright (c) 2001-2015, RWTH-Aachen University * 5 * Department of Computer Graphics and Multimedia * 6 * All rights reserved. * 7 * www.openmesh.org * 8 * * 9 *---------------------------------------------------------------------------* 10 * This file is part of OpenMesh. * 11 *---------------------------------------------------------------------------* 12 * * 13 * Redistribution and use in source and binary forms, with or without * 14 * modification, are permitted provided that the following conditions * 15 * are met: * 16 * * 17 * 1. Redistributions of source code must retain the above copyright notice, * 18 * this list of conditions and the following disclaimer. * 19 * * 20 * 2. Redistributions in binary form must reproduce the above copyright * 21 * notice, this list of conditions and the following disclaimer in the * 22 * documentation and/or other materials provided with the distribution. * 23 * * 24 * 3. Neither the name of the copyright holder nor the names of its * 25 * contributors may be used to endorse or promote products derived from * 26 * this software without specific prior written permission. * 27 * * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * 30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * 31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * 32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * 33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * 34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * 35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * 36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * 38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 39 * * 40 * ========================================================================= */ 41 42 43 44 45 //============================================================================= 46 // 47 // Implements the baseclass for MeshWriter exporter modules 48 // 49 //============================================================================= 50 51 52 #ifndef __BASEEXPORTER_HH__ 53 #define __BASEEXPORTER_HH__ 54 55 56 //=== INCLUDES ================================================================ 57 58 59 // STL 60 #include <vector> 61 62 // OpenMesh 63 #include <OpenMesh/Core/System/config.h> 64 #include <OpenMesh/Core/Geometry/VectorT.hh> 65 #include <OpenMesh/Core/Mesh/BaseKernel.hh> 66 67 68 //=== NAMESPACES ============================================================== 69 70 71 namespace OpenMesh { 72 namespace IO { 73 74 75 //=== EXPORTER ================================================================ 76 77 78 /** 79 Base class for exporter modules. 80 The exporter modules provide an interface between the writer modules and 81 the target data structure. 82 */ 83 84 class OPENMESHDLLEXPORT BaseExporter 85 { 86 public: 87 ~BaseExporter()88 virtual ~BaseExporter() { } 89 90 91 // get vertex data 92 virtual Vec3f point(VertexHandle _vh) const = 0; 93 virtual Vec3d pointd(VertexHandle _vh) const = 0; 94 virtual bool is_point_double() const = 0; 95 virtual Vec3f normal(VertexHandle _vh) const = 0; 96 virtual Vec3d normald(VertexHandle _vh) const = 0; 97 virtual bool is_normal_double() const = 0; 98 virtual Vec3uc color(VertexHandle _vh) const = 0; 99 virtual Vec4uc colorA(VertexHandle _vh) const = 0; 100 virtual Vec3ui colori(VertexHandle _vh) const = 0; 101 virtual Vec4ui colorAi(VertexHandle _vh) const = 0; 102 virtual Vec3f colorf(VertexHandle _vh) const = 0; 103 virtual Vec4f colorAf(VertexHandle _vh) const = 0; 104 virtual Vec2f texcoord(VertexHandle _vh) const = 0; 105 virtual Vec2f texcoord(HalfedgeHandle _heh) const = 0; 106 virtual OpenMesh::Attributes::StatusInfo status(VertexHandle _vh) const = 0; 107 108 109 // get face data 110 virtual unsigned int 111 get_vhandles(FaceHandle _fh, 112 std::vector<VertexHandle>& _vhandles) const=0; 113 114 /// 115 /// \brief getHeh returns the HalfEdgeHandle that belongs to the face 116 /// specified by _fh and has a toVertexHandle that corresponds to _vh. 117 /// \param _fh FaceHandle that is used to search for the half edge handle 118 /// \param _vh to_vertex_handle of the searched heh 119 /// \return HalfEdgeHandle or invalid HalfEdgeHandle if none is found. 120 /// 121 virtual HalfedgeHandle getHeh(FaceHandle _fh, VertexHandle _vh) const = 0; 122 virtual unsigned int 123 get_face_texcoords(std::vector<Vec2f>& _hehandles) const = 0; 124 virtual Vec3f normal(FaceHandle _fh) const = 0; 125 virtual Vec3d normald(FaceHandle _fh) const = 0; 126 virtual Vec3uc color (FaceHandle _fh) const = 0; 127 virtual Vec4uc colorA(FaceHandle _fh) const = 0; 128 virtual Vec3ui colori(FaceHandle _fh) const = 0; 129 virtual Vec4ui colorAi(FaceHandle _fh) const = 0; 130 virtual Vec3f colorf(FaceHandle _fh) const = 0; 131 virtual Vec4f colorAf(FaceHandle _fh) const = 0; 132 virtual OpenMesh::Attributes::StatusInfo status(FaceHandle _fh) const = 0; 133 134 // get edge data 135 virtual Vec3uc color(EdgeHandle _eh) const = 0; 136 virtual Vec4uc colorA(EdgeHandle _eh) const = 0; 137 virtual Vec3ui colori(EdgeHandle _eh) const = 0; 138 virtual Vec4ui colorAi(EdgeHandle _eh) const = 0; 139 virtual Vec3f colorf(EdgeHandle _eh) const = 0; 140 virtual Vec4f colorAf(EdgeHandle _eh) const = 0; 141 virtual OpenMesh::Attributes::StatusInfo status(EdgeHandle _eh) const = 0; 142 143 // get halfedge data 144 virtual int get_halfedge_id(VertexHandle _vh) = 0; 145 virtual int get_halfedge_id(FaceHandle _vh) = 0; 146 virtual int get_next_halfedge_id(HalfedgeHandle _heh) = 0; 147 virtual int get_to_vertex_id(HalfedgeHandle _heh) = 0; 148 virtual int get_face_id(HalfedgeHandle _heh) = 0; 149 virtual OpenMesh::Attributes::StatusInfo status(HalfedgeHandle _heh) const = 0; 150 151 // get reference to base kernel kernel()152 virtual const BaseKernel* kernel() { return nullptr; } 153 154 155 // query number of faces, vertices, normals, texcoords 156 virtual size_t n_vertices() const = 0; 157 virtual size_t n_faces() const = 0; 158 virtual size_t n_edges() const = 0; 159 160 161 // property information is_triangle_mesh() const162 virtual bool is_triangle_mesh() const { return false; } has_vertex_normals() const163 virtual bool has_vertex_normals() const { return false; } has_vertex_colors() const164 virtual bool has_vertex_colors() const { return false; } has_vertex_status() const165 virtual bool has_vertex_status() const { return false; } has_vertex_texcoords() const166 virtual bool has_vertex_texcoords() const { return false; } has_edge_colors() const167 virtual bool has_edge_colors() const { return false; } has_edge_status() const168 virtual bool has_edge_status() const { return false; } has_halfedge_status() const169 virtual bool has_halfedge_status() const { return false; } has_face_normals() const170 virtual bool has_face_normals() const { return false; } has_face_colors() const171 virtual bool has_face_colors() const { return false; } has_face_status() const172 virtual bool has_face_status() const { return false; } 173 }; 174 175 176 //============================================================================= 177 } // namespace IO 178 } // namespace OpenMesh 179 //============================================================================= 180 #endif 181 //============================================================================= 182