Files
OrcaSlicer/src/slic3r/plugin/host/PluginHostMesh.hpp
T
SoftFever c17d9732be refactor(plugin): bind raw TriangleMesh instead of HostTriangleMesh wrapper
Bind libslic3r's TriangleMesh directly with a shared_ptr holder rather than
wrapping it in a HostTriangleMesh snapshot struct. ModelVolume.mesh() hands
out the volume's own shared_ptr (via const_pointer_cast, which only serves
the holder type), so the Python object pins the snapshot exactly as the
wrapper did, and the zero-copy views now use the Python object as their
array base — deleting the capsule machinery.

The wrapper's type-level constness becomes a documented rule instead:
handed-out meshes are copy-on-write snapshots shared across threads, so the
binding exposes only const methods; a future mutable-mesh API must operate
on plugin-owned copies handed back via ModelVolume::set_mesh.

No Python-visible change (orca.host.TriangleMesh, same methods/docstrings),
and plugins now hold the real class a future set_mesh() will accept.
Verified with slic3rutils and fff_print suites.
2026-07-11 18:54:07 +08:00

19 lines
560 B
C++

#pragma once
#include <libslic3r/BoundingBox.hpp>
#include <libslic3r/TriangleMesh.hpp>
namespace Slic3r {
// Build a BoundingBoxf3 from precomputed (float) triangle-mesh stats min/max.
// Shared by the TriangleMesh binding (PluginHostMesh.cpp) and the mesh-derived
// ModelVolume accessors (PluginHostModel.cpp).
inline BoundingBoxf3 bbox_from_stats(const TriangleMeshStats& stats)
{
if (stats.number_of_facets == 0)
return BoundingBoxf3();
return BoundingBoxf3(stats.min.cast<double>(), stats.max.cast<double>());
}
} // namespace Slic3r