0025769: Replace BOPCol_Array1 with NCollection_Vector
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_10.cxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 //                         EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 //
7 // This file is part of Open CASCADE Technology software library.
8 //
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License version 2.1 as published
11 // by the Free Software Foundation, with special exception defined in the file
12 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 // distribution for complete text of the license and disclaimer of any warranty.
14 //
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
17
18 #include <BOPAlgo_PaveFiller.ixx>
19
20 #include <gp_Pnt.hxx>
21
22 #include <TopAbs_State.hxx>
23
24 #include <TopoDS_Vertex.hxx>
25 #include <TopoDS_Solid.hxx>
26 #include <BRep_Tool.hxx>
27 #include <BRepClass3d_SolidClassifier.hxx>
28
29 #include <IntTools_Context.hxx>
30
31 #include <BOPDS_DS.hxx>
32 #include <BOPDS_IteratorSI.hxx>
33 #include <BOPDS_Interf.hxx>
34
35 //=======================================================================
36 //function : PerformVZ
37 //purpose  : 
38 //=======================================================================
39 void BOPAlgo_PaveFiller::PerformVZ()
40 {
41   Standard_Boolean bJustAdd;
42   Standard_Integer iSize, nV, nZ;
43   Standard_Real aTol;
44   gp_Pnt aPV;
45   TopAbs_State aState;
46   //
47   myErrorStatus=0;
48   //
49   myIterator->Initialize(TopAbs_VERTEX, TopAbs_SOLID);
50   iSize=myIterator->ExpectedLength();
51   if (!iSize) {
52     return; 
53   }
54   //
55   BOPDS_VectorOfInterfVZ& aVZs=myDS->InterfVZ();
56   aVZs.SetIncrement(iSize);
57   //
58   for (; myIterator->More(); myIterator->Next()) {
59     myIterator->Value(nV, nZ, bJustAdd);
60     if(bJustAdd) {
61       continue;
62     }
63     //
64     const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
65     const BOPDS_ShapeInfo& aSIZ=myDS->ShapeInfo(nZ);
66     //
67     const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aSIV.Shape()); 
68     const TopoDS_Solid& aZ=*((TopoDS_Solid*)&aSIZ.Shape()); 
69     //
70     BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aZ);
71     //
72     aPV=BRep_Tool::Pnt(aV);
73     aTol=BRep_Tool::Tolerance(aV);
74     //
75     aSC.Perform(aPV, aTol);
76     //
77     aState=aSC.State();
78     if (aState==TopAbs_IN)  {
79       BOPDS_InterfVZ& aVZ=aVZs.Append1();
80       aVZ.SetIndices(nV, nZ);
81       //
82       myDS->AddInterf(nV, nZ);
83     }
84   }
85 }
86 //=======================================================================
87 //function : PerformEZ
88 //purpose  : 
89 //=======================================================================
90 void BOPAlgo_PaveFiller::PerformEZ()
91 {
92   Standard_Boolean bJustAdd, bHasInterf;
93   Standard_Integer iSize, nE, nZ;
94   //
95   myErrorStatus=0;
96   //
97   myIterator->Initialize(TopAbs_EDGE, TopAbs_SOLID);
98   iSize=myIterator->ExpectedLength();
99   if (!iSize) {
100     return; 
101   }
102   //
103   BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ();
104   aEZs.SetIncrement(iSize);
105   //
106   for (; myIterator->More(); myIterator->Next()) {
107     myIterator->Value(nE, nZ, bJustAdd);
108     if(bJustAdd) {
109       continue;
110     }
111     //
112     bHasInterf=myDS->HasInterfShapeSubShapes(nE, nZ);
113     if (bHasInterf) {
114       continue;
115     }
116     //
117     bHasInterf=myDS->HasInterfShapeSubShapes(nZ, nE);
118     if (!bHasInterf) {
119       continue;
120     }
121     //
122     BOPDS_InterfEZ& aEZ=aEZs.Append1();
123     aEZ.SetIndices(nE, nZ);
124     //
125     myDS->AddInterf(nE, nZ);
126   }
127 }
128 //=======================================================================
129 //function : PerformFZ
130 //purpose  : 
131 //=======================================================================
132 void BOPAlgo_PaveFiller::PerformFZ()
133 {
134   Standard_Boolean bJustAdd, bHasInterf;
135   Standard_Integer iSize, nF, nZ;
136   //
137   myErrorStatus=0;
138   //
139   myIterator->Initialize(TopAbs_FACE, TopAbs_SOLID);
140   iSize=myIterator->ExpectedLength();
141   if (!iSize) {
142     return; 
143   }
144   //
145   BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ();
146   aFZs.SetIncrement(iSize);
147   //
148   for (; myIterator->More(); myIterator->Next()) {
149     myIterator->Value(nF, nZ, bJustAdd);
150     if(bJustAdd) {
151       continue;
152     }
153     //
154     bHasInterf=myDS->HasInterfShapeSubShapes(nF, nZ);
155     if (bHasInterf) {
156       continue;
157     }
158     //
159     bHasInterf=myDS->HasInterfShapeSubShapes(nZ, nF);
160     if (!bHasInterf) {
161       continue;
162     }
163     //
164     BOPDS_InterfFZ& aFZ=aFZs.Append1();
165     aFZ.SetIndices(nF, nZ);
166     //
167     myDS->AddInterf(nF, nZ);
168   }
169 }
170 //=======================================================================
171 //function : PerformZZ
172 //purpose  : 
173 //=======================================================================
174 void BOPAlgo_PaveFiller::PerformZZ()
175 {
176   Standard_Boolean bJustAdd, bHasInterf, bFlag;
177   Standard_Integer iSize, nZ1, nZ;
178   //
179   myErrorStatus=0;
180   //
181   myIterator->Initialize(TopAbs_SOLID, TopAbs_SOLID);
182   iSize=myIterator->ExpectedLength();
183   if (!iSize) {
184     return; 
185   }
186   //
187   BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ();
188   aZZs.SetIncrement(iSize);
189   //
190   bFlag=Standard_False;
191   //
192   for (; myIterator->More(); myIterator->Next()) {
193     myIterator->Value(nZ1, nZ, bJustAdd);
194     if(bJustAdd) {
195       continue;
196     }
197     //
198     bHasInterf=myDS->HasInterfShapeSubShapes(nZ, nZ1, bFlag);
199     if (!bHasInterf) {
200       bHasInterf=myDS->HasInterfShapeSubShapes(nZ1, nZ, bFlag);
201     }
202     if (!bHasInterf) {
203       continue; 
204     }
205     //
206     BOPDS_InterfZZ& aZZ=aZZs.Append1();
207     aZZ.SetIndices(nZ1, nZ);
208     //
209     myDS->AddInterf(nZ1, nZ);
210   }
211 }