Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:19:05

0001 // Created by: Peter KURNEV
0002 // Copyright (c) 1999-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 _BOPDS_SubIterator_HeaderFile
0016 #define _BOPDS_SubIterator_HeaderFile
0017 
0018 #include <Standard.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 #include <Standard_Handle.hxx>
0021 
0022 #include <BOPDS_PDS.hxx>
0023 #include <NCollection_DynamicArray.hxx>
0024 #include <BOPDS_Pair.hxx>
0025 #include <NCollection_BaseAllocator.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <NCollection_List.hxx>
0028 
0029 //! The class BOPDS_SubIterator is used to compute intersections between
0030 //! bounding boxes of two sub-sets of BRep sub-shapes of arguments
0031 //! of an operation (see the class BOPDS_DS).
0032 //! The class provides interface to iterate the pairs of intersected sub-shapes.
0033 
0034 class BOPDS_SubIterator
0035 {
0036 public:
0037   DEFINE_STANDARD_ALLOC
0038 
0039   //! Empty constructor
0040   Standard_EXPORT BOPDS_SubIterator();
0041   Standard_EXPORT virtual ~BOPDS_SubIterator();
0042 
0043   //! Constructor
0044   //! theAllocator - the allocator to manage the memory
0045   Standard_EXPORT BOPDS_SubIterator(const occ::handle<NCollection_BaseAllocator>& theAllocator);
0046 
0047   //! Sets the data structure <pDS> to process.
0048   //! It is used to access the shapes and their bounding boxes.
0049   void SetDS(const BOPDS_PDS& pDS) { myDS = pDS; }
0050 
0051   //! Returns the data structure
0052   const BOPDS_DS& DS() const { return *myDS; }
0053 
0054   //! Sets the first set of indices <theLI> to process
0055   void SetSubSet1(const NCollection_List<int>& theLI)
0056   {
0057     mySubSet1 = (NCollection_List<int>*)&theLI;
0058   }
0059 
0060   //! Returns the first set of indices to process
0061   const NCollection_List<int>& SubSet1() const { return *mySubSet1; }
0062 
0063   //! Sets the second set of indices <theLI> to process
0064   void SetSubSet2(const NCollection_List<int>& theLI)
0065   {
0066     mySubSet2 = (NCollection_List<int>*)&theLI;
0067   }
0068 
0069   //! Returns the second set of indices to process
0070   const NCollection_List<int>& SubSet2() const { return *mySubSet2; }
0071 
0072   //! Initializes the iterator
0073   Standard_EXPORT void Initialize();
0074 
0075   //! Returns true if there are more pairs of intersected shapes
0076   bool More() const { return myIterator.More(); }
0077 
0078   //! Moves iterations ahead
0079   void Next() { myIterator.Next(); }
0080 
0081   //! Returns indices (DS) of intersected shapes
0082   //! theIndex1 - the index of the first shape
0083   //! theIndex2 - the index of the second shape
0084   Standard_EXPORT void Value(int& theIndex1, int& theIndex2) const;
0085 
0086   //! Perform the intersection algorithm and prepare
0087   //! the results to be used
0088   Standard_EXPORT virtual void Prepare();
0089 
0090   //! Returns the number of interfering pairs
0091   int ExpectedLength() const { return myList.Length(); }
0092 
0093 protected:
0094   //! Performs intersection of bounding boxes
0095   Standard_EXPORT virtual void Intersect();
0096 
0097   occ::handle<NCollection_BaseAllocator>         myAllocator;
0098   BOPDS_PDS                                      myDS;
0099   NCollection_DynamicArray<BOPDS_Pair>           myList;
0100   NCollection_DynamicArray<BOPDS_Pair>::Iterator myIterator;
0101   NCollection_List<int>*                         mySubSet1;
0102   NCollection_List<int>*                         mySubSet2;
0103 };
0104 
0105 #endif // _BOPDS_SubIterator_HeaderFile