1 // Copyright (C) 2007-2011 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.cxx
21 // Created: Tue Feb 6 10:37:59 2007
22 // Author: Peter KURNEV
24 #include <NMTDS_IteratorCheckerSI.ixx>
26 #include <TopAbs_ShapeEnum.hxx>
28 #include <Bnd_Box.hxx>
30 #include <TopoDS_Shape.hxx>
31 #include <TopoDS_Vertex.hxx>
33 #include <BRep_Tool.hxx>
35 #include <TColStd_IndexedMapOfInteger.hxx>
36 #include <TColStd_ListOfInteger.hxx>
37 #include <TColStd_DataMapOfIntegerInteger.hxx>
38 #include <TColStd_ListIteratorOfListOfInteger.hxx>
39 #include <TColStd_MapOfInteger.hxx>
40 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
41 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
42 #include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
44 #include <TopTools_DataMapOfShapeInteger.hxx>
46 #include <NCollection_UBTreeFiller.hxx>
47 #include <NMTDS_BoxBndTree.hxx>
48 #include <NMTDS_ShapesDataStructure.hxx>
49 #include <NMTDS_CArray1OfIndexRange.hxx>
50 #include <NMTDS_IndexRange.hxx>
51 #include <NMTDS_PassKeyBoolean.hxx>
52 #include <NMTDS_MapOfPassKeyBoolean.hxx>
53 #include <NMTDS_IndexedDataMapOfShapeBox.hxx>
54 #include <NMTDS_Tools.hxx>
56 //=======================================================================
59 //=======================================================================
60 NMTDS_IteratorCheckerSI::NMTDS_IteratorCheckerSI()
65 //=======================================================================
68 //=======================================================================
69 NMTDS_IteratorCheckerSI::~NMTDS_IteratorCheckerSI()
72 //=======================================================================
73 // function: Intersect
75 //=======================================================================
76 void NMTDS_IteratorCheckerSI::Intersect()
78 Standard_Boolean bFlag;
79 Standard_Integer aNbS, i, aNbA, aNbB, iFlag;
80 Standard_Integer aNbSD, iX, j, iDS, jB, k, aNbLV;
81 TColStd_ListIteratorOfListOfInteger aIt;
82 TColStd_DataMapOfIntegerInteger aMII;
83 TColStd_DataMapOfIntegerListOfInteger aMVSD;
84 TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD;
85 TopTools_DataMapOfShapeInteger aMSI;
86 TopAbs_ShapeEnum aTi, aTj;
87 NMTDS_PassKeyBoolean aPKXB;
88 NMTDS_MapOfPassKeyBoolean aMPKXB;
89 NMTDS_IndexedDataMapOfShapeBox aMSB;
90 NMTDS_MapOfPassKeyBoolean aMPA;//myPairsAvoid
92 NMTDS_BoxBndTreeSelector aSelector;
93 NMTDS_BoxBndTree aBBTree;
94 NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
96 aNbS=myDS->NumberOfShapesOfTheObject();
98 // myPairsAvoid, aMSI, aMSB
99 for (i=1; i<=aNbS; ++i) {
100 const TopoDS_Shape& aSi=myDS->Shape(i);
102 if (NMTDS_Tools::HasBRep(aTi)) {
103 if (aTi!=TopAbs_VERTEX) {
104 TColStd_IndexedMapOfInteger aMA;
106 myDS->GetAllSuccessors(i, aMA);
109 for (j=1; j<=aNbA; ++j) {
124 myDS->ComputeBoxEx(i, aBoxEx);
126 aMSB.Add(aSi, aBoxEx);
132 for (i=1; i<=aNbB; ++i) {
133 const TopoDS_Shape& aS=aMSB.FindKey(i);
134 const Bnd_Box& aBoxEx=aMSB(i);
136 aTreeFiller.Add(i, aBoxEx);
144 for (i=1; i<=aNbS; ++i) {
145 const TopoDS_Shape& aSi=myDS->Shape(i);
147 if (!NMTDS_Tools::HasBRep(aTi)){
150 const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi);
152 aSelector.SetBox(aBoxEx);
154 aNbSD=aBBTree.Select(aSelector);
159 const TColStd_ListOfInteger& aLI=aSelector.Indices();
162 TColStd_ListOfInteger aLV;
165 for (; aIt.More(); aIt.Next()) {
166 jB=aIt.Value(); // box index in MII
167 j=aMII.Find(jB); // DS index
170 if (aMPA.Contains(aPKXB)) {
174 if (aMPKXB.Add(aPKXB)) {
175 bFlag=Standard_False;// Bounding boxes are intersected
176 const Bnd_Box& aBoxi=myDS->GetBoundingBox(i);
177 const Bnd_Box& aBoxj=myDS->GetBoundingBox(j);
178 if (aBoxi.IsOut(aBoxj)) {
179 bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected
181 const TopoDS_Shape& aSj=myDS->Shape(j);
183 iX=NMTDS_Tools::TypeToInteger(aTi, aTj);
184 //bFlag=(iStatus==2);
185 aPKXB.SetFlag(bFlag);
186 myLists[iX].Append(aPKXB);
192 }// if (aMPKXB.Add(aPKXB)) {
193 }// for (; aIt.More(); aIt.Next()) {
198 TColStd_ListOfInteger aLV1;
200 const TopoDS_Vertex& aVi=TopoDS::Vertex(aSi);
202 for (; aIt.More(); aIt.Next()) {
204 const TopoDS_Shape& aSj=myDS->Shape(j);
205 const TopoDS_Vertex& aVj=TopoDS::Vertex(aSj);
206 iFlag=NMTDS_Tools::ComputeVV(aVi, aVj);
212 aMPKXB.Remove(aPKXB);
217 }//for (i=1; i<=aNbS; ++i) {
223 NMTDS_Iterator::FillMVSD(aMVSD, myMVSD);