1 // Created on: 1994-03-29
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor3d_CurveOnSurface.hxx>
19 #include <Adaptor3d_CurveOnSurface.hxx>
20 #include <BRep_Tool.hxx>
21 #include <BRepBlend_Line.hxx>
22 #include <BRepLProp_CLProps.hxx>
23 #include <BRepTopAdaptor_TopolTool.hxx>
24 #include <BSplCLib.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_FilSpine.hxx>
31 #include <ChFiDS_HData.hxx>
32 #include <ChFiDS_Regul.hxx>
33 #include <ChFiDS_SequenceOfSurfData.hxx>
34 #include <ChFiDS_Spine.hxx>
35 #include <ChFiDS_State.hxx>
36 #include <ChFiDS_Stripe.hxx>
37 #include <ChFiDS_SurfData.hxx>
38 #include <ChFiKPart_ComputeData.hxx>
39 #include <Geom_BSplineSurface.hxx>
40 #include <Geom2d_TrimmedCurve.hxx>
41 #include <Geom2dAdaptor_Curve.hxx>
42 #include <Geom2dConvert.hxx>
43 #include <GeomAdaptor_Curve.hxx>
44 #include <GeomAdaptor_Surface.hxx>
45 #include <GeomFill_ConstrainedFilling.hxx>
46 #include <GeomFill_SimpleBound.hxx>
51 #include <gp_Pnt2d.hxx>
52 #include <Standard_ErrorHandler.hxx>
53 #include <Standard_NotImplemented.hxx>
54 #include <StdFail_NotDone.hxx>
55 #include <TColStd_Array1OfReal.hxx>
56 #include <TColStd_ListOfInteger.hxx>
58 #include <TopAbs_Orientation.hxx>
61 #include <TopoDS_Edge.hxx>
62 #include <TopoDS_Face.hxx>
63 #include <TopoDS_Shape.hxx>
64 #include <TopoDS_Vertex.hxx>
65 #include <TopOpeBRepDS_DataStructure.hxx>
66 #include <TopOpeBRepDS_HDataStructure.hxx>
69 #include <DrawTrSurf.hxx>
72 #include <Geom_TrimmedCurve.hxx>
73 extern Standard_Boolean ChFi3d_GettraceDRAWSPINE();
74 extern Standard_Boolean ChFi3d_GetcontextFORCEFILLING();
75 #include <OSD_Chronometer.hxx>
77 extern Standard_Real t_t2cornerinit ,t_perf2cornerbyinter,t_chfikpartcompdata,
78 t_cheminement,t_remplissage,t_t2cornerDS;
79 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
80 extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
83 //=======================================================================
84 //function : ToricRotule
85 //purpose : Test if it is a particular case of torus routine.
86 // Three planes with two constant incident fillets
87 // of the same radius and the third face perpendicular to
88 // two others are required.
89 //=======================================================================
91 static Standard_Boolean ToricRotule(const BRepAdaptor_Surface& fac,
92 const BRepAdaptor_Surface& s1,
93 const BRepAdaptor_Surface& s2,
94 const Handle(ChFiDS_Stripe)& c1,
95 const Handle(ChFiDS_Stripe)& c2)
98 Standard_Real tolesp = 1.e-7;
100 Handle(ChFiDS_FilSpine) sp1=Handle(ChFiDS_FilSpine)::DownCast(c1->Spine());
101 Handle(ChFiDS_FilSpine) sp2=Handle(ChFiDS_FilSpine)::DownCast(c2->Spine());
102 if(sp1.IsNull() || sp2.IsNull()) return Standard_False;
103 if (!sp1->IsConstant() || !sp2->IsConstant())
104 return Standard_False;
105 if ((fac.GetType() != GeomAbs_Plane) ||
106 (s1.GetType() != GeomAbs_Plane) ||
107 (s2.GetType() != GeomAbs_Plane)) return Standard_False;
108 gp_Dir df = fac.Plane().Position().Direction();
109 gp_Dir ds1 = s1.Plane().Position().Direction();
110 gp_Dir ds2 = s2.Plane().Position().Direction();
111 if ( Abs(df.Dot(ds1)) >= tolesp || Abs(df.Dot(ds2)) >= tolesp )
112 return Standard_False;
113 Standard_Real r1 = sp1->Radius();
114 Standard_Real r2 = sp2->Radius();
115 if(Abs(r1 - r2) >= tolesp) return Standard_False;
116 return Standard_True;
119 static void RemoveSD(Handle(ChFiDS_Stripe)& Stripe,
120 const Standard_Integer num1,
121 const Standard_Integer num2 )
123 ChFiDS_SequenceOfSurfData& Seq =
124 Stripe->ChangeSetOfSurfData()->ChangeSequence();
125 if(Seq.IsEmpty()) return;
129 Seq.Remove(num1,num2);
133 //=======================================================================
134 //function : PerformTwoCorner
136 //=======================================================================
138 void ChFi3d_FilBuilder::PerformTwoCorner(const Standard_Integer Index)
142 ChFi3d_InitChron(ch); // init perf initialisation
146 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
147 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
148 ChFiDS_ListIteratorOfListOfStripe It;
149 It.Initialize(myVDataMap(Index));
150 Handle(ChFiDS_Stripe) st1,st2;
151 Standard_Integer Sens1,Sens2;
152 Standard_Integer Isd1,Isd2,i1,i2;
153 Handle(ChFiDS_SurfData) sd1,sd2;
154 ChFiDS_SequenceOfSurfData SeqFil1,SeqFil2;
155 Handle(Geom_Surface) surf1,surf2;
156 Standard_Boolean OkinterCC,Okvisavis,SameSide;
157 Standard_Integer IFaCo1,IFaCo2;
158 Standard_Real UIntPC1,UIntPC2;
163 Standard_Integer nbsurf1,nbsurf2,deb1,fin1,deb2,fin2;
164 Standard_Real parE1,parE2;
165 //Necessary information on fillets is extracted
166 //------------------------------------------------------
172 Isd1 = ChFi3d_IndexOfSurfData(Vtx,st1,Sens1);
181 Isd2 = st2->SetOfSurfData()->Length();
183 else{ Isd2 = ChFi3d_IndexOfSurfData(Vtx,st2,Sens2); }
185 // If two edges to rounded are tangent GeomPlate is called
187 if (Sens1==1) E1= st1->Spine()->Edges(1);
188 else E1= st1->Spine()->Edges( st1->Spine()->NbEdges());
190 if (Sens2==1) E2= st2->Spine()->Edges(1);
191 else E2= st2->Spine()->Edges( st2->Spine()->NbEdges());
193 BRepAdaptor_Curve BCurv1(E1);
194 BRepAdaptor_Curve BCurv2(E2);
195 parE1=BRep_Tool::Parameter(Vtx,E1);
196 parE2=BRep_Tool::Parameter(Vtx,E2);
197 BRepLProp_CLProps CL1(BCurv1,parE1 , 1, 1.e-4);
198 BRepLProp_CLProps CL2(BCurv2,parE2 , 1, 1.e-4);
202 if (Sens1==-1) dir1.Reverse();
203 if (Sens2==-1) dir2.Reverse();
205 ang1=Abs(dir1.Angle(dir2));
206 if (ang1<M_PI/180.) {
207 PerformMoreThreeCorner(Index,2);
212 OkinterCC = ChFi3d_IsInFront(DStr,st1,st2,Isd1,Isd2,Sens1,Sens2,
213 UIntPC1,UIntPC2,FaCo,SameSide,
214 IFaCo1,IFaCo2,Okvisavis,Vtx,Standard_True);
216 Standard_Boolean trouve=Standard_False;
220 // one is not limited to the first or the last surfdata
221 // to find the opposing data
222 nbsurf1=st1->SetOfSurfData()->Length();
223 nbsurf2=st2->SetOfSurfData()->Length();
249 for (i1=deb1;i1<=fin1 &&!trouve;i1++) {
251 for (i2=deb2;i2<=fin2 &&!trouve;i2++) {
254 OkinterCC = ChFi3d_IsInFront(DStr,st1,st2,Isd1,Isd2,Sens1,Sens2,
255 UIntPC1,UIntPC2,FaCo,SameSide,
256 IFaCo1,IFaCo2,Okvisavis,Vtx,Standard_True);
261 PerformMoreThreeCorner(Index,2);
266 if (Sens1==1 && Isd1!=1) RemoveSD(st1,1,1);
267 if (Sens1!=1 && Isd1!=nbsurf1) RemoveSD(st1,fin1,fin1);
268 if (Sens2==1 && Isd2!=1) RemoveSD(st2,1,1);
269 if (Sens2!=1 && Isd2!=nbsurf2) RemoveSD(st2,fin2,fin2);
272 Isd1=ChFi3d_IndexOfSurfData(Vtx,st1,Sens1);
273 Isd2=ChFi3d_IndexOfSurfData(Vtx,st2,Sens2);
275 // throw StdFail_NotDone("TwoCorner : no common face");
276 Standard_Integer IFaArc1 = 3-IFaCo1, IFaArc2 = 3-IFaCo2;
277 SeqFil1 = st1->ChangeSetOfSurfData()->ChangeSequence();
278 SeqFil2 = st2->ChangeSetOfSurfData()->ChangeSequence();
279 sd1 = SeqFil1.ChangeValue(Isd1);
280 surf1 = DStr.Surface(sd1->Surf()).Surface();
281 sd2 = SeqFil2.ChangeValue(Isd2);
282 surf2 = DStr.Surface(sd2->Surf()).Surface();
283 TopAbs_Orientation OFaCo = FaCo.Orientation();
284 // The concavities are analyzed and the opposite face and the
285 // eventual intersection of 2 pcurves on this face are found.
287 ChFiDS_State Stat1,Stat2;
288 Standard_Boolean isfirst1 = (Sens1 == 1);
289 Standard_Boolean isfirst2 = (Sens2 == 1);
290 Stat1 = st1->Spine()->Status(isfirst1);
291 Stat2 = st2->Spine()->Status(isfirst2);
292 Standard_Boolean c1biseau = (Stat1 == ChFiDS_AllSame);
293 Standard_Boolean c1rotule = (Stat1 == ChFiDS_OnSame && Stat2 == ChFiDS_OnSame);
295 // It is checked if the fillets have a commonpoint on a common arc.
296 // This edge is the pivot of the bevel or the knee.
298 ChFiDS_CommonPoint& CP1 = sd1->ChangeVertex(isfirst1,IFaArc1);
299 ChFiDS_CommonPoint& CP2 = sd2->ChangeVertex(isfirst2,IFaArc2);
301 Standard_Boolean resetcp1 = 0;
302 Standard_Boolean resetcp2 = 0;
305 Standard_Boolean yapiv = Standard_False;
306 if(CP1.IsOnArc()) pivot = CP1.Arc();
308 PerformMoreThreeCorner(Index,2);
312 if(CP1.IsOnArc()&& CP2.IsOnArc()){
313 yapiv = (pivot.IsSame(CP2.Arc()));
315 Handle(BRepAdaptor_Curve) Hpivot;
316 Standard_Boolean sameparam = Standard_False;
317 Standard_Real parCP1 = 0., parCP2 = 0.;
319 Hpivot = new BRepAdaptor_Curve(pivot);
320 parCP1 = CP1.ParameterOnArc();
321 parCP2 = CP2.ParameterOnArc();
322 gp_Pnt tst1 = Hpivot->Value(parCP1);
323 gp_Pnt tst2 = Hpivot->Value(parCP2);
324 sameparam = tst1.Distance(tst2) <= tolesp;
326 Handle(BRepAdaptor_Surface) HFaCo = new BRepAdaptor_Surface();
327 Handle(BRepAdaptor_Surface) HFaPiv;
328 Handle(BRepAdaptor_Surface) HBRS1 = new BRepAdaptor_Surface();
329 Handle(BRepAdaptor_Surface) HBRS2 = new BRepAdaptor_Surface();
331 BRepAdaptor_Surface& BRS1 = *HBRS1;
332 BRepAdaptor_Surface& BRS2 = *HBRS2;
333 BRepAdaptor_Surface& BRFaCo = *HFaCo;
334 BRFaCo.Initialize(FaCo);
336 TopoDS_Face FF1,FF2,F,FaPiv;
337 TopAbs_Orientation pctrans = TopAbs_FORWARD ;
338 Handle(Geom2d_BSplineCurve) PCurveOnPiv;
339 FF1 = TopoDS::Face(DStr.Shape(sd1->Index(IFaArc1)));
340 FF2 = TopoDS::Face(DStr.Shape(sd2->Index(IFaArc2)));
341 if (FF1.IsNull()||FF2.IsNull())
342 {PerformMoreThreeCorner(Index,2);
346 BRS1.Initialize(FF1);
347 BRS2.Initialize(FF2);
350 TopTools_ListIteratorOfListOfShape Kt;
351 Standard_Boolean ok1 = Standard_False, ok2 = Standard_False;
352 for (Kt.Initialize(myEFMap(pivot)); Kt.More(); Kt.Next()){
353 F = TopoDS::Face(Kt.Value());
354 if(!ok1 && FF1.IsSame(F)){
357 if(!ok2 && FF2.IsSame(F)){
362 PerformMoreThreeCorner(Index,2);
369 ChFi3d_ResultChron(ch ,t_t2cornerinit);//result perf initialisation
374 ChFiDS_CommonPoint cp11,cp12,cp21,cp22;
375 ChFiDS_FaceInterference intf11,intf12,intf21,intf22;
379 ChFi3d_InitChron(ch); // init perf PerformTwoCornerbyInter
382 done = PerformTwoCornerbyInter(Index);
385 ChFi3d_ResultChron(ch , t_perf2cornerbyinter); // result perf PerformTwoCornerbyInter
389 PerformMoreThreeCorner(Index,2);
394 else if(c1rotule){//save.
395 cp11 = sd1->Vertex(isfirst1,1);
396 cp12 = sd1->Vertex(isfirst1,2);
397 cp21 = sd2->Vertex(isfirst2,1);
398 cp22 = sd2->Vertex(isfirst2,2);
399 intf11 = sd1->InterferenceOnS1();
400 intf12 = sd1->InterferenceOnS2();
401 intf21 = sd2->InterferenceOnS1();
402 intf22 = sd2->InterferenceOnS2();
404 ChFi3d_InitChron(ch); // init perf PerformTwoCornerbyInter
407 done = PerformTwoCornerbyInter(Index);
410 ChFi3d_ResultChron(ch , t_perf2cornerbyinter); // result perf PerformTwoCornerbyInter
414 sd1->ChangeVertex(isfirst1,1) = cp11;
415 sd1->ChangeVertex(isfirst1,2) = cp12;
416 sd2->ChangeVertex(isfirst2,1) = cp21;
417 sd2->ChangeVertex(isfirst2,2) = cp22;
418 sd1->ChangeInterferenceOnS1() = intf11;
419 sd1->ChangeInterferenceOnS2() = intf12;
420 sd2->ChangeInterferenceOnS1() = intf21;
421 sd2->ChangeInterferenceOnS2() = intf22;
426 if(!c1biseau && !done){
427 //new cornerdata is created
428 //-------------------------------
429 Handle(ChFiDS_Stripe) corner = new ChFiDS_Stripe();
430 Handle(ChFiDS_HData)& cornerset = corner->ChangeSetOfSurfData();
431 cornerset = new ChFiDS_HData();
432 Handle(ChFiDS_SurfData) coin = new ChFiDS_SurfData();
433 cornerset->Append(coin);
436 if(ToricRotule(BRFaCo,BRS1,BRS2,st1,st2)){
437 // Direct construction.
438 // ---------------------
440 Standard_Integer bid;
441 TopAbs_Orientation ori = OFaCo;
442 TopAbs_Orientation oriS = st1->Orientation(IFaCo1);
443 TopAbs_Orientation OFF1 = FF1.Orientation();
444 TopAbs_Orientation oriSFF1 = st1->Orientation(IFaArc1);
446 bid = ChFi3d::NextSide(ori,OFF1,oriS,oriSFF1,bid);
447 TopAbs_Orientation op1 = TopAbs_FORWARD,op2 = TopAbs_FORWARD;
448 if(yapiv) bid = ChFi3d::ConcaveSide(BRS1,BRS2,pivot,op1,op2);
449 op1 = TopAbs::Reverse(op1);
450 op2 = TopAbs::Reverse(op2);
452 ChFi3d_InitChron(ch);// init perf ChFiKPart_ComputeData
454 Standard_Real radius =
455 Handle(ChFiDS_FilSpine)::DownCast(st1->Spine())->Radius();
456 done = ChFiKPart_ComputeData::ComputeCorner(DStr,coin,HFaCo,HBRS1,HBRS2,
457 OFaCo,ori,op1,op2,radius);
459 ChFi3d_ResultChron(ch , t_chfikpartcompdata);//result perf ChFiKPart_ComputeData
463 // Construction by filling remplissage
464 // ----------------------------
465 Standard_Real uPCArc1, uPCArc2;
466 gp_Pnt2d p2da1,p2df1,p2da2,p2df2,p2dfac1,p2dfac2;
467 gp_Vec2d v2dfac1,v2dfac2;
468 Handle(GeomFill_Boundary) B1,B2,Bpiv,Bfac;
469 uPCArc1 = sd1->Interference(IFaArc1).Parameter(isfirst1);
470 p2da1 = sd1->Interference(IFaArc1).PCurveOnSurf()->Value(uPCArc1);
471 p2df1 = sd1->Interference(IFaCo1).PCurveOnSurf()->Value(uPCArc1);
472 sd1->Interference(IFaCo1).PCurveOnFace()->D1(uPCArc1,p2dfac1,v2dfac1);
473 uPCArc2 = sd2->Interference(IFaArc2).Parameter(isfirst2);
474 p2da2 = sd2->Interference(IFaArc2).PCurveOnSurf()->Value(uPCArc2);
475 p2df2 = sd2->Interference(IFaCo2).PCurveOnSurf()->Value(uPCArc2);
476 sd2->Interference(IFaCo2).PCurveOnFace()->D1(uPCArc2,p2dfac2,v2dfac2);
478 ChFi3d_InitChron(ch ); // init perf filling
480 B1 = ChFi3d_mkbound(surf1,p2df1,p2da1,tolesp,2.e-4);
481 B2 = ChFi3d_mkbound(surf2,p2df2,p2da2,tolesp,2.e-4);
482 Handle(Geom2d_Curve) PCurveOnFace;
483 Bfac = ChFi3d_mkbound(HFaCo,PCurveOnFace,Sens1,p2dfac1,v2dfac1,
484 Sens2,p2dfac2,v2dfac2,tolesp,2.e-4);
485 GeomFill_ConstrainedFilling fil(8,20);
487 fil.Init(Bfac,B2,B1,1);
490 Handle(Adaptor3d_Curve) HPivTrim = Hpivot->Trim(Min(parCP1,parCP2),Max(parCP1,parCP2),tolesp);
491 Bpiv = new GeomFill_SimpleBound(HPivTrim,tolesp,2.e-4);
492 fil.Init(Bfac,B2,Bpiv,B1,1);
493 BRepAdaptor_Curve2d pcpivot;
496 Hpivot->D1(parCP1,bidon,dArc);
497 Standard_Real fb1,lb1;
499 B1->D1(lb1,bidon,dcf);
500 Standard_Boolean pivotverslebas = dArc.Dot(dcf) <= 0.;
501 Standard_Boolean pcfalenvers = (parCP1 > parCP2);
502 if((pivotverslebas && !pcfalenvers)||
503 (!pivotverslebas && pcfalenvers)) {
513 FaPiv.Orientation(TopAbs_FORWARD);
514 pcpivot.Initialize(pivot,FaPiv);
515 TopExp_Explorer Expl;
516 for(Expl.Init(FaPiv,TopAbs_EDGE); Expl.More(); Expl.Next()){
517 if(Expl.Current().IsSame(pivot)) {
518 pctrans = Expl.Current().Orientation();
522 if(pcpivot.GetType() != GeomAbs_BSplineCurve){
523 Handle(Geom2d_TrimmedCurve)
524 trc = new Geom2d_TrimmedCurve(pcpivot.Curve(),
527 PCurveOnPiv = Geom2dConvert::CurveToBSplineCurve(trc);
530 PCurveOnPiv = Geom2dConvert::SplitBSplineCurve
531 (Handle(Geom2d_BSplineCurve)::DownCast(pcpivot.Curve()),
532 Min(parCP1,parCP2),Max(parCP1,parCP2),tol2d);
534 TColStd_Array1OfReal kk(1,PCurveOnPiv->NbKnots());
535 PCurveOnPiv->Knots(kk);
536 BSplCLib::Reparametrize(0.,1.,kk);
537 PCurveOnPiv->SetKnots(kk);
539 PCurveOnPiv->Reverse();
540 pctrans = TopAbs::Reverse(pctrans);
543 Handle(Geom_Surface) Surfcoin = fil.Surface();
544 done = CompleteData(coin,Surfcoin,
546 HFaPiv,PCurveOnPiv,OFaCo,1,
549 ChFi3d_ResultChron(ch , t_remplissage);// result perf filling
553 ChFi3d_InitChron(ch); // init perf update DS
556 // Update 3 CornerData and the DS
557 // ----------------------------------------
559 gp_Pnt pjyl = CP1.Point();
560 Standard_Real tolsav = CP1.Tolerance();
563 CP1.SetTolerance(tolsav);
566 gp_Pnt pjyl = CP2.Point();
567 Standard_Real tolsav = CP2.Tolerance();
570 CP2.SetTolerance(tolsav);
572 Standard_Real P1deb,P2deb,P1fin,P2fin;
573 Standard_Integer If1,If2,Il1,Il2,Icf,Icl;
574 const ChFiDS_CommonPoint& Pf1 = coin->VertexFirstOnS1();
575 ChFiDS_CommonPoint& Pf2 = coin->ChangeVertexFirstOnS2();
576 const ChFiDS_CommonPoint& Pl1 = coin->VertexLastOnS1();
577 ChFiDS_CommonPoint& Pl2 = coin->ChangeVertexLastOnS2();
581 // the corner to start,
582 // -----------------------
583 ChFiDS_Regul regdeb, regfin;
584 If1 = ChFi3d_IndexPointInDS(Pf1,DStr);
585 If2 = ChFi3d_IndexPointInDS(Pf2,DStr);
586 Il1 = ChFi3d_IndexPointInDS(Pl1,DStr);
587 if(sameparam) Il2 = If2;
588 else Il2 = ChFi3d_IndexPointInDS(Pl2,DStr);
591 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
592 Value(coin->InterferenceOnS1().FirstParameter());
593 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
594 Value(coin->InterferenceOnS2().FirstParameter());
595 Handle(Geom_Curve) C3d;
596 Standard_Real tolreached;
597 ChFi3d_ComputeArete(Pf1,pp1,Pf2,pp2,
598 DStr.Surface(coin->Surf()).Surface(),C3d,
599 corner->ChangeFirstPCurve(),P1deb,P2deb,
600 tolesp,tol2d,tolreached,0);
601 Standard_Real par1 = sd1->Interference(IFaArc1).Parameter(isfirst1);
602 pp1 = sd1->Interference(IFaCo1).PCurveOnSurf()->Value(par1);
603 pp2 = sd1->Interference(IFaArc1).PCurveOnSurf()->Value(par1);
605 ChFi3d_ComputePCurv(C3d,pp1,pp2,st1->ChangePCurve(isfirst1),
606 DStr.Surface(sd1->Surf()).Surface(),
607 P1deb,P2deb,tolesp,tolr1);
608 tolreached = Max(tolreached,tolr1);
609 TopOpeBRepDS_Curve Tcurv1(C3d,tolreached);
610 Icf = DStr.AddCurve(Tcurv1);
611 regdeb.SetCurve(Icf);
612 regdeb.SetS1(coin->Surf(),0);
613 regdeb.SetS2(sd1->Surf(),0);
614 myRegul.Append(regdeb);
615 corner->ChangeFirstCurve(Icf);
616 corner->ChangeFirstParameters(P1deb,P2deb);
617 corner->ChangeIndexFirstPointOnS1(If1);
618 corner->ChangeIndexFirstPointOnS2(If2);
620 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
621 Value(coin->InterferenceOnS1().LastParameter());
622 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
623 Value(coin->InterferenceOnS2().LastParameter());
624 ChFi3d_ComputeArete(Pl1,pp1,Pl2,pp2,
625 DStr.Surface(coin->Surf()).Surface(),C3d,
626 corner->ChangeLastPCurve(),P1fin,P2fin,
627 tolesp,tol2d,tolreached,0);
628 Standard_Real par2 = sd2->Interference(IFaArc2).Parameter(isfirst2);
629 pp1 = sd2->Interference(IFaCo2).PCurveOnSurf()->Value(par2);
630 pp2 = sd2->Interference(IFaArc2).PCurveOnSurf()->Value(par2);
632 ChFi3d_ComputePCurv(C3d,pp1,pp2,st2->ChangePCurve(isfirst2),
633 DStr.Surface(sd2->Surf()).Surface(),
634 P1deb,P2deb,tolesp,tolr2);
635 tolreached = Max(tolreached,tolr2);
636 TopOpeBRepDS_Curve Tcurv2(C3d,tolreached);
637 Icl = DStr.AddCurve(Tcurv2);
638 regfin.SetCurve(Icl);
639 regfin.SetS1(coin->Surf(),0);
640 regfin.SetS2(sd2->Surf(),0);
641 myRegul.Append(regfin);
642 corner->ChangeLastCurve(Icl);
643 corner->ChangeLastParameters(P1fin,P2fin);
644 corner->ChangeIndexLastPointOnS1(Il1);
645 corner->ChangeIndexLastPointOnS2(Il2);
647 coin->ChangeIndexOfS1(DStr.AddShape(FaCo));
648 if(sameparam) coin->ChangeIndexOfS2(0);
650 coin->ChangeIndexOfS2(DStr.AddShape(FaPiv));
651 coin->ChangeInterferenceOnS2().SetTransition(pctrans);
653 corner->SetSolidIndex(st1->SolidIndex());
655 // then the starting Stripe,
656 // ------------------------
657 st1->SetCurve(Icf,isfirst1);
658 st1->SetIndexPoint(If1,isfirst1,IFaCo1);
659 st1->SetIndexPoint(If2,isfirst1,IFaArc1);
660 st1->SetParameters(isfirst1,P1deb,P2deb);
661 sd1->ChangeVertex(isfirst1,IFaCo1) = Pf1;
662 sd1->ChangeVertex(isfirst1,IFaArc1) = Pf2;
663 sd1->ChangeInterference(IFaCo1).SetParameter(par1,isfirst1);
664 if (IFaCo1 == 2) st1->SetOrientation(TopAbs_REVERSED,isfirst1);
666 // then the end Stripe,
667 // -------------------------
668 st2->SetCurve(Icl,isfirst2);
669 st2->SetIndexPoint(Il1,isfirst2,IFaCo2);
670 st2->SetIndexPoint(Il2,isfirst2,IFaArc2);
671 st2->SetParameters(isfirst2,P1fin,P2fin);
672 sd2->ChangeVertex(isfirst2,IFaCo2) = Pl1;
673 sd2->ChangeVertex(isfirst2,IFaArc2) = Pl2;
674 sd2->ChangeInterference(IFaCo2).SetParameter(par2,isfirst2);
675 if (IFaCo2 == 2) st2->SetOrientation(TopAbs_REVERSED,isfirst2);
678 ChFi3d_ResultChron(ch , t_t2cornerDS);// result perf update DS
682 //it is necessary to make difference with
684 throw Standard_Failure("TwoCorner : No intersection pc pc");
686 Handle(ChFiDS_Stripe) stsam, stdif;
687 Handle(ChFiDS_SurfData) sdsam, sddif;
688 Standard_Real uintpcsam = 0., uintpcdif = 0.;
689 Standard_Integer ifacosam = 0, ifacodif = 0, ifaopsam = 0, ifaopdif = 0;
690 Standard_Boolean isfirstsam = Standard_False, isfirstdif = Standard_False;
691 if(Stat1 == ChFiDS_OnSame && Stat2 == ChFiDS_OnDiff){
692 stsam = st1; sdsam = sd1; uintpcsam = UIntPC1;
693 ifacosam = IFaCo1; ifaopsam = IFaArc1; isfirstsam = isfirst1;
694 stdif = st2; sddif = sd2; uintpcdif = UIntPC2;
695 ifacodif = IFaCo2; ifaopdif = IFaArc2; isfirstdif = isfirst2;
697 else if(Stat1 == ChFiDS_OnDiff && Stat2 == ChFiDS_OnSame){
698 stsam = st2; sdsam = sd2; uintpcsam = UIntPC2;
699 ifacosam = IFaCo2; ifaopsam = IFaArc2; isfirstsam = isfirst2;
700 stdif = st1; sddif = sd1; uintpcdif = UIntPC1;
701 ifacodif = IFaCo1; ifaopdif = IFaArc1; isfirstdif = isfirst1;
704 throw Standard_Failure("TwoCorner : Config unknown");
706 //It is checked if surface ondiff has a point on arc from the side opposed
707 //to the common face and if this arc is connected to the base face
708 //opposed to common face of the surface onsame.
709 ChFiDS_CommonPoint& cpopdif = sddif->ChangeVertex(isfirstdif,ifaopdif);
710 if(!cpopdif.IsOnArc()) {
711 throw Standard_Failure("TwoCorner : No point on restriction on surface OnDiff");
713 const TopoDS_Edge& Arcopdif = cpopdif.Arc();
714 const TopoDS_Face& Fopsam = TopoDS::Face(DStr.Shape(sdsam->Index(ifaopsam)));
716 for(ex.Init(Fopsam,TopAbs_EDGE); ex.More(); ex.Next()){
717 if(ex.Current().IsSame(Arcopdif)) {
720 else if(!ex.More()) {
721 throw Standard_Failure("TwoCorner : No common face to loop the contour");
725 ChFi3d_InitChron(ch ); // init perf filling
727 Handle(GeomFill_Boundary) Bsam,Bdif,Bfac;
729 sdsam->Interference(ifaopsam).PCurveOnSurf()->Value(uintpcsam);
731 sdsam->Interference(ifacosam).PCurveOnSurf()->Value(uintpcsam);
732 Handle(Geom_Surface) surfsam = DStr.Surface(sdsam->Surf()).Surface();
733 Handle(GeomAdaptor_Surface) Hsurfsam = new GeomAdaptor_Surface(surfsam);
734 Handle(Geom2d_Curve) pcsurfsam;
735 Bsam = ChFi3d_mkbound(Hsurfsam,pcsurfsam,ppopsam,ppcosam,tolesp,2.e-4);
736 Standard_Real upcopdif = sddif->Interference(ifaopdif).Parameter(isfirstdif);
738 sddif->Interference(ifaopdif).PCurveOnSurf()->Value(upcopdif);
740 sddif->Interference(ifacodif).PCurveOnSurf()->Value(uintpcdif);
741 Handle(Geom_Surface) surfdif = DStr.Surface(sddif->Surf()).Surface();
742 Handle(GeomAdaptor_Surface) Hsurfdif = new GeomAdaptor_Surface(surfdif);
743 Handle(Geom2d_Curve) pcsurfdif;
744 Bdif = ChFi3d_mkbound(Hsurfdif,pcsurfdif,ppcodif,ppopdif,tolesp,2.e-4);
745 gp_Pnt2d ppfacsam,ppfacdif;
746 gp_Pnt PPfacsam,PPfacdif;
747 gp_Vec VVfacsam,VVfacdif;
748 sdsam->Interference(ifaopsam).PCurveOnFace()->D0(uintpcsam,ppfacsam);
749 const Handle(Geom_Curve)& curvopsam =
750 DStr.Curve(sdsam->Interference(ifaopsam).LineIndex()).Curve();
751 curvopsam->D1(uintpcsam,PPfacsam,VVfacsam);
752 BRepAdaptor_Curve2d PCArcFac(Arcopdif,Fopsam);
753 PCArcFac.D0(cpopdif.ParameterOnArc(),ppfacdif);
755 BRepAdaptor_Surface SurFopsam(Fopsam);
756 if (SurFopsam.IsUClosed())
758 Standard_Real Uperiod = SurFopsam.LastUParameter() - SurFopsam.FirstUParameter();
759 if (Abs(ppfacsam.X() - ppfacdif.X()) > Uperiod/2)
761 if (ppfacdif.X() < ppfacsam.X())
762 ppfacdif.SetX(ppfacdif.X() + Uperiod);
764 ppfacdif.SetX(ppfacdif.X() - Uperiod);
768 BRepAdaptor_Curve CArcFac(Arcopdif);
769 CArcFac.D1(cpopdif.ParameterOnArc(),PPfacdif,VVfacdif);
770 Handle(BRepAdaptor_Surface) HBRFopsam = new BRepAdaptor_Surface();
771 BRepAdaptor_Surface& BRFopsam = *HBRFopsam;
772 BRFopsam.Initialize(Fopsam,Standard_False);
773 Handle(Geom2d_Curve) pcFopsam = ChFi3d_BuildPCurve(HBRFopsam,
775 ppfacdif,VVfacdif,1);
776 Bfac = ChFi3d_mkbound(HBRFopsam,pcFopsam,tolesp,2.e-4);
777 GeomFill_ConstrainedFilling fil(8,20);
778 fil.Init(Bsam,Bdif,Bfac,1);
780 for(Standard_Integer ib = 0; ib < 4; ib++){
781 if(ib == 2) continue;
782 fil.CheckCoonsAlgPatch(ib);
783 fil.CheckTgteField(ib);
788 Handle(Geom_Surface) Surfcoin = fil.Surface();
789 TopAbs_Orientation Osurfsam = sdsam->Orientation();
790 Handle(Geom2d_Curve) pcnul;
791 done = CompleteData(coin,Surfcoin,
793 HBRFopsam,pcnul,Osurfsam,1,
796 ChFi3d_ResultChron(ch , t_remplissage);// result perf filling
798 if(!done) throw Standard_Failure("concavites inverted : fail");
800 ChFi3d_InitChron(ch); // init perf update DS
802 // Update 3 CornerData and the DS
803 // ----------------------------------------
804 // the corner to start,
805 // -----------------------
806 Standard_Real P1deb,P2deb,P1fin,P2fin;
807 Standard_Integer If1,If2,Il1,Il2,Icf,Icl;
808 const ChFiDS_CommonPoint& Pf1 = coin->VertexFirstOnS1();
809 ChFiDS_CommonPoint& Pf2 = coin->ChangeVertexFirstOnS2();
810 const ChFiDS_CommonPoint& Pl1 = coin->VertexLastOnS1();
811 ChFiDS_CommonPoint& Pl2 = coin->ChangeVertexLastOnS2();
814 ChFiDS_Regul regdeb, regfin;
815 If1 = ChFi3d_IndexPointInDS(Pf1,DStr);
816 If2 = ChFi3d_IndexPointInDS(Pf2,DStr);
817 Il1 = ChFi3d_IndexPointInDS(Pl1,DStr);
821 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
822 Value(coin->InterferenceOnS1().FirstParameter());
823 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
824 Value(coin->InterferenceOnS2().FirstParameter());
825 Handle(Geom_Curve) C3d;
826 Standard_Real tolreached;
827 ChFi3d_ComputeArete(Pf1,pp1,Pf2,pp2,
828 DStr.Surface(coin->Surf()).Surface(),C3d,
829 corner->ChangeFirstPCurve(),P1deb,P2deb,
830 tolesp,tol2d,tolreached,0);
832 Handle(GeomAdaptor_Curve) HC3d = new GeomAdaptor_Curve(C3d);
833 ChFi3d_SameParameter(HC3d,pcFopsam,HBRFopsam,tolesp,tolr1);
834 tolreached = Max(tolreached,tolr1);
835 TopOpeBRepDS_Curve Tcurv1(C3d,tolreached);
836 Icf = DStr.AddCurve(Tcurv1);
837 // place the pcurve on face in the DS
838 TopAbs_Orientation OpcFopsam = sdsam->Interference(ifaopsam).Transition();
839 Standard_Integer IFopsam = sdsam->Index(ifaopsam);
840 if(isfirstsam) OpcFopsam = TopAbs::Reverse(OpcFopsam);
841 Handle(TopOpeBRepDS_SurfaceCurveInterference)
842 interf = ChFi3d_FilCurveInDS(Icf,IFopsam,pcFopsam,OpcFopsam);
843 DStr.ChangeShapeInterferences(IFopsam).Append(interf);
845 regdeb.SetCurve(Icf);
846 regdeb.SetS1(coin->Surf(),0);
847 regdeb.SetS2(IFopsam,1);
848 myRegul.Append(regdeb);
849 corner->ChangeFirstCurve(Icf);
850 corner->ChangeFirstParameters(P1deb,P2deb);
851 corner->ChangeIndexFirstPointOnS1(If1);
852 corner->ChangeIndexFirstPointOnS2(If2);
854 pp1 = coin->InterferenceOnS1().PCurveOnSurf()->
855 Value(coin->InterferenceOnS1().LastParameter());
856 pp2 = coin->InterferenceOnS2().PCurveOnSurf()->
857 Value(coin->InterferenceOnS2().LastParameter());
858 ChFi3d_ComputeArete(Pl1,pp1,Pl2,pp2,
859 DStr.Surface(coin->Surf()).Surface(),C3d,
860 corner->ChangeLastPCurve(),P1fin,P2fin,
861 tolesp,tol2d,tolreached,0);
864 ChFi3d_SameParameter(HC3d,pcsurfdif,Hsurfdif,tolesp,tolr2);
865 tolreached = Max(tolreached,tolr2);
866 TopOpeBRepDS_Curve Tcurv2(C3d,tolreached);
867 Icl = DStr.AddCurve(Tcurv2);
868 regfin.SetCurve(Icl);
869 regfin.SetS1(coin->Surf(),0);
870 regfin.SetS2(sddif->Surf(),0);
871 myRegul.Append(regfin);
872 corner->ChangeLastCurve(Icl);
873 corner->ChangeLastParameters(P1fin,P2fin);
874 corner->ChangeIndexLastPointOnS1(Il1);
875 corner->ChangeIndexLastPointOnS2(Il2);
877 coin->ChangeIndexOfS1(-sdsam->Surf());
878 coin->ChangeIndexOfS2(0);
880 corner->SetSolidIndex(stsam->SolidIndex());
882 // then Stripe OnSame
883 // ---------------------
884 const ChFiDS_FaceInterference& intcoin1 = coin->InterferenceOnS1();
885 stsam->SetCurve(intcoin1.LineIndex(),isfirstsam);
886 stsam->InDS(isfirstsam); // filDS already works from the corner.
887 stsam->ChangePCurve(isfirstsam) = coin->InterferenceOnS1().PCurveOnFace();
888 stsam->SetIndexPoint(If1,isfirstsam,ifaopsam);
889 stsam->SetIndexPoint(Il1,isfirstsam,ifacosam);
890 stsam->SetParameters(isfirstsam,
891 intcoin1.FirstParameter(),
892 intcoin1.LastParameter());
893 sdsam->ChangeVertex(isfirstsam,ifaopsam) = Pf1;
894 sdsam->ChangeVertex(isfirstsam,ifacosam) = Pl1;
895 sdsam->ChangeInterferenceOnS1().SetParameter(uintpcsam,isfirstsam);
896 sdsam->ChangeInterferenceOnS2().SetParameter(uintpcsam,isfirstsam);
897 if (ifaopsam == 2) stsam->SetOrientation(TopAbs_REVERSED,isfirstsam);
899 // then Stripe OnDiff
900 // ---------------------
901 stdif->SetCurve(Icl,isfirstdif);
902 stdif->ChangePCurve(isfirstdif) = pcsurfdif;
903 stdif->SetIndexPoint(Il2,isfirstdif,ifaopdif);
904 stdif->SetIndexPoint(Il1,isfirstdif,ifacodif);
905 stdif->SetParameters(isfirstdif,P1fin,P2fin);
906 sddif->ChangeVertex(isfirstdif,ifaopdif) = Pl2;
907 sddif->ChangeVertex(isfirstdif,ifacodif) = Pl1;
908 sddif->ChangeInterference(ifacodif).SetParameter(uintpcdif,isfirstdif);
909 if (ifaopdif == 1) stdif->SetOrientation(TopAbs_REVERSED,isfirstdif);
911 ChFi3d_ResultChron(ch , t_t2cornerDS);// result perf update DS
914 if(!myEVIMap.IsBound(Vtx)){
915 TColStd_ListOfInteger li;
916 myEVIMap.Bind(Vtx,li);
918 myEVIMap.ChangeFind(Vtx).Append(coin->Surf());
919 myListStripe.Append(corner);