-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
if(aShape->shapeType() == GeomAPI_Shape::COMPOUND) {
for(GeomAPI_ShapeIterator anIt(aShape); anIt.more(); anIt.next()) {
GeomShapePtr aSubShape = anIt.current();
- if(aSubShape->shapeType() != GeomAPI_Shape::VERTEX
- && aSubShape->shapeType() != GeomAPI_Shape::EDGE
- && aSubShape->shapeType() != GeomAPI_Shape::FACE) {
+ if (aSubShape->shapeType() > GeomAPI_Shape::VERTEX ||
+ aSubShape->shapeType() < GeomAPI_Shape::FACE) {
theError = "Error: Compound should contain only faces, edges or vertices.";
return false;
}
}
}
- ResultBodyPtr aContextOwner = ModelAPI_Tools::bodyOwner(aContext);
- GeomShapePtr anOwner = aContextOwner.get() ? aContextOwner->shape() : aContext->shape();
+ ResultBodyPtr aContextOwner = ModelAPI_Tools::bodyOwner(aContext, true);
+ GeomShapePtr anOwner = aContext->shape();
+ GeomShapePtr aTopLevelOwner = aContextOwner.get() ? aContextOwner->shape() : anOwner;
if (!anOwner) {
theError = "Error: wrong feature is selected.";
}
if (!aBaseSolid)
- aBaseSolid = anOwner;
- else if (!aBaseSolid->isEqual(anOwner)) {
+ aBaseSolid = aTopLevelOwner;
+ else if (!aBaseSolid->isEqual(aTopLevelOwner)) {
theError = "Error: Sub-shapes of different solids have been selected.";
return false;
}