From f4dec2ece6cb7b3fe2eedaa644d9d2389e2566ea Mon Sep 17 00:00:00 2001 From: kreso-t Date: Fri, 7 Sep 2018 19:09:53 +0200 Subject: [PATCH] Path: Adaptive - fix --- src/Mod/Path/libarea/Adaptive.cpp | 23 ++++++++++++----------- src/Mod/Path/libarea/Adaptive.hpp | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Mod/Path/libarea/Adaptive.cpp b/src/Mod/Path/libarea/Adaptive.cpp index d171bd7861..67613b39b8 100644 --- a/src/Mod/Path/libarea/Adaptive.cpp +++ b/src/Mod/Path/libarea/Adaptive.cpp @@ -1409,7 +1409,7 @@ namespace AdaptivePath { return collisionArea < optimalCutAreaPD*RESOLUTION_FACTOR/10+1; } - bool Adaptive2d::IsAllowedToCutTrough(const IntPoint &p1,const IntPoint &p2,const Paths & cleared, const Paths & toolBoundPaths) { + bool Adaptive2d::IsAllowedToCutTrough(const IntPoint &p1,const IntPoint &p2,const Paths & cleared, const Paths & toolBoundPaths, double areaFactor) { double stepSize=2*RESOLUTION_FACTOR; Clipper clip; size_t clpPathIndex; @@ -1427,7 +1427,7 @@ namespace AdaptivePath { IntPoint toolPos2(long(p1.X + double(p2.X-p1.X)*d/distance),long(p1.Y + double(p2.Y-p1.Y)*d/distance)); double area = CalcCutArea(clip,toolPos1,toolPos2, cleared,false); // if we are cutting above optimal -> not clear to cut - if(area>1.5*stepSize*optimalCutAreaPD) return false; + if(area>areaFactor*stepSize*optimalCutAreaPD) return false; //if tool is outside boundary -> its not clear to cut if(!IsPointWithinCutRegion(toolBoundPaths,toolPos2) @@ -2087,15 +2087,18 @@ namespace AdaptivePath { CleanPath(finShiftedPath,finCleaned,FINISHING_CLEAN_PATH_TOLERANCE); //safety check for finishing paths - + bool cutOK = true; + int invalidPoints=0; for(size_t i=1;i3) cutOK=false; } } - if(allCutsAllowed) { + if(cutOK) { AppendToolPath(progressPaths,output,finCleaned,clearedBeforePass,toolBoundPaths); //expand cleared for finishing path clipof.Clear(); @@ -2111,11 +2114,7 @@ namespace AdaptivePath { lastPoint.X = finCleaned.back().X; lastPoint.Y = finCleaned.back().Y; } - } else { - cerr << "UNABLE TO ADD FINISHING PASS! Please try increasing accuracy." << endl; - break; } - clearedBeforePass=cleared; } Path returnPath; @@ -2147,7 +2146,9 @@ namespace AdaptivePath { #endif // make sure invalid paths are not used - if(!allCutsAllowed) output.AdaptivePaths.clear(); + if(!allCutsAllowed) { + cerr << "INVALID CUTS DETECTED! Please try to modify accuracy and/or step-over." << endl; + } results.push_back(output); } diff --git a/src/Mod/Path/libarea/Adaptive.hpp b/src/Mod/Path/libarea/Adaptive.hpp index afd7237418..0c3c91e439 100644 --- a/src/Mod/Path/libarea/Adaptive.hpp +++ b/src/Mod/Path/libarea/Adaptive.hpp @@ -102,7 +102,7 @@ namespace AdaptivePath { double CalcCutArea(Clipper & clip,const IntPoint &toolPos, const IntPoint &newToolPos, const Paths &cleared_paths, bool preventConvetionalMode=true); void AppendToolPath(TPaths &progressPaths,AdaptiveOutput & output,const Path & passToolPath,const Paths & cleared,const Paths & toolBoundPaths); bool IsClearPath(const Path & path,const Paths & cleared, double safetyDistanceScaled=0); - bool IsAllowedToCutTrough(const IntPoint &p1,const IntPoint &p2,const Paths & cleared,const Paths & toolBoundPaths); + bool IsAllowedToCutTrough(const IntPoint &p1,const IntPoint &p2,const Paths & cleared,const Paths & toolBoundPaths, double areaFactor=1.5); friend class EngagePoint; // for CalcCutArea