00001 /*===========================================================================*\ 00002 * * 00003 * OpenMesh * 00004 * Copyright (C) 2003 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 #ifndef OM_MESHIO_HH 00028 #define OM_MESHIO_HH 00029 00030 00031 //=== INCLUDES ================================================================ 00032 00033 // -------------------- system settings 00034 #include <OpenMesh/Core/System/config.h> 00035 // -------------------- check include order 00036 #if defined (OPENMESH_TRIMESH_ARRAY_KERNEL_HH) || \ 00037 defined (OPENMESH_POLYMESH_ARRAY_KERNEL_HH) 00038 # error "Include MeshIO.hh before including a mesh type!" 00039 #endif 00040 // -------------------- OpenMesh 00041 #include <OpenMesh/Core/IO/SR_store.hh> 00042 #include <OpenMesh/Core/IO/IOManager.hh> 00043 #include <OpenMesh/Core/IO/importer/ImporterT.hh> 00044 #include <OpenMesh/Core/IO/exporter/ExporterT.hh> 00045 00046 00047 //== NAMESPACES ============================================================== 00048 00049 namespace OpenMesh { 00050 namespace IO { 00051 00052 00053 //=== IMPLEMENTATION ========================================================== 00054 00055 00061 00062 00063 //----------------------------------------------------------------------------- 00064 00065 00068 template <class Mesh> 00069 bool read_mesh(Mesh& _mesh, const std::string& _filename) 00070 { 00071 Options opt; 00072 return read_mesh(_mesh, _filename, opt); 00073 } 00074 00075 00078 template <class Mesh> 00079 bool read_mesh(Mesh& _mesh, const std::string& _filename, Options& _opt) 00080 { 00081 _mesh.clear(); 00082 ImporterT<Mesh> importer(_mesh); 00083 return IOManager::Instance().read(_filename, importer, _opt); 00084 } 00085 00086 00087 //----------------------------------------------------------------------------- 00088 00089 00092 template <class Mesh> 00093 bool write_mesh(const Mesh& _mesh, const std::string& _filename, 00094 Options _opt = Options::Default) 00095 { 00096 ExporterT<Mesh> exporter(_mesh); 00097 return IOManager::Instance().write(_filename, exporter, _opt); 00098 } 00099 00100 00101 //----------------------------------------------------------------------------- 00102 00103 00104 template <class Mesh> 00105 size_t binary_size(const Mesh& _mesh, const std::string& _format, 00106 Options _opt = Options::Default) 00107 { 00108 ExporterT<Mesh> exporter(_mesh); 00109 return IOManager::Instance().binary_size(_format, exporter, _opt); 00110 } 00111 00112 00113 //----------------------------------------------------------------------------- 00114 00116 00117 00118 //============================================================================= 00119 } // namespace IO 00120 } // namespace OpenMesh 00121 //============================================================================= 00122 #if defined(OM_STATIC_BUILD) 00123 # include <OpenMesh/Core/IO/IOInstances.hh> 00124 #endif 00125 //============================================================================= 00126 #endif 00127 //=============================================================================