1 // Copyright (C) 2014-2022 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 #ifndef FeaturesPlugin_VersionedBoolean_H_
21 #define FeaturesPlugin_VersionedBoolean_H_
23 #include "FeaturesPlugin.h"
24 #include "FeaturesPlugin_Tools.h"
26 #include <GeomAPI_ShapeHierarchy.h>
27 #include <GeomAlgoAPI_Tools.h>
29 #include <ModelAPI_Feature.h>
30 #include <ModelAPI_Tools.h>
32 class ModelAPI_Attribute;
33 class ModelAPI_Result;
34 class GeomAlgoAPI_MakeShapeList;
36 /// \class FeaturesPlugin_VersionedBoolean
38 /// \brief Feature controls a version of Boolean operations.
39 class FeaturesPlugin_VersionedBoolean : public ModelAPI_Feature
42 static const std::string& BOP_VERSION_9_4()
44 static const std::string VERSION("v9.4");
48 /// Use plugin manager for features creation.
49 FeaturesPlugin_VersionedBoolean() {}
51 /// Initialize version field of the Boolean feature.
52 /// The version is initialized for newly created features,
53 /// not read from previously stored document.
54 void initVersion(const std::string& theVersion,
55 const std::shared_ptr<ModelAPI_Attribute> theObjectsAttr
56 = std::shared_ptr<ModelAPI_Attribute>(),
57 const std::shared_ptr<ModelAPI_Attribute> theToolsAttr
58 = std::shared_ptr<ModelAPI_Attribute>());
60 /// Process SelectionList attribute and fill the objects hierarchy.
61 bool processAttribute(const std::string& theAttributeName,
62 GeomAPI_ShapeHierarchy& theObjects,
63 ListOfShape& thePlanesList);
65 /// Perform Boolean operation of the object with the tools.
66 /// In case of theResultCompound is not empty, the result of Boolean operation
67 /// is added to this compound, and corresponding ResultBody is not generated.
68 /// \return \c false if something went wrong
69 bool processObject(const GeomAlgoAPI_Tools::BOPType theBooleanType,
70 const GeomShapePtr& theObject,
71 const ListOfShape& theTools,
72 const ListOfShape& thePlanes,
74 std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
75 ListOfShape& theResultShapesList,
76 GeomShapePtr theResulCompound = GeomShapePtr());
78 /// Perform Boolean operation of the Compsolid with the tools
79 /// In case of theResultCompound is not empty, the result of Boolean operation
80 /// is added to this compound, and corresponding ResultBody is not generated.
81 /// \return \c false if something went wrong
82 bool processCompsolid(const GeomAlgoAPI_Tools::BOPType theBooleanType,
83 GeomAPI_ShapeHierarchy& theCompsolidHierarchy,
84 const GeomShapePtr& theCompsolid,
85 const ListOfShape& theTools,
86 const ListOfShape& thePlanes,
88 std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
89 ListOfShape& theResultShapesList,
90 GeomShapePtr theResulCompound = GeomShapePtr());
92 /// Perform Boolean operation of the Compound with the tools
93 /// In case of theResultCompound is not empty, the result of Boolean operation
94 /// is added to this compound, and corresponding ResultBody is not generated.
95 /// \return \c false if something went wrong
96 bool processCompound(const GeomAlgoAPI_Tools::BOPType theBooleanType,
97 GeomAPI_ShapeHierarchy& theCompoundHierarchy,
98 const GeomShapePtr& theCompound,
99 const ListOfShape& theTools,
101 std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
102 ListOfShape& theResultShapesList,
103 GeomShapePtr theResulCompound = GeomShapePtr());
105 /// Resize planes to fit them to the bounding box of the given lins of objects.
106 static void resizePlanes(const ListOfShape& theObjects,
107 ListOfShape& thePlanes,
108 std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList);
110 /// Process unused sub-shapes of compounds.
111 /// Keep the compound hierarchy, but merge top-level compounds
112 /// into a single compound and add the result of the FUSE operation.
113 GeomShapePtr keepUnusedSubsOfCompound(
114 const GeomShapePtr& theResult,
115 const GeomAPI_ShapeHierarchy& theObjectsHierarchy,
116 const GeomAPI_ShapeHierarchy& theToolsHierarchy,
117 std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList);