40 std::ifstream
file(filename, std::ios::binary);
44 <<
" " << filename <<
" " 45 <<
"could not be read!" << std::endl;
49 std::streampos file_size = 0;
50 file.seekg(0, std::ios::end);
51 file_size = file.tellg() - file_size;
52 file.seekg(0, std::ios::beg);
53 std::vector<char> data(file_size);
54 file.read(data.data(), file_size);
59 <<
" " << filename <<
" " 60 <<
"is empty!" << std::endl;
64 draco::DecoderBuffer buffer;
65 buffer.Init(data.data(), data.size());
67 auto type = draco::Decoder::GetEncodedGeometryType(&buffer);
71 std::cerr <<
"Content in" 72 <<
" " << filename <<
" " 73 <<
"is neither a Mesh nor a PointCloud!" << std::endl;
77 const draco::EncodedGeometryType geom_type = type.value();
90 std::cerr <<
"no model set for export!" << std::endl;
96 std::cerr <<
"model does not contain geometry data!" << std::endl;
101 std::unique_ptr<draco::EncoderBuffer> buffer =
103 : draco::EncodedGeometryType::TRIANGULAR_MESH));
107 std::ofstream
file(filename, std::ios::binary);
110 file.write(buffer->data(), buffer->size());
Decodes a draco comptressed file into a lvr model.
virtual void save(string filename)
Save/Compress the loaded elements to a draco file.
IO module for importing and exporting .drc files.
ModelPtr decodeDraco(draco::DecoderBuffer &buffer, draco::EncodedGeometryType type)
delivers ModelPtr from draco DecoderBuffer
std::unique_ptr< draco::EncoderBuffer > encodeDraco(ModelPtr modelPtr, draco::EncodedGeometryType type)
encodes Model to draco EncodeBuffer which contents can be written into a file
std::shared_ptr< Model > ModelPtr
virtual ModelPtr read(string filename)
Parse the draco and load supported elements.
Encodes a lvr model into a draco compressed file.