Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-03 09:15:17

0001 // Created by: Peter KURNEV
0002 // Copyright (c) 2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _BRepAlgoAPI_BuilderAlgo_HeaderFile
0016 #define _BRepAlgoAPI_BuilderAlgo_HeaderFile
0017 
0018 #include <Standard.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 #include <Standard_Handle.hxx>
0021 
0022 #include <BOPAlgo_GlueEnum.hxx>
0023 #include <BOPAlgo_PPaveFiller.hxx>
0024 #include <BOPAlgo_PBuilder.hxx>
0025 #include <BRepAlgoAPI_Algo.hxx>
0026 #include <BRepTools_History.hxx>
0027 #include <Precision.hxx>
0028 #include <Standard_Real.hxx>
0029 #include <TopoDS_Shape.hxx>
0030 #include <NCollection_List.hxx>
0031 
0032 //! The class contains API level of the General Fuse algorithm.
0033 //!
0034 //! Additionally to the options defined in the base class, the algorithm has
0035 //! the following options:
0036 //! - *Safe processing mode* - allows to avoid modification of the input
0037 //!                            shapes during the operation (by default it is off);
0038 //! - *Gluing options* - allows to speed up the calculation of the intersections
0039 //!                      on the special cases, in which some sub-shapes are coinciding.
0040 //! - *Disabling the check for inverted solids* - Disables/Enables the check of the input solids
0041 //!                          for inverted status (holes in the space). The default value is TRUE,
0042 //!                          i.e. the check is performed. Setting this flag to FALSE for inverted
0043 //!                          solids, most likely will lead to incorrect results.
0044 //! - *Disabling history collection* - allows disabling the collection of the history
0045 //!                                    of shapes modifications during the operation.
0046 //!
0047 //! It returns the following Error statuses:
0048 //! - 0 - in case of success;
0049 //! - *BOPAlgo_AlertTooFewArguments* - in case there are no enough arguments to perform the
0050 //! operation;
0051 //! - *BOPAlgo_AlertIntersectionFailed* - in case the intersection of the arguments has failed;
0052 //! - *BOPAlgo_AlertBuilderFailed* - in case building of the result shape has failed.
0053 //!
0054 //! Warnings statuses from underlying DS Filler and Builder algorithms
0055 //! are collected in the report.
0056 //!
0057 //! The class provides possibility to simplify the resulting shape by unification
0058 //! of the tangential edges and faces. It is performed by the method *SimplifyResult*.
0059 //! See description of this method for more details.
0060 //!
0061 class BRepAlgoAPI_BuilderAlgo : public BRepAlgoAPI_Algo
0062 {
0063 public:
0064   DEFINE_STANDARD_ALLOC
0065 
0066 public: //! @name Constructors
0067   //! Empty constructor
0068   Standard_EXPORT BRepAlgoAPI_BuilderAlgo();
0069   Standard_EXPORT ~BRepAlgoAPI_BuilderAlgo() override;
0070 
0071   //! Constructor with prepared Filler object
0072   Standard_EXPORT BRepAlgoAPI_BuilderAlgo(const BOPAlgo_PaveFiller& thePF);
0073 
0074   //! Copy constructor is not allowed
0075   BRepAlgoAPI_BuilderAlgo(const BRepAlgoAPI_BuilderAlgo&) = delete;
0076 
0077   //! Move constructor is not allowed
0078   BRepAlgoAPI_BuilderAlgo(BRepAlgoAPI_BuilderAlgo&&) = delete;
0079 
0080   //! Copy assignment is not allowed
0081   BRepAlgoAPI_BuilderAlgo& operator=(const BRepAlgoAPI_BuilderAlgo&) = delete;
0082 
0083   //! Move assignment is not allowed
0084   BRepAlgoAPI_BuilderAlgo& operator=(BRepAlgoAPI_BuilderAlgo&&) = delete;
0085 
0086 public: //! @name Setting/Getting data for the algorithm
0087   //! Sets the arguments
0088   void SetArguments(const NCollection_List<TopoDS_Shape>& theLS) { myArguments = theLS; }
0089 
0090   //! Gets the arguments
0091   const NCollection_List<TopoDS_Shape>& Arguments() const { return myArguments; }
0092 
0093 public: //! @name Setting options
0094   //! Sets the flag that defines the mode of treatment.
0095   //! In non-destructive mode the argument shapes are not modified. Instead
0096   //! a copy of a sub-shape is created in the result if it is needed to be updated.
0097   void SetNonDestructive(const bool theFlag) { myNonDestructive = theFlag; }
0098 
0099   //! Returns the flag that defines the mode of treatment.
0100   //! In non-destructive mode the argument shapes are not modified. Instead
0101   //! a copy of a sub-shape is created in the result if it is needed to be updated.
0102   bool NonDestructive() const { return myNonDestructive; }
0103 
0104   //! Sets the glue option for the algorithm,
0105   //! which allows increasing performance of the intersection
0106   //! of the input shapes.
0107   void SetGlue(const BOPAlgo_GlueEnum theGlue) { myGlue = theGlue; }
0108 
0109   //! Returns the glue option of the algorithm
0110   BOPAlgo_GlueEnum Glue() const { return myGlue; }
0111 
0112   //! Enables/Disables the check of the input solids for inverted status
0113   void SetCheckInverted(const bool theCheck) { myCheckInverted = theCheck; }
0114 
0115   //! Returns the flag defining whether the check for input solids on inverted status
0116   //! should be performed or not.
0117   bool CheckInverted() const { return myCheckInverted; }
0118 
0119 public: //! @name Performing the operation
0120   //! Performs the algorithm
0121   Standard_EXPORT void Build(
0122     const Message_ProgressRange& theRange = Message_ProgressRange()) override;
0123 
0124 public: //! @name Result simplification
0125   //! Simplification of the result shape is performed by the means of
0126   //! *ShapeUpgrade_UnifySameDomain* algorithm. The result of the operation will
0127   //! be overwritten with the simplified result.
0128   //!
0129   //! The simplification is performed without creation of the Internal shapes,
0130   //! i.e. shapes connections will never be broken.
0131   //!
0132   //! Simplification is performed on the whole result shape. Thus, if the input
0133   //! shapes contained connected tangent edges or faces unmodified during the operation
0134   //! they will also be unified.
0135   //!
0136   //! After simplification, the History of result simplification is merged into the main
0137   //! history of operation. So, it is taken into account when asking for Modified,
0138   //! Generated and Deleted shapes.
0139   //!
0140   //! Some options of the main operation are passed into the Unifier:
0141   //! - Fuzzy tolerance of the operation is given to the Unifier as the linear tolerance.
0142   //! - Non destructive mode here controls the safe input mode in Unifier.
0143   //!
0144   //! @param theUnifyEdges Controls the edges unification. TRUE by default.
0145   //! @param theUnifyFaces Controls the faces unification. TRUE by default.
0146   //! @param theAngularTol Angular criteria for tangency of edges and faces.
0147   //!                      Precision::Angular() by default.
0148   Standard_EXPORT void SimplifyResult(const bool   theUnifyEdges = true,
0149                                       const bool   theUnifyFaces = true,
0150                                       const double theAngularTol = Precision::Angular());
0151 
0152 public: //! @name History support
0153   //! Returns the shapes modified from the shape <theS>.
0154   //! If any, the list will contain only those splits of the
0155   //! given shape, contained in the result.
0156   Standard_EXPORT const NCollection_List<TopoDS_Shape>& Modified(const TopoDS_Shape& theS) override;
0157 
0158   //! Returns the list of shapes generated from the shape <theS>.
0159   //! In frames of Boolean Operations algorithms only Edges and Faces
0160   //! could have Generated elements, as only they produce new elements
0161   //! during intersection:
0162   //! - Edges can generate new vertices;
0163   //! - Faces can generate new edges and vertices.
0164   Standard_EXPORT const NCollection_List<TopoDS_Shape>& Generated(
0165     const TopoDS_Shape& theS) override;
0166 
0167   //! Checks if the shape <theS> has been completely removed from the result,
0168   //! i.e. the result does not contain the shape itself and any of its splits.
0169   //! Returns TRUE if the shape has been deleted.
0170   Standard_EXPORT bool IsDeleted(const TopoDS_Shape& aS) override;
0171 
0172   //! Returns true if any of the input shapes has been modified during operation.
0173   Standard_EXPORT virtual bool HasModified() const;
0174 
0175   //! Returns true if any of the input shapes has generated shapes during operation.
0176   Standard_EXPORT virtual bool HasGenerated() const;
0177 
0178   //! Returns true if any of the input shapes has been deleted during operation.
0179   //! Normally, General Fuse operation should not have Deleted elements,
0180   //! but all derived operation can have.
0181   Standard_EXPORT virtual bool HasDeleted() const;
0182 
0183 public: //! @name Enabling/Disabling the history collection.
0184   //! Allows disabling the history collection
0185   void SetToFillHistory(const bool theHistFlag) { myFillHistory = theHistFlag; }
0186 
0187   //! Returns flag of history availability
0188   bool HasHistory() const { return myFillHistory; }
0189 
0190 public: //! @name Getting the section edges
0191   //! Returns a list of section edges.
0192   //! The edges represent the result of intersection between arguments of operation.
0193   Standard_EXPORT const NCollection_List<TopoDS_Shape>& SectionEdges();
0194 
0195 public: //! @name Getting tools performing the job
0196   //! Returns the Intersection tool
0197   const BOPAlgo_PPaveFiller& DSFiller() const { return myDSFiller; }
0198 
0199   //! Returns the Building tool
0200   const BOPAlgo_PBuilder& Builder() const { return myBuilder; }
0201 
0202   //! History tool
0203   occ::handle<BRepTools_History> History() const { return myFillHistory ? myHistory : nullptr; }
0204 
0205 protected: //! @name Setting options to the Intersection tool
0206   //! Sets options (available in child classes) for the intersection tool.
0207   //! Here it does nothing.
0208   virtual void SetAttributes() {}
0209 
0210 protected: //! @name Protected methods for shapes intersection and building result
0211   //! Intersects the given shapes with the intersection tool
0212   Standard_EXPORT void IntersectShapes(const NCollection_List<TopoDS_Shape>& theArgs,
0213                                        const Message_ProgressRange&          theRange);
0214 
0215   //! Builds the resulting shape
0216   Standard_EXPORT void BuildResult(const Message_ProgressRange& theRange = Message_ProgressRange());
0217 
0218 protected: //! @name Clearing the contents of the algorithm
0219   //! Clears the algorithm from previous runs
0220   Standard_EXPORT void Clear() override;
0221 
0222 protected: //! @name Fields
0223   // Inputs
0224   NCollection_List<TopoDS_Shape> myArguments; //!< Arguments of the operation
0225 
0226   // Options
0227   bool             myNonDestructive; //!< Non-destructive mode management
0228   BOPAlgo_GlueEnum myGlue;           //!< Gluing mode management
0229   bool             myCheckInverted;  //!< Check for inverted solids management
0230   bool             myFillHistory;    //!< Controls the history collection
0231 
0232   // Tools
0233   bool myIsIntersectionNeeded;              //!< Flag to control whether the intersection
0234                                             //! of arguments should be performed or not
0235   BOPAlgo_PPaveFiller myDSFiller;           //!< Intersection tool performs intersection of the
0236                                             //! argument shapes.
0237   BOPAlgo_PBuilder myBuilder;               //!< Building tool performs construction of the result
0238                                             //! basing on the results of intersection
0239   occ::handle<BRepTools_History> myHistory; //!< General History tool, containing all History of
0240                                             //! shapes modifications during the operation
0241                                             //! (including result simplification)
0242   occ::handle<BRepTools_History> mySimplifierHistory; //!< History of result shape simplification
0243 };
0244 
0245 #endif // _BRepAlgoAPI_BuilderAlgo_HeaderFile