OpenMesh
BaseImporter.hh
1/* ========================================================================= *
2 * *
3 * OpenMesh *
4 * Copyright (c) 2001-2025, 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 IOManager importer modules
48//
49//=============================================================================
50
51
52#ifndef __BASEIMPORTER_HH__
53#define __BASEIMPORTER_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
71namespace OpenMesh {
72namespace IO {
73
74
75//=== IMPLEMENTATION ==========================================================
76
77
83class OPENMESHDLLEXPORT BaseImporter
84{
85public:
86
87 // base class needs virtual destructor
88 virtual ~BaseImporter() {}
89
90
91 // add a vertex with coordinate \c _point
92 virtual VertexHandle add_vertex(const Vec3f& _point) = 0;
93
94 // add a vertex with coordinate \c _point
95 virtual VertexHandle add_vertex(const Vec3d& _point) { return add_vertex(Vec3f(_point)); }
96
97 // add a vertex without coordinate. Use set_point to set the position deferred
98 virtual VertexHandle add_vertex() = 0;
99
100 // add an edge. Use set_next, set_vertex and set_face to set corresponding entities for halfedges
101 virtual HalfedgeHandle add_edge(VertexHandle _vh0, VertexHandle _vh1) = 0;
102
103 // add a face with indices _indices refering to vertices
104 typedef std::vector<VertexHandle> VHandles;
105 virtual FaceHandle add_face(const VHandles& _indices) = 0;
106
107 // add a face with incident halfedge
108 virtual FaceHandle add_face(HalfedgeHandle _heh) = 0;
109
110 // add texture coordinates per face, _vh references the first texcoord
111 virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec2f>& _face_texcoords) = 0;
112
113 // add texture 3d coordinates per face, _vh references the first texcoord
114 virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec3f>& _face_texcoords) = 0;
115
116 // Set the texture index for a face
117 virtual void set_face_texindex( FaceHandle _fh, int _texId ) = 0;
118
119 // Set coordinate of the given vertex. Use this function, if you created a vertex without coordinate
120 virtual void set_point(VertexHandle _vh, const Vec3f& _point) = 0;
121
122 // Set outgoing halfedge for the given vertex.
123 virtual void set_halfedge(VertexHandle _vh, HalfedgeHandle _heh) = 0;
124
125 // set vertex normal
126 virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) = 0;
127
128 // set vertex normal
129 virtual void set_normal(VertexHandle _vh, const Vec3d& _normal) = 0;
130
131 // set vertex color
132 virtual void set_color(VertexHandle _vh, const Vec3uc& _color) = 0;
133
134 // set vertex color
135 virtual void set_color(VertexHandle _vh, const Vec4uc& _color) = 0;
136
137 // set vertex color
138 virtual void set_color(VertexHandle _vh, const Vec3f& _color) = 0;
139
140 // set vertex color
141 virtual void set_color(VertexHandle _vh, const Vec4f& _color) = 0;
142
143 // set vertex texture coordinate
144 virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord) = 0;
145
146 // set vertex status
147 virtual void set_status(VertexHandle _vh, const OpenMesh::Attributes::StatusInfo& _status) = 0;
148
149 // set next halfedge handle
150 virtual void set_next(HalfedgeHandle _heh, HalfedgeHandle _next) = 0;
151
152 // set incident face handle for given halfedge
153 virtual void set_face(HalfedgeHandle _heh, FaceHandle _fh) = 0;
154
155 // request texture coordinate property
156 virtual void request_face_texcoords2D() = 0;
157
158 // set vertex texture coordinate
159 virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) = 0;
160
161 // set 3d vertex texture coordinate
162 virtual void set_texcoord(VertexHandle _vh, const Vec3f& _texcoord) = 0;
163
164 // set 3d vertex texture coordinate
165 virtual void set_texcoord(HalfedgeHandle _heh, const Vec3f& _texcoord) = 0;
166
167 // set halfedge status
168 virtual void set_status(HalfedgeHandle _heh, const OpenMesh::Attributes::StatusInfo& _status) = 0;
169
170 // set edge color
171 virtual void set_color(EdgeHandle _eh, const Vec3uc& _color) = 0;
172
173 // set edge color
174 virtual void set_color(EdgeHandle _eh, const Vec4uc& _color) = 0;
175
176 // set edge color
177 virtual void set_color(EdgeHandle _eh, const Vec3f& _color) = 0;
178
179 // set edge color
180 virtual void set_color(EdgeHandle _eh, const Vec4f& _color) = 0;
181
182 // set edge status
183 virtual void set_status(EdgeHandle _eh, const OpenMesh::Attributes::StatusInfo& _status) = 0;
184
185 // set face normal
186 virtual void set_normal(FaceHandle _fh, const Vec3f& _normal) = 0;
187
188 // set face normal
189 virtual void set_normal(FaceHandle _fh, const Vec3d& _normal) = 0;
190
191 // set face color
192 virtual void set_color(FaceHandle _fh, const Vec3uc& _color) = 0;
193
194 // set face color
195 virtual void set_color(FaceHandle _fh, const Vec4uc& _color) = 0;
196
197 // set face color
198 virtual void set_color(FaceHandle _fh, const Vec3f& _color) = 0;
199
200 // set face color
201 virtual void set_color(FaceHandle _fh, const Vec4f& _color) = 0;
202
203 // set face status
204 virtual void set_status(FaceHandle _fh, const OpenMesh::Attributes::StatusInfo& _status) = 0;
205
206 // Store a property in the mesh mapping from an int to a texture file
207 // Use set_face_texindex to set the index for each face
208 virtual void add_texture_information( int _id , std::string _name ) = 0;
209
210 // get reference to base kernel
211 virtual BaseKernel* kernel() { return nullptr; }
212
213 virtual bool is_triangle_mesh() const { return false; }
214
215 // reserve mem for elements
216 virtual void reserve( unsigned int /* nV */,
217 unsigned int /* nE */,
218 unsigned int /* nF */) {}
219
220 // query number of faces, vertices, normals, texcoords
221 virtual size_t n_vertices() const = 0;
222 virtual size_t n_faces() const = 0;
223 virtual size_t n_edges() const = 0;
224
225
226 // pre-processing
227 virtual void prepare() {}
228
229 // post-processing
230 virtual void finish() {}
231};
232
233
234//=============================================================================
235} // namespace IO
236} // namespace OpenMesh
237//=============================================================================
238#endif
239//=============================================================================
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
VectorT< float, 3 > Vec3f
3-float vector
Definition: Vector11T.hh:851
Base class for importer modules.
Definition: BaseImporter.hh:84
This class provides low-level property management like adding/removing properties and access to prope...
Definition: BaseKernel.hh:98
Handle for a vertex entity.
Definition: Handles.hh:121
Handle for a halfedge entity.
Definition: Handles.hh:128
Handle for a edge entity.
Definition: Handles.hh:135
Handle for a face entity.
Definition: Handles.hh:142
Add status information to a base class.
Definition: Status.hh:95

Project OpenMesh, ©  Visual Computing Institute, RWTH Aachen. Documentation generated using doxygen .