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};
}

View File

@@ -25,6 +25,7 @@
#define PART_TOOLS_H
#include <Base/Converter.h>
#include <Base/Placement.h>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
@@ -206,7 +207,7 @@ public:
* \param done
*/
static void getNormal(const Handle(Geom_Surface)& surf, double u, double v, const Standard_Real tol, gp_Dir& dir, Standard_Boolean& done);
/* \brief getNormal
/*! \brief getNormal
* Returns the normal at the given parameters on the face and the state of the calculation.
* The orientation is taken into account
* \param face
@@ -217,6 +218,12 @@ public:
* \param done
*/
static void getNormal(const TopoDS_Face& face, double u, double v, const Standard_Real tol, gp_Dir& dir, Standard_Boolean& done);
/*!
* \brief fromPlacement
* Converts a placement into a TopLoc_Location
* \return TopLoc_Location
*/
static TopLoc_Location fromPlacement(const Base::Placement&);
};
} //namespace Part