1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: NMTDS_IteratorChecker.hxx
21 // Author: Peter KURNEV
23 #include <NMTDS_IteratorCheckerSI.hxx>
25 #include <TopAbs_ShapeEnum.hxx>
27 #include <Bnd_Box.hxx>
29 #include <TopoDS_Shape.hxx>
30 #include <TopoDS_Vertex.hxx>
32 #include <BRep_Tool.hxx>
34 #include <TColStd_IndexedMapOfInteger.hxx>
35 #include <TColStd_ListOfInteger.hxx>
36 #include <TColStd_DataMapOfIntegerInteger.hxx>
37 #include <TColStd_ListIteratorOfListOfInteger.hxx>
38 #include <TColStd_MapOfInteger.hxx>
39 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
40 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
41 #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
43 #include <TopTools_DataMapOfShapeInteger.hxx>
45 #include <NCollection_UBTreeFiller.hxx>
46 #include <NMTDS_BoxBndTree.hxx>
47 #include <NMTDS_ShapesDataStructure.hxx>
48 #include <NMTDS_CArray1OfIndexRange.hxx>
49 #include <NMTDS_IndexRange.hxx>
50 #include <NMTDS_PairBoolean.hxx>
51 #include <NMTDS_MapOfPairBoolean.hxx>
52 #include <NMTDS_IndexedDataMapOfShapeBox.hxx>
53 #include <NMTDS_Tools.hxx>
55 //=======================================================================
58 //=======================================================================
59 NMTDS_IteratorCheckerSI::NMTDS_IteratorCheckerSI()
64 //=======================================================================
67 //=======================================================================
68 NMTDS_IteratorCheckerSI::~NMTDS_IteratorCheckerSI()
71 //=======================================================================
72 // function: Intersect
74 //=======================================================================
75 void NMTDS_IteratorCheckerSI::Intersect()
77 Standard_Boolean bFlag;
78 Standard_Integer aNbS, i, aNbA, aNbB, iFlag;
79 Standard_Integer aNbSD, iX, j, iDS, jB, k, aNbLV;
80 TColStd_ListIteratorOfListOfInteger aIt;
81 TColStd_DataMapOfIntegerInteger aMII;
82 TColStd_DataMapOfIntegerListOfInteger aMVSD;
83 TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD;
84 TopTools_DataMapOfShapeInteger aMSI;
85 TopAbs_ShapeEnum aTi, aTj;
86 NMTDS_PairBoolean aPKXB;
87 NMTDS_MapOfPairBoolean aMPKXB;
88 NMTDS_IndexedDataMapOfShapeBox aMSB;
89 NMTDS_MapOfPairBoolean aMPA;//myPairsAvoid
91 NMTDS_BoxBndTreeSelector aSelector;
92 NMTDS_BoxBndTree aBBTree;
93 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
95 aNbS=myDS->NumberOfShapesOfTheObject();
97 // myPairsAvoid, aMSI, aMSB
98 for (i=1; i<=aNbS; ++i) {
99 const TopoDS_Shape& aSi=myDS->Shape(i);
101 if (NMTDS_Tools::HasBRep(aTi)) {
102 if (aTi!=TopAbs_VERTEX) {
103 TColStd_IndexedMapOfInteger aMA;
105 myDS->GetAllSuccessors(i, aMA);
108 for (j=1; j<=aNbA; ++j) {
123 myDS->ComputeBoxEx(i, aBoxEx);
125 aMSB.Add(aSi, aBoxEx);
131 for (i=1; i<=aNbB; ++i) {
132 const TopoDS_Shape& aS=aMSB.FindKey(i);
133 const Bnd_Box& aBoxEx=aMSB(i);
135 aTreeFiller.Add(i, aBoxEx);
143 for (i=1; i<=aNbS; ++i) {
144 const TopoDS_Shape& aSi=myDS->Shape(i);
146 if (!NMTDS_Tools::HasBRep(aTi)){
149 const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi);
151 aSelector.SetBox(aBoxEx);
153 aNbSD=aBBTree.Select(aSelector);
158 const TColStd_ListOfInteger& aLI=aSelector.Indices();
161 TColStd_ListOfInteger aLV;
164 for (; aIt.More(); aIt.Next()) {
165 jB=aIt.Value(); // box index in MII
166 j=aMII.Find(jB); // DS index
169 if (aMPA.Contains(aPKXB)) {
173 if (aMPKXB.Add(aPKXB)) {
174 bFlag=Standard_False;// Bounding boxes are intersected
175 const Bnd_Box& aBoxi=myDS->GetBoundingBox(i);
176 const Bnd_Box& aBoxj=myDS->GetBoundingBox(j);
177 if (aBoxi.IsOut(aBoxj)) {
178 bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
180 const TopoDS_Shape& aSj=myDS->Shape(j);
182 iX=NMTDS_Tools::TypeToInteger(aTi, aTj);
183 //bFlag=(iStatus==2);
184 aPKXB.SetFlag(bFlag);
185 myLists[iX].Append(aPKXB);
191 }// if (aMPKXB.Add(aPKXB)) {
192 }// for (; aIt.More(); aIt.Next()) {
197 TColStd_ListOfInteger aLV1;
199 const TopoDS_Vertex& aVi=TopoDS::Vertex(aSi);
201 for (; aIt.More(); aIt.Next()) {
203 const TopoDS_Shape& aSj=myDS->Shape(j);
204 const TopoDS_Vertex& aVj=TopoDS::Vertex(aSj);
205 iFlag=NMTDS_Tools::ComputeVV(aVi, aVj);
211 aMPKXB.Remove(aPKXB);
216 }//for (i=1; i<=aNbS; ++i) {
222 NMTDS_Iterator::FillMVSD(aMVSD, myMVSD);