Part: add convenience function to convert Placement into TopLoc_Location

This commit is contained in:
wmayer
2022-05-04 14:56:40 +02:00
parent 87db9dccb5
commit ac421ffd0e
2 changed files with 22 additions and 1 deletions

View File

@@ -25,6 +25,7 @@
# include <cassert>
# include <gp_Pln.hxx>
# include <gp_Lin.hxx>
# include <gp_Quaternion.hxx>
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <BRepBuilderAPI_MakeEdge.hxx>
@@ -724,3 +725,16 @@ void Part::Tools::getNormal(const TopoDS_Face& face, double u, double v,
if (face.Orientation() == TopAbs_REVERSED)
dir.Reverse();
}
TopLoc_Location Part::Tools::fromPlacement(const Base::Placement& plm)
{
Base::Rotation r = plm.getRotation();
double q1, q2, q3, q4;
r.getValue(q1, q2, q3, q4);
Base::Vector3d t = plm.getPosition();
gp_Trsf trf;
trf.SetTranslation(gp_Vec(t.x, t.y, t.z));
trf.SetRotation(gp_Quaternion(q1, q2, q3, q4));
return {trf};
}