Hotfix for hollowing issues
This commit is contained in:
parent
7e74f781c6
commit
7d6c2cad0a
@ -37,7 +37,11 @@ inline void perform_csg(CSGType op, VoxelGridPtr &dst, VoxelGridPtr &src)
|
||||
|
||||
switch (op) {
|
||||
case CSGType::Union:
|
||||
if (is_grid_empty(*dst) && !is_grid_empty(*src))
|
||||
dst = clone(*src);
|
||||
else
|
||||
grid_union(*dst, *src);
|
||||
|
||||
break;
|
||||
case CSGType::Difference:
|
||||
grid_difference(*dst, *src);
|
||||
|
@ -300,4 +300,9 @@ void rescale_grid(VoxelGrid &grid, float scale)
|
||||
// grid.grid.setTransform(tr);
|
||||
}
|
||||
|
||||
bool is_grid_empty(const VoxelGrid &grid)
|
||||
{
|
||||
return grid.grid.empty();
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
@ -77,6 +77,8 @@ void grid_union(VoxelGrid &grid, VoxelGrid &arg);
|
||||
void grid_difference(VoxelGrid &grid, VoxelGrid &arg);
|
||||
void grid_intersection(VoxelGrid &grid, VoxelGrid &arg);
|
||||
|
||||
bool is_grid_empty(const VoxelGrid &grid);
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // OPENVDBUTILS_HPP
|
||||
|
@ -75,11 +75,12 @@ InteriorPtr generate_interior(const VoxelGrid &vgrid,
|
||||
const HollowingConfig &hc,
|
||||
const JobController &ctl)
|
||||
{
|
||||
double offset = hc.min_thickness;
|
||||
double D = hc.closing_distance;
|
||||
float in_range = 1.1f * float(offset + D);
|
||||
auto narrowb = 3.f / get_voxel_scale(vgrid);
|
||||
float out_range = narrowb;
|
||||
double voxsc = get_voxel_scale(vgrid);
|
||||
double offset = hc.min_thickness; // world units
|
||||
double D = hc.closing_distance; // world units
|
||||
float in_range = 1.1f * float(offset + D); // world units
|
||||
float out_range = 1.f / voxsc; // world units
|
||||
auto narrowb = 1.f; // voxel units (voxel count)
|
||||
|
||||
if (ctl.stopcondition()) return {};
|
||||
else ctl.statuscb(0, L("Hollowing"));
|
||||
@ -91,12 +92,12 @@ InteriorPtr generate_interior(const VoxelGrid &vgrid,
|
||||
|
||||
double iso_surface = D;
|
||||
if (D > EPSILON) {
|
||||
in_range = narrowb;
|
||||
gridptr = redistance_grid(*gridptr, -(offset + D), narrowb, in_range);
|
||||
gridptr = redistance_grid(*gridptr, -(offset + D), narrowb, narrowb);
|
||||
|
||||
gridptr = dilate_grid(*gridptr, std::ceil(iso_surface), 0.f);
|
||||
gridptr = dilate_grid(*gridptr, 1.1 * std::ceil(iso_surface), 0.f);
|
||||
|
||||
out_range = iso_surface;
|
||||
in_range = narrowb / voxsc;
|
||||
} else {
|
||||
iso_surface = -offset;
|
||||
}
|
||||
|
@ -91,15 +91,15 @@ inline InteriorPtr generate_interior(const indexed_triangle_set &mesh,
|
||||
auto statusfn = [&ctl](int){ return ctl.stopcondition && ctl.stopcondition(); };
|
||||
auto grid = mesh_to_grid(mesh, MeshToGridParams{}
|
||||
.voxel_scale(voxel_scale)
|
||||
.exterior_bandwidth(1.f)
|
||||
.interior_bandwidth(1.f)
|
||||
.exterior_bandwidth(3.f)
|
||||
.interior_bandwidth(3.f)
|
||||
.statusfn(statusfn));
|
||||
|
||||
if (!grid || (ctl.stopcondition && ctl.stopcondition()))
|
||||
return {};
|
||||
|
||||
if (its_is_splittable(mesh))
|
||||
grid = redistance_grid(*grid, 0.0f, 6.f / voxel_scale, 6.f / voxel_scale);
|
||||
// if (its_is_splittable(mesh))
|
||||
grid = redistance_grid(*grid, 0.0f, 3.f, 3.f);
|
||||
|
||||
return grid ? generate_interior(*grid, hc, ctl) : InteriorPtr{};
|
||||
}
|
||||
@ -132,11 +132,12 @@ InteriorPtr generate_interior(const Range<It> &csgparts,
|
||||
const JobController &ctl = {})
|
||||
{
|
||||
double mesh_vol = csgmesh_positive_maxvolume(csgparts);
|
||||
double voxsc = get_voxel_scale(mesh_vol, hc);
|
||||
|
||||
auto params = csg::VoxelizeParams{}
|
||||
.voxel_scale(get_voxel_scale(mesh_vol, hc))
|
||||
.exterior_bandwidth(1.f)
|
||||
.interior_bandwidth(1.f)
|
||||
.voxel_scale(voxsc)
|
||||
.exterior_bandwidth(3.f)
|
||||
.interior_bandwidth(3.f)
|
||||
.statusfn([&ctl](int){ return ctl.stopcondition && ctl.stopcondition(); });
|
||||
|
||||
auto ptr = csg::voxelize_csgmesh(csgparts, params);
|
||||
@ -144,11 +145,10 @@ InteriorPtr generate_interior(const Range<It> &csgparts,
|
||||
if (!ptr || (ctl.stopcondition && ctl.stopcondition()))
|
||||
return {};
|
||||
|
||||
if (csgparts.size() > 1 || its_is_splittable(*csg::get_mesh(*csgparts.begin())))
|
||||
ptr = redistance_grid(*ptr,
|
||||
0.0f,
|
||||
6.f / params.voxel_scale(),
|
||||
6.f / params.voxel_scale());
|
||||
// TODO: figure out issues without the redistance
|
||||
// if (csgparts.size() > 1 || its_is_splittable(*csg::get_mesh(*csgparts.begin())))
|
||||
|
||||
ptr = redistance_grid(*ptr, 0.0f, 3.f, 3.f);
|
||||
|
||||
return ptr ? generate_interior(*ptr, hc, ctl) : InteriorPtr{};
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
// #define SLAPRINT_DO_BENCHMARK
|
||||
#define SLAPRINT_DO_BENCHMARK
|
||||
|
||||
#ifdef SLAPRINT_DO_BENCHMARK
|
||||
#include <libnest2d/tools/benchmark.h>
|
||||
|
Loading…
Reference in New Issue
Block a user