1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "FeaturesPlugin_ExtrusionBoolean.h"
22 #include <ModelAPI_AttributeSelectionList.h>
23 #include <ModelAPI_AttributeString.h>
25 #include <GeomAlgoAPI_ShapeTools.h>
27 //=================================================================================================
28 void FeaturesPlugin_ExtrusionBoolean::initAttributes()
30 FeaturesPlugin_Extrusion::initAttributes();
32 initBooleanAttributes();
35 //=================================================================================================
36 bool FeaturesPlugin_ExtrusionBoolean::makeGeneration(ListOfShape& theBaseShapes,
37 ListOfMakeShape& theMakeShapes)
39 ListOfShape aBoundaryShapes;
40 return makeExtrusions(theBaseShapes, aBoundaryShapes, theMakeShapes);
43 //=================================================================================================
44 void FeaturesPlugin_ExtrusionBoolean::storeGenerationHistory(ResultBodyPtr theResultBody,
45 const GeomShapePtr theBaseShape,
46 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
48 FeaturesPlugin_Extrusion::storeGenerationHistory(theResultBody, theBaseShape, theMakeShape);
51 //=================================================================================================
52 void FeaturesPlugin_ExtrusionBoolean::getSizes(double& theToSize, double& theFromSize)
54 if (string(CREATION_METHOD())->value() != CREATION_METHOD_THROUGH_ALL()) {
55 FeaturesPlugin_Extrusion::getSizes(theToSize, theFromSize);
58 ListOfShape anObjects;
59 AttributeSelectionListPtr anObjectsSelList = myFeature->selectionList(OBJECTS_ID());
60 for (int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
61 AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
62 GeomShapePtr anObject = anObjectAttr->value();
63 if (!anObject.get()) {
64 myFeature->setError("Error: Could not get object.");
67 anObjects.push_back(anObject);
70 // Getting prism bases.
71 ListOfShape aBaseShapes;
72 getBaseShapes(aBaseShapes);
74 // Getting prism direction.
75 std::shared_ptr<GeomAPI_Dir> aDir;
79 GeomAlgoAPI_ShapeTools::computeThroughAll(anObjects, aBaseShapes, aDir, theToSize, theFromSize);