OpenMesh
BaseImporter.hh
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  * $Revision$ *
45  * $Date$ *
46  * *
47 \*===========================================================================*/
48 
49 
50 //=============================================================================
51 //
52 // Implements the baseclass for IOManager importer modules
53 //
54 //=============================================================================
55 
56 
57 #ifndef __BASEIMPORTER_HH__
58 #define __BASEIMPORTER_HH__
59 
60 
61 //=== INCLUDES ================================================================
62 
63 
64 // STL
65 #include <vector>
66 
67 // OpenMesh
68 #include <OpenMesh/Core/System/config.h>
69 #include <OpenMesh/Core/Geometry/VectorT.hh>
70 #include <OpenMesh/Core/Mesh/BaseKernel.hh>
71 
72 
73 //== NAMESPACES ===============================================================
74 
75 
76 namespace OpenMesh {
77 namespace IO {
78 
79 
80 //=== IMPLEMENTATION ==========================================================
81 
82 
88 class OPENMESHDLLEXPORT BaseImporter
89 {
90 public:
91 
92  // base class needs virtual destructor
93  virtual ~BaseImporter() {}
94 
95 
96  // add a vertex with coordinate \c _point
97  virtual VertexHandle add_vertex(const Vec3f& _point) = 0;
98 
99  // add a vertex without coordinate. Use set_point to set the position deferred
100  virtual VertexHandle add_vertex() = 0;
101 
102  // add a face with indices _indices refering to vertices
103  typedef std::vector<VertexHandle> VHandles;
104  virtual FaceHandle add_face(const VHandles& _indices) = 0;
105 
106  // add texture coordinates per face, _vh references the first texcoord
107  virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec2f>& _face_texcoords) = 0;
108 
109  // add texture 3d coordinates per face, _vh references the first texcoord
110  virtual void add_face_texcoords( FaceHandle _fh, VertexHandle _vh, const std::vector<Vec3f>& _face_texcoords) = 0;
111 
112  // Set the texture index for a face
113  virtual void set_face_texindex( FaceHandle _fh, int _texId ) = 0;
114 
115  // Set coordinate of the given vertex. Use this function, if you created a vertex without coordinate
116  virtual void set_point(VertexHandle _vh, const Vec3f& _point) = 0;
117 
118  // set vertex normal
119  virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) = 0;
120 
121  // set vertex color
122  virtual void set_color(VertexHandle _vh, const Vec3uc& _color) = 0;
123 
124  // set vertex color
125  virtual void set_color(VertexHandle _vh, const Vec4uc& _color) = 0;
126 
127  // set vertex color
128  virtual void set_color(VertexHandle _vh, const Vec3f& _color) = 0;
129 
130  // set vertex color
131  virtual void set_color(VertexHandle _vh, const Vec4f& _color) = 0;
132 
133  // set vertex texture coordinate
134  virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord) = 0;
135 
136  // set vertex texture coordinate
137  virtual void set_texcoord(HalfedgeHandle _heh, const Vec2f& _texcoord) = 0;
138 
139  // set 3d vertex texture coordinate
140  virtual void set_texcoord(VertexHandle _vh, const Vec3f& _texcoord) = 0;
141 
142  // set 3d vertex texture coordinate
143  virtual void set_texcoord(HalfedgeHandle _heh, const Vec3f& _texcoord) = 0;
144 
145  // set edge color
146  virtual void set_color(EdgeHandle _eh, const Vec3uc& _color) = 0;
147 
148  // set edge color
149  virtual void set_color(EdgeHandle _eh, const Vec4uc& _color) = 0;
150 
151  // set edge color
152  virtual void set_color(EdgeHandle _eh, const Vec3f& _color) = 0;
153 
154  // set edge color
155  virtual void set_color(EdgeHandle _eh, const Vec4f& _color) = 0;
156 
157  // set face normal
158  virtual void set_normal(FaceHandle _fh, const Vec3f& _normal) = 0;
159 
160  // set face color
161  virtual void set_color(FaceHandle _fh, const Vec3uc& _color) = 0;
162 
163  // set face color
164  virtual void set_color(FaceHandle _fh, const Vec4uc& _color) = 0;
165 
166  // set face color
167  virtual void set_color(FaceHandle _fh, const Vec3f& _color) = 0;
168 
169  // set face color
170  virtual void set_color(FaceHandle _fh, const Vec4f& _color) = 0;
171 
172  // Store a property in the mesh mapping from an int to a texture file
173  // Use set_face_texindex to set the index for each face
174  virtual void add_texture_information( int _id , std::string _name ) = 0;
175 
176  // get reference to base kernel
177  virtual BaseKernel* kernel() { return 0; }
178 
179  virtual bool is_triangle_mesh() const { return false; }
180 
181  // reserve mem for elements
182  virtual void reserve( unsigned int /* nV */,
183  unsigned int /* nE */,
184  unsigned int /* nF */) {}
185 
186  // query number of faces, vertices, normals, texcoords
187  virtual size_t n_vertices() const = 0;
188  virtual size_t n_faces() const = 0;
189  virtual size_t n_edges() const = 0;
190 
191 
192  // pre-processing
193  virtual void prepare() {}
194 
195  // post-processing
196  virtual void finish() {}
197 };
198 
199 
200 //=============================================================================
201 } // namespace IO
202 } // namespace OpenMesh
203 //=============================================================================
204 #endif
205 //=============================================================================
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
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
Handle for a vertex entity.
Definition: Handles.hh:125
Base class for importer modules.
Definition: BaseImporter.hh:88
Handle for a edge entity.
Definition: Handles.hh:139

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