0026173: Wrong result of ChFi3d_ChBuilder algorithm: incorrect processing of G1 junct...
[occt.git] / src / ChFi3d / ChFi3d_FilBuilder_C2.cxx
1 // Created on: 1994-03-29
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1994-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 <Adaptor3d_CurveOnSurface.hxx>
19 #include <Adaptor3d_HCurveOnSurface.hxx>
20 #include <Adaptor3d_TopolTool.hxx>
21 #include <BRep_Tool.hxx>
22 #include <BRepAdaptor_Curve.hxx>
23 #include <BRepAdaptor_Curve2d.hxx>
24 #include <BRepAdaptor_HCurve.hxx>
25 #include <BRepAdaptor_HCurve2d.hxx>
26 #include <BRepAdaptor_HSurface.hxx>
27 #include <BRepAdaptor_Surface.hxx>
28 #include <BRepBlend_CSCircular.hxx>
29 #include <BRepBlend_Line.hxx>
30 #include <BRepLProp_CLProps.hxx>
31 #include <BRepTopAdaptor_TopolTool.hxx>
32 #include <BSplCLib.hxx>
33 #include <ChFi3d.hxx>
34 #include <ChFi3d_Builder_0.hxx>
35 #include <ChFi3d_FilBuilder.hxx>
36 #include <ChFiDS_CommonPoint.hxx>
37 #include <ChFiDS_FaceInterference.hxx>
38 #include <ChFiDS_FilSpine.hxx>
39 #include <ChFiDS_HData.hxx>
40 #include <ChFiDS_HElSpine.hxx>
41 #include <ChFiDS_ListIteratorOfListOfStripe.hxx>
42 #include <ChFiDS_Regul.hxx>
43 #include <ChFiDS_SequenceOfSurfData.hxx>
44 #include <ChFiDS_Spine.hxx>
45 #include <ChFiDS_State.hxx>
46 #include <ChFiDS_Stripe.hxx>
47 #include <ChFiDS_SurfData.hxx>
48 #include <ChFiKPart_ComputeData.hxx>
49 #include <Geom2d_BSplineCurve.hxx>
50 #include <Geom2d_TrimmedCurve.hxx>
51 #include <Geom2dAdaptor_Curve.hxx>
52 #include <Geom2dAdaptor_HCurve.hxx>
53 #include <Geom2dConvert.hxx>
54 #include <Geom_BSplineCurve.hxx>
55 #include <Geom_BSplineSurface.hxx>
56 #include <GeomAdaptor_Curve.hxx>
57 #include <GeomAdaptor_HCurve.hxx>
58 #include <GeomAdaptor_HSurface.hxx>
59 #include <GeomAdaptor_Surface.hxx>
60 #include <GeomFill_ConstrainedFilling.hxx>
61 #include <GeomFill_SimpleBound.hxx>
62 #include <gp_Ax3.hxx>
63 #include <gp_Dir.hxx>
64 #include <gp_Lin.hxx>
65 #include <gp_Pln.hxx>
66 #include <gp_Pnt.hxx>
67 #include <gp_Pnt2d.hxx>
68 #include <gp_XY.hxx>
69 #include <IntCurveSurface_HInter.hxx>
70 #include <IntCurveSurface_IntersectionPoint.hxx>
71 #include <IntSurf_LineOn2S.hxx>
72 #include <IntSurf_Transition.hxx>
73 #include <IntSurf_TypeTrans.hxx>
74 #include <Law_Function.hxx>
75 #include <Law_Linear.hxx>
76 #include <math_Vector.hxx>
77 #include <Standard_ErrorHandler.hxx>
78 #include <Standard_NotImplemented.hxx>
79 #include <StdFail_NotDone.hxx>
80 #include <TColgp_Array1OfPnt.hxx>
81 #include <TColgp_Array1OfPnt2d.hxx>
82 #include <TColStd_Array1OfInteger.hxx>
83 #include <TColStd_Array1OfReal.hxx>
84 #include <TColStd_ListOfInteger.hxx>
85 #include <TopAbs.hxx>
86 #include <TopAbs_Orientation.hxx>
87 #include <TopExp.hxx>
88 #include <TopoDS.hxx>
89 #include <TopoDS_Edge.hxx>
90 #include <TopoDS_Face.hxx>
91 #include <TopoDS_Shape.hxx>
92 #include <TopoDS_Vertex.hxx>
93 #include <TopOpeBRepDS_DataStructure.hxx>
94 #include <TopOpeBRepDS_HDataStructure.hxx>
95 #include <TopOpeBRepDS_ListOfInterference.hxx>
96 #include <TopTools_ListIteratorOfListOfShape.hxx>
97
98 #ifdef DRAW
99 #include <DrawTrSurf.hxx>
100 #endif
101 #ifdef OCCT_DEBUG
102 #include <Geom_TrimmedCurve.hxx>
103 extern Standard_Boolean ChFi3d_GettraceDRAWSPINE();
104 extern Standard_Boolean ChFi3d_GetcontextFORCEFILLING();
105 #include <OSD_Chronometer.hxx>
106
107 extern Standard_Real  t_t2cornerinit ,t_perf2cornerbyinter,t_chfikpartcompdata,
108                      t_cheminement,t_remplissage,t_t2cornerDS;
109 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
110 extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
111 #endif
112
113 //=======================================================================
114 //function : ToricRotule
115 //purpose  : Test if it is a particular case of torus routine.
116 //           Three planes with two constant incident fillets
117 //           of the same radius and the third face perpendicular to  
118 //           two others are required.
119 //=======================================================================
120
121 static Standard_Boolean ToricRotule(const BRepAdaptor_Surface& fac,
122                                     const BRepAdaptor_Surface& s1,
123                                     const BRepAdaptor_Surface& s2,
124                                     const Handle(ChFiDS_Stripe)& c1,
125                                     const Handle(ChFiDS_Stripe)& c2)
126
127 {
128   Standard_Real tolesp = 1.e-7;
129
130   Handle(ChFiDS_FilSpine) sp1=Handle(ChFiDS_FilSpine)::DownCast(c1->Spine()); 
131   Handle(ChFiDS_FilSpine) sp2=Handle(ChFiDS_FilSpine)::DownCast(c2->Spine()); 
132   if(sp1.IsNull() || sp2.IsNull()) return Standard_False;
133   if (!sp1->IsConstant() || !sp2->IsConstant()) 
134     return Standard_False;
135   if ((fac.GetType() != GeomAbs_Plane) ||
136       (s1.GetType() != GeomAbs_Plane) ||
137       (s2.GetType() != GeomAbs_Plane)) return Standard_False;
138   gp_Dir df = fac.Plane().Position().Direction();
139   gp_Dir ds1 = s1.Plane().Position().Direction();
140   gp_Dir ds2 = s2.Plane().Position().Direction();
141   if ( Abs(df.Dot(ds1)) >= tolesp || Abs(df.Dot(ds2)) >= tolesp ) 
142     return Standard_False;
143   Standard_Real r1 = sp1->Radius();
144   Standard_Real r2 = sp2->Radius();
145   if(Abs(r1 - r2) >= tolesp) return Standard_False;
146   return Standard_True;
147 }
148
149 static void RemoveSD(Handle(ChFiDS_Stripe)& Stripe,
150                       const Standard_Integer num1,
151                       const Standard_Integer num2 )
152 {
153   ChFiDS_SequenceOfSurfData& Seq = 
154     Stripe->ChangeSetOfSurfData()->ChangeSequence();
155   if(Seq.IsEmpty()) return;
156   if (num1==num2) 
157     Seq.Remove(num1);
158   else
159     Seq.Remove(num1,num2);
160 }
161
162
163 //=======================================================================
164 //function : PerformTwoCorner
165 //purpose  : 
166 //=======================================================================
167
168 void ChFi3d_FilBuilder::PerformTwoCorner(const Standard_Integer Index)
169 {
170 #ifdef OCCT_DEBUG
171   OSD_Chronometer ch;
172   ChFi3d_InitChron(ch); // init perf initialisation 
173 #endif 
174   
175   done = 0;
176   const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
177   TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
178   ChFiDS_ListIteratorOfListOfStripe It;
179   It.Initialize(myVDataMap(Index));
180   Handle(ChFiDS_Stripe)  st1,st2;
181   Standard_Integer Sens1,Sens2;
182   Standard_Integer Isd1,Isd2,i1,i2;
183   Handle(ChFiDS_SurfData) sd1,sd2;
184   ChFiDS_SequenceOfSurfData SeqFil1,SeqFil2;
185   Handle(Geom_Surface) surf1,surf2;
186   Standard_Boolean  OkinterCC,Okvisavis,SameSide;
187   Standard_Integer IFaCo1,IFaCo2;
188   Standard_Real UIntPC1,UIntPC2;
189   TopoDS_Face FaCo;
190   TopoDS_Edge E1,E2,E;
191   TopoDS_Vertex V1,V2;
192 //  gp_Pnt P1,P2;
193   Standard_Integer nbsurf1,nbsurf2,deb1,fin1,deb2,fin2;
194   Standard_Real parE1,parE2;
195   //Necessary information on fillets is extracted 
196   //------------------------------------------------------
197   
198   //the first
199   //----------
200  
201   st1 = It.Value(); 
202   Isd1 = ChFi3d_IndexOfSurfData(Vtx,st1,Sens1);
203   
204   
205   //the second
206   //----------
207   It.Next();
208   st2 = It.Value();
209   if(st2 == st1) {
210     Sens2 = -1;
211     Isd2 = st2->SetOfSurfData()->Length();
212   }
213   else{ Isd2 = ChFi3d_IndexOfSurfData(Vtx,st2,Sens2); }
214   
215   // If two edges to rounded are tangent GeomPlate is called
216
217   if (Sens1==1)  E1= st1->Spine()->Edges(1);
218   else E1= st1->Spine()->Edges( st1->Spine()->NbEdges());
219   
220   if (Sens2==1)  E2= st2->Spine()->Edges(1);
221   else E2= st2->Spine()->Edges( st2->Spine()->NbEdges());
222   
223   BRepAdaptor_Curve BCurv1(E1);
224   BRepAdaptor_Curve BCurv2(E2);
225   parE1=BRep_Tool::Parameter(Vtx,E1);
226   parE2=BRep_Tool::Parameter(Vtx,E2);
227   BRepLProp_CLProps CL1(BCurv1,parE1 , 1, 1.e-4);
228   BRepLProp_CLProps CL2(BCurv2,parE2 , 1, 1.e-4);
229   gp_Dir dir1,dir2 ;
230   CL1.Tangent(dir1);
231   CL2.Tangent(dir2);
232   if (Sens1==-1)  dir1.Reverse();
233   if (Sens2==-1)  dir2.Reverse();
234   Standard_Real ang1;
235   ang1=Abs(dir1.Angle(dir2));
236   if (ang1<M_PI/180.) {
237     PerformMoreThreeCorner(Index,2);
238     done=1;
239     return;
240   }
241
242   OkinterCC = ChFi3d_IsInFront(DStr,st1,st2,Isd1,Isd2,Sens1,Sens2,
243                                UIntPC1,UIntPC2,FaCo,SameSide,
244                                IFaCo1,IFaCo2,Okvisavis,Vtx,Standard_True);
245
246   Standard_Boolean trouve=Standard_False;  
247   if (!Okvisavis) {
248
249   
250 // one is not limited to the first or the last surfdata 
251 // to find the opposing data
252     nbsurf1=st1->SetOfSurfData()->Length();
253     nbsurf2=st2->SetOfSurfData()->Length();
254     deb1=1; 
255     deb2=1;
256     fin1=1;
257     fin2=1;
258     if (nbsurf1!=1) {
259       if (Sens1==1) {
260         deb1=1;
261         fin1=2;
262       }
263       else  {
264         deb1=nbsurf1-1;
265         fin1=nbsurf1;
266       }
267     }
268     if (nbsurf2!=1) {
269       if (Sens2==1 ) {
270         deb2=1;
271         fin2=2;
272       }
273       else {
274         deb2=nbsurf2-1;
275         fin2=nbsurf2;
276       }
277     }
278   
279     for (i1=deb1;i1<=fin1 &&!trouve;i1++) {
280       Isd1=i1;
281       for (i2=deb2;i2<=fin2 &&!trouve;i2++) {
282         Isd2=i2;
283  
284         OkinterCC = ChFi3d_IsInFront(DStr,st1,st2,Isd1,Isd2,Sens1,Sens2,
285                                UIntPC1,UIntPC2,FaCo,SameSide,
286                                IFaCo1,IFaCo2,Okvisavis,Vtx,Standard_True);
287         trouve=Okvisavis;
288       }
289     } 
290     if (!trouve){
291       PerformMoreThreeCorner(Index,2);
292       done=1;
293       return;
294     }
295     else {
296       if (Sens1==1 && Isd1!=1) RemoveSD(st1,1,1);
297       if (Sens1!=1 && Isd1!=nbsurf1) RemoveSD(st1,fin1,fin1);
298       if (Sens2==1 && Isd2!=1) RemoveSD(st2,1,1);
299       if (Sens2!=1 && Isd2!=nbsurf2) RemoveSD(st2,fin2,fin2);
300
301     }
302     Isd1=ChFi3d_IndexOfSurfData(Vtx,st1,Sens1);
303     Isd2=ChFi3d_IndexOfSurfData(Vtx,st2,Sens2);
304   }
305    // StdFail_NotDone::Raise("TwoCorner : no common face");
306   Standard_Integer IFaArc1 = 3-IFaCo1, IFaArc2 = 3-IFaCo2;
307   SeqFil1 = st1->ChangeSetOfSurfData()->ChangeSequence();
308   SeqFil2 = st2->ChangeSetOfSurfData()->ChangeSequence();
309   sd1 = SeqFil1.ChangeValue(Isd1);
310   surf1 = DStr.Surface(sd1->Surf()).Surface();
311   sd2 = SeqFil2.ChangeValue(Isd2);
312   surf2 = DStr.Surface(sd2->Surf()).Surface();
313   TopAbs_Orientation OFaCo = FaCo.Orientation(); 
314   // The concavities are analyzed and the opposite face and the
315   // eventual intersection of 2 pcurves on this face are found.
316   
317   ChFiDS_State Stat1,Stat2;
318   Standard_Boolean isfirst1 = (Sens1 == 1);
319   Standard_Boolean isfirst2 = (Sens2 == 1);
320   Stat1 = st1->Spine()->Status(isfirst1);
321   Stat2 = st2->Spine()->Status(isfirst2);
322   Standard_Boolean c1biseau = (Stat1 == ChFiDS_AllSame); 
323   Standard_Boolean c1rotule = (Stat1 == ChFiDS_OnSame && Stat2 == ChFiDS_OnSame);
324   
325   // It is checked if the fillets have a commonpoint on a common arc. 
326   // This edge is the pivot of the bevel or the knee.
327   
328   ChFiDS_CommonPoint& CP1 = sd1->ChangeVertex(isfirst1,IFaArc1);
329   ChFiDS_CommonPoint& CP2 = sd2->ChangeVertex(isfirst2,IFaArc2);
330   
331   Standard_Boolean resetcp1 = 0;
332   Standard_Boolean resetcp2 = 0;
333   
334   TopoDS_Edge pivot;
335   Standard_Boolean yapiv = Standard_False;
336   if(CP1.IsOnArc()) pivot = CP1.Arc();
337   else {
338     PerformMoreThreeCorner(Index,2);
339     done=1;
340     return;
341   }
342   if(CP1.IsOnArc()&& CP2.IsOnArc()){
343     yapiv = (pivot.IsSame(CP2.Arc()));
344   }
345   Handle(BRepAdaptor_HCurve) Hpivot;
346   Standard_Boolean sameparam = Standard_False;
347   Standard_Real parCP1 = 0., parCP2 = 0.;
348   if(yapiv) {
349     Hpivot = new BRepAdaptor_HCurve(pivot);
350     parCP1 = CP1.ParameterOnArc();
351     parCP2 = CP2.ParameterOnArc();
352     gp_Pnt tst1 = Hpivot->Value(parCP1);
353     gp_Pnt tst2 = Hpivot->Value(parCP2);
354     sameparam = tst1.Distance(tst2) <= tolesp;
355   }
356   Handle(BRepAdaptor_HSurface) HFaCo = new BRepAdaptor_HSurface();
357   Handle(BRepAdaptor_HSurface) HFaPiv;
358   Handle(BRepAdaptor_HSurface) HBRS1 = new BRepAdaptor_HSurface();
359   Handle(BRepAdaptor_HSurface) HBRS2 = new BRepAdaptor_HSurface();
360   
361   BRepAdaptor_Surface& BRS1 = HBRS1->ChangeSurface();
362   BRepAdaptor_Surface& BRS2 = HBRS2->ChangeSurface();
363   BRepAdaptor_Surface& BRFaCo = HFaCo->ChangeSurface();
364   BRFaCo.Initialize(FaCo);
365   
366   TopoDS_Face FF1,FF2,F,FaPiv;
367   TopAbs_Orientation pctrans = TopAbs_FORWARD ;
368   Handle(Geom2d_BSplineCurve) PCurveOnPiv;
369   FF1 = TopoDS::Face(DStr.Shape(sd1->Index(IFaArc1)));
370   FF2 = TopoDS::Face(DStr.Shape(sd2->Index(IFaArc2)));
371   if (FF1.IsNull()||FF2.IsNull()) 
372   {PerformMoreThreeCorner(Index,2);
373    done=1;
374    return;
375   }
376   BRS1.Initialize(FF1);
377   BRS2.Initialize(FF2);
378   
379   if(yapiv ) {
380     TopTools_ListIteratorOfListOfShape Kt;
381     Standard_Boolean ok1 = Standard_False, ok2 = Standard_False;
382     for (Kt.Initialize(myEFMap(pivot)); Kt.More(); Kt.Next()){
383       F = TopoDS::Face(Kt.Value());
384       if(!ok1 && FF1.IsSame(F)){
385         ok1 = Standard_True;
386       }
387       if(!ok2 && FF2.IsSame(F)){
388         ok2 = Standard_True;
389       }
390     }
391     if(!ok1 || !ok2){
392       PerformMoreThreeCorner(Index,2);
393       done=1;
394       return;
395     }
396   }
397   
398 #ifdef OCCT_DEBUG
399   ChFi3d_ResultChron(ch ,t_t2cornerinit);//result perf initialisation 
400 #endif 
401   
402   //bevel
403   //------
404   ChFiDS_CommonPoint cp11,cp12,cp21,cp22;
405   ChFiDS_FaceInterference intf11,intf12,intf21,intf22;
406
407   if(c1biseau){
408 #ifdef OCCT_DEBUG
409     ChFi3d_InitChron(ch); // init perf PerformTwoCornerbyInter
410 #endif 
411     
412     done = PerformTwoCornerbyInter(Index);
413     
414 #ifdef OCCT_DEBUG
415     ChFi3d_ResultChron(ch , t_perf2cornerbyinter); // result perf  PerformTwoCornerbyInter
416 #endif 
417    
418     if (!done){
419       PerformMoreThreeCorner(Index,2);
420       done=1;
421       return;
422     }
423   } 
424   else if(c1rotule){//save.
425     cp11 = sd1->Vertex(isfirst1,1);
426     cp12 = sd1->Vertex(isfirst1,2);
427     cp21 = sd2->Vertex(isfirst2,1);
428     cp22 = sd2->Vertex(isfirst2,2);
429     intf11 = sd1->InterferenceOnS1();
430     intf12 = sd1->InterferenceOnS2();
431     intf21 = sd2->InterferenceOnS1();
432     intf22 = sd2->InterferenceOnS2();
433 #ifdef OCCT_DEBUG
434     ChFi3d_InitChron(ch); // init perf PerformTwoCornerbyInter
435 #endif 
436       
437     done = PerformTwoCornerbyInter(Index);
438       
439 #ifdef OCCT_DEBUG
440       ChFi3d_ResultChron(ch , t_perf2cornerbyinter); // result perf  PerformTwoCornerbyInter
441 #endif 
442     if (!done) {
443       // restore
444       sd1->ChangeVertex(isfirst1,1) = cp11;
445       sd1->ChangeVertex(isfirst1,2) = cp12;
446       sd2->ChangeVertex(isfirst2,1) = cp21;
447       sd2->ChangeVertex(isfirst2,2) = cp22;
448       sd1->ChangeInterferenceOnS1() = intf11;
449       sd1->ChangeInterferenceOnS2() = intf12;
450       sd2->ChangeInterferenceOnS1() = intf21;
451       sd2->ChangeInterferenceOnS2() = intf22;
452       done = 0;
453     }
454   }
455   
456   if(!c1biseau && !done){
457     //new cornerdata is created
458     //-------------------------------
459     Handle(ChFiDS_Stripe) corner = new ChFiDS_Stripe();
460     Handle(ChFiDS_HData)& cornerset = corner->ChangeSetOfSurfData();
461     cornerset = new ChFiDS_HData();
462     Handle(ChFiDS_SurfData) coin = new ChFiDS_SurfData();
463     cornerset->Append(coin);
464     
465     if (SameSide) {
466       if(ToricRotule(BRFaCo,BRS1,BRS2,st1,st2)){
467         // Direct construction.
468         // ---------------------
469         
470         Standard_Integer bid;
471         TopAbs_Orientation ori = OFaCo;
472         TopAbs_Orientation oriS = st1->Orientation(IFaCo1);
473         TopAbs_Orientation OFF1 = FF1.Orientation(); 
474         TopAbs_Orientation oriSFF1 = st1->Orientation(IFaArc1);
475         bid = 1;
476         bid = ChFi3d::NextSide(ori,OFF1,oriS,oriSFF1,bid);
477         TopAbs_Orientation op1 = TopAbs_FORWARD,op2 = TopAbs_FORWARD;
478         if(yapiv) bid = ChFi3d::ConcaveSide(BRS1,BRS2,pivot,op1,op2);
479         op1 = TopAbs::Reverse(op1);
480         op2 = TopAbs::Reverse(op2);
481 #ifdef OCCT_DEBUG
482         ChFi3d_InitChron(ch);// init perf ChFiKPart_ComputeData 
483 #endif 
484         Standard_Real radius = 
485           Handle(ChFiDS_FilSpine)::DownCast(st1->Spine())->Radius();
486         done = ChFiKPart_ComputeData::ComputeCorner(DStr,coin,HFaCo,HBRS1,HBRS2,
487                                                     OFaCo,ori,op1,op2,radius);
488 #ifdef OCCT_DEBUG
489         ChFi3d_ResultChron(ch , t_chfikpartcompdata);//result perf ChFiKPart_ComputeData 
490 #endif 
491       }
492       else {
493         // Construction by filling remplissage
494         // ----------------------------
495         Standard_Real  uPCArc1,  uPCArc2;
496         gp_Pnt2d p2da1,p2df1,p2da2,p2df2,p2dfac1,p2dfac2;
497         gp_Vec2d v2dfac1,v2dfac2;
498         Handle(GeomFill_Boundary) B1,B2,Bpiv,Bfac;
499         uPCArc1 = sd1->Interference(IFaArc1).Parameter(isfirst1);
500         p2da1 = sd1->Interference(IFaArc1).PCurveOnSurf()->Value(uPCArc1);
501         p2df1 = sd1->Interference(IFaCo1).PCurveOnSurf()->Value(uPCArc1);
502         sd1->Interference(IFaCo1).PCurveOnFace()->D1(uPCArc1,p2dfac1,v2dfac1);
503         uPCArc2 = sd2->Interference(IFaArc2).Parameter(isfirst2);
504         p2da2 = sd2->Interference(IFaArc2).PCurveOnSurf()->Value(uPCArc2);
505         p2df2 = sd2->Interference(IFaCo2).PCurveOnSurf()->Value(uPCArc2);
506         sd2->Interference(IFaCo2).PCurveOnFace()->D1(uPCArc2,p2dfac2,v2dfac2);
507 #ifdef OCCT_DEBUG
508         ChFi3d_InitChron(ch ); // init perf filling
509 #endif 
510         B1 = ChFi3d_mkbound(surf1,p2df1,p2da1,tolesp,2.e-4);
511         B2 = ChFi3d_mkbound(surf2,p2df2,p2da2,tolesp,2.e-4);
512         Handle(Geom2d_Curve) PCurveOnFace;
513         Bfac = ChFi3d_mkbound(HFaCo,PCurveOnFace,Sens1,p2dfac1,v2dfac1,
514                               Sens2,p2dfac2,v2dfac2,tolesp,2.e-4);
515         GeomFill_ConstrainedFilling fil(8,20);
516         if(sameparam) {
517           fil.Init(Bfac,B2,B1,1);
518         }
519         else {
520           Handle(Adaptor3d_HCurve) HPivTrim = Hpivot->ChangeCurve().
521             Trim(Min(parCP1,parCP2),Max(parCP1,parCP2),tolesp);
522           Bpiv = new GeomFill_SimpleBound(HPivTrim,tolesp,2.e-4);
523           fil.Init(Bfac,B2,Bpiv,B1,1);
524           BRepAdaptor_Curve2d pcpivot;
525           gp_Vec dArc,dcf;
526           gp_Pnt bidon;
527           Hpivot->D1(parCP1,bidon,dArc);
528           Standard_Real fb1,lb1;
529           B1->Bounds(fb1,lb1);
530           B1->D1(lb1,bidon,dcf);
531           Standard_Boolean pivotverslebas = dArc.Dot(dcf) <= 0.; 
532           Standard_Boolean pcfalenvers = (parCP1 > parCP2);
533           if((pivotverslebas && !pcfalenvers)||
534              (!pivotverslebas && pcfalenvers)) {
535             FaPiv = FF2;
536             HFaPiv = HBRS2;
537             resetcp2 = 1;
538           }
539           else {
540             FaPiv = FF1;
541             HFaPiv = HBRS1;
542             resetcp1 = 1;
543           }
544           FaPiv.Orientation(TopAbs_FORWARD);
545           pcpivot.Initialize(pivot,FaPiv);
546           TopExp_Explorer Expl;
547           for(Expl.Init(FaPiv,TopAbs_EDGE); Expl.More(); Expl.Next()){
548             if(Expl.Current().IsSame(pivot)) {
549               pctrans = Expl.Current().Orientation();
550               break;
551             }
552           }
553           if(pcpivot.GetType() != GeomAbs_BSplineCurve){
554             Handle(Geom2d_TrimmedCurve) 
555               trc = new Geom2d_TrimmedCurve(pcpivot.Curve(),
556                                             Min(parCP1,parCP2),
557                                             Max(parCP1,parCP2));
558             PCurveOnPiv = Geom2dConvert::CurveToBSplineCurve(trc);
559           }
560           else {
561             PCurveOnPiv = Geom2dConvert::SplitBSplineCurve
562               (Handle(Geom2d_BSplineCurve)::DownCast(pcpivot.Curve()),
563                Min(parCP1,parCP2),Max(parCP1,parCP2),tol2d);
564           }
565           TColStd_Array1OfReal kk(1,PCurveOnPiv->NbKnots());
566           PCurveOnPiv->Knots(kk);
567           BSplCLib::Reparametrize(0.,1.,kk);
568           PCurveOnPiv->SetKnots(kk);
569           if(pcfalenvers) {
570             PCurveOnPiv->Reverse();
571             pctrans = TopAbs::Reverse(pctrans);
572           }
573         }
574         Handle(Geom_Surface) Surfcoin = fil.Surface();
575         done = CompleteData(coin,Surfcoin,
576                             HFaCo,PCurveOnFace,
577                             HFaPiv,PCurveOnPiv,OFaCo,1,
578                             0,0,0,0);
579 #ifdef OCCT_DEBUG
580         ChFi3d_ResultChron(ch , t_remplissage);// result perf filling 
581 #endif 
582       }
583 #ifdef OCCT_DEBUG
584       ChFi3d_InitChron(ch); // init perf update DS
585 #endif 
586       if (done){
587         // Update 3 CornerData and the DS
588         // ----------------------------------------
589         if(resetcp1){
590           gp_Pnt pjyl = CP1.Point();
591           Standard_Real tolsav = CP1.Tolerance();
592           CP1.Reset();
593           CP1.SetPoint(pjyl);
594           CP1.SetTolerance(tolsav);
595         }
596         else if(resetcp2){
597           gp_Pnt pjyl = CP2.Point();
598           Standard_Real tolsav = CP2.Tolerance();
599           CP2.Reset();
600           CP2.SetPoint(pjyl);
601           CP2.SetTolerance(tolsav);
602         }
603         Standard_Real P1deb,P2deb,P1fin,P2fin;
604         Standard_Integer If1,If2,Il1,Il2,Icf,Icl;
605         const ChFiDS_CommonPoint& Pf1 = coin->VertexFirstOnS1();
606         ChFiDS_CommonPoint& Pf2 = coin->ChangeVertexFirstOnS2();
607         const ChFiDS_CommonPoint& Pl1 = coin->VertexLastOnS1();
608         ChFiDS_CommonPoint& Pl2 = coin->ChangeVertexLastOnS2();
609         Pf2 = CP1;
610         Pl2 = CP2;
611         
612         // the corner to start,
613         // -----------------------
614         ChFiDS_Regul regdeb, regfin;
615         If1 = ChFi3d_IndexPointInDS(Pf1,DStr);
616         If2 = ChFi3d_IndexPointInDS(Pf2,DStr);
617         Il1 = ChFi3d_IndexPointInDS(Pl1,DStr);
618         if(sameparam) Il2 = If2;
619         else Il2 = ChFi3d_IndexPointInDS(Pl2,DStr);
620         
621         gp_Pnt2d pp1,pp2;
622         pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
623           Value(coin->InterferenceOnS1().FirstParameter());
624         pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
625           Value(coin->InterferenceOnS2().FirstParameter());
626         Handle(Geom_Curve) C3d;
627         Standard_Real tolreached;
628         ChFi3d_ComputeArete(Pf1,pp1,Pf2,pp2,
629                             DStr.Surface(coin->Surf()).Surface(),C3d,
630                             corner->ChangeFirstPCurve(),P1deb,P2deb,
631                             tolesp,tol2d,tolreached,0);
632         Standard_Real par1 = sd1->Interference(IFaArc1).Parameter(isfirst1);
633         pp1 = sd1->Interference(IFaCo1).PCurveOnSurf()->Value(par1);
634         pp2 = sd1->Interference(IFaArc1).PCurveOnSurf()->Value(par1);
635         Standard_Real tolr1;
636         ChFi3d_ComputePCurv(C3d,pp1,pp2,st1->ChangePCurve(isfirst1),
637                             DStr.Surface(sd1->Surf()).Surface(),
638                             P1deb,P2deb,tolesp,tolr1);
639         tolreached = Max(tolreached,tolr1);
640         TopOpeBRepDS_Curve Tcurv1(C3d,tolreached);
641         Icf = DStr.AddCurve(Tcurv1);
642         regdeb.SetCurve(Icf);
643         regdeb.SetS1(coin->Surf(),0);
644         regdeb.SetS2(sd1->Surf(),0);
645         myRegul.Append(regdeb);
646         corner->ChangeFirstCurve(Icf);
647         corner->ChangeFirstParameters(P1deb,P2deb);
648         corner->ChangeIndexFirstPointOnS1(If1);
649         corner->ChangeIndexFirstPointOnS2(If2);
650       
651         pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
652           Value(coin->InterferenceOnS1().LastParameter());
653         pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
654           Value(coin->InterferenceOnS2().LastParameter());
655         ChFi3d_ComputeArete(Pl1,pp1,Pl2,pp2,
656                             DStr.Surface(coin->Surf()).Surface(),C3d,
657                             corner->ChangeLastPCurve(),P1fin,P2fin,
658                             tolesp,tol2d,tolreached,0);
659         Standard_Real par2 = sd2->Interference(IFaArc2).Parameter(isfirst2);
660         pp1 = sd2->Interference(IFaCo2).PCurveOnSurf()->Value(par2);
661         pp2 = sd2->Interference(IFaArc2).PCurveOnSurf()->Value(par2);
662         Standard_Real tolr2;
663         ChFi3d_ComputePCurv(C3d,pp1,pp2,st2->ChangePCurve(isfirst2),
664                             DStr.Surface(sd2->Surf()).Surface(),
665                             P1deb,P2deb,tolesp,tolr2);
666         tolreached = Max(tolreached,tolr2);
667         TopOpeBRepDS_Curve Tcurv2(C3d,tolreached);
668         Icl = DStr.AddCurve(Tcurv2);
669         regfin.SetCurve(Icl);
670         regfin.SetS1(coin->Surf(),0);
671         regfin.SetS2(sd2->Surf(),0);
672         myRegul.Append(regfin);
673         corner->ChangeLastCurve(Icl);
674         corner->ChangeLastParameters(P1fin,P2fin);
675         corner->ChangeIndexLastPointOnS1(Il1);
676         corner->ChangeIndexLastPointOnS2(Il2);
677         
678         coin->ChangeIndexOfS1(DStr.AddShape(FaCo));
679         if(sameparam) coin->ChangeIndexOfS2(0);
680         else {
681           coin->ChangeIndexOfS2(DStr.AddShape(FaPiv));
682           coin->ChangeInterferenceOnS2().SetTransition(pctrans);
683         }
684         corner->SetSolidIndex(st1->SolidIndex());
685         
686         // then the starting Stripe,
687         // ------------------------
688         st1->SetCurve(Icf,isfirst1);
689         st1->SetIndexPoint(If1,isfirst1,IFaCo1);
690         st1->SetIndexPoint(If2,isfirst1,IFaArc1);
691         st1->SetParameters(isfirst1,P1deb,P2deb);
692         sd1->ChangeVertex(isfirst1,IFaCo1) = Pf1;
693         sd1->ChangeVertex(isfirst1,IFaArc1) = Pf2;
694         sd1->ChangeInterference(IFaCo1).SetParameter(par1,isfirst1);
695         if (IFaCo1 == 2) st1->SetOrientation(TopAbs_REVERSED,isfirst1);
696         
697         // then the end Stripe,
698         // -------------------------
699         st2->SetCurve(Icl,isfirst2);
700         st2->SetIndexPoint(Il1,isfirst2,IFaCo2);
701         st2->SetIndexPoint(Il2,isfirst2,IFaArc2);
702         st2->SetParameters(isfirst2,P1fin,P2fin);
703         sd2->ChangeVertex(isfirst2,IFaCo2) = Pl1;
704         sd2->ChangeVertex(isfirst2,IFaArc2) = Pl2;
705         sd2->ChangeInterference(IFaCo2).SetParameter(par2,isfirst2);
706         if (IFaCo2 == 2) st2->SetOrientation(TopAbs_REVERSED,isfirst2);
707       }
708 #ifdef OCCT_DEBUG
709       ChFi3d_ResultChron(ch , t_t2cornerDS);// result perf update DS 
710 #endif 
711     }
712     else {
713       //it is necessary to make difference with
714       if(!OkinterCC) {
715         Standard_Failure::Raise("TwoCorner : No intersection pc pc");
716       }
717       Handle(ChFiDS_Stripe) stsam, stdif;
718       Handle(ChFiDS_SurfData) sdsam, sddif;
719       Standard_Real uintpcsam = 0., uintpcdif = 0.;
720       Standard_Integer ifacosam = 0, ifacodif = 0, ifaopsam = 0, ifaopdif = 0;
721       Standard_Boolean isfirstsam = Standard_False, isfirstdif = Standard_False;
722       if(Stat1 == ChFiDS_OnSame && Stat2 == ChFiDS_OnDiff){
723         stsam = st1; sdsam = sd1; uintpcsam = UIntPC1; 
724         ifacosam = IFaCo1; ifaopsam = IFaArc1; isfirstsam = isfirst1;
725         stdif = st2; sddif = sd2; uintpcdif = UIntPC2; 
726         ifacodif = IFaCo2; ifaopdif = IFaArc2; isfirstdif = isfirst2;
727       }
728       else if(Stat1 == ChFiDS_OnDiff && Stat2 == ChFiDS_OnSame){
729         stsam = st2; sdsam = sd2; uintpcsam = UIntPC2; 
730         ifacosam = IFaCo2; ifaopsam = IFaArc2; isfirstsam = isfirst2;
731         stdif = st1; sddif = sd1; uintpcdif = UIntPC1; 
732         ifacodif = IFaCo1; ifaopdif = IFaArc1; isfirstdif = isfirst1;
733       }
734       else {
735         Standard_Failure::Raise("TwoCorner : Config unknown");
736       }
737       //It is checked if surface ondiff has a point on arc from the side opposed
738       //to the common face and if this arc is connected to the base face  
739       //opposed to common face of the surface onsame.
740       ChFiDS_CommonPoint& cpopdif = sddif->ChangeVertex(isfirstdif,ifaopdif);
741       if(!cpopdif.IsOnArc()) {
742         Standard_Failure::Raise
743           ("TwoCorner : No point on restriction on surface OnDiff");
744       }
745       const TopoDS_Edge& Arcopdif = cpopdif.Arc();
746       const TopoDS_Face& Fopsam = TopoDS::Face(DStr.Shape(sdsam->Index(ifaopsam)));
747       TopExp_Explorer ex;
748       for(ex.Init(Fopsam,TopAbs_EDGE); ex.More(); ex.Next()){
749         if(ex.Current().IsSame(Arcopdif)) {
750           break;
751         }
752         else if(!ex.More()) {
753           Standard_Failure::Raise
754             ("TwoCorner : No common face to loop the contour");
755         }
756       }
757 #ifdef OCCT_DEBUG
758       ChFi3d_InitChron(ch ); // init perf filling 
759 #endif 
760       Handle(GeomFill_Boundary) Bsam,Bdif,Bfac;
761       gp_Pnt2d ppopsam = 
762         sdsam->Interference(ifaopsam).PCurveOnSurf()->Value(uintpcsam);
763       gp_Pnt2d ppcosam = 
764         sdsam->Interference(ifacosam).PCurveOnSurf()->Value(uintpcsam);
765       Handle(Geom_Surface) surfsam = DStr.Surface(sdsam->Surf()).Surface();
766       Handle(GeomAdaptor_HSurface) Hsurfsam = new GeomAdaptor_HSurface(surfsam);
767       Handle(Geom2d_Curve) pcsurfsam;
768       Bsam = ChFi3d_mkbound(Hsurfsam,pcsurfsam,ppopsam,ppcosam,tolesp,2.e-4);
769       Standard_Real upcopdif = sddif->Interference(ifaopdif).Parameter(isfirstdif);
770       gp_Pnt2d ppopdif = 
771         sddif->Interference(ifaopdif).PCurveOnSurf()->Value(upcopdif);
772       gp_Pnt2d ppcodif = 
773         sddif->Interference(ifacodif).PCurveOnSurf()->Value(uintpcdif);
774       Handle(Geom_Surface) surfdif = DStr.Surface(sddif->Surf()).Surface();
775       Handle(GeomAdaptor_HSurface) Hsurfdif = new GeomAdaptor_HSurface(surfdif);
776       Handle(Geom2d_Curve) pcsurfdif;
777       Bdif = ChFi3d_mkbound(Hsurfdif,pcsurfdif,ppcodif,ppopdif,tolesp,2.e-4);
778       gp_Pnt2d ppfacsam,ppfacdif;
779       gp_Pnt PPfacsam,PPfacdif;
780       gp_Vec VVfacsam,VVfacdif;
781       sdsam->Interference(ifaopsam).PCurveOnFace()->D0(uintpcsam,ppfacsam);
782       const Handle(Geom_Curve)& curvopsam = 
783         DStr.Curve(sdsam->Interference(ifaopsam).LineIndex()).Curve();
784       curvopsam->D1(uintpcsam,PPfacsam,VVfacsam);
785       BRepAdaptor_Curve2d PCArcFac(Arcopdif,Fopsam);
786       PCArcFac.D0(cpopdif.ParameterOnArc(),ppfacdif);
787       //jgv for OCC26173
788       BRepAdaptor_Surface SurFopsam(Fopsam);
789       if (SurFopsam.IsUClosed())
790       {
791         Standard_Real Uperiod = SurFopsam.LastUParameter() - SurFopsam.FirstUParameter();
792         if (Abs(ppfacsam.X() - ppfacdif.X()) > Uperiod/2)
793         {
794           if (ppfacdif.X() < ppfacsam.X())
795             ppfacdif.SetX(ppfacdif.X() + Uperiod);
796           else
797             ppfacdif.SetX(ppfacdif.X() - Uperiod);
798         }
799       }
800       //////////////////
801       BRepAdaptor_Curve CArcFac(Arcopdif);
802       CArcFac.D1(cpopdif.ParameterOnArc(),PPfacdif,VVfacdif);
803       Handle(BRepAdaptor_HSurface) HBRFopsam = new BRepAdaptor_HSurface();
804       BRepAdaptor_Surface& BRFopsam = HBRFopsam->ChangeSurface();
805       BRFopsam.Initialize(Fopsam,Standard_False);
806       Handle(Geom2d_Curve) pcFopsam = ChFi3d_BuildPCurve(HBRFopsam,
807                                                          ppfacsam,VVfacsam,
808                                                          ppfacdif,VVfacdif,1);
809       Bfac = ChFi3d_mkbound(HBRFopsam,pcFopsam,tolesp,2.e-4);
810       GeomFill_ConstrainedFilling fil(8,20);
811       fil.Init(Bsam,Bdif,Bfac,1);
812 #if 0
813       for(Standard_Integer ib = 0; ib < 4; ib++){
814         if(ib == 2) continue;
815         fil.CheckCoonsAlgPatch(ib);
816         fil.CheckTgteField(ib);
817         fil.CheckApprox(ib);
818         fil.CheckResult(ib);
819       }
820 #endif
821       Handle(Geom_Surface) Surfcoin = fil.Surface();
822       TopAbs_Orientation Osurfsam = sdsam->Orientation();
823       Handle(Geom2d_Curve) pcnul;
824       done = CompleteData(coin,Surfcoin,
825                           Hsurfsam,pcsurfsam,
826                           HBRFopsam,pcnul,Osurfsam,1,
827                           0,0,0,0);
828 #ifdef OCCT_DEBUG
829       ChFi3d_ResultChron(ch , t_remplissage);// result perf filling 
830 #endif 
831       if(!done) Standard_Failure::Raise("concavites inverted : fail");
832 #ifdef OCCT_DEBUG
833       ChFi3d_InitChron(ch); // init perf update DS
834 #endif 
835       // Update 3 CornerData and the DS
836       // ----------------------------------------
837       // the corner to start,
838       // -----------------------
839       Standard_Real P1deb,P2deb,P1fin,P2fin;
840       Standard_Integer If1,If2,Il1,Il2,Icf,Icl;
841       const ChFiDS_CommonPoint& Pf1 = coin->VertexFirstOnS1();
842       ChFiDS_CommonPoint& Pf2 = coin->ChangeVertexFirstOnS2();
843       const ChFiDS_CommonPoint& Pl1 = coin->VertexLastOnS1();
844       ChFiDS_CommonPoint& Pl2 = coin->ChangeVertexLastOnS2();
845       Pf2 = Pl2 = cpopdif;
846         
847       ChFiDS_Regul regdeb, regfin;
848       If1 = ChFi3d_IndexPointInDS(Pf1,DStr);
849       If2 = ChFi3d_IndexPointInDS(Pf2,DStr);
850       Il1 = ChFi3d_IndexPointInDS(Pl1,DStr);
851       Il2 = If2;
852         
853       gp_Pnt2d pp1,pp2;
854       pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
855         Value(coin->InterferenceOnS1().FirstParameter());
856       pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
857         Value(coin->InterferenceOnS2().FirstParameter());
858       Handle(Geom_Curve) C3d;
859       Standard_Real tolreached;
860       ChFi3d_ComputeArete(Pf1,pp1,Pf2,pp2,
861                           DStr.Surface(coin->Surf()).Surface(),C3d,
862                           corner->ChangeFirstPCurve(),P1deb,P2deb,
863                           tolesp,tol2d,tolreached,0);
864       Standard_Real tolr1;
865       Handle(GeomAdaptor_HCurve) HC3d = new GeomAdaptor_HCurve(C3d);
866       ChFi3d_SameParameter(HC3d,pcFopsam,HBRFopsam,tolesp,tolr1);
867       tolreached = Max(tolreached,tolr1);
868       TopOpeBRepDS_Curve Tcurv1(C3d,tolreached);
869       Icf = DStr.AddCurve(Tcurv1);
870       // place the pcurve on face in the DS
871       TopAbs_Orientation OpcFopsam = sdsam->Interference(ifaopsam).Transition();
872       Standard_Integer IFopsam = sdsam->Index(ifaopsam);
873       if(isfirstsam) OpcFopsam = TopAbs::Reverse(OpcFopsam);
874       Handle(TopOpeBRepDS_SurfaceCurveInterference) 
875         interf = ChFi3d_FilCurveInDS(Icf,IFopsam,pcFopsam,OpcFopsam);
876       DStr.ChangeShapeInterferences(IFopsam).Append(interf);
877
878       regdeb.SetCurve(Icf);
879       regdeb.SetS1(coin->Surf(),0);
880       regdeb.SetS2(IFopsam,1);
881       myRegul.Append(regdeb);
882       corner->ChangeFirstCurve(Icf);
883       corner->ChangeFirstParameters(P1deb,P2deb);
884       corner->ChangeIndexFirstPointOnS1(If1);
885       corner->ChangeIndexFirstPointOnS2(If2);
886       
887       pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
888         Value(coin->InterferenceOnS1().LastParameter());
889       pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
890         Value(coin->InterferenceOnS2().LastParameter());
891       ChFi3d_ComputeArete(Pl1,pp1,Pl2,pp2,
892                           DStr.Surface(coin->Surf()).Surface(),C3d,
893                           corner->ChangeLastPCurve(),P1fin,P2fin,
894                           tolesp,tol2d,tolreached,0);
895       Standard_Real tolr2;
896       HC3d->ChangeCurve().Load(C3d);
897       ChFi3d_SameParameter(HC3d,pcsurfdif,Hsurfdif,tolesp,tolr2);
898       tolreached = Max(tolreached,tolr2);
899       TopOpeBRepDS_Curve Tcurv2(C3d,tolreached);
900       Icl = DStr.AddCurve(Tcurv2);
901       regfin.SetCurve(Icl);
902       regfin.SetS1(coin->Surf(),0);
903       regfin.SetS2(sddif->Surf(),0);
904       myRegul.Append(regfin);
905       corner->ChangeLastCurve(Icl);
906       corner->ChangeLastParameters(P1fin,P2fin);
907       corner->ChangeIndexLastPointOnS1(Il1);
908       corner->ChangeIndexLastPointOnS2(Il2);
909         
910       coin->ChangeIndexOfS1(-sdsam->Surf());
911       coin->ChangeIndexOfS2(0);
912
913       corner->SetSolidIndex(stsam->SolidIndex());
914         
915       // then Stripe OnSame
916       // ---------------------
917       const ChFiDS_FaceInterference& intcoin1 = coin->InterferenceOnS1();
918       stsam->SetCurve(intcoin1.LineIndex(),isfirstsam);
919       stsam->InDS(isfirstsam); // filDS already works from the corner.
920       stsam->ChangePCurve(isfirstsam) = coin->InterferenceOnS1().PCurveOnFace();
921       stsam->SetIndexPoint(If1,isfirstsam,ifaopsam);
922       stsam->SetIndexPoint(Il1,isfirstsam,ifacosam);
923       stsam->SetParameters(isfirstsam,
924                            intcoin1.FirstParameter(),
925                            intcoin1.LastParameter());
926       sdsam->ChangeVertex(isfirstsam,ifaopsam) = Pf1;
927       sdsam->ChangeVertex(isfirstsam,ifacosam) = Pl1;
928       sdsam->ChangeInterferenceOnS1().SetParameter(uintpcsam,isfirstsam);
929       sdsam->ChangeInterferenceOnS2().SetParameter(uintpcsam,isfirstsam);
930       if (ifaopsam == 2) stsam->SetOrientation(TopAbs_REVERSED,isfirstsam);
931         
932       // then Stripe OnDiff
933       // ---------------------
934       stdif->SetCurve(Icl,isfirstdif);
935       stdif->ChangePCurve(isfirstdif) = pcsurfdif;
936       stdif->SetIndexPoint(Il2,isfirstdif,ifaopdif);
937       stdif->SetIndexPoint(Il1,isfirstdif,ifacodif);
938       stdif->SetParameters(isfirstdif,P1fin,P2fin);
939       sddif->ChangeVertex(isfirstdif,ifaopdif) = Pl2;
940       sddif->ChangeVertex(isfirstdif,ifacodif) = Pl1;
941       sddif->ChangeInterference(ifacodif).SetParameter(uintpcdif,isfirstdif);
942       if (ifaopdif == 1) stdif->SetOrientation(TopAbs_REVERSED,isfirstdif);
943 #ifdef OCCT_DEBUG
944       ChFi3d_ResultChron(ch , t_t2cornerDS);// result perf update DS 
945 #endif 
946     }
947     if(!myEVIMap.IsBound(Vtx)){
948       TColStd_ListOfInteger li;
949       myEVIMap.Bind(Vtx,li);
950     }
951     myEVIMap.ChangeFind(Vtx).Append(coin->Surf());
952     myListStripe.Append(corner);
953   }
954 }  
955