SHAPER  9.12.0
FeaturesPlugin_CompositeBoolean.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef FeaturesPlugin_CompositeBoolean_H_
21 #define FeaturesPlugin_CompositeBoolean_H_
22 
23 #include "FeaturesPlugin.h"
24 
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_ResultBody.h>
27 #include <GeomAlgoAPI_MakeShape.h>
28 #include <GeomAlgoAPI_MakeShapeList.h>
29 
34 {
35 public:
36  enum OperationType {
37  BOOL_CUT,
38  BOOL_FUSE,
39  BOOL_COMMON,
40  BOOL_SMASH
41  };
42 
44  inline static const std::string& OBJECTS_ID()
45  {
46  static const std::string MY_OBJECTS_ID("main_objects");
47  return MY_OBJECTS_ID;
48  }
49 
51  FEATURESPLUGIN_EXPORT virtual void executeCompositeBoolean();
52 
53  const OperationType& operationType() const { return myOperationType; }
54 
55 protected:
56  struct ResultBaseAlgo {
57  ResultBodyPtr resultBody;
58  GeomShapePtr baseShape;
59  std::shared_ptr<GeomAlgoAPI_MakeShape> makeShape;
60  };
61 
62 protected:
64 
66  void initBooleanAttributes();
67 
69  virtual bool makeGeneration(ListOfShape& theBaseShapes,
70  ListOfMakeShape& theMakeShapes) = 0;
71 
77  bool makeBoolean(const ListOfShape& theTools,
78  ListOfShape& theObjects,
79  ListOfMakeShape& theMakeShapes);
80 
82  virtual void storeGenerationHistory(ResultBodyPtr theResultBody,
83  const GeomShapePtr theBaseShape,
84  const GeomMakeShapePtr theMakeShape) = 0;
85 
87  void storeModificationHistory(ResultBodyPtr theResultBody,
88  const GeomShapePtr theObject,
89  const ListOfShape& theTools,
90  const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
91 
93  void storeDeletedShapes(std::vector<ResultBaseAlgo>& theResultBaseAlgoList,
94  const ListOfShape& theTools,
95  const GeomShapePtr theResultShapesCompound);
96 
97 private:
105  bool cutRecursiveCompound (const GeomShapePtr theCompound,
106  const ListOfShape& theTools,
107  std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
108  GeomShapePtr& theResult);
109 
116  void addSubShapes (const GeomShapePtr theCompound,
117  const ListOfShape& theSubShapesToAvoid,
118  ListOfShape& theSubShapesToAdd);
119 
120 protected:
121  ModelAPI_Feature* myFeature;
122  OperationType myOperationType;
123 };
124 
125 #endif
Interface for the composite boolean feature.
Definition: FeaturesPlugin_CompositeBoolean.h:34
virtual void storeGenerationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theBaseShape, const GeomMakeShapePtr theMakeShape)=0
Stores generation history.
virtual bool makeGeneration(ListOfShape &theBaseShapes, ListOfMakeShape &theMakeShapes)=0
This function need to be defined for extrusion/revolution generation.
static const std::string & OBJECTS_ID()
Attribute name of main objects.
Definition: FeaturesPlugin_CompositeBoolean.h:44
void initBooleanAttributes()
Initializes boolean attributes.
Definition: FeaturesPlugin_CompositeBoolean.cpp:37
virtual void executeCompositeBoolean()
Performs the algorithm and stores results it in the data structure.
Definition: FeaturesPlugin_CompositeBoolean.cpp:43
bool makeBoolean(const ListOfShape &theTools, ListOfShape &theObjects, ListOfMakeShape &theMakeShapes)
Makes boolean operation.
Definition: FeaturesPlugin_CompositeBoolean.cpp:229
void storeDeletedShapes(std::vector< ResultBaseAlgo > &theResultBaseAlgoList, const ListOfShape &theTools, const GeomShapePtr theResultShapesCompound)
Stores deleted shapes.
Definition: FeaturesPlugin_CompositeBoolean.cpp:555
void storeModificationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theObject, const ListOfShape &theTools, const std::shared_ptr< GeomAlgoAPI_MakeShape > theMakeShape)
Stores modification history.
Definition: FeaturesPlugin_CompositeBoolean.cpp:538
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39
Definition: FeaturesPlugin_CompositeBoolean.h:56