+ in Fem constraint force dialog handle empty Direction

This commit is contained in:
wmayer
2015-02-27 23:27:08 +01:00
parent 6721139630
commit 20c367f2dc
2 changed files with 15 additions and 3 deletions

View File

@@ -55,6 +55,7 @@
#include <Mod/Part/App/PartFeature.h>
#include <Base/Console.h>
#include <Base/Exception.h>
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) {

View File

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