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 <BRepBlend_ConstRad.hxx>
20 #include <BRepBlend_ConstRadInv.hxx>
21 #include <BRepBlend_EvolRad.hxx>
22 #include <BRepBlend_EvolRadInv.hxx>
23 #include <BRepBlend_Line.hxx>
24 #include <BRepTopAdaptor_TopolTool.hxx>
26 #include <ChFi3d_Builder_0.hxx>
27 #include <ChFi3d_FilBuilder.hxx>
28 #include <ChFiDS_CommonPoint.hxx>
29 #include <ChFiDS_FaceInterference.hxx>
30 #include <ChFiDS_HData.hxx>
31 #include <ChFiDS_ElSpine.hxx>
32 #include <ChFiDS_Regul.hxx>
33 #include <ChFiDS_Spine.hxx>
34 #include <ChFiDS_Stripe.hxx>
35 #include <ChFiDS_SurfData.hxx>
36 #include <ChFiKPart_ComputeData.hxx>
38 #include <Geom2d_Curve.hxx>
39 #include <Geom_BSplineSurface.hxx>
40 #include <GeomAdaptor_Surface.hxx>
41 #include <GeomFill_ConstrainedFilling.hxx>
45 #include <gp_Pnt2d.hxx>
48 #include <math_Vector.hxx>
49 #include <Precision.hxx>
50 #include <Standard_NotImplemented.hxx>
51 #include <TColStd_ListOfInteger.hxx>
52 #include <TopAbs_Orientation.hxx>
53 #include <TopoDS_Face.hxx>
54 #include <TopoDS_Shape.hxx>
55 #include <TopoDS_Vertex.hxx>
56 #include <TopOpeBRepDS_Curve.hxx>
57 #include <TopOpeBRepDS_DataStructure.hxx>
58 #include <TopOpeBRepDS_HDataStructure.hxx>
59 #include <TopOpeBRepDS_Surface.hxx>
62 #include <DrawTrSurf.hxx>
65 #include <Geom_TrimmedCurve.hxx>
66 extern Standard_Boolean ChFi3d_GettraceDRAWSPINE();
67 extern Standard_Boolean ChFi3d_GetcontextSPINEBEZIER();
68 extern Standard_Boolean ChFi3d_GetcontextSPINECIRCLE();
69 extern Standard_Boolean ChFi3d_GetcontextSPINECE();
70 extern Standard_Boolean ChFi3d_GetcontextFORCEFILLING();
71 #include <OSD_Chronometer.hxx>
73 extern Standard_Real t_t3cornerinit ,t_spherique,t_torique,
74 t_notfilling,t_filling,t_t3cornerDS;
75 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
76 extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
79 //=======================================================================
80 //function : SearchPivot
82 //=======================================================================
83 static Standard_Integer SearchPivot(Standard_Integer* s,
84 Standard_Real u[3][3],
85 const Standard_Real t)
87 Standard_Boolean bondeb,bonfin;
88 for(Standard_Integer i = 0; i <= 2; i++){
89 if(s[(i+1)%3] == 1){bondeb = (u[(i+1)%3][i]-u[(i+1)%3][(i+2)%3] >= -t);}
90 else {bondeb = (u[(i+1)%3][i]-u[(i+1)%3][(i+2)%3] <= t);}
91 if(s[(i+2)%3] == 1){bonfin = (u[(i+2)%3][i]-u[(i+2)%3][(i+1)%3] >= -t);}
92 else {bonfin = (u[(i+2)%3][i]-u[(i+2)%3][(i+1)%3] <= t);}
93 if (bondeb && bonfin){ return i; }
99 //=======================================================================
100 //function : SearchFD
102 //=======================================================================
103 static Standard_Boolean SearchFD(TopOpeBRepDS_DataStructure& DStr,
104 const Handle(ChFiDS_Stripe)& cd1,
105 const Handle(ChFiDS_Stripe)& cd2,
106 const Standard_Integer sens1,
107 const Standard_Integer sens2,
108 Standard_Integer& i1,
109 Standard_Integer& i2,
112 const Standard_Integer ind1,
113 const Standard_Integer ind2,
115 Standard_Boolean& sameside,
116 Standard_Integer& jf1,
117 Standard_Integer& jf2)
119 Standard_Boolean found = Standard_False;
120 Standard_Integer id1 = ind1, id2 = ind2;
121 Standard_Integer if1 = ind1, if2 = ind2;
122 Standard_Integer l1 = cd1->SetOfSurfData()->Length();
123 Standard_Integer l2 = cd2->SetOfSurfData()->Length();
125 Standard_Boolean fini1 = Standard_False, fini2 = Standard_False;
126 Standard_Boolean visavis;
129 for(i = id1; (i*sens1) <= (if1*sens1) && !found && !fini2; i = i+sens1 ){
130 if(ChFi3d_IsInFront(DStr,cd1,cd2,i,if2,sens1,sens2,p1,p2,face,sameside,jf1,jf2,visavis,Vtx,Standard_False,0)){
133 found = Standard_True;
138 if(if1 < 1 || if1 > l1){ if1 = if1 - sens1; fini1 = Standard_True; }
141 for(i = id2; (i*sens2) <= (if2*sens2) && !found && !fini1; i = i+sens2 ){
142 if(ChFi3d_IsInFront(DStr,cd1,cd2,if1,i,sens1,sens2,p1,p2,face,sameside,jf1,jf2,visavis,Vtx,Standard_False,0)){
145 found = Standard_True;
150 if(if2 < 1 || if2 > l2){ if2 = if2 - sens2; fini2 = Standard_True; }
152 if(fini1 && fini2) break;
158 //=======================================================================
159 //function : ToricCorner
160 //purpose : Test if this is a paricular cas of a torus corner
161 // (or spherical limited by isos).
162 //=======================================================================
164 static Standard_Boolean ToricCorner(const TopoDS_Face& F,
165 const Standard_Real rd,
166 const Standard_Real rf,
169 if(Abs(rd-rf) > Precision::Confusion()){ return Standard_False; }
170 BRepAdaptor_Surface bs(F);
171 if(bs.GetType() != GeomAbs_Plane){ return Standard_False; }
172 Standard_Real scal1 = Abs(bs.Plane().Position().XDirection().Dot(v));
173 Standard_Real scal2 = Abs(bs.Plane().Position().YDirection().Dot(v));
174 return (scal1 <= Precision::Confusion() &&
175 scal2 <= Precision::Confusion());
178 //=======================================================================
179 //function : PerformThreeCorner
180 //purpose : Calculate fillet on a top with three edges
181 // incident carrying each edge.
182 //=======================================================================
184 void ChFi3d_FilBuilder::PerformThreeCorner(const Standard_Integer Jndex)
189 ChFi3d_InitChron(ch); // init perf initialisation
192 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
193 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Jndex);
194 ChFiDS_ListIteratorOfListOfStripe It;
195 Standard_Integer Index[3],pivot,deb,fin,ii,jj,kk;
196 //Standard_Real R = 0.;
197 Standard_Boolean pivdif = Standard_True;
198 Standard_Boolean c1pointu = Standard_False;
199 Standard_Boolean c1toric = Standard_False;
200 Standard_Boolean c1spheric = Standard_False;
201 Handle(ChFiDS_Stripe) CD[3];
203 Standard_Integer jf[3][3];
204 Standard_Boolean sameside[3], oksea[3];
205 for(Standard_Integer g = 0; g <= 2; g++){oksea[g] = Standard_False;}
206 Standard_Integer i[3][3];
207 Standard_Integer sens[3];
208 Standard_Real p[3][3];
210 Standard_Boolean filling = 0;
212 for (It.Initialize(myVDataMap(Jndex)),ii=0;It.More() && ii<3;It.Next(),ii++){
213 Index[ii] = ChFi3d_IndexOfSurfData(Vtx,It.Value(),sens[ii]);
216 // It is checked if one of CD is not present twice in which
217 // case it is necessary to modify the return of IndexOfSurfData
218 // that takes the first solution.
220 Index[1] = CD[1]->SetOfSurfData()->Length();
223 else if(CD[1] == CD[2]){
224 Index[2] = CD[2]->SetOfSurfData()->Length();
227 else if(CD[0] == CD[2]){
228 Index[2] = CD[2]->SetOfSurfData()->Length();
231 oksea[2] = SearchFD(DStr,CD[0],CD[1],sens[0],sens[1],i[0][1],i[1][0],
232 p[0][1],p[1][0],Index[0],Index[1],face[2],sameside[2],
234 oksea[1] = SearchFD(DStr,CD[0],CD[2],sens[0],sens[2],i[0][2],i[2][0],
235 p[0][2],p[2][0],Index[0],Index[2],face[1],sameside[1],
237 oksea[0] = SearchFD(DStr,CD[1],CD[2],sens[1],sens[2],i[1][2],i[2][1],
238 p[1][2],p[2][1],Index[1],Index[2],face[0],sameside[0],
241 // Analyze concavities of 3 fillets :
242 // - 2 concavities identic and 1 inverted.
243 // - 3 concavities identic
245 if(oksea[2] && oksea[1] && !sameside[2] && !sameside[1])
246 { pivot = 0; deb = 1; fin = 2;}
247 else if(oksea[2] && oksea[0] && !sameside[2] && !sameside[0])
248 { pivot = 1; deb = 2; fin = 0;}
249 else if(oksea[1] && oksea[0] && !sameside[1] && !sameside[0])
250 { pivot = 2; deb = 0; fin = 1;}
251 else if(oksea[0] && oksea[1] && oksea[2]){
252 // 3 concavities identic.
253 pivot = SearchPivot(sens,p,tol2d);
256 std::cout<<"pivot not found, plate is called"<<std::endl;
258 PerformMoreThreeCorner(Jndex, 3);
261 else{deb = (pivot+1)%3 ; fin = (pivot+2)%3;}
262 pivdif = Standard_False;
263 if(Abs(p[0][1]-p[0][2]) <= tol2d &&
264 Abs(p[1][0]-p[1][2]) <= tol2d &&
265 Abs(p[2][0]-p[2][1]) <= tol2d){
266 c1pointu = Standard_True;
270 PerformMoreThreeCorner(Jndex, 3);
273 Standard_Integer ifacdeb, ifacfin;
274 ifacdeb = CD[deb]->ChangeSetOfSurfData()->Value(i[deb][pivot])->Index(3-jf[deb][pivot]);
275 ifacfin = CD[fin]->ChangeSetOfSurfData()->Value(i[fin][pivot])->Index(3-jf[fin][pivot]);
276 if(ifacfin != ifacdeb){
278 std::cout<<"several base faces, plate is called"<<std::endl;
280 PerformMoreThreeCorner(Jndex, 3);
283 if(i[pivot][deb] != i[pivot][fin]){
285 std::cout<<"load surfdata on the pivot, plate is called"<<std::endl;
287 PerformMoreThreeCorner(Jndex, 3);
291 Standard_Real Rdeb,Rfin,Rdp,Rfp;
292 gp_Pnt Pdeb,Pfin,Pdp,Pfp;
293 gp_Vec Vdeb,Vfin,Vdp,Vfp;
298 for(ii = 0; ii<=2; ii++){
299 jj = (ii+1)%3 ; kk = (ii+2)%3;
300 ChFi3d_ExtrSpineCarac(DStr,CD[jj],i[jj][ii],p[jj][ii],1,
301 sens[jj],pbid,qv[jj],qr[jj]);
303 for(ii = 0; ii<=2 && !c1toric; ii++){
304 jj = (ii+1)%3 ; kk = (ii+2)%3;
305 if(ToricCorner(face[ii],qr[jj],qr[kk],qv[ii])){
306 c1toric = Standard_True;
307 pivot = ii; deb = jj; fin = kk;
310 if(!c1toric)c1spheric=(Abs(qr[0]-qr[1])<tolapp3d && Abs(qr[0]-qr[2])<tolapp3d);
313 // Previously to avoid loops the points were always located
314 // inside, which could impede the construction of the
315 // guideline of the corner which now is a circle.
316 // Standard_Integer jjjd = jf[deb][fin], jjjf = jf[fin][deb];
317 // if (pivdif) jjjd = jf[deb][pivot], jjjf = jf[fin][pivot];
318 Standard_Integer jjjd = jf[deb][pivot], jjjf = jf[fin][pivot];
319 ChFi3d_ExtrSpineCarac(DStr,CD[deb],i[deb][pivot],p[deb][pivot],
320 jjjd,sens[deb],Pdeb,Vdeb,Rdeb);
321 ChFi3d_ExtrSpineCarac(DStr,CD[fin],i[fin][pivot],p[fin][pivot],
322 jjjf,sens[fin],Pfin,Vfin,Rfin);
323 ChFi3d_ExtrSpineCarac(DStr,CD[pivot],i[pivot][deb],p[pivot][deb],
324 0,sens[pivot],Pdp,Vdp,Rdp);
325 ChFi3d_ExtrSpineCarac(DStr,CD[pivot],i[pivot][fin],p[pivot][fin],
326 0,sens[pivot],Pfp,Vfp,Rfp);
327 //in cas of allsame it is checked that points on the face are not
328 //too close, which can stop the work.
330 gp_Pnt ptestdeb,ptestfin; gp_Vec bidvec; Standard_Real bidr;
331 ChFi3d_ExtrSpineCarac(DStr,CD[deb],i[deb][pivot],p[deb][pivot],
332 jf[deb][fin],sens[deb],ptestdeb,bidvec,bidr);
333 ChFi3d_ExtrSpineCarac(DStr,CD[fin],i[fin][pivot],p[fin][pivot],
334 jf[fin][deb],sens[fin],ptestfin,bidvec,bidr);
335 Standard_Real distest = ptestdeb.Distance(ptestfin);
336 if(distest < (Rdp+Rfp)*0.05) filling = 1;
337 if(distest < (Rdp+Rfp)*0.005) c1pointu = 1;
341 if (!pivdif) c1pointu = (Abs(p[deb][pivot]-p[deb][fin]) <=tol2d &&
342 Abs(p[fin][pivot]-p[fin][deb]) <=tol2d);
343 if(Abs(p[pivot][deb] - p[pivot][fin]) <= tol2d)
344 c1toric = ToricCorner(face[pivot],Rdeb,Rfin,Vdp);
346 // there is a pivot, the start and the end CD (finally !?!) :
347 // -------------------------------------------------------------
348 // the criterions determining if the corner is a torus or a sphere
349 // are based only on the configuration of sections at end and the
350 // nature of faces, it is necessary to make tests to
351 // determine if a more detailed analysis of incident fillets
352 // is necessare to provide tangency between them and
353 // the corner (in particular in the case with variable radius).
357 Handle(ChFiDS_SurfData)&
358 fddeb = CD[deb]->ChangeSetOfSurfData()->ChangeValue(i[deb][pivot]);
359 Handle(ChFiDS_SurfData)&
360 fdfin = CD[fin]->ChangeSetOfSurfData()->ChangeValue(i[fin][pivot]);
361 Handle(ChFiDS_SurfData)&
362 fdpiv = CD[pivot]->ChangeSetOfSurfData()->ChangeValue(i[pivot][deb]);
365 // HSurfaces and other suitable tools are constructed.
366 // ----------------------------------------------------------
368 TopAbs_Orientation OFac = face[pivot].Orientation();
369 Handle(BRepAdaptor_Surface) Fac = new BRepAdaptor_Surface(face[pivot]);
371 const ChFiDS_FaceInterference& bid1 = CD[pivot]->SetOfSurfData()->
372 Value(i[pivot][deb])->InterferenceOnS1();
373 ppp1 = bid1.PCurveOnSurf()->Value(bid1.FirstParameter());
374 const ChFiDS_FaceInterference& bid2 = CD[pivot]->SetOfSurfData()->
375 Value(i[pivot][deb])->InterferenceOnS2();
376 ppp2 = bid2.PCurveOnSurf()->Value(bid2.LastParameter());
377 Standard_Real uu1 = ppp1.X(), uu2 = ppp2.X(), vv1 = ppp1.Y(), vv2 = ppp2.Y();
379 gasurf((DStr.Surface(CD[pivot]->SetOfSurfData()->
380 Value(i[pivot][deb])->Surf())).Surface(),
382 GeomAbs_SurfaceType styp = gasurf.GetType();
383 if(styp == GeomAbs_Cylinder){
384 Standard_Real h = vv2 - vv1;
387 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
388 Value(i[pivot][deb])->Surf())).Surface(),
391 else if(styp == GeomAbs_Torus){
392 Standard_Real h = uu2 - uu1;
395 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
396 Value(i[pivot][deb])->Surf())).Surface(),
399 else if(styp == GeomAbs_BezierSurface || styp == GeomAbs_BSplineSurface){
400 gasurf.Load((DStr.Surface(CD[pivot]->SetOfSurfData()->
401 Value(i[pivot][deb])->Surf())).Surface());
404 Handle(GeomAdaptor_Surface) Surf = new GeomAdaptor_Surface(gasurf);
405 // Handle(BRepTopAdaptor_TopolTool) IFac = new BRepTopAdaptor_TopolTool(Fac);
406 // Try to not classify on the face for cases of reentering fillets which naturally depass
408 Handle(GeomAdaptor_Surface)
409 bidsurf = new GeomAdaptor_Surface(Fac->ChangeSurface().Surface());
410 Handle(Adaptor3d_TopolTool)
411 IFac = new Adaptor3d_TopolTool(bidsurf);
412 // end of the attempt.
413 Handle(Adaptor3d_TopolTool) ISurf = new Adaptor3d_TopolTool(Surf);
414 Handle(ChFiDS_Stripe) corner = new ChFiDS_Stripe();
415 Handle(ChFiDS_HData)& cornerset = corner->ChangeSetOfSurfData();
416 cornerset = new ChFiDS_HData();
417 Handle(ChFiDS_SurfData) coin = new ChFiDS_SurfData();
418 cornerset->Append(coin);
419 TopAbs_Orientation o1,o2,os1,os2,oo1,oo2;
420 Standard_Integer choix = CD[deb]->Choix();
421 o1 = face[pivot].Orientation();
422 o2 = fdpiv->Orientation();
424 os1 = CD[deb]->OrientationOnFace1();
425 os2 = CD[deb]->OrientationOnFace2();
426 if(jf[deb][fin] == 1){
427 choix = ChFi3d::NextSide(o1,o2,os1,os2,choix);
429 if(choix%2 == 1) choix++;
434 choix = ChFi3d::NextSide(o2,o1,os1,os2,-choix);
436 if(choix%2 == 1) choix++;
441 gp_Pnt2d pfac1,pfac2,psurf1,psurf2;
442 gp_Vec2d vfac1,vfac2;
443 CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
444 Interference(jf[deb][fin]).PCurveOnFace()->D1(p[deb][pivot],pfac1,vfac1);
445 CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
446 Interference(jf[fin][deb]).PCurveOnFace()->D1(p[fin][pivot],pfac2,vfac2);
447 psurf1 = CD[pivot]->SetOfSurfData()->Value(i[pivot][deb])->
448 Interference(jf[pivot][deb]).PCurveOnSurf()->Value(p[pivot][deb]);
449 psurf2 = CD[pivot]->SetOfSurfData()->Value(i[pivot][fin])->
450 Interference(jf[pivot][fin]).PCurveOnSurf()->Value(p[pivot][fin]);
452 done = Standard_False;
454 if(ChFi3d_GetcontextFORCEFILLING()) c1spheric = c1toric = 0;
458 ChFi3d_ResultChron(ch , t_t3cornerinit); // result perf initialisations
464 ChFi3d_InitChron(ch); // init perf case torus
467 // Direct Construction.
468 // ---------------------
469 done = ChFiKPart_ComputeData::ComputeCorner
470 (DStr,coin,Fac,Surf,oo1,oo2,o1,o2,Rdeb,Rdp,pfac1,pfac2,psurf1,psurf2);
473 ChFi3d_ResultChron(ch , t_torique); // result perf case torus
480 ChFi3d_InitChron(ch); //init perf case sphere
483 done = ChFiKPart_ComputeData::ComputeCorner
484 (DStr,coin,Fac,Surf,oo1,oo2,o1,o2,Rdp,pfac1,psurf1,psurf2);
487 ChFi3d_ResultChron(ch , t_spherique);// result perf cas sphere
498 ChFi3d_InitChron(ch);// init perf not filling
501 //Calculate a guideline,
502 //------------------------------
503 //Numerous problems with loops and half-turns connected to
504 //the curvature of the guideline !!!!!!
506 //If the nature of guideline is changed it is necessary to
507 //reset points Pdeb and Pfin at the inside (see the
508 //comments about it in the calculation of Pdeb and Pfin).
510 Standard_Real radpondere = (Rdp+Rfp)/2.;
511 Standard_Real locfleche = fleche;
513 Standard_Real WFirst,WLast;
514 Handle(Geom_Curve) spinecoin = ChFi3d_CircularSpine(WFirst,WLast,
516 Pfin,Vfin,radpondere);
517 if(spinecoin.IsNull()){
518 // This is a bad case when the intersection of
519 // section planes is done out of the sector.
520 spinecoin = ChFi3d_Spine(Pdeb,Vdeb,
521 Pfin,Vfin,radpondere);
522 WFirst = 0.; WLast = 1.;
524 else locfleche = radpondere * (WLast - WFirst) * fleche;
525 Standard_Real pasmax = (WLast-WFirst)*0.05;
526 Handle(ChFiDS_ElSpine) cornerspine = new ChFiDS_ElSpine();
527 cornerspine->SetCurve(spinecoin);
528 cornerspine->FirstParameter(WFirst - pasmax);
529 cornerspine->LastParameter(WLast + pasmax);
530 // Just to confuse Compute that should not require this
531 // in this exact case ...
532 Handle(ChFiDS_Spine) NullSpine;
533 // The fillet is calculated - from beginning to end
534 // - from the face to the surface
536 math_Vector Soldep(1,4);
537 Soldep(1) = pfac1.X();
538 Soldep(2) = pfac1.Y();
539 Soldep(3) = psurf1.X();
540 Soldep(4) = psurf1.Y();
542 Standard_Boolean Gd1,Gd2,Gf1,Gf2;
543 Handle(BRepBlend_Line) lin;
544 Standard_Real ffi = WFirst, lla = WLast + pasmax;
546 if (Abs(Rdeb-Rfin)<=tolapp3d){
548 BRepBlend_ConstRad func(Fac,Surf,cornerspine);
549 BRepBlend_ConstRadInv finv(Fac,Surf,cornerspine);
550 func.Set(Rdeb,choix);
552 finv.Set(Rdeb,choix);
553 Standard_Real TolGuide = cornerspine->Resolution(tolapp3d);
555 Standard_Integer intf = 3, intl = 3;
556 done = ComputeData(coin,cornerspine,NullSpine,lin,Fac,IFac,Surf,ISurf,
557 func,finv,ffi,pasmax,locfleche,TolGuide,ffi,lla,
558 0,0,1,Soldep,intf,intl,Gd1,Gd2,Gf1,Gf2,0,1);
560 if(ChFi3d_GetcontextFORCEFILLING()) done = 0;
563 done = CompleteData(coin,func,lin,Fac,Surf,OFac,Gd1,0,Gf1,0);
569 Handle(Law_S) law = new Law_S();
570 law->Set(WFirst,Rdeb,WLast,Rfin);
571 BRepBlend_EvolRad func(Fac,Surf,cornerspine,law);
572 BRepBlend_EvolRadInv finv(Fac,Surf,cornerspine,law);
576 Standard_Real TolGuide = cornerspine->Resolution(tolapp3d);
577 Standard_Integer intf = 3, intl = 3;
578 done = ComputeData(coin,cornerspine,NullSpine,lin,Fac,IFac,Surf,ISurf,
579 func,finv,ffi,pasmax,locfleche,TolGuide,ffi,lla,
580 0,0,1,Soldep,intf,intl,Gd1,Gd2,Gf1,Gf2,0,1);
582 if(ChFi3d_GetcontextFORCEFILLING()) done = 0;
585 done = CompleteData(coin,func,lin,Fac,Surf,OFac,Gd1,0,Gf1,0);
592 ChFi3d_ResultChron(ch , t_notfilling);// result perf not filling
600 ChFi3d_InitChron(ch); // init perf filling
603 // the contour to be fillet consists of straight lines uv in beginning and end
604 // of two pcurves (only one if c1pointu) calculted as possible
605 // on piv and the opposite face.
606 Handle(GeomFill_Boundary) Bdeb,Bfin,Bpiv,Bfac;
607 Handle(Geom2d_Curve) PCurveOnFace;
609 Bfac = ChFi3d_mkbound(Fac,PCurveOnFace,sens[deb],pfac1,vfac1,
610 sens[fin],pfac2,vfac2,tolapp3d,2.e-4);
611 Standard_Integer kkk;
614 kkk = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
615 Interference(jf[deb][pivot]).LineIndex();
616 DStr.Curve(kkk).Curve()->D1(p[deb][pivot],ppbid,vp1);
617 kkk = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
618 Interference(jf[fin][pivot]).LineIndex();
619 DStr.Curve(kkk).Curve()->D1(p[fin][pivot],ppbid,vp2);
620 Handle(Geom2d_Curve) PCurveOnPiv;
621 // Bpiv = ChFi3d_mkbound(Surf,PCurveOnPiv,sens[deb],psurf1,vp1,
622 // sens[fin],psurf2,vp2,tolesp,2.e-4);
623 Bpiv = ChFi3d_mkbound(Surf,PCurveOnPiv,psurf1,psurf2,tolapp3d,2.e-4,0);
624 Standard_Real pardeb2 = p[deb][pivot];
625 Standard_Real parfin2 = p[fin][pivot];
627 pardeb2 = p[deb][fin];
628 parfin2 = p[fin][deb];
630 gp_Pnt2d pdeb1 = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
631 Interference(jf[deb][pivot]).PCurveOnSurf()->Value(p[deb][pivot]);
632 gp_Pnt2d pdeb2 = CD[deb]->SetOfSurfData()->Value(i[deb][pivot])->
633 Interference(jf[deb][fin]).PCurveOnSurf()->Value(pardeb2);
634 gp_Pnt2d pfin1 = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
635 Interference(jf[fin][pivot]).PCurveOnSurf()->Value(p[fin][pivot]);
636 gp_Pnt2d pfin2 = CD[fin]->SetOfSurfData()->Value(i[fin][pivot])->
637 Interference(jf[fin][deb]).PCurveOnSurf()->Value(parfin2);
638 Handle(Geom_Surface) sdeb =
639 DStr.Surface(CD[deb]->SetOfSurfData()->
640 Value(i[deb][pivot])->Surf()).Surface();
641 Handle(Geom_Surface) sfin =
642 DStr.Surface(CD[fin]->SetOfSurfData()->
643 Value(i[fin][pivot])->Surf()).Surface();
645 Bdeb = ChFi3d_mkbound(sdeb,pdeb1,pdeb2,tolapp3d,2.e-4);
646 Bfin = ChFi3d_mkbound(sfin,pfin1,pfin2,tolapp3d,2.e-4);
648 GeomFill_ConstrainedFilling fil(11,20);
649 if(c1pointu) fil.Init(Bpiv,Bfin,Bdeb,1);
650 else fil.Init(Bpiv,Bfin,Bfac,Bdeb,1);
652 Handle(Geom_Surface) Surfcoin = fil.Surface();
653 Surfcoin->VReverse(); // revert to direction face surface;
654 done = CompleteData(coin,Surfcoin,
656 Surf,PCurveOnPiv,fdpiv->Orientation(),0,
660 ChFi3d_ResultChron(ch , t_filling);// result perf filling
665 Standard_Real P1deb,P2deb,P1fin,P2fin;
667 p[deb][fin] = p[deb][pivot];
668 p[fin][deb] = p[fin][pivot];
672 // Update of 4 Stripes and the DS
673 // -------------------------------------
676 ChFi3d_InitChron(ch);// init perf update DS
680 Standard_Real parpp1,parpp2;
681 Standard_Integer If1,If2,Il1,Il2,Icf,Icl;
682 const ChFiDS_CommonPoint& Pf1 = coin->VertexFirstOnS1();
683 const ChFiDS_CommonPoint& Pf2 = coin->VertexFirstOnS2();
684 ChFiDS_CommonPoint& Pl1 = coin->ChangeVertexLastOnS1();
685 if(c1pointu) Pl1 = coin->ChangeVertexFirstOnS1();
686 const ChFiDS_CommonPoint& Pl2 = coin->VertexLastOnS2();
688 Bnd_Box bf1,bl1,bf2,bl2;
689 Bnd_Box *pbf1 = &bf1,*pbl1 = &bl1,*pbf2 = &bf2,*pbl2 = &bl2;
690 if(c1pointu) pbl1 = pbf1;
691 pbf1->Add(Pf1.Point());pbf2->Add(Pf2.Point());
692 pbl1->Add(Pl1.Point());pbl2->Add(Pl2.Point());
695 // -----------------------
696 ChFiDS_Regul regdeb, regfin;
697 If1 = ChFi3d_IndexPointInDS(Pf1,DStr);
698 If2 = ChFi3d_IndexPointInDS(Pf2,DStr);
699 if(c1pointu) Il1 = If1;
700 else Il1 = ChFi3d_IndexPointInDS(Pl1,DStr);
701 Il2 = ChFi3d_IndexPointInDS(Pl2,DStr);
702 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
703 Value(coin->InterferenceOnS1().FirstParameter());
704 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
705 Value(coin->InterferenceOnS2().FirstParameter());
706 if(c1pointu) coin->ChangeIndexOfS1(0);
707 else coin->ChangeIndexOfS1(DStr.AddShape(face[pivot]));
708 coin->ChangeIndexOfS2(-fdpiv->Surf());
710 Handle(Geom_Curve) C3d;
711 Standard_Real tolreached;
712 ChFi3d_ComputeArete(Pf1,pp1,Pf2,pp2,
713 DStr.Surface(coin->Surf()).Surface(),C3d,
714 corner->ChangeFirstPCurve(),P1deb,P2deb,
715 tolapp3d,tol2d,tolreached,0);
716 TopOpeBRepDS_Curve Tcurv1(C3d,tolreached);
717 Icf = DStr.AddCurve(Tcurv1);
718 regdeb.SetCurve(Icf);
719 regdeb.SetS1(coin->Surf(),0);
720 regdeb.SetS2(fddeb->Surf(),0);
721 myRegul.Append(regdeb);
722 corner->ChangeFirstCurve(Icf);
723 corner->ChangeFirstParameters(P1deb,P2deb);
724 corner->ChangeIndexFirstPointOnS1(If1);
725 corner->ChangeIndexFirstPointOnS2(If2);
726 ChFi3d_EnlargeBox(DStr,corner,coin,*pbf1,*pbf2,1);
728 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
729 Value(coin->InterferenceOnS1().LastParameter());
730 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
731 Value(coin->InterferenceOnS2().LastParameter());
732 ChFi3d_ComputeArete(Pl1,pp1,Pl2,pp2,
733 DStr.Surface(coin->Surf()).Surface(),C3d,
734 corner->ChangeLastPCurve(),P1fin,P2fin,
735 tolapp3d,tol2d,tolreached,0);
736 TopOpeBRepDS_Curve Tcurv2(C3d,tolreached);
737 Icl = DStr.AddCurve(Tcurv2);
738 regfin.SetCurve(Icl);
739 regfin.SetS1(coin->Surf(),0);
740 regfin.SetS2(fdfin->Surf(),0);
741 myRegul.Append(regfin);
742 corner->ChangeLastCurve(Icl);
743 corner->ChangeLastParameters(P1fin,P2fin);
744 corner->ChangeIndexLastPointOnS1(Il1);
745 corner->ChangeIndexLastPointOnS2(Il2);
746 ChFi3d_EnlargeBox(DStr,corner,coin,*pbl1,*pbl2,0);
748 // then CornerData of the beginning,
749 // --------------------------------
750 Standard_Boolean isfirst = (sens[deb] == 1), rev = (jf[deb][fin] == 2);
751 Standard_Integer isurf1 = 1, isurf2 = 2;
752 parpp1 = p[deb][fin]; parpp2 = p[deb][pivot];
754 isurf1 = 2; isurf2 = 1;
755 parpp1 = p[deb][pivot]; parpp2 = p[deb][fin];
756 CD[deb]->SetOrientation(TopAbs_REVERSED,isfirst);
758 pp1 = fddeb->InterferenceOnS1().PCurveOnSurf()->Value(parpp1);
759 pp2 = fddeb->InterferenceOnS2().PCurveOnSurf()->Value(parpp2);
760 CD[deb]->SetCurve(Icf,isfirst);
761 CD[deb]->SetIndexPoint(If1,isfirst,isurf1);
762 CD[deb]->SetIndexPoint(If2,isfirst,isurf2);
763 CD[deb]->SetParameters(isfirst,P1deb,P2deb);
764 fddeb->ChangeVertex(isfirst,isurf1) = Pf1;
765 fddeb->ChangeVertex(isfirst,isurf2) = Pf2;
766 fddeb->ChangeInterferenceOnS1().SetParameter(parpp1,isfirst);
767 fddeb->ChangeInterferenceOnS2().SetParameter(parpp2,isfirst);
768 TopOpeBRepDS_Curve& tcdeb = DStr.ChangeCurve(Icf);
769 Handle(Geom_Curve) crefdeb = tcdeb.Curve();
770 Standard_Real tolrdeb;
771 ChFi3d_ComputePCurv(crefdeb,pp1,pp2,CD[deb]->ChangePCurve(isfirst),
772 DStr.Surface(fddeb->Surf()).Surface(),
773 P1deb,P2deb,tolapp3d,tolrdeb,rev);
774 tcdeb.Tolerance(Max(tolrdeb,tcdeb.Tolerance()));
775 if(rev) ChFi3d_EnlargeBox(DStr,CD[deb],fddeb,*pbf2,*pbf1,isfirst);
776 else ChFi3d_EnlargeBox(DStr,CD[deb],fddeb,*pbf1,*pbf2,isfirst);
778 // then the end CornerData,
779 // ------------------------
780 isfirst = (sens[fin] == 1); rev = (jf[fin][deb] == 2);
781 isurf1 = 1; isurf2 = 2;
782 parpp1 = p[fin][deb]; parpp2 = p[fin][pivot];
784 isurf1 = 2; isurf2 = 1;
785 parpp1 = p[fin][pivot]; parpp2 = p[fin][deb];
786 CD[fin]->SetOrientation(TopAbs_REVERSED,isfirst);
788 pp1 = fdfin->InterferenceOnS1().PCurveOnSurf()->Value(parpp1);
789 pp2 = fdfin->InterferenceOnS2().PCurveOnSurf()->Value(parpp2);
790 CD[fin]->SetCurve(Icl,isfirst);
791 CD[fin]->SetIndexPoint(Il1,isfirst,isurf1);
792 CD[fin]->SetIndexPoint(Il2,isfirst,isurf2);
793 CD[fin]->SetParameters(isfirst,P1fin,P2fin);
794 fdfin->ChangeVertex(isfirst,isurf1) = Pl1;
795 fdfin->ChangeVertex(isfirst,isurf2) = Pl2;
796 fdfin->ChangeInterferenceOnS1().SetParameter(parpp1,isfirst);
797 fdfin->ChangeInterferenceOnS2().SetParameter(parpp2,isfirst);
798 TopOpeBRepDS_Curve& tcfin = DStr.ChangeCurve(Icl);
799 Handle(Geom_Curve) creffin = tcfin.Curve();
800 Standard_Real tolrfin;
801 ChFi3d_ComputePCurv(creffin,pp1,pp2,CD[fin]->ChangePCurve(isfirst),
802 DStr.Surface(fdfin->Surf()).Surface(),
803 P1fin,P2fin,tolapp3d,tolrfin,rev);
804 tcfin.Tolerance(Max(tolrfin,tcfin.Tolerance()));
805 if(rev) ChFi3d_EnlargeBox(DStr,CD[fin],fdfin,*pbl2,*pbl1,isfirst);
806 else ChFi3d_EnlargeBox(DStr,CD[fin],fdfin,*pbl1,*pbl2,isfirst);
808 // anf finally the pivot.
809 // ------------------
810 ChFiDS_FaceInterference& fi = coin->ChangeInterferenceOnS2();
811 isfirst = (sens[pivot] == 1); rev = (jf[pivot][deb] == 2);
812 isurf1 = 1; isurf2 = 2;
814 isurf1 = 2; isurf2 = 1;
815 CD[pivot]->SetOrientation(TopAbs_REVERSED,isfirst);
817 Standard_Integer ICcoinpiv = fi.LineIndex();
818 TopOpeBRepDS_Curve& TCcoinpiv = DStr.ChangeCurve(ICcoinpiv);
819 CD[pivot]->SetCurve(ICcoinpiv,isfirst);
820 Handle(Geom_Curve) Ccoinpiv = DStr.Curve(ICcoinpiv).Curve();
821 Handle(Geom2d_Curve)& C2dOnPiv = fi.ChangePCurveOnFace();
822 Handle(Geom_Surface) Spiv = DStr.Surface(fdpiv->Surf()).Surface();
824 ChFi3d_SameParameter(Ccoinpiv,C2dOnPiv,Spiv,
825 fi.FirstParameter(),fi.LastParameter(),
827 TCcoinpiv.Tolerance(Max(TCcoinpiv.Tolerance(),tolr));
828 CD[pivot]->ChangePCurve(isfirst) = C2dOnPiv;
829 CD[pivot]->SetIndexPoint(If2,isfirst,isurf1);
830 CD[pivot]->SetIndexPoint(Il2,isfirst,isurf2);
831 CD[pivot]->SetParameters(isfirst,fi.FirstParameter(),fi.LastParameter());
832 fdpiv->ChangeVertex(isfirst,isurf1) = Pf2;
833 fdpiv->ChangeVertex(isfirst,isurf2) = Pl2;
834 fdpiv->ChangeInterference(isurf1).SetParameter(p[pivot][deb],isfirst);
835 fdpiv->ChangeInterference(isurf2).SetParameter(p[pivot][fin],isfirst);
836 CD[pivot]->InDS(isfirst); // filDS already does it from the corner.
837 if(rev) ChFi3d_EnlargeBox(DStr,CD[pivot],fdpiv,*pbl2,*pbf2,isfirst);
838 else ChFi3d_EnlargeBox(DStr,CD[pivot],fdpiv,*pbf2,*pbl2,isfirst);
840 //To end the tolerances of points are rescaled.
841 ChFi3d_SetPointTolerance(DStr,*pbf1,If1);
842 ChFi3d_SetPointTolerance(DStr,*pbf2,If2);
843 ChFi3d_SetPointTolerance(DStr,*pbl1,Il1);
844 ChFi3d_SetPointTolerance(DStr,*pbl2,Il2);
847 //The data corners are truncated and index is updated.
848 //----------------------------------------------------
850 if(i[deb][pivot] < Index[deb]){
851 CD[deb]->ChangeSetOfSurfData()->Remove(i[deb][pivot]+1,Index[deb]);
852 Index[deb] = i[deb][pivot];
854 else if(i[deb][pivot] > Index[deb]) {
855 CD[deb]->ChangeSetOfSurfData()->Remove(Index[deb],i[deb][pivot]-1);
856 i[deb][pivot] = Index[deb];
858 if(i[fin][pivot] < Index[fin]) {
859 CD[fin]->ChangeSetOfSurfData()->Remove(i[fin][pivot]+1,Index[fin]);
860 Index[fin] = i[fin][pivot];
862 else if(i[fin][pivot] > Index[fin]) {
863 CD[fin]->ChangeSetOfSurfData()->Remove(Index[fin],i[fin][pivot]-1);
864 i[fin][pivot] = Index[fin];
866 // it is necessary to take into account mutant corners.
867 if(i[pivot][deb] < Index[pivot]) {
868 CD[pivot]->ChangeSetOfSurfData()->Remove(i[pivot][deb]+1,Index[pivot]);
869 Index[pivot] = i[pivot][deb];
871 else if(i[pivot][deb] > Index[pivot]) {
872 CD[pivot]->ChangeSetOfSurfData()->Remove(Index[pivot],i[pivot][deb]-1);
873 i[pivot][deb] = Index[pivot];
875 if(!myEVIMap.IsBound(Vtx)){
876 TColStd_ListOfInteger li;
877 myEVIMap.Bind(Vtx,li);
879 myEVIMap.ChangeFind(Vtx).Append(coin->Surf());
880 corner->SetSolidIndex(CD[pivot]->SolidIndex());
881 myListStripe.Append(corner);
884 ChFi3d_ResultChron(ch , t_t3cornerDS);// result perf update DS