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 Lesser General Public License as published * 00013 * by the Free Software Foundation, version 2.1. * 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 * Lesser General Public License for more details. * 00019 * * 00020 * You should have received a copy of the GNU Lesser 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 a writer module for OFF files 00030 // 00031 //============================================================================= 00032 00033 00034 #ifndef __OFFWRITER_HH__ 00035 #define __OFFWRITER_HH__ 00036 00037 00038 //=== INCLUDES ================================================================ 00039 00040 00041 #include <stdio.h> 00042 #include <string> 00043 #include <fstream> 00044 00045 #include <OpenMesh/Core/System/config.h> 00046 #include <OpenMesh/Core/Utils/SingletonT.hh> 00047 #include <OpenMesh/Core/IO/exporter/BaseExporter.hh> 00048 #include <OpenMesh/Core/IO/writer/BaseWriter.hh> 00049 00050 00051 //== NAMESPACES =============================================================== 00052 00053 00054 namespace OpenMesh { 00055 namespace IO { 00056 00057 00058 //=== IMPLEMENTATION ========================================================== 00059 00060 00065 class _OFFWriter_ : public BaseWriter 00066 { 00067 public: 00068 00069 _OFFWriter_(); 00070 00071 std::string get_description() const { return "no description"; } 00072 std::string get_extensions() const { return "off"; } 00073 00074 bool write(const std::string&, BaseExporter&, Options) const; 00075 00076 size_t binary_size(BaseExporter& _be, Options _opt) const; 00077 00078 00079 protected: 00080 void writeInt(std::fstream& _out, unsigned int value) const; 00081 void writeFloat(std::fstream& _out, float value) const; 00082 00083 bool write_ascii(std::fstream& _in, BaseExporter&, Options) const; 00084 bool write_binary(std::fstream& _in, BaseExporter&, Options) const; 00085 }; 00086 00087 00088 //== TYPE DEFINITION ========================================================== 00089 00090 00092 extern _OFFWriter_ __OFFWriterInstance; 00093 _OFFWriter_& OFFWriter(); 00094 00095 00096 //============================================================================= 00097 } // namespace IO 00098 } // namespace OpenMesh 00099 //============================================================================= 00100 #endif 00101 //=============================================================================