App: Add methods to get base and direction of datum element
Add the methods DatumElement::getBasePoint() and DatumElement::getDirection() to hide implementation details and guarantee consistent behaviour. Using the methods fixes several regressions in: * Constraint::getDirection * PolarPattern::getTransformations
This commit is contained in:
@@ -87,6 +87,21 @@ bool DatumElement::isOriginFeature()
|
||||
return lcs ? lcs->isOrigin() : false;
|
||||
}
|
||||
|
||||
Base::Vector3d DatumElement::getBasePoint() const
|
||||
{
|
||||
Base::Placement plc = Placement.getValue();
|
||||
return plc.getPosition();
|
||||
}
|
||||
|
||||
Base::Vector3d DatumElement::getDirection() const
|
||||
{
|
||||
Base::Vector3d dir(0.0, 0.0, 1.0);
|
||||
Base::Placement plc = Placement.getValue();
|
||||
Base::Rotation rot = plc.getRotation();
|
||||
rot.multVec(dir, dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
LocalCoordinateSystem::LocalCoordinateSystem()
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
|
||||
/// Finds the origin object this plane belongs to
|
||||
App::LocalCoordinateSystem* getLCS();
|
||||
Base::Vector3d getBasePoint() const;
|
||||
Base::Vector3d getDirection() const;
|
||||
|
||||
bool getCameraAlignmentDirection(Base::Vector3d& direction, const char* subname) const override;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user