File indexing completed on 2025-10-30 08:46:26
0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 
0012 
0013 
0014 
0015 #ifndef _BOPAlgo_Tools_HeaderFile
0016 #define _BOPAlgo_Tools_HeaderFile
0017 
0018 #include <Standard.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 
0021 #include <BOPDS_IndexedDataMapOfPaveBlockListOfInteger.hxx>
0022 #include <BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock.hxx>
0023 #include <BOPDS_PDS.hxx>
0024 #include <NCollection_BaseAllocator.hxx>
0025 #include <TopTools_DataMapOfShapeBox.hxx>
0026 #include <TopTools_DataMapOfShapeListOfShape.hxx>
0027 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
0028 #include <TopTools_IndexedDataMapOfShapeReal.hxx>
0029 #include <TopTools_ListOfListOfShape.hxx>
0030 #include <TopTools_ListOfShape.hxx>
0031 #include <TopTools_MapOfShape.hxx>
0032 #include <Standard_Integer.hxx>
0033 #include <Message_ProgressRange.hxx>
0034 
0035 class BOPDS_PaveBlock;
0036 class BOPDS_CommonBlock;
0037 class IntTools_Context;
0038 class TopoDS_Shape;
0039 
0040 
0041 class BOPAlgo_Tools
0042 {
0043 public:
0044 
0045   
0046   template <class TheMap, class TheList>
0047   static void MakeBlocks(const TheMap& theMILI,
0048                          TheList& theMBlocks,
0049                          const Handle(NCollection_BaseAllocator)& theAllocator)
0050   {
0051     NCollection_Map<typename TheMap::key_type, typename TheMap::hasher> aMFence;
0052     Standard_Integer i, aNb = theMILI.Extent();
0053     for (i = 1; i <= aNb; ++i) {
0054       const typename TheMap::key_type& n = theMILI.FindKey(i);
0055       if (!aMFence.Add(n))
0056         continue;
0057       
0058       
0059       typename TheList::value_type& aChain = theMBlocks.Append(typename TheList::value_type(theAllocator));
0060       aChain.Append(n);
0061       
0062       typename TheList::value_type::Iterator aItLChain(aChain);
0063       for (; aItLChain.More(); aItLChain.Next()) {
0064         const typename TheMap::key_type& n1 = aItLChain.Value();
0065         const typename TheList::value_type& aLI = theMILI.FindFromKey(n1);
0066         
0067         typename TheList::value_type::Iterator aItLI(aLI);
0068         for (; aItLI.More(); aItLI.Next()) {
0069           const typename TheMap::key_type& n2 = aItLI.Value();
0070           if (aMFence.Add(n2)) {
0071             aChain.Append(n2);
0072           }
0073         }
0074       }
0075     }
0076   }
0077 
0078   
0079   template <class TheType, class TheMap>
0080   static void FillMap(const TheType& n1,
0081                       const TheType& n2,
0082                       TheMap& theMILI,
0083                       const Handle(NCollection_BaseAllocator)& theAllocator)
0084   {
0085     typename TheMap::value_type *pList1 = theMILI.ChangeSeek(n1);
0086     if (!pList1) {
0087       pList1 = &theMILI(theMILI.Add(n1, NCollection_List<TheType>(theAllocator)));
0088     }
0089     pList1->Append(n2);
0090     
0091     typename TheMap::value_type*pList2 = theMILI.ChangeSeek(n2);
0092     if (!pList2) {
0093       pList2 = &theMILI(theMILI.Add(n2, typename TheMap::value_type(theAllocator)));
0094     }
0095     pList2->Append(n1);
0096   }
0097 
0098   Standard_EXPORT static void FillMap(const Handle(BOPDS_PaveBlock)& thePB1,
0099                                       const Standard_Integer theF,
0100                                       BOPDS_IndexedDataMapOfPaveBlockListOfInteger& theMILI,
0101                                       const Handle(NCollection_BaseAllocator)& theAllocator);
0102 
0103   
0104   
0105   Standard_EXPORT static void PerformCommonBlocks(BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock& theMBlocks,
0106                                                   const Handle(NCollection_BaseAllocator)& theAllocator,
0107                                                   BOPDS_PDS& theDS,
0108                                                   const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
0109 
0110   
0111   Standard_EXPORT static void PerformCommonBlocks(const BOPDS_IndexedDataMapOfPaveBlockListOfInteger& theMBlocks,
0112                                                   const Handle(NCollection_BaseAllocator)& theAllocator,
0113                                                   BOPDS_PDS& pDS,
0114                                                   const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)());
0115 
0116   Standard_EXPORT static Standard_Real ComputeToleranceOfCB
0117                                         (const Handle(BOPDS_CommonBlock)& theCB,
0118                                          const BOPDS_PDS theDS,
0119                                          const Handle(IntTools_Context)& theContext);
0120 
0121   
0122   
0123   
0124   
0125   
0126   
0127   
0128   
0129   
0130   
0131   
0132   
0133   
0134   
0135   
0136   
0137   
0138   
0139   
0140   Standard_EXPORT static Standard_Integer EdgesToWires(const TopoDS_Shape& theEdges,
0141                                                        TopoDS_Shape& theWires,
0142                                                        const Standard_Boolean theShared = Standard_False,
0143                                                        const Standard_Real theAngTol = 1.e-8);
0144 
0145   
0146   
0147   
0148   
0149   
0150   
0151   
0152   
0153   
0154   
0155   
0156   
0157   
0158   
0159   Standard_EXPORT static Standard_Boolean WiresToFaces(const TopoDS_Shape& theWires,
0160                                                        TopoDS_Shape& theFaces,
0161                                                        const Standard_Real theAngTol = 1.e-8);
0162 
0163   
0164   Standard_EXPORT static void IntersectVertices(const TopTools_IndexedDataMapOfShapeReal& theVertices,
0165                                                 const Standard_Real theFuzzyValue,
0166                                                 TopTools_ListOfListOfShape& theChains);
0167 
0168   
0169   
0170   
0171   
0172   
0173   
0174   
0175   
0176   
0177   
0178   
0179   
0180   
0181   Standard_EXPORT static void ClassifyFaces(const TopTools_ListOfShape& theFaces,
0182                                             const TopTools_ListOfShape& theSolids,
0183                                             const Standard_Boolean theRunParallel,
0184                                             Handle(IntTools_Context)& theContext,
0185                                             TopTools_IndexedDataMapOfShapeListOfShape& theInParts,
0186                                             const TopTools_DataMapOfShapeBox& theShapeBoxMap = TopTools_DataMapOfShapeBox(),
0187                                             const TopTools_DataMapOfShapeListOfShape& theSolidsIF = TopTools_DataMapOfShapeListOfShape(),
0188                                             const Message_ProgressRange& theRange = Message_ProgressRange());
0189 
0190   
0191   
0192   
0193   
0194   
0195   
0196   
0197   Standard_EXPORT static void FillInternals(const TopTools_ListOfShape& theSolids,
0198                                             const TopTools_ListOfShape& theParts,
0199                                             const TopTools_DataMapOfShapeListOfShape& theImages,
0200                                             const Handle(IntTools_Context)& theContext);
0201 
0202   
0203   
0204   
0205   
0206   
0207   
0208   
0209   
0210   
0211   Standard_EXPORT static Standard_Boolean TrsfToPoint (const Bnd_Box& theBox1,
0212                                                        const Bnd_Box& theBox2,
0213                                                        gp_Trsf&       theTrsf,
0214                                                        const gp_Pnt&  thePoint = gp_Pnt (0.0, 0.0, 0.0),
0215                                                        const Standard_Real theCriteria = 1.e+5);
0216 };
0217 
0218 #endif