1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: NMTDS_IteratorChecker.cxx
23 // Created: Tue Feb 6 10:37:59 2007
24 // Author: Peter KURNEV
26 #include <NMTDS_IteratorCheckerSI.ixx>
28 #include <TopAbs_ShapeEnum.hxx>
30 #include <Bnd_Box.hxx>
32 #include <TopoDS_Shape.hxx>
33 #include <TopoDS_Vertex.hxx>
35 #include <BRep_Tool.hxx>
37 #include <TColStd_IndexedMapOfInteger.hxx>
38 #include <TColStd_ListOfInteger.hxx>
39 #include <TColStd_DataMapOfIntegerInteger.hxx>
40 #include <TColStd_ListIteratorOfListOfInteger.hxx>
41 #include <TColStd_MapOfInteger.hxx>
42 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
43 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
44 #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
46 #include <TopTools_DataMapOfShapeInteger.hxx>
48 #include <NCollection_UBTreeFiller.hxx>
49 #include <NMTDS_BoxBndTree.hxx>
50 #include <NMTDS_ShapesDataStructure.hxx>
51 #include <NMTDS_CArray1OfIndexRange.hxx>
52 #include <NMTDS_IndexRange.hxx>
53 #include <NMTDS_PassKeyBoolean.hxx>
54 #include <NMTDS_MapOfPassKeyBoolean.hxx>
55 #include <NMTDS_IndexedDataMapOfShapeBox.hxx>
56 #include <NMTDS_Tools.hxx>
58 //=======================================================================
61 //=======================================================================
62 NMTDS_IteratorCheckerSI::NMTDS_IteratorCheckerSI()
67 //=======================================================================
70 //=======================================================================
71 NMTDS_IteratorCheckerSI::~NMTDS_IteratorCheckerSI()
74 //=======================================================================
75 // function: Intersect
77 //=======================================================================
78 void NMTDS_IteratorCheckerSI::Intersect()
80 Standard_Boolean bFlag;
81 Standard_Integer aNbS, i, aNbA, aNbB, iFlag;
82 Standard_Integer aNbSD, iX, j, iDS, jB, k, aNbLV;
83 TColStd_ListIteratorOfListOfInteger aIt;
84 TColStd_DataMapOfIntegerInteger aMII;
85 TColStd_DataMapOfIntegerListOfInteger aMVSD;
86 TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD;
87 TopTools_DataMapOfShapeInteger aMSI;
88 TopAbs_ShapeEnum aTi, aTj;
89 NMTDS_PassKeyBoolean aPKXB;
90 NMTDS_MapOfPassKeyBoolean aMPKXB;
91 NMTDS_IndexedDataMapOfShapeBox aMSB;
92 NMTDS_MapOfPassKeyBoolean aMPA;//myPairsAvoid
94 NMTDS_BoxBndTreeSelector aSelector;
95 NMTDS_BoxBndTree aBBTree;
96 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
98 aNbS=myDS->NumberOfShapesOfTheObject();
100 // myPairsAvoid, aMSI, aMSB
101 for (i=1; i<=aNbS; ++i) {
102 const TopoDS_Shape& aSi=myDS->Shape(i);
104 if (NMTDS_Tools::HasBRep(aTi)) {
105 if (aTi!=TopAbs_VERTEX) {
106 TColStd_IndexedMapOfInteger aMA;
108 myDS->GetAllSuccessors(i, aMA);
111 for (j=1; j<=aNbA; ++j) {
126 myDS->ComputeBoxEx(i, aBoxEx);
128 aMSB.Add(aSi, aBoxEx);
134 for (i=1; i<=aNbB; ++i) {
135 const TopoDS_Shape& aS=aMSB.FindKey(i);
136 const Bnd_Box& aBoxEx=aMSB(i);
138 aTreeFiller.Add(i, aBoxEx);
146 for (i=1; i<=aNbS; ++i) {
147 const TopoDS_Shape& aSi=myDS->Shape(i);
149 if (!NMTDS_Tools::HasBRep(aTi)){
152 const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi);
154 aSelector.SetBox(aBoxEx);
156 aNbSD=aBBTree.Select(aSelector);
161 const TColStd_ListOfInteger& aLI=aSelector.Indices();
164 TColStd_ListOfInteger aLV;
167 for (; aIt.More(); aIt.Next()) {
168 jB=aIt.Value(); // box index in MII
169 j=aMII.Find(jB); // DS index
172 if (aMPA.Contains(aPKXB)) {
176 if (aMPKXB.Add(aPKXB)) {
177 bFlag=Standard_False;// Bounding boxes are intersected
178 const Bnd_Box& aBoxi=myDS->GetBoundingBox(i);
179 const Bnd_Box& aBoxj=myDS->GetBoundingBox(j);
180 if (aBoxi.IsOut(aBoxj)) {
181 bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
183 const TopoDS_Shape& aSj=myDS->Shape(j);
185 iX=NMTDS_Tools::TypeToInteger(aTi, aTj);
186 //bFlag=(iStatus==2);
187 aPKXB.SetFlag(bFlag);
188 myLists[iX].Append(aPKXB);
194 }// if (aMPKXB.Add(aPKXB)) {
195 }// for (; aIt.More(); aIt.Next()) {
200 TColStd_ListOfInteger aLV1;
202 const TopoDS_Vertex& aVi=TopoDS::Vertex(aSi);
204 for (; aIt.More(); aIt.Next()) {
206 const TopoDS_Shape& aSj=myDS->Shape(j);
207 const TopoDS_Vertex& aVj=TopoDS::Vertex(aSj);
208 iFlag=NMTDS_Tools::ComputeVV(aVi, aVj);
214 aMPKXB.Remove(aPKXB);
219 }//for (i=1; i<=aNbS; ++i) {
225 NMTDS_Iterator::FillMVSD(aMVSD, myMVSD);