00001 /*===========================================================================*\ 00002 * * 00003 * OpenMesh * 00004 * Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen * 00005 * www.openmesh.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * * 00009 * License * 00010 * * 00011 * This library is free software; you can redistribute it and/or modify it * 00012 * under the terms of the GNU Library General Public License as published * 00013 * by the Free Software Foundation, version 2. * 00014 * * 00015 * This library is distributed in the hope that it will be useful, but * 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00018 * Library General Public License for more details. * 00019 * * 00020 * You should have received a copy of the GNU Library General Public * 00021 * License along with this library; if not, write to the Free Software * 00022 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00023 * * 00024 \*===========================================================================*/ 00025 00026 00027 //============================================================================= 00028 // 00029 // Implements the baseclass for IOManager importer modules 00030 // 00031 //============================================================================= 00032 00033 00034 #ifndef __BASEIMPORTER_HH__ 00035 #define __BASEIMPORTER_HH__ 00036 00037 00038 //=== INCLUDES ================================================================ 00039 00040 00041 // STL 00042 #include <vector> 00043 00044 // OpenMesh 00045 #include <OpenMesh/Core/System/config.hh> 00046 #include <OpenMesh/Core/Math/VectorT.hh> 00047 #include <OpenMesh/Core/Mesh/Kernels/Common/BaseKernel.hh> 00048 00049 00050 //== NAMESPACES =============================================================== 00051 00052 00053 namespace OpenMesh { 00054 namespace IO { 00055 00056 00057 //=== IMPLEMENTATION ========================================================== 00058 00059 00065 class BaseImporter 00066 { 00067 public: 00068 00069 // base class needs virtual destructor 00070 virtual ~BaseImporter() {} 00071 00072 00073 // add a vertex with coordinate \c _point 00074 virtual VertexHandle add_vertex(const Vec3f& _point) = 0; 00075 00076 // add a face with indices _indices refering to vertices 00077 typedef std::vector<VertexHandle> VHandles; 00078 virtual FaceHandle add_face(const VHandles& _indices) = 0; 00079 00080 // set vertex normal 00081 virtual void set_normal(VertexHandle _vh, const Vec3f& _normal) = 0; 00082 00083 // set vertex color 00084 virtual void set_color(VertexHandle _vh, const Vec3uc& _color) = 0; 00085 00086 // set vertex texture coordinate 00087 virtual void set_texcoord(VertexHandle _vh, const Vec2f& _texcoord) = 0; 00088 00089 // set face normal 00090 virtual void set_normal(FaceHandle _fh, const Vec3f& _normal) = 0; 00091 00092 // set face color 00093 virtual void set_color(FaceHandle _fh, const Vec3uc& _color) = 0; 00094 00095 // get reference to base kernel 00096 virtual BaseKernel* kernel() { return 0; } 00097 00098 virtual bool is_triangle_mesh() const { return false; } 00099 00100 // reserve mem for elements 00101 void reserve(unsigned int nV, unsigned int nE, unsigned int nF) {} 00102 00103 // query number of faces, vertices, normals, texcoords 00104 virtual size_t n_vertices() const = 0; 00105 virtual size_t n_faces() const = 0; 00106 virtual size_t n_edges() const = 0; 00107 00108 00109 // pre-processing 00110 virtual void prepare() {} 00111 00112 // post-processing 00113 virtual void finish() {} 00114 }; 00115 00116 00117 //============================================================================= 00118 } // namespace IO 00119 } // namespace OpenMesh 00120 //============================================================================= 00121 #endif 00122 //=============================================================================