0024510: Remove unused local variables
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_ProcessEdgeInterferences.cxx
CommitLineData
b311480e 1// Created on: 1996-03-21
2// Created by: Modelistation
3// Copyright (c) 1996-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <TopOpeBRepDS_EXPORT.hxx>
18#include <TopOpeBRepDS_EdgeInterferenceTool.hxx>
19#include <TopOpeBRepDS_EdgeVertexInterference.hxx>
20#include <TopOpeBRepDS_CurvePointInterference.hxx>
21#include <TopOpeBRepDS_TKI.hxx>
22#include <TopoDS.hxx>
23#include <TopoDS_Shell.hxx>
24#include <TopoDS_Solid.hxx>
25#include <TopExp_Explorer.hxx>
26#include <TopExp.hxx>
27#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
28#include <BRep_Tool.hxx>
29#include <Precision.hxx>
30#include <Geom_Curve.hxx>
31#include <BRep_Builder.hxx>
32#include <TopOpeBRepDS_define.hxx>
33#include <TopOpeBRepTool_EXPORT.hxx>
34#include <TopOpeBRepDS_connex.hxx>
35#include <TopOpeBRepTool_SC.hxx>
36
37#ifdef DEB
1d0a9d4d 38extern Standard_Boolean TopOpeBRepDS_GettracePEI();
39extern Standard_Boolean TopOpeBRepDS_GettracePI();
40extern Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer);
41extern Standard_Boolean TopOpeBRepDS_GettraceEDPR();
7fd59977 42static Standard_Boolean TRCE(const Standard_Integer SIX) {
43 Standard_Boolean b1 = TopOpeBRepDS_GettracePEI();
44 Standard_Boolean b2 = TopOpeBRepDS_GettracePI();
45 Standard_Boolean b3 = TopOpeBRepDS_GettraceSPSX(SIX);
46 return (b1 || b2 || b3);
47}
48Standard_EXPORT void debredunke(const Standard_Integer i){cout<<"++ debredunke e"<<i<<endl;};
49Standard_EXPORT void debpurse (const Standard_Integer i){cout<<"++ debpurse e"<<i<<endl;};
50#endif
51
52#define MDShcpi Handle(TopOpeBRepDS_CurvePointInterference)
53#define MAKECPI(IJKLM) (Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(IJKLM))
54
55//------------------------------------------------------
56Standard_EXPORT Standard_Boolean FUN_vertexofedge
57//------------------------------------------------------
58// FUN_vertexofedge : True si le vertex V est un vertex de E
59(const TopoDS_Shape& V, const TopoDS_Shape& E)
60{
61 Standard_Boolean isv = Standard_False;
62 TopExp_Explorer ex;
63 for (ex.Init(E,TopAbs_VERTEX); ex.More(); ex.Next())
64// for (TopExp_Explorer ex(E,TopAbs_VERTEX); ex.More(); ex.Next())
65 if (ex.Current().IsSame(V) ) {
66 isv = Standard_True;
67 break;
68 }
69 return isv;
70}
71
72//------------------------------------------------------
73static Standard_Boolean FUN_keepEinterference
74//------------------------------------------------------
75(const TopOpeBRepDS_DataStructure& DS,const Handle(TopOpeBRepDS_Interference)& I,const TopoDS_Shape& E)
76{
77 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I,GT1,G1,ST1,S1);
78
79 Standard_Boolean res = Standard_True;
80 if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_EdgeVertexInterference)) ) {
81 // EVI I rejetee si son arete-support est E accedant I
82 Standard_Boolean k1 = ! ::FUN_interfhassupport(DS,I,E);
83 res = k1;
84
85 // EVI rejetee si transition ON EDGE before ou after
86 const TopOpeBRepDS_Transition& T = I->Transition();
87 TopAbs_ShapeEnum shab = T.ShapeBefore(),shaa = T.ShapeAfter();
88 TopAbs_State stab = T.Before(),staa = T.After();
89 Standard_Boolean k2 = ! (((shab == TopAbs_EDGE) && (stab == TopAbs_ON)) ||
90 ((shaa == TopAbs_EDGE) && (staa == TopAbs_ON)));
91 res = res && k2;
92
93 const TopoDS_Shape& VG = DS.Shape(I->Geometry());
94
95 /* xpu : 20-01-98
96 // EVI I rejetee si son vertex-geometrie est un vertex de l'arete
97 // qui accede I.
98 Standard_Boolean k3 = ! ::FUN_vertexofedge(VG,E);
99 res = res && k3;
100 */
101
102 // EVI rejetee si OUT FACE before et after
103 // et si le vertex-geometrie de l'interference collisionne avec
104 // un des vertex de l'arete (E) accedant l'interference (I)
105#ifdef DEB
106 // Standard_Boolean k4I = (((shab == TopAbs_FACE) && (stab == TopAbs_OUT)) &&
107// ((shaa == TopAbs_FACE) && (staa == TopAbs_OUT)));
108#endif
7fd59977 109 {
110 TopoDS_Vertex Vf,Vr; TopExp::Vertices(TopoDS::Edge(E),Vf,Vr);
111 TopTools_ListIteratorOfListOfShape it(DS.ShapeSameDomain(VG));
112 for (; it.More(); it.Next()) {
113 const TopoDS_Shape& Vsd = it.Value();
96a95605
DB
114 if ( Vsd.IsSame(Vf) ) { break; }
115 else if ( Vsd.IsSame(Vr) ) { break; }
7fd59977 116 }
117 }
118#ifdef DEB
119// Standard_Boolean k4 = ! ( k4I && k4C );
120#endif
121 // res = res && k4;
122 }
123
124 else if ( I->IsKind(STANDARD_TYPE(TopOpeBRepDS_CurvePointInterference)) ) {
125 Handle(TopOpeBRepDS_CurvePointInterference) aCPI =
126 Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I);
127
128 // MSV Oct 4, 2001: reject interference having the parameter coinciding with
129 // one of sides of the edge range
130
131 Standard_Real eps = Precision::PConfusion();
132 Standard_Real par = aCPI->Parameter();
133 Standard_Real f,l;
134 BRep_Tool::Range(TopoDS::Edge(E), f,l);
135 if (Abs(par-f) < eps || Abs(par-l) < eps)
136 res = Standard_False;
137 }
138
139 return res;
140}
141
142//------------------------------------------------------
143Standard_EXPORT Standard_Integer FUN_unkeepEinterferences
144//------------------------------------------------------
145(TopOpeBRepDS_ListOfInterference& LI,const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SIX)
146{
147#ifdef DEB
148 Standard_Boolean TRC=TRCE(SIX);
149#endif
150
151 const TopoDS_Shape& E = BDS.Shape(SIX);
152 Standard_Boolean isEd;
153 isEd = BRep_Tool::Degenerated(TopoDS::Edge(E));
154
155#ifdef DEB
156 if (TRC) {cout<<"FUN_unkeepEinterferences on "<<SIX<<" nI = "<<LI.Extent()<<endl;}
157#endif
158
159 if (isEd) {
160 return LI.Extent();
161 }
162
163 TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI);
164 while (it1.More() ) {
165 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
166 Standard_Boolean k1 = ::FUN_keepEinterference(BDS,I1,E);
167 if ( !k1 ) {
168
169#ifdef DEB
170 if(TRC) {cout<<endl<<"rejet d'interference "<<SIX<<endl;I1->Dump(cout);cout<<endl;}
171#endif
172
173 LI.Remove(it1);
174 continue;
175 }
176 else {
177 it1.Next();
178 }
179 }
180 Standard_Integer n = LI.Extent();
181
182#ifdef DEB
183 if (TRC) cout<<"FUN_unkeepEinterferences on "<<SIX<<" returns nI = "<<n<<endl;
184#endif
185
186 return n;
187} // FUN_unkeepEinterferences
188
189/*
190//------------------------------------------------------
191Standard_EXPORT void FUN_changeFOUT
192//------------------------------------------------------
193(TopOpeBRepDS_ListOfInterference& LF,const TopOpeBRepDS_ListOfInterference& LE,const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SIX)
194{
195#ifdef DEB
196 Standard_Boolean TRC=TRCE(SIX);
197 if (TRC) cout<<"FUN_changeFOUT on "<<SIX<<" nI = "<<LE.Extent()<<endl;
198#endif
199
200 const TopoDS_Shape& E = BDS.Shape(SIX);
201
202 // reduction du cas OUT(FACE),OUT(FACE) par un vertex si on
203 // trouve une transition EDGE par ce meme vertex.
204 // pour toute interference Fi de LF = OUT(FACE),OUT(FACE) par vertex V
205 // chercher une interference Ei de LE :
206 // 1/ Ei = IN(EDGE),OUT(EDGE) par vertex V <==> ON(FACE),OUT(EDGE) par vertex V
207 // 2/ Ei = OUT(EDGE),IN(EDGE) par vertex V <==> OUT(EDGE),ON(EDGE) par vertex V
208 // si trouve 1/ : Fi devient IN(FACE),OUT(FACE)
209 // si trouve 2/ : Fe devient OUT(FACE),IN(FACE)
210
211 TopOpeBRepDS_ListIteratorOfListOfInterference it1(LF);
212 while (it1.More()) {
213 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
214 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
215
216 if ( GT1 == TopOpeBRepDS_VERTEX ) {
217 TopOpeBRepDS_Transition& T1 = I1->ChangeTransition();
218 TopAbs_ShapeEnum shab1 = T1.ShapeBefore(), shaa1 = T1.ShapeAfter();
219 TopAbs_State stab1 = T1.Before(), staa1 = T1.After();
220 const Standard_Boolean foub = (shab1 == TopAbs_FACE) && (stab1 == TopAbs_OUT);
221 const Standard_Boolean foua = (shaa1 == TopAbs_FACE) && (staa1 == TopAbs_OUT);
222 const Standard_Boolean foufou = foub && foua;
223 if (!foufou) {
224 it1.Next();
225 continue;
226 }
227
228 TopOpeBRepDS_ListIteratorOfListOfInterference it2(LE);
229 while (it2.More()) {
230 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
231 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2);
232
233 Standard_Boolean memver = ((GT2 == GT1) && (G2 == G1));
234 if ( ! memver ) {
235 it2.Next();
236 continue;
237 }
238
239 const TopOpeBRepDS_Transition& T2 = I2->Transition();
240 TopAbs_ShapeEnum shab2 = T2.ShapeBefore(), shaa2 = T2.ShapeAfter();
241 TopAbs_State stab2 = T2.Before(), staa2 = T2.After();
242 const Standard_Boolean eoub = (shab2 == TopAbs_EDGE) && (stab2 == TopAbs_OUT);
243 const Standard_Boolean einb = (shab2 == TopAbs_EDGE) && (stab2 == TopAbs_IN);
244 const Standard_Boolean eoua = (shaa2 == TopAbs_EDGE) && (staa2 == TopAbs_OUT);
245 const Standard_Boolean eina = (shaa2 == TopAbs_EDGE) && (staa2 == TopAbs_IN);
246 const Standard_Boolean eouein = (eoub && eina);
247 const Standard_Boolean eineou = (einb && eoua);
248 Standard_Boolean changeFi = (eouein || eineou);
249 if ( ! changeFi ) {
250 it2.Next();
251 continue;
252 }
253
254 // on modifie T1 de I1 et on arrete la pour I1
255 if (eouein) T1.After(TopAbs_IN,TopAbs_FACE);
256 else if (eineou) T1.Before(TopAbs_IN,TopAbs_FACE);
257 break;
258
259 it2.Next();
260 }
261
262 }
263 it1.Next();
264 }
265#ifdef DEB
266 if (TRC) cout<<" FUN_changeFOUT on "<<SIX<<"returns nI = "<<LE.Extent()<<endl;
267#endif
268
269}*/
270
271//------------------------------------------------------
272Standard_EXPORT void FUN_unkeepEsymetrictransitions
273//------------------------------------------------------
274// unkeepEsymetric : pour pallier au fonctionnement limite du TopTrans_CurveTransition
275// qui ne peut pas gerer correctement deux fois la meme arete (FORWARD,REVERSED)
276// incidentes en un vertex. (cas d'un shell fait de deux faces partageant une arete.)
277(TopOpeBRepDS_ListOfInterference& LI,const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SIX)
278{
279#ifdef DEB
280 Standard_Boolean TRC=TRCE(SIX);
281#endif
282
283 const TopoDS_Shape& E = BDS.Shape(SIX);
284
285 Standard_Boolean isEd;
286 isEd = BRep_Tool::Degenerated(TopoDS::Edge(E));
287
288#ifdef DEB
289 if (TRC) {
290 cout<<"FUN_unkeepEsymetrictransitions on "<<SIX<<" nI = "<<LI.Extent()<<endl;
291 ::FDS_dumpLI(LI,"debut : ");
292 }
293#endif
294
295 if (isEd) return;
296
297 TopOpeBRepDS_ListIteratorOfListOfInterference it1;
298
299 // process interferences of LI with VERTEX geometry
300
301 it1.Initialize(LI);
302 while (it1.More() ) {
303 Standard_Boolean it1toremove = Standard_False;
304 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
305 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
306 TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1; ::FDS_Tdata(I1,tsb1,isb1,tsa1,isa1);
307 const TopOpeBRepDS_Transition T1 = I1->Transition();
308
309 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1);
310 it2.Next();
311 while ( it2.More() ) {
312 const Handle(TopOpeBRepDS_Interference)& I2 = it2.Value();
313 TopOpeBRepDS_Kind GT2,ST2; Standard_Integer G2,S2; FDS_data(I2,GT2,G2,ST2,S2);
314 TopAbs_ShapeEnum tsb2,tsa2; Standard_Integer isb2,isa2; ::FDS_Tdata(I2,tsb2,isb2,tsa2,isa2);
315 const TopOpeBRepDS_Transition T2 = I2->Transition(); // + 03-03-97
316 Standard_Boolean idGS = (GT2 == GT1 && G2 == G1 && ST2 == ST1 && S2 == S1);
317 Standard_Boolean idiba = (isb1 == isb2 && isa1 == isa2);
318 Standard_Boolean cond = idGS;
319 cond = cond && idiba; // ++971219
320
321 if (cond) {
322 Standard_Boolean idshape = ::FUN_transitionSHAPEEQUAL(T1,T2);
323 Standard_Boolean idstate = ::FUN_transitionSTATEEQUAL(T1,T2);
324 Standard_Boolean newV = Standard_True;
1d47d8d0 325 Standard_Boolean oppostate = Standard_False;
7fd59977 326
327 if (newV) {
328 // sym is not precise enough (croix3_3-> OUT/IN; ON/OUT)
329#define M_OUTIN(st1,st2) ((st1 == TopAbs_OUT)&&(st2 == TopAbs_IN))
330 TopAbs_State t1b = T1.Before(), t2b = T2.Before();
331 TopAbs_State t1a = T1.After(), t2a = T2.After();
332 oppostate = M_OUTIN(t1b,t2b) || M_OUTIN(t2b,t1b);
333 oppostate = oppostate && (M_OUTIN(t1a,t2a) || M_OUTIN(t2a,t1a));
334 }
335
336 Standard_Boolean sym;
337 if (newV) sym = idshape && oppostate;
338 else sym = idshape && !idstate;
339
340 if ( sym ) { // les 2 interferences ne different que leurs etats (symetriques)
341#ifdef DEB
342// cout<<"TopOpeBRepDS FUN_unkeepEsymetrictransitions on edge "<<SIX<<endl;
343 if(TRC){
344 cout<<"edge "<<SIX<<" : symetrique ";I1->Dump(cout);cout<<endl;
345 cout<<" ";I2->Dump(cout);cout<<endl;
346 }
347#endif
348 LI.Remove(it2);
349 it1toremove = Standard_True;
350 }
351 else it2.Next();
352 }
353 else it2.Next();
354 }
355 if (it1toremove) {
356 LI.Remove(it1);
357 }
358 else {
359 it1.Next();
360 }
361 } // it1.More()
362
363#ifdef DEB
364 if(TRC) {
365 ::FDS_dumpLI(LI,"apres elim. des sym. : ");
366 cout<<"FUN_unkeepEsymetrictransitions on "<<SIX<<" returns nI = "<<LI.Extent()<<endl;
367 }
368#endif
369}
370
371#ifdef DEB
372void deborderFF(const Standard_Integer) {};
373void deborderFF1(const Standard_Integer) {};
374void deborderFF2(const Standard_Integer) {};
375#endif
376
377//------------------------------------------------------
378Standard_EXPORT void FUN_orderFFsamedomain
379//------------------------------------------------------
380// partition de LI en deux sous listes :
381// L1/ = interfs dont la transition est definie / face samedomain
382// L2/ = les autres interfs
383// L = L1 + L2;
384 (TopOpeBRepDS_ListOfInterference& LI,
385 const Handle(TopOpeBRepDS_HDataStructure)& HDS,
386#ifdef DEB
387 const Standard_Integer SIX)
388#else
389 const Standard_Integer )
390#endif
391{
392#ifdef DEB
393 Standard_Boolean TRC=TRCE(SIX);
394 if (TRC) deborderFF(SIX);
395 Standard_Boolean modif = Standard_False;
396#endif
397
398 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
399 TopOpeBRepDS_ListOfInterference LIffsd,LIother;
400// BDS.Shape(SIX);
401 TopOpeBRepDS_ListIteratorOfListOfInterference it1;
402
403 it1.Initialize(LI);
404 while (it1.More() ) {
405 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
406 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; FDS_data(I1,GT1,G1,ST1,S1);
407 TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1; FDS_Tdata(I1,tsb1,isb1,tsa1,isa1);
408// I1->Transition();
409
410#ifdef DEB
411 if (TRC) deborderFF1(SIX);
412#endif
413
414 Standard_Boolean ffsd = Standard_False;
415 if (tsb1 == TopAbs_FACE && tsa1 == TopAbs_FACE) {
416 // T1 states are defined on FACEs
417 const TopoDS_Shape& fb = BDS.Shape(isb1);
418 const TopoDS_Shape& fa = BDS.Shape(isa1);
419 Standard_Boolean ffsd1 = HDS->HasSameDomain(fb);
420 Standard_Boolean ffsd2 = HDS->HasSameDomain(fa);
421 ffsd = ffsd1 && ffsd2;
422 }
423
424 if (ffsd) LIffsd.Append(I1);
425 else LIother.Append(I1);
426
427 LI.Remove(it1);
428 } // it1.More()
429
430 LI.Clear();
431 LI.Append(LIffsd);
432 LI.Append(LIother);
433
434#ifdef DEB
435 if(TRC && modif){ FDS_dumpLI(LI,"apres groupage fsd : "); }
436#endif
437} // FUN_orderFFsamedomain
438
439
440#ifdef DEB
441void deborderSTATETRANS(const Standard_Integer) {};
442#endif
443
444//------------------------------------------------------
445Standard_EXPORT void FUN_orderSTATETRANSonG
446//------------------------------------------------------
447// LI : liste d'interf en une meme Geometrie (K,G)
448// partition de LI en deux sous listes :
449// L1/ = interfs dont la transition a des etats egaux
450// L2/ = les autres interfs
451// L = L1 + L2;
452(TopOpeBRepDS_ListOfInterference& LI,const Handle(TopOpeBRepDS_HDataStructure)& /*HDS*/,
453#ifdef DEB
454 const Standard_Integer SIX)
455#else
456 const Standard_Integer)
457#endif
458{
459#ifdef DEB
460 Standard_Boolean TRC=TRCE(SIX);
461 if (TRC) deborderSTATETRANS(SIX);
462 Standard_Boolean modif = Standard_False;
463#endif
464
465// TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
466 TopOpeBRepDS_ListOfInterference L1,L2;
467 TopOpeBRepDS_ListIteratorOfListOfInterference it1;
468
469 it1.Initialize(LI);
470 while (it1.More() ) {
471 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
472 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
473 FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
474 const TopOpeBRepDS_Transition& T1 = I1->Transition();
475 TopAbs_State stab1 = T1.Before();
476 TopAbs_State staa1 = T1.After();
477
478 Standard_Boolean steq = (tsb1 == tsa1 && isb1 == isa1 && stab1 == staa1);
479 if (steq) L1.Append(I1);
480 else L2.Append(I1);
481
482 it1.Next();
483 } // it1.More()
484
485 LI.Clear();
486 LI.Append(L1);
487 LI.Append(L2);
488#ifdef DEB
489 if(TRC && modif){ FDS_dumpLI(LI,"apres groupage STATETRANS : "); }
490#endif
491} // FUN_orderSTATETRANSonG
492
493//------------------------------------------------------
494Standard_EXPORT void FUN_orderSTATETRANS
495//------------------------------------------------------
496// partition de LI en deux sous listes :
497// L1/ = interfs dont la transition a des etats egaux
498// L2/ = les autres interfs
499// L = L1 + L2;
500(TopOpeBRepDS_ListOfInterference& LI,const Handle(TopOpeBRepDS_HDataStructure)& HDS,const Standard_Integer SIX)
501{
502#ifdef DEB
503 Standard_Boolean TRC=TRCE(SIX);
504 if (TRC) deborderSTATETRANS(SIX);
505#endif
506
507 TopOpeBRepDS_TKI tki;
508 tki.FillOnGeometry(LI);
509 tki.Init();
510 for (; tki.More(); tki.Next()) {
511 TopOpeBRepDS_Kind K; Standard_Integer G; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
512 ::FUN_orderSTATETRANSonG(loi,HDS,SIX);
513 }
514
515 LI.Clear();
516 tki.Init();
517 for (; tki.More(); tki.Next()) {
518 TopOpeBRepDS_Kind K; Standard_Integer G; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(K,G);
519 LI.Append(loi);
520 }
521} // FUN_orderSTATETRANS
522
523//------------------------------------------------------
524Standard_EXPORT void FUN_resolveEUNKNOWN
525//------------------------------------------------------
526(TopOpeBRepDS_ListOfInterference& LI,TopOpeBRepDS_DataStructure& BDS,const Standard_Integer SIX)
527{
528#ifdef DEB
529 Standard_Boolean TRC=TRCE(SIX); if (TRC) debredunke(SIX);
530 Standard_Boolean modif = Standard_False;
531#endif
532
533 const TopoDS_Shape& E = BDS.Shape(SIX);
534 TopOpeBRepDS_ListIteratorOfListOfInterference it1;
535
536 const TopoDS_Edge& EE = TopoDS::Edge(E);
537 Standard_Real fE,lE; BRep_Tool::Range(EE,fE,lE);
538
539 // process interferences of LI with UNKNOWN transition
540
541 for (it1.Initialize(LI); it1.More(); it1.Next() ) {
542 Handle(TopOpeBRepDS_Interference)& I1 = it1.Value();
543 const TopOpeBRepDS_Transition& T1 = I1->Transition();
544 Standard_Boolean isunk = T1.IsUnknown();
545 if (!isunk) continue;
546
547#ifdef DEB
548 modif = Standard_True;
549 if(TRC){debredunke(SIX);TCollection_AsciiString s="E";s=s+SIX+" T UNKNOWN ";I1->Dump(cout,s,"\n");}
550#endif
551
552 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1; TopAbs_ShapeEnum tsb1,tsa1; Standard_Integer isb1,isa1;
553 FDS_Idata(I1,tsb1,isb1,tsa1,isa1,GT1,G1,ST1,S1);
554 Standard_Boolean idt = (tsb1==TopAbs_FACE && tsa1==TopAbs_FACE
555 && GT1==TopOpeBRepDS_POINT && ST1==TopOpeBRepDS_FACE);
556 Standard_Boolean idi = (isb1==S1 && isa1==S1);
557 Standard_Boolean etgf = idt && idi; // edge tangent a une face en 1 point
558 if (!etgf) continue;
559
560#ifdef DEB
561 if(TRC){debredunke(SIX);TCollection_AsciiString s="E";s=s+SIX+" etgf ";I1->Dump(cout,s,"\n");}
562#endif
563
564 Handle(TopOpeBRepDS_CurvePointInterference) cpi = MAKECPI(I1);
565 if (cpi.IsNull()) continue;
566
567 Standard_Real bid; Handle(Geom_Curve) CE = BRep_Tool::Curve(EE,bid,bid);
568 if (CE.IsNull()) continue; // NYI : get points from 2d curve
569
570 Standard_Real parcpi = cpi->Parameter();
571 Standard_Real ttb = 0.8; Standard_Real parb = (1-ttb)*fE + ttb*parcpi;
572 Standard_Real tta = 0.2; Standard_Real para = (1-tta)*parcpi + tta*lE;
573 gp_Pnt Pb;CE->D0(parb,Pb);
574 gp_Pnt Pa;CE->D0(para,Pa);
575
576 BRep_Builder BB;
577 const TopoDS_Face& FS = TopoDS::Face(BDS.Shape(S1));
578 TopoDS_Shell sh; BB.MakeShell(sh);
579 TopoDS_Solid so; BB.MakeSolid(so);
580 BB.Add(sh,FS);BB.Add(so,sh);
581 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(so);
582 PSC.StateP3DReference(Pb);
583 TopAbs_State stateb = PSC.State();
584 PSC.StateP3DReference(Pa);
585 TopAbs_State statea = PSC.State();
586 if (stateb==TopAbs_UNKNOWN || statea==TopAbs_UNKNOWN) continue;
587
588 TopOpeBRepDS_Transition& newT1 = I1->ChangeTransition();
589 newT1.Set(stateb,statea,tsb1,tsa1);
590
591#ifdef DEB
592 if(TRC){debredunke(SIX);TCollection_AsciiString s="E";s=s+SIX+" T corrected ";I1->Dump(cout,s,"\n");}
593#endif
594
595 }
596
597#ifdef DEB
598 if(TRC && modif){ FDS_dumpLI(LI,"apres correction UNKNOWN : "); }
599#endif
600
601 FUN_unkeepUNKNOWN(LI,BDS,SIX);
602
603#ifdef DEB
604 if(TRC && modif){ FDS_dumpLI(LI,"sans suppression UNKNOWN residuels : "); }
605#endif
606}
607
608// ----------------------------------------------------------------------
609Standard_EXPORT void FUN_purgeDSonSE(const Handle(TopOpeBRepDS_HDataStructure)& HDS,const Standard_Integer EIX,TopOpeBRepDS_ListOfInterference& LI)
610// ----------------------------------------------------------------------
611{
612#ifdef DEB
613 Standard_Boolean trc = TopOpeBRepDS_GettraceSPSX(EIX);
614 if (trc) {cout<<endl<<"FUN_purgeDSonSE on "<<EIX<<" nI = "<<LI.Extent()<<endl;}
615#endif
616
617 // recall : (I1,I2) / I1=(T(F),G,S=edge), I2=(T(F),G,S=F) describes a 3d interference
618 //
619 // purpose : attached to EIX (section egde SE), I=(T(Fsdm),G,S) /
620 // Fsdm shares same domain with Fanc ancestor face of SE
621 // => SE has split ON near G =>
622 // I'=(T(Fsdm),G,S=Fsdm) gives bad information (3d information whereas
623 // we should only have 2d information)
624 // - PRO12660 for spON(e48) -
625
626 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
627 const TopoDS_Edge& SE = TopoDS::Edge(BDS.Shape(EIX));
628 Standard_Integer rkSE = BDS.AncestorRank(SE);
629 Standard_Boolean isse = BDS.IsSectionEdge(SE);
630 if (!isse) return;
631
632#ifdef DEB
633 if (trc) debpurse(EIX);
634#endif
635
636 TopTools_MapOfShape fsdmFancSE;
637 // ---------------
638 const TopTools_ListOfShape& lFancSE = FDSCNX_EdgeConnexitySameShape(SE,HDS);
639 for (TopTools_ListIteratorOfListOfShape itf(lFancSE); itf.More(); itf.Next()){
640 const TopTools_ListOfShape& fsdm = BDS.ShapeSameDomain(itf.Value());
641 for (TopTools_ListIteratorOfListOfShape itsdm(fsdm); itsdm.More(); itsdm.Next()){
642 const TopoDS_Shape& sdmf = itsdm.Value();
643 Standard_Integer sdmrk = BDS.AncestorRank(sdmf);
644 if (sdmrk == rkSE) continue;
645 fsdmFancSE.Add(sdmf);
646 }
647 }
648 if (fsdmFancSE.IsEmpty()) return;
649
650 TopOpeBRepDS_ListOfInterference newLI;
651 // ---------
652 TopOpeBRepDS_TKI tki;
653 tki.FillOnGeometry(LI);
654 for (tki.Init(); tki.More(); tki.Next()) {
655
656 TopOpeBRepDS_Kind Kcur; Standard_Integer Gcur; TopOpeBRepDS_ListOfInterference& loi = tki.ChangeValue(Kcur,Gcur);
657#ifdef DEB
658// Standard_Boolean hasfsdmFanc = Standard_False;
659#endif
660 TopOpeBRepDS_ListIteratorOfListOfInterference it(loi);
661// for (; it.More(); it.Next()){
662// const Handle(TopOpeBRepDS_Interference)& I = it.Value();
663// TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(I,tsb,isb,tsa,isa);
664// if (tsb != TopAbs_FACE) continue;
665// const TopoDS_Shape& f = BDS.Shape(isb); Standard_Integer ifa = BDS.Shape(f); // DEB
666// Standard_Boolean isbound = fsdmFancSE.Contains(f);
667// if (isbound) {hasfsdmFanc = Standard_True; break;}
668// }
669// if (!hasfsdmFanc)
670// {newLI.Append(loi); continue;}
671// TopOpeBRepDS_ListOfInterference LIface; Standard_Integer nfound = FUN_selectSIinterference(loi,TopOpeBRepDS_FACE,LIface);
672
673 // - cto 900 D1 - : we need interference I''=(T(face),G,face), face !sdmFancSE
674 // to compute spOUT(e9)
675
676 TopOpeBRepDS_ListOfInterference LIface;
677 for (; it.More(); it.Next()){
678 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
679 TopOpeBRepDS_Kind GT,ST; Standard_Integer G,S; FDS_data(I,GT,G,ST,S);
680 TopAbs_ShapeEnum tsb,tsa; Standard_Integer isb,isa; FDS_Tdata(I,tsb,isb,tsa,isa);
681
682 if (tsb != TopAbs_FACE) {newLI.Append(I); continue;}
683 if (ST != TopOpeBRepDS_FACE) {newLI.Append(I); continue;}
684
685 const TopoDS_Shape& f = BDS.Shape(isb);
686 Standard_Boolean isbound = fsdmFancSE.Contains(f);
687 if (isbound) LIface.Append(I);
688 else newLI.Append(I);
689 }
690
691#ifdef DEB
692 if (trc)
693 for (TopOpeBRepDS_ListIteratorOfListOfInterference itt(LIface); itt.More(); itt.Next())
694 {cout<<"rejet d'interference "<<EIX<<" ";itt.Value()->Dump(cout);cout<<endl;}
695#endif
696// newLI.Append(loi);
697 } // tki
698
699 LI.Clear();
700 LI.Append(newLI);
701
702#ifdef DEB
703 if (trc) cout<<"FUN_purgeDSonSE on "<<EIX<<" returns nI = "<<LI.Extent()<<endl;
704#endif
705}