Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created by: Peter KURNEV
0002 // Copyright (c) 2010-2014 OPEN CASCADE SAS
0003 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
0004 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
0005 //                         EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
0006 //
0007 // This file is part of Open CASCADE Technology software library.
0008 //
0009 // This library is free software; you can redistribute it and/or modify it under
0010 // the terms of the GNU Lesser General Public License version 2.1 as published
0011 // by the Free Software Foundation, with special exception defined in the file
0012 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0013 // distribution for complete text of the license and disclaimer of any warranty.
0014 //
0015 // Alternatively, this file may be used under the terms of Open CASCADE
0016 // commercial license or contractual agreement.
0017 
0018 #ifndef _BOPAlgo_BuilderSolid_HeaderFile
0019 #define _BOPAlgo_BuilderSolid_HeaderFile
0020 
0021 #include <Standard.hxx>
0022 #include <Standard_DefineAlloc.hxx>
0023 #include <Standard_Handle.hxx>
0024 
0025 #include <BOPAlgo_BuilderArea.hxx>
0026 #include <NCollection_BaseAllocator.hxx>
0027 #include <TopTools_DataMapOfShapeBox.hxx>
0028 
0029 
0030 //! Solid Builder is the algorithm for building solids from set of faces.
0031 //! The given faces should be non-intersecting, i.e. all coinciding parts
0032 //! of the faces should be shared among them.
0033 //!
0034 //! The algorithm performs the following steps to build the solids:
0035 //! 1. Find:
0036 //!    - faces orientated INTERNAL;
0037 //!    - alone faces given twice with different orientation;
0038 //! 2. Build all possible closed shells from the rest of the faces
0039 //!    (*BOPAlgo_ShellSplitter* is used for that);
0040 //! 3. Classify the obtained shells on the Holes and Growths;
0041 //! 4. Build solids from the Growth shells, put Hole shells into closest Growth solids;
0042 //! 5. Classify all unused faces relatively created solids and put them as internal
0043 //!    shells into the closest solids;
0044 //! 6. Find all unclassified faces, i.e. faces outside of all created solids,
0045 //!    make internal shells from them and put these shells into a warning.
0046 //!
0047 //! It is possible to avoid all internal shells in the resulting solids.
0048 //! For that it is necessary to use the method SetAvoidInternalShapes(true)
0049 //! of the base class. In this case the steps 5 and 6 will not be performed at all.
0050 //!
0051 //! The algorithm may return the following warnings:
0052 //! - *BOPAlgo_AlertShellSplitterFailed* in case the ShellSplitter algorithm has failed;
0053 //! - *BOPAlgo_AlertSolidBuilderUnusedFaces* in case there are some faces outside of
0054 //!   created solids left.
0055 //!
0056 //! Example of usage of the algorithm:
0057 //! ~~~~
0058 //! const TopTools_ListOfShape& aFaces = ...;     // Faces to build the solids
0059 //! Standard_Boolean isAvoidInternals = ...;      // Flag which defines whether to create the internal shells or not
0060 //! BOPAlgo_BuilderSolid aBS;                     // Solid Builder tool
0061 //! aBS.SetShapes(aFaces);                        // Set the faces
0062 //! aBS.SetAvoidInternalShapes(isAvoidInternals); // Set the AvoidInternalShapesFlag
0063 //! aBS.Perform();                                // Perform the operation
0064 //! if (!aBS.IsDone())                            // Check for the errors
0065 //! {
0066 //!   // error treatment
0067 //!   Standard_SStream aSStream;
0068 //!   aBS.DumpErrors(aSStream);
0069 //!   return;
0070 //! }
0071 //! if (aBS.HasWarnings())                        // Check for the warnings
0072 //! {
0073 //!   // warnings treatment
0074 //!   Standard_SStream aSStream;
0075 //!   aBS.DumpWarnings(aSStream);
0076 //! }
0077 //!
0078 //! const TopTools_ListOfShape& aSolids = aBS.Areas(); // Obtaining the result solids
0079 //! ~~~~
0080 //!
0081 class BOPAlgo_BuilderSolid  : public BOPAlgo_BuilderArea
0082 {
0083 public:
0084 
0085   DEFINE_STANDARD_ALLOC
0086 
0087 public: //! @name Constructors
0088 
0089   //! Empty constructor
0090   Standard_EXPORT BOPAlgo_BuilderSolid();
0091   Standard_EXPORT virtual ~BOPAlgo_BuilderSolid();
0092 
0093   //! Constructor with allocator
0094   Standard_EXPORT BOPAlgo_BuilderSolid(const Handle(NCollection_BaseAllocator)& theAllocator);
0095 
0096 public: //! @name Performing the operation
0097 
0098   //! Performs the construction of the solids from the given faces
0099   Standard_EXPORT virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
0100 
0101 public: //! @name Getting the bounding boxes of the created solids
0102 
0103   //! For classification purposes the algorithm builds the bounding boxes
0104   //! for all created solids. This method returns the data map of solid - box pairs.
0105   const TopTools_DataMapOfShapeBox& GetBoxesMap() const
0106   {
0107     return myBoxes;
0108   }
0109 
0110 protected: //! @name Protected methods performing the operation
0111 
0112   //! Collect the faces:
0113   //! - with INTERNAL orientation;
0114   //! - that are alone but given twice with different orientation.
0115   //! These faces will be put into the map *myShapesToAvoid* and will be
0116   //! avoided in shells construction, but will be classified later on.
0117   Standard_EXPORT virtual void PerformShapesToAvoid(const Message_ProgressRange& theRange) Standard_OVERRIDE;
0118 
0119   //! Build all possible closed shells from the given faces.
0120   //! The method fills the following maps:
0121   //! - myLoops - Created closed shells;
0122   //! - myLoopsInternal - The shells created from unused faces.
0123   Standard_EXPORT virtual void PerformLoops(const Message_ProgressRange& theRange) Standard_OVERRIDE;
0124 
0125   //! Classifies the created shells on the Holes and Growths.
0126   //! Creates the solids from the Growths shells.
0127   //! Puts the Hole shells into the closest Growths solids.
0128   Standard_EXPORT virtual void PerformAreas(const Message_ProgressRange& theRange) Standard_OVERRIDE;
0129 
0130   //! Classifies the unused faces relatively the created solids.
0131   //! Puts the classified faces into the closest solids as internal shells.
0132   //! Warns the user about unclassified faces if any.
0133   Standard_EXPORT virtual void PerformInternalShapes(const Message_ProgressRange& theRange) Standard_OVERRIDE;
0134 
0135 private:
0136 
0137   TopTools_DataMapOfShapeBox myBoxes; // Boxes of the produced solids
0138 
0139 };
0140 
0141 #endif // _BOPAlgo_BuilderSolid_HeaderFile