1 // Copyright (C) 2017-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 "BuildPlugin_Solid.h"
22 #include <ModelAPI_AttributeSelectionList.h>
23 #include <ModelAPI_ResultBody.h>
25 #include <GeomAPI_ShapeExplorer.h>
26 #include <GeomAPI_ShapeIterator.h>
28 #include <GeomAlgoAPI_MakeVolume.h>
30 //=================================================================================================
31 BuildPlugin_Solid::BuildPlugin_Solid()
35 //=================================================================================================
36 void BuildPlugin_Solid::initAttributes()
38 data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
41 //=================================================================================================
42 void BuildPlugin_Solid::execute()
44 // all the needed checkings are in validator, so, here just make and store result
45 ListOfShape anOriginalFaces;
46 ListOfShape anOriginalSolids;
47 getOriginalShapesAndContexts(BASE_OBJECTS_ID(), anOriginalFaces, anOriginalSolids);
49 std::shared_ptr<GeomAlgoAPI_MakeVolume> anAlgo(
50 new GeomAlgoAPI_MakeVolume(anOriginalFaces, false));
51 // check and process result of volume maker
52 GeomShapePtr aResShape = getSingleSubshape(anAlgo->shape());
53 storeResult(anAlgo, anOriginalFaces, anOriginalSolids, aResShape);
56 GeomShapePtr BuildPlugin_Solid::getSingleSubshape(const GeomShapePtr& theCompound)
58 if (theCompound->shapeType() == GeomAPI_Shape::COMPOUND) {
59 GeomAPI_ShapeIterator anIt(theCompound);
60 return anIt.current();