0024510: Remove unused local variables
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_EIR.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
973c2be1 6// This library is free software; you can redistribute it and / or modify it
7// under the terms of the GNU Lesser General Public 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.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
7fd59977 14
15#include <TopOpeBRepDS_EIR.ixx>
16#include <BRep_Tool.hxx>
17#include <TopExp.hxx>
18#include <TopOpeBRepDS_CurvePointInterference.hxx>
19#include <TopOpeBRepDS_Dumper.hxx>
20#include <TopOpeBRepDS_Edge3dInterferenceTool.hxx>
21#include <TopOpeBRepDS_EdgeInterferenceTool.hxx>
22#include <TopOpeBRepDS_EdgeVertexInterference.hxx>
23#include <TopOpeBRepDS_Interference.hxx>
24#include <TopOpeBRepDS_TKI.hxx>
25#include <TopoDS.hxx>
26#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
27#include <TopOpeBRepTool_EXPORT.hxx>
28#include <TopOpeBRepDS_EXPORT.hxx>
29#include <TopOpeBRepDS_define.hxx>
30#include <TopOpeBRepDS_repvg.hxx>
31#include <TopOpeBRepDS_connex.hxx>
32#include <TopOpeBRepTool_TOOL.hxx>
33#ifdef DEB
34#include <TopOpeBRepDS_reDEB.hxx>
35Standard_EXPORT void debredpnc(const Standard_Integer ie){cout<<"+++ debredpnc e"<<ie<<endl;}
1d0a9d4d 36extern Standard_Boolean TopOpeBRepDS_GetcontextNOPNC();
7fd59977 37#endif
38
39#define M_FORWARD(O) (O == TopAbs_FORWARD)
40#define M_REVERSED(O) (O == TopAbs_REVERSED)
41#define M_INTERNAL(O) (O == TopAbs_INTERNAL)
42#define M_EXTERNAL(O) (O == TopAbs_EXTERNAL)
43
44// modified by NIZHNY-MKK Mon Apr 2 15:34:28 2001.BEGIN
45static Standard_Boolean CheckInterferenceIsValid(const Handle(TopOpeBRepDS_Interference)& I,
46 const TopoDS_Edge& theEdge,
47 const TopoDS_Edge& theSupportEdge,
48 const TopoDS_Vertex& theVertex);
49// modified by NIZHNY-MKK Mon Apr 2 15:34:32 2001.END
50
51//------------------------------------------------------
52static void FDS_reduceONFACEinterferences(TopOpeBRepDS_ListOfInterference& LI,
53 const TopOpeBRepDS_DataStructure& /*BDS*/,
54 const Standard_Integer
55#ifdef DEB
56 EIX
57#endif
58 )
59//------------------------------------------------------
60{
61#ifdef DEB
62 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
63 TRC = Standard_False; //MOINSTRACE
64 if (TRC) cout<<endl<<"reduceONFACEinterferences on "<<EIX<<" <- "<<LI.Extent()<<endl;
65#endif
66
67 TopOpeBRepDS_ListIteratorOfListOfInterference it1; // set hasONFACE = True if LI contains interfs with (ON,FACE) transition(s).
68 Standard_Boolean hasONFACE = Standard_False;
69 for (it1.Initialize(LI); it1.More(); it1.Next() ) {
70 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
71 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
72 if ( GT1 == TopOpeBRepDS_POINT ) {
73 hasONFACE = FUN_hasStateShape(I1->Transition(),TopAbs_ON,TopAbs_FACE);
74 if ( hasONFACE ) break;
75 }
76 }
77
78#ifdef DEB
79 if(TRC){if( hasONFACE)cout<<"egde "<<EIX<<" has (ON,FACE)"<<endl;}
80 if(TRC){if(!hasONFACE)cout<<"egde "<<EIX<<" has no (ON,FACE)"<<endl;}
81#endif
82
83 if ( hasONFACE ) {
84 // LI has (ON,FACE) : remove all other interf (POINT,(not(ON,FACE)))
85 it1.Initialize(LI);
86 while( it1.More() ) {
87 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
88 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
89 if ( GT1 == TopOpeBRepDS_POINT ) {
90 hasONFACE = FUN_hasStateShape(I1->Transition(),TopAbs_ON,TopAbs_FACE);
91 if ( ! hasONFACE ) {
92 LI.Remove(it1);
93 }
94 else it1.Next();
95 }
96 else it1.Next();
97 }
98 }
99
100#ifdef DEB
101 if (TRC) cout<<"reduceONFACEinterferences E"<<EIX<<" -> "<<LI.Extent()<<endl<<endl;
102#endif
103}
104
105//------------------------------------------------------
106static void FUN_ReducerEdge3d(const Standard_Integer SIX, TopOpeBRepDS_DataStructure& BDS,
107 TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& reducedLI)
108//------------------------------------------------------
109// <LI> = { I3d = (TonFACE, G=POINT/VERTEX, S=EDGE) }
110// {I3d} --reducing processing-> I3d' = (TonFACE, G=POINT/VERTEX, S=FACE)
111// <LI> -> <reducedLI> + <LI>
112{
113 reducedLI.Clear();
114#ifdef DEB
115 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
116 TRC = Standard_False; //MOINSTRACE
117 if(TRC) {cout<<endl; debreducer3d(SIX);}
118 if (TRC) cout<<endl<<"ReducerEdge3d E"<<SIX<<" <- "<<LI.Extent()<<endl;
119#endif
120 Standard_Integer n3d = LI.Extent();
121 if (n3d <= 1) return;
122 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(SIX));
123 Standard_Integer rankE = BDS.AncestorRank(E);
124 TopoDS_Shape OOv; Standard_Integer Gsta = 0;
125
126 TopOpeBRepDS_ListIteratorOfListOfInterference it1;
127 it1.Initialize(LI);
128
129 // <-- jyl 231198 : cts21797
130 Standard_Integer nLI = LI.Extent();
131 if (nLI >= 1) {
132 while (it1.More()) {
133 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
134 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
135 TopAbs_ShapeEnum SB1,SA1; Standard_Integer IB1,IA1; FDS_Tdata(I1,SB1,IB1,SA1,IA1);
136 Standard_Boolean torem = Standard_False;
137 if (ST1 == TopOpeBRepDS_EDGE) {
138 const TopoDS_Edge& EE = TopoDS::Edge(BDS.Shape(S1));
139 const TopoDS_Face& FF = TopoDS::Face(BDS.Shape(IB1));
140 TopAbs_Orientation o; Standard_Boolean ok = FUN_tool_orientEinFFORWARD(EE,FF,o);
141 if (ok && (o == TopAbs_EXTERNAL)) torem = Standard_True;
142 }
143 if (torem) LI.Remove(it1);
144 else it1.Next();
145 }
146 nLI = LI.Extent();
147 if (nLI <= 1) return;
148 }
149 // --> jyl 231198 : cts21797
150
151 it1.Initialize(LI);
152 while (it1.More()){
153
154 Standard_Boolean isComplex = Standard_False;
155 TopOpeBRepDS_Edge3dInterferenceTool EFITool;
156 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
157 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
158 TopAbs_ShapeEnum SB1,SA1; Standard_Integer IB1,IA1; FDS_Tdata(I1,SB1,IB1,SA1,IA1);
159
160 // modified by NIZHNY-MKK Mon Apr 2 15:35:58 2001.BEGIN
161 TopoDS_Vertex aVertex;
162
163 if((GT1 == TopOpeBRepDS_VERTEX) && G1!=0) {
164 aVertex = TopoDS::Vertex(BDS.Shape(G1));
165 }
166
167 if(!CheckInterferenceIsValid(I1, E, TopoDS::Edge(BDS.Shape(S1)), aVertex)) {
168 LI.Remove(it1);
169 continue;
170 }
171 // modified by NIZHNY-MKK Mon Apr 2 15:36:02 2001.END
172
173 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1);
174 if (it2.More()) it2.Next();
175 else return;
176
177 while ( it2.More()){
178 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
179 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2);
180 TopAbs_ShapeEnum SB2,SA2; Standard_Integer IB2,IA2; FDS_Tdata(I2,SB2,IB2,SA2,IA2);
181
182 // modified by NIZHNY-MKK Mon Apr 2 15:36:42 2001.BEGIN
183 aVertex.Nullify();
184
185 if((GT2 == TopOpeBRepDS_VERTEX) && G2!=0) {
186 aVertex = TopoDS::Vertex(BDS.Shape(G2));
187 }
188
189 if(!CheckInterferenceIsValid(I2, E, TopoDS::Edge(BDS.Shape(S2)), aVertex)) {
190 LI.Remove(it2);
191 continue;
192 }
193 // modified by NIZHNY-MKK Mon Apr 2 15:36:45 2001.END
194
195 Standard_Boolean sameG = (GT2 == GT1) && (G2 == G1);
196 if (!sameG) break;
197
198 // <Gsta>, <OOv>
199 if (GT1 == TopOpeBRepDS_VERTEX) {
200 TopoDS_Vertex vG1 = TopoDS::Vertex(BDS.Shape(G1));
201 Standard_Integer rankvG1 = BDS.AncestorRank(vG1);
202 Standard_Integer sdG1; Standard_Boolean G1hsd = FUN_ds_getVsdm(BDS,G1,sdG1);
203 if (rankvG1 != rankE) { // vG1 not on E
204 OOv = vG1;
205 Gsta = G1hsd? 3: 2;
206 }
207 else { // vG on E
208 if (G1hsd) OOv = BDS.Shape(sdG1);
209 Gsta = G1hsd? 3: 1;
210 }
211 }
212
213 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(IB1));
214 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(IB2)); // F2 != F1
215
216 Standard_Boolean sameS = (ST2 == ST1) && (S2 == S1);
217 if (!sameS) {
218 TopoDS_Shape Eshared; Standard_Boolean foundsh = FUN_tool_Eshared(OOv,F1,F2,Eshared);
219 if (!foundsh) return;
220
221 // modified by NIZHNY-MKK Mon Apr 2 15:37:12 2001.BEGIN
222 if(!BDS.HasShape(Eshared)) {
223 return;
224 }
225 // modified by NIZHNY-MKK Mon Apr 2 15:37:15 2001.END
226
227 S1 = S2 = BDS.Shape(Eshared);
228 }
229
230 const TopoDS_Edge& E1 = TopoDS::Edge(BDS.Shape(S1));
231 const TopoDS_Edge& E2 = TopoDS::Edge(BDS.Shape(S2)); // E2 == E1
232
233 Standard_Boolean sdm = FUN_ds_sdm(BDS,E,E1);
234 if (sdm) {
235#ifdef DEB
236 if (TRC) cout<<" NO I3d : e"<<SIX<<" same domain with e"<<S1<<endl;
237#endif
238 it2.Next(); continue;
239 }
240
241 Standard_Boolean init = !isComplex;
242 Standard_Boolean isvertex = (GT1 == TopOpeBRepDS_VERTEX);
243 init = init || isvertex; // !!!KK a revoir!!!!
244
245 if (init) {
246
247 // xpu : 04-03-98 : !!!KK a revoir!!!!
248 if (isComplex) {
249 Handle(TopOpeBRepDS_Interference) IBID = new TopOpeBRepDS_Interference();
250 EFITool.Transition(IBID);
251 I1->ChangeTransition().Set(IBID->Transition().Orientation(TopAbs_IN));
252 }
253 // !!!KK a revoir!!!!
254
255 if (!isComplex) EFITool.InitPointVertex(Gsta,OOv);
256 isComplex = Standard_True;
257 EFITool.Init(E,E1,F1,I1);
258 EFITool.Add(E,E1,F1,I1);
259#ifdef DEB
260 if(TRC){cout<<endl<<"complex T3d E"<<SIX<<endl;I1->Dump(cout,"init :","\n");}
261#endif
262 } // !isComplex
263
264#ifdef DEB
265 if(TRC) I2->Dump(cout,"add : ","\n");
266#endif
267 EFITool.Add(E,E2,F2,I2);
268 LI.Remove(it2);
269
270#ifdef DEB
271 if(TRC){cout<<"resulting : "; Handle(TopOpeBRepDS_Interference) IBID = new TopOpeBRepDS_Interference();
272 EFITool.Transition(IBID);IBID->Transition().Dump(cout);cout<<endl;}
273#endif
274 } // it2
275
276 if (isComplex) {
277 Handle(TopOpeBRepDS_Interference) newI;
278 Handle(TopOpeBRepDS_Interference) IIBID = new TopOpeBRepDS_Interference();
279 EFITool.Transition(IIBID);
280 TopOpeBRepDS_Transition T = IIBID->Transition(); T.Index(IB1);
281
282 Standard_Boolean isevi = I1->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
283 Standard_Boolean iscpi = I1->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference));
284 if (isevi) {
285 const Handle(TopOpeBRepDS_EdgeVertexInterference)& EVI = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I1);
286 newI = new TopOpeBRepDS_EdgeVertexInterference(T,TopOpeBRepDS_FACE,IB1,G1,EVI->GBound(),
287 TopOpeBRepDS_UNSHGEOMETRY,EVI->Parameter());
288 }
289 if (iscpi) {
290 const Handle(TopOpeBRepDS_CurvePointInterference)& CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I1);
291 newI = new TopOpeBRepDS_CurvePointInterference(T,TopOpeBRepDS_FACE,IB1,TopOpeBRepDS_POINT,G1,CPI->Parameter());
292 }
293
294#ifdef DEB
295 if (TRC){cout<<"reduced T E"<<SIX<<" ";newI->Dump(cout);cout<<endl;}
296#endif
297 if (!newI.IsNull()) {
298 reducedLI.Append(newI);
299 LI.Remove(it1);
300 }
301 }
302 else
303 it1.Next();
304 } // it1
305
306#ifdef DEB
307 if (TRC) {
308 cout<<"ReducerEdge3d E"<<SIX<<" -> nIreduced "<<reducedLI.Extent();
309 cout<<" + nInonreduced "<<LI.Extent()<<endl<<endl;
310 }
311#endif
312}
313
314//------------------------------------------------------
315static void FUN_ReducerEdge(const Standard_Integer SIX,const TopOpeBRepDS_DataStructure& BDS,
316 TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& reducedLI)
317//------------------------------------------------------
318{
319#ifdef DEB
320 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
321// TRC = Standard_False; //MOINSTRACE
322 if (TRC) cout<<endl<<"ReducerEdge E"<<SIX<<" <- nI "<<LI.Extent()<<endl;
323#endif
324
325 FDS_repvg(BDS,SIX,TopOpeBRepDS_VERTEX,LI,reducedLI);
326 FDS_reduceONFACEinterferences(LI,BDS,SIX);
327 FDS_repvg(BDS,SIX,TopOpeBRepDS_POINT,LI,reducedLI);
328
329#ifdef DEB
330 if (TRC) cout<<"ReducerEdge E"<<SIX<<" -> nI "<<LI.Extent()<<endl<<endl;
331#endif
332}
333
334//------------------------------------------------------
335static void FUN_ReducerSDEdge(const Standard_Integer SIX,const TopOpeBRepDS_DataStructure& BDS,
336 TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& reducedLI)
337//------------------------------------------------------
338{
339 reducedLI.Clear();
340 Standard_Integer nI = LI.Extent();
341#ifdef DEB
342 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
343 TRC = Standard_False; //MOINSTRACE
344 if (TRC) cout<<endl<<"ReducerSDEdge E"<<SIX<<" <- nI "<<nI<<endl;
345#endif
346 if (nI <= 1) return;
347
348 TopOpeBRepDS_ListOfInterference newLI;
349 const TopoDS_Shape& EIX = BDS.Shape(SIX);
350 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
351 for (tki.Init(); tki.More(); tki.Next()) {
352 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
353 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi;
354
355 TopOpeBRepDS_ListIteratorOfListOfInterference it1(loi);
356 while (it1.More()) {
357 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); const TopOpeBRepDS_Transition& T1 = I1->Transition();
358 TopAbs_Orientation O1 = T1.Orientation(TopAbs_IN); Standard_Integer IB1 = T1.Index();
359 Standard_Boolean cond1 = FUN_ds_sdm(BDS,EIX,BDS.Shape(IB1));
360 if (!cond1) {newLI.Append(I1); it1.Next(); continue;}
361
362 Standard_Boolean complex1d = Standard_False;
363 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1);
364 if (it2.More()) it2.Next();
365 else break;
366
367 TopOpeBRepDS_Transition T(TopAbs_IN,TopAbs_IN,TopAbs_EDGE,TopAbs_EDGE);
368 while (it2.More()){
369 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value(); const TopOpeBRepDS_Transition& T2 = I2->Transition();
370 TopAbs_Orientation O2 = T2.Orientation(TopAbs_IN); Standard_Integer IB2 = T2.Index();
371 Standard_Boolean cond2 = FUN_ds_sdm(BDS,EIX,BDS.Shape(IB2));
372 if (!cond2) {newLI.Append(I2); it2.Next(); continue;}
373
374 complex1d = (M_FORWARD(O1) && M_REVERSED(O2));
375 complex1d = complex1d || (M_FORWARD(O2) && M_REVERSED(O1));
376 if (!complex1d) {newLI.Append(I2); it2.Next(); continue;}
377
378 if (complex1d) {
379 Standard_Integer IB = (M_REVERSED(O1)) ? IB1 : IB2; T.IndexBefore(IB);
380 Standard_Integer IA = (M_REVERSED(O1)) ? IB2 : IB1; T.IndexAfter(IA);
381 }
382 loi.Remove(it2);
383 break; // no more than 2 interferences on sdmTRASHA at same G
384 } // it2
385
386 if (complex1d) {
387 const Handle(TopOpeBRepDS_EdgeVertexInterference)& EVI = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I1);
388 TopOpeBRepDS_Config cEIX=BDS.SameDomainOri(SIX), c1=BDS.SameDomainOri(IB1);
389 TopOpeBRepDS_Config Conf = (cEIX == c1) ? TopOpeBRepDS_SAMEORIENTED : TopOpeBRepDS_DIFFORIENTED;
390 Handle(TopOpeBRepDS_Interference) newI = new TopOpeBRepDS_EdgeVertexInterference(T,TopOpeBRepDS_EDGE,IB1,G,EVI->GBound(),Conf,EVI->Parameter());
391 reducedLI.Append(newI);
392 it1.Next();
393 }
394 else {
395 newLI.Append(I1);
396 loi.Remove(it1);
397 }
398 } // it1
399 } // tki
400
401 LI.Clear(); LI.Append(newLI);
402
403#ifdef DEB
404 if (TRC) cout<<"ReducerSDEdge E"<<SIX<<" -> nI "<<LI.Extent()<<endl<<endl;
405#endif
406}
407
408//------------------------------------------------------
409static void FUN_reclSE2(const Standard_Integer SIX,const TopOpeBRepDS_DataStructure& BDS,
410 TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_ListOfInterference& reducedLI)
411//------------------------------------------------------
412// reducing LI = {I = (T(edge),G0,edge)}
413// edge <SIX> is same domain with edge <SE>
414// {I1 = (OU/IN(SE),VG,SE)
415// I2 = (IN/OU(SE),VG,SE))} -> Ir = (IN/IN(SE),VG,SE)
416{
417 reducedLI.Clear();
96a95605 418#ifdef DEB
7fd59977 419 Standard_Integer nI = LI.Extent(); // DEB
96a95605 420#endif
7fd59977 421
422 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(SIX));
423
424#ifdef DEB
425 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
426 TRC = Standard_False; //MOINSTRACE
427 if (TRC) cout<<endl<<"reclSE2 E"<<SIX<<" <- nI "<<nI<<endl;
428#endif
429
430 TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI);
431 while (it1.More()) {
432 const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
433 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
434
435 const TopOpeBRepDS_Transition& T1 = I1->Transition(); TopAbs_Orientation O1 = T1.Orientation(TopAbs_IN);
436 if (M_INTERNAL(O1) || M_EXTERNAL(O1)) {it1.Next(); continue;}
437 TopAbs_Orientation cO1 = TopAbs::Complement(O1);
438
439 const TopoDS_Vertex& v1 = TopoDS::Vertex(BDS.Shape(G1));
440 const TopoDS_Edge& E1 = TopoDS::Edge(BDS.Shape(S1));
441 TopoDS_Vertex vclo1; Standard_Boolean iscE1 = TopOpeBRepTool_TOOL::ClosedE(E1,vclo1);
442 if (!iscE1) {it1.Next(); continue;}
443 if (!vclo1.IsSame(v1)) {it1.Next(); continue;}
444
445 Standard_Boolean sdm = FUN_ds_sdm(BDS,E,E1);
446 if (!sdm) {it1.Next(); continue;}
447
448 Standard_Boolean hascO = Standard_False;
449 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1);
450 if (it2.More()) it2.Next();
451 else {it1.Next(); continue;}
452 while ( it2.More()){
453 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
454 const TopOpeBRepDS_Transition& T2 = I2->Transition(); TopAbs_Orientation O2 = T2.Orientation(TopAbs_IN);
455 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2);
456
457 if (S1 != S2) {it2.Next(); continue;}
458 if (O2 != cO1) {it2.Next(); continue;}
459
460 LI.Remove(it2);
96a95605 461#ifdef DEB
7fd59977 462 nI = LI.Extent(); // DEB
96a95605 463#endif
7fd59977 464 hascO = Standard_True; break;
465 } //it2
466
467 if (hascO) {
468 I1->ChangeTransition().Set(TopAbs_INTERNAL);
469 reducedLI.Append(I1); LI.Remove(it1);
96a95605 470#ifdef DEB
7fd59977 471 nI = LI.Extent(); // DEB
96a95605 472#endif
7fd59977 473 }
474 else it1.Next();
475 } //it1
476
477#ifdef DEB
478 if (TRC) cout<<"reclSE2 E"<<SIX<<" -> nI "<<LI.Extent()<<endl<<endl;
479#endif
480} // FUN_reclSE2
481
482//------------------------------------------------------
483Standard_EXPORT void FUN_reclSE(const Standard_Integer EIX,const TopOpeBRepDS_DataStructure& BDS,
484 TopOpeBRepDS_ListOfInterference& LOI,TopOpeBRepDS_ListOfInterference& RLOI)
485//------------------------------------------------------
486{
487 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LOI);
488#ifdef DEB
489 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
490 TRC = Standard_False; //MOINSTRACE
491 if (TRC) cout<<endl<<"reclSE E"<<EIX<<" <- "<<LOI.Extent()<<endl;
492 if (TRC) tki.DumpTKIIterator("","\n");
493#endif
494
495 LOI.Clear();
496 for (tki.Init(); tki.More(); tki.Next()) {
497 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
498 if (K != TopOpeBRepDS_VERTEX) continue;
499
500#ifdef DEB
501 if (TRC) {tki.DumpTKI(K,G,"","\n");}
502#endif
503 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi;
504 Standard_Integer nloi = loi.Extent();
505 if (nloi == 0) continue;
506 else if (nloi == 1) LOI.Append(loi);
507 else {
508 FUN_reclSE2(EIX,BDS,loi,Rloi);
509 LOI.Append(loi); RLOI.Append(Rloi);
510 }
511 }
512
513#ifdef DEB
514 if (TRC) cout<<"reclSE E"<<EIX<<" -> reste "<<LOI.Extent()<<" + reduit "<<RLOI.Extent()<<endl<<endl;
515#endif
516} // FUN_reclSE
517
518//------------------------------------------------------
519static void FUN_unkeepEVIonGb1(const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer EIX,TopOpeBRepDS_ListOfInterference& LI)
520//------------------------------------------------------
521// LI = {I attached to <E> = (T,G,S)}, unkeep I = EVI with G = vertex of <E>
522{
523
524#ifdef DEB
525 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
526 TRC = Standard_False; //MOINSTRACE
527 if (TRC) {cout<<endl;debreducerE(EIX);}
528#endif
529
530 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
531
532 TopOpeBRepDS_ListIteratorOfListOfInterference it(LI);
533 while (it.More()) {
534 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
535 Standard_Boolean evi = I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference));
536 if (!evi) {it.Next(); continue;}
537 TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S);
538 if (GT != TopOpeBRepDS_VERTEX){it.Next(); continue;}
539
540 const TopoDS_Vertex& V = TopoDS::Vertex(BDS.Shape(G));
541 Standard_Integer o = FUN_tool_orientVinE(V,E);
542 if (o == 0){it.Next(); continue;}
543#ifdef DEB
544 if (TRC) {cout<<"-> rejet EVI on Gb 1 on "<<EIX<<" : ";I->Dump(cout);cout<<endl;}
545#endif
546 LI.Remove(it);
547 }
548}
549
550// ---------------------------------------------------------
551//unreferenced function, commented
552/*#ifdef DEB
553static void FUN_reorder(const Standard_Integer EIX, const Handle(TopOpeBRepDS_HDataStructure)& HDS,TopOpeBRepDS_ListOfInterference& LIR, TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& LIend)
554// ---------------------------------------------------------
555// at same G :in <LI> I =(T, G, S)
556// in <LRI> Ir =(Tr,G,Sr)
557// I gives less information than reduced Ir
558{
559
560 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
561 TRC = Standard_False; //MOINSTRACE
562 if (TRC) cout<<endl<<"FUN_reorder :"<<endl;
563 TopOpeBRepDS_Dumper DSD(HDS);
564
565 LIend.Clear();
566
567 TopOpeBRepDS_TKI tki;
568 tki.FillOnGeometry(LI);
569
570 TopOpeBRepDS_TKI tkiR;
571 tkiR.FillOnGeometry(LIR);
572
573 for (tkiR.Init(); tkiR.More(); tkiR.Next()) {
574 TopOpeBRepDS_Kind K; Standard_Integer G; tkiR.Value(K,G);
575
576 tki.Init();
577 Standard_Boolean isbound = tki.IsBound(K,G);
578 if (!isbound) continue;
579
580 TopOpeBRepDS_ListOfInterference& loiR = tkiR.ChangeValue(K,G);
581 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
582#ifdef DEB
583 if (TRC) {TCollection_AsciiString bb("lIreduced");bb += TCollection_AsciiString(G);DSD.DumpLOI(loiR,cout,bb);
584 TCollection_AsciiString aa("lI");aa+=TCollection_AsciiString(G);DSD.DumpLOI(loi,cout,aa);}
585#endif
586 loiR.Append(loi);
587 }
588
589#ifdef DEB
590 if (TRC) cout<<"-> ordered :"<<endl;
591#endif
592 for (tkiR.Init(); tkiR.More(); tkiR.Next()) {
593 TopOpeBRepDS_Kind K; Standard_Integer G; TopOpeBRepDS_ListOfInterference& loi = tkiR.ChangeValue(K,G);
594#ifdef DEB
595 if (TRC) {TCollection_AsciiString aa("lI");aa+=TCollection_AsciiString(G);DSD.DumpLOI(loi,cout,aa);}
596#endif
597 LIend.Append(loi);
598 }
599
600#ifdef DEB
601 if (TRC) cout<<"-> residual :"<<endl;
602#endif
603 for (tki.Init(); tki.More(); tki.Next()) {
604 TopOpeBRepDS_Kind K; Standard_Integer G; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
605#ifdef DEB
606 if (TRC) {TCollection_AsciiString aa("lI");aa+=TCollection_AsciiString(G);DSD.DumpLOI(loi,cout,aa);}
607#endif
608 LIend.Append(loi);
609 }
610}
611#endif
612*/
613
614static void FUN_keepl3dF(const Standard_Integer
615#ifdef DEB
616 SIX
617#endif
618 ,const Handle(TopOpeBRepDS_HDataStructure)&
619#ifdef DEB
620 HDS
621#endif
622 ,const TopOpeBRepDS_ListOfInterference& l3dF
623 ,const TopOpeBRepDS_ListOfInterference& LR3dFE,
624 TopOpeBRepDS_ListOfInterference& l3dFkeep)
625//purpose : soit I de l3dF, on cherche IR interf dans LR3dFE de meme geometrie
626// si on n'en trouve pas, l3dFkeep += I
627{
628#ifdef DEB
629 Standard_Boolean TRC=DSREDUEDGETRCE(SIX);
630 TRC = Standard_False; //MOINSTRACE
631 if (TRC) cout<<endl<<"keepl3dF E"<<SIX<<endl;
632 TopOpeBRepDS_Dumper DSD(HDS);
633#endif
634
635 TopOpeBRepDS_TKI tki;
636 tki.FillOnGeometry(l3dF);
637
638 TopOpeBRepDS_TKI tkiR;
639 tkiR.FillOnGeometry(LR3dFE);
640
641 for (tki.Init(); tki.More(); tki.Next()) {
642 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
643 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
644 tkiR.Init();
645 Standard_Boolean isbound = tkiR.IsBound(K,G);
646 if (!isbound) {l3dFkeep.Append(loi);}
647
648#ifdef DEB
649 if (TRC) {TCollection_AsciiString bb("l3dFkeep");bb += TCollection_AsciiString(G);DSD.DumpLOI(loi,cout,bb);cout<<endl;}
650#endif
651 }
652} // FUN_keepl3dF
653
654static void FUN_reducepure2dI0(TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& RLI)
655// xpu210798 : CTS21216 (e7,G=P3,S=E9,FTRASHA=f8,f10)
656// LI attached to section edge
657// 2dI1=(REVERSED(ftrasha1),G,ES), 2dI2=(FORWARD(ftrasha2),G,ES)
658// for the compute of splitON(EIX), reduce 2dI1+2dI2 -> 2dR=(IN(ftrasha1,ftrasha2)
659// LI-> RLI + LI
660{
661 const Handle(TopOpeBRepDS_Interference)& I1 = LI.First();
662 TopAbs_Orientation O1 = I1->Transition().Orientation(TopAbs_IN);
663 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
664 FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
665
666 const Handle(TopOpeBRepDS_Interference)& I2 = LI.Last();
667 TopAbs_Orientation O2 = I2->Transition().Orientation(TopAbs_IN);
668 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2;
669 FDS_Idata(I2,tsb2,isb2,tsa2,isa2,GT2,G2,ST2,S2);
670
671 if (isb1 == isb2) return; //xpu170898 FOR+REV ->INT/EXT (cto009B1(es6,p1,f9))
672
673 // recall : G1==G2 && ST1==ST2==EDGE
674 Standard_Boolean ok = (G1==G2);
675 ok = ok && (tsb1 == TopAbs_FACE) && (tsb1==tsb2) && (isb1==isa1) && (isb2==isa2);
676 if (!ok) return;
677
678 Standard_Boolean int12 = M_REVERSED(O1) && M_FORWARD(O2);
679 Standard_Boolean int21 = M_REVERSED(O2) && M_FORWARD(O1);
680 ok = int12 || int21;
681 if (!ok) return;
682
683 TopOpeBRepDS_Transition newT(TopAbs_INTERNAL);
684 Standard_Integer bef = int12? isb1 : isb2;
685 Standard_Integer aft = int21? isb1 : isb2;
686 newT.IndexBefore(bef); newT.IndexAfter(aft);
687 I1->ChangeTransition() = newT;
688 RLI.Append(I1);
689 LI.Clear();
690} // FUN_reducepure2dI0
691
692static void FUN_reducepure2dI(TopOpeBRepDS_ListOfInterference& LI, TopOpeBRepDS_ListOfInterference& RLI)
693{
694 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
695 TopOpeBRepDS_ListOfInterference newLI;
696 for (tki.Init(); tki.More(); tki.Next()) {
697 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
698 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G); TopOpeBRepDS_ListOfInterference Rloi;
699 Standard_Integer nloi = loi.Extent();
700 Standard_Boolean ok = (nloi == 2) && (K == TopOpeBRepDS_POINT);
701 if (ok) ::FUN_reducepure2dI0(loi,Rloi);
702 RLI.Append(Rloi);
703 newLI.Append(loi);
704 }
705 LI.Clear(); LI.Append(newLI);
706} // FUN_reducepure2dI
707
708//=======================================================================
709//function : TopOpeBRepDS_EIR
710//purpose :
711//=======================================================================
712TopOpeBRepDS_EIR::TopOpeBRepDS_EIR
713(const Handle(TopOpeBRepDS_HDataStructure)& HDS) : myHDS(HDS)
714{}
715
716//=======================================================================
717//function : ProcessEdgeInterferences
718//purpose :
719//=======================================================================
720void TopOpeBRepDS_EIR::ProcessEdgeInterferences()
721{
722 TopOpeBRepDS_DataStructure& BDS = myHDS->ChangeDS();
723 Standard_Integer i,nshape = BDS.NbShapes();
724 for (i = 1; i <= nshape; i++) {
725 const TopoDS_Shape& S = BDS.Shape(i);
726 if(S.IsNull()) continue;
727 if ( S.ShapeType() == TopAbs_EDGE ) {
728 ProcessEdgeInterferences(i);
729 }
730 }
731}
732static void FUN_ProcessEdgeInterferences(const Standard_Integer EIX
733 , const TopOpeBRepDS_Kind
734#ifdef DEB
735 K
736#endif
737 ,const Standard_Integer
738#ifdef DEB
739 G
740#endif
741 , const Handle(TopOpeBRepDS_HDataStructure)& HDS,
742 TopOpeBRepDS_ListOfInterference& LI)
743{
744 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
745 const TopoDS_Shape& E = BDS.Shape(EIX);
746#ifdef DEB
747 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
748 if (TRC) {
749 cout<<endl;debreducerE(EIX);cout<<"EIR E"<<EIX;
750 if(K==TopOpeBRepDS_POINT)cout<<",point";
751 else cout<<",vertex";
752 cout<<G<<endl;
753 }
754#endif
755
7fd59977 756 // LI -> (lF + lFE) + lE + [LI]
757 // lF = {interference on edge <EIX> : (T(face),G=POINT/VERTEX,S)
758 // lFE = {interference on edge <EIX> : (T(face),G=POINT/VERTEX,S=EDGE)
759 // lE = {interference on edge <EIX> : (T(edge),G=POINT/VERTEX,S)
96a95605
DB
760 TopOpeBRepDS_ListOfInterference lF; FUN_selectTRASHAinterference(LI,TopAbs_FACE,lF);
761 TopOpeBRepDS_ListOfInterference lFE; FUN_selectSKinterference(lF,TopOpeBRepDS_EDGE,lFE);
762 TopOpeBRepDS_ListOfInterference lE; FUN_selectTRASHAinterference(LI,TopAbs_EDGE,lE);
7fd59977 763
764#ifdef DEB
765 TopOpeBRepDS_Dumper DSD(HDS);
766 Standard_Boolean trcl = TRC;
767// trcl = Standard_False; // MOINSTRACE
768#endif
769
770 // xpu210798 : CTS21216 (e7,G=P3,S=E9,FTRASHA=f8,f10)
771 // EIX is section edge
772 // 2dI1=(REVERSED(ftrasha1),G,ES), 2dI2=(FORWARD(ftrasha2),G,ES)
773 // for the compute of splitON(EIX), reduce 2dI1+2dI2 -> 2dR=(IN(ftrasha1,ftrasha2)
774 Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(E));
775 if (isse) {
776 TopOpeBRepDS_ListOfInterference lI2dFE,lRI2dFE;
777 // lF -> lF
778 // lFE -> lI2dFE + [lFE] / lI2dFE={FEI=(T(FTRASHA),G,SE) : no FFI=(T(FTRASHA),G,FTRASHA)}
779 FUN_selectpure2dI(lF,lFE,lI2dFE);
780#ifdef DEB
781 if (trcl) {
782 cout<<endl<<"lI2dFE -> lRI2dFE + lI2dFE"<<endl;
783 TCollection_AsciiString aa("lI2dFE :"); DSD.DumpLOI(lI2dFE,cout,aa);
784 }
785#endif
786 ::FUN_reducepure2dI(lI2dFE,lRI2dFE); // lI2dFE -> lRI2dFE + lI2dFE
787#ifdef DEB
788 if (trcl) { TCollection_AsciiString bb("lRI2dFE :"); DSD.DumpLOI(lRI2dFE,cout,bb);}
789#endif
790 lFE.Append(lI2dFE); lFE.Append(lRI2dFE);
791 }
792
793 // I -> 3dI +2dI + 1dI:
794 // -------------------
795 // lFE -> l3dFE [+l3dFEresi] +l2dFE [+lFE (+lFEresi)]
796 // : l3dFE={I3d } to reduce; for I3dFE=(T(F),G,SE) there is I3dF=(T(F),G,F)
797 // l2dFE={I2d} to reduce
798 // lFEresi to remove
799 // lF -> l3dF [+lF] : l3dF to remove
800
801 // lE -> l1dE +l1dEsd [+lE}
802 // : l1dE={I1d=(T(ETRA),G,ETRA)/same ETRA} to reduce
803 // l2dEsd={I1dsd=(T(ETRA),G,ETRA)/ E sdm ETRA}
804
805 TopOpeBRepDS_ListOfInterference lFEresi,l3dFE,l3dF,l3dFEresi,l2dFE;
806 FUN_select3dinterference(EIX,BDS,lF,l3dF,
807 lFE,lFEresi,l3dFE,l3dFEresi,
808 l2dFE);
809 TopOpeBRepDS_ListOfInterference l1dE; FUN_select2dI(EIX,BDS,TopAbs_EDGE,lE,l1dE);
810 TopOpeBRepDS_ListOfInterference l1dEsd; FUN_select1dI(EIX,BDS,lE,l1dEsd);
811
812#ifdef DEB
813 if (trcl) {
814 cout<<"lFE("<<EIX<<") -> l3dFE (S=EDGE) [+l3dFEresi] + l2dFE + [lFE +lFEresi]"<<endl;
815 TCollection_AsciiString oo("lFE :");DSD.DumpLOI(lFE,cout,oo);
816 TCollection_AsciiString pp("lFEresi :");DSD.DumpLOI(lFEresi,cout,pp);
817 TCollection_AsciiString bb("l3dFE :");DSD.DumpLOI(l3dFE,cout,bb);
818 TCollection_AsciiString bb1("l3dFEresi :");DSD.DumpLOI(l3dFEresi,cout,bb1);
819 TCollection_AsciiString ll("l2dFE :");DSD.DumpLOI(l2dFE,cout,ll);
820 cout<<"lF("<<EIX<<") -> l3dF (S=FACE) [+lF]"<<endl;
821 TCollection_AsciiString cc("lF :"); DSD.DumpLOI(lF,cout,cc);
822 TCollection_AsciiString aa("l3dF :"); DSD.DumpLOI(l3dF,cout,aa);
823 cout<<"lE("<<EIX<<") -> l1dE + lE"<<endl;
824 TCollection_AsciiString ee("lE :"); DSD.DumpLOI(lE,cout,ee);
825 TCollection_AsciiString ff("l1dE :"); DSD.DumpLOI(l1dE,cout,ff);
826 TCollection_AsciiString gg("l1dEsd :"); DSD.DumpLOI(l1dEsd,cout,gg);}
827#endif
828
829 // reducer3d :
830 // ----------
831 // l3dFE -> lR3dFE [+l3dFE (non reduced 3dI)]
832 TopOpeBRepDS_ListOfInterference lR3dFE; FUN_ReducerEdge3d(EIX,BDS,l3dFE,lR3dFE);
833#ifdef DEB
834 if (trcl) { cout<<"l3dFE("<<EIX<<") -> lR3dFE + l3dFE"<<endl;
835 TCollection_AsciiString aa("lR3dFE :");DSD.DumpLOI(lR3dFE,cout,aa);
836 TCollection_AsciiString bb("l3dFE :"); DSD.DumpLOI(l3dFE,cout,bb);}
837#endif
838
839// FUN_unkeepEVIonGb1(BDS,EIX,l1dE); // filter :
840// FUN_unkeepEVIonGb1(BDS,EIX,l2dFE); // filter :
841
842 // no reduction on G : we keep l3dF(G)
843 TopOpeBRepDS_ListOfInterference l3dFkeep; FUN_keepl3dF(EIX,HDS,l3dF,lR3dFE,l3dFkeep);
844 lF.Append(l3dFkeep);
845
846 // reducer2d :
847 // ----------
848 // l2dFE -> LR2dFE + l2dFE (non reduced 2dI)
849 TopOpeBRepDS_ListOfInterference LR2dFE; FUN_ReducerEdge(EIX,BDS,l2dFE,LR2dFE);
850
851 // reducer1d :
852 // ----------
853 // xpu210498 : reduce interferences I1(T1(esd1),VG,esd1), I2(T2(esd2),VG,esd2)
854 // if EIX sdm {esd1,esd2}
855 // - t2_2 e32 has I1(in/ou(e32),v30,e20) && I2(ou/in(e20),v30,e20) -
856 TopOpeBRepDS_ListOfInterference lR1dEsd; FUN_ReducerSDEdge(EIX,BDS,l1dEsd,lR1dEsd);
857
858 // xpu190298 : edge <EIX> same domain with closed support edge <SE>
859 // at same G = vertex <VG> = closing vertex of <SE>
860 // (I1 = (OU/IN(SE),VG,SE) && I2 = (IN/OU(SE),VG,SE)) -> Ir = (IN/IN(SE),VG,SE)
861 TopOpeBRepDS_ListOfInterference lR1dclosedSE; FUN_reclSE(EIX,BDS,l1dE,lR1dclosedSE);
862
863 // l1dE -> LR1dE + l1dE (non reduced 2dI)
864 TopOpeBRepDS_ListOfInterference LR1dE; FUN_ReducerEdge(EIX,BDS,l1dE,LR1dE);
865
866 // attached to edge <EIX>,
867 // at same G : I =(T, G,S) gives less information than
868 // Ir =(Tr,G,Sr) -reduced interference- with valid Tr
869 // -> unkeep I.
870 // using reduced I : lR3dFE, LR2dFE, LR1dE
871 TopOpeBRepDS_ListOfInterference LRI;
872 LRI.Append(lR1dEsd); LRI.Append(LR1dE); LRI.Append(lR1dclosedSE);
873 LRI.Append(LR2dFE);
874 LRI.Append(lR3dFE);
875
876 lF.Append(lFE); lF.Append(l3dFE); lF.Append(l2dFE);// lF += LFE + l3dFE + l2dFE
877 lE.Append(l1dE); // lE += l1dE
878 lE.Append(l1dEsd); // lE += l1dEsd xpu210498
879// TopOpeBRepDS_ListOfInterference LItmp; LItmp.Append(lF); LItmp.Append(lE);
880
881 // xpu : 23-01-98 : attached to edge <EIX>,
882 // at same G : I =(T, G, S) gives less information than
883 // Ir =(Tr,G,Sr) -reduced interference-
884 // -> I is added after Ir to help the edge builder.
885 LI.Clear();
886 LI.Append(LRI);LI.Append(lE);LI.Append(lF);
887// FUN_reorder(EIX,HDS,LRI, LItmp, LI);
888
889 // xpu260698 : cto902A5, spOU(e6)
890 // cto801G1, spON(se26)
891 if (isse) {
892 FUN_unkeepEVIonGb1(BDS,EIX,LI); // filter :
893 }
894//FUN_unkeepEVIonGb1(BDS,EIX,LI); // filter :
895
896#ifdef DEB
897 if (TRC){TCollection_AsciiString aa("reduced->");DSD.DumpLOI(LI,cout,aa);}
898#endif
899} // ProcessEdgeInterferences
900
901//=======================================================================
902//function : ProcessEdgeInterferences
903//purpose :
904//=======================================================================
905void TopOpeBRepDS_EIR::ProcessEdgeInterferences(const Standard_Integer EIX)
906{
907 TopOpeBRepDS_DataStructure& BDS = myHDS->ChangeDS();
908
909#ifdef DEB
910 TopOpeBRepDS_Dumper DSD(myHDS);
911 Standard_Boolean TRC=DSREDUEDGETRCE(EIX);
912 if (TRC) {cout<<endl;debreducerE(EIX);}
913#endif
914
915 // E is the edge, LI is list of interferences to compact
916 const TopoDS_Edge& E = TopoDS::Edge(BDS.Shape(EIX));
917 Standard_Boolean isdg = BRep_Tool::Degenerated(E);
918 if (isdg) return;
919
920 TopOpeBRepDS_ListOfInterference& LI = BDS.ChangeShapeInterferences(EIX);
921 TopOpeBRepDS_TKI newtki; newtki.FillOnGeometry(LI);
922 TopOpeBRepDS_TKI tki; tki.FillOnGeometry(LI);
923 for (tki.Init(); tki.More(); tki.Next()) {
924 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
925 const TopOpeBRepDS_ListOfInterference& loi = tki.Value(K,G);
926 if (K==TopOpeBRepDS_POINT) continue;
927 const TopoDS_Shape& vG = BDS.Shape(G);
928 TopoDS_Shape oovG; Standard_Boolean sdm = FUN_ds_getoov(vG,BDS,oovG);
929 if (!sdm) continue;
930 Standard_Integer OOG=BDS.Shape(oovG);
931 if (OOG == 0) continue;//NYIRaise
932
933 Standard_Boolean isb = newtki.IsBound(K,OOG);
934
935 // xpu201098 : cto904F6, e10,v6
936 Standard_Boolean isbound = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(loi.First())->GBound();
937 if (isbound) { // replacing vG with oovG
938 TopOpeBRepDS_ListIteratorOfListOfInterference it(loi); TopOpeBRepDS_ListOfInterference newloi;
939 for (; it.More(); it.Next()){
940 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
941 TopOpeBRepDS_Kind GT,ST;
942 Standard_Integer G1,S;
943 FDS_data(I,GT,G1,ST,S);
944 Standard_Real par = FDS_Parameter(I);
945 Handle(TopOpeBRepDS_Interference) newI = MakeEPVInterference(I->Transition(),S,OOG,par,K,ST,Standard_False);
946 newloi.Append(newI);
947#ifdef DEB
948 if (TRC) {cout<<"on e"<<EIX;I->Dump(cout);cout<<"gives ";newI->Dump(cout);cout<<endl;}
949#endif
950 }
951 newtki.ChangeInterferences(K,G).Clear();
952 if (!isb) newtki.Add(K,OOG);
953 newtki.ChangeInterferences(K,OOG).Append(newloi);
954 continue;
955 }
956
957 if (!isb) continue;
958 TopOpeBRepDS_ListOfInterference& li = newtki.ChangeInterferences(K,OOG);
959 newtki.ChangeInterferences(K,G).Append(li);
960 } // tki
961
962 TopOpeBRepDS_ListOfInterference LInew;
963 for (newtki.Init(); newtki.More(); newtki.Next()) {
964 TopOpeBRepDS_Kind K; Standard_Integer G; newtki.Value(K,G);
965 TopOpeBRepDS_ListOfInterference& loi = newtki.ChangeValue(K,G);
966 ::FUN_ProcessEdgeInterferences(EIX,K,G,myHDS,loi);
967 LInew.Append(loi);
968 }
969 LI.Clear();
970 LI.Append(LInew);
971
972 Standard_Boolean performPNC = Standard_False; // JYL 28/09/98 : temporaire
973#ifdef DEB
974 if (TopOpeBRepDS_GetcontextNOPNC()) performPNC = Standard_False;
975 if (TRC) debredpnc(EIX);
976#endif
977 if (!performPNC) return;
978
979 // suppression des I/G(I) n'est accede par aucune courbe
980 // portee par une des faces cnx a EIX.
981 Standard_Boolean isfafa = BDS.Isfafa();
982 if (!isfafa) {
983
984 tki.Clear();
985 tki.FillOnGeometry(LI);
986 LI.Clear();
987
988 for (tki.Init(); tki.More(); tki.Next()) {
989 TopOpeBRepDS_Kind K; Standard_Integer G; tki.Value(K,G);
990 TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
7fd59977 991 if (K != TopOpeBRepDS_POINT) {
992 LI.Append(loi);
993 continue;
994 }
995
996 const TopTools_ListOfShape& lfx = FDSCNX_EdgeConnexitySameShape(E,myHDS);
997#ifdef DEB
998// Standard_Integer nlfx = lfx.Extent();
999#endif
1000
1001 // nlfx < 2 => 0 ou 1 face accede E => pas d'autre fcx pouvant generer une courbe 3d
1002 TopTools_ListIteratorOfListOfShape itlfx(lfx);
1003 Standard_Boolean curvefound = Standard_False;
1004 for (; itlfx.More();itlfx.Next()) {
1005 const TopoDS_Face& fx = TopoDS::Face(itlfx.Value());
1006// BDS.Shape(fx);
1007 const TopOpeBRepDS_ListOfInterference& lifx = BDS.ShapeInterferences(fx); TopOpeBRepDS_ListIteratorOfListOfInterference itlifx(lifx);
1008 if (!itlifx.More()) continue;
1009
1010 Handle(TopOpeBRepDS_Interference) I1;TopOpeBRepDS_Kind GT1;Standard_Integer G1;TopOpeBRepDS_Kind ST1;Standard_Integer S1;
1011 for (; itlifx.More(); itlifx.Next()) {
1012 FDS_data(itlifx,I1,GT1,G1,ST1,S1);
1013 Standard_Boolean isfci = (GT1 == TopOpeBRepDS_CURVE);
1014 if (!isfci) continue;
1015
1016 TopOpeBRepDS_ListOfInterference& lic = BDS.ChangeCurveInterferences(G1);
1017 TopOpeBRepDS_ListIteratorOfListOfInterference itlic(lic);
1018 if (!itlic.More()) continue;
1019
1020 Handle(TopOpeBRepDS_Interference) I2;TopOpeBRepDS_Kind GT2;Standard_Integer G2;TopOpeBRepDS_Kind ST2;Standard_Integer S2;
1021 for (; itlic.More(); itlic.Next()) {
1022 FDS_data(itlic,I2,GT2,G2,ST2,S2);
1023 Standard_Boolean isp = (GT2 == TopOpeBRepDS_POINT);
1024 if (!isp) continue;
1025 if ( G2 != G ) continue;
1026 curvefound = Standard_True;
1027 break;
1028 } // itlic.More()
1029
1030 if (curvefound) break;
1031 } // itlifx.More()
1032
1033 if (curvefound) break;
1034 } // itlfx.More()
1035
7fd59977 1036#ifdef DEB
1037// Standard_Integer nLI = LI.Extent();
1038#endif
1039 if (curvefound) {
1040 LI.Append(loi);
1041 }
1042 else {
1043#ifdef DEB
1044// if (TRC) {
1045// debredpnc(EIX);
1046 TCollection_AsciiString ss = "\n--- TopOpeBRepDS_EIR::ProcessEdgeInterferences : suppress pnc of E"; ss = ss + EIX;
1047 DSD.DumpLOI(loi,cout,ss);
1048// }
1049#endif
1050 }
1051
1052 } // tki.More()
1053 } // (!isfafa)
1054
1055} // ProcessEdgeInterferences
1056
1057// modified by NIZHNY-MKK Mon Apr 2 15:34:56 2001.BEGIN
1058static Standard_Boolean CheckInterferenceIsValid(const Handle(TopOpeBRepDS_Interference)& I,
1059 const TopoDS_Edge& theEdge,
1060 const TopoDS_Edge& theSupportEdge,
1061 const TopoDS_Vertex& theVertex) {
1062 Standard_Real pref = 0. ;
1063 Standard_Boolean ok = Standard_False;
1064 BRepAdaptor_Curve BC(theEdge);
1065
1066 Handle(TopOpeBRepDS_CurvePointInterference) CPI;
1067 CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I);
1068
1069 if(!CPI.IsNull()) {
1070 pref = CPI->Parameter();
1071 ok = Standard_True;
1072 }
1073
1074 if(!ok) {
1075 Handle(TopOpeBRepDS_EdgeVertexInterference) EVI = Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I);
1076 if(!EVI.IsNull()) {
1077 pref = EVI->Parameter();
1078 ok = Standard_True;
1079 }
1080 }
1081
1082 if(!ok)
1083 return ok;
1084
1085 gp_Pnt P3d1 = BC.Value(pref);
1086 Standard_Real dist, paronSupportE;
1087 ok = FUN_tool_projPonE(P3d1,theSupportEdge,paronSupportE,dist);
1088
1089 if(!ok)
1090 return ok;
1091 BRepAdaptor_Curve BCtmp(theSupportEdge);
1092 gp_Pnt P3d2 = BCtmp.Value(paronSupportE);
1093 Standard_Real Tolerance = (BRep_Tool::Tolerance(theEdge) > BRep_Tool::Tolerance(theSupportEdge)) ? BRep_Tool::Tolerance(theEdge) : BRep_Tool::Tolerance(theSupportEdge);
1094 if(!theVertex.IsNull()) {
1095 Tolerance = (BRep_Tool::Tolerance(theVertex) > Tolerance) ? BRep_Tool::Tolerance(theVertex) : Tolerance;
1096 }
1097 if(P3d1.Distance(P3d2) > Tolerance) {
1098 ok = Standard_False;
1099 }
1100
1101 return ok;
1102}