Integration of OCCT 6.5.0 from SVN
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_FIR.cxx
CommitLineData
7fd59977 1// File: TopOpeBRepDS_FIR.cxx
2
3// Robert Boehne 30 May 2000 : Dec Osf
4
5#include <TopOpeBRepDS_FIR.ixx>
6#include <TopOpeBRepDS_define.hxx>
7#include <TopOpeBRepTool_EXPORT.hxx>
8#include <TopOpeBRepTool_SC.hxx>
9
10#include <TopOpeBRepDS_ProcessInterferencesTool.hxx>
11#include <TopoDS.hxx>
12#include <TopExp_Explorer.hxx>
13#include <TopOpeBRepDS_FaceInterferenceTool.hxx>
14#include <TopOpeBRepDS_CurvePointInterference.hxx>
15#include <TopOpeBRepDS_ShapeShapeInterference.hxx>
16#include <TopOpeBRepDS_ShapeData.hxx>
17#include <TopOpeBRepDS_MapOfShapeData.hxx>
18#include <BRepAdaptor_Curve.hxx>
19#include <BRep_Builder.hxx>
20#include <BRep_Tool.hxx>
21#include <TopOpeBRepDS_ListOfShapeOn1State.hxx>
22#include <TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State.hxx>
23
24#define MDSke TopOpeBRepDS_EDGE
25#define MDSkf TopOpeBRepDS_FACE
26
27#ifdef DEB
28Standard_EXPORT void debrededg(const Standard_Integer I) {cout<<"+++ debrededg f"<<I<<endl;}
29Standard_EXPORT void debredfac(const Standard_Integer I) {cout<<"+++ debredfac f"<<I<<endl;}
30void FUN_dumploiS(const TopoDS_Shape& SG,const TopOpeBRepDS_ListOfInterference& loi,const TopOpeBRepDS_DataStructure& BDS,TCollection_AsciiString str)
31{
32 cout<<str<<" G : "<<BDS.Shape(SG)<<" S : ";
33 for(TopOpeBRepDS_ListIteratorOfListOfInterference it(loi);it.More();it.Next()) cout<<it.Value()->Support()<<" ";
34 cout<<endl;cout.flush();
35}
36void FUN_dumpmosd(TopOpeBRepDS_MapOfShapeData& mosd,const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer F,TCollection_AsciiString str)
37{
38 cout<<str<<"GmapS sur ";TopAbs::Print(BDS.Shape(F).ShapeType(),cout);
39 cout<<" "<<F<<" : "<<mosd.Extent()<<" (GK EDGE)(SK FACE)"<<endl;
40 for(Standard_Integer i=1,n=mosd.Extent();i<=n;i++) {
41 FUN_dumploiS(mosd.FindKey(i),mosd.FindFromIndex(i).Interferences(),BDS,str);
42 }
43}
44#endif
45
46#ifdef DEB
47Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSTRANGE();
48Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettracePEI();
49Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettracePFI();
50Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettracePI();
51Standard_EXPORT Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer);
52static Standard_Boolean FTRCF(const Standard_Integer F) {
53 Standard_Boolean b1 = TopOpeBRepDS_GettracePFI();
54 Standard_Boolean b2 = TopOpeBRepDS_GettracePI();
55 Standard_Boolean b3 = TopOpeBRepDS_GettraceSPSX(F);
56 return (b1 || b2 || b3);
57}
58static Standard_Boolean FTRCE(const Standard_Integer E) {
59 Standard_Boolean b1 = TopOpeBRepDS_GettracePEI();
60 Standard_Boolean b2 = TopOpeBRepDS_GettracePI();
61 Standard_Boolean b3 = TopOpeBRepDS_GettraceSPSX(E);
62 return (b1 || b2 || b3);
63}
64#endif
65
66Standard_EXPORT Standard_Boolean FUN_Parameters(const gp_Pnt& Pnt,const TopoDS_Shape& F,Standard_Real& u,Standard_Real& v);
67Standard_EXPORT Standard_Boolean FUN_edgeofface(const TopoDS_Shape& E,const TopoDS_Shape& F);
68
69//------------------------------------------------------
70Standard_Boolean FUN_isPonF(const TopOpeBRepDS_ListOfInterference& LIF,const gp_Pnt& P,const TopOpeBRepDS_DataStructure& BDS,const TopoDS_Edge& E)
71{
72 Standard_Boolean Pok = Standard_True;
73 TopOpeBRepDS_Kind GT1,ST1; Standard_Integer G1,S1;
74
75 TopOpeBRepDS_ListIteratorOfListOfInterference itF(LIF);
76 for (;itF.More();itF.Next()) {
77 Handle(TopOpeBRepDS_Interference)& IF = itF.Value(); FDS_data(IF,GT1,G1,ST1,S1);
78 const TopoDS_Face& F = TopoDS::Face(BDS.Shape(S1));
79 TopAbs_Orientation oEinF; Standard_Boolean edonfa = FUN_tool_orientEinFFORWARD(E,F,oEinF );
80 if ( edonfa ) Pok = Standard_True;
81 else {
82 // P est NOK pour une face de LIF : arret
83 Standard_Real u,v; Pok = FUN_Parameters(P,F,u,v);
84 if (!Pok) break;
85 }
86 }
87 return Pok;
88}
89
90//------------------------------------------------------
91Standard_Boolean FUN_findPonF(const TopoDS_Edge& E,const TopOpeBRepDS_DataStructure& BDS, const TopOpeBRepDS_ListOfInterference& LIF,gp_Pnt& P,Standard_Real& par)
92{
93 Standard_Boolean Pok = Standard_False;
94 BRepAdaptor_Curve BAC(E);
95 const TopOpeBRepDS_ListOfInterference& LIE = BDS.ShapeInterferences(E);
96 TopOpeBRepDS_ListIteratorOfListOfInterference itI; itI.Initialize(LIE);
97
98 if ( !itI.More() ) {
99 Pok = FUN_tool_findPinBAC(BAC,P,par);
100 Pok = FUN_isPonF(LIF,P,BDS,E);
101 return Pok;
102 }
103
104 TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1;
105 for (;itI.More();itI.Next()) {
106 Standard_Boolean pardef = Standard_False;
107
108 Handle(TopOpeBRepDS_Interference)& I = itI.Value(); FDS_data(I,GT1,G1,ST1,S1);
109 const Handle(TopOpeBRepDS_CurvePointInterference)& CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I);
110 const Handle(TopOpeBRepDS_ShapeShapeInterference)& SSI = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
111 if (!CPI.IsNull()) {
112 par = CPI->Parameter(); pardef = Standard_True;
113 }
114 else if (!SSI.IsNull()) {
115 Standard_Boolean gb = SSI->GBound();
116 if (gb) {
117 const TopoDS_Vertex& V = TopoDS::Vertex(BDS.Shape(G1));
118 P = BRep_Tool::Pnt(V); par = BRep_Tool::Parameter(V,E); pardef = Standard_True;
119 }
120 else {
121 pardef = Standard_False;
122 if (GT1 == TopOpeBRepDS_POINT) P = BDS.Point(G1).Point();
123 else if (GT1 == TopOpeBRepDS_VERTEX) P = BRep_Tool::Pnt(TopoDS::Vertex(BDS.Shape(G1)));
124 if (pardef) {
125 Standard_Real dist; pardef = FUN_tool_projPonC(P,BAC,par,dist);
126 }
127 }
128 }
129 else {
130 continue;
131 }
132
133 if (!pardef) {
134 continue;
135 }
136
137 BAC.D0(par,P);
138 Pok = FUN_isPonF(LIF,P,BDS,E);
139 // P est OK pour toutes les faces de LIF : on arrete de chercher
140 if (Pok) {
141 break;
142 }
143 }
144 return Pok;
145}
146
147// --------------------------------------------------------
148static void FDS_DUMPTRANSITION(const Standard_Boolean
149#ifdef DEB
150 TRCF
151#endif
152 ,const TCollection_AsciiString&
153#ifdef DEB
154 str
155#endif
156 ,const Standard_Integer
157#ifdef DEB
158 iFI
159#endif
160 ,TopOpeBRepDS_FaceInterferenceTool&
161#ifdef DEB
162 FITool
163#endif
164 )
165{
166#ifdef DEB
167 if (TRCF) {
168 cout<<str<<iFI<<endl;
169 Handle(TopOpeBRepDS_Interference) IBID = new TopOpeBRepDS_Interference();
170 FITool.Transition(IBID);
171 IBID->Transition().Dump(cout);cout<<endl;
172 }
173#endif
174}
175
176// --------------------------------------------------------
177static void FDS_ADDEDGE
178(const Standard_Boolean
179#ifdef DEB
180 TRCF
181#endif
182 ,const TCollection_AsciiString&
183#ifdef DEB
184 str
185#endif
186 ,const Standard_Integer
187#ifdef DEB
188 iFI // DEB args
189#endif
190 ,TopOpeBRepDS_FaceInterferenceTool& FITool
191 ,const TopoDS_Shape& FI
192 ,const TopoDS_Shape& F
193 ,const TopoDS_Shape& Ecpx
194 ,const Standard_Boolean isEGsp
195 ,const Handle(TopOpeBRepDS_Interference)& I
196)
197{
198#ifdef DEB
199 if (TRCF) {TCollection_AsciiString cr("\n"),s=str+iFI+cr;I->Dump(cout,s,cr);}
200#endif
201 FITool.Add(FI,F,Ecpx,isEGsp,I);
202#ifdef DEB
203 FDS_DUMPTRANSITION(TRCF,"--> resultat partiel sur face ",iFI,FITool);
204#endif
205}
206
207//------------------------------------------------------
208// EGsp = edge splittee de iEG ( Null si iEG n'est pas splittee)
209void FUN_reduceEDGEgeometry1
210(TopOpeBRepDS_ListOfInterference& LI,const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer iFI,const Standard_Integer iEG,const TopoDS_Shape& EGsp,
211// const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& MEsp)
212 const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& )
213{
214 Standard_Boolean TRCF = Standard_False;
215#ifdef DEB
216 Standard_Boolean TRCE = Standard_False;
217 TRCE = FTRCE(iEG);if (TRCE) debrededg(iEG);
218 TRCF = FTRCF(iFI);if (TRCF) debredfac(iFI);
219#endif
220
221 TopOpeBRepDS_ListIteratorOfListOfInterference ili(LI); if (!ili.More()) return;
222
223 // choix de l'arete Ecpx, lieu de resolution de la transition complexe
224 const TopoDS_Face& FI = TopoDS::Face(BDS.Shape(iFI));
225 Standard_Boolean isEGsp = (! EGsp.IsNull());
226 TopoDS_Edge Ecpx;
227 if (isEGsp) Ecpx = TopoDS::Edge(EGsp);
228 else Ecpx = TopoDS::Edge(BDS.Shape(iEG));
229
230 TopOpeBRepDS_PDataStructure pbds = (TopOpeBRepDS_PDataStructure)(void*)&BDS;
231 TopOpeBRepDS_FaceInterferenceTool FITool(pbds);
232 gp_Pnt Pok; Standard_Boolean isPok = Standard_False; Standard_Real parPok;
233 if ( LI.Extent() >= 2) {
234 if ( isEGsp ) isPok = FUN_tool_findPinE(Ecpx,Pok,parPok);
235 else isPok = FUN_findPonF(Ecpx,BDS,LI,Pok,parPok); // NYI pas necessaire
236 if (!isPok) { LI.Clear(); return; }
237 FITool.SetEdgePntPar(Pok,parPok);
238 }
239
240 // xpu :090498 :
241 // CTS20205 : sp(e5) = sp(e4 of rank=1) and c3d(e5) c3d(e4) are diff oriented
242 // As transitions on face<iFI> are given relative to the geometry of e5,
243 // we have to complement them.
244// Standard_Boolean toreverse = Standard_False;
245// Standard_Boolean hsdm = !BDS.ShapeSameDomain(iEG).IsEmpty();
246// if (hsdm) {
247// Standard_Boolean sameoriented = Standard_False;
248// Standard_Boolean ok = FUN_tool_curvesSO(TopoDS::Edge(Ecpx),parPok,TopoDS::Edge(BDS.Shape(iEG)),
249// sameoriented);
250// if (ok) toreverse = !sameoriented;
251// }
252 // xpu :090498
253
254 // FI = face de reference (shape), iFI (indice)
255 // E = arete geometrie d'interference (shape), iEG (indice)
256 // LI = liste d'interf de geom iEG et dont les Support() sont a transitionner complexe
257
258 Handle(TopOpeBRepDS_Interference) I1,I2; TopOpeBRepDS_Kind GT1,ST1,GT2,ST2; Standard_Integer G1,S1,G2,S2;
259 TopOpeBRepDS_ListIteratorOfListOfInterference it1; it1.Initialize(LI);
260 while (it1.More()) {
261 Standard_Boolean u1 = FDS_data(it1,I1,GT1,G1,ST1,S1);if (u1) {it1.Next();continue;}
262 Standard_Boolean ya1 = (GT1 == MDSke); if (!ya1) {it1.Next();continue;}
263
264 Standard_Boolean isComplex = Standard_False; // True if at least two interfs on the same edge
265 const TopoDS_Face& F1 = TopoDS::Face(BDS.Shape(S1));
266
267 TopOpeBRepDS_ListIteratorOfListOfInterference it2(it1); it2.Next();
268 while (it2.More()) {
269 Standard_Boolean u2 = FDS_data(it2,I2,GT2,G2,ST2,S2);if (u2) {it2.Next();continue;}
270 Standard_Boolean ya2 = (GT2==GT1 && G2==G1 && ST2==ST1); if (!ya2) {it2.Next();continue;}
271 const TopoDS_Face& F2 = TopoDS::Face(BDS.Shape(S2));
272 if (!isComplex) {
273 isComplex = Standard_True;
274
275
276// TopOpeBRepDS_Transition T1 = I1->Transition(); TopAbs_Orientation O1 = T1.Orientation(TopAbs_IN); // xpu :090498
277// Standard_Boolean revT1 = toreverse && (M_FORWARD(O1) || M_REVERSED(O1)); // xpu :090498
278#ifdef DEB
279// if ((TRCE || TRCF) && revT1) cout<<"-> REVERSE T"<<endl;
280#endif
281// if (revT1) I1->ChangeTransition() = T1.Complement(); //xpu :090498
282 FITool.Init(FI,Ecpx,isEGsp,I1);
283 FDS_ADDEDGE(TRCF,"\ninit transition complexe F",iFI,FITool,FI,F1,Ecpx,isEGsp,I1);
284// if (revT1) I1->ChangeTransition() = T1.Complement(); //xpu :090498
285 }
286
287// TopOpeBRepDS_Transition T2 = I2->Transition(); TopAbs_Orientation O2 = T2.Orientation(TopAbs_IN); // xpu :090498
288// Standard_Boolean revT2 = toreverse && (M_FORWARD(O2) || M_REVERSED(O2)); // xpu :090498
289#ifdef DEB
290// if ((TRCE || TRCF) && revT2) cout<<"-> REVERSE T"<<endl;
291#endif
292// if (revT2) I2->ChangeTransition() = T2.Complement(); //xpu :090498
293 FDS_ADDEDGE(TRCF,"add transition complexe F",iFI,FITool,FI,F2,Ecpx,isEGsp,I2);
294// if (revT2) I2->ChangeTransition() = T2.Complement(); //xpu :090498
295
296 LI.Remove(it2);
297 }
298 if (isComplex) {
299 FITool.Transition(I1);
300 FDS_DUMPTRANSITION(TRCF,"--> result transition on face ",iFI,FITool); // DEB
301 }
302 it1.Next();
303 } // it1.More()
304} // FUN_reduceEDGEgeometry1
305
306//------------------------------------------------------
307void FUN_GmapS(TopOpeBRepDS_ListOfInterference& LI, const TopOpeBRepDS_DataStructure& BDS, TopOpeBRepDS_MapOfShapeData& mosd)
308{
309 mosd.Clear();
310 TopOpeBRepDS_Kind GT1,ST1;Standard_Integer G1,S1;
311 for (TopOpeBRepDS_ListIteratorOfListOfInterference it1(LI);it1.More();it1.Next()) {
312 Handle(TopOpeBRepDS_Interference)& I1=it1.Value(); FDS_data(I1,GT1,G1,ST1,S1);
313 if ( GT1 != MDSke || ST1 != MDSkf ) continue;
314 const TopoDS_Shape& SG1 = BDS.Shape(G1);
315 TopOpeBRepDS_ShapeData thedata;
316 if (!mosd.Contains(SG1)) mosd.Add(SG1, thedata);
317 mosd.ChangeFromKey(SG1).ChangeInterferences().Append(I1);
318 }
319}
320
321//------------------------------------------------------
322TopAbs_State FUN_stateedgeface(const TopoDS_Shape& E, const TopoDS_Shape& F, gp_Pnt& P)
323{
324 TopAbs_State state = TopAbs_UNKNOWN;
325 Standard_Real par; FUN_tool_findPinE(E,P,par);
326 Standard_Real u,v; Standard_Boolean Pok = FUN_Parameters(P,F,u,v);
327 if (Pok) { // classifier u,v dans F
328 TopOpeBRepTool_ShapeClassifier& PSC = FSC_GetPSC(F);
329 gp_Pnt2d Puv(u,v);
330 PSC.StateP2DReference(Puv);
331 state = PSC.State();
332 }
333 return state;
334}
335
336#define M_IN(ssstate) ((ssstate) == TopAbs_IN)
337#define M_ON(ssstate) ((ssstate) == TopAbs_ON)
338#define M_OUT(ssstate) ((ssstate) == TopAbs_OUT)
339#define M_UNK(ssstate) ((ssstate) == TopAbs_UNK)
340
341//------------------------------------------------------
342void FUN_reduceEDGEgeometry
343(TopOpeBRepDS_ListOfInterference& LI,const TopOpeBRepDS_DataStructure& BDS,const Standard_Integer iFI,
344const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& MEsp)
345{
346 if (!LI.Extent()) return;
347
348 TopOpeBRepDS_MapOfShapeData mosd;
349 FUN_GmapS(LI,BDS,mosd);
350
351#ifdef DEB
352 Standard_Boolean TRC = FTRCF(iFI);
353 if (TRC) FUN_dumpmosd(mosd,BDS,iFI,"");
354 if (TRC) debredfac(iFI);
355#endif
356
357 TopOpeBRepDS_ListOfInterference LIout;
358 //modified by NIZNHY-PKV Thu Mar 16 09:44:24 2000 f
359 Standard_Integer i, aN;
360 aN=mosd.Extent();
361 //for(Standard_Integer i=1,n=mosd.Extent(); i<=n; i++) {
362 //modified by NIZNHY-PKV Thu Mar 16 09:44:27 2000 t
363 for(i=1 ; i<=aN; i++) {
364 const TopoDS_Shape& EG = mosd.FindKey(i);
365 Standard_Integer iEG = BDS.Shape(EG);
366
367 // donnees samedomain attachees a l'arete iEG
368 const TopTools_ListOfShape& esdeg = BDS.ShapeSameDomain(iEG);
369 Standard_Boolean egissect = BDS.IsSectionEdge(TopoDS::Edge(EG));
370 Standard_Boolean eghasesd = (! esdeg.IsEmpty());
371
372#ifdef DEB
373// Standard_Integer egiref = BDS.SameDomainRef(iEG);
374// Standard_Integer egisref = (iEG == egiref);
375// TopOpeBRepDS_Config egc = BDS.SameDomainOri(iEG);
376#endif
377
378 TopOpeBRepDS_ListOfInterference& LIEG = mosd.ChangeFromKey(EG).ChangeInterferences();
379 Standard_Integer nExt = LIEG.Extent();
380 // LIEG = toutes les interferences dont le Support() est une
381 // face possedant une interference dont la Geometry() est EG.
382
383#ifdef DEB
384 if (TRC) FUN_dumploiS(EG,LIEG,BDS," ");
385#endif
386
387 if (nExt == 0) {
388 continue;
389 }
390 if (nExt == 1) {
391 LIout.Append(LIEG);
392 }
393
394 else if (nExt >= 2) {
395 Standard_Boolean isEGsp = MEsp.IsBound(EG);
396 //modified by NIZNHY-PKV Thu Mar 16 11:03:44 2000 from
397 //Standard_Integer nEGsp = 0;
398 //modified by NIZNHY-PKV Thu Mar 16 11:03:49 2000 to
399 if (isEGsp) {
400 const TopOpeBRepDS_ListOfShapeOn1State& los1 = MEsp.Find(EG);
401 isEGsp = los1.IsSplit();
402 //modified by NIZNHY-PKV Thu Mar 16 11:02:40 2000 from
403 //if ( isEGsp ) {
404 // const TopTools_ListOfShape& los = los1.ListOnState();
405 // nEGsp = los.Extent();
406 //}
407 //modified by NIZNHY-PKV Thu Mar 16 11:02:46 2000 to
408 }
409
410 if ( isEGsp ) {
411 const TopTools_ListOfShape& los = MEsp.Find(EG).ListOnState();
412 TopTools_ListIteratorOfListOfShape itlos(los);
413 for(;itlos.More();itlos.Next()) {
414 // EGsp est une arete splitee de EG.
415 const TopoDS_Shape& EGsp = itlos.Value();
416
417 // LISFIN = liste des interferences de LI dont le Support()
418 // est une face contenant geometriquement l'arete EGsp
419 TopOpeBRepDS_ListOfInterference LISFIN;
420 TopOpeBRepDS_ListIteratorOfListOfInterference itLIEG(LIEG);
421 for(; itLIEG.More(); itLIEG.Next()) {
422 const Handle(TopOpeBRepDS_Interference)& ILIEG = itLIEG.Value();
423 Standard_Integer iS = ILIEG->Support();
424 TopOpeBRepDS_Kind kS = ILIEG->SupportType();
425 if ( kS == MDSkf ) {
426 const TopoDS_Shape& SFILIEG = BDS.Shape(iS);
427 gp_Pnt P;
428 TopAbs_State staef = FUN_stateedgeface(EGsp,SFILIEG,P);
429
430 Standard_Boolean Pok = M_IN(staef);
431 if ( eghasesd || egissect ) {
432 Pok = Pok || M_ON(staef);
433 }
434
435 if (Pok) {
436 LISFIN.Append(ILIEG);
437 }
438 }
439 } // itLIEG.More
440
441 Standard_Integer nLISFIN = LISFIN.Extent();
442 if (nLISFIN >= 2 ) {
443 Standard_Boolean gb;
444 gb = Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(LISFIN.First())->GBound();
445
446 if (gb) {
447 //modified by NIZNHY-PKV Thu Mar 16 10:40:57 2000 f
448 // we have to rest at least one Interference on the face.
449 // To kill all of them is too bravely.
450 Handle(TopOpeBRepDS_Interference) anInterference = LISFIN.First();
451 LISFIN.Clear();
452 LISFIN.Append(anInterference);
453 //modified by NIZNHY-PKV Thu Mar 16 10:41:01 2000 t
454 }
455 else
456 FUN_reduceEDGEgeometry1(LISFIN,BDS,iFI,iEG,EGsp,MEsp);
457 }
458
459 nLISFIN = LISFIN.Extent();
460 if (nLISFIN)
461 LIout.Append(LISFIN);
462 }
463 } // isEGsp
464 else {
465 // iFI = face de reference (indice)
466 // E = arete geometrie d'interference (shape), iEG (indice)
467 // LIEG = liste d'interferences de geometrie EG
468 // et dont les Support() sont a transitionner complexe
469 TopoDS_Shape Enull;
470 FUN_reduceEDGEgeometry1(LIEG,BDS,iFI,iEG,Enull,MEsp);
471 LIout.Append(LIEG);
472 }
473 }
474 }
475
476 LI.Clear();
477 LI.Append(LIout);
478} // FUN_reduceEDGEgeometry
479
480//=======================================================================
481//function : TopOpeBRepDS_FIR
482//purpose :
483//=======================================================================
484TopOpeBRepDS_FIR::TopOpeBRepDS_FIR
485(const Handle(TopOpeBRepDS_HDataStructure)& HDS) : myHDS(HDS)
486{}
487
488//=======================================================================
489//function : ProcessFaceInterferences
490//purpose :
491//=======================================================================
492void TopOpeBRepDS_FIR::ProcessFaceInterferences(const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& M)
493{
494 TopOpeBRepDS_DataStructure& BDS = myHDS->ChangeDS();
495 Standard_Integer i,nshape = BDS.NbShapes();
496 for (i = 1; i <= nshape; i++) {
497 const TopoDS_Shape& S = BDS.Shape(i);
498 if(S.IsNull()) continue;
499 if ( S.ShapeType() == TopAbs_FACE ) {
500 ProcessFaceInterferences(i,M);
501 }
502 }
503}
504
505//=======================================================================
506//function : ProcessFaceInterferences
507//purpose :
508//=======================================================================
509void TopOpeBRepDS_FIR::ProcessFaceInterferences
510(const Standard_Integer SIX,const TopOpeBRepDS_DataMapOfShapeListOfShapeOn1State& MEsp)
511{
512 TopOpeBRepDS_DataStructure& BDS = myHDS->ChangeDS();
513
514#ifdef DEB
515 Standard_Boolean TRC = FTRCF(SIX);
516 if (TRC) debredfac(SIX);
517#endif
518 // F is the Face, LI is list of interferences to compact
519#ifdef DEB
520// const TopoDS_Shape& F = BDS.Shape(SIX);
521#endif
522 TopOpeBRepDS_ListOfInterference& LI = BDS.ChangeShapeInterferences(SIX);
523 TopOpeBRepDS_ListOfInterference lw, lE, lFE, lFEF, lF; lw.Assign(LI);
524
525 Standard_Integer nF = ::FUN_selectTRASHAinterference(lw,TopAbs_FACE,lF);
526 Standard_Integer nFE = ::FUN_selectGKinterference(lF,MDSke,lFE);
527 Standard_Integer nFEF = ::FUN_selectSKinterference(lFE,MDSkf,lFEF);
528 Standard_Integer nE = ::FUN_selectTRASHAinterference(lw,TopAbs_EDGE,lE);
529
530 nF = lF.Extent();
531 nFE = lFE.Extent();
532 nFEF = lFEF.Extent();
533 nE = lE.Extent();
534#ifdef DEB
535 if(TRC){
536 if(nF||nFE||nFEF||nE){cout<<endl;cout<<"-----------------------"<<endl;}
537 if(nF) {cout<<"FACE "<<SIX<<" (FACE) : "<<nF<<endl;FDS_dumpLI(lF," ");}
538 if(nFE){cout<<"FACE "<<SIX<<" (FACE)(GK EDGE) : "<<nFE<<endl;FDS_dumpLI(lFE," ");}
539 if(nFEF){cout<<"FACE "<<SIX<<" (FACE)(GK EDGE)(SK FACE) : "<<nFEF<<endl;FDS_dumpLI(lFEF," ");}
540 if(nE) {cout<<"FACE "<<SIX<<" (EDGE) : "<<nE<<endl;FDS_dumpLI(lE," ");}
541 }
542#endif
543
544 FUN_reduceEDGEgeometry(lFEF,BDS,SIX,MEsp);
545
546 nF = lF.Extent();
547 nFE = lFE.Extent();
548 nFEF = lFEF.Extent();
549 nE = lE.Extent();
550#ifdef DEB
551 if(TRC){
552 if(nF||nFE||nFEF||nE)cout<<endl;
553 if(nF) {cout<<"FACE "<<SIX<<" (FACE) : "<<nF<<endl;FDS_dumpLI(lF," ");}
554 if(nFE){cout<<"FACE "<<SIX<<" (FACE)(GK EDGE) : "<<nFE<<endl;FDS_dumpLI(lFE," ");}
555 if(nFEF){cout<<"FACE "<<SIX<<" (FACE)(GK EDGE)(SK FACE) : "<<nFEF<<endl;FDS_dumpLI(lFEF," ");}
556 if(nE) {cout<<"FACE "<<SIX<<" (EDGE) : "<<nE<<endl;FDS_dumpLI(lE," ");}
557 cout<<"-----------------------"<<endl;
558 }
559#endif
560
561 LI.Clear();
562 LI.Append(lF);
563 LI.Append(lFE);
564 LI.Append(lFEF);
565 LI.Append(lE);
566 // MSV: filter duplicates
567 ::FUN_reducedoublons(LI,BDS,SIX);
568}