1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <BOPDS_IteratorSI.ixx>
17 #include <TopAbs_ShapeEnum.hxx>
19 #include <Bnd_Box.hxx>
21 #include <TopoDS_Shape.hxx>
22 #include <TopoDS_Vertex.hxx>
24 #include <BRep_Tool.hxx>
26 #include <NCollection_UBTreeFiller.hxx>
27 #include <NCollection_IncAllocator.hxx>
29 #include <BOPCol_BoxBndTree.hxx>
30 #include <BOPDS_IndexRange.hxx>
31 #include <BOPDS_PassKeyBoolean.hxx>
32 #include <BOPDS_MapOfPassKeyBoolean.hxx>
33 #include <BOPDS_DS.hxx>
35 #include <BOPCol_IndexedDataMapOfShapeBox.hxx>
36 #include <BOPDS_Tools.hxx>
37 #include <BOPCol_DataMapOfShapeInteger.hxx>
38 #include <BOPCol_DataMapOfIntegerInteger.hxx>
39 #include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
40 #include <BOPCol_IndexedMapOfInteger.hxx>
41 #include <BOPDS_ShapeInfo.hxx>
42 #include <BOPCol_ListOfInteger.hxx>
43 #include <BOPCol_IndexedMapOfInteger.hxx>
45 //=======================================================================
48 //=======================================================================
49 BOPDS_IteratorSI::BOPDS_IteratorSI()
54 //=======================================================================
57 //=======================================================================
58 BOPDS_IteratorSI::BOPDS_IteratorSI
59 (const Handle(NCollection_BaseAllocator)& theAllocator)
61 BOPDS_Iterator(theAllocator)
64 //=======================================================================
67 //=======================================================================
68 BOPDS_IteratorSI::~BOPDS_IteratorSI()
71 //=======================================================================
72 // function: UpdateByLevelOfCheck
74 //=======================================================================
75 void BOPDS_IteratorSI::UpdateByLevelOfCheck(const Standard_Integer theLevel)
77 Standard_Integer i, aNbInterfTypes;
79 aNbInterfTypes=BOPDS_DS::NbInterfTypes();
80 for (i=theLevel+1; i<aNbInterfTypes; ++i) {
84 //=======================================================================
85 // function: Intersect
87 //=======================================================================
88 void BOPDS_IteratorSI::Intersect()
90 Standard_Boolean bFlag;
91 Standard_Integer aNbS, i, aNbB;
92 Standard_Integer aNbSD, iX, j, iDS, jB;
93 TopAbs_ShapeEnum aTi, aTj;
94 Handle(NCollection_IncAllocator) aAllocator;
95 BOPCol_ListIteratorOfListOfInteger aIt;
96 BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD;
98 //-----------------------------------------------------scope_1 f
99 aAllocator=new NCollection_IncAllocator();
101 BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator);
102 BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator);
103 BOPDS_MapOfPassKeyBoolean aMPA(100, aAllocator);
104 BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator);
105 BOPCol_IndexedDataMapOfShapeBox aMSB(100, aAllocator);
106 BOPDS_PassKeyBoolean aPKXB;
108 BOPCol_BoxBndTreeSelector aSelector;
109 BOPCol_BoxBndTree aBBTree;
110 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
112 // myPairsAvoid, aMSI, aMSB
113 aNbS=myDS->NbSourceShapes();
114 for (i=0; i<aNbS; ++i) {
115 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
117 if (!aSI.IsInterfering()) {
121 const TopoDS_Shape& aSi=aSI.Shape();
123 if (aTi!=TopAbs_VERTEX) {
124 const BOPCol_ListOfInteger& aLA=aSI.SubShapes();
126 for (; aIt.More(); aIt.Next()) {
138 const Bnd_Box& aBoxEx=aSI.Box();
141 aMSB.Add(aSi, aBoxEx);
142 } // for (i=0; i<aNbS; ++i) {
146 for (i=1; i<=aNbB; ++i) {
147 const TopoDS_Shape& aS=aMSB.FindKey(i);
148 const Bnd_Box& aBoxEx=aMSB(i);
150 aTreeFiller.Add(i, aBoxEx);
158 for (i=0; i<aNbS; ++i) {
159 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
161 if (!aSI.IsInterfering()){
165 const TopoDS_Shape& aSi=myDS->Shape(i);
167 const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi);
169 aSelector.SetBox(aBoxEx);
171 aNbSD=aBBTree.Select(aSelector);
176 const BOPCol_ListOfInteger& aLI=aSelector.Indices();
179 for (; aIt.More(); aIt.Next()) {
180 jB=aIt.Value(); // box index in MII
181 j=aMII.Find(jB); // DS index
184 if (aMPA.Contains(aPKXB)) {
188 if (aMPKXB.Add(aPKXB)) {
189 bFlag=Standard_False;// Bounding boxes are intersected
190 const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box();
191 const Bnd_Box& aBoxj=myDS->ShapeInfo(j).Box();
192 if (aBoxi.IsOut(aBoxj)) {
193 bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
195 aTj=myDS->ShapeInfo(j).ShapeType();//
196 iX=BOPDS_Tools::TypeToInteger(aTi, aTj);
197 aPKXB.SetFlag(bFlag);
198 myLists(iX).Append(aPKXB);
199 }// if (aMPKXB.Add(aPKXB)) {
200 }// for (; aIt.More(); aIt.Next()) {
201 }//for (i=1; i<=aNbS; ++i) {
209 aAllocator.Nullify();
210 //-----------------------------------------------------scope_1 t