53 #include <OpenMesh/Core/IO/OMFormat.hh> 63 Chunk::Integer_Size needed_bits(
size_t s )
65 if (s <= 0x000100)
return Chunk::Integer_8;
66 if (s <= 0x010000)
return Chunk::Integer_16;
71 if ( (
sizeof(
size_t ) == 8) && (s >= 0x100000000) )
72 return Chunk::Integer_64;
75 return Chunk::Integer_32;
84 val |= hdr.name_ << OMFormat::Chunk::OFF_NAME;
85 val |= hdr.entity_ << OMFormat::Chunk::OFF_ENTITY;
86 val |= hdr.type_ << OMFormat::Chunk::OFF_TYPE;
87 val |= hdr.signed_ << OMFormat::Chunk::OFF_SIGNED;
88 val |= hdr.float_ << OMFormat::Chunk::OFF_FLOAT;
89 val |= hdr.dim_ << OMFormat::Chunk::OFF_DIM;
90 val |= hdr.bits_ << OMFormat::Chunk::OFF_BITS;
101 hdr.name_ = val >> OMFormat::Chunk::OFF_NAME;
102 hdr.entity_ = val >> OMFormat::Chunk::OFF_ENTITY;
103 hdr.type_ = val >> OMFormat::Chunk::OFF_TYPE;
104 hdr.signed_ = val >> OMFormat::Chunk::OFF_SIGNED;
105 hdr.float_ = val >> OMFormat::Chunk::OFF_FLOAT;
106 hdr.dim_ = val >> OMFormat::Chunk::OFF_DIM;
107 hdr.bits_ = val >> OMFormat::Chunk::OFF_BITS;
114 std::string as_string(uint8 version)
116 std::stringstream ss;
117 ss << major_version(version);
119 ss << minor_version(version);
126 const char *as_string(Chunk::Entity e)
130 case Chunk::Entity_Vertex:
return "Vertex";
131 case Chunk::Entity_Mesh:
return "Mesh";
132 case Chunk::Entity_Edge:
return "Edge";
133 case Chunk::Entity_Halfedge:
return "Halfedge";
134 case Chunk::Entity_Face:
return "Face";
136 std::clog <<
"as_string(Chunk::Entity): Invalid value!";
144 const char *as_string(Chunk::Type t)
148 case Chunk::Type_Pos:
return "Pos";
149 case Chunk::Type_Normal:
return "Normal";
150 case Chunk::Type_Texcoord:
return "Texcoord";
151 case Chunk::Type_Status:
return "Status";
152 case Chunk::Type_Color:
return "Color";
153 case Chunk::Type_Custom:
return "Custom";
154 case Chunk::Type_Topology:
return "Topology";
162 const char *as_string(Chunk::Dim d)
166 case Chunk::Dim_1D:
return "1D";
167 case Chunk::Dim_2D:
return "2D";
168 case Chunk::Dim_3D:
return "3D";
169 case Chunk::Dim_4D:
return "4D";
170 case Chunk::Dim_5D:
return "5D";
171 case Chunk::Dim_6D:
return "6D";
172 case Chunk::Dim_7D:
return "7D";
173 case Chunk::Dim_8D:
return "8D";
181 const char *as_string(Chunk::Integer_Size d)
185 case Chunk::Integer_8 :
return "8";
186 case Chunk::Integer_16 :
return "16";
187 case Chunk::Integer_32 :
return "32";
188 case Chunk::Integer_64 :
return "64";
193 const char *as_string(Chunk::Float_Size d)
197 case Chunk::Float_32 :
return "32";
198 case Chunk::Float_64 :
return "64";
199 case Chunk::Float_128:
return "128";
207 std::ostream&
operator << ( std::ostream& _os,
const Chunk::Header& _c )
209 _os <<
"Chunk Header : 0x" << std::setw(4)
210 << std::hex << (*(uint16*)(&_c)) << std::dec <<
'\n';
212 << as_string(Chunk::Entity(_c.entity_)) <<
'\n';
214 << as_string(Chunk::Type(_c.type_));
215 if ( Chunk::Type(_c.type_)!=Chunk::Type_Custom)
219 << _c.signed_ <<
'\n';
221 << _c.float_ <<
'\n';
223 << as_string(Chunk::Dim(_c.dim_)) <<
'\n';
226 ? as_string(Chunk::Float_Size(_c.bits_))
227 : as_string(Chunk::Integer_Size(_c.bits_)));
235 std::ostream&
operator << ( std::ostream& _os,
const Header& _h )
237 _os <<
"magic = '" << _h.magic_[0] << _h.magic_[1] <<
"'\n" 238 <<
"mesh = '" << _h.mesh_ <<
"'\n" 239 <<
"version = 0x" << std::hex << (uint16)_h.version_ << std::dec
240 <<
" (" << major_version(_h.version_)
241 <<
"." << minor_version(_h.version_) <<
")\n" 242 <<
"#V = " << _h.n_vertices_ <<
'\n' 243 <<
"#F = " << _h.n_faces_ <<
'\n' 244 <<
"#E = " << _h.n_edges_;
auto operator<<(std::ostream &os, const VectorT< Scalar, DIM > &_vec) -> typename std::enable_if< sizeof(decltype(os<< _vec[0])) >=0
output a vector by printing its space-separated compontens