From 20c367f2dc991ef6f947237fdc2acd3794a58309 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 27 Feb 2015 23:27:08 +0100 Subject: [PATCH] + in Fem constraint force dialog handle empty Direction --- src/Mod/Fem/App/FemConstraint.cpp | 11 ++++++++++- src/Mod/Fem/App/FemConstraintForce.cpp | 7 +++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Mod/Fem/App/FemConstraint.cpp b/src/Mod/Fem/App/FemConstraint.cpp index 1297b8fefb..565167ee45 100644 --- a/src/Mod/Fem/App/FemConstraint.cpp +++ b/src/Mod/Fem/App/FemConstraint.cpp @@ -55,6 +55,7 @@ #include #include +#include using namespace Fem; @@ -312,7 +313,15 @@ const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub &direct const Part::TopoShape& shape = feat->Shape.getShape(); if (shape.isNull()) return Base::Vector3d(0,0,0); - TopoDS_Shape sh = shape.getSubShape(subName.c_str()); + TopoDS_Shape sh; + try { + sh = shape.getSubShape(subName.c_str()); + } + catch (Standard_Failure) { + std::stringstream str; + str << "No such sub-element '" << subName << "'"; + throw Base::AttributeError(str.str()); + } gp_Dir dir; if (sh.ShapeType() == TopAbs_FACE) { diff --git a/src/Mod/Fem/App/FemConstraintForce.cpp b/src/Mod/Fem/App/FemConstraintForce.cpp index cca87225e6..3a30b1192d 100644 --- a/src/Mod/Fem/App/FemConstraintForce.cpp +++ b/src/Mod/Fem/App/FemConstraintForce.cpp @@ -96,8 +96,11 @@ void ConstraintForce::onChanged(const App::Property* prop) } else if (prop == &NormalDirection) { // Set a default direction if no direction reference has been given if (Direction.getValue() == NULL) { - DirectionVector.setValue(NormalDirection.getValue()); - naturalDirectionVector = NormalDirection.getValue(); + Base::Vector3d direction = NormalDirection.getValue(); + if (Reversed.getValue()) + direction = -direction; + DirectionVector.setValue(direction); + naturalDirectionVector = direction; } } }