From 364302d32c3d1a52241714d4a0e606d4a762a589 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Tue, 16 May 2017 00:12:00 +0800 Subject: [PATCH 1/3] Path.Area: fix side effect on projection --- src/Mod/Path/App/Area.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index e3ab1bbdda..264357b252 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -1032,6 +1032,9 @@ int Area::project(TopoDS_Shape &shape_out, FC_TIME_LOG(t1,"WireJoiner findClosedWires"); Area area(params); + area.myParams.SectionCount = 0; + area.myParams.Offset = 0.0; + area.myParams.PocketMode = 0; area.myParams.Explode = false; area.myParams.FitArcs = false; area.myParams.Reorient = false; From c6e912786368c7847794d55fa691b2ff86d1f702 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Tue, 16 May 2017 01:41:56 +0800 Subject: [PATCH 2/3] Path.Area: removed LogLevel from setDefaultParams Use App.setLogLevel('Path.Area', ) instead. --- src/Mod/Path/App/Area.cpp | 18 +++++++----------- src/Mod/Path/App/Area.h | 9 --------- src/Mod/Path/App/AreaParams.h | 15 +-------------- src/Mod/Path/App/AreaPyImp.cpp | 3 +-- 4 files changed, 9 insertions(+), 36 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index 264357b252..da4c27de15 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -476,7 +476,7 @@ struct WireJoiner { BRepBndLib::Add(e,bound); bound.SetGap(0.1); if (bound.IsVoid()) { - if(Area::TraceEnabled()) + if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) AREA_WARN("failed to get bound of edge"); return false; } @@ -687,7 +687,7 @@ struct WireJoiner { intersects = true; break; } - }else if(Area::TraceEnabled()) + }else if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) AREA_WARN("BRepExtrema_DistShapeShape failed"); } } @@ -711,7 +711,7 @@ struct WireJoiner { mkEdge2.Init(curve, pt, pend); } if(!mkEdge1.IsDone() || !mkEdge2.IsDone()) { - if(Area::TraceEnabled()) + if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) AREA_WARN((reversed?"reversed ":"")<<"edge split failed "<< AREA_XYZ(pstart)<<", " << AREA_XYZ(pt)<< ", "< > Area::makeSections( double height = z-tolerance; if(z-zMin0.0) break; }else if(zMax-z= BOOST_PP_CAT(LogLevel,_elem);\ -} -BOOST_PP_SEQ_FOR_EACH(AREA_LOG_CHECK_DEFINE,_,AREA_PARAM_LOG_LEVEL) diff --git a/src/Mod/Path/App/Area.h b/src/Mod/Path/App/Area.h index 043108e6bd..ed1202cb42 100644 --- a/src/Mod/Path/App/Area.h +++ b/src/Mod/Path/App/Area.h @@ -75,8 +75,6 @@ struct PathExport AreaParams: CAreaParams { }; struct PathExport AreaStaticParams: AreaParams { - PARAM_DECLARE(PARAM_FNAME,AREA_PARAMS_EXTRA_CONF); - AreaStaticParams(); }; @@ -378,13 +376,6 @@ public: static void setDefaultParams(const AreaStaticParams ¶ms); static const AreaStaticParams &getDefaultParams(); - - -#define AREA_LOG_CHECK_DECLARE(_1,_2,_elem) \ - static bool BOOST_PP_CAT(_elem,Enabled)(); - BOOST_PP_SEQ_FOR_EACH(AREA_LOG_CHECK_DECLARE,_,AREA_PARAM_LOG_LEVEL) - - PARAM_ENUM_DECLARE(AREA_PARAMS_LOG_LEVEL) }; } //namespace Path diff --git a/src/Mod/Path/App/AreaParams.h b/src/Mod/Path/App/AreaParams.h index 9df150fddc..0291de2baa 100644 --- a/src/Mod/Path/App/AreaParams.h +++ b/src/Mod/Path/App/AreaParams.h @@ -255,20 +255,7 @@ AREA_PARAMS_CONF \ AREA_PARAMS_OPCODE -#define AREA_PARAM_LOG_LEVEL (Error)(Warning)(Log)(Trace) -#if FC_DEBUG -# define AREA_PARAMS_LOG_LEVEL \ - ((enum, log_level, LogLevel, 3, "Area log level", AREA_PARAM_LOG_LEVEL)) -#else -# define AREA_PARAMS_LOG_LEVEL \ - ((enum, log_level, LogLevel, 1, "Area log level", AREA_PARAM_LOG_LEVEL)) -#endif - -#define AREA_PARAMS_EXTRA_CONF \ - AREA_PARAMS_LOG_LEVEL - #define AREA_PARAMS_STATIC_CONF \ - AREA_PARAMS_CONF \ - AREA_PARAMS_EXTRA_CONF + AREA_PARAMS_CONF #endif //PATH_AreaParam_H diff --git a/src/Mod/Path/App/AreaPyImp.cpp b/src/Mod/Path/App/AreaPyImp.cpp index 42a862ae6f..1be34defcd 100644 --- a/src/Mod/Path/App/AreaPyImp.cpp +++ b/src/Mod/Path/App/AreaPyImp.cpp @@ -149,10 +149,9 @@ static const PyMethodDef areaOverrides[] = { }, { "setDefaultParams",(PyCFunction)areaSetParams, METH_VARARGS|METH_KEYWORDS|METH_STATIC, - "setDefaultParams(" PARAM_PY_ARGS_DOC(NAME,AREA_PARAMS_EXTRA_CONF) ", key=value...):\n" + "setDefaultParams(key=value...):\n" "Static method to set the default parameters of all following Path.Area, plus the following\n" "additional parameters.\n" - PARAM_PY_DOC(NAME,AREA_PARAMS_EXTRA_CONF) }, { "getDefaultParams",(PyCFunction)areaGetParams, METH_VARARGS|METH_STATIC, From d62614d44b93b5c3288839bf2c3e3a9ca38e849b Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Wed, 17 May 2017 12:00:04 +0800 Subject: [PATCH 3/3] Path.Area: make Path.fromShapes optionally return end pos --- src/Mod/Path/App/AppPathPy.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Mod/Path/App/AppPathPy.cpp b/src/Mod/Path/App/AppPathPy.cpp index cdf058024f..2c4832bfa6 100644 --- a/src/Mod/Path/App/AppPathPy.cpp +++ b/src/Mod/Path/App/AppPathPy.cpp @@ -119,10 +119,11 @@ public: "fromShape(Shape): Returns a Path object from a Part Shape" ); add_keyword_method("fromShapes",&Module::fromShapes, - "fromShapes(shapes, start=Vector(), " PARAM_PY_ARGS_DOC(ARG,AREA_PARAMS_PATH) ")\n" + "fromShapes(shapes, start=Vector(), return_end=False" PARAM_PY_ARGS_DOC(ARG,AREA_PARAMS_PATH) ")\n" "\nReturns a Path object from a list of shapes\n" "\n* shapes: input list of shapes.\n" "\n* start (Vector()): optional start position.\n" + "\n* return_end (False): if True, returns tuple (path, endPosition).\n" PARAM_PY_DOC(ARG, AREA_PARAMS_PATH) ); add_keyword_method("sortWires",&Module::sortWires, @@ -325,11 +326,12 @@ private: PARAM_PY_DECLARE_INIT(PARAM_FARG,AREA_PARAMS_PATH) PyObject *pShapes=NULL; PyObject *start=NULL; - static char* kwd_list[] = {"shapes", "start", + PyObject *return_end=Py_False; + static char* kwd_list[] = {"shapes", "start", "return_end", PARAM_FIELD_STRINGS(ARG,AREA_PARAMS_PATH), NULL}; if (!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), - "O|O!" PARAM_PY_KWDS(AREA_PARAMS_PATH), - kwd_list, &pShapes, &(Base::VectorPy::Type), &start, + "O|O!O" PARAM_PY_KWDS(AREA_PARAMS_PATH), + kwd_list, &pShapes, &(Base::VectorPy::Type), &start, &return_end, PARAM_REF(PARAM_FARG,AREA_PARAMS_PATH))) throw Py::Exception(); @@ -357,10 +359,16 @@ private: } try { + gp_Pnt pend; std::unique_ptr path(new Toolpath); - Area::toPath(*path,shapes,&pstart, NULL, + Area::toPath(*path,shapes,&pstart, &pend, PARAM_PY_FIELDS(PARAM_FARG,AREA_PARAMS_PATH)); - return Py::asObject(new PathPy(path.release())); + if(!PyObject_IsTrue(return_end)) + return Py::asObject(new PathPy(path.release())); + Py::Tuple tuple(2); + tuple.setItem(0, Py::asObject(new PathPy(path.release()))); + tuple.setItem(1, Py::asObject(new Base::VectorPy(Base::Vector3d(pend.X(),pend.Y(),pend.Z())))); + return tuple; } PATH_CATCH }