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