Marked the unsafe ClipperUtils offset functions with CLIPPERUTILS_UNSAFE_OFFSET

Replaced some of the unsafe offset functions with safe variants.
Please test the
1) print bed from STL function
2) concentric infill
This commit is contained in:
Vojtech Bubnik 2021-04-13 13:28:21 +02:00
parent 2791139002
commit c1179fc2c7
8 changed files with 55 additions and 16 deletions

View file

@ -511,20 +511,22 @@ void TriangleMesh::merge(const TriangleMesh &mesh)
//FIXME This could be extremely slow! Use it for tiny meshes only!
ExPolygons TriangleMesh::horizontal_projection() const
{
Polygons pp;
pp.reserve(this->stl.stats.number_of_facets);
ClipperLib::Paths paths;
Polygon p;
p.points.assign(3, Point());
auto delta = scaled<float>(0.01);
std::vector<float> deltas { delta, delta, delta };
paths.reserve(this->stl.stats.number_of_facets);
for (const stl_facet &facet : this->stl.facet_start) {
Polygon p;
p.points.resize(3);
p.points[0] = Point::new_scale(facet.vertex[0](0), facet.vertex[0](1));
p.points[1] = Point::new_scale(facet.vertex[1](0), facet.vertex[1](1));
p.points[2] = Point::new_scale(facet.vertex[2](0), facet.vertex[2](1));
p.make_counter_clockwise(); // do this after scaling, as winding order might change while doing that
pp.emplace_back(p);
p.make_counter_clockwise();
paths.emplace_back(mittered_offset_path_scaled(p.points, deltas, 3.));
}
// the offset factor was tuned using groovemount.stl
return union_ex(offset(pp, scale_(0.01)), true);
return ClipperPaths_to_Slic3rExPolygons(paths);
}
// 2D convex hull of a 3D mesh projected into the Z=0 plane.
@ -1797,7 +1799,7 @@ void TriangleMeshSlicer::make_expolygons(const Polygons &loops, const float clos
// append to the supplied collection
if (safety_offset > 0)
expolygons_append(*slices, offset2_ex(union_(loops, false), +safety_offset, -safety_offset));
expolygons_append(*slices, offset2_ex(union_ex(loops, false), +safety_offset, -safety_offset));
else
expolygons_append(*slices, union_ex(loops, false));
}