1 // Copyright (C) 2014-2019 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_Boolean.h"
22 #include <ModelAPI_Data.h>
23 #include <ModelAPI_Document.h>
24 #include <ModelAPI_AttributeReference.h>
25 #include <ModelAPI_AttributeInteger.h>
26 #include <ModelAPI_ResultBody.h>
27 #include <ModelAPI_AttributeSelectionList.h>
28 #include <ModelAPI_Session.h>
29 #include <ModelAPI_Validator.h>
30 #include <ModelAPI_Tools.h>
32 #include <GeomAlgoAPI_Boolean.h>
33 #include <GeomAlgoAPI_MakeShapeCustom.h>
34 #include <GeomAlgoAPI_MakeShapeList.h>
35 #include <GeomAlgoAPI_Partition.h>
36 #include <GeomAlgoAPI_PaveFiller.h>
37 #include <GeomAlgoAPI_ShapeTools.h>
38 #include <GeomAPI_Face.h>
39 #include <GeomAPI_ShapeExplorer.h>
40 #include <GeomAPI_ShapeIterator.h>
45 //=================================================================================================
46 FeaturesPlugin_Boolean::FeaturesPlugin_Boolean(const OperationType theOperationType)
47 : myOperationType(theOperationType)
51 //=================================================================================================
52 void FeaturesPlugin_Boolean::initAttributes()
54 AttributeSelectionListPtr aSelection =
55 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
56 FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
58 aSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
59 FeaturesPlugin_Boolean::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
61 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_LIST_ID());
62 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID());
65 //=================================================================================================
66 FeaturesPlugin_Boolean::OperationType FeaturesPlugin_Boolean::operationType()
68 return myOperationType;
71 //=================================================================================================
72 void FeaturesPlugin_Boolean::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
73 const std::shared_ptr<GeomAPI_Shape> theBaseShape,
74 const ListOfShape& theTools,
75 const std::shared_ptr<GeomAPI_Shape> theResultShape,
76 const GeomMakeShapePtr& theMakeShape)
79 if(theBaseShape->isEqual(theResultShape)) {
80 theResultBody->store(theResultShape, false);
84 theResultBody->storeModified(theBaseShape, theResultShape);
86 theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE);
87 theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
89 theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
91 for (ListOfShape::const_iterator anIter = theTools.begin();
92 anIter != theTools.end();
95 GeomAPI_Shape::ShapeType aShapeType =
96 (*anIter)->shapeType() <= GeomAPI_Shape::FACE ? GeomAPI_Shape::FACE
97 : GeomAPI_Shape::EDGE;
98 theResultBody->loadModifiedShapes(theMakeShape, *anIter, aShapeType);
100 theResultBody->loadDeletedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE);