58 #include <OpenMesh/Core/IO/OMFormat.hh> 68 Chunk::Integer_Size needed_bits(
size_t s )
70 if (s <= 0x000100)
return Chunk::Integer_8;
71 if (s <= 0x010000)
return Chunk::Integer_16;
76 if ( (
sizeof(
size_t ) == 8) && (s >= 0x100000000) )
77 return Chunk::Integer_64;
80 return Chunk::Integer_32;
89 val |= hdr.name_ << OMFormat::Chunk::OFF_NAME;
90 val |= hdr.entity_ << OMFormat::Chunk::OFF_ENTITY;
91 val |= hdr.type_ << OMFormat::Chunk::OFF_TYPE;
92 val |= hdr.signed_ << OMFormat::Chunk::OFF_SIGNED;
93 val |= hdr.float_ << OMFormat::Chunk::OFF_FLOAT;
94 val |= hdr.dim_ << OMFormat::Chunk::OFF_DIM;
95 val |= hdr.bits_ << OMFormat::Chunk::OFF_BITS;
106 hdr.name_ = val >> OMFormat::Chunk::OFF_NAME;
107 hdr.entity_ = val >> OMFormat::Chunk::OFF_ENTITY;
108 hdr.type_ = val >> OMFormat::Chunk::OFF_TYPE;
109 hdr.signed_ = val >> OMFormat::Chunk::OFF_SIGNED;
110 hdr.float_ = val >> OMFormat::Chunk::OFF_FLOAT;
111 hdr.dim_ = val >> OMFormat::Chunk::OFF_DIM;
112 hdr.bits_ = val >> OMFormat::Chunk::OFF_BITS;
118 const char *as_string(Chunk::Entity e)
122 case Chunk::Entity_Vertex:
return "Vertex";
123 case Chunk::Entity_Mesh:
return "Mesh";
124 case Chunk::Entity_Edge:
return "Edge";
125 case Chunk::Entity_Halfedge:
return "Halfedge";
126 case Chunk::Entity_Face:
return "Face";
128 std::clog <<
"as_string(Chunk::Entity): Invalid value!";
136 const char *as_string(Chunk::Type t)
140 case Chunk::Type_Pos:
return "Pos";
141 case Chunk::Type_Normal:
return "Normal";
142 case Chunk::Type_Texcoord:
return "Texcoord";
143 case Chunk::Type_Status:
return "Status";
144 case Chunk::Type_Color:
return "Color";
145 case Chunk::Type_Custom:
return "Custom";
146 case Chunk::Type_Topology:
return "Topology";
154 const char *as_string(Chunk::Dim d)
158 case Chunk::Dim_1D:
return "1D";
159 case Chunk::Dim_2D:
return "2D";
160 case Chunk::Dim_3D:
return "3D";
161 case Chunk::Dim_4D:
return "4D";
162 case Chunk::Dim_5D:
return "5D";
163 case Chunk::Dim_6D:
return "6D";
164 case Chunk::Dim_7D:
return "7D";
165 case Chunk::Dim_8D:
return "8D";
173 const char *as_string(Chunk::Integer_Size d)
177 case Chunk::Integer_8 :
return "8";
178 case Chunk::Integer_16 :
return "16";
179 case Chunk::Integer_32 :
return "32";
180 case Chunk::Integer_64 :
return "64";
185 const char *as_string(Chunk::Float_Size d)
189 case Chunk::Float_32 :
return "32";
190 case Chunk::Float_64 :
return "64";
191 case Chunk::Float_128:
return "128";
199 std::ostream&
operator << ( std::ostream& _os,
const Chunk::Header& _c )
201 _os <<
"Chunk Header : 0x" << std::setw(4)
202 << std::hex << (*(uint16*)(&_c)) << std::dec <<
'\n';
204 << as_string(Chunk::Entity(_c.entity_)) <<
'\n';
206 << as_string(Chunk::Type(_c.type_));
207 if ( Chunk::Type(_c.type_)!=Chunk::Type_Custom)
211 << _c.signed_ <<
'\n';
213 << _c.float_ <<
'\n';
215 << as_string(Chunk::Dim(_c.dim_)) <<
'\n';
218 ? as_string(Chunk::Float_Size(_c.bits_))
219 : as_string(Chunk::Integer_Size(_c.bits_)));
227 std::ostream&
operator << ( std::ostream& _os,
const Header& _h )
229 _os <<
"magic = '" << _h.magic_[0] << _h.magic_[1] <<
"'\n" 230 <<
"mesh = '" << _h.mesh_ <<
"'\n" 231 <<
"version = 0x" << std::hex << (uint16)_h.version_ << std::dec
232 <<
" (" << major_version(_h.version_)
233 <<
"." << minor_version(_h.version_) <<
")\n" 234 <<
"#V = " << _h.n_vertices_ <<
'\n' 235 <<
"#F = " << _h.n_faces_ <<
'\n' 236 <<
"#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