OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BaseImporter.hh
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
5 * www.openmesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenMesh. *
9 * *
10 * OpenMesh is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenMesh is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 /*===========================================================================*\
36 * *
37 * $Revision: 818 $ *
38 * $Date: 2013-03-04 17:36:20 +0100 (Mo, 04. Mär 2013) $ *
39 * *
40 \*===========================================================================*/
41
42
43 //=============================================================================
44 //
45 // Implements the baseclass for IOManager importer modules
46 //
47 //=============================================================================
48
49
50 #ifndef __BASEIMPORTER_HH__
51 #define __BASEIMPORTER_HH__
52
53
54 //=== INCLUDES ================================================================
55
56
57 // STL
58 #include <vector>
59
60 // OpenMesh
61 #include <OpenMesh/Core/System/config.h>
62 #include <OpenMesh/Core/Geometry/VectorT.hh>
63 #include <OpenMesh/Core/Mesh/BaseKernel.hh>
64
65
66 //== NAMESPACES ===============================================================
67
68
69 namespace OpenMesh {
70 namespace IO {
71
72
73 //=== IMPLEMENTATION ==========================================================
74
75
81 class OPENMESHDLLEXPORT BaseImporter
82 {
83 public:
84
85 // base class needs virtual destructor
86 virtual ~BaseImporter() {}
87
88
89 // add a vertex with coordinate \c _point
90 virtual VertexHandle add_vertex(const Vec3f& _point) = 0;
91
92 // add a face with indices _indices refering to vertices
93 typedef std::vector<VertexHandle> VHandles;
94 virtual FaceHandle add_face(const VHandles& _indices) = 0;
95
96 // add texture coordinates per face, _vh references the first texcoord
97 virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec2f>& _face_texcoords) = 0;
98
99 // Set the texture index for a face
100 virtual void set_face_texindex( FaceHandle _fh, int _texId ) = 0;
101
102 // set vertex normal
103 virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) = 0;
104
105 // set vertex color
106 virtual void set_color(VertexHandle _vh, const Vec3uc& _color) = 0;
107
108 // set vertex color
109 virtual void set_color(VertexHandle _vh, const Vec4uc& _color) = 0;
110
111 // set vertex color
112 virtual void set_color(VertexHandle _vh, const Vec3f& _color) = 0;
113
114 // set vertex color
115 virtual void set_color(VertexHandle _vh, const Vec4f& _color) = 0;
116
117 // set vertex texture coordinate
118 virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord) = 0;
119
120 // set vertex texture coordinate
121 virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) = 0;
122
123 // set edge color
124 virtual void set_color(EdgeHandle _eh, const Vec3uc& _color) = 0;
125
126 // set edge color
127 virtual void set_color(EdgeHandle _eh, const Vec4uc& _color) = 0;
128
129 // set edge color
130 virtual void set_color(EdgeHandle _eh, const Vec3f& _color) = 0;
131
132 // set edge color
133 virtual void set_color(EdgeHandle _eh, const Vec4f& _color) = 0;
134
135 // set face normal
136 virtual void set_normal(FaceHandle _fh, const Vec3f& _normal) = 0;
137
138 // set face color
139 virtual void set_color(FaceHandle _fh, const Vec3uc& _color) = 0;
140
141 // set face color
142 virtual void set_color(FaceHandle _fh, const Vec4uc& _color) = 0;
143
144 // set face color
145 virtual void set_color(FaceHandle _fh, const Vec3f& _color) = 0;
146
147 // set face color
148 virtual void set_color(FaceHandle _fh, const Vec4f& _color) = 0;
149
150 // Store a property in the mesh mapping from an int to a texture file
151 // Use set_face_texindex to set the index for each face
152 virtual void add_texture_information( int _id , std::string _name ) = 0;
153
154 // get reference to base kernel
155 virtual BaseKernel* kernel() { return 0; }
156
157 virtual bool is_triangle_mesh() const { return false; }
158
159 // reserve mem for elements
160 virtual void reserve( unsigned int /* nV */,
161 unsigned int /* nE */,
162 unsigned int /* nF */) {}
163
164 // query number of faces, vertices, normals, texcoords
165 virtual size_t n_vertices() const = 0;
166 virtual size_t n_faces() const = 0;
167 virtual size_t n_edges() const = 0;
168
169
170 // pre-processing
171 virtual void prepare() {}
172
173 // post-processing
174 virtual void finish() {}
175 };
176
177
178 //=============================================================================
179 } // namespace IO
180 } // namespace OpenMesh
181 //=============================================================================
182 #endif
183 //=============================================================================