- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# Core/IO/reader/OMReader.hh

    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 a reader module for OFF files
    00030 //
    00031 //=============================================================================
    00032
    00033
    00034 #ifndef __OMREADER_HH__
    00035 #define __OMREADER_HH__
    00036
    00037
    00038 //=== INCLUDES ================================================================
    00039
    00040 // OpenMesh
    00041 #include <OpenMesh/Core/System/config.hh>
    00042 #include <OpenMesh/Core/Utils/SingletonT.hh>
    00043 #include <OpenMesh/Core/IO/OMFormat.hh>
    00044 #include <OpenMesh/Core/IO/IOManager.hh>
    00045 #include <OpenMesh/Core/IO/importer/BaseImporter.hh>
    00046 #include <OpenMesh/Core/IO/reader/BaseReader.hh>
    00047
    00048 // STD C++
    00049 #include <iostream>
    00050 #include <string>
    00051
    00052
    00053 //== NAMESPACES ===============================================================
    00054
    00055
    00056 namespace OpenMesh {
    00057 namespace IO {
    00058
    00059
    00060 //== IMPLEMENTATION ===========================================================
    00061
    00062
    00067 class _OMReader_ : public BaseReader
    00068 {
    00069 public:
    00070
    00071   _OMReader_();
    00072   virtual ~_OMReader_() { }
    00073
    00074   std::string get_description() const { return "OpenMesh File Format"; }
    00075   std::string get_extensions()  const { return "om"; }
    00076   std::string get_magic()       const { return "OM"; }
    00077
    00078   bool read(const std::string& _filename,
    00079             BaseImporter& _bi,
    00080             Options& _opt );
    00081
    00082   virtual bool can_u_read(const std::string& _filename) const;
    00083   virtual bool can_u_read(std::istream& _is) const;
    00084
    00085
    00086 private:
    00087
    00088   bool supports( const OMFormat::uint8 version ) const;
    00089
    00090   bool read(std::istream& _is, BaseImporter& _bi, Options& _opt );
    00091   bool read_ascii(std::istream& _is, BaseImporter& _bi, Options& _opt);
    00092   bool read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt);
    00093
    00094   typedef OMFormat::Header              Header;
    00095   typedef OMFormat::Chunk::Header       ChunkHeader;
    00096   typedef OMFormat::Chunk::PropertyName PropertyName;
    00097
    00098   // initialized/updated by read_binary*/read_ascii*
    00099   size_t                  bytes_;
    00100   Header                  header_;
    00101   ChunkHeader             chunk_header_;
    00102   PropertyName            property_name_;
    00103   BaseImporter::VHandles  vhandles_;
    00104
    00105
    00106   bool read_binary_vertex_chunk(   std::istream      &_is,
    00107                                    BaseImporter      &_bi,
    00108                                    Options           &_opt,
    00109                                    bool              _swap);
    00110
    00111   bool read_binary_face_chunk(     std::istream      &_is,
    00112                                    BaseImporter      &_bi,
    00113                                    Options           &_opt,
    00114                                    bool              _swap);
    00115
    00116   bool read_binary_edge_chunk(     std::istream      &_is,
    00117                                    BaseImporter      &_bi,
    00118                                    Options           &_opt,
    00119                                    bool              _swap);
    00120
    00121   bool read_binary_halfedge_chunk( std::istream      &_is,
    00122                                    BaseImporter      &_bi,
    00123                                    Options           &_opt,
    00124                                    bool              _swap);
    00125
    00126   bool read_binary_mesh_chunk(     std::istream      &_is,
    00127                                    BaseImporter      &_bi,
    00128                                    Options           &_opt,
    00129                                    bool              _swap);
    00130
    00131   size_t restore_binary_custom_data( std::istream& _is,
    00132                                      BaseProperty* _bp,
    00133                                      size_t _n_elem,
    00134                                      bool _swap);
    00135
    00136 };
    00137
    00138
    00139 //== TYPE DEFINITION ==========================================================
    00140
    00141
    00143 extern _OMReader_  __OMReaderInstance;
    00144 _OMReader_&  OMReader();
    00145
    00146
    00147 //=============================================================================
    00148 } // namespace IO
    00149 } // namespace OpenMesh
    00150 //=============================================================================
    00151 #endif
    00152 //=============================================================================