From 7a567812854b7d41a8895e7eea206ee90511121a Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 24 Feb 2021 23:53:15 +0100 Subject: [PATCH] FEM: [skip ci] support Line and Plane objects in Constraint::getDirection() --- src/Mod/Fem/App/FemConstraint.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Mod/Fem/App/FemConstraint.cpp b/src/Mod/Fem/App/FemConstraint.cpp index 35e7c098a6..4e77962533 100644 --- a/src/Mod/Fem/App/FemConstraint.cpp +++ b/src/Mod/Fem/App/FemConstraint.cpp @@ -58,6 +58,7 @@ #include #include +#include #include #include @@ -431,6 +432,24 @@ Base::Vector3d Constraint::getBasePoint(const Base::Vector3d& base, const Base:: const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub &direction) { App::DocumentObject* obj = direction.getValue(); + if (obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + Base::Vector3d vec(1.0, 0.0, 0.0); + static_cast(obj)->Placement.getValue().multVec(vec, vec); + return vec; + } + + if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + Base::Vector3d vec(0.0, 0.0, 1.0); + static_cast(obj)->Placement.getValue().multVec(vec, vec); + return vec; + } + + if (!obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + std::stringstream str; + str << "Type is not a line, plane or Part object"; + throw Base::TypeError(str.str()); + } + std::vector names = direction.getSubValues(); if (names.size() == 0) return Base::Vector3d(0,0,0);