MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / compress

Method compress

tools/Compression/Draco/DracoCompressionEngine.cpp:260–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260std::string DracoCompressionEngine::compress(Mesh::Ptr mesh) const {
261 const size_t num_faces = mesh->get_num_faces();
262
263 draco::EncoderBuffer buffer;
264 draco::Encoder encoder;
265 if (num_faces > 0) {
266 auto draco_mesh = DracoCompressionEngineHelper::to_draco_mesh(mesh);
267 const auto status = encoder.EncodeMeshToBuffer(*draco_mesh, &buffer);
268 if (!status.ok()) {
269 throw RuntimeError("Draco encoding error!");
270 }
271 return std::string(buffer.data(), buffer.size());
272 } else {
273 auto draco_mesh = DracoCompressionEngineHelper::to_draco_point_cloud(mesh);
274 const auto status = encoder.EncodePointCloudToBuffer(*draco_mesh, &buffer);
275 if (!status.ok()) {
276 throw RuntimeError("Draco encoding error!");
277 }
278 return std::string(buffer.data(), buffer.size());
279 }
280}
281
282Mesh::Ptr DracoCompressionEngine::decompress(const std::string& data) const {
283 draco::DecoderBuffer buffer;

Callers 9

init_CompressionFunction · 0.45
compressFunction · 0.45
test_simpleMethod · 0.45
test_point_cloudMethod · 0.45
test_2DMethod · 0.45
test_quadMethod · 0.45
test_empty_meshMethod · 0.45
test_attributesMethod · 0.45
TEST_FFunction · 0.45

Calls 5

to_draco_meshFunction · 0.85
RuntimeErrorClass · 0.85
to_draco_point_cloudFunction · 0.85
get_num_facesMethod · 0.45
sizeMethod · 0.45

Tested by 7

test_simpleMethod · 0.36
test_point_cloudMethod · 0.36
test_2DMethod · 0.36
test_quadMethod · 0.36
test_empty_meshMethod · 0.36
test_attributesMethod · 0.36
TEST_FFunction · 0.36