CenterType aCenterType = theType[0] == 'v' || theType[0] == 'V' ? // only for vertex-type
centerTypeByName(aSubShapeName) : NOT_CENTER;
std::string aType = aCenterType == NOT_CENTER ? theType : "EDGE"; // search for edge now
- TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(GeomAPI_Shape::shapeTypeByStr(theType));
static const GeomShapePtr anEmptyShape;
// first iteration is selection by name without center prefix, second - in case of problem,
// try with initial name
for(int aUseCenter = 1; aUseCenter >= 0; aUseCenter--) {
- std::string aSubShapeName = theSubShapeName;
if (aUseCenter == 0 && aCenterType != NOT_CENTER) {
+ aSubShapeName = theSubShapeName;
aCenterType = NOT_CENTER;
aType = theType;
} else if (aUseCenter != 1) continue;
+ TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(GeomAPI_Shape::shapeTypeByStr(aType));
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(owner()->document());
}
}
}
- aSubShapeName = theSubShapeName;
}
// invalid
TDF_Label aSelLab = selectionLabel();
// to avoid detection of part changes by local selection only
AttributeSelectionPtr aSel =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRef);
- if (aSel.get() && !aSel->value()->isSame(aSel->context()->shape()))
+ if (aSel.get() && aSel->value().get() &&
+ !aSel->value()->isSame(aSel->context()->shape()))
continue;
FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
if (aGroup->Get() == ModelAPI_ResultBody::group().c_str()) {
aNewBody = createBody(theFeature->data(), aResIndex);
} else if (aGroup->Get() == ModelAPI_ResultPart::group().c_str()) {
- std::shared_ptr<ModelAPI_ResultPart> aNewP = createPart(theFeature->data(), aResIndex);
- theFeature->setResult(aNewP, aResIndex);
- if (!aNewP->partDoc().get())
- // create the part result: it is better to restore the previous result if it is possible
- theFeature->execute();
+ if (aResIndex <= theFeature->results().size()) { // to avoid crash if previous execute
+ // for index = 0 erases result
+ std::shared_ptr<ModelAPI_ResultPart> aNewP = createPart(theFeature->data(), aResIndex);
+ theFeature->setResult(aNewP, aResIndex);
+ if (!aNewP->partDoc().get())
+ // create the part result: it is better to restore the previous result if it is possible
+ theFeature->execute();
+ }
} else if (aGroup->Get() == ModelAPI_ResultConstruction::group().c_str()) {
ResultConstructionPtr aConstr = createConstruction(theFeature->data(), aResIndex);
if (!aConstr->updateShape())
{
std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
if (myShape.IsNull()) { // shape is not produced yet, create it
+ SessionPtr aMgr = ModelAPI_Session::get();
+ bool aToSendUpdate = aMgr->isOperation(); // inside of operation may send an update evnet
if (myTrsf.get()) { // get shape of the base result and apply the transformation
ResultPtr anOrigResult = baseRef();
std::shared_ptr<GeomAPI_Shape> anOrigShape = anOrigResult->shape();
aResult->setImpl(new TopoDS_Shape(aShape));
}
}
+ if (!myShape.IsNull() && aToSendUpdate) {
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+ ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
+ }
return aResult;
} else {
DocumentPtr aDoc = Model_ResultPart::partDoc();
}
}
}
+ if (!myShape.IsNull() && aToSendUpdate) {
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+ ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
+ }
}
- if (!myShape.IsNull())
+ if (!myShape.IsNull()) {
aResult->setImpl(new TopoDS_Shape(myShape));
+ }
return aResult;
}