+ theShapesList.clear();
+
+ ListOfShape aBaseFacesList;
+ std::map<ResultConstructionPtr, ListOfShape> aSketchWiresMap;
+ if(!theSelectionList.get()) {
+ theError = "Error: Could not get base objects selection list.";
+ return false;
+ }
+ if(theSelectionList->size() == 0) {
+ theError = "Error: Base objects list is empty.";
+ return false;
+ }
+ for(int anIndex = 0; anIndex < theSelectionList->size(); anIndex++) {
+ AttributeSelectionPtr aBaseObjectSelection = theSelectionList->value(anIndex);
+ if(!aBaseObjectSelection.get()) {
+ theError = "Error: Selected base object is empty.";
+ return false;
+ }
+ GeomShapePtr aBaseShape = aBaseObjectSelection->value();
+ if(aBaseShape.get() && !aBaseShape->isNull()) {
+ GeomAPI_Shape::ShapeType aST = aBaseShape->shapeType();
+ if(aST == GeomAPI_Shape::SOLID || aST == GeomAPI_Shape::COMPSOLID) {
+ theError = "Error: Selected shapes has unsupported type.";
+ return false;
+ }
+ ResultConstructionPtr aConstruction =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseObjectSelection->context());
+ if(aConstruction.get() && !aBaseShape->isEqual(aConstruction->shape()) &&
+ aST == GeomAPI_Shape::WIRE) {
+ // It is a wire on the sketch, store it to make face later.
+ aSketchWiresMap[aConstruction].push_back(aBaseShape);
+ continue;
+ } else {
+ aST == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) :
+ theShapesList.push_back(aBaseShape);
+ }
+ } else {
+ // This may be the whole sketch result selected, check and get faces.
+ ResultConstructionPtr aConstruction =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aBaseObjectSelection->context());
+ if(!aConstruction.get()) {
+ theError = "Error: Selected sketches does not have results.";
+ return false;
+ }
+ GeomValidators_ShapeType::TypeOfShape aSelType =
+ GeomValidators_ShapeType::shapeType(theSelectionList->selectionType());
+ int aFacesNum = 0;
+ if (aSelType != GeomValidators_ShapeType::Vertex &&
+ aSelType != GeomValidators_ShapeType::Edge)
+ aFacesNum = aConstruction->facesNum();
+ if(aFacesNum == 0) {
+ // Probably it can be construction.
+ aBaseShape = aConstruction->shape();
+ if(aBaseShape.get() && !aBaseShape->isNull()) {
+ GeomAPI_Shape::ShapeType aST = aBaseShape->shapeType();
+ if(aST == GeomAPI_Shape::SOLID || aST == GeomAPI_Shape::COMPSOLID) {
+ theError = "Error: Selected shapes has unsupported type.";
+ return false;
+ }
+ aST == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) :
+ theShapesList.push_back(aBaseShape);
+ }
+ } else {
+ for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
+ GeomShapePtr aBaseFace = aConstruction->face(aFaceIndex);
+ if(!aBaseFace.get() || aBaseFace->isNull()) {
+ theError = "Error: One of the faces on selected sketch is null.";
+ return false;
+ }
+ aBaseFacesList.push_back(aBaseFace);
+ }