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
7 // under the terms of the GNU Lesser General Public 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 <BOPCol_BoxBndTree.hxx>
28 #include <BOPDS_IndexRange.hxx>
29 #include <BOPDS_PassKeyBoolean.hxx>
30 #include <BOPDS_MapOfPassKeyBoolean.hxx>
31 #include <BOPDS_DS.hxx>
33 #include <BOPCol_IndexedDataMapOfShapeBox.hxx>
34 #include <BOPDS_Tools.hxx>
35 #include <BOPCol_DataMapOfShapeInteger.hxx>
36 #include <BOPCol_DataMapOfIntegerInteger.hxx>
37 #include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
38 #include <BOPCol_IndexedMapOfInteger.hxx>
39 #include <BOPDS_ShapeInfo.hxx>
40 #include <BOPCol_ListOfInteger.hxx>
41 #include <BOPCol_IndexedMapOfInteger.hxx>
43 //=======================================================================
46 //=======================================================================
47 BOPDS_IteratorSI::BOPDS_IteratorSI()
52 //=======================================================================
55 //=======================================================================
56 BOPDS_IteratorSI::BOPDS_IteratorSI
57 (const Handle(NCollection_BaseAllocator)& theAllocator)
59 BOPDS_Iterator(theAllocator)
62 //=======================================================================
65 //=======================================================================
66 BOPDS_IteratorSI::~BOPDS_IteratorSI()
69 //=======================================================================
70 // function: UpdateByLevelOfCheck
72 //=======================================================================
73 void BOPDS_IteratorSI::UpdateByLevelOfCheck(const Standard_Integer theLevel)
75 Standard_Integer i, aNbInterfTypes;
77 aNbInterfTypes=BOPDS_DS::NbInterfTypes();
78 for (i=theLevel+1; i<aNbInterfTypes; ++i) {
82 //=======================================================================
83 // function: Intersect
85 //=======================================================================
86 void BOPDS_IteratorSI::Intersect()
88 Standard_Boolean bFlag;
89 Standard_Integer aNbS, i, aNbB;
90 Standard_Integer aNbSD, iX, j, iDS, jB;
91 TopAbs_ShapeEnum aTi, aTj;
92 Handle(NCollection_IncAllocator) aAllocator;
93 BOPCol_ListIteratorOfListOfInteger aIt;
94 BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD;
96 //-----------------------------------------------------scope_1 f
97 aAllocator=new NCollection_IncAllocator();
99 BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator);
100 BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator);
101 BOPDS_MapOfPassKeyBoolean aMPA(100, aAllocator);
102 BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator);
103 BOPCol_IndexedDataMapOfShapeBox aMSB(100, aAllocator);
104 BOPDS_PassKeyBoolean aPKXB;
106 BOPCol_BoxBndTreeSelector aSelector;
107 BOPCol_BoxBndTree aBBTree;
108 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
110 // myPairsAvoid, aMSI, aMSB
111 aNbS=myDS->NbSourceShapes();
112 for (i=0; i<aNbS; ++i) {
113 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
115 if (!aSI.IsInterfering()) {
119 const TopoDS_Shape& aSi=aSI.Shape();
121 if (aTi!=TopAbs_VERTEX) {
122 const BOPCol_ListOfInteger& aLA=aSI.SubShapes();
124 for (; aIt.More(); aIt.Next()) {
136 const Bnd_Box& aBoxEx=aSI.Box();
139 aMSB.Add(aSi, aBoxEx);
140 } // for (i=0; i<aNbS; ++i) {
144 for (i=1; i<=aNbB; ++i) {
145 const TopoDS_Shape& aS=aMSB.FindKey(i);
146 const Bnd_Box& aBoxEx=aMSB(i);
148 aTreeFiller.Add(i, aBoxEx);
156 for (i=0; i<aNbS; ++i) {
157 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
159 if (!aSI.IsInterfering()){
163 const TopoDS_Shape& aSi=myDS->Shape(i);
165 const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi);
167 aSelector.SetBox(aBoxEx);
169 aNbSD=aBBTree.Select(aSelector);
174 const BOPCol_ListOfInteger& aLI=aSelector.Indices();
177 for (; aIt.More(); aIt.Next()) {
178 jB=aIt.Value(); // box index in MII
179 j=aMII.Find(jB); // DS index
182 if (aMPA.Contains(aPKXB)) {
186 if (aMPKXB.Add(aPKXB)) {
187 bFlag=Standard_False;// Bounding boxes are intersected
188 const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box();
189 const Bnd_Box& aBoxj=myDS->ShapeInfo(j).Box();
190 if (aBoxi.IsOut(aBoxj)) {
191 bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
193 aTj=myDS->ShapeInfo(j).ShapeType();//
194 iX=BOPDS_Tools::TypeToInteger(aTi, aTj);
195 aPKXB.SetFlag(bFlag);
196 myLists(iX).Append(aPKXB);
197 }// if (aMPKXB.Add(aPKXB)) {
198 }// for (; aIt.More(); aIt.Next()) {
199 }//for (i=1; i<=aNbS; ++i) {
207 aAllocator.Nullify();
208 //-----------------------------------------------------scope_1 t