OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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: 736 $ *
38  * $Date: 2012-10-08 09:30:49 +0200 (Mo, 08 Okt 2012) $ *
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 texture coordinate
112  virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord) = 0;
113 
114  // set vertex texture coordinate
115  virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) = 0;
116 
117  // set edge color
118  virtual void set_color(EdgeHandle _eh, const Vec3uc& _color) = 0;
119 
120  // set edge color
121  virtual void set_color(EdgeHandle _eh, const Vec4uc& _color) = 0;
122 
123  // set face normal
124  virtual void set_normal(FaceHandle _fh, const Vec3f& _normal) = 0;
125 
126  // set face color
127  virtual void set_color(FaceHandle _fh, const Vec3uc& _color) = 0;
128 
129  // set face color
130  virtual void set_color(FaceHandle _fh, const Vec4uc& _color) = 0;
131 
132  // Store a property in the mesh mapping from an int to a texture file
133  // Use set_face_texindex to set the index for each face
134  virtual void add_texture_information( int _id , std::string _name ) = 0;
135 
136  // get reference to base kernel
137  virtual BaseKernel* kernel() { return 0; }
138 
139  virtual bool is_triangle_mesh() const { return false; }
140 
141  // reserve mem for elements
142  virtual void reserve( unsigned int /* nV */,
143  unsigned int /* nE */,
144  unsigned int /* nF */) {}
145 
146  // query number of faces, vertices, normals, texcoords
147  virtual size_t n_vertices() const = 0;
148  virtual size_t n_faces() const = 0;
149  virtual size_t n_edges() const = 0;
150 
151 
152  // pre-processing
153  virtual void prepare() {}
154 
155  // post-processing
156  virtual void finish() {}
157 };
158 
159 
160 //=============================================================================
161 } // namespace IO
162 } // namespace OpenMesh
163 //=============================================================================
164 #endif
165 //=============================================================================

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .