Fix thin_wall detection

supermerill/SuperSlicer#1437
This commit is contained in:
remi durand 2021-07-31 19:43:42 +02:00
parent 6a964d8107
commit ff880ac348
2 changed files with 6 additions and 3 deletions

View File

@ -532,8 +532,8 @@ bool test_path(const ClipperLib::Path &path) {
ClipperLib::IntPoint centroid = ClipperLib::Centroid(path, area); ClipperLib::IntPoint centroid = ClipperLib::Centroid(path, area);
for (const ClipperLib::IntPoint& pt : path) { for (const ClipperLib::IntPoint& pt : path) {
// &0x3FFFFFFF to let (dx * dx + dy * dy) be storable into a int64 // &0x3FFFFFFF to let (dx * dx + dy * dy) be storable into a int64
ClipperLib::cInt dx = (pt.X - centroid.X) & 0x3FFFFFFF; ClipperLib::cInt dx = std::abs(pt.X - centroid.X) & 0x3FFFFFFF;
ClipperLib::cInt dy = (pt.Y - centroid.Y) & 0x3FFFFFFF; ClipperLib::cInt dy = std::abs(pt.Y - centroid.Y) & 0x3FFFFFFF;
ClipperLib::cInt dist_sqrd = (dx * dx + dy * dy); ClipperLib::cInt dist_sqrd = (dx * dx + dy * dy);
max_dist_sqrd = std::max(max_dist_sqrd, dist_sqrd); max_dist_sqrd = std::max(max_dist_sqrd, dist_sqrd);
} }

View File

@ -1606,6 +1606,8 @@ check_circular(ExPolygon& expolygon, coord_t max_variation) {
void void
MedialAxis::build(ThickPolylines &polylines_out) MedialAxis::build(ThickPolylines &polylines_out)
{ {
//static int id = 0;
//id++;
//std::cout << this->id << "\n"; //std::cout << this->id << "\n";
//{ //{
// std::stringstream stri; // std::stringstream stri;
@ -1629,11 +1631,12 @@ MedialAxis::build(ThickPolylines &polylines_out)
//check for circular shape //check for circular shape
double radius = check_circular(this->expolygon, this->min_width/4); double radius = check_circular(this->expolygon, this->min_width/4);
if (radius > 0) { if (radius > 0 && this->expolygon.contour.points.size() > 4) {
ExPolygons miniPeri = offset_ex(this->expolygon.contour, -radius / 2); ExPolygons miniPeri = offset_ex(this->expolygon.contour, -radius / 2);
if (miniPeri.size() == 1 && miniPeri[0].holes.size() == 0) { if (miniPeri.size() == 1 && miniPeri[0].holes.size() == 0) {
ThickPolyline thickPoly; ThickPolyline thickPoly;
thickPoly.points = miniPeri[0].contour.points; thickPoly.points = miniPeri[0].contour.points;
thickPoly.points.push_back(thickPoly.points.front());
thickPoly.endpoints.first = false; thickPoly.endpoints.first = false;
thickPoly.endpoints.second = false; thickPoly.endpoints.second = false;
for (int i = 0; i < thickPoly.points.size(); i++) { for (int i = 0; i < thickPoly.points.size(); i++) {