From a5c8113aaa6a5c0a6f507856afa9db51ffde3a2a Mon Sep 17 00:00:00 2001 From: logari81 Date: Thu, 8 Dec 2011 20:10:57 +0000 Subject: [PATCH] + fix wrong positioning of Sketch on rotated Support git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5240 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Part/App/Part2DObject.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index 3a015cdd5..33f8c6a64 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -101,9 +101,16 @@ Base::Placement Part2DObject::positionBySupport(const TopoDS_Face &face, const B gp_Dir dir = Normal.Direction(); gp_Ax3 SketchPos; - double cosNX = dir.Dot(gp::DX()); - double cosNY = dir.Dot(gp::DY()); - double cosNZ = dir.Dot(gp::DZ()); + Base::Vector3d dX,dY,dZ; + Place.getRotation().multVec(Base::Vector3d(1,0,0),dX); + Place.getRotation().multVec(Base::Vector3d(0,1,0),dY); + Place.getRotation().multVec(Base::Vector3d(0,0,1),dZ); + gp_Dir dirX(dX.x, dX.y, dX.z); + gp_Dir dirY(dY.x, dY.y, dY.z); + gp_Dir dirZ(dZ.x, dZ.y, dZ.z); + double cosNX = dir.Dot(dirX); + double cosNY = dir.Dot(dirY); + double cosNZ = dir.Dot(dirZ); std::vector cosXYZ; cosXYZ.push_back(fabs(cosNX)); cosXYZ.push_back(fabs(cosNY)); @@ -114,20 +121,20 @@ Base::Placement Part2DObject::positionBySupport(const TopoDS_Face &face, const B // +X/-X if (pos == 0) { if (cosNX > 0) - SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(0,1,0)); + SketchPos = gp_Ax3(SketchBasePoint, dir, dirY); else - SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(0,-1,0)); + SketchPos = gp_Ax3(SketchBasePoint, dir, -dirY); } // +Y/-Y else if (pos == 1) { if (cosNY > 0) - SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(-1,0,0)); + SketchPos = gp_Ax3(SketchBasePoint, dir, -dirX); else - SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(1,0,0)); + SketchPos = gp_Ax3(SketchBasePoint, dir, dirX); } // +Z/-Z else { - SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(1,0,0)); + SketchPos = gp_Ax3(SketchBasePoint, dir, dirX); } gp_Trsf Trf;