From 67a16db6cb638ef88c92b8d9db44fbd83c768181 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Tue, 24 Jan 2017 14:37:12 +0800 Subject: [PATCH] Path.Area: fixed plane finding for edge only shapes --- src/Mod/Path/App/Area.cpp | 40 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index a44940f760..d7343a44ba 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -346,29 +346,23 @@ void Area::build() { if(myWorkPlane.IsNull()) { myShapePlane.Nullify(); for(const Shape &s : myShapes) { - bool haveFace = false; - for(TopExp_Explorer it(s.shape, TopAbs_FACE); it.More(); it.Next()) { - haveFace = true; - BRepLib_FindSurface planeFinder(it.Current(),-1,Standard_True); - if (!planeFinder.Found()) - continue; - myShapePlane = it.Current(); - myTrsf.SetTransformation(GeomAdaptor_Surface( - planeFinder.Surface()).Plane().Position()); - break; - } - if(!myShapePlane.IsNull()) break; - if(haveFace) continue; - for(TopExp_Explorer it(s.shape, TopAbs_WIRE); it.More(); it.Next()) { - BRepLib_FindSurface planeFinder(it.Current(),-1,Standard_True); - if (!planeFinder.Found()) - continue; - myShapePlane = it.Current(); - myTrsf.SetTransformation(GeomAdaptor_Surface( - planeFinder.Surface()).Plane().Position()); - break; - } - if(!myShapePlane.IsNull()) break; + bool haveShape = false; +#define AREA_CHECK_PLANE(_type) \ + for(TopExp_Explorer it(s.shape, TopAbs_##_type); it.More(); it.Next()) {\ + haveShape = true;\ + BRepLib_FindSurface planeFinder(it.Current(),-1,Standard_True);\ + if (!planeFinder.Found())\ + continue;\ + myShapePlane = it.Current();\ + myTrsf.SetTransformation(GeomAdaptor_Surface(\ + planeFinder.Surface()).Plane().Position());\ + break;\ + }\ + if(!myShapePlane.IsNull()) break;\ + if(haveShape) continue; + AREA_CHECK_PLANE(FACE) + AREA_CHECK_PLANE(WIRE) + AREA_CHECK_PLANE(EDGE) } if(myShapePlane.IsNull())