0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_ffsfs.cxx
1 // Created on: 1996-03-07
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License 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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <BRep_Tool.hxx>
19 #include <BRepClass3d_SolidExplorer.hxx>
20 #include <BRepTopAdaptor_FClass2d.hxx>
21 #include <gp_Pnt.hxx>
22 #include <Standard_NoSuchObject.hxx>
23 #include <TCollection_AsciiString.hxx>
24 #include <TopoDS.hxx>
25 #include <TopoDS_Edge.hxx>
26 #include <TopoDS_Face.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <TopoDS_Vertex.hxx>
29 #include <TopOpeBRepBuild_Builder.hxx>
30 #include <TopOpeBRepBuild_define.hxx>
31 #include <TopOpeBRepBuild_EdgeBuilder.hxx>
32 #include <TopOpeBRepBuild_FaceBuilder.hxx>
33 #include <TopOpeBRepBuild_FuseFace.hxx>
34 #include <TopOpeBRepBuild_GTopo.hxx>
35 #include <TopOpeBRepBuild_HBuilder.hxx>
36 #include <TopOpeBRepBuild_PaveSet.hxx>
37 #include <TopOpeBRepBuild_ShapeSet.hxx>
38 #include <TopOpeBRepBuild_ShellFaceSet.hxx>
39 #include <TopOpeBRepBuild_SolidBuilder.hxx>
40 #include <TopOpeBRepBuild_WireEdgeSet.hxx>
41 #include <TopOpeBRepDS_BuildTool.hxx>
42 #include <TopOpeBRepDS_CurveIterator.hxx>
43 #include <TopOpeBRepDS_EXPORT.hxx>
44 #include <TopOpeBRepDS_HDataStructure.hxx>
45 #include <TopOpeBRepDS_PointIterator.hxx>
46 #include <TopOpeBRepDS_samdom.hxx>
47 #include <TopOpeBRepDS_SurfaceIterator.hxx>
48 #include <TopOpeBRepTool_EXPORT.hxx>
49 #include <TopOpeBRepTool_SC.hxx>
50 #include <TopOpeBRepTool_ShapeExplorer.hxx>
51
52 #ifdef OCCT_DEBUG
53 #define DEBSHASET(sarg,meth,shaset,str) TCollection_AsciiString sarg((meth));(sarg)=(sarg)+(shaset).DEBNumber()+(str);
54 Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextNOFUFA();
55 Standard_EXPORT void debffsfs(const Standard_Integer i){std::cout<<"+++ debffsfs "<<i<<std::endl;}
56 Standard_EXPORT void debffflo(const Standard_Integer i){std::cout<<"+++ debffflo "<<i<<std::endl;}
57 #endif
58
59 static Standard_Boolean STATIC_motheropedef = Standard_False; static TopOpeBRepBuild_GTopo STATIC_Gmotherope;
60 Standard_EXPORT void FUN_setmotherope(const TopOpeBRepBuild_GTopo& G) {STATIC_Gmotherope = G;STATIC_motheropedef = Standard_True;}
61 Standard_EXPORT void FUN_unsetmotherope() { STATIC_motheropedef = Standard_False; }
62 Standard_EXPORT Standard_Boolean FUN_ismotheropedef() { return STATIC_motheropedef; }
63 Standard_EXPORT const TopOpeBRepBuild_GTopo& FUN_motherope() { return STATIC_Gmotherope; } 
64
65 //Standard_IMPORT extern Standard_Boolean GLOBAL_classifysplitedge;
66 Standard_EXPORTEXTERN Standard_Boolean GLOBAL_classifysplitedge;
67 //Standard_IMPORT extern Standard_Boolean GLOBAL_revownsplfacori;
68 Standard_EXPORTEXTERN Standard_Boolean GLOBAL_revownsplfacori;
69 Standard_EXPORT void FUNBUILD_ANCESTORRANKPREPARE
70 (TopOpeBRepBuild_Builder& B,const TopTools_ListOfShape& LF1,const TopTools_ListOfShape& LF2,const TopOpeBRepDS_Config c1,const TopOpeBRepDS_Config c2);
71 Standard_EXPORT void FUNBUILD_ANCESTORRANKGET(TopOpeBRepBuild_Builder& B,const TopoDS_Shape& f,Standard_Boolean& of1,Standard_Boolean& of2);
72
73 static Standard_Integer FUN_getAncestorFsp(TopOpeBRepBuild_Builder& B,TopOpeBRepTool_ShapeClassifier& SC,const TopTools_ListOfShape& LF,const TopoDS_Shape& fsp,Standard_Boolean& p3ddef,gp_Pnt& p3d);
74 static Standard_Integer FUN_getAncestorFsp(TopOpeBRepBuild_Builder& B,TopOpeBRepTool_ShapeClassifier& SC,const TopTools_ListOfShape& LF1,const TopTools_ListOfShape& LF2,const TopoDS_Shape& fsp);
75 #ifdef OCCT_DEBUG
76 //static void FUN_getAncestorFsp(const Handle(TopOpeBRepDS_HDataStructure)& HDS,TopOpeBRepTool_ShapeClassifier& SC,const TopTools_ListOfShape& LF1,const TopTools_ListOfShape& LF2,const TopTools_ListOfShape& spFOR,
77 //                             TopTools_DataMapOfShapeInteger* SplitAnc);
78 #endif
79
80 static Standard_Integer FUN_getAncestorFsp(TopOpeBRepBuild_Builder& B,TopOpeBRepTool_ShapeClassifier& SC,const TopTools_ListOfShape& LF,const TopoDS_Shape& fsp,Standard_Boolean& p3ddef,gp_Pnt& p3d)
81 {
82   const TopOpeBRepDS_DataStructure& BDS = B.DataStructure()->DS(); // How to do static <--> const
83
84   TopTools_ListIteratorOfListOfShape itf(LF);
85   for (; itf.More(); itf.Next()){
86     const TopoDS_Face& f = TopoDS::Face(itf.Value());
87     TopAbs_State st = SC.StateShapeShape(fsp,f,1);
88     if ((st == TopAbs_UNKNOWN) || (st == TopAbs_OUT)) continue;
89     if (st == TopAbs_ON) {
90       if (!p3ddef) {
91         Standard_Boolean ok = BRepClass3d_SolidExplorer::FindAPointInTheFace(TopoDS::Face(fsp),p3d);
92         if (!ok) return 0;
93         p3ddef = Standard_True;
94       }
95       gp_Pnt2d p2d;Standard_Real dd = 0.; Standard_Boolean ok = FUN_tool_projPonF(p3d,f,p2d,dd);
96       if (!ok) return 0;
97       Standard_Real tolf = BRep_Tool::Tolerance(f)*1.e1;
98       if (dd > tolf) return 0;
99       Standard_Real  TolClass  = 1e-8; BRepTopAdaptor_FClass2d FClass2d(f,TolClass);
100       st = FClass2d.Perform(p2d);
101     }
102     if (st == TopAbs_IN) {
103       Standard_Integer ianc = BDS.Shape(f);
104       return ianc;
105     }
106   } // itf(LF)
107   return 0;
108 }
109
110 static Standard_Integer FUN_getAncestorFsp(TopOpeBRepBuild_Builder& B,TopOpeBRepTool_ShapeClassifier& SC,
111                               const TopTools_ListOfShape& LF1,const TopTools_ListOfShape& LF2,const TopoDS_Shape& fsp)
112 {
113   // IMPORTANT : fsp is split IN/OUT of F1,so it has only one ancestor face
114   // LF1 faces sdm with LF2
115   const TopOpeBRepDS_DataStructure& BDS = B.DataStructure()->DS();
116   Standard_Boolean of1,of2; FUNBUILD_ANCESTORRANKGET(B,fsp,of1,of2);    
117   Standard_Integer rkfsp = 0;
118   if      (of1 && !of2) rkfsp = 1;
119   else if (of2 && !of1) rkfsp = 2;
120   Standard_Boolean unk = (rkfsp == 0);
121
122   Standard_Integer rkf1 = BDS.AncestorRank(LF1.First()); 
123   Standard_Integer rkf2 = BDS.AncestorRank(LF2.First());  
124   Standard_Boolean p3ddef = Standard_False; gp_Pnt p3d;
125   
126   Standard_Boolean ison1 = (rkf1 == rkfsp); 
127   Standard_Boolean ison2 = (rkf2 == rkfsp); 
128
129   Standard_Integer ianc1=0,ianc2=0;
130   if (ison1 || unk) 
131     ianc1 = FUN_getAncestorFsp(B,SC,LF1,fsp,p3ddef,p3d);
132   if (ison1) return ianc1;
133
134   if (ison2 || unk) 
135     ianc2 = FUN_getAncestorFsp(B,SC,LF2,fsp,p3ddef,p3d);
136   if (ison2) return ianc2;
137
138   if (ianc1 + ianc2 >0) {
139     if      (ianc1 == 0) return ianc2; 
140     else if (ianc2 == 0) return ianc1;
141     else                 return 0; // fsp has 2 ancestor faces
142   } 
143   return 0;
144 }
145
146 Standard_EXPORT TopTools_DataMapOfShapeInteger* GLOBAL_SplitAnc = NULL; //xpu260598
147
148 static void FUN_getAncestorFsp(TopOpeBRepBuild_Builder& B,TopOpeBRepTool_ShapeClassifier& SC,
149                                const TopTools_ListOfShape& LF1,const TopTools_ListOfShape& LF2,
150                                const TopoDS_Shape& FOR,TopTools_DataMapOfShapeInteger* SplitAnc)
151 {       
152   if (SplitAnc == NULL) return;
153
154   Standard_Boolean issplitIN = B.IsSplit(FOR,TopAbs_IN); 
155   Standard_Boolean issplitOU = B.IsSplit(FOR,TopAbs_OUT); 
156   if (!issplitIN && !issplitOU) return;
157
158   TopTools_ListOfShape spFOR; 
159   if (issplitIN) FDS_copy(B.Splits(FOR,TopAbs_IN),spFOR);
160   if (issplitOU) FDS_copy(B.Splits(FOR,TopAbs_OUT),spFOR);
161
162   for (TopTools_ListIteratorOfListOfShape itsp(spFOR); itsp.More(); itsp.Next()){
163     const TopoDS_Shape& fsp = itsp.Value();
164     
165     Standard_Boolean isbound = SplitAnc->IsBound(fsp);
166     if (isbound) continue;
167     
168     Standard_Integer ianc = FUN_getAncestorFsp(B,SC,LF1,LF2,fsp);
169     if (ianc != 0) {
170       SplitAnc->Bind(fsp,ianc);
171     }
172   } // itsp
173 }
174
175 Standard_EXPORT TopTools_ListOfShape* GLOBAL_lfr1 = NULL;
176 Standard_EXPORT Standard_Boolean GLOBAL_lfrtoprocess = Standard_False;
177 //Standard_IMPORT extern TopTools_ListOfShape* GLOBAL_lfr1;
178 //Standard_IMPORT TopTools_ListOfShape* GLOBAL_lfr1;
179 //Standard_IMPORT extern Standard_Boolean GLOBAL_lfrtoprocess;
180 //Standard_IMPORT Standard_Boolean GLOBAL_lfrtoprocess;
181
182 //=======================================================================
183 //function : GFillFaceSFS
184 //purpose  : 
185 //=======================================================================
186 void TopOpeBRepBuild_Builder::GFillFaceSFS(const TopoDS_Shape& FOR,const TopTools_ListOfShape& LSO2,const TopOpeBRepBuild_GTopo& Gin,TopOpeBRepBuild_ShellFaceSet& SFS)
187 {
188   TopAbs_State TB1,TB2; Gin.StatesON(TB1,TB2);
189   
190 #ifdef OCCT_DEBUG
191   Standard_Integer iF; Standard_Boolean tSPS = GtraceSPS(FOR,iF);
192   if(tSPS)std::cout<<std::endl;
193 #endif
194   const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
195   Standard_Boolean tosplit = GToSplit(FOR,TB1);
196   Standard_Boolean tomerge = GToMerge(FOR);
197 #ifdef OCCT_DEBUG
198 //  Standard_Integer iFOR = BDS.Shape(FOR);
199 #endif
200   Standard_Integer rkFOR = BDS.AncestorRank(FOR);
201   
202 #ifdef OCCT_DEBUG
203   if(tSPS){
204     GdumpSHASTA(FOR,TB1,"--- GFillFaceSFS START ");
205     std::cout<<" tosplit "<<tosplit<<" tomerge "<<tomerge<<std::endl;
206     debffsfs(iF);
207   }
208 #endif
209   
210   TopoDS_Shape FF = FOR; FF.Orientation(TopAbs_FORWARD);  
211   Standard_Boolean hsd = myDataStructure->HasSameDomain(FOR);   //xpu280598
212   GLOBAL_lfrtoprocess = Standard_False;
213
214   if ( tosplit && tomerge ) {
215     
216     // merge des faces SameDomain
217     
218     // on effectue le merge ssi FOR est la reference de ses faces SameDomain
219     Standard_Integer iref = myDataStructure->SameDomainReference(FOR);
220     const TopoDS_Shape& fref = myDataStructure->Shape(iref);
221     Standard_Boolean isref = FOR.IsSame(fref);
222
223     Standard_Boolean makemerge = isref;
224     // xpu280199 PRO16958 : f10=ref(f6), GToMerge(f10)=false 
225     Standard_Boolean makemergeref = GToMerge(fref);
226     makemerge = makemerge || (!makemergeref && (rkFOR == 1));
227     
228     if (makemerge) {
229       
230 #ifdef OCCT_DEBUG
231       if(tSPS) {
232         GdumpSHASTA(FOR,TB1,"[[[[[[[[[[[[[[[[[[[[[[[[[[ GFillFaceSFS makemerge START ");
233         std::cout<<std::endl;
234       }
235 #endif
236
237       Standard_Boolean performfufa = Standard_True;
238 #ifdef OCCT_DEBUG
239       performfufa = !TopOpeBRepBuild_GetcontextNOFUFA();
240 #endif    
241       if (performfufa) {        
242         GLOBAL_lfrtoprocess = Standard_True;
243         if (GLOBAL_lfrtoprocess) {
244           if (GLOBAL_lfr1==NULL) GLOBAL_lfr1=(TopTools_ListOfShape*)new TopTools_ListOfShape();
245           GLOBAL_lfr1->Clear();
246         }
247       }
248
249       // xpu280598 : Filling up GLOBAL_SplitAnc = {(fsp,ifanc)}
250       //              . fsp = spIN/OU(fanc),
251       //              . fanc hsdm is the unique ancestor face     
252       if ( GLOBAL_SplitAnc == NULL ) GLOBAL_SplitAnc = (TopTools_DataMapOfShapeInteger*) new TopTools_DataMapOfShapeInteger(); 
253       GLOBAL_SplitAnc->Clear();
254
255       TopTools_ListOfShape LFSO,LFDO,LFSO1,LFDO1,LFSO2,LFDO2;
256       GFindSamDomSODO(FF,LFSO,LFDO); // -980617
257 //      FDSSDM_sordor(FF,LFSO,LFDO);
258       Standard_Integer rankF=GShapeRank(FF),rankX=(rankF)?((rankF==1)?2:1):0;
259       GFindSameRank(LFSO,rankF,LFSO1);
260       GFindSameRank(LFDO,rankF,LFDO1);
261       GFindSameRank(LFSO,rankX,LFSO2);
262       GFindSameRank(LFDO,rankX,LFDO2);
263       TopTools_ListOfShape LF1,LF2;
264       
265       TopOpeBRepBuild_GTopo GM;
266       TopAbs_State TB,NTB;
267       Standard_Boolean dodo;
268       Standard_Integer l1,l2;
269       
270       // WES : toutes les faces de meme orientation topologique
271       LF1 = LFSO1; // NYI pointeurs
272       LF2 = LFSO2; // NYI pointeurs
273       l1 = LF1.Extent(); l2 = LF2.Extent();
274       dodo = (l1!=0) && (l2!=0);      
275       
276       FUN_unsetmotherope(); // +12/07
277       
278       GM = Gin;
279       GM.ChangeConfig(TopOpeBRepDS_SAMEORIENTED,TopOpeBRepDS_SAMEORIENTED);
280       if (dodo) {
281 #ifdef OCCT_DEBUG
282         if(tSPS){
283           GdumpSAMDOM(LF1, (char *) "LF1 (LFSO1) : ");
284           GdumpSAMDOM(LF2, (char *) "LF2 (LFSO2) : ");
285         }
286 #endif
287         GLOBAL_classifysplitedge = Standard_True;
288         GFillFacesWESMakeFaces(LF1,LF2,LSO2,GM);
289         GLOBAL_classifysplitedge = Standard_False;
290         
291         GLOBAL_revownsplfacori = Standard_True;
292         FUNBUILD_ANCESTORRANKPREPARE
293           (*this,LF1,LF2,TopOpeBRepDS_SAMEORIENTED,TopOpeBRepDS_SAMEORIENTED);
294         if (hsd) FUN_getAncestorFsp((*this),myShapeClassifier,
295                                     LF1,LF2,FOR,GLOBAL_SplitAnc); //xpu280598
296
297         // GLOBAL_lfrtoprocess = t 
298         // ==> on ne stocke PAS les faces 'startelement' dans le SFS
299         //     mais dans GLOBAL_lfr1,
300         // GLOBAL_lfrtoprocess = f
301         // ==> on stocke normalement dans le SFS et pas dans GLOBAL_lfr1
302         // NYI : + argument a la methode GSplitFaceSFS ?? a voir
303
304         // ici : GLOBAL_lfrtoprocess = t
305         if (GLOBAL_lfr1==NULL) GLOBAL_lfr1=(TopTools_ListOfShape*)new TopTools_ListOfShape(); //flo150998
306         GLOBAL_lfr1->Clear();
307         GSplitFaceSFS(FOR,LSO2,GM,SFS);
308         GLOBAL_lfrtoprocess = Standard_False;
309         GLOBAL_revownsplfacori = Standard_False;
310       }
311       
312       // WES : FOR + faces d'orientation topologique opposee
313       LF1 = LFSO1; // NYI pointeurs
314       LF2 = LFDO2; // NYI pointeurs
315       l1 = LF1.Extent(); l2 = LF2.Extent();
316       dodo = (l1!=0) && (l2!=0);
317       
318       
319       GM = Gin; // OUT,OUT-> OUT,IN + IN OUT
320       TB = TB2; //           ------
321       NTB = TopAbs_IN; // NTB = (TB == TopAbs_OUT) ? TopAbs_IN : TopAbs_OUT;
322       GM.ChangeValue(TB,TopAbs_ON,Standard_False);
323       GM.ChangeValue(NTB,TopAbs_ON,Standard_True);
324       GM.ChangeConfig(TopOpeBRepDS_SAMEORIENTED,TopOpeBRepDS_DIFFORIENTED);
325       FUN_setmotherope(GM); // +12/07
326       if (dodo) {
327 #ifdef OCCT_DEBUG
328         if(tSPS){
329           TopAbs_State TB11,TB21; GM.StatesON(TB11,TB21);
330           std::cout<<std::endl;
331           std::cout <<"@@@@"<<std::endl;
332           std::cout <<"@@@@@@@@ partie 1 : ";TopAbs::Print(TB11,std::cout);std::cout<<" ";TopAbs::Print(TB21,std::cout);std::cout<<std::endl;
333           std::cout <<"@@@@"<<std::endl;
334           GdumpSAMDOM(LF1, (char *) "LF1 (LFSO1) : ");
335           GdumpSAMDOM(LF2, (char *) "LF2 (LFDO2) : ");
336           std::cout<<std::endl;
337         }
338 #endif
339         GLOBAL_classifysplitedge = Standard_True;
340         GFillFacesWESMakeFaces(LF1,LF2,LSO2,GM);
341         GLOBAL_classifysplitedge = Standard_False;
342         
343         GLOBAL_revownsplfacori = Standard_True;
344         FUNBUILD_ANCESTORRANKPREPARE
345           (*this,LF1,LF2,TopOpeBRepDS_SAMEORIENTED,TopOpeBRepDS_DIFFORIENTED);
346         if (hsd) FUN_getAncestorFsp((*this),myShapeClassifier,
347                                     LF1,LF2,FOR,GLOBAL_SplitAnc); //xpu280598
348         
349         if ( Opecom() ) {
350           Standard_Boolean issplitIN = IsSplit(FOR,TopAbs_IN); 
351           if (issplitIN) {
352             const TopTools_ListOfShape& spFOR = Splits(FOR,TopAbs_IN);
353             TopTools_ListOfShape spFORcopy; FDS_copy(spFOR,spFORcopy);
354
355             TopTools_ListIteratorOfListOfShape it(LF1);
356             for (; it.More(); it.Next()) {
357               const TopoDS_Shape& f = it.Value();
358               Standard_Boolean issplit = IsSplit(f,TopAbs_IN);
359               if ( issplit ) ChangeSplit(f,TopAbs_IN).Clear();
360             }
361             it.Initialize(LF2);
362             for (; it.More(); it.Next()) {
363               const TopoDS_Shape& f = it.Value();
364               Standard_Boolean issplit = IsSplit(f,TopAbs_IN);
365               if ( issplit ) ChangeSplit(f,TopAbs_IN).Clear();
366             }
367             ChangeSplit(FOR,TopAbs_IN).Append(spFORcopy); // keep split for reference
368           } // issplitIN
369         } // OpeCom 
370
371         GSplitFaceSFS(FOR,LSO2,GM,SFS);
372         GLOBAL_revownsplfacori = Standard_False;
373
374       } // dodo
375       
376       if (!Opecom()) {
377         GM = Gin; // OUT,OUT-> OUT,IN + IN OUT
378         TB = TB1; //                    ------ 
379         //      NTB = (TB == TopAbs_OUT) ? TopAbs_IN : TopAbs_OUT;
380         NTB = TopAbs_IN;
381         GM.ChangeValue(TopAbs_ON,TB,Standard_False);
382         GM.ChangeValue(TopAbs_ON,NTB,Standard_True);
383         GM.ChangeConfig(TopOpeBRepDS_SAMEORIENTED,TopOpeBRepDS_DIFFORIENTED);
384         FUN_setmotherope(GM); // +12/07
385         if (dodo) {
386 #ifdef OCCT_DEBUG
387           if(tSPS){
388             TopAbs_State TB12,TB22; GM.StatesON(TB12,TB22);
389             std::cout<<std::endl;
390             std::cout <<"@@@@"<<std::endl;
391             std::cout <<"@@@@@@@@ partie 2 : ";TopAbs::Print(TB12,std::cout);std::cout<<" ";TopAbs::Print(TB22,std::cout);std::cout<<std::endl;
392             std::cout <<"@@@@"<<std::endl;
393             GdumpSAMDOM(LF1, (char *) "LF1 (LFSO1) : ");
394             GdumpSAMDOM(LF2, (char *) "LF2 (LFDO2) : ");
395             std::cout<<std::endl;
396           }
397 #endif
398           GLOBAL_classifysplitedge = Standard_True;
399           GFillFacesWESMakeFaces(LF1,LF2,LSO2,GM);
400           GLOBAL_classifysplitedge = Standard_False;
401           
402           GLOBAL_revownsplfacori = Standard_True;
403           FUNBUILD_ANCESTORRANKPREPARE
404             (*this,LF1,LF2,TopOpeBRepDS_SAMEORIENTED,TopOpeBRepDS_DIFFORIENTED);
405           if (hsd) FUN_getAncestorFsp((*this),myShapeClassifier,
406                                       LF1,LF2,FOR,GLOBAL_SplitAnc); //xpu280598
407           GSplitFaceSFS(FOR,LSO2,GM,SFS);
408           GLOBAL_revownsplfacori = Standard_False;
409         }
410       } // !Opecom
411       
412       FUN_unsetmotherope(); // +12/07
413       
414 #ifdef OCCT_DEBUG
415       if(tSPS) { 
416         GdumpSHASTA(FOR,TB1,"]]]]]]]]]]]]]]]]]]]]]]]]]] GFillFaceSFS makemerge END ");
417         std::cout<<std::endl;
418       }
419 #endif
420
421       GLOBAL_SplitAnc->Clear(); // xpu280598
422
423       // FuseFace
424       SFS.ChangeStartShapes().Extent();
425       if (performfufa) {        
426 #ifdef OCCT_DEBUG
427         if(tSPS) debffflo(iF);
428 #endif
429 //      const TopTools_ListOfShape& lou = Splits(FF,TopAbs_OUT); Standard_Integer nou = lou.Extent();
430 //      const TopTools_ListOfShape& lin = Splits(FF,TopAbs_IN);  Standard_Integer nin = lin.Extent();
431 //      GCopyList(lou,*GLOBAL_lfr1);
432 //      GCopyList(lin,*GLOBAL_lfr1);    
433 #ifdef OCCT_DEBUG
434 //      Standard_Integer nlfr1 = GLOBAL_lfr1->Extent();
435 #endif
436
437         // NYI : Builder += methode pour le process fufa
438         TopOpeBRepBuild_FuseFace fufa; TopTools_ListOfShape ldum; Standard_Integer addinternal = 1; // disparition
439         fufa.Init(ldum,*GLOBAL_lfr1,addinternal);
440         fufa.PerformFace();
441         Standard_Boolean isdone = fufa.IsDone();
442         if (!isdone) return;
443 #ifdef OCCT_DEBUG
444 //      Standard_Boolean ismodified = fufa.IsModified();
445 #endif
446         const TopTools_ListOfShape& lfr2 = fufa.LFuseFace();
447 //
448 //      const TopTools_ListOfShape& lfr2 = *GLOBAL_lfr1
449         // les faces remplacantes
450         for (TopTools_ListIteratorOfListOfShape itlfr2(lfr2);itlfr2.More();itlfr2.Next()) {
451           const TopoDS_Shape& flfr2 = itlfr2.Value();
452           
453 #ifdef OCCT_DEBUG
454           if(tSPS){
455             DEBSHASET(ss,"--- FillFaceSFS apres fufa",SFS," AddStartElement SFS+ face ");  
456             GdumpSHA(flfr2,(Standard_Address)ss.ToCString());
457             std::cout<<" ";TopAbs::Print(TB1,std::cout)<<" : 1 face ";
458             TopAbs::Print(flfr2.Orientation(),std::cout); std::cout<<std::endl;
459           }
460 #endif
461           SFS.AddStartElement(flfr2);
462         }
463       } // performfufa (context)
464       
465     } // makemerge
466   } // tosplit && tomerge
467   
468   else if ( tosplit && !tomerge ) {    
469     GSplitFace(FOR,Gin,LSO2);
470     GSplitFaceSFS(FOR,LSO2,Gin,SFS);
471   }
472   else if ( !tosplit && !tomerge ) {
473     GSplitFaceSFS(FOR,LSO2,Gin,SFS);
474   }
475   
476   myEdgeAvoid.Clear();
477   
478 #ifdef OCCT_DEBUG
479   if(tSPS){
480     GdumpSHASTA(FOR,TB1,"--- GFillFaceSFS END ");std::cout<<std::endl;
481   }
482 #endif
483  
484 } // GFillFaceSFS