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 <BOPDS_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(const Handle(NCollection_BaseAllocator)& theAllocator)
58 BOPDS_Iterator(theAllocator)
61 //=======================================================================
64 //=======================================================================
65 BOPDS_IteratorSI::~BOPDS_IteratorSI()
68 //=======================================================================
69 // function: Intersect
71 //=======================================================================
72 void BOPDS_IteratorSI::Intersect()
74 Standard_Boolean bFlag;
75 Standard_Integer aNbS, i, aNbB;//, iFlag, aNbLV, aNbA
76 Standard_Integer aNbSD, iX, j, iDS, jB, k;;
77 TopAbs_ShapeEnum aTi, aTj;
78 Handle(NCollection_IncAllocator) aAllocator;
79 BOPCol_ListIteratorOfListOfInteger aIt;
80 BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD;
82 //-----------------------------------------------------scope_1 f
83 aAllocator=new NCollection_IncAllocator();
85 BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator);
86 BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator);
87 BOPDS_MapOfPassKeyBoolean aMPA(100, aAllocator);
88 BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator);
89 BOPCol_IndexedDataMapOfShapeBox aMSB(100, aAllocator);
90 BOPDS_PassKeyBoolean aPKXB;
92 BOPDS_BoxBndTreeSelector aSelector;
93 BOPDS_BoxBndTree aBBTree;
94 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
96 // myPairsAvoid, aMSI, aMSB
97 aNbS=myDS->NbSourceShapes();
98 for (i=0; i<aNbS; ++i) {
99 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
102 const TopoDS_Shape& aSi=aSI.Shape();
104 if (aTi!=TopAbs_VERTEX) {
105 const BOPCol_ListOfInteger& aLA=aSI.SubShapes();
107 for (; aIt.More(); aIt.Next()) {
119 const Bnd_Box& aBoxEx=aSI.Box();
122 aMSB.Add(aSi, aBoxEx);
124 } // for (i=0; i<aNbS; ++i) {
128 for (i=1; i<=aNbB; ++i) {
129 const TopoDS_Shape& aS=aMSB.FindKey(i);
130 const Bnd_Box& aBoxEx=aMSB(i);
132 aTreeFiller.Add(i, aBoxEx);
140 for (i=0; i<aNbS; ++i) {
141 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
147 const TopoDS_Shape& aSi=myDS->Shape(i);
149 const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi);
151 aSelector.SetBox(aBoxEx);
153 aNbSD=aBBTree.Select(aSelector);
158 const BOPCol_ListOfInteger& aLI=aSelector.Indices();
163 for (; aIt.More(); aIt.Next()) {
164 jB=aIt.Value(); // box index in MII
165 j=aMII.Find(jB); // DS index
168 if (aMPA.Contains(aPKXB)) {
172 if (aMPKXB.Add(aPKXB)) {
173 bFlag=Standard_False;// Bounding boxes are intersected
174 const Bnd_Box& aBoxi=myDS->ShapeInfo(i).Box();
175 const Bnd_Box& aBoxj=myDS->ShapeInfo(j).Box();
176 if (aBoxi.IsOut(aBoxj)) {
177 bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
179 aTj=myDS->ShapeInfo(j).ShapeType();//
180 iX=BOPDS_Tools::TypeToInteger(aTi, aTj);
181 aPKXB.SetFlag(bFlag);
182 myLists(iX).Append(aPKXB);
183 }// if (aMPKXB.Add(aPKXB)) {
184 }// for (; aIt.More(); aIt.Next()) {
185 }//for (i=1; i<=aNbS; ++i) {
193 aAllocator.Nullify();
194 //-----------------------------------------------------scope_1 t
197 //=======================================================================
198 // function: UpdateByLevelOfCheck
200 //=======================================================================
201 void BOPDS_IteratorSI::UpdateByLevelOfCheck(const Standard_Integer theLevel)
205 for (i=theLevel+1; i<6; ++i) {