mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-24 07:03:59 -06:00
Hollowing step in SLAPrint process, PrintConfig params added.
This commit is contained in:
parent
f913be2d93
commit
bdf6f7342e
14 changed files with 311 additions and 65 deletions
|
@ -22,40 +22,38 @@ static Slic3r::TriangleMesh load_model(const std::string &obj_filename)
|
|||
return mesh;
|
||||
}
|
||||
|
||||
static Slic3r::TriangleMesh hollowed_interior(const Slic3r::TriangleMesh &mesh,
|
||||
double min_thickness)
|
||||
{
|
||||
Slic3r::sla::Contour3D imesh = Slic3r::sla::Contour3D{mesh};
|
||||
//static Slic3r::TriangleMesh hollowed_interior(const Slic3r::TriangleMesh &mesh,
|
||||
// double min_thickness)
|
||||
//{
|
||||
// Slic3r::sla::Contour3D imesh = Slic3r::sla::Contour3D{mesh};
|
||||
|
||||
double scale = std::max(1.0, 3. / min_thickness);
|
||||
double offset = scale * min_thickness;
|
||||
float range = float(std::max(2 * offset, scale));
|
||||
// double scale = std::max(1.0, 3. / min_thickness);
|
||||
// double offset = scale * min_thickness;
|
||||
// float range = float(std::max(2 * offset, scale));
|
||||
|
||||
for (auto &p : imesh.points) p *= scale;
|
||||
auto ptr = Slic3r::meshToVolume(imesh, {}, 0.1f * float(offset), range);
|
||||
// for (auto &p : imesh.points) p *= scale;
|
||||
// auto ptr = Slic3r::meshToVolume(imesh, {}, 0.1f * float(offset), range);
|
||||
|
||||
REQUIRE(ptr);
|
||||
// REQUIRE(ptr);
|
||||
|
||||
openvdb::tools::Filter<openvdb::FloatGrid>{*ptr}.gaussian(int(scale), 1);
|
||||
// openvdb::tools::Filter<openvdb::FloatGrid>{*ptr}.gaussian(int(scale), 1);
|
||||
|
||||
double iso_surface = -offset;
|
||||
double adaptivity = 0.;
|
||||
Slic3r::sla::Contour3D omesh = Slic3r::volumeToMesh(*ptr, iso_surface, adaptivity);
|
||||
// double iso_surface = -offset;
|
||||
// double adaptivity = 0.;
|
||||
// Slic3r::sla::Contour3D omesh = Slic3r::volumeToMesh(*ptr, iso_surface, adaptivity);
|
||||
|
||||
REQUIRE(!omesh.empty());
|
||||
// for (auto &p : omesh.points) p /= scale;
|
||||
|
||||
for (auto &p : omesh.points) p /= scale;
|
||||
|
||||
return to_triangle_mesh(omesh);
|
||||
}
|
||||
// return to_triangle_mesh(omesh);
|
||||
//}
|
||||
|
||||
TEST_CASE("Negative 3D offset should produce smaller object.", "[Hollowing]")
|
||||
{
|
||||
Slic3r::TriangleMesh in_mesh = load_model("20mm_cube.obj");
|
||||
Slic3r::TriangleMesh in_mesh = load_model("zaba.obj");
|
||||
Benchmark bench;
|
||||
bench.start();
|
||||
|
||||
Slic3r::TriangleMesh out_mesh = hollowed_interior(in_mesh, 2);
|
||||
Slic3r::TriangleMesh out_mesh = hollowed_interior(in_mesh, 0.5);
|
||||
|
||||
bench.stop();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue