From 43ee740ef779b12ee81a0061585264f1086b2a5b Mon Sep 17 00:00:00 2001 From: kreso-t Date: Sat, 8 Sep 2018 16:17:31 +0200 Subject: [PATCH] Path: Adaptive - prepping the PR --- src/Mod/Path/InitGui.py | 4 ++- src/Mod/Path/PathScripts/PathAdaptive.py | 25 ++++++++++++++- src/Mod/Path/PathScripts/PathAdaptiveGui.py | 21 +++++++++++++ src/Mod/Path/libarea/Adaptive.cpp | 35 ++++++++++++++++++--- src/Mod/Path/libarea/Adaptive.hpp | 23 ++++++++++++++ 5 files changed, 102 insertions(+), 6 deletions(-) diff --git a/src/Mod/Path/InitGui.py b/src/Mod/Path/InitGui.py index aad5d7ee52..437bf73cfd 100644 --- a/src/Mod/Path/InitGui.py +++ b/src/Mod/Path/InitGui.py @@ -109,7 +109,7 @@ class PathWorkbench (Workbench): projcmdlist = ["Path_Job", "Path_Post"] toolcmdlist = ["Path_Inspect", "Path_Simulator", "Path_ToolLibraryEdit", "Path_SelectLoop"] prepcmdlist = ["Path_Fixture", "Path_Comment", "Path_Stop", "Path_Custom"] - twodopcmdlist = ["Path_Contour", "Path_Profile_Faces", "Path_Profile_Edges", "Path_Pocket_Shape", "Path_Drilling", "Path_MillFace", "Path_Helix", "Path_Adaptive"] + twodopcmdlist = ["Path_Contour", "Path_Profile_Faces", "Path_Profile_Edges", "Path_Pocket_Shape", "Path_Drilling", "Path_MillFace", "Path_Helix" ] threedopcmdlist = ["Path_Pocket_3D"] engravecmdlist = ["Path_Engrave"] modcmdlist = ["Path_OperationCopy", "Path_Array", "Path_SimpleCopy" ] @@ -130,6 +130,8 @@ class PathWorkbench (Workbench): threedopcmdlist.append("Path_Surface") threedcmdgroup = ['Path_3dTools'] FreeCADGui.addCommand('Path_3dTools', PathCommandGroup(threedopcmdlist, QtCore.QT_TRANSLATE_NOOP("Path",'3D Operations'))) + + twodopcmdlist.append("Path_Adaptive") else: engravecmdgroup = engravecmdlist threedcmdgroup = threedopcmdlist diff --git a/src/Mod/Path/PathScripts/PathAdaptive.py b/src/Mod/Path/PathScripts/PathAdaptive.py index f957c2d6eb..720e15c974 100644 --- a/src/Mod/Path/PathScripts/PathAdaptive.py +++ b/src/Mod/Path/PathScripts/PathAdaptive.py @@ -1,3 +1,26 @@ +# /************************************************************************** +# * Copyright (c) Kresimir Tusek (kresimir.tusek@gmail.com) 2018 * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * This library is free software; you can redistribute it and/or * +# * modify it under the terms of the GNU Library General Public * +# * License as published by the Free Software Foundation; either * +# * version 2 of the License, or (at your option) any later version. * +# * * +# * This library is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this library; see the file COPYING.LIB. If not, * +# * write to the Free Software Foundation, Inc., 59 Temple Place, * +# * Suite 330, Boston, MA 02111-1307, USA * +# * * +# ***************************************************************************/ + + + import PathScripts.PathOp as PathOp import Path import FreeCAD @@ -360,7 +383,7 @@ class PathAdaptive(PathOp.ObjectOp): obj.addProperty("App::PropertyLength", "HelixDiameterLimit", "Adaptive", "Limit helix entry diameter, if limit larger than tool diameter or 0, tool diameter is used") - def opSetDefaultValues(self, obj): + def opSetDefaultValues(self, obj, job): obj.Side="Inside" obj.OperationType = "Clearing" obj.Tolerance = 0.1 diff --git a/src/Mod/Path/PathScripts/PathAdaptiveGui.py b/src/Mod/Path/PathScripts/PathAdaptiveGui.py index e167966ba9..eecbd8dc41 100644 --- a/src/Mod/Path/PathScripts/PathAdaptiveGui.py +++ b/src/Mod/Path/PathScripts/PathAdaptiveGui.py @@ -1,3 +1,24 @@ +# /************************************************************************** +# * Copyright (c) Kresimir Tusek (kresimir.tusek@gmail.com) 2018 * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * This library is free software; you can redistribute it and/or * +# * modify it under the terms of the GNU Library General Public * +# * License as published by the Free Software Foundation; either * +# * version 2 of the License, or (at your option) any later version. * +# * * +# * This library is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this library; see the file COPYING.LIB. If not, * +# * write to the Free Software Foundation, Inc., 59 Temple Place, * +# * Suite 330, Boston, MA 02111-1307, USA * +# * * +# ***************************************************************************/ + import FreeCAD import FreeCADGui import PathScripts.PathLog as PathLog diff --git a/src/Mod/Path/libarea/Adaptive.cpp b/src/Mod/Path/libarea/Adaptive.cpp index f0abfb65b4..6b0e3c2c33 100644 --- a/src/Mod/Path/libarea/Adaptive.cpp +++ b/src/Mod/Path/libarea/Adaptive.cpp @@ -1,3 +1,24 @@ +/************************************************************************** +* Copyright (c) Kresimir Tusek (kresimir.tusek@gmail.com) 2018 * +* This file is part of the FreeCAD CAx development system. * +* * +* This library is free software; you can redistribute it and/or * +* modify it under the terms of the GNU Library General Public * +* License as published by the Free Software Foundation; either * +* version 2 of the License, or (at your option) any later version. * +* * +* This library is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Library General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this library; see the file COPYING.LIB. If not, * +* write to the Free Software Foundation, Inc., 59 Temple Place, * +* Suite 330, Boston, MA 02111-1307, USA * +* * +***************************************************************************/ + #include "Adaptive.hpp" #include #include @@ -15,7 +36,7 @@ namespace AdaptivePath { using namespace ClipperLib; using namespace std; #define SAME_POINT_TOL_SQRD_SCALED 16.0 - + #define UNUSED(expr) (void)(expr) /********************************************* * Utils - inline ***********************************************/ @@ -1362,6 +1383,10 @@ namespace AdaptivePath { Paths &cleared /*output-initial cleard area by helix*/, IntPoint &entryPoint /*output*/, IntPoint & toolPos, DoublePoint & toolDir) { + + UNUSED(progressPaths); // to silence compiler warning + UNUSED(boundPaths); // to silence compiler warning + Clipper clip; ClipperOffset clipof; // check if boundary shape to cut is outside the stock @@ -1452,6 +1477,9 @@ namespace AdaptivePath { void Adaptive2d::AppendToolPath(TPaths &progressPaths,AdaptiveOutput & output,const Path & passToolPath,const Paths & cleared, const Paths & toolBoundPaths) { if(passToolPath.size()<1) return; + + UNUSED(progressPaths); // to silence compiler warning,var is occasionally used in dev. for debugging + IntPoint nextPoint(passToolPath[0]); // if there is a previous path - need to resolve linking move to new path @@ -1761,7 +1789,7 @@ namespace AdaptivePath { entryPoint=toolPos; } - cout << "Entry point:" << double(entryPoint.X)/scaleFactor << "," << double(entryPoint.Y)/scaleFactor << endl; + //cout << "Entry point:" << double(entryPoint.X)/scaleFactor << "," << double(entryPoint.Y)/scaleFactor << endl; AdaptiveOutput output; output.HelixCenterPoint.first = double(entryPoint.X)/scaleFactor; @@ -2077,7 +2105,7 @@ namespace AdaptivePath { Path finShiftedPath; bool allCutsAllowed=true; - while(PopPathWithClosestPoint(finishingPaths,lastPoint,finShiftedPath)) { + while(!stopProcessing && PopPathWithClosestPoint(finishingPaths,lastPoint,finShiftedPath)) { if(finShiftedPath.empty()) continue; // skip finishing passes outside the stock boundary - make no sense to cut where is no material bool allPointsOutside=true; @@ -2167,7 +2195,6 @@ namespace AdaptivePath { // make sure invalid paths are not used if(!allCutsAllowed) { cerr << "INVALID CUTS DETECTED! Please try to modify accuracy and/or step-over." << endl; - output.AdaptivePaths.clear(); } results.push_back(output); diff --git a/src/Mod/Path/libarea/Adaptive.hpp b/src/Mod/Path/libarea/Adaptive.hpp index 133cb6b719..cf9f8f2303 100644 --- a/src/Mod/Path/libarea/Adaptive.hpp +++ b/src/Mod/Path/libarea/Adaptive.hpp @@ -1,3 +1,26 @@ +/************************************************************************** +* Copyright (c) Kresimir Tusek (kresimir.tusek@gmail.com) 2018 * +* This file is part of the FreeCAD CAx development system. * +* * +* This library is free software; you can redistribute it and/or * +* modify it under the terms of the GNU Library General Public * +* License as published by the Free Software Foundation; either * +* version 2 of the License, or (at your option) any later version. * +* * +* This library is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Library General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this library; see the file COPYING.LIB. If not, * +* write to the Free Software Foundation, Inc., 59 Temple Place, * +* Suite 330, Boston, MA 02111-1307, USA * +* * +***************************************************************************/ + + + #include "clipper.hpp" #include #include