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

Method decompress

tools/Compression/Draco/DracoCompressionEngine.cpp:282–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282Mesh::Ptr DracoCompressionEngine::decompress(const std::string& data) const {
283 draco::DecoderBuffer buffer;
284 buffer.Init(data.c_str(), data.size());
285 auto type_statusor = draco::Decoder::GetEncodedGeometryType(&buffer);
286 if (!type_statusor.ok()) {
287 throw RuntimeError("Failed to decode Draco buffer.");
288 }
289
290 draco::Decoder decoder;
291 draco::Mesh* draco_mesh = nullptr;
292 const draco::EncodedGeometryType geom_type = type_statusor.value();
293 if (geom_type == draco::TRIANGULAR_MESH) {
294 auto statusor = decoder.DecodeMeshFromBuffer(&buffer);
295 if (!statusor.ok()) {
296 throw RuntimeError("Draco decoding from triangle mesh failed.");
297 }
298 std::unique_ptr<draco::Mesh> in_mesh = std::move(statusor).value();
299 if (!in_mesh) {
300 throw RuntimeError("Draco decoding from triangle mesh failed.");
301 }
302 return DracoCompressionEngineHelper::from_draco_mesh(std::move(in_mesh));
303 } else if (geom_type == draco::POINT_CLOUD) {
304 auto statusor = decoder.DecodePointCloudFromBuffer(&buffer);
305 if (!statusor.ok()) {
306 throw RuntimeError("Draco decoding from point cloud failed.");
307 }
308 std::unique_ptr<draco::PointCloud> in_mesh = std::move(statusor).value();
309 if (!in_mesh) {
310 throw RuntimeError("Draco decoding from point cloud failed.");
311 }
312 return DracoCompressionEngineHelper::from_draco_point_cloud(std::move(in_mesh));
313 } else {
314 throw NotImplementedError("Unsupported Draco mesh type.");
315 }
316}
317
318#endif

Callers 7

decompressFunction · 0.45
test_simpleMethod · 0.45
test_point_cloudMethod · 0.45
test_2DMethod · 0.45
test_empty_meshMethod · 0.45
test_attributesMethod · 0.45
TEST_FFunction · 0.45

Calls 7

RuntimeErrorClass · 0.85
from_draco_meshFunction · 0.85
from_draco_point_cloudFunction · 0.85
NotImplementedErrorClass · 0.85
InitMethod · 0.45
sizeMethod · 0.45
valueMethod · 0.45

Tested by 6

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