1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "FeaturesPlugin_Boolean.h"
23 #include <ModelAPI_Data.h>
24 #include <ModelAPI_Document.h>
25 #include <ModelAPI_AttributeReference.h>
26 #include <ModelAPI_AttributeInteger.h>
27 #include <ModelAPI_ResultBody.h>
28 #include <ModelAPI_AttributeSelectionList.h>
29 #include <ModelAPI_Session.h>
30 #include <ModelAPI_Validator.h>
31 #include <ModelAPI_Tools.h>
33 #include <GeomAlgoAPI_Boolean.h>
34 #include <GeomAlgoAPI_MakeShapeCustom.h>
35 #include <GeomAlgoAPI_MakeShapeList.h>
36 #include <GeomAlgoAPI_Partition.h>
37 #include <GeomAlgoAPI_PaveFiller.h>
38 #include <GeomAlgoAPI_ShapeTools.h>
39 #include <GeomAPI_Face.h>
40 #include <GeomAPI_ShapeExplorer.h>
41 #include <GeomAPI_ShapeIterator.h>
46 //=================================================================================================
47 FeaturesPlugin_Boolean::FeaturesPlugin_Boolean(const OperationType theOperationType)
48 : myOperationType(theOperationType)
52 //=================================================================================================
53 void FeaturesPlugin_Boolean::initAttributes()
55 AttributeSelectionListPtr aSelection =
56 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
57 FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
59 aSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
60 FeaturesPlugin_Boolean::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
62 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_LIST_ID());
63 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID());
66 //=================================================================================================
67 FeaturesPlugin_Boolean::OperationType FeaturesPlugin_Boolean::operationType()
69 return myOperationType;
72 //=================================================================================================
73 void FeaturesPlugin_Boolean::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
74 const std::shared_ptr<GeomAPI_Shape> theBaseShape,
75 const ListOfShape& theTools,
76 const std::shared_ptr<GeomAPI_Shape> theResultShape,
77 const GeomMakeShapePtr& theMakeShape)
80 if(theBaseShape->isEqual(theResultShape)) {
81 theResultBody->store(theResultShape, false);
85 theResultBody->storeModified(theBaseShape, theResultShape);
87 theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE);
88 theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
90 theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
92 for (ListOfShape::const_iterator anIter = theTools.begin();
93 anIter != theTools.end();
96 GeomAPI_Shape::ShapeType aShapeType =
97 (*anIter)->shapeType() <= GeomAPI_Shape::FACE ? GeomAPI_Shape::FACE
98 : GeomAPI_Shape::EDGE;
99 theResultBody->loadModifiedShapes(theMakeShape, *anIter, aShapeType);
101 theResultBody->loadDeletedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE);