1 // Created on: 1993-10-14
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _BRepAlgoAPI_BooleanOperation_HeaderFile
18 #define _BRepAlgoAPI_BooleanOperation_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <BOPAlgo_Operation.hxx>
25 #include <BRepAlgoAPI_BuilderAlgo.hxx>
26 class BOPAlgo_PaveFiller;
29 //! The root API class for performing Boolean Operations on arbitrary shapes.
31 //! The arguments of the operation are divided in two groups - *Objects* and *Tools*.
32 //! Each group can contain any number of shapes, but each shape should be valid
33 //! in terms of *BRepCheck_Analyzer* and *BOPAlgo_ArgumentAnalyzer*.
34 //! The algorithm builds the splits of the given arguments using the intersection
35 //! results and combines the result of Boolean Operation of given type:
36 //! - *FUSE* - union of two groups of objects;
37 //! - *COMMON* - intersection of two groups of objects;
38 //! - *CUT* - subtraction of one group from the other;
39 //! - *SECTION* - section edges and vertices of all arguments;
41 //! The rules for the arguments and type of the operation are the following:
42 //! - For Boolean operation *FUSE* all arguments should have equal dimensions;
43 //! - For Boolean operation *CUT* the minimal dimension of *Tools* should not be
44 //! less than the maximal dimension of *Objects*;
45 //! - For Boolean operation *COMMON* the arguments can have any dimension.
46 //! - For Boolean operation *SECTION* the arguments can be of any type.
48 //! Additionally to the errors of the base class the algorithm returns
49 //! the following Errors:<br>
50 //! - *BOPAlgo_AlertBOPNotSet* - in case the type of Boolean Operation is not set.<br>
51 class BRepAlgoAPI_BooleanOperation : public BRepAlgoAPI_BuilderAlgo
57 public: //! @name Constructors
60 Standard_EXPORT BRepAlgoAPI_BooleanOperation();
62 //! Constructor with precomputed intersections of arguments.
63 Standard_EXPORT BRepAlgoAPI_BooleanOperation(const BOPAlgo_PaveFiller& thePF);
66 public: //! @name Setting/getting arguments
68 //! Returns the first argument involved in this Boolean operation.
70 const TopoDS_Shape& Shape1() const
72 return myArguments.First();
75 //! Returns the second argument involved in this Boolean operation.
77 const TopoDS_Shape& Shape2() const
79 return myTools.First();
82 //! Sets the Tool arguments
83 void SetTools(const TopTools_ListOfShape& theLS)
88 //! Returns the Tools arguments
89 const TopTools_ListOfShape& Tools() const
95 public: //! @name Setting/Getting the type of Boolean operation
97 //! Sets the type of Boolean operation
98 void SetOperation(const BOPAlgo_Operation theBOP)
100 myOperation = theBOP;
103 //! Returns the type of Boolean Operation
104 BOPAlgo_Operation Operation() const
110 public: //! @name Performing the operation
112 //! Performs the Boolean operation.
113 Standard_EXPORT virtual void Build() Standard_OVERRIDE;
116 protected: //! @name Constructors
118 //! Constructor to perform Boolean operation on only two arguments.
120 Standard_EXPORT BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& theS1,
121 const TopoDS_Shape& theS2,
122 const BOPAlgo_Operation theOperation);
124 //! Constructor to perform Boolean operation on only two arguments
125 //! with precomputed intersection results.
127 Standard_EXPORT BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& theS1,
128 const TopoDS_Shape& theS2,
129 const BOPAlgo_PaveFiller& thePF,
130 const BOPAlgo_Operation theOperation);
133 protected: //! @name Fields
135 TopTools_ListOfShape myTools; //!< Tool arguments of operation
136 BOPAlgo_Operation myOperation; //!< Type of Boolean Operation
140 #endif // _BRepAlgoAPI_BooleanOperation_HeaderFile