From 16bf2eb737ce1e365b99fe0be2ce4d5472294857 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Thu, 11 May 2017 15:34:39 +0800 Subject: [PATCH] Path.Area: fix work plane direction --- src/Mod/Path/App/Area.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index e1f331638e..d68dfabd43 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -913,25 +913,37 @@ struct FindPlane { if (!finder.Found()) return; - gp_Ax3 pos = GeomAdaptor_Surface(finder.Surface()).Plane().Position(); // TODO: It seemed that FindSurface disregard shape's // transformation SOMETIME, so we have to transformed the found // plane manually. Need to figure out WHY! - pos.Transform(shape.Location().Transformation()); + gp_Pln pln = GeomAdaptor_Surface(finder.Surface()).Plane(); + pln.Transform(shape.Location().Transformation()); + gp_Ax3 pos = pln.Position(); // We only use right hand coordinate, hence gp_Ax2 instead of gp_Ax3 - // This means that no matter what the work plane face oriented, we - // will treat it as face upward in a right hand coordinate system. - if(!pos.Direct()) + if(!pos.Direct()) { + AREA_WARN("left hand coordinate"); pos = gp_Ax3(pos.Ax2()); + } gp_Dir dir(pos.Direction()); + // To make things more 'normalized', we force the plane to face positive + // axis direction if it parallels to either X, Y or Z plane. + bool x0 = fabs(dir.X()) pt.Z()) @@ -941,6 +953,8 @@ struct FindPlane { return; myPlaneShape = shape; myTrsf = trsf; + AREA_TRACE("plane pos " << AREA_XYZ(pos.Location()) << + ", " << AREA_XYZ(pos.Direction())); } };