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 __OFFREADER_HH__
00035 #define __OFFREADER_HH__
00036
00037
00038
00039
00040
00041 #include <iostream>
00042 #include <string>
00043 #include <stdio.h>
00044 #include <fstream>
00045
00046 #include <OpenMesh/Core/System/config.h>
00047 #include <OpenMesh/Core/Utils/SingletonT.hh>
00048 #include <OpenMesh/Core/IO/reader/BaseReader.hh>
00049
00050 #ifndef WIN32
00051 #include <string.h>
00052 #endif
00053
00054
00055
00056
00057 namespace OpenMesh {
00058 namespace IO {
00059
00060
00061
00062
00063
00064 class BaseImporter;
00065
00066
00067
00068
00069
00074 class _OFFReader_ : public BaseReader
00075 {
00076 public:
00077
00078 _OFFReader_();
00079
00080 std::string get_description() const { return "Object File Format"; }
00081 std::string get_extensions() const { return "off"; }
00082 std::string get_magic() const { return "OFF"; }
00083
00084 bool read(const std::string& _filename,
00085 BaseImporter& _bi,
00086 Options& _opt);
00087
00088 bool can_u_read(const std::string& _filename) const;
00089
00090
00091
00092 private:
00093
00094 bool can_u_read(std::istream& _is) const;
00095
00096 bool read(std::fstream& _in, BaseImporter& _bi, Options& _opt ) const;
00097 bool read_ascii(std::fstream& _in, BaseImporter& _bi) const;
00098 bool read_binary(std::fstream& _in, BaseImporter& _bi, bool swap) const;
00099
00100 unsigned int getInt(std::fstream& _in) const;
00101 float getFloat(std::fstream& _in) const;
00102
00104 mutable struct {
00105 unsigned vertex_dim:8;
00106 unsigned vertex_has_normal:1;
00107 unsigned vertex_has_color:1;
00108 unsigned vertex_has_texcoord:1;
00109 unsigned vertex_has_hcoord:1;
00110 unsigned is_binary:1;
00111 } options_;
00112 };
00113
00114
00115
00116
00117
00119 extern _OFFReader_ __OFFReaderInstance;
00120 _OFFReader_& OFFReader();
00121
00122
00123
00124 }
00125 }
00126
00127 #endif
00128