+ 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
This commit is contained in:
logari81 2011-12-08 20:10:57 +00:00
parent 43134ea110
commit a5c8113aaa

View File

@ -101,9 +101,16 @@ Base::Placement Part2DObject::positionBySupport(const TopoDS_Face &face, const B
gp_Dir dir = Normal.Direction(); gp_Dir dir = Normal.Direction();
gp_Ax3 SketchPos; gp_Ax3 SketchPos;
double cosNX = dir.Dot(gp::DX()); Base::Vector3d dX,dY,dZ;
double cosNY = dir.Dot(gp::DY()); Place.getRotation().multVec(Base::Vector3d(1,0,0),dX);
double cosNZ = dir.Dot(gp::DZ()); 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<double> cosXYZ; std::vector<double> cosXYZ;
cosXYZ.push_back(fabs(cosNX)); cosXYZ.push_back(fabs(cosNX));
cosXYZ.push_back(fabs(cosNY)); cosXYZ.push_back(fabs(cosNY));
@ -114,20 +121,20 @@ Base::Placement Part2DObject::positionBySupport(const TopoDS_Face &face, const B
// +X/-X // +X/-X
if (pos == 0) { if (pos == 0) {
if (cosNX > 0) if (cosNX > 0)
SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(0,1,0)); SketchPos = gp_Ax3(SketchBasePoint, dir, dirY);
else else
SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(0,-1,0)); SketchPos = gp_Ax3(SketchBasePoint, dir, -dirY);
} }
// +Y/-Y // +Y/-Y
else if (pos == 1) { else if (pos == 1) {
if (cosNY > 0) if (cosNY > 0)
SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(-1,0,0)); SketchPos = gp_Ax3(SketchBasePoint, dir, -dirX);
else else
SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(1,0,0)); SketchPos = gp_Ax3(SketchBasePoint, dir, dirX);
} }
// +Z/-Z // +Z/-Z
else { else {
SketchPos = gp_Ax3(SketchBasePoint, dir, gp_Dir(1,0,0)); SketchPos = gp_Ax3(SketchBasePoint, dir, dirX);
} }
gp_Trsf Trf; gp_Trsf Trf;