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_MapOfPair.hxx>
26 #include <BOPDS_Pair.hxx>
27 #include <BOPDS_ShapeInfo.hxx>
28 #include <BOPDS_Tools.hxx>
29 #include <BRep_Tool.hxx>
31 #include <NCollection_UBTreeFiller.hxx>
32 #include <TopAbs_ShapeEnum.hxx>
34 #include <TopoDS_Shape.hxx>
35 #include <TopoDS_Vertex.hxx>
38 //=======================================================================
41 //=======================================================================
42 BOPDS_IteratorSI::BOPDS_IteratorSI()
47 //=======================================================================
50 //=======================================================================
51 BOPDS_IteratorSI::BOPDS_IteratorSI
52 (const Handle(NCollection_BaseAllocator)& theAllocator)
54 BOPDS_Iterator(theAllocator)
57 //=======================================================================
60 //=======================================================================
61 BOPDS_IteratorSI::~BOPDS_IteratorSI()
64 //=======================================================================
65 // function: UpdateByLevelOfCheck
67 //=======================================================================
68 void BOPDS_IteratorSI::UpdateByLevelOfCheck(const Standard_Integer theLevel)
70 Standard_Integer i, aNbInterfTypes;
72 aNbInterfTypes=BOPDS_DS::NbInterfTypes();
73 for (i=theLevel+1; i<aNbInterfTypes; ++i) {
77 //=======================================================================
78 // function: Intersect
80 //=======================================================================
81 void BOPDS_IteratorSI::Intersect()
83 Standard_Integer i, j, iX, aNbS;
84 Standard_Integer iTi, iTj;
85 TopAbs_ShapeEnum aTi, aTj;
87 BOPCol_BoxBndTreeSelector aSelector;
88 BOPCol_BoxBndTree aBBTree;
89 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
91 aNbS = myDS->NbSourceShapes();
92 for (i=0; i<aNbS; ++i) {
93 const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
94 if (!aSI.IsInterfering()) {
98 const Bnd_Box& aBoxEx = aSI.Box();
99 aTreeFiller.Add(i, aBoxEx);
104 BOPDS_MapOfPair aMPFence;
106 for (i = 0; i < aNbS; ++i) {
107 const BOPDS_ShapeInfo& aSI = myDS->ShapeInfo(i);
108 if (!aSI.IsInterfering()){
112 const Bnd_Box& aBoxEx = aSI.Box();
115 aSelector.SetBox(aBoxEx);
117 Standard_Integer aNbSD = aBBTree.Select(aSelector);
122 aTi = aSI.ShapeType();
123 iTi = BOPDS_Tools::TypeToInteger(aTi);
125 const BOPCol_ListOfInteger& aLI = aSelector.Indices();
126 BOPCol_ListIteratorOfListOfInteger aIt(aLI);
127 for (; aIt.More(); aIt.Next()) {
129 const BOPDS_ShapeInfo& aSJ = myDS->ShapeInfo(j);
130 aTj = aSJ.ShapeType();
131 iTj = BOPDS_Tools::TypeToInteger(aTj);
133 // avoid interfering of the same shapes and shape with its sub-shapes
134 if ((i == j) || ((iTi < iTj) && aSI.HasSubShape(j)) ||
135 ((iTi > iTj) && aSJ.HasSubShape(i))) {
139 BOPDS_Pair aPair(i, j);
140 if (aMPFence.Add(aPair)) {
141 iX = BOPDS_Tools::TypeToInteger(aTi, aTj);
142 myLists(iX).Append(aPair);
143 }// if (aMPKXB.Add(aPKXB)) {
144 }// for (; aIt.More(); aIt.Next()) {
145 }//for (i=1; i<=aNbS; ++i) {