Fem: [skip ci] handle exception in Fem Constraint in case referenced shape element doesn't exist

This commit is contained in:
wmayer
2020-06-30 11:34:07 +02:00
parent 2b5ef38a86
commit 68b98f5ffe

View File

@@ -90,9 +90,14 @@ Constraint::~Constraint()
App::DocumentObjectExecReturn *Constraint::execute(void)
{
References.touch();
Scale.touch();
return StdReturn;
try {
References.touch();
Scale.touch();
return StdReturn;
}
catch (const Standard_Failure& e) {
return new App::DocumentObjectExecReturn(e.GetMessageString(), this);
}
}
//OvG: Provide the ability to determine how big to draw constraint arrows etc.
@@ -123,14 +128,15 @@ void Constraint::onChanged(const App::Property* prop)
// Extract geometry from References
TopoDS_Shape sh;
bool execute = this->isRecomputing();
for (std::size_t i = 0; i < Objects.size(); i++) {
App::DocumentObject* obj = Objects[i];
Part::Feature* feat = static_cast<Part::Feature*>(obj);
const Part::TopoShape& toposhape = feat->Shape.getShape();
if (!toposhape.getShape().IsNull()) {
sh = toposhape.getSubShape(SubElements[i].c_str());
sh = toposhape.getSubShape(SubElements[i].c_str(), !execute);
if (sh.ShapeType() == TopAbs_FACE) {
if (!sh.IsNull() && sh.ShapeType() == TopAbs_FACE) {
// Get face normal in center point
TopoDS_Face face = TopoDS::Face(sh);
BRepGProp_Face props(face);
@@ -142,8 +148,7 @@ void Constraint::onChanged(const App::Property* prop)
normal.Normalize();
NormalDirection.setValue(normal.X(), normal.Y(), normal.Z());
// One face is enough...
App::DocumentObject::onChanged(prop);
return;
break;
}
}
}
@@ -174,7 +179,9 @@ bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base
if (toposhape.isNull())
return false;
sh = toposhape.getSubShape(SubElements[i].c_str());
sh = toposhape.getSubShape(SubElements[i].c_str(), true);
if (sh.IsNull())
return false;
if (sh.ShapeType() == TopAbs_VERTEX) {
const TopoDS_Vertex& vertex = TopoDS::Vertex(sh);