From 004f82b3e76d122ae1307e70d84af658e3be0843 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Mon, 22 Jan 2018 16:36:40 +0800 Subject: [PATCH] Path.Area: respect zero start point when generating path --- src/Mod/Path/App/AppPathPy.cpp | 4 ++-- src/Mod/Path/App/Area.cpp | 9 ++++----- src/Mod/Path/App/Area.h | 7 +++++-- src/Mod/Path/App/FeaturePathShape.cpp | 3 ++- src/Mod/Path/App/FeaturePathShape.h | 1 + 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Mod/Path/App/AppPathPy.cpp b/src/Mod/Path/App/AppPathPy.cpp index 24bc1d6914..fcdf1411ca 100644 --- a/src/Mod/Path/App/AppPathPy.cpp +++ b/src/Mod/Path/App/AppPathPy.cpp @@ -362,7 +362,7 @@ private: try { gp_Pnt pend; std::unique_ptr path(new Toolpath); - Area::toPath(*path,shapes,&pstart, &pend, + Area::toPath(*path,shapes,start?&pstart:0, &pend, PARAM_PY_FIELDS(PARAM_FARG,AREA_PARAMS_PATH)); if(!PyObject_IsTrue(return_end)) return Py::asObject(new PathPy(path.release())); @@ -415,7 +415,7 @@ private: try { bool need_arc_plane = arc_plane==Area::ArcPlaneAuto; - std::list wires = Area::sortWires(shapes,&pstart, + std::list wires = Area::sortWires(shapes,start!=0,&pstart, &pend, 0, &arc_plane, PARAM_PY_FIELDS(PARAM_FARG,AREA_PARAMS_SORT)); PyObject *list = PyList_New(0); for(auto &wire : wires) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index ab889bf46a..ab420ebae2 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -2721,7 +2721,8 @@ typedef Standard_Real (gp_Pnt::*AxisGetter)() const; typedef void (gp_Pnt::*AxisSetter)(Standard_Real); std::list Area::sortWires(const std::list &shapes, - gp_Pnt *_pstart, gp_Pnt *_pend, double *stepdown_hint, short *_parc_plane, + bool has_start, gp_Pnt *_pstart, gp_Pnt *_pend, + double *stepdown_hint, short *_parc_plane, PARAM_ARGS(PARAM_FARG,AREA_PARAMS_SORT)) { std::list wires; @@ -2814,9 +2815,7 @@ std::list Area::sortWires(const std::list &shapes, gp_Pnt pstart,pend; if(_pstart) pstart = *_pstart; - bool use_bound = fabs(pstart.X()) &shapes, if(_pstart) pstart = *_pstart; double stepdown_hint = 1.0; - wires = sortWires(shapes,&pstart,pend,&stepdown_hint, + wires = sortWires(shapes,_pstart!=0,&pstart,pend,&stepdown_hint, PARAM_REF(PARAM_FARG,AREA_PARAMS_ARC_PLANE), PARAM_FIELDS(PARAM_FARG,AREA_PARAMS_SORT)); diff --git a/src/Mod/Path/App/Area.h b/src/Mod/Path/App/Area.h index 1cf18f9a58..8ec7a9b91f 100644 --- a/src/Mod/Path/App/Area.h +++ b/src/Mod/Path/App/Area.h @@ -340,7 +340,10 @@ public: * minimize traval distance * * \arg \c shapes: input list of shapes. - * \arg \c pstart: optional start point + * \arg \c has_start: if false or pstart is 0, then a start point will be + * auto selected. + * \arg \c pstart: optional start point. If has_start is false, then the + * auto selected start point will be returned with this point if not NULL. * \arg \c pend: optional output containing the ending point of the returned * \arg \c stepdown_hint: optional output of a hint of step down as the max * distance between two sections. @@ -352,7 +355,7 @@ public: * \return sorted wires */ static std::list sortWires(const std::list &shapes, - gp_Pnt *pstart=NULL, gp_Pnt *pend=NULL, double *stepdown_hint=NULL, + bool has_start=false, gp_Pnt *pstart=NULL, gp_Pnt *pend=NULL, double *stepdown_hint=NULL, short *arc_plane = NULL, PARAM_ARGS_DEF(PARAM_FARG,AREA_PARAMS_SORT)); /** Convert a list of wires to gcode diff --git a/src/Mod/Path/App/FeaturePathShape.cpp b/src/Mod/Path/App/FeaturePathShape.cpp index 5d2c79ffad..3e43afc1b2 100644 --- a/src/Mod/Path/App/FeaturePathShape.cpp +++ b/src/Mod/Path/App/FeaturePathShape.cpp @@ -56,6 +56,7 @@ FeatureShape::FeatureShape() { ADD_PROPERTY(Sources,(0)); ADD_PROPERTY_TYPE(StartPoint,(Base::Vector3d()),"Path",App::Prop_None,"Feed start position"); + ADD_PROPERTY_TYPE(UseStartPoint,(false),"Path",App::Prop_None,"Enable feed start position"); PARAM_PROP_ADD("Path",AREA_PARAMS_PATH); PARAM_PROP_SET_ENUM(Enums,AREA_PARAMS_PATH); } @@ -86,7 +87,7 @@ App::DocumentObjectExecReturn *FeatureShape::execute(void) shapes.push_back(shape); } - Area::toPath(path,shapes,&pstart,NULL,PARAM_PROP_ARGS(AREA_PARAMS_PATH)); + Area::toPath(path,shapes,UseStartPoint.getValue()?&pstart:0,0,PARAM_PROP_ARGS(AREA_PARAMS_PATH)); Path.setValue(path); return App::DocumentObject::StdReturn; diff --git a/src/Mod/Path/App/FeaturePathShape.h b/src/Mod/Path/App/FeaturePathShape.h index ff63aea1db..1234402431 100644 --- a/src/Mod/Path/App/FeaturePathShape.h +++ b/src/Mod/Path/App/FeaturePathShape.h @@ -53,6 +53,7 @@ public: // Part::PropertyPartShape Shape; App::PropertyLinkList Sources; App::PropertyVector StartPoint; + App::PropertyBool UseStartPoint; PARAM_PROP_DECLARE(AREA_PARAMS_PATH) //@{