OMReader.cc 16.7 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
2
3
/*===========================================================================*\
 *                                                                           *
 *                               OpenMesh                                    *
Jan Möbius's avatar
Jan Möbius committed
4
 *      Copyright (C) 2001-2013 by Computer Graphics Group, RWTH Aachen      *
Jan Möbius's avatar
Jan Möbius committed
5
6
 *                           www.openmesh.org                                *
 *                                                                           *
7
 *---------------------------------------------------------------------------*
8
 *  This file is part of OpenMesh.                                           *
Jan Möbius's avatar
Jan Möbius committed
9
 *                                                                           *
10
 *  OpenMesh is free software: you can redistribute it and/or modify         *
11
12
13
14
 *  it under the terms of the GNU Lesser General Public License as           *
 *  published by the Free Software Foundation, either version 3 of           *
 *  the License, or (at your option) any later version with the              *
 *  following exceptions:                                                    *
Jan Möbius's avatar
Jan Möbius committed
15
 *                                                                           *
16
17
18
19
20
21
22
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
Jan Möbius's avatar
Jan Möbius committed
23
 *                                                                           *
24
25
26
27
 *  OpenMesh is distributed in the hope that it will be useful,              *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *  GNU Lesser General Public License for more details.                      *
Jan Möbius's avatar
Jan Möbius committed
28
 *                                                                           *
29
30
31
32
 *  You should have received a copy of the GNU LesserGeneral Public          *
 *  License along with OpenMesh.  If not,                                    *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
33
\*===========================================================================*/
34
35

/*===========================================================================*\
36
 *                                                                           *
37
38
 *   $Revision$                                                         *
 *   $Date$                   *
Jan Möbius's avatar
Jan Möbius committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 *                                                                           *
\*===========================================================================*/


//== INCLUDES =================================================================


//STL
#include <fstream>

// OpenMesh
#include <OpenMesh/Core/System/config.h>
#include <OpenMesh/Core/System/omstream.hh>
#include <OpenMesh/Core/Utils/Endian.hh>
#include <OpenMesh/Core/IO/OMFormat.hh>
#include <OpenMesh/Core/IO/reader/OMReader.hh>


//=== NAMESPACES ==============================================================


namespace OpenMesh {
namespace IO {


//=== INSTANCIATE =============================================================


// register the OMReader singleton with MeshReader
_OMReader_  __OMReaderInstance;
_OMReader_&  OMReader() { return __OMReaderInstance; }



//=== IMPLEMENTATION ==========================================================


_OMReader_::_OMReader_()
{
78
  IOManager().register_module(this);
Jan Möbius's avatar
Jan Möbius committed
79
80
81
82
83
84
}


//-----------------------------------------------------------------------------


85
bool _OMReader_::read(const std::string& _filename, BaseImporter& _bi, Options& _opt)
Jan Möbius's avatar
Jan Möbius committed
86
87
{
  // check whether importer can give us an OpenMesh BaseKernel
88
89
  if (!_bi.kernel())
    return false;
Jan Möbius's avatar
Jan Möbius committed
90
91

  _opt += Options::Binary; // only binary format supported!
92
  fileOptions_ = Options::Binary;
Jan Möbius's avatar
Jan Möbius committed
93
94

  // Open file
95
96
97
  std::ifstream ifs(_filename.c_str(), std::ios::binary);
  if (!ifs.is_open() || !ifs.good()) {
    omerr() << "[OMReader] : cannot not open file " << _filename << std::endl;
Jan Möbius's avatar
Jan Möbius committed
98
99
    return false;
  }
100

Jan Möbius's avatar
Jan Möbius committed
101
102
  // Pass stream to read method, remember result
  bool result = read(ifs, _bi, _opt);
103

Jan Möbius's avatar
Jan Möbius committed
104
105
  // close input stream
  ifs.close();
106

107
108
  _opt = _opt & fileOptions_;

Jan Möbius's avatar
Jan Möbius committed
109
110
111
112
113
114
  return result;
}

//-----------------------------------------------------------------------------


115
bool _OMReader_::read(std::istream& _is, BaseImporter& _bi, Options& _opt)
Jan Möbius's avatar
Jan Möbius committed
116
{
117
  // check whether importer can give us an OpenMesh BaseKernel
118
119
  if (!_bi.kernel())
    return false;
120
121

  _opt += Options::Binary; // only binary format supported!
122
  fileOptions_ = Options::Binary;
123

124
125
  if (!_is.good()) {
    omerr() << "[OMReader] : cannot read from stream " << std::endl;
126
127
128
129
130
131
    return false;
  }

  // Pass stream to read method, remember result
  bool result = read_binary(_is, _bi, _opt);

132
133
  if (result)
    _opt += Options::Binary;
Jan Möbius's avatar
Jan Möbius committed
134

135
136
  _opt = _opt & fileOptions_;

137
  return result;
Jan Möbius's avatar
Jan Möbius committed
138
139
140
141
142
143
}



//-----------------------------------------------------------------------------

144
bool _OMReader_::read_ascii(std::istream& /* _is */, BaseImporter& /* _bi */, Options& /* _opt */) const
Jan Möbius's avatar
Jan Möbius committed
145
146
147
148
149
150
151
152
{
  // not supported yet!
  return false;
}


//-----------------------------------------------------------------------------

153
bool _OMReader_::read_binary(std::istream& _is, BaseImporter& _bi, Options& _opt) const
Jan Möbius's avatar
Jan Möbius committed
154
155
156
{
  bool swap = _opt.check(Options::Swap) || (Endian::local() == Endian::MSB);

157
  // Initialize byte counter
158
  bytes_ = 0;
Jan Möbius's avatar
Jan Möbius committed
159

160
  bytes_ += restore(_is, header_, swap);
Jan Möbius's avatar
Jan Möbius committed
161
162


163
164
  while (!_is.eof()) {
    bytes_ += restore(_is, chunk_header_, swap);
Jan Möbius's avatar
Jan Möbius committed
165

166
    if (_is.eof())
Jan Möbius's avatar
Jan Möbius committed
167
168
169
      break;

    // Is this a named property restore the name
170
    if (chunk_header_.name_) {
Jan Möbius's avatar
Jan Möbius committed
171
      OMFormat::Chunk::PropertyName pn;
172
      bytes_ += restore(_is, property_name_, swap);
Jan Möbius's avatar
Jan Möbius committed
173
174
175
176
    }

    // Read in the property data. If it is an anonymous or unknown named
    // property, then skip data.
177
    switch (chunk_header_.entity_) {
178
      case OMFormat::Chunk::Entity_Vertex:
179
180
181
        if (!read_binary_vertex_chunk(_is, _bi, _opt, swap))
          return false;
        break;
Jan Möbius's avatar
Jan Möbius committed
182
      case OMFormat::Chunk::Entity_Face:
183
184
185
        if (!read_binary_face_chunk(_is, _bi, _opt, swap))
          return false;
        break;
Jan Möbius's avatar
Jan Möbius committed
186
      case OMFormat::Chunk::Entity_Edge:
187
188
189
        if (!read_binary_edge_chunk(_is, _bi, _opt, swap))
          return false;
        break;
Jan Möbius's avatar
Jan Möbius committed
190
      case OMFormat::Chunk::Entity_Halfedge:
191
192
193
        if (!read_binary_halfedge_chunk(_is, _bi, _opt, swap))
          return false;
        break;
Jan Möbius's avatar
Jan Möbius committed
194
      case OMFormat::Chunk::Entity_Mesh:
195
196
197
        if (!read_binary_mesh_chunk(_is, _bi, _opt, swap))
          return false;
        break;
Jan Möbius's avatar
Jan Möbius committed
198
      default:
199
        return false;
Jan Möbius's avatar
Jan Möbius committed
200
    }
Jan Möbius's avatar
Jan Möbius committed
201

Jan Möbius's avatar
Jan Möbius committed
202
203
204
205
206
207
208
209
210
  }

  // File was successfully parsed.
  return true;
}


//-----------------------------------------------------------------------------

211
bool _OMReader_::can_u_read(const std::string& _filename) const
Jan Möbius's avatar
Jan Möbius committed
212
213
214
{
  // !!! Assuming BaseReader::can_u_parse( std::string& )
  // does not call BaseReader::read_magic()!!!
215
216
217
  if (this->BaseReader::can_u_read(_filename)) {
    std::ifstream ifile(_filename.c_str());
    if (ifile && can_u_read(ifile))
218
      return true;
Jan Möbius's avatar
Jan Möbius committed
219
220
221
222
223
  }
  return false;
}

//-----------------------------------------------------------------------------
224

225
bool _OMReader_::can_u_read(std::istream& _is) const
Jan Möbius's avatar
Jan Möbius committed
226
227
228
229
230
{
  std::vector<char> evt;
  evt.reserve(20);

  // read first 4 characters into a buffer
231
232
  while (evt.size() < 4)
    evt.push_back(static_cast<char>(_is.get()));
Jan Möbius's avatar
Jan Möbius committed
233

234
  // put back all read characters
Jan Möbius's avatar
Jan Möbius committed
235
  std::vector<char>::reverse_iterator it = evt.rbegin();
236
237
  while (it != evt.rend())
    _is.putback(*it++);
Jan Möbius's avatar
Jan Möbius committed
238
239

  // evaluate header information
240
  OMFormat::Header *hdr = (OMFormat::Header*) &evt[0];
Jan Möbius's avatar
Jan Möbius committed
241
242
243
244
245
246

  // first two characters must be 'OM'
  if (hdr->magic_[0] != 'O' || hdr->magic_[1] != 'M')
    return false;

  // 3rd characters defines the mesh type:
247
  switch (hdr->mesh_) {
Jan Möbius's avatar
Jan Möbius committed
248
249
250
251
252
253
254
    case 'T': // Triangle Mesh
    case 'Q': // Quad Mesh
    case 'P': // Polygonal Mesh
      break;
    default:  // ?
      return false;
  }
255

Jan Möbius's avatar
Jan Möbius committed
256
  // 4th characters encodes the version
257
  return supports(hdr->version_);
Jan Möbius's avatar
Jan Möbius committed
258
259
260
261
}

//-----------------------------------------------------------------------------

262
bool _OMReader_::supports(const OMFormat::uint8 /* version */) const
Jan Möbius's avatar
Jan Möbius committed
263
264
265
266
267
268
269
{
  return true;
}


//-----------------------------------------------------------------------------

270
bool _OMReader_::read_binary_vertex_chunk(std::istream &_is, BaseImporter &_bi, Options &_opt, bool _swap) const
Jan Möbius's avatar
Jan Möbius committed
271
272
273
{
  using OMFormat::Chunk;

274
  assert( chunk_header_.entity_ == Chunk::Entity_Vertex);
275

276
277
  OpenMesh::Vec3f v3f;
  OpenMesh::Vec2f v2f;
Jan Möbius's avatar
Jan Möbius committed
278
279
280
281
  OpenMesh::Vec3uc v3uc; // rgb

  OMFormat::Chunk::PropertyName custom_prop;

282
283
  size_t vidx = 0;
  switch (chunk_header_.type_) {
Jan Möbius's avatar
Jan Möbius committed
284
    case Chunk::Type_Pos:
285
      assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3f::dim()));
Jan Möbius's avatar
Jan Möbius committed
286

287
288
289
      for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
        bytes_ += vector_restore(_is, v3f, _swap);
        _bi.add_vertex(v3f);
Jan Möbius's avatar
Jan Möbius committed
290
291
292
293
      }
      break;

    case Chunk::Type_Normal:
294
      assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3f::dim()));
Jan Möbius's avatar
Jan Möbius committed
295

296
      fileOptions_ += Options::VertexNormal;
297
298
      for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
        bytes_ += vector_restore(_is, v3f, _swap);
299
        if (fileOptions_.vertex_has_normal() && _opt.vertex_has_normal())
300
          _bi.set_normal(VertexHandle(int(vidx)), v3f);
Jan Möbius's avatar
Jan Möbius committed
301
302
303
304
      }
      break;

    case Chunk::Type_Texcoord:
305
      assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec2f::dim()));
Jan Möbius's avatar
Jan Möbius committed
306

307
      fileOptions_ += Options::VertexTexCoord;
308
309
      for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
        bytes_ += vector_restore(_is, v2f, _swap);
310
        if (fileOptions_.vertex_has_texcoord() && _opt.vertex_has_texcoord())
311
          _bi.set_texcoord(VertexHandle(int(vidx)), v2f);
Jan Möbius's avatar
Jan Möbius committed
312
      }
313
      break;
Jan Möbius's avatar
Jan Möbius committed
314
315
316

    case Chunk::Type_Color:

317
      assert( OMFormat::dimensions(chunk_header_) == 3);
Jan Möbius's avatar
Jan Möbius committed
318

319
      fileOptions_ += Options::VertexColor;
320

321
322
      for (; vidx < header_.n_vertices_ && !_is.eof(); ++vidx) {
        bytes_ += vector_restore(_is, v3uc, _swap);
323
        if (fileOptions_.vertex_has_color() && _opt.vertex_has_color())
324
          _bi.set_color(VertexHandle(int(vidx)), v3uc);
Jan Möbius's avatar
Jan Möbius committed
325
326
327
328
      }
      break;

    case Chunk::Type_Custom:
329

330
      bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_vprop(property_name_), header_.n_vertices_, _swap);
Jan Möbius's avatar
Jan Möbius committed
331
332
333
334
335
336
337
338

      vidx = header_.n_vertices_;

      break;

    default: // skip unknown chunks
    {
      omerr() << "Unknown chunk type ignored!\n";
339
340
      size_t size_of = header_.n_vertices_ * OMFormat::vector_size(chunk_header_);
      _is.ignore(size_of);
Jan Möbius's avatar
Jan Möbius committed
341
342
343
344
345
346
347
348
349
350
351
      bytes_ += size_of;
    }
  }

  // all chunk data has been read..?!
  return vidx == header_.n_vertices_;
}


//-----------------------------------------------------------------------------

352
bool _OMReader_::read_binary_face_chunk(std::istream &_is, BaseImporter &_bi, Options &_opt, bool _swap) const
Jan Möbius's avatar
Jan Möbius committed
353
354
355
{
  using OMFormat::Chunk;

356
  assert( chunk_header_.entity_ == Chunk::Entity_Face);
Jan Möbius's avatar
Jan Möbius committed
357

358
359
  size_t fidx = 0;
  OpenMesh::Vec3f v3f;  // normal
Jan Möbius's avatar
Jan Möbius committed
360
361
  OpenMesh::Vec3uc v3uc; // rgb

362
363
364
365
366
367
368
369
370
371
372
373
374
  switch (chunk_header_.type_) {
    case Chunk::Type_Topology: {
      BaseImporter::VHandles vhandles;
      size_t nV = 0;
      size_t vidx = 0;

      switch (header_.mesh_) {
        case 'T':
          nV = 3;
          break;
        case 'Q':
          nV = 4;
          break;
Jan Möbius's avatar
Jan Möbius committed
375
      }
376

377
378
379
      for (; fidx < header_.n_faces_; ++fidx) {
        if (header_.mesh_ == 'P')
          bytes_ += restore(_is, nV, Chunk::Integer_16, _swap);
Jan Möbius's avatar
Jan Möbius committed
380

381
382
383
        vhandles.clear();
        for (size_t j = 0; j < nV; ++j) {
          bytes_ += restore(_is, vidx, Chunk::Integer_Size(chunk_header_.bits_), _swap);
Jan Möbius's avatar
Jan Möbius committed
384

385
          vhandles.push_back(VertexHandle(int(vidx)));
386
        }
Jan Möbius's avatar
Jan Möbius committed
387

388
        _bi.add_face(vhandles);
Jan Möbius's avatar
Jan Möbius committed
389
390
      }
    }
391
      break;
Jan Möbius's avatar
Jan Möbius committed
392
393

    case Chunk::Type_Normal:
394
      assert( OMFormat::dimensions(chunk_header_) == size_t(OpenMesh::Vec3f::dim()));
Jan Möbius's avatar
Jan Möbius committed
395

396
      fileOptions_ += Options::FaceNormal;
397
398
      for (; fidx < header_.n_faces_ && !_is.eof(); ++fidx) {
        bytes_ += vector_restore(_is, v3f, _swap);
399
        if( fileOptions_.face_has_normal() && _opt.face_has_normal())
400
          _bi.set_normal(FaceHandle(int(fidx)), v3f);
Jan Möbius's avatar
Jan Möbius committed
401
402
403
404
405
      }
      break;

    case Chunk::Type_Color:

406
      assert( OMFormat::dimensions(chunk_header_) == 3);
Jan Möbius's avatar
Jan Möbius committed
407

408
      fileOptions_ += Options::FaceColor;
409
410
      for (; fidx < header_.n_faces_ && !_is.eof(); ++fidx) {
        bytes_ += vector_restore(_is, v3uc, _swap);
411
        if( fileOptions_.face_has_color() && _opt.face_has_color())
412
          _bi.set_color(FaceHandle(int(fidx)), v3uc);
Jan Möbius's avatar
Jan Möbius committed
413
414
415
416
      }
      break;

    case Chunk::Type_Custom:
417

418
      bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_fprop(property_name_), header_.n_faces_, _swap);
Jan Möbius's avatar
Jan Möbius committed
419
420
421
422

      fidx = header_.n_faces_;

      break;
423

Jan Möbius's avatar
Jan Möbius committed
424
425
426
427
    default: // skip unknown chunks
    {
      omerr() << "Unknown chunk type ignore!\n";
      size_t size_of = OMFormat::chunk_data_size(header_, chunk_header_);
428
      _is.ignore(size_of);
429
      bytes_ += size_of;
Jan Möbius's avatar
Jan Möbius committed
430
431
432
433
434
435
436
437
    }
  }
  return fidx == header_.n_faces_;
}


//-----------------------------------------------------------------------------

438
bool _OMReader_::read_binary_edge_chunk(std::istream &_is, BaseImporter &_bi, Options &/*_opt */, bool _swap) const
Jan Möbius's avatar
Jan Möbius committed
439
440
441
{
  using OMFormat::Chunk;

442
  assert( chunk_header_.entity_ == Chunk::Entity_Edge);
Jan Möbius's avatar
Jan Möbius committed
443

444
  size_t b = bytes_;
Jan Möbius's avatar
Jan Möbius committed
445

446
  switch (chunk_header_.type_) {
447
    case Chunk::Type_Custom:
Jan Möbius's avatar
Jan Möbius committed
448

449
      bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_eprop(property_name_), header_.n_edges_, _swap);
Jan Möbius's avatar
Jan Möbius committed
450
451
452
453
454
455

      break;

    default:
      // skip unknown type
      size_t size_of = OMFormat::chunk_data_size(header_, chunk_header_);
456
      _is.ignore(size_of);
Jan Möbius's avatar
Jan Möbius committed
457
458
459
460
461
462
463
464
465
      bytes_ += size_of;
  }

  return b < bytes_;
}


//-----------------------------------------------------------------------------

466
bool _OMReader_::read_binary_halfedge_chunk(std::istream &_is, BaseImporter &_bi, Options &/* _opt */, bool _swap) const
Jan Möbius's avatar
Jan Möbius committed
467
468
469
{
  using OMFormat::Chunk;

470
  assert( chunk_header_.entity_ == Chunk::Entity_Halfedge);
Jan Möbius's avatar
Jan Möbius committed
471
472
473

  size_t b = bytes_;

474
  switch (chunk_header_.type_) {
Jan Möbius's avatar
Jan Möbius committed
475
476
    case Chunk::Type_Custom:

477
      bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_hprop(property_name_), 2 * header_.n_edges_, _swap);
Jan Möbius's avatar
Jan Möbius committed
478
479
480
481
482
483
      break;

    default:
      // skip unknown chunk
      omerr() << "Unknown chunk type ignored!\n";
      size_t size_of = OMFormat::chunk_data_size(header_, chunk_header_);
484
      _is.ignore(size_of);
Jan Möbius's avatar
Jan Möbius committed
485
486
487
488
489
490
491
492
493
      bytes_ += size_of;
  }

  return b < bytes_;
}


//-----------------------------------------------------------------------------

494
bool _OMReader_::read_binary_mesh_chunk(std::istream &_is, BaseImporter &_bi, Options & /* _opt */, bool _swap) const
Jan Möbius's avatar
Jan Möbius committed
495
496
497
{
  using OMFormat::Chunk;

498
  assert( chunk_header_.entity_ == Chunk::Entity_Mesh);
Jan Möbius's avatar
Jan Möbius committed
499
500
501

  size_t b = bytes_;

502
  switch (chunk_header_.type_) {
Jan Möbius's avatar
Jan Möbius committed
503
    case Chunk::Type_Custom:
504

505
      bytes_ += restore_binary_custom_data(_is, _bi.kernel()->_get_mprop(property_name_), 1, _swap);
506

Jan Möbius's avatar
Jan Möbius committed
507
508
509
510
511
      break;

    default:
      // skip unknown chunk
      size_t size_of = OMFormat::chunk_data_size(header_, chunk_header_);
512
      _is.ignore(size_of);
Jan Möbius's avatar
Jan Möbius committed
513
514
515
516
517
518
519
520
521
522
      bytes_ += size_of;
  }

  return b < bytes_;
}


//-----------------------------------------------------------------------------


523
size_t _OMReader_::restore_binary_custom_data(std::istream& _is, BaseProperty* _bp, size_t _n_elem, bool _swap) const
524
{
525
  assert( !_bp || (_bp->name() == property_name_));
Jan Möbius's avatar
Jan Möbius committed
526
527
528

  using OMFormat::Chunk;

529
530
  size_t bytes = 0;
  Chunk::esize_t block_size;
Jan Möbius's avatar
Jan Möbius committed
531
532
  Chunk::PropertyName custom_prop;

533
  bytes += restore(_is, block_size, OMFormat::Chunk::Integer_32, _swap);
Jan Möbius's avatar
Jan Möbius committed
534

535
536
  if (_bp) {
    size_t n_bytes = _bp->size_of(_n_elem);
Jan Möbius's avatar
Jan Möbius committed
537

538
539
    if (((n_bytes == BaseProperty::UnknownSize) || (n_bytes == block_size))
        && (_bp->element_size() == BaseProperty::UnknownSize || (_n_elem * _bp->element_size() == block_size))) {
Jan Möbius's avatar
Jan Möbius committed
540
#if defined(OM_DEBUG)
Jan Möbius's avatar
Jan Möbius committed
541
      size_t b;
Jan Möbius's avatar
Jan Möbius committed
542
543
      bytes += (b=_bp->restore( _is, _swap ));
#else
544
      bytes += _bp->restore(_is, _swap);
Jan Möbius's avatar
Jan Möbius committed
545
#endif
546

Jan Möbius's avatar
Jan Möbius committed
547
548
549
#if defined(OM_DEBUG)
      assert( block_size == b );
#endif
550
551

      assert( block_size == _bp->size_of());
Jan Möbius's avatar
Jan Möbius committed
552
553

      block_size = 0;
554
555
    } else {
      omerr() << "Warning! Property " << _bp->name() << " not loaded: " << "Mismatching data sizes!n";
Jan Möbius's avatar
Jan Möbius committed
556
557
558
    }
  }

559
560
561
  if (block_size) {
    _is.ignore(block_size);
    bytes += block_size;
Jan Möbius's avatar
Jan Möbius committed
562
563
564
565
566
567
568
569
570
571
572
573
  }

  return bytes;
}


//-----------------------------------------------------------------------------

//=============================================================================
} // namespace IO
} // namespace OpenMesh
//=============================================================================