Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:04

0001 // Created by: Eugeny MALTCHIKOV
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 _BOPAlgo_MakerVolume_HeaderFile
0016 #define _BOPAlgo_MakerVolume_HeaderFile
0017 
0018 #include <Standard.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 #include <Standard_Handle.hxx>
0021 
0022 #include <BOPAlgo_Builder.hxx>
0023 #include <Bnd_Box.hxx>
0024 #include <NCollection_BaseAllocator.hxx>
0025 #include <TopoDS_Solid.hxx>
0026 #include <TopTools_ListOfShape.hxx>
0027 #include <TopTools_MapOfShape.hxx>
0028 class BOPAlgo_PaveFiller;
0029 
0030 
0031 
0032 //! The algorithm is to build solids from set of shapes.
0033 //! It uses the BOPAlgo_Builder algorithm to intersect the given shapes
0034 //! and build the images of faces (if needed) and BOPAlgo_BuilderSolid
0035 //! algorithm to build the solids.
0036 //!
0037 //! Steps of the algorithm:
0038 //! 1. Collect all faces: intersect the shapes if necessary and collect
0039 //! the images of faces, otherwise just collect the faces to the
0040 //! <myFaces> list;
0041 //! All faces on this step added twice, with orientation FORWARD
0042 //! and REVERSED;
0043 //!
0044 //! 2. Create bounding box covering all the faces from <myFaces> and
0045 //! create solid box from corner points of that bounding box
0046 //! (myBBox, mySBox). Add faces from that box to <myFaces>;
0047 //!
0048 //! 3. Build solids from <myFaces> using BOPAlgo_BuilderSolid algorithm;
0049 //!
0050 //! 4. Treat the result: Eliminate solid containing faces from <mySBox>;
0051 //!
0052 //! 5. Fill internal shapes: add internal vertices and edges into
0053 //! created solids;
0054 //!
0055 //! 6. Prepare the history.
0056 //!
0057 //! Fields:
0058 //! <myIntersect> - boolean flag. It defines whether intersect shapes
0059 //! from <myArguments> (if set to TRUE) or not (FALSE).
0060 //! The default value is TRUE. By setting it to FALSE
0061 //! the user should guarantee that shapes in <myArguments>
0062 //! do not interfere with each other, otherwise the result
0063 //! is unpredictable.
0064 //!
0065 //! <myBBox>      - bounding box, covering all faces from <myFaces>.
0066 //!
0067 //! <mySBox>      - Solid box created from the corner points of <myBBox>.
0068 //!
0069 //! <myFaces>     - the list is to keep the "final" faces, that will be
0070 //! given to the BOPAlgo_BuilderSolid algorithm.
0071 //! If the shapes have been interfered it should contain
0072 //! the images of the source shapes, otherwise its just
0073 //! the original faces.
0074 //! It also contains the faces from <mySBox>.
0075 //!
0076 //! Fields inherited from BOPAlgo_Builder:
0077 //!
0078 //! <myArguments> - list of the source shapes. The source shapes can have
0079 //! any type, but each shape must not be self-interfered.
0080 //!
0081 //! <myShape>     - Result shape:
0082 //! - empty compound - if no solids were created;
0083 //! - solid - if created only one solid;
0084 //! - compound of solids - if created more than one solid.
0085 //!
0086 //! Fields inherited from BOPAlgo_Algo:
0087 //!
0088 //! <myRunParallel> - Defines whether the parallel processing is
0089 //! switched on or not.
0090 //! <myReport> - Error status of the operation. Additionally to the
0091 //! errors of the parent algorithm it can have the following values:
0092 //! - *BOPAlgo_AlertSolidBuilderFailed* - BOPAlgo_BuilderSolid algorithm has failed.
0093 //!
0094 //! Example:
0095 //!
0096 //! BOPAlgo_MakerVolume aMV;
0097 //! //
0098 //! aMV.SetArguments(aLS); //source shapes
0099 //! aMV.SetRunParallel(bRunParallel); //parallel or single mode
0100 //! aMV.SetIntersect(bIntersect); //intersect or not the shapes from <aLS>
0101 //! //
0102 //! aMV.Perform(); //perform the operation
0103 //! if (aMV.HasErrors()) { //check error status
0104 //!   return;
0105 //! }
0106 //! //
0107 //! const TopoDS_Shape& aResult = aMV.Shape();  //result of the operation
0108 class BOPAlgo_MakerVolume  : public BOPAlgo_Builder
0109 {
0110 public:
0111 
0112   DEFINE_STANDARD_ALLOC
0113 
0114   //! Empty constructor.
0115   BOPAlgo_MakerVolume();
0116   virtual ~BOPAlgo_MakerVolume();
0117 
0118   //! Empty constructor.
0119   BOPAlgo_MakerVolume(const Handle(NCollection_BaseAllocator)& theAllocator);
0120 
0121   //! Clears the data.
0122   virtual void Clear() Standard_OVERRIDE;
0123 
0124   //! Sets the flag myIntersect:
0125   //! if <bIntersect> is TRUE the shapes from <myArguments> will be intersected.
0126   //! if <bIntersect> is FALSE no intersection will be done.
0127   void SetIntersect(const Standard_Boolean bIntersect);
0128 
0129   //! Returns the flag <myIntersect>.
0130   Standard_Boolean IsIntersect() const;
0131 
0132   //! Returns the solid box <mySBox>.
0133   const TopoDS_Solid& Box() const;
0134 
0135   //! Returns the processed faces <myFaces>.
0136   const TopTools_ListOfShape& Faces() const;
0137 
0138   //! Defines the preventing of addition of internal for solid parts into the result.
0139   //! By default the internal parts are added into result.
0140   void SetAvoidInternalShapes(const Standard_Boolean theAvoidInternal) {
0141     myAvoidInternalShapes = theAvoidInternal;
0142   }
0143 
0144   //! Returns the AvoidInternalShapes flag
0145   Standard_Boolean IsAvoidInternalShapes() const {
0146     return myAvoidInternalShapes;
0147   }
0148 
0149   //! Performs the operation.
0150   Standard_EXPORT virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
0151 
0152 protected:
0153 
0154   //! Checks the data.
0155   Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
0156 
0157   //! Performs the operation.
0158   Standard_EXPORT virtual void PerformInternal1 (const BOPAlgo_PaveFiller& thePF, const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
0159 
0160   //! Collects all faces.
0161   Standard_EXPORT void CollectFaces();
0162 
0163   //! Makes solid box.
0164   Standard_EXPORT void MakeBox (TopTools_MapOfShape& theBoxFaces);
0165 
0166   //! Builds solids.
0167   Standard_EXPORT void BuildSolids (TopTools_ListOfShape& theLSR,
0168                                     const Message_ProgressRange& theRange);
0169 
0170   //! Removes the covering box.
0171   Standard_EXPORT void RemoveBox (TopTools_ListOfShape& theLSR, const TopTools_MapOfShape& theBoxFaces);
0172 
0173   //! Fills the solids with internal shapes.
0174   Standard_EXPORT void FillInternalShapes (const TopTools_ListOfShape& theLSR);
0175 
0176   //! Builds the result.
0177   Standard_EXPORT void BuildShape (const TopTools_ListOfShape& theLSR);
0178 
0179 protected:
0180   //! List of operations to be supported by the Progress Indicator.
0181   //! Enumeration is going to contain some extra operations from base class,
0182   //! which are not going to be used here. So, the array of steps will also
0183   //! contain some extra zero values. This is the only extra resource that is
0184   //! going to be used, but it allows us not to override the methods that use
0185   //! the values of the enumeration of base class.
0186   //! Starting the enumeration from the middle of enumeration of base class is
0187   //! not a good idea as the values in enumeration may be swapped.
0188   enum BOPAlgo_PIOperation
0189   {
0190     PIOperation_BuildSolids = BOPAlgo_Builder::PIOperation_Last,
0191     PIOperation_Last
0192   };
0193 
0194   //! Analyze progress steps
0195   Standard_EXPORT void fillPISteps(BOPAlgo_PISteps& theSteps) const Standard_OVERRIDE;
0196 
0197 protected:
0198 
0199   Standard_Boolean myIntersect;
0200   Bnd_Box myBBox;
0201   TopoDS_Solid mySBox;
0202   TopTools_ListOfShape myFaces;
0203   Standard_Boolean myAvoidInternalShapes;
0204 
0205 private:
0206 
0207 };
0208 
0209 #include <BOPAlgo_MakerVolume.lxx>
0210 
0211 #endif // _BOPAlgo_MakerVolume_HeaderFile