1 // Created on: 1995-04-26
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor3d_CurveOnSurface.hxx>
19 #include <Adaptor3d_HSurface.hxx>
20 #include <Adaptor3d_TopolTool.hxx>
21 #include <BRepAdaptor_Curve.hxx>
22 #include <BRepAdaptor_HCurve.hxx>
23 #include <BRepAdaptor_HCurve2d.hxx>
24 #include <BRepAdaptor_HSurface.hxx>
25 #include <BRepAdaptor_Surface.hxx>
26 #include <BRepBlend_ConstRad.hxx>
27 #include <BRepBlend_ConstRadInv.hxx>
28 #include <BRepBlend_EvolRad.hxx>
29 #include <BRepBlend_EvolRadInv.hxx>
30 #include <BRepBlend_Line.hxx>
31 #include <BRepTopAdaptor_TopolTool.hxx>
33 #include <ChFi3d_Builder_0.hxx>
34 #include <ChFi3d_FilBuilder.hxx>
35 #include <ChFiDS_CommonPoint.hxx>
36 #include <ChFiDS_FaceInterference.hxx>
37 #include <ChFiDS_HData.hxx>
38 #include <ChFiDS_HElSpine.hxx>
39 #include <ChFiDS_ListIteratorOfListOfStripe.hxx>
40 #include <ChFiDS_Regul.hxx>
41 #include <ChFiDS_SequenceOfSurfData.hxx>
42 #include <ChFiDS_Spine.hxx>
43 #include <ChFiDS_Stripe.hxx>
44 #include <ChFiDS_SurfData.hxx>
45 #include <ChFiKPart_ComputeData.hxx>
48 #include <Geom2d_BezierCurve.hxx>
49 #include <Geom2d_Curve.hxx>
50 #include <Geom2d_Line.hxx>
51 #include <Geom2d_TrimmedCurve.hxx>
52 #include <Geom2dAdaptor_Curve.hxx>
53 #include <Geom2dAdaptor_HCurve.hxx>
54 #include <Geom_BezierCurve.hxx>
55 #include <Geom_BSplineSurface.hxx>
56 #include <Geom_Circle.hxx>
57 #include <Geom_Plane.hxx>
58 #include <GeomAdaptor_Curve.hxx>
59 #include <GeomAdaptor_HCurve.hxx>
60 #include <GeomAdaptor_HSurface.hxx>
61 #include <GeomAdaptor_Surface.hxx>
67 #include <gp_Pnt2d.hxx>
70 #include <IntAna_QuadQuadGeo.hxx>
71 #include <IntCurveSurface_IntersectionPoint.hxx>
72 #include <Law_Function.hxx>
74 #include <math_Vector.hxx>
75 #include <Precision.hxx>
76 #include <Standard_Failure.hxx>
77 #include <Standard_NotImplemented.hxx>
78 #include <TColgp_Array1OfPnt2d.hxx>
79 #include <TColStd_ListOfInteger.hxx>
81 #include <TopAbs_Orientation.hxx>
83 #include <TopoDS_Edge.hxx>
84 #include <TopoDS_Face.hxx>
85 #include <TopoDS_Shape.hxx>
86 #include <TopoDS_Vertex.hxx>
87 #include <TopOpeBRepDS_Curve.hxx>
88 #include <TopOpeBRepDS_DataStructure.hxx>
89 #include <TopOpeBRepDS_HDataStructure.hxx>
90 #include <TopOpeBRepDS_Surface.hxx>
93 #include <DrawTrSurf.hxx>
96 #include <Geom_TrimmedCurve.hxx>
97 extern Standard_Boolean ChFi3d_GettraceDRAWSPINE();
98 extern Standard_Boolean ChFi3d_GetcontextSPINEBEZIER();
99 extern Standard_Boolean ChFi3d_GetcontextSPINECIRCLE();
100 extern Standard_Boolean ChFi3d_GetcontextSPINECE();
101 extern Standard_Boolean ChFi3d_GetcontextFORCEFILLING();
102 #include <OSD_Chronometer.hxx>
104 extern Standard_Real t_t3cornerinit ,t_spherique,t_torique,
105 t_notfilling,t_filling,t_t3cornerDS;
106 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
107 extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
110 //=======================================================================
111 //function : SearchPivot
113 //=======================================================================
114 static Standard_Integer SearchPivot(Standard_Integer* s,
115 Standard_Real u[3][3],
116 const Standard_Real t)
118 Standard_Boolean bondeb,bonfin;
119 for(Standard_Integer i = 0; i <= 2; i++){
120 if(s[(i+1)%3] == 1){bondeb = (u[(i+1)%3][i]-u[(i+1)%3][(i+2)%3] >= -t);}
121 else {bondeb = (u[(i+1)%3][i]-u[(i+1)%3][(i+2)%3] <= t);}
122 if(s[(i+2)%3] == 1){bonfin = (u[(i+2)%3][i]-u[(i+2)%3][(i+1)%3] >= -t);}
123 else {bonfin = (u[(i+2)%3][i]-u[(i+2)%3][(i+1)%3] <= t);}
124 if (bondeb && bonfin){ return i; }
130 //=======================================================================
131 //function : SearchFD
133 //=======================================================================
134 static Standard_Boolean SearchFD(TopOpeBRepDS_DataStructure& DStr,
135 const Handle(ChFiDS_Stripe)& cd1,
136 const Handle(ChFiDS_Stripe)& cd2,
137 const Standard_Integer sens1,
138 const Standard_Integer sens2,
139 Standard_Integer& i1,
140 Standard_Integer& i2,
143 const Standard_Integer ind1,
144 const Standard_Integer ind2,
146 Standard_Boolean& sameside,
147 Standard_Integer& jf1,
148 Standard_Integer& jf2)
150 Standard_Boolean found = Standard_False;
151 Standard_Integer id1 = ind1, id2 = ind2;
152 Standard_Integer if1 = ind1, if2 = ind2;
153 Standard_Integer l1 = cd1->SetOfSurfData()->Length();
154 Standard_Integer l2 = cd2->SetOfSurfData()->Length();
156 Standard_Boolean fini1 = Standard_False, fini2 = Standard_False;
157 Standard_Boolean visavis;
160 for(i = id1; (i*sens1) <= (if1*sens1) && !found && !fini2; i = i+sens1 ){
161 if(ChFi3d_IsInFront(DStr,cd1,cd2,i,if2,sens1,sens2,p1,p2,face,sameside,jf1,jf2,visavis,Vtx,Standard_False,0)){
164 found = Standard_True;
169 if(if1 < 1 || if1 > l1){ if1 = if1 - sens1; fini1 = Standard_True; }
172 for(i = id2; (i*sens2) <= (if2*sens2) && !found && !fini1; i = i+sens2 ){
173 if(ChFi3d_IsInFront(DStr,cd1,cd2,if1,i,sens1,sens2,p1,p2,face,sameside,jf1,jf2,visavis,Vtx,Standard_False,0)){
176 found = Standard_True;
181 if(if2 < 1 || if2 > l2){ if2 = if2 - sens2; fini2 = Standard_True; }
183 if(fini1 && fini2) break;
189 //=======================================================================
190 //function : ToricCorner
191 //purpose : Test if this is a paricular cas of a torus corner
192 // (or spherical limited by isos).
193 //=======================================================================
195 static Standard_Boolean ToricCorner(const TopoDS_Face& F,
196 const Standard_Real rd,
197 const Standard_Real rf,
200 if(Abs(rd-rf) > Precision::Confusion()){ return Standard_False; }
201 BRepAdaptor_Surface bs(F);
202 if(bs.GetType() != GeomAbs_Plane){ return Standard_False; }
203 Standard_Real scal1 = Abs(bs.Plane().Position().XDirection().Dot(v));
204 Standard_Real scal2 = Abs(bs.Plane().Position().YDirection().Dot(v));
205 return (scal1 <= Precision::Confusion() &&
206 scal2 <= Precision::Confusion());
209 //=======================================================================
210 //function : PerformThreeCorner
211 //purpose : Calculate fillet on a top with three edges
212 // incident carrying each edge.
213 //=======================================================================
215 void ChFi3d_FilBuilder::PerformThreeCorner(const Standard_Integer Jndex)
220 ChFi3d_InitChron(ch); // init perf initialisation
223 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
224 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Jndex);
225 ChFiDS_ListIteratorOfListOfStripe It;
226 Standard_Integer Index[3],pivot,deb,fin,ii,jj,kk;
227 //Standard_Real R = 0.;
228 Standard_Boolean pivdif = Standard_True;
229 Standard_Boolean c1pointu = Standard_False;
230 Standard_Boolean c1toric = Standard_False;
231 Standard_Boolean c1spheric = Standard_False;
232 Handle(ChFiDS_Stripe) CD[3];
234 Standard_Integer jf[3][3];
235 Standard_Boolean sameside[3], oksea[3];
236 for(Standard_Integer g = 0; g <= 2; g++){oksea[g] = Standard_False;}
237 Standard_Integer i[3][3];
238 Standard_Integer sens[3];
239 Standard_Real p[3][3];
241 Standard_Boolean filling = 0;
243 for (It.Initialize(myVDataMap(Jndex)),ii=0;It.More() && ii<3;It.Next(),ii++){
244 Index[ii] = ChFi3d_IndexOfSurfData(Vtx,It.Value(),sens[ii]);
247 // It is checked if one of CD is not present twice in which
248 // case it is necessary to modify the return of IndexOfSurfData
249 // that takes the first solution.
251 Index[1] = CD[1]->SetOfSurfData()->Length();
254 else if(CD[1] == CD[2]){
255 Index[2] = CD[2]->SetOfSurfData()->Length();
258 else if(CD[0] == CD[2]){
259 Index[2] = CD[2]->SetOfSurfData()->Length();
262 oksea[2] = SearchFD(DStr,CD[0],CD[1],sens[0],sens[1],i[0][1],i[1][0],
263 p[0][1],p[1][0],Index[0],Index[1],face[2],sameside[2],
265 oksea[1] = SearchFD(DStr,CD[0],CD[2],sens[0],sens[2],i[0][2],i[2][0],
266 p[0][2],p[2][0],Index[0],Index[2],face[1],sameside[1],
268 oksea[0] = SearchFD(DStr,CD[1],CD[2],sens[1],sens[2],i[1][2],i[2][1],
269 p[1][2],p[2][1],Index[1],Index[2],face[0],sameside[0],
272 // Analyze concavities of 3 fillets :
273 // - 2 concavities identic and 1 inverted.
274 // - 3 concavities identic
276 if(oksea[2] && oksea[1] && !sameside[2] && !sameside[1])
277 { pivot = 0; deb = 1; fin = 2;}
278 else if(oksea[2] && oksea[0] && !sameside[2] && !sameside[0])
279 { pivot = 1; deb = 2; fin = 0;}
280 else if(oksea[1] && oksea[0] && !sameside[1] && !sameside[0])
281 { pivot = 2; deb = 0; fin = 1;}
282 else if(oksea[0] && oksea[1] && oksea[2]){
283 // 3 concavities identic.
284 pivot = SearchPivot(sens,p,tol2d);
287 cout<<"pivot not found, plate is called"<<endl;
289 PerformMoreThreeCorner(Jndex, 3);
292 else{deb = (pivot+1)%3 ; fin = (pivot+2)%3;}
293 pivdif = Standard_False;
294 if(Abs(p[0][1]-p[0][2]) <= tol2d &&
295 Abs(p[1][0]-p[1][2]) <= tol2d &&
296 Abs(p[2][0]-p[2][1]) <= tol2d){
297 c1pointu = Standard_True;
301 PerformMoreThreeCorner(Jndex, 3);
304 Standard_Integer ifacdeb, ifacfin;
305 ifacdeb = CD[deb]->ChangeSetOfSurfData()->Value(i[deb][pivot])->Index(3-jf[deb][pivot]);
306 ifacfin = CD[fin]->ChangeSetOfSurfData()->Value(i[fin][pivot])->Index(3-jf[fin][pivot]);
307 if(ifacfin != ifacdeb){
309 cout<<"several base faces, plate is called"<<endl;
311 PerformMoreThreeCorner(Jndex, 3);
314 if(i[pivot][deb] != i[pivot][fin]){
316 cout<<"load surfdata on the pivot, plate is called"<<endl;
318 PerformMoreThreeCorner(Jndex, 3);
322 Standard_Real Rdeb,Rfin,Rdp,Rfp;
323 gp_Pnt Pdeb,Pfin,Pdp,Pfp;
324 gp_Vec Vdeb,Vfin,Vdp,Vfp;
329 for(ii = 0; ii<=2; ii++){
330 jj = (ii+1)%3 ; kk = (ii+2)%3;
331 ChFi3d_ExtrSpineCarac(DStr,CD[jj],i[jj][ii],p[jj][ii],1,
332 sens[jj],pbid,qv[jj],qr[jj]);
334 for(ii = 0; ii<=2 && !c1toric; ii++){
335 jj = (ii+1)%3 ; kk = (ii+2)%3;
336 if(ToricCorner(face[ii],qr[jj],qr[kk],qv[ii])){
337 c1toric = Standard_True;
338 pivot = ii; deb = jj; fin = kk;
341 if(!c1toric)c1spheric=(Abs(qr[0]-qr[1])<tolesp && Abs(qr[0]-qr[2])<tolesp);
344 // Previously to avoid loops the points were always located
345 // inside, which could impede the construction of the
346 // guideline of the corner which now is a circle.
347 // Standard_Integer jjjd = jf[deb][fin], jjjf = jf[fin][deb];
348 // if (pivdif) jjjd = jf[deb][pivot], jjjf = jf[fin][pivot];
349 Standard_Integer jjjd = jf[deb][pivot], jjjf = jf[fin][pivot];
350 ChFi3d_ExtrSpineCarac(DStr,CD[deb],i[deb][pivot],p[deb][pivot],
351 jjjd,sens[deb],Pdeb,Vdeb,Rdeb);
352 ChFi3d_ExtrSpineCarac(DStr,CD[fin],i[fin][pivot],p[fin][pivot],
353 jjjf,sens[fin],Pfin,Vfin,Rfin);
354 ChFi3d_ExtrSpineCarac(DStr,CD[pivot],i[pivot][deb],p[pivot][deb],
355 0,sens[pivot],Pdp,Vdp,Rdp);
356 ChFi3d_ExtrSpineCarac(DStr,CD[pivot],i[pivot][fin],p[pivot][fin],
357 0,sens[pivot],Pfp,Vfp,Rfp);
358 //in cas of allsame it is checked that points on the face are not
359 //too close, which can stop the work.
361 gp_Pnt ptestdeb,ptestfin; gp_Vec bidvec; Standard_Real bidr;
362 ChFi3d_ExtrSpineCarac(DStr,CD[deb],i[deb][pivot],p[deb][pivot],
363 jf[deb][fin],sens[deb],ptestdeb,bidvec,bidr);
364 ChFi3d_ExtrSpineCarac(DStr,CD[fin],i[fin][pivot],p[fin][pivot],
365 jf[fin][deb],sens[fin],ptestfin,bidvec,bidr);
366 Standard_Real distest = ptestdeb.Distance(ptestfin);
367 if(distest < (Rdp+Rfp)*0.05) filling = 1;
368 if(distest < (Rdp+Rfp)*0.005) c1pointu = 1;
372 if (!pivdif) c1pointu = (Abs(p[deb][pivot]-p[deb][fin]) <=tol2d &&
373 Abs(p[fin][pivot]-p[fin][deb]) <=tol2d);
374 if(Abs(p[pivot][deb] - p[pivot][fin]) <= tol2d)
375 c1toric = ToricCorner(face[pivot],Rdeb,Rfin,Vdp);
377 // there is a pivot, the start and the end CD (finally !?!) :
378 // -------------------------------------------------------------
379 // the criterions determining if the corner is a torus or a sphere
380 // are based only on the configuration of sections at end and the
381 // nature of faces, it is necessary to make tests to
382 // determine if a more detailed analysis of incident fillets
383 // is necessare to provide tangency between them and
384 // the corner (in particular in the case with variable radius).
388 Handle(ChFiDS_SurfData)&
389 fddeb = CD[deb]->ChangeSetOfSurfData()->ChangeValue(i[deb][pivot]);
390 Handle(ChFiDS_SurfData)&
391 fdfin = CD[fin]->ChangeSetOfSurfData()->ChangeValue(i[fin][pivot]);
392 Handle(ChFiDS_SurfData)&
393 fdpiv = CD[pivot]->ChangeSetOfSurfData()->ChangeValue(i[pivot][deb]);
396 // HSurfaces and other suitable tools are constructed.
397 // ----------------------------------------------------------
399 TopAbs_Orientation OFac = face[pivot].Orientation();
400 Handle(BRepAdaptor_HSurface) Fac = new BRepAdaptor_HSurface(face[pivot]);
402 const ChFiDS_FaceInterference& bid1 = CD[pivot]->SetOfSurfData()->
403 Value(i[pivot][deb])->InterferenceOnS1();
404 ppp1 = bid1.PCurveOnSurf()->Value(bid1.FirstParameter());
405 const ChFiDS_FaceInterference& bid2 = CD[pivot]->SetOfSurfData()->
406 Value(i[pivot][deb])->InterferenceOnS2();
407 ppp2 = bid2.PCurveOnSurf()->Value(bid2.LastParameter());
408 Standard_Real uu1 = ppp1.X(), uu2 = ppp2.X(), vv1 = ppp1.Y(), vv2 = ppp2.Y();
410 gasurf((DStr.Surface(CD[pivot]->SetOfSurfData()->
411 Value(i[pivot][deb])->Surf())).Surface(),
413 GeomAbs_SurfaceType styp = gasurf.GetType();
414 if(styp == GeomAbs_Cylinder){
415 Standard_Real h = vv2 - vv1;
418 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
419 Value(i[pivot][deb])->Surf())).Surface(),
422 else if(styp == GeomAbs_Torus){
423 Standard_Real h = uu2 - uu1;
426 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
427 Value(i[pivot][deb])->Surf())).Surface(),
430 else if(styp == GeomAbs_BezierSurface || styp == GeomAbs_BSplineSurface){
431 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
432 Value(i[pivot][deb])->Surf())).Surface());
435 Handle(GeomAdaptor_HSurface) Surf = new GeomAdaptor_HSurface(gasurf);
436 // Handle(BRepTopAdaptor_TopolTool) IFac = new BRepTopAdaptor_TopolTool(Fac);
437 // Try to not classify on the face for cases of reentering fillets which naturally depass
439 Handle(GeomAdaptor_HSurface)
440 bidsurf = new GeomAdaptor_HSurface(Fac->ChangeSurface().Surface());
441 Handle(Adaptor3d_TopolTool)
442 IFac = new Adaptor3d_TopolTool(bidsurf);
443 // end of the attempt.
444 Handle(Adaptor3d_TopolTool) ISurf = new Adaptor3d_TopolTool(Surf);
445 Handle(ChFiDS_Stripe) corner = new ChFiDS_Stripe();
446 Handle(ChFiDS_HData)& cornerset = corner->ChangeSetOfSurfData();
447 cornerset = new ChFiDS_HData();
448 Handle(ChFiDS_SurfData) coin = new ChFiDS_SurfData();
449 cornerset->Append(coin);
450 TopAbs_Orientation o1,o2,os1,os2,oo1,oo2;
451 Standard_Integer choix = CD[deb]->Choix();
452 o1 = face[pivot].Orientation();
453 o2 = fdpiv->Orientation();
455 os1 = CD[deb]->OrientationOnFace1();
456 os2 = CD[deb]->OrientationOnFace2();
457 if(jf[deb][fin] == 1){
458 choix = ChFi3d::NextSide(o1,o2,os1,os2,choix);
460 if(choix%2 == 1) choix++;
465 choix = ChFi3d::NextSide(o2,o1,os1,os2,-choix);
467 if(choix%2 == 1) choix++;
472 gp_Pnt2d pfac1,pfac2,psurf1,psurf2;
473 gp_Vec2d vfac1,vfac2;
474 CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
475 Interference(jf[deb][fin]).PCurveOnFace()->D1(p[deb][pivot],pfac1,vfac1);
476 CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
477 Interference(jf[fin][deb]).PCurveOnFace()->D1(p[fin][pivot],pfac2,vfac2);
478 psurf1 = CD[pivot]->SetOfSurfData()->Value(i[pivot][deb])->
479 Interference(jf[pivot][deb]).PCurveOnSurf()->Value(p[pivot][deb]);
480 psurf2 = CD[pivot]->SetOfSurfData()->Value(i[pivot][fin])->
481 Interference(jf[pivot][fin]).PCurveOnSurf()->Value(p[pivot][fin]);
483 done = Standard_False;
485 if(ChFi3d_GetcontextFORCEFILLING()) c1spheric = c1toric = 0;
489 ChFi3d_ResultChron(ch , t_t3cornerinit); // result perf initialisations
495 ChFi3d_InitChron(ch); // init perf case torus
498 // Direct Construction.
499 // ---------------------
500 done = ChFiKPart_ComputeData::ComputeCorner
501 (DStr,coin,Fac,Surf,oo1,oo2,o1,o2,Rdeb,Rdp,pfac1,pfac2,psurf1,psurf2);
504 ChFi3d_ResultChron(ch , t_torique); // result perf case torus
511 ChFi3d_InitChron(ch); //init perf case sphere
514 done = ChFiKPart_ComputeData::ComputeCorner
515 (DStr,coin,Fac,Surf,oo1,oo2,o1,o2,Rdp,pfac1,psurf1,psurf2);
518 ChFi3d_ResultChron(ch , t_spherique);// result perf cas sphere
529 ChFi3d_InitChron(ch);// init perf not filling
532 //Calculate a guideline,
533 //------------------------------
534 //Numerous problems with loops and half-turns connected to
535 //the curvature of the guideline !!!!!!
537 //If the nature of guideline is changed it is necessary to
538 //reset points Pdeb and Pfin at the inside (see the
539 //comments about it in the calculation of Pdeb and Pfin).
541 Standard_Real radpondere = (Rdp+Rfp)/2.;
542 Standard_Real locfleche = fleche;
544 Standard_Real WFirst,WLast;
545 Handle(Geom_Curve) spinecoin = ChFi3d_CircularSpine(WFirst,WLast,
547 Pfin,Vfin,radpondere);
548 if(spinecoin.IsNull()){
549 // This is a bad case when the intersection of
550 // section planes is done out of the sector.
551 spinecoin = ChFi3d_Spine(Pdeb,Vdeb,
552 Pfin,Vfin,radpondere);
553 WFirst = 0.; WLast = 1.;
555 else locfleche = radpondere * (WLast - WFirst) * fleche;
556 Standard_Real pasmax = (WLast-WFirst)*0.05;
557 Handle(ChFiDS_HElSpine) cornerspine = new ChFiDS_HElSpine();
558 cornerspine->ChangeCurve().SetCurve(spinecoin);
559 cornerspine->ChangeCurve().FirstParameter(WFirst - pasmax);
560 cornerspine->ChangeCurve().LastParameter(WLast + pasmax);
561 // Just to confuse Compute that should not require this
562 // in this exact case ...
563 Handle(ChFiDS_Spine) NullSpine;
564 // The fillet is calculated - from beginning to end
565 // - from the face to the surface
567 math_Vector Soldep(1,4);
568 Soldep(1) = pfac1.X();
569 Soldep(2) = pfac1.Y();
570 Soldep(3) = psurf1.X();
571 Soldep(4) = psurf1.Y();
573 Standard_Boolean Gd1,Gd2,Gf1,Gf2;
574 Handle(BRepBlend_Line) lin;
575 Standard_Real ffi = WFirst, lla = WLast + pasmax;
577 if (Abs(Rdeb-Rfin)<=tolesp){
579 BRepBlend_ConstRad func(Fac,Surf,cornerspine);
580 BRepBlend_ConstRadInv finv(Fac,Surf,cornerspine);
581 func.Set(Rdeb,choix);
583 finv.Set(Rdeb,choix);
584 Standard_Real TolGuide = cornerspine->Resolution(tolesp);
586 Standard_Integer intf = 3, intl = 3;
587 done = ComputeData(coin,cornerspine,NullSpine,lin,Fac,IFac,Surf,ISurf,
588 func,finv,ffi,pasmax,locfleche,TolGuide,ffi,lla,
589 0,0,1,Soldep,intf,intl,Gd1,Gd2,Gf1,Gf2,0,1);
591 if(ChFi3d_GetcontextFORCEFILLING()) done = 0;
594 done = CompleteData(coin,func,lin,Fac,Surf,OFac,Gd1,0,Gf1,0);
600 Handle(Law_S) law = new Law_S();
601 law->Set(WFirst,Rdeb,WLast,Rfin);
602 BRepBlend_EvolRad func(Fac,Surf,cornerspine,law);
603 BRepBlend_EvolRadInv finv(Fac,Surf,cornerspine,law);
607 Standard_Real TolGuide = cornerspine->Resolution(tolesp);
608 Standard_Integer intf = 3, intl = 3;
609 done = ComputeData(coin,cornerspine,NullSpine,lin,Fac,IFac,Surf,ISurf,
610 func,finv,ffi,pasmax,locfleche,TolGuide,ffi,lla,
611 0,0,1,Soldep,intf,intl,Gd1,Gd2,Gf1,Gf2,0,1);
613 if(ChFi3d_GetcontextFORCEFILLING()) done = 0;
616 done = CompleteData(coin,func,lin,Fac,Surf,OFac,Gd1,0,Gf1,0);
623 ChFi3d_ResultChron(ch , t_notfilling);// result perf not filling
631 ChFi3d_InitChron(ch); // init perf filling
634 // the contour to be fillet consists of straight lines uv in beginning and end
635 // of two pcurves (only one if c1pointu) calculted as possible
636 // on piv and the opposite face.
637 Handle(GeomFill_Boundary) Bdeb,Bfin,Bpiv,Bfac;
638 Handle(Geom2d_Curve) PCurveOnFace;
640 Bfac = ChFi3d_mkbound(Fac,PCurveOnFace,sens[deb],pfac1,vfac1,
641 sens[fin],pfac2,vfac2,tolesp,2.e-4);
642 Standard_Integer kkk;
645 kkk = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
646 Interference(jf[deb][pivot]).LineIndex();
647 DStr.Curve(kkk).Curve()->D1(p[deb][pivot],ppbid,vp1);
648 kkk = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
649 Interference(jf[fin][pivot]).LineIndex();
650 DStr.Curve(kkk).Curve()->D1(p[fin][pivot],ppbid,vp2);
651 Handle(Geom2d_Curve) PCurveOnPiv;
652 // Bpiv = ChFi3d_mkbound(Surf,PCurveOnPiv,sens[deb],psurf1,vp1,
653 // sens[fin],psurf2,vp2,tolesp,2.e-4);
654 Bpiv = ChFi3d_mkbound(Surf,PCurveOnPiv,psurf1,psurf2,tolesp,2.e-4,0);
655 Standard_Real pardeb2 = p[deb][pivot];
656 Standard_Real parfin2 = p[fin][pivot];
658 pardeb2 = p[deb][fin];
659 parfin2 = p[fin][deb];
661 gp_Pnt2d pdeb1 = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
662 Interference(jf[deb][pivot]).PCurveOnSurf()->Value(p[deb][pivot]);
663 gp_Pnt2d pdeb2 = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
664 Interference(jf[deb][fin]).PCurveOnSurf()->Value(pardeb2);
665 gp_Pnt2d pfin1 = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
666 Interference(jf[fin][pivot]).PCurveOnSurf()->Value(p[fin][pivot]);
667 gp_Pnt2d pfin2 = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
668 Interference(jf[fin][deb]).PCurveOnSurf()->Value(parfin2);
669 Handle(Geom_Surface) sdeb =
670 DStr.Surface(CD[deb]->SetOfSurfData()->
671 Value(i[deb][pivot])->Surf()).Surface();
672 Handle(Geom_Surface) sfin =
673 DStr.Surface(CD[fin]->SetOfSurfData()->
674 Value(i[fin][pivot])->Surf()).Surface();
676 Bdeb = ChFi3d_mkbound(sdeb,pdeb1,pdeb2,tolesp,2.e-4);
677 Bfin = ChFi3d_mkbound(sfin,pfin1,pfin2,tolesp,2.e-4);
679 GeomFill_ConstrainedFilling fil(11,20);
680 if(c1pointu) fil.Init(Bpiv,Bfin,Bdeb,1);
681 else fil.Init(Bpiv,Bfin,Bfac,Bdeb,1);
683 Handle(Geom_Surface) Surfcoin = fil.Surface();
684 Surfcoin->VReverse(); // revert to direction face surface;
685 done = CompleteData(coin,Surfcoin,
687 Surf,PCurveOnPiv,fdpiv->Orientation(),0,
691 ChFi3d_ResultChron(ch , t_filling);// result perf filling
696 Standard_Real P1deb,P2deb,P1fin,P2fin;
698 p[deb][fin] = p[deb][pivot];
699 p[fin][deb] = p[fin][pivot];
703 // Update of 4 Stripes and the DS
704 // -------------------------------------
707 ChFi3d_InitChron(ch);// init perf update DS
711 Standard_Real parpp1,parpp2;
712 Standard_Integer If1,If2,Il1,Il2,Icf,Icl;
713 const ChFiDS_CommonPoint& Pf1 = coin->VertexFirstOnS1();
714 const ChFiDS_CommonPoint& Pf2 = coin->VertexFirstOnS2();
715 ChFiDS_CommonPoint& Pl1 = coin->ChangeVertexLastOnS1();
716 if(c1pointu) Pl1 = coin->ChangeVertexFirstOnS1();
717 const ChFiDS_CommonPoint& Pl2 = coin->VertexLastOnS2();
719 Bnd_Box bf1,bl1,bf2,bl2;
720 Bnd_Box *pbf1 = &bf1,*pbl1 = &bl1,*pbf2 = &bf2,*pbl2 = &bl2;
721 if(c1pointu) pbl1 = pbf1;
722 pbf1->Add(Pf1.Point());pbf2->Add(Pf2.Point());
723 pbl1->Add(Pl1.Point());pbl2->Add(Pl2.Point());
726 // -----------------------
727 ChFiDS_Regul regdeb, regfin;
728 If1 = ChFi3d_IndexPointInDS(Pf1,DStr);
729 If2 = ChFi3d_IndexPointInDS(Pf2,DStr);
730 if(c1pointu) Il1 = If1;
731 else Il1 = ChFi3d_IndexPointInDS(Pl1,DStr);
732 Il2 = ChFi3d_IndexPointInDS(Pl2,DStr);
733 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
734 Value(coin->InterferenceOnS1().FirstParameter());
735 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
736 Value(coin->InterferenceOnS2().FirstParameter());
737 if(c1pointu) coin->ChangeIndexOfS1(0);
738 else coin->ChangeIndexOfS1(DStr.AddShape(face[pivot]));
739 coin->ChangeIndexOfS2(-fdpiv->Surf());
741 Handle(Geom_Curve) C3d;
742 Standard_Real tolreached;
743 ChFi3d_ComputeArete(Pf1,pp1,Pf2,pp2,
744 DStr.Surface(coin->Surf()).Surface(),C3d,
745 corner->ChangeFirstPCurve(),P1deb,P2deb,
746 tolesp,tol2d,tolreached,0);
747 TopOpeBRepDS_Curve Tcurv1(C3d,tolreached);
748 Icf = DStr.AddCurve(Tcurv1);
749 regdeb.SetCurve(Icf);
750 regdeb.SetS1(coin->Surf(),0);
751 regdeb.SetS2(fddeb->Surf(),0);
752 myRegul.Append(regdeb);
753 corner->ChangeFirstCurve(Icf);
754 corner->ChangeFirstParameters(P1deb,P2deb);
755 corner->ChangeIndexFirstPointOnS1(If1);
756 corner->ChangeIndexFirstPointOnS2(If2);
757 ChFi3d_EnlargeBox(DStr,corner,coin,*pbf1,*pbf2,1);
759 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
760 Value(coin->InterferenceOnS1().LastParameter());
761 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
762 Value(coin->InterferenceOnS2().LastParameter());
763 ChFi3d_ComputeArete(Pl1,pp1,Pl2,pp2,
764 DStr.Surface(coin->Surf()).Surface(),C3d,
765 corner->ChangeLastPCurve(),P1fin,P2fin,
766 tolesp,tol2d,tolreached,0);
767 TopOpeBRepDS_Curve Tcurv2(C3d,tolreached);
768 Icl = DStr.AddCurve(Tcurv2);
769 regfin.SetCurve(Icl);
770 regfin.SetS1(coin->Surf(),0);
771 regfin.SetS2(fdfin->Surf(),0);
772 myRegul.Append(regfin);
773 corner->ChangeLastCurve(Icl);
774 corner->ChangeLastParameters(P1fin,P2fin);
775 corner->ChangeIndexLastPointOnS1(Il1);
776 corner->ChangeIndexLastPointOnS2(Il2);
777 ChFi3d_EnlargeBox(DStr,corner,coin,*pbl1,*pbl2,0);
779 // then CornerData of the beginning,
780 // --------------------------------
781 Standard_Boolean isfirst = (sens[deb] == 1), rev = (jf[deb][fin] == 2);
782 Standard_Integer isurf1 = 1, isurf2 = 2;
783 parpp1 = p[deb][fin]; parpp2 = p[deb][pivot];
785 isurf1 = 2; isurf2 = 1;
786 parpp1 = p[deb][pivot]; parpp2 = p[deb][fin];
787 CD[deb]->SetOrientation(TopAbs_REVERSED,isfirst);
789 pp1 = fddeb->InterferenceOnS1().PCurveOnSurf()->Value(parpp1);
790 pp2 = fddeb->InterferenceOnS2().PCurveOnSurf()->Value(parpp2);
791 CD[deb]->SetCurve(Icf,isfirst);
792 CD[deb]->SetIndexPoint(If1,isfirst,isurf1);
793 CD[deb]->SetIndexPoint(If2,isfirst,isurf2);
794 CD[deb]->SetParameters(isfirst,P1deb,P2deb);
795 fddeb->ChangeVertex(isfirst,isurf1) = Pf1;
796 fddeb->ChangeVertex(isfirst,isurf2) = Pf2;
797 fddeb->ChangeInterferenceOnS1().SetParameter(parpp1,isfirst);
798 fddeb->ChangeInterferenceOnS2().SetParameter(parpp2,isfirst);
799 TopOpeBRepDS_Curve& tcdeb = DStr.ChangeCurve(Icf);
800 Handle(Geom_Curve) crefdeb = tcdeb.Curve();
801 Standard_Real tolrdeb;
802 ChFi3d_ComputePCurv(crefdeb,pp1,pp2,CD[deb]->ChangePCurve(isfirst),
803 DStr.Surface(fddeb->Surf()).Surface(),
804 P1deb,P2deb,tolesp,tolrdeb,rev);
805 tcdeb.Tolerance(Max(tolrdeb,tcdeb.Tolerance()));
806 if(rev) ChFi3d_EnlargeBox(DStr,CD[deb],fddeb,*pbf2,*pbf1,isfirst);
807 else ChFi3d_EnlargeBox(DStr,CD[deb],fddeb,*pbf1,*pbf2,isfirst);
809 // then the end CornerData,
810 // ------------------------
811 isfirst = (sens[fin] == 1); rev = (jf[fin][deb] == 2);
812 isurf1 = 1; isurf2 = 2;
813 parpp1 = p[fin][deb]; parpp2 = p[fin][pivot];
815 isurf1 = 2; isurf2 = 1;
816 parpp1 = p[fin][pivot]; parpp2 = p[fin][deb];
817 CD[fin]->SetOrientation(TopAbs_REVERSED,isfirst);
819 pp1 = fdfin->InterferenceOnS1().PCurveOnSurf()->Value(parpp1);
820 pp2 = fdfin->InterferenceOnS2().PCurveOnSurf()->Value(parpp2);
821 CD[fin]->SetCurve(Icl,isfirst);
822 CD[fin]->SetIndexPoint(Il1,isfirst,isurf1);
823 CD[fin]->SetIndexPoint(Il2,isfirst,isurf2);
824 CD[fin]->SetParameters(isfirst,P1fin,P2fin);
825 fdfin->ChangeVertex(isfirst,isurf1) = Pl1;
826 fdfin->ChangeVertex(isfirst,isurf2) = Pl2;
827 fdfin->ChangeInterferenceOnS1().SetParameter(parpp1,isfirst);
828 fdfin->ChangeInterferenceOnS2().SetParameter(parpp2,isfirst);
829 TopOpeBRepDS_Curve& tcfin = DStr.ChangeCurve(Icl);
830 Handle(Geom_Curve) creffin = tcfin.Curve();
831 Standard_Real tolrfin;
832 ChFi3d_ComputePCurv(creffin,pp1,pp2,CD[fin]->ChangePCurve(isfirst),
833 DStr.Surface(fdfin->Surf()).Surface(),
834 P1fin,P2fin,tolesp,tolrfin,rev);
835 tcfin.Tolerance(Max(tolrfin,tcfin.Tolerance()));
836 if(rev) ChFi3d_EnlargeBox(DStr,CD[fin],fdfin,*pbl2,*pbl1,isfirst);
837 else ChFi3d_EnlargeBox(DStr,CD[fin],fdfin,*pbl1,*pbl2,isfirst);
839 // anf finally the pivot.
840 // ------------------
841 ChFiDS_FaceInterference& fi = coin->ChangeInterferenceOnS2();
842 isfirst = (sens[pivot] == 1); rev = (jf[pivot][deb] == 2);
843 isurf1 = 1; isurf2 = 2;
845 isurf1 = 2; isurf2 = 1;
846 CD[pivot]->SetOrientation(TopAbs_REVERSED,isfirst);
848 Standard_Integer ICcoinpiv = fi.LineIndex();
849 TopOpeBRepDS_Curve& TCcoinpiv = DStr.ChangeCurve(ICcoinpiv);
850 CD[pivot]->SetCurve(ICcoinpiv,isfirst);
851 Handle(Geom_Curve) Ccoinpiv = DStr.Curve(ICcoinpiv).Curve();
852 Handle(Geom2d_Curve)& C2dOnPiv = fi.ChangePCurveOnFace();
853 Handle(Geom_Surface) Spiv = DStr.Surface(fdpiv->Surf()).Surface();
855 ChFi3d_SameParameter(Ccoinpiv,C2dOnPiv,Spiv,
856 fi.FirstParameter(),fi.LastParameter(),
858 TCcoinpiv.Tolerance(Max(TCcoinpiv.Tolerance(),tolr));
859 CD[pivot]->ChangePCurve(isfirst) = C2dOnPiv;
860 CD[pivot]->SetIndexPoint(If2,isfirst,isurf1);
861 CD[pivot]->SetIndexPoint(Il2,isfirst,isurf2);
862 CD[pivot]->SetParameters(isfirst,fi.FirstParameter(),fi.LastParameter());
863 fdpiv->ChangeVertex(isfirst,isurf1) = Pf2;
864 fdpiv->ChangeVertex(isfirst,isurf2) = Pl2;
865 fdpiv->ChangeInterference(isurf1).SetParameter(p[pivot][deb],isfirst);
866 fdpiv->ChangeInterference(isurf2).SetParameter(p[pivot][fin],isfirst);
867 CD[pivot]->InDS(isfirst); // filDS already does it from the corner.
868 if(rev) ChFi3d_EnlargeBox(DStr,CD[pivot],fdpiv,*pbl2,*pbf2,isfirst);
869 else ChFi3d_EnlargeBox(DStr,CD[pivot],fdpiv,*pbf2,*pbl2,isfirst);
871 //To end the tolerances of points are rescaled.
872 ChFi3d_SetPointTolerance(DStr,*pbf1,If1);
873 ChFi3d_SetPointTolerance(DStr,*pbf2,If2);
874 ChFi3d_SetPointTolerance(DStr,*pbl1,Il1);
875 ChFi3d_SetPointTolerance(DStr,*pbl2,Il2);
878 //The data corners are truncated and index is updated.
879 //----------------------------------------------------
881 if(i[deb][pivot] < Index[deb]){
882 CD[deb]->ChangeSetOfSurfData()->Remove(i[deb][pivot]+1,Index[deb]);
883 Index[deb] = i[deb][pivot];
885 else if(i[deb][pivot] > Index[deb]) {
886 CD[deb]->ChangeSetOfSurfData()->Remove(Index[deb],i[deb][pivot]-1);
887 i[deb][pivot] = Index[deb];
889 if(i[fin][pivot] < Index[fin]) {
890 CD[fin]->ChangeSetOfSurfData()->Remove(i[fin][pivot]+1,Index[fin]);
891 Index[fin] = i[fin][pivot];
893 else if(i[fin][pivot] > Index[fin]) {
894 CD[fin]->ChangeSetOfSurfData()->Remove(Index[fin],i[fin][pivot]-1);
895 i[fin][pivot] = Index[fin];
897 // it is necessary to take into account mutant corners.
898 if(i[pivot][deb] < Index[pivot]) {
899 CD[pivot]->ChangeSetOfSurfData()->Remove(i[pivot][deb]+1,Index[pivot]);
900 Index[pivot] = i[pivot][deb];
902 else if(i[pivot][deb] > Index[pivot]) {
903 CD[pivot]->ChangeSetOfSurfData()->Remove(Index[pivot],i[pivot][deb]-1);
904 i[pivot][deb] = Index[pivot];
906 if(!myEVIMap.IsBound(Vtx)){
907 TColStd_ListOfInteger li;
908 myEVIMap.Bind(Vtx,li);
910 myEVIMap.ChangeFind(Vtx).Append(coin->Surf());
911 corner->SetSolidIndex(CD[pivot]->SolidIndex());
912 myListStripe.Append(corner);
915 ChFi3d_ResultChron(ch , t_t3cornerDS);// result perf update DS