Merge pull request #18704 from wwmayer/fix_line_dir
App: Add methods to get base and direction of datum element
This commit is contained in:
@@ -516,14 +516,12 @@ const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub& direct
|
||||
}
|
||||
|
||||
if (obj->isDerivedFrom<App::Line>()) {
|
||||
Base::Vector3d vec(1.0, 0.0, 0.0);
|
||||
static_cast<App::Line*>(obj)->Placement.getValue().multVec(vec, vec);
|
||||
Base::Vector3d vec = static_cast<App::Line*>(obj)->getDirection();
|
||||
return vec;
|
||||
}
|
||||
|
||||
if (obj->isDerivedFrom<App::Plane>()) {
|
||||
Base::Vector3d vec(0.0, 0.0, 1.0);
|
||||
static_cast<App::Plane*>(obj)->Placement.getValue().multVec(vec, vec);
|
||||
Base::Vector3d vec = static_cast<App::Plane*>(obj)->getDirection();
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
#include <Base/Placement.h>
|
||||
#include <Base/Rotation.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Mod/Material/App/MaterialManager.h>
|
||||
|
||||
#include "Geometry.h"
|
||||
@@ -76,7 +77,7 @@
|
||||
#include "PartFeaturePy.h"
|
||||
#include "PartPyCXX.h"
|
||||
#include "TopoShapePy.h"
|
||||
#include "Base/Tools.h"
|
||||
#include "Tools.h"
|
||||
|
||||
using namespace Part;
|
||||
namespace sp = std::placeholders;
|
||||
@@ -993,7 +994,9 @@ static TopoShape _getTopoShape(const App::DocumentObject* obj,
|
||||
if (linked->isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
static TopoDS_Shape _shape;
|
||||
if (_shape.IsNull()) {
|
||||
BRepBuilderAPI_MakeEdge builder(gp_Lin(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)));
|
||||
auto line = static_cast<App::Line*>(linked);
|
||||
Base::Vector3d dir = line->getBaseDirection();
|
||||
BRepBuilderAPI_MakeEdge builder(gp_Lin(gp_Pnt(0, 0, 0), Base::convertTo<gp_Dir>(dir)));
|
||||
_shape = builder.Shape();
|
||||
_shape.Infinite(Standard_True);
|
||||
}
|
||||
@@ -1002,7 +1005,9 @@ static TopoShape _getTopoShape(const App::DocumentObject* obj,
|
||||
else if (linked->isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
static TopoDS_Shape _shape;
|
||||
if (_shape.IsNull()) {
|
||||
BRepBuilderAPI_MakeFace builder(gp_Pln(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)));
|
||||
auto plane = static_cast<App::Plane*>(linked);
|
||||
Base::Vector3d dir = plane->getBaseDirection();
|
||||
BRepBuilderAPI_MakeFace builder(gp_Pln(gp_Pnt(0, 0, 0), Base::convertTo<gp_Dir>(dir)));
|
||||
_shape = builder.Shape();
|
||||
_shape.Infinite(Standard_True);
|
||||
}
|
||||
|
||||
@@ -161,9 +161,7 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
|
||||
dir = gp_Dir(d.x, d.y, d.z);
|
||||
} else if (refObject->isDerivedFrom<App::Line>()) {
|
||||
App::Line* line = static_cast<App::Line*>(refObject);
|
||||
Base::Rotation rot = line->Placement.getValue().getRotation();
|
||||
Base::Vector3d d(1,0,0);
|
||||
rot.multVec(d, d);
|
||||
Base::Vector3d d = line->getDirection();
|
||||
dir = gp_Dir(d.x, d.y, d.z);
|
||||
} else if (refObject->isDerivedFrom<Part::Feature>()) {
|
||||
if (subStrings[0].empty())
|
||||
|
||||
@@ -116,11 +116,9 @@ const std::list<gp_Trsf> Mirrored::getTransformations(const std::vector<App::Doc
|
||||
getMirrorAxis axisOfPlane = [this](gp_Pnt& axbase, gp_Dir& axdir) {
|
||||
App::DocumentObject* refObject = MirrorPlane.getValue();
|
||||
if (auto plane = dynamic_cast<App::Plane*>(refObject)) {
|
||||
Base::Vector3d base = plane->Placement.getValue().getPosition();
|
||||
Base::Vector3d base = plane->getBasePoint();
|
||||
axbase = gp_Pnt(base.x, base.y, base.z);
|
||||
Base::Rotation rot = plane->Placement.getValue().getRotation();
|
||||
Base::Vector3d dir(0,0,1);
|
||||
rot.multVec(dir, dir);
|
||||
Base::Vector3d dir = plane->getDirection();
|
||||
axdir = gp_Dir(dir.x, dir.y, dir.z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -129,9 +129,7 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
|
||||
axdir = gp_Dir(dir.x, dir.y, dir.z);
|
||||
} else if (refObject->isDerivedFrom<App::Line>()) {
|
||||
App::Line* line = static_cast<App::Line*>(refObject);
|
||||
Base::Rotation rot = line->Placement.getValue().getRotation();
|
||||
Base::Vector3d d(1,0,0);
|
||||
rot.multVec(d, d);
|
||||
Base::Vector3d d = line->getDirection();
|
||||
axdir = gp_Dir(d.x, d.y, d.z);
|
||||
} else if (refObject->isDerivedFrom<Part::Feature>()) {
|
||||
if (subStrings[0].empty())
|
||||
|
||||
@@ -1358,9 +1358,8 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st
|
||||
|
||||
if (pcReferenceAxis->isDerivedFrom<App::Line>()) {
|
||||
auto* line = static_cast<const App::Line*>(pcReferenceAxis);
|
||||
Base::Placement plc = line->Placement.getValue();
|
||||
base = plc.getPosition();
|
||||
plc.getRotation().multVec(Base::Vector3d(0, 0, 1), dir);
|
||||
base = line->getBasePoint();
|
||||
dir = line->getDirection();
|
||||
|
||||
verifyAxisFunc(checkAxis, sketchplane, gp_Dir(dir.x, dir.y, dir.z));
|
||||
return;
|
||||
|
||||
@@ -357,17 +357,17 @@ class DocumentBasicCases(unittest.TestCase):
|
||||
|
||||
res = obj.getSubObject("X_Axis", retType=2)
|
||||
self.assertEqual(
|
||||
res[1].multVec(FreeCAD.Vector(0, 0, 1)).getAngle(FreeCAD.Vector(1, 0, 0)), 0.0
|
||||
res[1].multVec(FreeCAD.Vector(1, 0, 0)).getAngle(FreeCAD.Vector(1, 0, 0)), 0.0
|
||||
)
|
||||
|
||||
res = obj.getSubObject("Y_Axis", retType=2)
|
||||
self.assertEqual(
|
||||
res[1].multVec(FreeCAD.Vector(0, 0, 1)).getAngle(FreeCAD.Vector(0, 1, 0)), 0.0
|
||||
res[1].multVec(FreeCAD.Vector(1, 0, 0)).getAngle(FreeCAD.Vector(0, 1, 0)), 0.0
|
||||
)
|
||||
|
||||
res = obj.getSubObject("Z_Axis", retType=2)
|
||||
self.assertEqual(
|
||||
res[1].multVec(FreeCAD.Vector(0, 0, 1)).getAngle(FreeCAD.Vector(0, 0, 1)), 0.0
|
||||
res[1].multVec(FreeCAD.Vector(1, 0, 0)).getAngle(FreeCAD.Vector(0, 0, 1)), 0.0
|
||||
)
|
||||
|
||||
res = obj.getSubObject("XY_Plane", retType=2)
|
||||
|
||||
Reference in New Issue
Block a user