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 <Bnd_Box.hxx>
16 #include <BOPCol_BoxBndTree.hxx>
17 #include <BOPCol_DataMapOfIntegerInteger.hxx>
18 #include <BOPCol_DataMapOfIntegerListOfInteger.hxx>
19 #include <BOPCol_DataMapOfShapeInteger.hxx>
20 #include <BOPCol_IndexedDataMapOfShapeBox.hxx>
21 #include <BOPCol_ListOfInteger.hxx>
22 #include <BOPDS_DS.hxx>
23 #include <BOPDS_IndexRange.hxx>
24 #include <BOPDS_IteratorSI.hxx>
25 #include <BOPDS_MapOfPassKeyBoolean.hxx>
26 #include <BOPDS_PassKeyBoolean.hxx>
27 #include <BOPDS_ShapeInfo.hxx>
28 #include <BOPDS_Tools.hxx>
29 #include <BRep_Tool.hxx>
31 #include <NCollection_IncAllocator.hxx>
32 #include <NCollection_UBTreeFiller.hxx>
33 #include <TopAbs_ShapeEnum.hxx>
35 #include <TopoDS_Shape.hxx>
36 #include <TopoDS_Vertex.hxx>
39 //=======================================================================
42 //=======================================================================
43 BOPDS_IteratorSI::BOPDS_IteratorSI()
48 //=======================================================================
51 //=======================================================================
52 BOPDS_IteratorSI::BOPDS_IteratorSI
53 (const Handle(NCollection_BaseAllocator)& theAllocator)
55 BOPDS_Iterator(theAllocator)
58 //=======================================================================
61 //=======================================================================
62 BOPDS_IteratorSI::~BOPDS_IteratorSI()
65 //=======================================================================
66 // function: UpdateByLevelOfCheck
68 //=======================================================================
69 void BOPDS_IteratorSI::UpdateByLevelOfCheck(const Standard_Integer theLevel)
71 Standard_Integer i, aNbInterfTypes;
73 aNbInterfTypes=BOPDS_DS::NbInterfTypes();
74 for (i=theLevel+1; i<aNbInterfTypes; ++i) {
78 //=======================================================================
79 // function: Intersect
81 //=======================================================================
82 void BOPDS_IteratorSI::Intersect()
84 Standard_Boolean bFlag;
85 Standard_Integer aNbS, i, aNbB;
86 Standard_Integer aNbSD, iX, j, iDS, jB;
87 TopAbs_ShapeEnum aTi, aTj;
88 Handle(NCollection_IncAllocator) aAllocator;
89 BOPCol_ListIteratorOfListOfInteger aIt;
91 //-----------------------------------------------------scope_1 f
92 aAllocator=new NCollection_IncAllocator();
94 BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator);
95 BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator);
96 BOPDS_MapOfPassKeyBoolean aMPA(100, aAllocator);
97 BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator);
98 BOPCol_IndexedDataMapOfShapeBox aMSB(100, aAllocator);
99 BOPDS_PassKeyBoolean aPKXB;
101 BOPCol_BoxBndTreeSelector aSelector;
102 BOPCol_BoxBndTree aBBTree;
103 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
105 // myPairsAvoid, aMSI, aMSB
106 aNbS=myDS->NbSourceShapes();
107 for (i=0; i<aNbS; ++i) {
108 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
110 if (!aSI.IsInterfering()) {
114 const TopoDS_Shape& aSi=aSI.Shape();
116 if (aTi!=TopAbs_VERTEX) {
117 const BOPCol_ListOfInteger& aLA=aSI.SubShapes();
119 for (; aIt.More(); aIt.Next()) {
131 const Bnd_Box& aBoxEx=aSI.Box();
134 aMSB.Add(aSi, aBoxEx);
135 } // for (i=0; i<aNbS; ++i) {
139 for (i=1; i<=aNbB; ++i) {
140 const TopoDS_Shape& aS=aMSB.FindKey(i);
141 const Bnd_Box& aBoxEx=aMSB(i);
143 aTreeFiller.Add(i, aBoxEx);
151 for (i=0; i<aNbS; ++i) {
152 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
154 if (!aSI.IsInterfering()){
158 const TopoDS_Shape& aSi=myDS->Shape(i);
160 const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi);
162 aSelector.SetBox(aBoxEx);
164 aNbSD=aBBTree.Select(aSelector);
169 const BOPCol_ListOfInteger& aLI=aSelector.Indices();
172 for (; aIt.More(); aIt.Next()) {
173 jB=aIt.Value(); // box index in MII
174 j=aMII.Find(jB); // DS index
177 if (aMPA.Contains(aPKXB)) {
181 if (aMPKXB.Add(aPKXB)) {
182 bFlag=Standard_False;// Bounding boxes are intersected
183 const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box();
184 const Bnd_Box& aBoxj=myDS->ShapeInfo(j).Box();
185 if (aBoxi.IsOut(aBoxj)) {
186 bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
188 aTj=myDS->ShapeInfo(j).ShapeType();//
189 iX=BOPDS_Tools::TypeToInteger(aTi, aTj);
190 aPKXB.SetFlag(bFlag);
191 myLists(iX).Append(aPKXB);
192 }// if (aMPKXB.Add(aPKXB)) {
193 }// for (; aIt.More(); aIt.Next()) {
194 }//for (i=1; i<=aNbS; ++i) {
202 aAllocator.Nullify();
203 //-----------------------------------------------------scope_1 t