Skip to content

Commit

Permalink
Sketcher: fix external geometry parallel projection offset
Browse files Browse the repository at this point in the history
Second try
  • Loading branch information
realthunder committed Jan 31, 2023
1 parent 5fc4cc4 commit 73c4ca2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Mod/Sketcher/App/SketchObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7966,11 +7966,21 @@ void SketchObject::rebuildExternalGeometry(bool defining, bool addIntersection)
Part::TopoShape projShape;
gp_Pln pln;
if (Part::TopoShape(edge).findPlane(pln)
&& pln.Axis().Direction().IsParallel(
sketchPlane.Axis().Direction(), Precision::Confusion())) {
double d = pln.Distance(sketchPlane);
&& pln.Position().Direction().IsParallel(
sketchPlane.Position().Direction(), Precision::Confusion())) {
// We can't use gp_Pln::Distance() because we need to
// know which side the plane is regarding the sketch
// plane, i.e. we need the returned distance to be
// signed.
// double d = pln.Distance(sketchPlane);
const gp_Pnt& aP = sketchPlane.Location();
const gp_Pnt& aLoc = pln.Location ();
const gp_Dir& aDir = pln.Position().Direction();
double d = (aDir.X() * (aP.X() - aLoc.X()) +
aDir.Y() * (aP.Y() - aLoc.Y()) +
aDir.Z() * (aP.Z() - aLoc.Z()));
gp_Trsf trsf;
trsf.SetTranslation(gp_Vec(sketchPlane.Axis().Direction()) * d);
trsf.SetTranslation(gp_Vec(aDir) * d);
projShape.setShape(edge);
projShape.transformShape(Part::TopoShape::convert(trsf), /*copy*/false);
} else {
Expand Down

0 comments on commit 73c4ca2

Please sign in to comment.