1 // Created on: 1995-04-26
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <ChFi3d_FilBuilder.jxx>
24 #include <ChFi3d_Builder_0.hxx>
27 #include <Precision.hxx>
29 #include <Standard_Failure.hxx>
30 #include <Standard_NotImplemented.hxx>
31 #include <TColStd_ListOfInteger.hxx>
33 #include <math_Vector.hxx>
38 #include <gp_Pnt2d.hxx>
45 #include <TColgp_Array1OfPnt2d.hxx>
47 #include <Geom_Plane.hxx>
48 #include <Geom_Circle.hxx>
49 #include <Geom_BezierCurve.hxx>
50 #include <Geom2d_BezierCurve.hxx>
51 #include <Geom2d_Curve.hxx>
52 #include <Geom2d_TrimmedCurve.hxx>
53 #include <Geom2d_Line.hxx>
55 #include <IntAna_QuadQuadGeo.hxx>
56 #include <IntCurveSurface_IntersectionPoint.hxx>
59 #include <TopoDS_Shape.hxx>
60 #include <TopoDS_Face.hxx>
61 #include <TopoDS_Edge.hxx>
62 #include <TopoDS_Vertex.hxx>
64 #include <Adaptor3d_HSurface.hxx>
65 #include <Adaptor3d_CurveOnSurface.hxx>
66 #include <Adaptor3d_TopolTool.hxx>
67 #include <Geom2dAdaptor_Curve.hxx>
68 #include <Geom2dAdaptor_HCurve.hxx>
69 #include <GeomAdaptor_Curve.hxx>
70 #include <GeomAdaptor_HCurve.hxx>
71 #include <GeomAdaptor_Surface.hxx>
72 #include <GeomAdaptor_HSurface.hxx>
73 #include <BRepAdaptor_Curve.hxx>
74 #include <BRepAdaptor_HCurve.hxx>
75 #include <BRepAdaptor_Surface.hxx>
76 #include <BRepAdaptor_HSurface.hxx>
77 #include <BRepTopAdaptor_TopolTool.hxx>
80 #include <TopAbs_Orientation.hxx>
82 #include <ChFiDS_SurfData.hxx>
83 #include <ChFiDS_CommonPoint.hxx>
84 #include <ChFiDS_FaceInterference.hxx>
85 #include <ChFiDS_Spine.hxx>
86 #include <ChFiDS_SequenceOfSurfData.hxx>
87 #include <ChFiDS_Stripe.hxx>
88 #include <ChFiDS_HData.hxx>
89 #include <ChFiDS_ListIteratorOfListOfStripe.hxx>
90 #include <ChFiDS_Regul.hxx>
92 #include <TopOpeBRepDS_HDataStructure.hxx>
93 #include <TopOpeBRepDS_DataStructure.hxx>
94 #include <TopOpeBRepDS_Curve.hxx>
95 #include <TopOpeBRepDS_Surface.hxx>
97 #include <ChFiKPart_ComputeData.hxx>
98 #include <BRepBlend_Line.hxx>
99 #include <BRepBlend_ConstRad.hxx>
100 #include <BRepBlend_ConstRadInv.hxx>
101 #include <BRepBlend_EvolRad.hxx>
102 #include <BRepBlend_EvolRadInv.hxx>
106 #include <DrawTrSurf.hxx>
109 #include <Geom_TrimmedCurve.hxx>
110 extern Standard_Boolean ChFi3d_GettraceDRAWSPINE();
111 extern Standard_Boolean ChFi3d_GetcontextSPINEBEZIER();
112 extern Standard_Boolean ChFi3d_GetcontextSPINECIRCLE();
113 extern Standard_Boolean ChFi3d_GetcontextSPINECE();
114 extern Standard_Boolean ChFi3d_GetcontextFORCEFILLING();
115 #include <OSD_Chronometer.hxx>
117 extern Standard_Real t_t3cornerinit ,t_spherique,t_torique,
118 t_notfilling,t_filling,t_t3cornerDS;
119 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
120 extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
123 //=======================================================================
124 //function : SearchPivot
126 //=======================================================================
127 static Standard_Integer SearchPivot(Standard_Integer* s,
128 Standard_Real u[3][3],
129 const Standard_Real t)
131 Standard_Boolean bondeb,bonfin;
132 for(Standard_Integer i = 0; i <= 2; i++){
133 if(s[(i+1)%3] == 1){bondeb = (u[(i+1)%3][i]-u[(i+1)%3][(i+2)%3] >= -t);}
134 else {bondeb = (u[(i+1)%3][i]-u[(i+1)%3][(i+2)%3] <= t);}
135 if(s[(i+2)%3] == 1){bonfin = (u[(i+2)%3][i]-u[(i+2)%3][(i+1)%3] >= -t);}
136 else {bonfin = (u[(i+2)%3][i]-u[(i+2)%3][(i+1)%3] <= t);}
137 if (bondeb && bonfin){ return i; }
143 //=======================================================================
144 //function : SearchFD
146 //=======================================================================
147 static Standard_Boolean SearchFD(TopOpeBRepDS_DataStructure& DStr,
148 const Handle(ChFiDS_Stripe)& cd1,
149 const Handle(ChFiDS_Stripe)& cd2,
150 const Standard_Integer sens1,
151 const Standard_Integer sens2,
152 Standard_Integer& i1,
153 Standard_Integer& i2,
156 const Standard_Integer ind1,
157 const Standard_Integer ind2,
159 Standard_Boolean& sameside,
160 Standard_Integer& jf1,
161 Standard_Integer& jf2)
163 Standard_Boolean found = Standard_False;
164 Standard_Integer id1 = ind1, id2 = ind2;
165 Standard_Integer if1 = ind1, if2 = ind2;
166 Standard_Integer l1 = cd1->SetOfSurfData()->Length();
167 Standard_Integer l2 = cd2->SetOfSurfData()->Length();
169 Standard_Boolean fini1 = Standard_False, fini2 = Standard_False;
170 Standard_Boolean visavis;
173 for(i = id1; (i*sens1) <= (if1*sens1) && !found && !fini2; i = i+sens1 ){
174 if(ChFi3d_IsInFront(DStr,cd1,cd2,i,if2,sens1,sens2,p1,p2,face,sameside,jf1,jf2,visavis,Vtx,Standard_False,0)){
177 found = Standard_True;
182 if(if1 < 1 || if1 > l1){ if1 = if1 - sens1; fini1 = Standard_True; }
185 for(i = id2; (i*sens2) <= (if2*sens2) && !found && !fini1; i = i+sens2 ){
186 if(ChFi3d_IsInFront(DStr,cd1,cd2,if1,i,sens1,sens2,p1,p2,face,sameside,jf1,jf2,visavis,Vtx,Standard_False,0)){
189 found = Standard_True;
194 if(if2 < 1 || if2 > l2){ if2 = if2 - sens2; fini2 = Standard_True; }
196 if(fini1 && fini2) break;
202 //=======================================================================
203 //function : ToricCorner
204 //purpose : Test if this is a paricular cas of a torus corner
205 // (or spherical limited by isos).
206 //=======================================================================
208 static Standard_Boolean ToricCorner(const TopoDS_Face& F,
209 const Standard_Real rd,
210 const Standard_Real rf,
213 if(Abs(rd-rf) > Precision::Confusion()){ return Standard_False; }
214 BRepAdaptor_Surface bs(F);
215 if(bs.GetType() != GeomAbs_Plane){ return Standard_False; }
216 Standard_Real scal1 = Abs(bs.Plane().Position().XDirection().Dot(v));
217 Standard_Real scal2 = Abs(bs.Plane().Position().YDirection().Dot(v));
218 return (scal1 <= Precision::Confusion() &&
219 scal2 <= Precision::Confusion());
222 //=======================================================================
223 //function : PerformThreeCorner
224 //purpose : Calculate fillet on a top with three edges
225 // incident carrying each edge.
226 //=======================================================================
228 void ChFi3d_FilBuilder::PerformThreeCorner(const Standard_Integer Jndex)
233 ChFi3d_InitChron(ch); // init perf initialisation
236 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
237 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Jndex);
238 ChFiDS_ListIteratorOfListOfStripe It;
239 Standard_Integer Index[3],pivot,deb,fin,ii,jj,kk;
240 //Standard_Real R = 0.;
241 Standard_Boolean pivdif = Standard_True;
242 Standard_Boolean c1pointu = Standard_False;
243 Standard_Boolean c1toric = Standard_False;
244 Standard_Boolean c1spheric = Standard_False;
245 Handle(ChFiDS_Stripe) CD[3];
247 Standard_Integer jf[3][3];
248 Standard_Boolean sameside[3], oksea[3];
249 for(Standard_Integer g = 0; g <= 2; g++){oksea[g] = Standard_False;}
250 Standard_Integer i[3][3];
251 Standard_Integer sens[3];
252 Standard_Real p[3][3];
254 Standard_Boolean filling = 0;
256 for (It.Initialize(myVDataMap(Jndex)),ii=0;It.More() && ii<3;It.Next(),ii++){
257 Index[ii] = ChFi3d_IndexOfSurfData(Vtx,It.Value(),sens[ii]);
260 // It is checked if one of CD is not present twice in which
261 // case it is necessary to modify the return of IndexOfSurfData
262 // that takes the first solution.
264 Index[1] = CD[1]->SetOfSurfData()->Length();
267 else if(CD[1] == CD[2]){
268 Index[2] = CD[2]->SetOfSurfData()->Length();
271 else if(CD[0] == CD[2]){
272 Index[2] = CD[2]->SetOfSurfData()->Length();
275 oksea[2] = SearchFD(DStr,CD[0],CD[1],sens[0],sens[1],i[0][1],i[1][0],
276 p[0][1],p[1][0],Index[0],Index[1],face[2],sameside[2],
278 oksea[1] = SearchFD(DStr,CD[0],CD[2],sens[0],sens[2],i[0][2],i[2][0],
279 p[0][2],p[2][0],Index[0],Index[2],face[1],sameside[1],
281 oksea[0] = SearchFD(DStr,CD[1],CD[2],sens[1],sens[2],i[1][2],i[2][1],
282 p[1][2],p[2][1],Index[1],Index[2],face[0],sameside[0],
285 // Analyze concavities of 3 fillets :
286 // - 2 concavities identic and 1 inverted.
287 // - 3 concavities identic
289 if(oksea[2] && oksea[1] && !sameside[2] && !sameside[1])
290 { pivot = 0; deb = 1; fin = 2;}
291 else if(oksea[2] && oksea[0] && !sameside[2] && !sameside[0])
292 { pivot = 1; deb = 2; fin = 0;}
293 else if(oksea[1] && oksea[0] && !sameside[1] && !sameside[0])
294 { pivot = 2; deb = 0; fin = 1;}
295 else if(oksea[0] && oksea[1] && oksea[2]){
296 // 3 concavities identic.
297 pivot = SearchPivot(sens,p,tol2d);
300 cout<<"pivot not found, plate is called"<<endl;
302 PerformMoreThreeCorner(Jndex, 3);
305 else{deb = (pivot+1)%3 ; fin = (pivot+2)%3;}
306 pivdif = Standard_False;
307 if(Abs(p[0][1]-p[0][2]) <= tol2d &&
308 Abs(p[1][0]-p[1][2]) <= tol2d &&
309 Abs(p[2][0]-p[2][1]) <= tol2d){
310 c1pointu = Standard_True;
314 PerformMoreThreeCorner(Jndex, 3);
317 Standard_Integer ifacdeb, ifacfin;
318 ifacdeb = CD[deb]->ChangeSetOfSurfData()->Value(i[deb][pivot])->Index(3-jf[deb][pivot]);
319 ifacfin = CD[fin]->ChangeSetOfSurfData()->Value(i[fin][pivot])->Index(3-jf[fin][pivot]);
320 if(ifacfin != ifacdeb){
322 cout<<"several base faces, plate is called"<<endl;
324 PerformMoreThreeCorner(Jndex, 3);
327 if(i[pivot][deb] != i[pivot][fin]){
329 cout<<"load surfdata on the pivot, plate is called"<<endl;
331 PerformMoreThreeCorner(Jndex, 3);
335 Standard_Real Rdeb,Rfin,Rdp,Rfp;
336 gp_Pnt Pdeb,Pfin,Pdp,Pfp;
337 gp_Vec Vdeb,Vfin,Vdp,Vfp;
342 for(ii = 0; ii<=2; ii++){
343 jj = (ii+1)%3 ; kk = (ii+2)%3;
344 ChFi3d_ExtrSpineCarac(DStr,CD[jj],i[jj][ii],p[jj][ii],1,
345 sens[jj],pbid,qv[jj],qr[jj]);
347 for(ii = 0; ii<=2 && !c1toric; ii++){
348 jj = (ii+1)%3 ; kk = (ii+2)%3;
349 if(ToricCorner(face[ii],qr[jj],qr[kk],qv[ii])){
350 c1toric = Standard_True;
351 pivot = ii; deb = jj; fin = kk;
354 if(!c1toric)c1spheric=(Abs(qr[0]-qr[1])<tolesp && Abs(qr[0]-qr[2])<tolesp);
357 // Previously to avoid loops the points were always located
358 // inside, which could impede the construction of the
359 // guideline of the corner which now is a circle.
360 // Standard_Integer jjjd = jf[deb][fin], jjjf = jf[fin][deb];
361 // if (pivdif) jjjd = jf[deb][pivot], jjjf = jf[fin][pivot];
362 Standard_Integer jjjd = jf[deb][pivot], jjjf = jf[fin][pivot];
363 ChFi3d_ExtrSpineCarac(DStr,CD[deb],i[deb][pivot],p[deb][pivot],
364 jjjd,sens[deb],Pdeb,Vdeb,Rdeb);
365 ChFi3d_ExtrSpineCarac(DStr,CD[fin],i[fin][pivot],p[fin][pivot],
366 jjjf,sens[fin],Pfin,Vfin,Rfin);
367 ChFi3d_ExtrSpineCarac(DStr,CD[pivot],i[pivot][deb],p[pivot][deb],
368 0,sens[pivot],Pdp,Vdp,Rdp);
369 ChFi3d_ExtrSpineCarac(DStr,CD[pivot],i[pivot][fin],p[pivot][fin],
370 0,sens[pivot],Pfp,Vfp,Rfp);
371 //in cas of allsame it is checked that points on the face are not
372 //too close, which can stop the work.
374 gp_Pnt ptestdeb,ptestfin; gp_Vec bidvec; Standard_Real bidr;
375 ChFi3d_ExtrSpineCarac(DStr,CD[deb],i[deb][pivot],p[deb][pivot],
376 jf[deb][fin],sens[deb],ptestdeb,bidvec,bidr);
377 ChFi3d_ExtrSpineCarac(DStr,CD[fin],i[fin][pivot],p[fin][pivot],
378 jf[fin][deb],sens[fin],ptestfin,bidvec,bidr);
379 Standard_Real distest = ptestdeb.Distance(ptestfin);
380 if(distest < (Rdp+Rfp)*0.05) filling = 1;
381 if(distest < (Rdp+Rfp)*0.005) c1pointu = 1;
385 if (!pivdif) c1pointu = (Abs(p[deb][pivot]-p[deb][fin]) <=tol2d &&
386 Abs(p[fin][pivot]-p[fin][deb]) <=tol2d);
387 if(Abs(p[pivot][deb] - p[pivot][fin]) <= tol2d)
388 c1toric = ToricCorner(face[pivot],Rdeb,Rfin,Vdp);
390 // there is a pivot, the start and the end CD (finally !?!) :
391 // -------------------------------------------------------------
392 // the criterions determining if the corner is a torus or a sphere
393 // are based only on the configuration of sections at end and the
394 // nature of faces, it is necessary to make tests to
395 // determine if a more detailed analysis of incident fillets
396 // is necessare to provide tangency between them and
397 // the corner (in particular in the case with variable radius).
401 Handle(ChFiDS_SurfData)&
402 fddeb = CD[deb]->ChangeSetOfSurfData()->ChangeValue(i[deb][pivot]);
403 Handle(ChFiDS_SurfData)&
404 fdfin = CD[fin]->ChangeSetOfSurfData()->ChangeValue(i[fin][pivot]);
405 Handle(ChFiDS_SurfData)&
406 fdpiv = CD[pivot]->ChangeSetOfSurfData()->ChangeValue(i[pivot][deb]);
409 // HSurfaces and other suitable tools are constructed.
410 // ----------------------------------------------------------
412 TopAbs_Orientation OFac = face[pivot].Orientation();
413 Handle(BRepAdaptor_HSurface) Fac = new BRepAdaptor_HSurface(face[pivot]);
415 const ChFiDS_FaceInterference& bid1 = CD[pivot]->SetOfSurfData()->
416 Value(i[pivot][deb])->InterferenceOnS1();
417 ppp1 = bid1.PCurveOnSurf()->Value(bid1.FirstParameter());
418 const ChFiDS_FaceInterference& bid2 = CD[pivot]->SetOfSurfData()->
419 Value(i[pivot][deb])->InterferenceOnS2();
420 ppp2 = bid2.PCurveOnSurf()->Value(bid2.LastParameter());
421 Standard_Real uu1 = ppp1.X(), uu2 = ppp2.X(), vv1 = ppp1.Y(), vv2 = ppp2.Y();
423 gasurf((DStr.Surface(CD[pivot]->SetOfSurfData()->
424 Value(i[pivot][deb])->Surf())).Surface(),
426 GeomAbs_SurfaceType styp = gasurf.GetType();
427 if(styp == GeomAbs_Cylinder){
428 Standard_Real h = vv2 - vv1;
431 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
432 Value(i[pivot][deb])->Surf())).Surface(),
435 else if(styp == GeomAbs_Torus){
436 Standard_Real h = uu2 - uu1;
439 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
440 Value(i[pivot][deb])->Surf())).Surface(),
443 else if(styp == GeomAbs_BezierSurface || styp == GeomAbs_BSplineSurface){
444 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
445 Value(i[pivot][deb])->Surf())).Surface());
448 Handle(GeomAdaptor_HSurface) Surf = new GeomAdaptor_HSurface(gasurf);
449 // Handle(BRepTopAdaptor_TopolTool) IFac = new BRepTopAdaptor_TopolTool(Fac);
450 // Try to not classify on the face for cases of reentering fillets which naturally depass
452 Handle(GeomAdaptor_HSurface)
453 bidsurf = new GeomAdaptor_HSurface(Fac->ChangeSurface().Surface());
454 Handle(Adaptor3d_TopolTool)
455 IFac = new Adaptor3d_TopolTool(bidsurf);
456 // end of the attempt.
457 Handle(Adaptor3d_TopolTool) ISurf = new Adaptor3d_TopolTool(Surf);
458 Handle(ChFiDS_Stripe) corner = new ChFiDS_Stripe();
459 Handle(ChFiDS_HData)& cornerset = corner->ChangeSetOfSurfData();
460 cornerset = new ChFiDS_HData();
461 Handle(ChFiDS_SurfData) coin = new ChFiDS_SurfData();
462 cornerset->Append(coin);
463 TopAbs_Orientation o1,o2,os1,os2,oo1,oo2;
464 Standard_Integer choix = CD[deb]->Choix();
465 o1 = face[pivot].Orientation();
466 o2 = fdpiv->Orientation();
468 os1 = CD[deb]->OrientationOnFace1();
469 os2 = CD[deb]->OrientationOnFace2();
470 if(jf[deb][fin] == 1){
471 choix = ChFi3d::NextSide(o1,o2,os1,os2,choix);
473 if(choix%2 == 1) choix++;
478 choix = ChFi3d::NextSide(o2,o1,os1,os2,-choix);
480 if(choix%2 == 1) choix++;
485 gp_Pnt2d pfac1,pfac2,psurf1,psurf2;
486 gp_Vec2d vfac1,vfac2;
487 CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
488 Interference(jf[deb][fin]).PCurveOnFace()->D1(p[deb][pivot],pfac1,vfac1);
489 CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
490 Interference(jf[fin][deb]).PCurveOnFace()->D1(p[fin][pivot],pfac2,vfac2);
491 psurf1 = CD[pivot]->SetOfSurfData()->Value(i[pivot][deb])->
492 Interference(jf[pivot][deb]).PCurveOnSurf()->Value(p[pivot][deb]);
493 psurf2 = CD[pivot]->SetOfSurfData()->Value(i[pivot][fin])->
494 Interference(jf[pivot][fin]).PCurveOnSurf()->Value(p[pivot][fin]);
496 done = Standard_False;
498 if(ChFi3d_GetcontextFORCEFILLING()) c1spheric = c1toric = 0;
502 ChFi3d_ResultChron(ch , t_t3cornerinit); // result perf initialisations
508 ChFi3d_InitChron(ch); // init perf case torus
511 // Direct Construction.
512 // ---------------------
513 done = ChFiKPart_ComputeData::ComputeCorner
514 (DStr,coin,Fac,Surf,oo1,oo2,o1,o2,Rdeb,Rdp,pfac1,pfac2,psurf1,psurf2);
517 ChFi3d_ResultChron(ch , t_torique); // result perf case torus
524 ChFi3d_InitChron(ch); //init perf case sphere
527 done = ChFiKPart_ComputeData::ComputeCorner
528 (DStr,coin,Fac,Surf,oo1,oo2,o1,o2,Rdp,pfac1,psurf1,psurf2);
531 ChFi3d_ResultChron(ch , t_spherique);// result perf cas sphere
542 ChFi3d_InitChron(ch);// init perf not filling
545 //Calculate a guideline,
546 //------------------------------
547 //Numerous problems with loops and half-turns connected to
548 //the curvature of the guideline !!!!!!
550 //If the nature of guideline is changed it is necessary to
551 //reset points Pdeb and Pfin at the inside (see the
552 //comments about it in the calculation of Pdeb and Pfin).
554 Standard_Real radpondere = (Rdp+Rfp)/2.;
555 Standard_Real locfleche = fleche;
557 Standard_Real WFirst,WLast;
558 Handle(Geom_Curve) spinecoin = ChFi3d_CircularSpine(WFirst,WLast,
560 Pfin,Vfin,radpondere);
561 if(spinecoin.IsNull()){
562 // This is a bad case when the intersection of
563 // section planes is done out of the sector.
564 spinecoin = ChFi3d_Spine(Pdeb,Vdeb,
565 Pfin,Vfin,radpondere);
566 WFirst = 0.; WLast = 1.;
568 else locfleche = radpondere * (WLast - WFirst) * fleche;
569 Standard_Real pasmax = (WLast-WFirst)*0.05;
570 Handle(ChFiDS_HElSpine) cornerspine = new ChFiDS_HElSpine();
571 cornerspine->ChangeCurve().SetCurve(spinecoin);
572 cornerspine->ChangeCurve().FirstParameter(WFirst - pasmax);
573 cornerspine->ChangeCurve().LastParameter(WLast + pasmax);
574 // Just to confuse Compute that should not require this
575 // in this exact case ...
576 Handle(ChFiDS_Spine) NullSpine;
577 // The fillet is calculated - from beginning to end
578 // - from the face to the surface
580 math_Vector Soldep(1,4);
581 Soldep(1) = pfac1.X();
582 Soldep(2) = pfac1.Y();
583 Soldep(3) = psurf1.X();
584 Soldep(4) = psurf1.Y();
586 Standard_Boolean Gd1,Gd2,Gf1,Gf2;
587 Handle(BRepBlend_Line) lin;
588 Standard_Real ffi = WFirst, lla = WLast + pasmax;
590 if (Abs(Rdeb-Rfin)<=tolesp){
592 BRepBlend_ConstRad func(Fac,Surf,cornerspine);
593 BRepBlend_ConstRadInv finv(Fac,Surf,cornerspine);
594 func.Set(Rdeb,choix);
596 finv.Set(Rdeb,choix);
597 Standard_Real TolGuide = cornerspine->Resolution(tolesp);
599 Standard_Boolean intf = 3, intl = 3;
600 done = ComputeData(coin,cornerspine,NullSpine,lin,Fac,IFac,Surf,ISurf,
601 func,finv,ffi,pasmax,locfleche,TolGuide,ffi,lla,
602 0,0,1,Soldep,intf,intl,Gd1,Gd2,Gf1,Gf2,0,1);
604 if(ChFi3d_GetcontextFORCEFILLING()) done = 0;
607 done = CompleteData(coin,func,lin,Fac,Surf,OFac,Gd1,0,Gf1,0);
613 Handle(Law_S) law = new Law_S();
614 law->Set(WFirst,Rdeb,WLast,Rfin);
615 BRepBlend_EvolRad func(Fac,Surf,cornerspine,law);
616 BRepBlend_EvolRadInv finv(Fac,Surf,cornerspine,law);
620 Standard_Real TolGuide = cornerspine->Resolution(tolesp);
621 Standard_Boolean intf = 3, intl = 3;
622 done = ComputeData(coin,cornerspine,NullSpine,lin,Fac,IFac,Surf,ISurf,
623 func,finv,ffi,pasmax,locfleche,TolGuide,ffi,lla,
624 0,0,1,Soldep,intf,intl,Gd1,Gd2,Gf1,Gf2,0,1);
626 if(ChFi3d_GetcontextFORCEFILLING()) done = 0;
629 done = CompleteData(coin,func,lin,Fac,Surf,OFac,Gd1,0,Gf1,0);
636 ChFi3d_ResultChron(ch , t_notfilling);// result perf not filling
644 ChFi3d_InitChron(ch); // init perf filling
647 // the contour to be fillet consists of straight lines uv in beginning and end
648 // of two pcurves (only one if c1pointu) calculted as possible
649 // on piv and the opposite face.
650 Handle(GeomFill_Boundary) Bdeb,Bfin,Bpiv,Bfac;
651 Handle(Geom2d_Curve) PCurveOnFace;
653 Bfac = ChFi3d_mkbound(Fac,PCurveOnFace,sens[deb],pfac1,vfac1,
654 sens[fin],pfac2,vfac2,tolesp,2.e-4);
655 Standard_Integer kkk;
658 kkk = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
659 Interference(jf[deb][pivot]).LineIndex();
660 DStr.Curve(kkk).Curve()->D1(p[deb][pivot],ppbid,vp1);
661 kkk = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
662 Interference(jf[fin][pivot]).LineIndex();
663 DStr.Curve(kkk).Curve()->D1(p[fin][pivot],ppbid,vp2);
664 Handle(Geom2d_Curve) PCurveOnPiv;
665 // Bpiv = ChFi3d_mkbound(Surf,PCurveOnPiv,sens[deb],psurf1,vp1,
666 // sens[fin],psurf2,vp2,tolesp,2.e-4);
667 Bpiv = ChFi3d_mkbound(Surf,PCurveOnPiv,psurf1,psurf2,tolesp,2.e-4,0);
668 Standard_Real pardeb2 = p[deb][pivot];
669 Standard_Real parfin2 = p[fin][pivot];
671 pardeb2 = p[deb][fin];
672 parfin2 = p[fin][deb];
674 gp_Pnt2d pdeb1 = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
675 Interference(jf[deb][pivot]).PCurveOnSurf()->Value(p[deb][pivot]);
676 gp_Pnt2d pdeb2 = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
677 Interference(jf[deb][fin]).PCurveOnSurf()->Value(pardeb2);
678 gp_Pnt2d pfin1 = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
679 Interference(jf[fin][pivot]).PCurveOnSurf()->Value(p[fin][pivot]);
680 gp_Pnt2d pfin2 = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
681 Interference(jf[fin][deb]).PCurveOnSurf()->Value(parfin2);
682 Handle(Geom_Surface) sdeb =
683 DStr.Surface(CD[deb]->SetOfSurfData()->
684 Value(i[deb][pivot])->Surf()).Surface();
685 Handle(Geom_Surface) sfin =
686 DStr.Surface(CD[fin]->SetOfSurfData()->
687 Value(i[fin][pivot])->Surf()).Surface();
689 Bdeb = ChFi3d_mkbound(sdeb,pdeb1,pdeb2,tolesp,2.e-4);
690 Bfin = ChFi3d_mkbound(sfin,pfin1,pfin2,tolesp,2.e-4);
692 GeomFill_ConstrainedFilling fil(11,20);
693 if(c1pointu) fil.Init(Bpiv,Bfin,Bdeb,1);
694 else fil.Init(Bpiv,Bfin,Bfac,Bdeb,1);
696 Handle(Geom_Surface) Surfcoin = fil.Surface();
697 Surfcoin->VReverse(); // revert to direction face surface;
698 done = CompleteData(coin,Surfcoin,
700 Surf,PCurveOnPiv,fdpiv->Orientation(),0,
704 ChFi3d_ResultChron(ch , t_filling);// result perf filling
709 Standard_Real P1deb,P2deb,P1fin,P2fin;
711 p[deb][fin] = p[deb][pivot];
712 p[fin][deb] = p[fin][pivot];
716 // Update of 4 Stripes and the DS
717 // -------------------------------------
720 ChFi3d_InitChron(ch);// init perf update DS
724 Standard_Real parpp1,parpp2;
725 Standard_Integer If1,If2,Il1,Il2,Icf,Icl;
726 const ChFiDS_CommonPoint& Pf1 = coin->VertexFirstOnS1();
727 const ChFiDS_CommonPoint& Pf2 = coin->VertexFirstOnS2();
728 ChFiDS_CommonPoint& Pl1 = coin->ChangeVertexLastOnS1();
729 if(c1pointu) Pl1 = coin->ChangeVertexFirstOnS1();
730 const ChFiDS_CommonPoint& Pl2 = coin->VertexLastOnS2();
732 Bnd_Box bf1,bl1,bf2,bl2;
733 Bnd_Box *pbf1 = &bf1,*pbl1 = &bl1,*pbf2 = &bf2,*pbl2 = &bl2;
734 if(c1pointu) pbl1 = pbf1;
735 pbf1->Add(Pf1.Point());pbf2->Add(Pf2.Point());
736 pbl1->Add(Pl1.Point());pbl2->Add(Pl2.Point());
739 // -----------------------
740 ChFiDS_Regul regdeb, regfin;
741 If1 = ChFi3d_IndexPointInDS(Pf1,DStr);
742 If2 = ChFi3d_IndexPointInDS(Pf2,DStr);
743 if(c1pointu) Il1 = If1;
744 else Il1 = ChFi3d_IndexPointInDS(Pl1,DStr);
745 Il2 = ChFi3d_IndexPointInDS(Pl2,DStr);
746 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
747 Value(coin->InterferenceOnS1().FirstParameter());
748 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
749 Value(coin->InterferenceOnS2().FirstParameter());
750 if(c1pointu) coin->ChangeIndexOfS1(0);
751 else coin->ChangeIndexOfS1(DStr.AddShape(face[pivot]));
752 coin->ChangeIndexOfS2(-fdpiv->Surf());
754 Handle(Geom_Curve) C3d;
755 Standard_Real tolreached;
756 ChFi3d_ComputeArete(Pf1,pp1,Pf2,pp2,
757 DStr.Surface(coin->Surf()).Surface(),C3d,
758 corner->ChangeFirstPCurve(),P1deb,P2deb,
759 tolesp,tol2d,tolreached,0);
760 TopOpeBRepDS_Curve Tcurv1(C3d,tolreached);
761 Icf = DStr.AddCurve(Tcurv1);
762 regdeb.SetCurve(Icf);
763 regdeb.SetS1(coin->Surf(),0);
764 regdeb.SetS2(fddeb->Surf(),0);
765 myRegul.Append(regdeb);
766 corner->ChangeFirstCurve(Icf);
767 corner->ChangeFirstParameters(P1deb,P2deb);
768 corner->ChangeIndexFirstPointOnS1(If1);
769 corner->ChangeIndexFirstPointOnS2(If2);
770 ChFi3d_EnlargeBox(DStr,corner,coin,*pbf1,*pbf2,1);
772 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
773 Value(coin->InterferenceOnS1().LastParameter());
774 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
775 Value(coin->InterferenceOnS2().LastParameter());
776 ChFi3d_ComputeArete(Pl1,pp1,Pl2,pp2,
777 DStr.Surface(coin->Surf()).Surface(),C3d,
778 corner->ChangeLastPCurve(),P1fin,P2fin,
779 tolesp,tol2d,tolreached,0);
780 TopOpeBRepDS_Curve Tcurv2(C3d,tolreached);
781 Icl = DStr.AddCurve(Tcurv2);
782 regfin.SetCurve(Icl);
783 regfin.SetS1(coin->Surf(),0);
784 regfin.SetS2(fdfin->Surf(),0);
785 myRegul.Append(regfin);
786 corner->ChangeLastCurve(Icl);
787 corner->ChangeLastParameters(P1fin,P2fin);
788 corner->ChangeIndexLastPointOnS1(Il1);
789 corner->ChangeIndexLastPointOnS2(Il2);
790 ChFi3d_EnlargeBox(DStr,corner,coin,*pbl1,*pbl2,0);
792 // then CornerData of the beginning,
793 // --------------------------------
794 Standard_Boolean isfirst = (sens[deb] == 1), rev = (jf[deb][fin] == 2);
795 Standard_Integer isurf1 = 1, isurf2 = 2;
796 parpp1 = p[deb][fin]; parpp2 = p[deb][pivot];
798 isurf1 = 2; isurf2 = 1;
799 parpp1 = p[deb][pivot]; parpp2 = p[deb][fin];
800 CD[deb]->SetOrientation(TopAbs_REVERSED,isfirst);
802 pp1 = fddeb->InterferenceOnS1().PCurveOnSurf()->Value(parpp1);
803 pp2 = fddeb->InterferenceOnS2().PCurveOnSurf()->Value(parpp2);
804 CD[deb]->SetCurve(Icf,isfirst);
805 CD[deb]->SetIndexPoint(If1,isfirst,isurf1);
806 CD[deb]->SetIndexPoint(If2,isfirst,isurf2);
807 CD[deb]->SetParameters(isfirst,P1deb,P2deb);
808 fddeb->ChangeVertex(isfirst,isurf1) = Pf1;
809 fddeb->ChangeVertex(isfirst,isurf2) = Pf2;
810 fddeb->ChangeInterferenceOnS1().SetParameter(parpp1,isfirst);
811 fddeb->ChangeInterferenceOnS2().SetParameter(parpp2,isfirst);
812 TopOpeBRepDS_Curve& tcdeb = DStr.ChangeCurve(Icf);
813 Handle(Geom_Curve) crefdeb = tcdeb.Curve();
814 Standard_Real tolrdeb;
815 ChFi3d_ComputePCurv(crefdeb,pp1,pp2,CD[deb]->ChangePCurve(isfirst),
816 DStr.Surface(fddeb->Surf()).Surface(),
817 P1deb,P2deb,tolesp,tolrdeb,rev);
818 tcdeb.Tolerance(Max(tolrdeb,tcdeb.Tolerance()));
819 if(rev) ChFi3d_EnlargeBox(DStr,CD[deb],fddeb,*pbf2,*pbf1,isfirst);
820 else ChFi3d_EnlargeBox(DStr,CD[deb],fddeb,*pbf1,*pbf2,isfirst);
822 // then the end CornerData,
823 // ------------------------
824 isfirst = (sens[fin] == 1); rev = (jf[fin][deb] == 2);
825 isurf1 = 1; isurf2 = 2;
826 parpp1 = p[fin][deb]; parpp2 = p[fin][pivot];
828 isurf1 = 2; isurf2 = 1;
829 parpp1 = p[fin][pivot]; parpp2 = p[fin][deb];
830 CD[fin]->SetOrientation(TopAbs_REVERSED,isfirst);
832 pp1 = fdfin->InterferenceOnS1().PCurveOnSurf()->Value(parpp1);
833 pp2 = fdfin->InterferenceOnS2().PCurveOnSurf()->Value(parpp2);
834 CD[fin]->SetCurve(Icl,isfirst);
835 CD[fin]->SetIndexPoint(Il1,isfirst,isurf1);
836 CD[fin]->SetIndexPoint(Il2,isfirst,isurf2);
837 CD[fin]->SetParameters(isfirst,P1fin,P2fin);
838 fdfin->ChangeVertex(isfirst,isurf1) = Pl1;
839 fdfin->ChangeVertex(isfirst,isurf2) = Pl2;
840 fdfin->ChangeInterferenceOnS1().SetParameter(parpp1,isfirst);
841 fdfin->ChangeInterferenceOnS2().SetParameter(parpp2,isfirst);
842 TopOpeBRepDS_Curve& tcfin = DStr.ChangeCurve(Icl);
843 Handle(Geom_Curve) creffin = tcfin.Curve();
844 Standard_Real tolrfin;
845 ChFi3d_ComputePCurv(creffin,pp1,pp2,CD[fin]->ChangePCurve(isfirst),
846 DStr.Surface(fdfin->Surf()).Surface(),
847 P1fin,P2fin,tolesp,tolrfin,rev);
848 tcfin.Tolerance(Max(tolrfin,tcfin.Tolerance()));
849 if(rev) ChFi3d_EnlargeBox(DStr,CD[fin],fdfin,*pbl2,*pbl1,isfirst);
850 else ChFi3d_EnlargeBox(DStr,CD[fin],fdfin,*pbl1,*pbl2,isfirst);
852 // anf finally the pivot.
853 // ------------------
854 ChFiDS_FaceInterference& fi = coin->ChangeInterferenceOnS2();
855 isfirst = (sens[pivot] == 1); rev = (jf[pivot][deb] == 2);
856 isurf1 = 1; isurf2 = 2;
858 isurf1 = 2; isurf2 = 1;
859 CD[pivot]->SetOrientation(TopAbs_REVERSED,isfirst);
861 Standard_Integer ICcoinpiv = fi.LineIndex();
862 TopOpeBRepDS_Curve& TCcoinpiv = DStr.ChangeCurve(ICcoinpiv);
863 CD[pivot]->SetCurve(ICcoinpiv,isfirst);
864 Handle(Geom_Curve) Ccoinpiv = DStr.Curve(ICcoinpiv).Curve();
865 Handle(Geom2d_Curve)& C2dOnPiv = fi.ChangePCurveOnFace();
866 Handle(Geom_Surface) Spiv = DStr.Surface(fdpiv->Surf()).Surface();
868 ChFi3d_SameParameter(Ccoinpiv,C2dOnPiv,Spiv,
869 fi.FirstParameter(),fi.LastParameter(),
871 TCcoinpiv.Tolerance(Max(TCcoinpiv.Tolerance(),tolr));
872 CD[pivot]->ChangePCurve(isfirst) = C2dOnPiv;
873 CD[pivot]->SetIndexPoint(If2,isfirst,isurf1);
874 CD[pivot]->SetIndexPoint(Il2,isfirst,isurf2);
875 CD[pivot]->SetParameters(isfirst,fi.FirstParameter(),fi.LastParameter());
876 fdpiv->ChangeVertex(isfirst,isurf1) = Pf2;
877 fdpiv->ChangeVertex(isfirst,isurf2) = Pl2;
878 fdpiv->ChangeInterference(isurf1).SetParameter(p[pivot][deb],isfirst);
879 fdpiv->ChangeInterference(isurf2).SetParameter(p[pivot][fin],isfirst);
880 CD[pivot]->InDS(isfirst); // filDS already does it from the corner.
881 if(rev) ChFi3d_EnlargeBox(DStr,CD[pivot],fdpiv,*pbl2,*pbf2,isfirst);
882 else ChFi3d_EnlargeBox(DStr,CD[pivot],fdpiv,*pbf2,*pbl2,isfirst);
884 //To end the tolerances of points are rescaled.
885 ChFi3d_SetPointTolerance(DStr,*pbf1,If1);
886 ChFi3d_SetPointTolerance(DStr,*pbf2,If2);
887 ChFi3d_SetPointTolerance(DStr,*pbl1,Il1);
888 ChFi3d_SetPointTolerance(DStr,*pbl2,Il2);
891 //The data corners are truncated and index is updated.
892 //----------------------------------------------------
894 if(i[deb][pivot] < Index[deb]){
895 CD[deb]->ChangeSetOfSurfData()->Remove(i[deb][pivot]+1,Index[deb]);
896 Index[deb] = i[deb][pivot];
898 else if(i[deb][pivot] > Index[deb]) {
899 CD[deb]->ChangeSetOfSurfData()->Remove(Index[deb],i[deb][pivot]-1);
900 i[deb][pivot] = Index[deb];
902 if(i[fin][pivot] < Index[fin]) {
903 CD[fin]->ChangeSetOfSurfData()->Remove(i[fin][pivot]+1,Index[fin]);
904 Index[fin] = i[fin][pivot];
906 else if(i[fin][pivot] > Index[fin]) {
907 CD[fin]->ChangeSetOfSurfData()->Remove(Index[fin],i[fin][pivot]-1);
908 i[fin][pivot] = Index[fin];
910 // it is necessary to take into account mutant corners.
911 if(i[pivot][deb] < Index[pivot]) {
912 CD[pivot]->ChangeSetOfSurfData()->Remove(i[pivot][deb]+1,Index[pivot]);
913 Index[pivot] = i[pivot][deb];
915 else if(i[pivot][deb] > Index[pivot]) {
916 CD[pivot]->ChangeSetOfSurfData()->Remove(Index[pivot],i[pivot][deb]-1);
917 i[pivot][deb] = Index[pivot];
919 if(!myEVIMap.IsBound(Vtx)){
920 TColStd_ListOfInteger li;
921 myEVIMap.Bind(Vtx,li);
923 myEVIMap.ChangeFind(Vtx).Append(coin->Surf());
924 corner->SetSolidIndex(CD[pivot]->SolidIndex());
925 myListStripe.Append(corner);
928 ChFi3d_ResultChron(ch , t_t3cornerDS);// result perf update DS