Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 09:15:08

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 _BOPDS_Iterator_HeaderFile
0019 #define _BOPDS_Iterator_HeaderFile
0020 
0021 #include <Standard.hxx>
0022 #include <Standard_DefineAlloc.hxx>
0023 #include <Standard_Handle.hxx>
0024 
0025 #include <Standard_Integer.hxx>
0026 #include <BOPDS_PDS.hxx>
0027 #include <NCollection_DynamicArray.hxx>
0028 #include <BOPDS_Pair.hxx>
0029 #include <BOPTools_BoxTree.hxx>
0030 #include <NCollection_BaseAllocator.hxx>
0031 #include <Precision.hxx>
0032 #include <TopAbs_ShapeEnum.hxx>
0033 class IntTools_Context;
0034 
0035 //! The class BOPDS_Iterator is
0036 //! 1.to compute intersections between BRep sub-shapes
0037 //! of arguments of an operation (see the class BOPDS_DS)
0038 //! in terms of theirs bounding boxes
0039 //! 2.provides interface to iterate the pairs of
0040 //! intersected sub-shapes of given type
0041 class BOPDS_Iterator
0042 {
0043 public:
0044   DEFINE_STANDARD_ALLOC
0045 
0046   //! Empty constructor
0047   Standard_EXPORT BOPDS_Iterator();
0048   Standard_EXPORT virtual ~BOPDS_Iterator();
0049 
0050   //! Constructor
0051   //! @param theAllocator the allocator to manage the memory
0052   Standard_EXPORT BOPDS_Iterator(const occ::handle<NCollection_BaseAllocator>& theAllocator);
0053 
0054   //! Modifier
0055   //! Sets the data structure <pDS> to process
0056   Standard_EXPORT void SetDS(const BOPDS_PDS& pDS);
0057 
0058   //! Selector
0059   //! Returns the data structure
0060   Standard_EXPORT const BOPDS_DS& DS() const;
0061 
0062   //! Initializes the iterator
0063   //! theType1 - the first type of shape
0064   //! theType2 - the second type of shape
0065   Standard_EXPORT void Initialize(const TopAbs_ShapeEnum theType1, const TopAbs_ShapeEnum theType2);
0066 
0067   //! Returns true if still there are pairs
0068   //! of intersected shapes
0069   Standard_EXPORT bool More() const;
0070 
0071   //! Moves iterations ahead
0072   Standard_EXPORT void Next();
0073 
0074   //! Returns indices (DS) of intersected shapes
0075   //! theIndex1 - the index of the first shape
0076   //! theIndex2 - the index of the second shape
0077   Standard_EXPORT void Value(int& theIndex1, int& theIndex2) const;
0078 
0079   //! Perform the intersection algorithm and prepare
0080   //! the results to be used
0081   Standard_EXPORT virtual void Prepare(
0082     const occ::handle<IntTools_Context>& theCtx        = occ::handle<IntTools_Context>(),
0083     const bool                           theCheckOBB   = false,
0084     const double                         theFuzzyValue = Precision::Confusion());
0085 
0086   //! Updates the tree of Bounding Boxes with increased boxes and
0087   //! intersects such elements with the tree.
0088   Standard_EXPORT void IntersectExt(const NCollection_Map<int>& theIndicies);
0089 
0090   //! Returns the number of intersections founded
0091   Standard_EXPORT int ExpectedLength() const;
0092 
0093   //! Returns the block length
0094   Standard_EXPORT int BlockLength() const;
0095 
0096   //! Set the flag of parallel processing
0097   //! if <theFlag> is true  the parallel processing is switched on
0098   //! if <theFlag> is false the parallel processing is switched off
0099   Standard_EXPORT void SetRunParallel(const bool theFlag);
0100 
0101   //! Returns the flag of parallel processing
0102   Standard_EXPORT bool RunParallel() const;
0103 
0104 public: //! @name Number of extra interfering types
0105   // Extra lists contain only V/V, V/E, V/F interfering pairs.
0106   // Although E/E is also initialized (but never filled) for code simplicity.
0107   static int NbExtInterfs() { return 4; }
0108 
0109 protected: //! @name Protected methods for bounding boxes intersection
0110   //! Intersects the Bounding boxes of sub-shapes of the arguments with the tree
0111   //! and saves the interfering pairs for further geometrical intersection.
0112   Standard_EXPORT virtual void Intersect(
0113     const occ::handle<IntTools_Context>& theCtx        = occ::handle<IntTools_Context>(),
0114     const bool                           theCheckOBB   = false,
0115     const double                         theFuzzyValue = Precision::Confusion());
0116 
0117 protected:                                            //! @name Fields
0118   occ::handle<NCollection_BaseAllocator> myAllocator; //!< Allocator
0119   int                                    myLength;    //!< Length of the intersection vector of
0120                                                       //! particular intersection type
0121   BOPDS_PDS myDS;                                     //!< Data Structure
0122   NCollection_DynamicArray<NCollection_DynamicArray<BOPDS_Pair>>
0123                                                  myLists; //!< Pairs with interfering bounding boxes
0124   NCollection_DynamicArray<BOPDS_Pair>::Iterator myIterator; //!< Iterator on each interfering type
0125   bool                                           myRunParallel; //!< Flag for parallel processing
0126   NCollection_DynamicArray<NCollection_DynamicArray<BOPDS_Pair>>
0127     myExtLists;  //!< Extra pairs of sub-shapes found after
0128                  //! intersection of increased sub-shapes
0129   bool myUseExt; //!< Information flag for using the extra lists
0130 };
0131 
0132 #endif // _BOPDS_Iterator_HeaderFile