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.
17 #include <ChFi3d_FilBuilder.jxx>
18 #include <ChFi3d_Builder_0.hxx>
21 #include <Precision.hxx>
23 #include <Standard_Failure.hxx>
24 #include <Standard_NotImplemented.hxx>
25 #include <TColStd_ListOfInteger.hxx>
27 #include <math_Vector.hxx>
32 #include <gp_Pnt2d.hxx>
39 #include <TColgp_Array1OfPnt2d.hxx>
41 #include <Geom_Plane.hxx>
42 #include <Geom_Circle.hxx>
43 #include <Geom_BezierCurve.hxx>
44 #include <Geom2d_BezierCurve.hxx>
45 #include <Geom2d_Curve.hxx>
46 #include <Geom2d_TrimmedCurve.hxx>
47 #include <Geom2d_Line.hxx>
48 #include <Geom_BSplineSurface.hxx>
50 #include <IntAna_QuadQuadGeo.hxx>
51 #include <IntCurveSurface_IntersectionPoint.hxx>
54 #include <TopoDS_Shape.hxx>
55 #include <TopoDS_Face.hxx>
56 #include <TopoDS_Edge.hxx>
57 #include <TopoDS_Vertex.hxx>
59 #include <Adaptor3d_HSurface.hxx>
60 #include <Adaptor3d_CurveOnSurface.hxx>
61 #include <Adaptor3d_TopolTool.hxx>
62 #include <Geom2dAdaptor_Curve.hxx>
63 #include <Geom2dAdaptor_HCurve.hxx>
64 #include <GeomAdaptor_Curve.hxx>
65 #include <GeomAdaptor_HCurve.hxx>
66 #include <GeomAdaptor_Surface.hxx>
67 #include <GeomAdaptor_HSurface.hxx>
68 #include <BRepAdaptor_Curve.hxx>
69 #include <BRepAdaptor_HCurve.hxx>
70 #include <BRepAdaptor_Surface.hxx>
71 #include <BRepAdaptor_HSurface.hxx>
72 #include <BRepTopAdaptor_TopolTool.hxx>
75 #include <TopAbs_Orientation.hxx>
77 #include <ChFiDS_SurfData.hxx>
78 #include <ChFiDS_CommonPoint.hxx>
79 #include <ChFiDS_FaceInterference.hxx>
80 #include <ChFiDS_Spine.hxx>
81 #include <ChFiDS_SequenceOfSurfData.hxx>
82 #include <ChFiDS_Stripe.hxx>
83 #include <ChFiDS_HData.hxx>
84 #include <ChFiDS_ListIteratorOfListOfStripe.hxx>
85 #include <ChFiDS_Regul.hxx>
87 #include <TopOpeBRepDS_HDataStructure.hxx>
88 #include <TopOpeBRepDS_DataStructure.hxx>
89 #include <TopOpeBRepDS_Curve.hxx>
90 #include <TopOpeBRepDS_Surface.hxx>
92 #include <ChFiKPart_ComputeData.hxx>
93 #include <BRepBlend_Line.hxx>
94 #include <BRepBlend_ConstRad.hxx>
95 #include <BRepBlend_ConstRadInv.hxx>
96 #include <BRepBlend_EvolRad.hxx>
97 #include <BRepBlend_EvolRadInv.hxx>
101 #include <DrawTrSurf.hxx>
104 #include <Geom_TrimmedCurve.hxx>
105 extern Standard_Boolean ChFi3d_GettraceDRAWSPINE();
106 extern Standard_Boolean ChFi3d_GetcontextSPINEBEZIER();
107 extern Standard_Boolean ChFi3d_GetcontextSPINECIRCLE();
108 extern Standard_Boolean ChFi3d_GetcontextSPINECE();
109 extern Standard_Boolean ChFi3d_GetcontextFORCEFILLING();
110 #include <OSD_Chronometer.hxx>
112 extern Standard_Real t_t3cornerinit ,t_spherique,t_torique,
113 t_notfilling,t_filling,t_t3cornerDS;
114 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
115 extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
118 //=======================================================================
119 //function : SearchPivot
121 //=======================================================================
122 static Standard_Integer SearchPivot(Standard_Integer* s,
123 Standard_Real u[3][3],
124 const Standard_Real t)
126 Standard_Boolean bondeb,bonfin;
127 for(Standard_Integer i = 0; i <= 2; i++){
128 if(s[(i+1)%3] == 1){bondeb = (u[(i+1)%3][i]-u[(i+1)%3][(i+2)%3] >= -t);}
129 else {bondeb = (u[(i+1)%3][i]-u[(i+1)%3][(i+2)%3] <= t);}
130 if(s[(i+2)%3] == 1){bonfin = (u[(i+2)%3][i]-u[(i+2)%3][(i+1)%3] >= -t);}
131 else {bonfin = (u[(i+2)%3][i]-u[(i+2)%3][(i+1)%3] <= t);}
132 if (bondeb && bonfin){ return i; }
138 //=======================================================================
139 //function : SearchFD
141 //=======================================================================
142 static Standard_Boolean SearchFD(TopOpeBRepDS_DataStructure& DStr,
143 const Handle(ChFiDS_Stripe)& cd1,
144 const Handle(ChFiDS_Stripe)& cd2,
145 const Standard_Integer sens1,
146 const Standard_Integer sens2,
147 Standard_Integer& i1,
148 Standard_Integer& i2,
151 const Standard_Integer ind1,
152 const Standard_Integer ind2,
154 Standard_Boolean& sameside,
155 Standard_Integer& jf1,
156 Standard_Integer& jf2)
158 Standard_Boolean found = Standard_False;
159 Standard_Integer id1 = ind1, id2 = ind2;
160 Standard_Integer if1 = ind1, if2 = ind2;
161 Standard_Integer l1 = cd1->SetOfSurfData()->Length();
162 Standard_Integer l2 = cd2->SetOfSurfData()->Length();
164 Standard_Boolean fini1 = Standard_False, fini2 = Standard_False;
165 Standard_Boolean visavis;
168 for(i = id1; (i*sens1) <= (if1*sens1) && !found && !fini2; i = i+sens1 ){
169 if(ChFi3d_IsInFront(DStr,cd1,cd2,i,if2,sens1,sens2,p1,p2,face,sameside,jf1,jf2,visavis,Vtx,Standard_False,0)){
172 found = Standard_True;
177 if(if1 < 1 || if1 > l1){ if1 = if1 - sens1; fini1 = Standard_True; }
180 for(i = id2; (i*sens2) <= (if2*sens2) && !found && !fini1; i = i+sens2 ){
181 if(ChFi3d_IsInFront(DStr,cd1,cd2,if1,i,sens1,sens2,p1,p2,face,sameside,jf1,jf2,visavis,Vtx,Standard_False,0)){
184 found = Standard_True;
189 if(if2 < 1 || if2 > l2){ if2 = if2 - sens2; fini2 = Standard_True; }
191 if(fini1 && fini2) break;
197 //=======================================================================
198 //function : ToricCorner
199 //purpose : Test if this is a paricular cas of a torus corner
200 // (or spherical limited by isos).
201 //=======================================================================
203 static Standard_Boolean ToricCorner(const TopoDS_Face& F,
204 const Standard_Real rd,
205 const Standard_Real rf,
208 if(Abs(rd-rf) > Precision::Confusion()){ return Standard_False; }
209 BRepAdaptor_Surface bs(F);
210 if(bs.GetType() != GeomAbs_Plane){ return Standard_False; }
211 Standard_Real scal1 = Abs(bs.Plane().Position().XDirection().Dot(v));
212 Standard_Real scal2 = Abs(bs.Plane().Position().YDirection().Dot(v));
213 return (scal1 <= Precision::Confusion() &&
214 scal2 <= Precision::Confusion());
217 //=======================================================================
218 //function : PerformThreeCorner
219 //purpose : Calculate fillet on a top with three edges
220 // incident carrying each edge.
221 //=======================================================================
223 void ChFi3d_FilBuilder::PerformThreeCorner(const Standard_Integer Jndex)
228 ChFi3d_InitChron(ch); // init perf initialisation
231 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
232 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Jndex);
233 ChFiDS_ListIteratorOfListOfStripe It;
234 Standard_Integer Index[3],pivot,deb,fin,ii,jj,kk;
235 //Standard_Real R = 0.;
236 Standard_Boolean pivdif = Standard_True;
237 Standard_Boolean c1pointu = Standard_False;
238 Standard_Boolean c1toric = Standard_False;
239 Standard_Boolean c1spheric = Standard_False;
240 Handle(ChFiDS_Stripe) CD[3];
242 Standard_Integer jf[3][3];
243 Standard_Boolean sameside[3], oksea[3];
244 for(Standard_Integer g = 0; g <= 2; g++){oksea[g] = Standard_False;}
245 Standard_Integer i[3][3];
246 Standard_Integer sens[3];
247 Standard_Real p[3][3];
249 Standard_Boolean filling = 0;
251 for (It.Initialize(myVDataMap(Jndex)),ii=0;It.More() && ii<3;It.Next(),ii++){
252 Index[ii] = ChFi3d_IndexOfSurfData(Vtx,It.Value(),sens[ii]);
255 // It is checked if one of CD is not present twice in which
256 // case it is necessary to modify the return of IndexOfSurfData
257 // that takes the first solution.
259 Index[1] = CD[1]->SetOfSurfData()->Length();
262 else if(CD[1] == CD[2]){
263 Index[2] = CD[2]->SetOfSurfData()->Length();
266 else if(CD[0] == CD[2]){
267 Index[2] = CD[2]->SetOfSurfData()->Length();
270 oksea[2] = SearchFD(DStr,CD[0],CD[1],sens[0],sens[1],i[0][1],i[1][0],
271 p[0][1],p[1][0],Index[0],Index[1],face[2],sameside[2],
273 oksea[1] = SearchFD(DStr,CD[0],CD[2],sens[0],sens[2],i[0][2],i[2][0],
274 p[0][2],p[2][0],Index[0],Index[2],face[1],sameside[1],
276 oksea[0] = SearchFD(DStr,CD[1],CD[2],sens[1],sens[2],i[1][2],i[2][1],
277 p[1][2],p[2][1],Index[1],Index[2],face[0],sameside[0],
280 // Analyze concavities of 3 fillets :
281 // - 2 concavities identic and 1 inverted.
282 // - 3 concavities identic
284 if(oksea[2] && oksea[1] && !sameside[2] && !sameside[1])
285 { pivot = 0; deb = 1; fin = 2;}
286 else if(oksea[2] && oksea[0] && !sameside[2] && !sameside[0])
287 { pivot = 1; deb = 2; fin = 0;}
288 else if(oksea[1] && oksea[0] && !sameside[1] && !sameside[0])
289 { pivot = 2; deb = 0; fin = 1;}
290 else if(oksea[0] && oksea[1] && oksea[2]){
291 // 3 concavities identic.
292 pivot = SearchPivot(sens,p,tol2d);
295 cout<<"pivot not found, plate is called"<<endl;
297 PerformMoreThreeCorner(Jndex, 3);
300 else{deb = (pivot+1)%3 ; fin = (pivot+2)%3;}
301 pivdif = Standard_False;
302 if(Abs(p[0][1]-p[0][2]) <= tol2d &&
303 Abs(p[1][0]-p[1][2]) <= tol2d &&
304 Abs(p[2][0]-p[2][1]) <= tol2d){
305 c1pointu = Standard_True;
309 PerformMoreThreeCorner(Jndex, 3);
312 Standard_Integer ifacdeb, ifacfin;
313 ifacdeb = CD[deb]->ChangeSetOfSurfData()->Value(i[deb][pivot])->Index(3-jf[deb][pivot]);
314 ifacfin = CD[fin]->ChangeSetOfSurfData()->Value(i[fin][pivot])->Index(3-jf[fin][pivot]);
315 if(ifacfin != ifacdeb){
317 cout<<"several base faces, plate is called"<<endl;
319 PerformMoreThreeCorner(Jndex, 3);
322 if(i[pivot][deb] != i[pivot][fin]){
324 cout<<"load surfdata on the pivot, plate is called"<<endl;
326 PerformMoreThreeCorner(Jndex, 3);
330 Standard_Real Rdeb,Rfin,Rdp,Rfp;
331 gp_Pnt Pdeb,Pfin,Pdp,Pfp;
332 gp_Vec Vdeb,Vfin,Vdp,Vfp;
337 for(ii = 0; ii<=2; ii++){
338 jj = (ii+1)%3 ; kk = (ii+2)%3;
339 ChFi3d_ExtrSpineCarac(DStr,CD[jj],i[jj][ii],p[jj][ii],1,
340 sens[jj],pbid,qv[jj],qr[jj]);
342 for(ii = 0; ii<=2 && !c1toric; ii++){
343 jj = (ii+1)%3 ; kk = (ii+2)%3;
344 if(ToricCorner(face[ii],qr[jj],qr[kk],qv[ii])){
345 c1toric = Standard_True;
346 pivot = ii; deb = jj; fin = kk;
349 if(!c1toric)c1spheric=(Abs(qr[0]-qr[1])<tolesp && Abs(qr[0]-qr[2])<tolesp);
352 // Previously to avoid loops the points were always located
353 // inside, which could impede the construction of the
354 // guideline of the corner which now is a circle.
355 // Standard_Integer jjjd = jf[deb][fin], jjjf = jf[fin][deb];
356 // if (pivdif) jjjd = jf[deb][pivot], jjjf = jf[fin][pivot];
357 Standard_Integer jjjd = jf[deb][pivot], jjjf = jf[fin][pivot];
358 ChFi3d_ExtrSpineCarac(DStr,CD[deb],i[deb][pivot],p[deb][pivot],
359 jjjd,sens[deb],Pdeb,Vdeb,Rdeb);
360 ChFi3d_ExtrSpineCarac(DStr,CD[fin],i[fin][pivot],p[fin][pivot],
361 jjjf,sens[fin],Pfin,Vfin,Rfin);
362 ChFi3d_ExtrSpineCarac(DStr,CD[pivot],i[pivot][deb],p[pivot][deb],
363 0,sens[pivot],Pdp,Vdp,Rdp);
364 ChFi3d_ExtrSpineCarac(DStr,CD[pivot],i[pivot][fin],p[pivot][fin],
365 0,sens[pivot],Pfp,Vfp,Rfp);
366 //in cas of allsame it is checked that points on the face are not
367 //too close, which can stop the work.
369 gp_Pnt ptestdeb,ptestfin; gp_Vec bidvec; Standard_Real bidr;
370 ChFi3d_ExtrSpineCarac(DStr,CD[deb],i[deb][pivot],p[deb][pivot],
371 jf[deb][fin],sens[deb],ptestdeb,bidvec,bidr);
372 ChFi3d_ExtrSpineCarac(DStr,CD[fin],i[fin][pivot],p[fin][pivot],
373 jf[fin][deb],sens[fin],ptestfin,bidvec,bidr);
374 Standard_Real distest = ptestdeb.Distance(ptestfin);
375 if(distest < (Rdp+Rfp)*0.05) filling = 1;
376 if(distest < (Rdp+Rfp)*0.005) c1pointu = 1;
380 if (!pivdif) c1pointu = (Abs(p[deb][pivot]-p[deb][fin]) <=tol2d &&
381 Abs(p[fin][pivot]-p[fin][deb]) <=tol2d);
382 if(Abs(p[pivot][deb] - p[pivot][fin]) <= tol2d)
383 c1toric = ToricCorner(face[pivot],Rdeb,Rfin,Vdp);
385 // there is a pivot, the start and the end CD (finally !?!) :
386 // -------------------------------------------------------------
387 // the criterions determining if the corner is a torus or a sphere
388 // are based only on the configuration of sections at end and the
389 // nature of faces, it is necessary to make tests to
390 // determine if a more detailed analysis of incident fillets
391 // is necessare to provide tangency between them and
392 // the corner (in particular in the case with variable radius).
396 Handle(ChFiDS_SurfData)&
397 fddeb = CD[deb]->ChangeSetOfSurfData()->ChangeValue(i[deb][pivot]);
398 Handle(ChFiDS_SurfData)&
399 fdfin = CD[fin]->ChangeSetOfSurfData()->ChangeValue(i[fin][pivot]);
400 Handle(ChFiDS_SurfData)&
401 fdpiv = CD[pivot]->ChangeSetOfSurfData()->ChangeValue(i[pivot][deb]);
404 // HSurfaces and other suitable tools are constructed.
405 // ----------------------------------------------------------
407 TopAbs_Orientation OFac = face[pivot].Orientation();
408 Handle(BRepAdaptor_HSurface) Fac = new BRepAdaptor_HSurface(face[pivot]);
410 const ChFiDS_FaceInterference& bid1 = CD[pivot]->SetOfSurfData()->
411 Value(i[pivot][deb])->InterferenceOnS1();
412 ppp1 = bid1.PCurveOnSurf()->Value(bid1.FirstParameter());
413 const ChFiDS_FaceInterference& bid2 = CD[pivot]->SetOfSurfData()->
414 Value(i[pivot][deb])->InterferenceOnS2();
415 ppp2 = bid2.PCurveOnSurf()->Value(bid2.LastParameter());
416 Standard_Real uu1 = ppp1.X(), uu2 = ppp2.X(), vv1 = ppp1.Y(), vv2 = ppp2.Y();
418 gasurf((DStr.Surface(CD[pivot]->SetOfSurfData()->
419 Value(i[pivot][deb])->Surf())).Surface(),
421 GeomAbs_SurfaceType styp = gasurf.GetType();
422 if(styp == GeomAbs_Cylinder){
423 Standard_Real h = vv2 - vv1;
426 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
427 Value(i[pivot][deb])->Surf())).Surface(),
430 else if(styp == GeomAbs_Torus){
431 Standard_Real h = uu2 - uu1;
434 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
435 Value(i[pivot][deb])->Surf())).Surface(),
438 else if(styp == GeomAbs_BezierSurface || styp == GeomAbs_BSplineSurface){
439 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
440 Value(i[pivot][deb])->Surf())).Surface());
443 Handle(GeomAdaptor_HSurface) Surf = new GeomAdaptor_HSurface(gasurf);
444 // Handle(BRepTopAdaptor_TopolTool) IFac = new BRepTopAdaptor_TopolTool(Fac);
445 // Try to not classify on the face for cases of reentering fillets which naturally depass
447 Handle(GeomAdaptor_HSurface)
448 bidsurf = new GeomAdaptor_HSurface(Fac->ChangeSurface().Surface());
449 Handle(Adaptor3d_TopolTool)
450 IFac = new Adaptor3d_TopolTool(bidsurf);
451 // end of the attempt.
452 Handle(Adaptor3d_TopolTool) ISurf = new Adaptor3d_TopolTool(Surf);
453 Handle(ChFiDS_Stripe) corner = new ChFiDS_Stripe();
454 Handle(ChFiDS_HData)& cornerset = corner->ChangeSetOfSurfData();
455 cornerset = new ChFiDS_HData();
456 Handle(ChFiDS_SurfData) coin = new ChFiDS_SurfData();
457 cornerset->Append(coin);
458 TopAbs_Orientation o1,o2,os1,os2,oo1,oo2;
459 Standard_Integer choix = CD[deb]->Choix();
460 o1 = face[pivot].Orientation();
461 o2 = fdpiv->Orientation();
463 os1 = CD[deb]->OrientationOnFace1();
464 os2 = CD[deb]->OrientationOnFace2();
465 if(jf[deb][fin] == 1){
466 choix = ChFi3d::NextSide(o1,o2,os1,os2,choix);
468 if(choix%2 == 1) choix++;
473 choix = ChFi3d::NextSide(o2,o1,os1,os2,-choix);
475 if(choix%2 == 1) choix++;
480 gp_Pnt2d pfac1,pfac2,psurf1,psurf2;
481 gp_Vec2d vfac1,vfac2;
482 CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
483 Interference(jf[deb][fin]).PCurveOnFace()->D1(p[deb][pivot],pfac1,vfac1);
484 CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
485 Interference(jf[fin][deb]).PCurveOnFace()->D1(p[fin][pivot],pfac2,vfac2);
486 psurf1 = CD[pivot]->SetOfSurfData()->Value(i[pivot][deb])->
487 Interference(jf[pivot][deb]).PCurveOnSurf()->Value(p[pivot][deb]);
488 psurf2 = CD[pivot]->SetOfSurfData()->Value(i[pivot][fin])->
489 Interference(jf[pivot][fin]).PCurveOnSurf()->Value(p[pivot][fin]);
491 done = Standard_False;
493 if(ChFi3d_GetcontextFORCEFILLING()) c1spheric = c1toric = 0;
497 ChFi3d_ResultChron(ch , t_t3cornerinit); // result perf initialisations
503 ChFi3d_InitChron(ch); // init perf case torus
506 // Direct Construction.
507 // ---------------------
508 done = ChFiKPart_ComputeData::ComputeCorner
509 (DStr,coin,Fac,Surf,oo1,oo2,o1,o2,Rdeb,Rdp,pfac1,pfac2,psurf1,psurf2);
512 ChFi3d_ResultChron(ch , t_torique); // result perf case torus
519 ChFi3d_InitChron(ch); //init perf case sphere
522 done = ChFiKPart_ComputeData::ComputeCorner
523 (DStr,coin,Fac,Surf,oo1,oo2,o1,o2,Rdp,pfac1,psurf1,psurf2);
526 ChFi3d_ResultChron(ch , t_spherique);// result perf cas sphere
537 ChFi3d_InitChron(ch);// init perf not filling
540 //Calculate a guideline,
541 //------------------------------
542 //Numerous problems with loops and half-turns connected to
543 //the curvature of the guideline !!!!!!
545 //If the nature of guideline is changed it is necessary to
546 //reset points Pdeb and Pfin at the inside (see the
547 //comments about it in the calculation of Pdeb and Pfin).
549 Standard_Real radpondere = (Rdp+Rfp)/2.;
550 Standard_Real locfleche = fleche;
552 Standard_Real WFirst,WLast;
553 Handle(Geom_Curve) spinecoin = ChFi3d_CircularSpine(WFirst,WLast,
555 Pfin,Vfin,radpondere);
556 if(spinecoin.IsNull()){
557 // This is a bad case when the intersection of
558 // section planes is done out of the sector.
559 spinecoin = ChFi3d_Spine(Pdeb,Vdeb,
560 Pfin,Vfin,radpondere);
561 WFirst = 0.; WLast = 1.;
563 else locfleche = radpondere * (WLast - WFirst) * fleche;
564 Standard_Real pasmax = (WLast-WFirst)*0.05;
565 Handle(ChFiDS_HElSpine) cornerspine = new ChFiDS_HElSpine();
566 cornerspine->ChangeCurve().SetCurve(spinecoin);
567 cornerspine->ChangeCurve().FirstParameter(WFirst - pasmax);
568 cornerspine->ChangeCurve().LastParameter(WLast + pasmax);
569 // Just to confuse Compute that should not require this
570 // in this exact case ...
571 Handle(ChFiDS_Spine) NullSpine;
572 // The fillet is calculated - from beginning to end
573 // - from the face to the surface
575 math_Vector Soldep(1,4);
576 Soldep(1) = pfac1.X();
577 Soldep(2) = pfac1.Y();
578 Soldep(3) = psurf1.X();
579 Soldep(4) = psurf1.Y();
581 Standard_Boolean Gd1,Gd2,Gf1,Gf2;
582 Handle(BRepBlend_Line) lin;
583 Standard_Real ffi = WFirst, lla = WLast + pasmax;
585 if (Abs(Rdeb-Rfin)<=tolesp){
587 BRepBlend_ConstRad func(Fac,Surf,cornerspine);
588 BRepBlend_ConstRadInv finv(Fac,Surf,cornerspine);
589 func.Set(Rdeb,choix);
591 finv.Set(Rdeb,choix);
592 Standard_Real TolGuide = cornerspine->Resolution(tolesp);
594 Standard_Boolean intf = 3, intl = 3;
595 done = ComputeData(coin,cornerspine,NullSpine,lin,Fac,IFac,Surf,ISurf,
596 func,finv,ffi,pasmax,locfleche,TolGuide,ffi,lla,
597 0,0,1,Soldep,intf,intl,Gd1,Gd2,Gf1,Gf2,0,1);
599 if(ChFi3d_GetcontextFORCEFILLING()) done = 0;
602 done = CompleteData(coin,func,lin,Fac,Surf,OFac,Gd1,0,Gf1,0);
608 Handle(Law_S) law = new Law_S();
609 law->Set(WFirst,Rdeb,WLast,Rfin);
610 BRepBlend_EvolRad func(Fac,Surf,cornerspine,law);
611 BRepBlend_EvolRadInv finv(Fac,Surf,cornerspine,law);
615 Standard_Real TolGuide = cornerspine->Resolution(tolesp);
616 Standard_Boolean intf = 3, intl = 3;
617 done = ComputeData(coin,cornerspine,NullSpine,lin,Fac,IFac,Surf,ISurf,
618 func,finv,ffi,pasmax,locfleche,TolGuide,ffi,lla,
619 0,0,1,Soldep,intf,intl,Gd1,Gd2,Gf1,Gf2,0,1);
621 if(ChFi3d_GetcontextFORCEFILLING()) done = 0;
624 done = CompleteData(coin,func,lin,Fac,Surf,OFac,Gd1,0,Gf1,0);
631 ChFi3d_ResultChron(ch , t_notfilling);// result perf not filling
639 ChFi3d_InitChron(ch); // init perf filling
642 // the contour to be fillet consists of straight lines uv in beginning and end
643 // of two pcurves (only one if c1pointu) calculted as possible
644 // on piv and the opposite face.
645 Handle(GeomFill_Boundary) Bdeb,Bfin,Bpiv,Bfac;
646 Handle(Geom2d_Curve) PCurveOnFace;
648 Bfac = ChFi3d_mkbound(Fac,PCurveOnFace,sens[deb],pfac1,vfac1,
649 sens[fin],pfac2,vfac2,tolesp,2.e-4);
650 Standard_Integer kkk;
653 kkk = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
654 Interference(jf[deb][pivot]).LineIndex();
655 DStr.Curve(kkk).Curve()->D1(p[deb][pivot],ppbid,vp1);
656 kkk = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
657 Interference(jf[fin][pivot]).LineIndex();
658 DStr.Curve(kkk).Curve()->D1(p[fin][pivot],ppbid,vp2);
659 Handle(Geom2d_Curve) PCurveOnPiv;
660 // Bpiv = ChFi3d_mkbound(Surf,PCurveOnPiv,sens[deb],psurf1,vp1,
661 // sens[fin],psurf2,vp2,tolesp,2.e-4);
662 Bpiv = ChFi3d_mkbound(Surf,PCurveOnPiv,psurf1,psurf2,tolesp,2.e-4,0);
663 Standard_Real pardeb2 = p[deb][pivot];
664 Standard_Real parfin2 = p[fin][pivot];
666 pardeb2 = p[deb][fin];
667 parfin2 = p[fin][deb];
669 gp_Pnt2d pdeb1 = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
670 Interference(jf[deb][pivot]).PCurveOnSurf()->Value(p[deb][pivot]);
671 gp_Pnt2d pdeb2 = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
672 Interference(jf[deb][fin]).PCurveOnSurf()->Value(pardeb2);
673 gp_Pnt2d pfin1 = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
674 Interference(jf[fin][pivot]).PCurveOnSurf()->Value(p[fin][pivot]);
675 gp_Pnt2d pfin2 = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
676 Interference(jf[fin][deb]).PCurveOnSurf()->Value(parfin2);
677 Handle(Geom_Surface) sdeb =
678 DStr.Surface(CD[deb]->SetOfSurfData()->
679 Value(i[deb][pivot])->Surf()).Surface();
680 Handle(Geom_Surface) sfin =
681 DStr.Surface(CD[fin]->SetOfSurfData()->
682 Value(i[fin][pivot])->Surf()).Surface();
684 Bdeb = ChFi3d_mkbound(sdeb,pdeb1,pdeb2,tolesp,2.e-4);
685 Bfin = ChFi3d_mkbound(sfin,pfin1,pfin2,tolesp,2.e-4);
687 GeomFill_ConstrainedFilling fil(11,20);
688 if(c1pointu) fil.Init(Bpiv,Bfin,Bdeb,1);
689 else fil.Init(Bpiv,Bfin,Bfac,Bdeb,1);
691 Handle(Geom_Surface) Surfcoin = fil.Surface();
692 Surfcoin->VReverse(); // revert to direction face surface;
693 done = CompleteData(coin,Surfcoin,
695 Surf,PCurveOnPiv,fdpiv->Orientation(),0,
699 ChFi3d_ResultChron(ch , t_filling);// result perf filling
704 Standard_Real P1deb,P2deb,P1fin,P2fin;
706 p[deb][fin] = p[deb][pivot];
707 p[fin][deb] = p[fin][pivot];
711 // Update of 4 Stripes and the DS
712 // -------------------------------------
715 ChFi3d_InitChron(ch);// init perf update DS
719 Standard_Real parpp1,parpp2;
720 Standard_Integer If1,If2,Il1,Il2,Icf,Icl;
721 const ChFiDS_CommonPoint& Pf1 = coin->VertexFirstOnS1();
722 const ChFiDS_CommonPoint& Pf2 = coin->VertexFirstOnS2();
723 ChFiDS_CommonPoint& Pl1 = coin->ChangeVertexLastOnS1();
724 if(c1pointu) Pl1 = coin->ChangeVertexFirstOnS1();
725 const ChFiDS_CommonPoint& Pl2 = coin->VertexLastOnS2();
727 Bnd_Box bf1,bl1,bf2,bl2;
728 Bnd_Box *pbf1 = &bf1,*pbl1 = &bl1,*pbf2 = &bf2,*pbl2 = &bl2;
729 if(c1pointu) pbl1 = pbf1;
730 pbf1->Add(Pf1.Point());pbf2->Add(Pf2.Point());
731 pbl1->Add(Pl1.Point());pbl2->Add(Pl2.Point());
734 // -----------------------
735 ChFiDS_Regul regdeb, regfin;
736 If1 = ChFi3d_IndexPointInDS(Pf1,DStr);
737 If2 = ChFi3d_IndexPointInDS(Pf2,DStr);
738 if(c1pointu) Il1 = If1;
739 else Il1 = ChFi3d_IndexPointInDS(Pl1,DStr);
740 Il2 = ChFi3d_IndexPointInDS(Pl2,DStr);
741 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
742 Value(coin->InterferenceOnS1().FirstParameter());
743 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
744 Value(coin->InterferenceOnS2().FirstParameter());
745 if(c1pointu) coin->ChangeIndexOfS1(0);
746 else coin->ChangeIndexOfS1(DStr.AddShape(face[pivot]));
747 coin->ChangeIndexOfS2(-fdpiv->Surf());
749 Handle(Geom_Curve) C3d;
750 Standard_Real tolreached;
751 ChFi3d_ComputeArete(Pf1,pp1,Pf2,pp2,
752 DStr.Surface(coin->Surf()).Surface(),C3d,
753 corner->ChangeFirstPCurve(),P1deb,P2deb,
754 tolesp,tol2d,tolreached,0);
755 TopOpeBRepDS_Curve Tcurv1(C3d,tolreached);
756 Icf = DStr.AddCurve(Tcurv1);
757 regdeb.SetCurve(Icf);
758 regdeb.SetS1(coin->Surf(),0);
759 regdeb.SetS2(fddeb->Surf(),0);
760 myRegul.Append(regdeb);
761 corner->ChangeFirstCurve(Icf);
762 corner->ChangeFirstParameters(P1deb,P2deb);
763 corner->ChangeIndexFirstPointOnS1(If1);
764 corner->ChangeIndexFirstPointOnS2(If2);
765 ChFi3d_EnlargeBox(DStr,corner,coin,*pbf1,*pbf2,1);
767 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
768 Value(coin->InterferenceOnS1().LastParameter());
769 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
770 Value(coin->InterferenceOnS2().LastParameter());
771 ChFi3d_ComputeArete(Pl1,pp1,Pl2,pp2,
772 DStr.Surface(coin->Surf()).Surface(),C3d,
773 corner->ChangeLastPCurve(),P1fin,P2fin,
774 tolesp,tol2d,tolreached,0);
775 TopOpeBRepDS_Curve Tcurv2(C3d,tolreached);
776 Icl = DStr.AddCurve(Tcurv2);
777 regfin.SetCurve(Icl);
778 regfin.SetS1(coin->Surf(),0);
779 regfin.SetS2(fdfin->Surf(),0);
780 myRegul.Append(regfin);
781 corner->ChangeLastCurve(Icl);
782 corner->ChangeLastParameters(P1fin,P2fin);
783 corner->ChangeIndexLastPointOnS1(Il1);
784 corner->ChangeIndexLastPointOnS2(Il2);
785 ChFi3d_EnlargeBox(DStr,corner,coin,*pbl1,*pbl2,0);
787 // then CornerData of the beginning,
788 // --------------------------------
789 Standard_Boolean isfirst = (sens[deb] == 1), rev = (jf[deb][fin] == 2);
790 Standard_Integer isurf1 = 1, isurf2 = 2;
791 parpp1 = p[deb][fin]; parpp2 = p[deb][pivot];
793 isurf1 = 2; isurf2 = 1;
794 parpp1 = p[deb][pivot]; parpp2 = p[deb][fin];
795 CD[deb]->SetOrientation(TopAbs_REVERSED,isfirst);
797 pp1 = fddeb->InterferenceOnS1().PCurveOnSurf()->Value(parpp1);
798 pp2 = fddeb->InterferenceOnS2().PCurveOnSurf()->Value(parpp2);
799 CD[deb]->SetCurve(Icf,isfirst);
800 CD[deb]->SetIndexPoint(If1,isfirst,isurf1);
801 CD[deb]->SetIndexPoint(If2,isfirst,isurf2);
802 CD[deb]->SetParameters(isfirst,P1deb,P2deb);
803 fddeb->ChangeVertex(isfirst,isurf1) = Pf1;
804 fddeb->ChangeVertex(isfirst,isurf2) = Pf2;
805 fddeb->ChangeInterferenceOnS1().SetParameter(parpp1,isfirst);
806 fddeb->ChangeInterferenceOnS2().SetParameter(parpp2,isfirst);
807 TopOpeBRepDS_Curve& tcdeb = DStr.ChangeCurve(Icf);
808 Handle(Geom_Curve) crefdeb = tcdeb.Curve();
809 Standard_Real tolrdeb;
810 ChFi3d_ComputePCurv(crefdeb,pp1,pp2,CD[deb]->ChangePCurve(isfirst),
811 DStr.Surface(fddeb->Surf()).Surface(),
812 P1deb,P2deb,tolesp,tolrdeb,rev);
813 tcdeb.Tolerance(Max(tolrdeb,tcdeb.Tolerance()));
814 if(rev) ChFi3d_EnlargeBox(DStr,CD[deb],fddeb,*pbf2,*pbf1,isfirst);
815 else ChFi3d_EnlargeBox(DStr,CD[deb],fddeb,*pbf1,*pbf2,isfirst);
817 // then the end CornerData,
818 // ------------------------
819 isfirst = (sens[fin] == 1); rev = (jf[fin][deb] == 2);
820 isurf1 = 1; isurf2 = 2;
821 parpp1 = p[fin][deb]; parpp2 = p[fin][pivot];
823 isurf1 = 2; isurf2 = 1;
824 parpp1 = p[fin][pivot]; parpp2 = p[fin][deb];
825 CD[fin]->SetOrientation(TopAbs_REVERSED,isfirst);
827 pp1 = fdfin->InterferenceOnS1().PCurveOnSurf()->Value(parpp1);
828 pp2 = fdfin->InterferenceOnS2().PCurveOnSurf()->Value(parpp2);
829 CD[fin]->SetCurve(Icl,isfirst);
830 CD[fin]->SetIndexPoint(Il1,isfirst,isurf1);
831 CD[fin]->SetIndexPoint(Il2,isfirst,isurf2);
832 CD[fin]->SetParameters(isfirst,P1fin,P2fin);
833 fdfin->ChangeVertex(isfirst,isurf1) = Pl1;
834 fdfin->ChangeVertex(isfirst,isurf2) = Pl2;
835 fdfin->ChangeInterferenceOnS1().SetParameter(parpp1,isfirst);
836 fdfin->ChangeInterferenceOnS2().SetParameter(parpp2,isfirst);
837 TopOpeBRepDS_Curve& tcfin = DStr.ChangeCurve(Icl);
838 Handle(Geom_Curve) creffin = tcfin.Curve();
839 Standard_Real tolrfin;
840 ChFi3d_ComputePCurv(creffin,pp1,pp2,CD[fin]->ChangePCurve(isfirst),
841 DStr.Surface(fdfin->Surf()).Surface(),
842 P1fin,P2fin,tolesp,tolrfin,rev);
843 tcfin.Tolerance(Max(tolrfin,tcfin.Tolerance()));
844 if(rev) ChFi3d_EnlargeBox(DStr,CD[fin],fdfin,*pbl2,*pbl1,isfirst);
845 else ChFi3d_EnlargeBox(DStr,CD[fin],fdfin,*pbl1,*pbl2,isfirst);
847 // anf finally the pivot.
848 // ------------------
849 ChFiDS_FaceInterference& fi = coin->ChangeInterferenceOnS2();
850 isfirst = (sens[pivot] == 1); rev = (jf[pivot][deb] == 2);
851 isurf1 = 1; isurf2 = 2;
853 isurf1 = 2; isurf2 = 1;
854 CD[pivot]->SetOrientation(TopAbs_REVERSED,isfirst);
856 Standard_Integer ICcoinpiv = fi.LineIndex();
857 TopOpeBRepDS_Curve& TCcoinpiv = DStr.ChangeCurve(ICcoinpiv);
858 CD[pivot]->SetCurve(ICcoinpiv,isfirst);
859 Handle(Geom_Curve) Ccoinpiv = DStr.Curve(ICcoinpiv).Curve();
860 Handle(Geom2d_Curve)& C2dOnPiv = fi.ChangePCurveOnFace();
861 Handle(Geom_Surface) Spiv = DStr.Surface(fdpiv->Surf()).Surface();
863 ChFi3d_SameParameter(Ccoinpiv,C2dOnPiv,Spiv,
864 fi.FirstParameter(),fi.LastParameter(),
866 TCcoinpiv.Tolerance(Max(TCcoinpiv.Tolerance(),tolr));
867 CD[pivot]->ChangePCurve(isfirst) = C2dOnPiv;
868 CD[pivot]->SetIndexPoint(If2,isfirst,isurf1);
869 CD[pivot]->SetIndexPoint(Il2,isfirst,isurf2);
870 CD[pivot]->SetParameters(isfirst,fi.FirstParameter(),fi.LastParameter());
871 fdpiv->ChangeVertex(isfirst,isurf1) = Pf2;
872 fdpiv->ChangeVertex(isfirst,isurf2) = Pl2;
873 fdpiv->ChangeInterference(isurf1).SetParameter(p[pivot][deb],isfirst);
874 fdpiv->ChangeInterference(isurf2).SetParameter(p[pivot][fin],isfirst);
875 CD[pivot]->InDS(isfirst); // filDS already does it from the corner.
876 if(rev) ChFi3d_EnlargeBox(DStr,CD[pivot],fdpiv,*pbl2,*pbf2,isfirst);
877 else ChFi3d_EnlargeBox(DStr,CD[pivot],fdpiv,*pbf2,*pbl2,isfirst);
879 //To end the tolerances of points are rescaled.
880 ChFi3d_SetPointTolerance(DStr,*pbf1,If1);
881 ChFi3d_SetPointTolerance(DStr,*pbf2,If2);
882 ChFi3d_SetPointTolerance(DStr,*pbl1,Il1);
883 ChFi3d_SetPointTolerance(DStr,*pbl2,Il2);
886 //The data corners are truncated and index is updated.
887 //----------------------------------------------------
889 if(i[deb][pivot] < Index[deb]){
890 CD[deb]->ChangeSetOfSurfData()->Remove(i[deb][pivot]+1,Index[deb]);
891 Index[deb] = i[deb][pivot];
893 else if(i[deb][pivot] > Index[deb]) {
894 CD[deb]->ChangeSetOfSurfData()->Remove(Index[deb],i[deb][pivot]-1);
895 i[deb][pivot] = Index[deb];
897 if(i[fin][pivot] < Index[fin]) {
898 CD[fin]->ChangeSetOfSurfData()->Remove(i[fin][pivot]+1,Index[fin]);
899 Index[fin] = i[fin][pivot];
901 else if(i[fin][pivot] > Index[fin]) {
902 CD[fin]->ChangeSetOfSurfData()->Remove(Index[fin],i[fin][pivot]-1);
903 i[fin][pivot] = Index[fin];
905 // it is necessary to take into account mutant corners.
906 if(i[pivot][deb] < Index[pivot]) {
907 CD[pivot]->ChangeSetOfSurfData()->Remove(i[pivot][deb]+1,Index[pivot]);
908 Index[pivot] = i[pivot][deb];
910 else if(i[pivot][deb] > Index[pivot]) {
911 CD[pivot]->ChangeSetOfSurfData()->Remove(Index[pivot],i[pivot][deb]-1);
912 i[pivot][deb] = Index[pivot];
914 if(!myEVIMap.IsBound(Vtx)){
915 TColStd_ListOfInteger li;
916 myEVIMap.Bind(Vtx,li);
918 myEVIMap.ChangeFind(Vtx).Append(coin->Surf());
919 corner->SetSolidIndex(CD[pivot]->SolidIndex());
920 myListStripe.Append(corner);
923 ChFi3d_ResultChron(ch , t_t3cornerDS);// result perf update DS