00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef __OMREADER_HH__
00035 #define __OMREADER_HH__
00036
00037
00038
00039
00040
00041 #include <OpenMesh/Core/System/config.h>
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
00049 #include <iostream>
00050 #include <string>
00051
00052
00053
00054
00055
00056 namespace OpenMesh {
00057 namespace IO {
00058
00059
00060
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 ) const;
00091 bool read_ascii(std::istream& _is, BaseImporter& _bi, Options& _opt) const;
00092 bool read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt) const;
00093
00094 typedef OMFormat::Header Header;
00095 typedef OMFormat::Chunk::Header ChunkHeader;
00096 typedef OMFormat::Chunk::PropertyName PropertyName;
00097
00098
00099 mutable size_t bytes_;
00100 mutable Header header_;
00101 mutable ChunkHeader chunk_header_;
00102 mutable PropertyName property_name_;
00103
00104 bool read_binary_vertex_chunk( std::istream &_is,
00105 BaseImporter &_bi,
00106 Options &_opt,
00107 bool _swap) const;
00108
00109 bool read_binary_face_chunk( std::istream &_is,
00110 BaseImporter &_bi,
00111 Options &_opt,
00112 bool _swap) const;
00113
00114 bool read_binary_edge_chunk( std::istream &_is,
00115 BaseImporter &_bi,
00116 Options &_opt,
00117 bool _swap) const;
00118
00119 bool read_binary_halfedge_chunk( std::istream &_is,
00120 BaseImporter &_bi,
00121 Options &_opt,
00122 bool _swap) const;
00123
00124 bool read_binary_mesh_chunk( std::istream &_is,
00125 BaseImporter &_bi,
00126 Options &_opt,
00127 bool _swap) const;
00128
00129 size_t restore_binary_custom_data( std::istream& _is,
00130 BaseProperty* _bp,
00131 size_t _n_elem,
00132 bool _swap) const;
00133
00134 };
00135
00136
00137
00138
00139
00141 extern _OMReader_ __OMReaderInstance;
00142 _OMReader_& OMReader();
00143
00144
00145
00146 }
00147 }
00148
00149 #endif
00150