0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BOPDS / BOPDS_SubIterator.hxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #ifndef _BOPDS_SubIterator_HeaderFile
16 #define _BOPDS_SubIterator_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
21
22 #include <BOPDS_PDS.hxx>
23 #include <BOPDS_VectorOfPair.hxx>
24 #include <NCollection_BaseAllocator.hxx>
25 #include <TColStd_ListOfInteger.hxx>
26 #include <Standard_Integer.hxx>
27
28
29 //! The class BOPDS_SubIterator is used to compute intersections between
30 //! bounding boxes of two sub-sets of BRep sub-shapes of arguments
31 //! of an operation (see the class BOPDS_DS).
32 //! The class provides interface to iterate the pairs of intersected sub-shapes.
33
34 class BOPDS_SubIterator 
35 {
36 public:
37
38   DEFINE_STANDARD_ALLOC
39
40   //! Empty constructor
41   Standard_EXPORT BOPDS_SubIterator();
42   Standard_EXPORT virtual ~BOPDS_SubIterator();
43
44   //! Constructor
45   //! theAllocator - the allocator to manage the memory
46   Standard_EXPORT BOPDS_SubIterator(const Handle(NCollection_BaseAllocator)& theAllocator);
47
48   //! Sets the data structure <pDS> to process.
49   //! It is used to access the shapes and their bounding boxes.
50   void SetDS (const BOPDS_PDS& pDS)
51   {
52     myDS = pDS;
53   }
54
55   //! Returns the data structure
56   const BOPDS_DS& DS() const
57   {
58     return *myDS;
59   }
60
61   //! Sets the first set of indices <theLI> to process
62   void SetSubSet1 (const TColStd_ListOfInteger& theLI)
63   {
64     mySubSet1 = (TColStd_ListOfInteger*)&theLI;
65   }
66
67   //! Returns the first set of indices to process
68   const TColStd_ListOfInteger& SubSet1() const
69   {
70     return *mySubSet1;
71   }
72
73   //! Sets the second set of indices <theLI> to process
74   void SetSubSet2 (const TColStd_ListOfInteger& theLI)
75   {
76     mySubSet2 = (TColStd_ListOfInteger*)&theLI;
77   }
78
79   //! Returns the second set of indices to process
80   const TColStd_ListOfInteger& SubSet2() const
81   {
82     return *mySubSet2;
83   }
84
85   //! Initializes the iterator
86   Standard_EXPORT void Initialize();
87
88   //! Returns true if there are more pairs of intersected shapes
89   Standard_Boolean More() const
90   {
91     return myIterator.More();
92   }
93
94   //! Moves iterations ahead
95   void Next()
96   {
97     myIterator.Next();
98   }
99
100   //! Returns indices (DS) of intersected shapes
101   //! theIndex1 - the index of the first shape
102   //! theIndex2 - the index of the second shape
103   Standard_EXPORT void Value (Standard_Integer& theIndex1, Standard_Integer& theIndex2) const;
104
105   //! Perform the intersection algorithm and prepare
106   //! the results to be used
107   Standard_EXPORT virtual void Prepare();
108
109   //! Returns the number of interfering pairs
110   Standard_Integer ExpectedLength() const
111   {
112     return myList.Length();
113   }
114
115 protected:
116
117   //! Performs intersection of bounding boxes
118   Standard_EXPORT virtual void Intersect();
119
120   Handle(NCollection_BaseAllocator) myAllocator;
121   BOPDS_PDS myDS;
122   BOPDS_VectorOfPair myList;
123   BOPDS_VectorOfPair::Iterator myIterator;
124   TColStd_ListOfInteger* mySubSet1;
125   TColStd_ListOfInteger* mySubSet2;
126
127 private:
128
129 };
130
131 #endif // _BOPDS_SubIterator_HeaderFile