for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
AttributeSelectionPtr aSelectionAttr = aListAttr->value(anIndex);
ResultPtr aContext = aSelectionAttr->context();
- if(!aContext.get()) {
+ if(!aContext.get() && !aSelectionAttr->contextFeature().get()) {
theError = "Error: Empty context.";
return false;
}
// If shape is compound check that it contains only faces and edges.
GeomShapePtr aShape = aSelectionAttr->value();
if(!aShape.get()) {
- aShape = aContext->shape();
+ if (aContext.get()) {
+ aShape = aContext->shape();
+ } else {
+ theError = "Error: Empty context.";
+ return false;
+ }
}
if(aShape->shapeType() == GeomAPI_Shape::COMPOUND) {
AttributeSelectionPtr aSelectionAttr = aListAttr->value(anIndex);
ResultPtr aContext = aSelectionAttr->context();
if(!aContext.get()) {
- theError = "Error: Empty context.";
- return false;
+ FeaturePtr aFeature = aSelectionAttr->contextFeature();
+ if (!aFeature.get() || aFeature->results().empty()) {
+ theError = "Error: Empty context.";
+ return false;
+ } else {
+ aContext = aFeature->firstResult();
+ }
}
ResultConstructionPtr aResultConstruction =
AttributeSelectionPtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
ResultPtr aContext = anAttr->context();
- if(!aContext.get()) {
+ if(!aContext.get() && !anAttr->contextFeature().get()) {
theError = "Error: Attribute have empty context.";
return false;
}
GeomShapePtr aShape = anAttr->value();
- GeomShapePtr aContextShape = aContext->shape();
- if(!aShape.get()) {
+ GeomShapePtr aContextShape;
+ if(!aShape.get() && aContext.get()) {
+ aContextShape = aContext->shape();
aShape = aContextShape;
}
if(!aShape.get()) {
return false;
}
- ResultConstructionPtr aConstruction =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
+ ResultConstructionPtr aConstruction;
+ if (!aContext.get() && anAttr->contextFeature()->results().size() == 1) {
+ aContext = anAttr->contextFeature()->firstResult();
+ }
+ if (aContext.get())
+ aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
if(aConstruction.get()) {
// Construciotn selected. Check that is is not infinite.
if(aConstruction->isInfinite()) {
return false;
}
+ GeomShapePtr aContextShape = aContext->shape();
if(aShape->isEqual(aContextShape)) {
// Whole construction selected. Check that it have faces.
if(aConstruction->facesNum() > 0) {
return false;
}
- if(!aShape->isEqual(aContextShape)) {
+ if(aContextShape.get() && !aShape->isEqual(aContextShape)) {
// Local selection on body does not allowed.
theError =
"Error: Selected shape is in the local selection. Only global selection is allowed.";
aDirShape = aSelAttr->value();
if(!aDirShape.get()) {
ResultPtr aContext = aSelAttr->context();
+ if(!aContext.get()) {
+ FeaturePtr aFeature = aSelAttr->contextFeature();
+ if (aFeature.get() && !aFeature->results().empty()) {
+ aContext = aFeature->firstResult();
+ }
+ }
+
if(aContext.get()) {
aDirShape = aContext->shape();
}
AttributeSelectionPtr anAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
ResultPtr aContext = anAttr->context();
- if(!aContext.get()) {
+ if(!aContext.get() && !anAttr->contextFeature().get()) {
return false;
}
GeomShapePtr aShape = anAttr->value();
- GeomShapePtr aContextShape = aContext->shape();
- if(!aShape.get()) {
+ if(!aShape.get() && aContext.get()) {
+ GeomShapePtr aContextShape = aContext->shape();
aShape = aContextShape;
}
if(!aShape.get()) {
theError = "Not enough arguments for Fuse operation.";
return false;
}
+ return true;
}
//=================================================================================================