- //============================================================================
-void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature,
- boost::shared_ptr<ModelAPI_ResultBody> theResultBody,
- boost::shared_ptr<GeomAPI_Shape> theBasis,
- boost::shared_ptr<GeomAPI_Shape> theContext)
-{
-
-
- //load result
- if(theBasis->impl<TopoDS_Shape>().IsEqual(theContext->impl<TopoDS_Shape>()))
- theResultBody->store(theFeature.shape());
- else
- theResultBody->storeGenerated(theContext, theFeature.shape());
-
- TopTools_DataMapOfShapeShape aSubShapes;
- for (TopExp_Explorer Exp(theFeature.shape()->impl<TopoDS_Shape>(),TopAbs_FACE); Exp.More(); Exp.Next()) {
- aSubShapes.Bind(Exp.Current(),Exp.Current());
- }
-
- //Insert lateral face : Face from Edge
- //GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
-
-
- TopTools_MapOfShape aView;
- TopExp_Explorer aShapeExplorer (theFeature.shape()->impl<TopoDS_Shape>(), TopAbs_EDGE);
- for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
- boost::shared_ptr<GeomAPI_Shape> aRootG(new GeomAPI_Shape());
- aRootG->setImpl((void *)&aRoot);
- const ListOfShape& aShapes = theFeature.generated(aRootG);
- std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aShapes.begin(), aLast = aShapes.end();
- for (; anIt != aLast; anIt++) {
- TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
- if (aSubShapes.IsBound(aNewShape)) {
- aNewShape.Orientation((aSubShapes(aNewShape)).Orientation());
+ // Getting sizes.
+ double aFromSize = real(FeaturesPlugin_Extrusion::FROM_SIZE_ID())->value();
+ double aToSize = real(FeaturesPlugin_Extrusion::TO_SIZE_ID())->value();
+
+ // for each selected face generate a result
+ int anIndex = 0, aResultIndex = 0;
+ for(; anIndex < aFaceRefs->size(); anIndex++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> aFaceRef = aFaceRefs->value(anIndex);
+ ResultPtr aContextRes = aFaceRef->context();
+ std::shared_ptr<GeomAPI_Shape> aContext = aContextRes->shape();
+ if (!aContext.get()) {
+ static const std::string aContextError = "The selection context is bad";
+ setError(aContextError);
+ break;
+ }
+
+ std::shared_ptr<GeomAPI_Shape> aValueFace = aFaceRef->value();
+ int aFacesNum = -1; // this mean that "aFace" is used
+ ResultConstructionPtr aConstruction =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes);
+ if (!aValueFace.get()) { // this may be the whole sketch result selected, check and get faces
+ if (aConstruction.get()) {
+ aFacesNum = aConstruction->facesNum();
+ } else {
+ static const std::string aFaceError = "Can not find basis for extrusion";
+ setError(aFaceError);
+ break;
+ }
+ }
+
+ for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) {
+ ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+ std::shared_ptr<GeomAPI_Shape> aBaseShape;
+ if (aFacesNum == -1) {
+ aBaseShape = aValueFace;
+ } else {
+ aBaseShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aConstruction->face(aFaceIndex));