1 // Created on: 1996-08-20
2 // Created by: Stagiaire Xuan Tang PHAMPHU
3 // Copyright (c) 1996-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_Builder.jxx>
19 #include <ChFi3d_Builder_0.hxx>
21 #include <Precision.hxx>
23 #include <Standard_Failure.hxx>
24 #include <Standard_NotImplemented.hxx>
25 #include <StdFail_NotDone.hxx>
32 #include <gp_Pnt2d.hxx>
33 #include <gp_Vec2d.hxx>
34 #include <gp_Dir2d.hxx>
35 #include <GeomLib.hxx>
36 #include <Extrema_ExtPC.hxx>
37 #include <Geom_Curve.hxx>
38 #include <Geom2d_Curve.hxx>
39 #include <Geom_BoundedCurve.hxx>
41 #include <Geom2dAdaptor_HCurve.hxx>
42 #include <GeomAbs_Shape.hxx>
43 #include <GeomAdaptor_HCurve.hxx>
44 #include <GeomAdaptor_Surface.hxx>
45 #include <GeomAdaptor_HSurface.hxx>
47 #include <Adaptor3d_HCurveOnSurface.hxx>
48 #include <BRepAdaptor_HSurface.hxx>
49 #include <BRepAdaptor_Curve.hxx>
50 #include <BRepAdaptor_Curve2d.hxx>
51 #include <BRepAdaptor_HCurve.hxx>
52 #include <BRepAdaptor_Surface.hxx>
54 #include <BRep_Tool.hxx>
57 #include <TopoDS_Shape.hxx>
58 #include <TopoDS_Face.hxx>
59 #include <TopoDS_Edge.hxx>
60 #include <TopoDS_Vertex.hxx>
63 #include <TopAbs_ShapeEnum.hxx>
64 #include <TopAbs_Orientation.hxx>
67 #include <TopExp_Explorer.hxx>
69 #include <TopTools_ListIteratorOfListOfShape.hxx>
71 #include <TopOpeBRepDS_Point.hxx>
72 #include <TopOpeBRepDS_Curve.hxx>
73 #include <TopOpeBRepDS_Surface.hxx>
74 #include <TopOpeBRepDS_SurfaceCurveInterference.hxx>
75 #include <TopOpeBRepDS_CurvePointInterference.hxx>
76 #include <TopOpeBRepDS_DataStructure.hxx>
77 #include <TopOpeBRepDS_ListOfInterference.hxx>
79 #include <ChFiDS_HData.hxx>
80 #include <ChFiDS_SurfData.hxx>
81 #include <ChFiDS_CommonPoint.hxx>
82 #include <ChFiDS_FaceInterference.hxx>
83 #include <ChFiDS_SequenceOfSurfData.hxx>
84 #include <ChFiDS_Stripe.hxx>
85 #include <ChFiDS_ListIteratorOfListOfStripe.hxx>
87 #include <TColStd_Array1OfReal.hxx>
89 static void Reduce(const Standard_Real& p1,
90 const Standard_Real& p2,
91 Handle(GeomAdaptor_HSurface)& hs1,
92 Handle(GeomAdaptor_HSurface)& hs2)
94 GeomAdaptor_Surface& s1 = hs1->ChangeSurface();
95 GeomAdaptor_Surface& s2 = hs2->ChangeSurface();
96 const Handle(Geom_Surface&) surf = s1.Surface();
97 Standard_Real ud,uf,vd,vf;
98 surf->Bounds(ud,uf,vd,vf);
99 Standard_Real milmoins = 0.51*vd+0.49*vf, milplus = 0.49*vd+0.51*vf;
101 s1.Load(surf,ud,uf,vd,milmoins);
102 s2.Load(surf,ud,uf,milplus,vf);
105 s1.Load(surf,ud,uf,milplus,vf);
106 s2.Load(surf,ud,uf,vd,milmoins);
110 static void Reduce(const Standard_Real& p1,
111 const Standard_Real& p2,
112 Handle(GeomAdaptor_HCurve)& hc)
114 GeomAdaptor_Curve& c = hc->ChangeCurve();
115 Standard_Real f = c.FirstParameter();
116 Standard_Real l = c.LastParameter();
117 Standard_Real milmoins = 0.51*f+0.49*l, milplus = 0.49*f+0.51*l;
119 c.Load(c.Curve(),f,milmoins);
122 c.Load(c.Curve(),milplus,l);
127 //=======================================================================
128 //function : PerformTwoCornerbyInter
129 //purpose : Performs PerformTwoCorner by intersection.
130 // In case of Biseau for all cases the
131 // path is used; 3D curve and 2 pcurves are approximated.
132 //=======================================================================
134 Standard_Integer ChFi3d_Builder::PerformTwoCornerbyInter(const Standard_Integer Index)
138 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
139 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
141 //Information on fillets is extracted
142 //------------------------------------------------------
146 ChFiDS_ListIteratorOfListOfStripe It;
147 It.Initialize(myVDataMap(Index));
148 Handle(ChFiDS_Stripe)& Corner1 = It.Value();
149 Standard_Integer Sens1;
150 Standard_Integer IFd1 =
151 ChFi3d_IndexOfSurfData(Vtx,Corner1,Sens1);
152 ChFiDS_SequenceOfSurfData& SeqFil1 =
153 Corner1->ChangeSetOfSurfData()->ChangeSequence();
154 Handle(ChFiDS_SurfData)& Fd1 = SeqFil1.ChangeValue(IFd1);
159 Handle(ChFiDS_Stripe)& Corner2 = It.Value();
160 Standard_Integer Sens2;
161 Standard_Integer IFd2;
162 if(Corner2 == Corner1) {
164 IFd2 = Corner2->SetOfSurfData()->Length();
166 else{ IFd2 = ChFi3d_IndexOfSurfData(Vtx,Corner2,Sens2); }
167 ChFiDS_SequenceOfSurfData& SeqFil2 =
168 Corner2->ChangeSetOfSurfData()->ChangeSequence();
169 Handle(ChFiDS_SurfData)& Fd2 = SeqFil2.ChangeValue(IFd2);
171 // The concavities are analysed in case of differents concavities,
172 // preview an evolutionary connection of type ThreeCorner of R to 0.
173 // Otherwise the opposite face
174 // and the eventual intersection of 2 pcurves on this face are found.
176 ChFiDS_State Stat1,Stat2;
177 Standard_Boolean isfirst1 = (Sens1 == 1);
178 Standard_Boolean isfirst2 = (Sens2 == 1);
179 Stat1 = Corner1->Spine()->Status(isfirst1);
180 Stat2 = Corner2->Spine()->Status(isfirst2);
182 Standard_Boolean evolcoin = ((Stat1 == ChFiDS_OnSame && Stat2 == ChFiDS_OnDiff) ||
183 (Stat2 == ChFiDS_OnSame && Stat1 == ChFiDS_OnDiff));
185 Standard_Boolean OkinterCC,Okvisavis,SameSide;
186 Standard_Integer IFaCo1,IFaCo2;
187 Standard_Real UIntPC1,UIntPC2;
189 OkinterCC = ChFi3d_IsInFront(DStr,Corner1,Corner2,IFd1,IFd2,Sens1,Sens2,
190 UIntPC1,UIntPC2,FaCo,SameSide,
191 IFaCo1,IFaCo2,Okvisavis,Vtx,Standard_True);
194 cout<<"TwoCorner : pas de face commune"<<endl;
200 // The intersection of pcurves is calculated without restricting them by
202 OkinterCC= ChFi3d_IsInFront(DStr,Corner1,Corner2,IFd1,IFd2,Sens1,Sens2,
203 UIntPC1,UIntPC2,FaCo,SameSide,
204 IFaCo1,IFaCo2,Okvisavis,Vtx,Standard_True,1);
209 cout<<"TwoCorner : no common face"<<endl;
216 cout<<"biseau : failed intersection of tangency lines on common face"<<endl;
221 Standard_Integer IFaArc1 = 3-IFaCo1, IFaArc2 = 3-IFaCo2;
223 // It is checked if the fillets have a commonpoint on a common arc.
224 // This edge is the pivot of the bevel or of the kneecap.
226 ChFiDS_CommonPoint& CP1 = Fd1->ChangeVertex(isfirst1,IFaArc1);
227 ChFiDS_CommonPoint& CP2 = Fd2->ChangeVertex(isfirst2,IFaArc2);
229 if (!CP1.IsOnArc() || !CP2.IsOnArc()) {
231 cout<<"fail 1 of 2 fillets are not on arc"<<endl;
236 if ( ! CP1.Arc().IsSame( CP2.Arc()) ) {
237 // look like OnSame + OnDiff case (eap, Arp 9 2002, occ266)
239 cout<<"PerformTwoCornerbyInter(): fillets are not on the same arc"<<endl;
241 done = Standard_True;
242 PerformMoreThreeCorner(Index, 2);
248 Standard_Real parCP1 = CP1.ParameterOnArc();
249 Standard_Real parCP2 = CP2.ParameterOnArc();
250 Handle(BRepAdaptor_HCurve) Hpivot = new BRepAdaptor_HCurve(pivot);
251 if (!pivot.IsSame(CP2.Arc())){
252 Handle(Geom_Curve) csau;
253 Standard_Real ubid,vbid;
254 csau=BRep_Tool::Curve(pivot,ubid,vbid );
255 Handle(Geom_BoundedCurve) C1= Handle(Geom_BoundedCurve)::DownCast(csau);
257 GeomLib::ExtendCurveToPoint(C1,CP2.Point(),1,Standard_False);
258 GeomAdaptor_Curve cad;
260 Extrema_ExtPC ext(CP2.Point(),cad,1.e-4);
261 parCP2 = ext.Point(1).Parameter();
264 gp_Pnt psp1 = Hpivot->Value(parCP1);
265 gp_Pnt psp2 = Hpivot->Value(parCP2);
266 Standard_Real sameparam = (psp1.Distance(psp2) < 10 * tolesp);
268 TopoDS_Face FF1 = TopoDS::Face(DStr.Shape(Fd1->Index(IFaArc1)));
269 TopoDS_Face FF2 = TopoDS::Face(DStr.Shape(Fd2->Index(IFaArc2)));
270 TopTools_ListIteratorOfListOfShape Kt;
271 Standard_Boolean ok1 = Standard_False, ok2 = Standard_False;
272 for (Kt.Initialize(myEFMap(pivot)); Kt.More(); Kt.Next()){
273 TopoDS_Face F = TopoDS::Face(Kt.Value());
274 if(!ok1 && FF1.IsSame(F)){
277 if(!ok2 && FF2.IsSame(F)){
283 cout<<"fail one of surfaces has no common base face with the pivot edge"<<endl;
289 Handle(GeomAdaptor_HSurface) HS1, HS2;
290 HS1 = ChFi3d_BoundSurf (DStr,Fd1,IFaCo1,IFaArc1);
291 HS2 = ChFi3d_BoundSurf (DStr,Fd2,IFaCo2,IFaArc2);
293 TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4);
295 Handle(Geom2d_Curve) PGc1,PGc2;
296 Handle(Geom_Curve) Gc;
299 // Side common face, calculation of Pardeb.
300 ChFi3d_ComputesIntPC (Fd1->Interference(IFaCo1),
301 Fd2->Interference(IFaCo2),
302 HS1,HS2,UIntPC1,UIntPC2);
304 UV = Fd1->Interference(IFaCo1).PCurveOnSurf()->Value(UIntPC1);
305 Pardeb(1)= UV.X(); Pardeb(2)=UV.Y();
306 UV = Fd2->Interference(IFaCo2).PCurveOnSurf()->Value(UIntPC2);
307 Pardeb(3)= UV.X(); Pardeb(4)=UV.Y();
308 gp_Pnt PFaCo = HS1->Surface().Value(Pardeb(1),Pardeb(2));
310 // Side arc, calculation of Parfin.
311 Standard_Real UIntArc1 = Fd1->Interference(IFaArc1).Parameter(isfirst1);
312 Standard_Real UIntArc2 = Fd2->Interference(IFaArc2).Parameter(isfirst2);
314 ChFi3d_ComputesIntPC (Fd1->Interference(IFaArc1),Fd2->Interference(IFaArc2),
315 HS1,HS2,UIntArc1,UIntArc2);
316 UV = Fd1->Interference(IFaArc1).PCurveOnSurf()->Value(UIntArc1);
317 Parfin(1)= UV.X(); Parfin(2)=UV.Y();
318 UV = Fd2->Interference(IFaArc2).PCurveOnSurf()->Value(UIntArc2);
319 Parfin(3)= UV.X(); Parfin(4)=UV.Y();
321 if(Fd1->Surf() == Fd2->Surf()){
322 Reduce(UIntPC1,UIntPC2,HS1,HS2);
325 Standard_Real tolreached = tolesp;
327 !ChFi3d_ComputeCurves(HS1,HS2,Pardeb,Parfin,Gc,
328 PGc1,PGc2,tolesp,tol2d,tolreached)) {
330 cout<<"failed to calculate bevel error interSS"<<endl;
335 else if (IFaCo1 == 2 &&
336 !ChFi3d_ComputeCurves(HS1,HS2,Parfin,Pardeb,Gc,
337 PGc1,PGc2,tolesp,tol2d,tolreached)) {
339 cout<<"failed to calculate bevel error interSS"<<endl;
344 // CornerData are updated with results of the intersection.
345 Standard_Real WFirst = Gc->FirstParameter();
346 Standard_Real WLast = Gc->LastParameter();
347 Standard_Integer Ipoin1;
348 Standard_Integer Ipoin2;
349 ChFiDS_CommonPoint& cpco1 = Fd1->ChangeVertex(isfirst1,IFaCo1);
350 ChFiDS_CommonPoint& cpco2 = Fd2->ChangeVertex(isfirst2,IFaCo2);
351 Standard_Real tolpco = Max(cpco1.Tolerance(),cpco2.Tolerance());
352 ChFiDS_CommonPoint& cparc1 = Fd1->ChangeVertex(isfirst1,IFaArc1);
353 ChFiDS_CommonPoint& cparc2 = Fd2->ChangeVertex(isfirst2,IFaArc2);
354 Standard_Real tolparc = Max(cparc1.Tolerance(),cparc2.Tolerance());
355 Standard_Integer ICurv = DStr.AddCurve(TopOpeBRepDS_Curve(Gc,tolreached));
357 Corner1->SetParameters(isfirst1,WFirst,WLast);
358 Corner1->SetCurve(ICurv,isfirst1);
359 Corner1->ChangePCurve(isfirst1) = PGc1;
361 cpco1.SetPoint(PFaCo);
362 cpco1.SetTolerance(Max(tolreached,tolpco));
363 Fd1->ChangeInterference(IFaCo1).SetParameter(UIntPC1,isfirst1);
364 tolparc = Max(tolparc,tolreached);
365 cparc1.SetTolerance(Max(tolparc,tolreached));
366 Ipoin1 = ChFi3d_IndexPointInDS(Fd1->Vertex(isfirst1,1),DStr);
367 Corner1->SetIndexPoint(Ipoin1,isfirst1,1);
368 Ipoin2 = ChFi3d_IndexPointInDS(Fd1->Vertex(isfirst1,2),DStr);
369 Corner1->SetIndexPoint(Ipoin2,isfirst1,2);
371 Corner2->SetParameters(isfirst2,WFirst,WLast);
372 Corner2->SetCurve(ICurv,isfirst2);
373 Corner2->ChangePCurve(isfirst2) = PGc2;
374 Fd2->ChangeInterference(IFaCo2).SetParameter(UIntPC2,isfirst2);
375 Fd2->ChangeVertex(isfirst2,IFaCo2) = Fd1->Vertex(isfirst1,IFaCo1);
376 Fd2->ChangeVertex(isfirst2,IFaArc2) = Fd1->Vertex(isfirst1,IFaArc1);
377 if (IFaCo1!=IFaCo2) Corner2->SetOrientation(TopAbs_REVERSED,isfirst2);
378 Corner2->SetIndexPoint(Corner1->IndexPoint(isfirst1,IFaCo1),
380 Corner2->SetIndexPoint(Corner1->IndexPoint(isfirst1,IFaArc1),
382 //The tolerances of points are updated.
384 if(IFaCo1 == 1) ChFi3d_EnlargeBox(DStr,Corner1,Fd1,bco,barc,isfirst1);
385 else ChFi3d_EnlargeBox(DStr,Corner1,Fd1,barc,bco,isfirst1);
386 if(IFaCo2 == 1) ChFi3d_EnlargeBox(DStr,Corner2,Fd2,bco,barc,isfirst2);
387 else ChFi3d_EnlargeBox(DStr,Corner2,Fd2,barc,bco,isfirst2);
388 const ChFiDS_CommonPoint& cparc = Fd1->Vertex(isfirst1,IFaArc1);
389 ChFi3d_EnlargeBox(cparc.Arc(),myEFMap(cparc.Arc()),cparc.ParameterOnArc(),barc);
390 ChFi3d_SetPointTolerance(DStr,barc,Corner1->IndexPoint(isfirst1,IFaArc1));
391 ChFi3d_SetPointTolerance(DStr,bco,Corner1->IndexPoint(isfirst1,IFaCo1));
394 // It is necessary to identify the border surface,
395 // find the end point of the intersection Surf/Surf
396 // by the intersection of the tangency line of the small
397 // on the opposing face with the surface of the big,
398 // and finally intersect the big with the face at end
399 // between this point and the point on arc.
400 Standard_Boolean parcrois = Standard_False ;
401 TopExp_Explorer Expl;
402 for(Expl.Init(pivot.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
403 Expl.More(); Expl.Next()){
404 if(Expl.Current().IsSame(Vtx)){
405 parcrois = (Expl.Current().Orientation() == TopAbs_FORWARD);
409 Handle(ChFiDS_Stripe) BigCD, SmaCD;
410 Handle(ChFiDS_SurfData) BigFD, SmaFD;
411 Handle(GeomAdaptor_HSurface) BigHS, SmaHS;
412 Standard_Integer IFaCoBig, IFaCoSma, IFaArcBig, IFaArcSma;
413 Standard_Boolean isfirstBig, isfirstSma;
414 Standard_Real UIntPCBig, UIntPCSma;
416 if((parcrois && parCP2 > parCP1) || (!parcrois && parCP2 < parCP1)){
417 UIntPCBig = UIntPC2; UIntPCSma = UIntPC1;
418 BigHS = HS2; SmaHS = HS1;
419 BigCD = Corner2; SmaCD = Corner1;
420 BigFD = Fd2; SmaFD = Fd1;
421 IFaCoBig = IFaCo2; IFaCoSma = IFaCo1;
422 IFaArcBig = IFaArc2; IFaArcSma = IFaArc1;
423 isfirstBig = isfirst2; isfirstSma = isfirst1;
426 UIntPCBig = UIntPC1, UIntPCSma = UIntPC2;
427 BigHS = HS1; SmaHS = HS2;
428 BigCD = Corner1; SmaCD = Corner2;
429 BigFD = Fd1; SmaFD = Fd2;
430 IFaCoBig = IFaCo1; IFaCoSma = IFaCo2;
431 IFaArcBig = IFaArc1; IFaArcSma = IFaArc2;
432 isfirstBig = isfirst1; isfirstSma = isfirst2;
435 //Intersection of the big with the small :
436 //------------------------------------
438 // Pardeb (parameters of point PFaCo)
439 // the intersection is checked
440 ChFi3d_ComputesIntPC (SmaFD->Interference(IFaCoSma),
441 BigFD->Interference(IFaCoBig),
442 SmaHS,BigHS,UIntPCSma,UIntPCBig);
444 UVi = BigFD->Interference(IFaCoBig).PCurveOnSurf()->Value(UIntPCBig);
445 Pardeb(3)= UVi.X(); Pardeb(4)=UVi.Y();
446 UVi = SmaFD->Interference(IFaCoSma).PCurveOnSurf()->Value(UIntPCSma);
447 Pardeb(1)= UVi.X(); Pardeb(2)=UVi.Y();
448 gp_Pnt PFaCo = SmaHS->Value(UVi.X(),UVi.Y());
450 // Parfin (parameters of point PMil)
451 const ChFiDS_FaceInterference& FiArcSma = SmaFD->Interference(IFaArcSma);
452 Handle(Geom_Curve) ctg = DStr.Curve(FiArcSma.LineIndex()).Curve();
453 Handle(GeomAdaptor_HCurve) Hctg = new GeomAdaptor_HCurve();
454 GeomAdaptor_Curve& bid = Hctg->ChangeCurve();
455 Standard_Real temp,wi;
458 wi = temp = FiArcSma.FirstParameter();
459 if (UIntPCSma < temp)
461 bid.Load(ctg,temp,FiArcSma.LastParameter());
464 wi = temp = FiArcSma.LastParameter();
465 if (UIntPCSma > temp)
467 bid.Load(ctg,FiArcSma.FirstParameter(),temp);
469 if(SmaFD->Surf() == BigFD->Surf()){
470 Reduce(UIntPCSma,UIntPCBig,SmaHS,BigHS);
471 Reduce(UIntPCSma,UIntPCBig,Hctg);
473 if(!ChFi3d_IntCS(BigHS,Hctg,UVi,wi)){
475 cout<<"bevel : failed inter C S"<<endl;
480 Parfin(3) = UVi.X(); Parfin(4) = UVi.Y();
481 UVi = FiArcSma.PCurveOnSurf()->Value(wi);
482 Parfin(1) = UVi.X(); Parfin(2) = UVi.Y();
483 gp_Pnt PMil = SmaHS->Value(Parfin(1),Parfin(2));
485 Standard_Real tolreached;
486 if (!ChFi3d_ComputeCurves(SmaHS,BigHS,Pardeb,Parfin,Gc,
487 PGc1,PGc2,tolesp,tol2d,tolreached)) {
489 cout<<"failed to calculate bevel failed interSS"<<endl;
494 // SmaCD is updated, for it this is all.
495 Standard_Real WFirst = Gc->FirstParameter();
496 Standard_Real WLast = Gc->LastParameter();
497 Standard_Integer IpointCo, IpointMil, IpointArc;
498 ChFiDS_CommonPoint& psmaco = SmaFD->ChangeVertex(isfirstSma,IFaCoSma);
499 ChFiDS_CommonPoint& pbigco = BigFD->ChangeVertex(isfirstBig,IFaCoBig);
500 Standard_Real tolpco = Max(psmaco.Tolerance(),pbigco.Tolerance());
501 ChFiDS_CommonPoint& psmamil = SmaFD->ChangeVertex(isfirstSma,IFaArcSma);
502 Standard_Real tolpmil = psmamil.Tolerance();
503 Standard_Integer ICurv = DStr.AddCurve(TopOpeBRepDS_Curve(Gc,tolreached));
505 SmaCD->SetParameters(isfirstSma,WFirst,WLast);
506 SmaCD->SetCurve(ICurv,isfirstSma);
507 SmaCD->ChangePCurve(isfirstSma) = PGc1;
509 psmaco.SetPoint(PFaCo);
510 psmaco.SetTolerance(Max(tolpco,tolreached));
511 SmaFD->ChangeInterference(IFaCoSma).SetParameter(UIntPCSma,isfirstSma);
513 psmamil.SetPoint(PMil);
514 psmamil.SetTolerance(Max(tolpmil,tolreached));
515 SmaFD->ChangeInterference(IFaArcSma).SetParameter(wi,isfirstSma);
516 IpointCo = ChFi3d_IndexPointInDS(psmaco,DStr);
517 SmaCD->SetIndexPoint(IpointCo,isfirstSma,IFaCoSma);
518 IpointMil = ChFi3d_IndexPointInDS(psmamil,DStr);
519 SmaCD->SetIndexPoint(IpointMil,isfirstSma,IFaArcSma);
520 if (IFaCoSma == 2) SmaCD->SetOrientation(TopAbs_REVERSED,isfirstSma);
522 // For BigCD the first results are met in the DS.
523 BigCD->SetIndexPoint(IpointCo,isfirstBig,IFaCoBig);
524 BigFD->ChangeVertex(isfirstBig,IFaCoBig) = psmaco;
525 BigFD->ChangeInterference(IFaCoBig).SetParameter(UIntPCBig,isfirstBig);
527 TopOpeBRepDS_ListOfInterference& Li = DStr.ChangeCurveInterferences(ICurv);
528 Handle(TopOpeBRepDS_CurvePointInterference) Interfp;
529 Interfp = ChFi3d_FilPointInDS(TopAbs_FORWARD,ICurv,IpointCo,WFirst);
531 Interfp = ChFi3d_FilPointInDS(TopAbs_REVERSED,ICurv,IpointMil,WLast);
534 // the transition of curves of intersection on the Big
535 TopAbs_Orientation tra = BigFD->InterferenceOnS1().Transition();
536 TopAbs_Orientation ofac = DStr.Shape(BigFD->IndexOfS1()).Orientation();
537 TopAbs_Orientation ofil = BigFD->Orientation();
538 TopAbs_Orientation tracurv = TopAbs::Compose(ofac,ofil);
539 tracurv = TopAbs::Compose(tracurv,tra);
540 if(!isfirstBig) tracurv = TopAbs::Reverse(tracurv);
541 if(IFaCoBig != 1) tracurv = TopAbs::Reverse(tracurv);
543 Handle(TopOpeBRepDS_SurfaceCurveInterference) Interfc;
544 Standard_Integer ISurf = BigFD->Surf();
545 Interfc = ChFi3d_FilCurveInDS (ICurv,ISurf,PGc2,tracurv);
546 DStr.ChangeSurfaceInterferences(ISurf).Append(Interfc);
548 //The tolerances of points are updated (beginning).
549 Bnd_Box bco,bmil,barc;
550 if(IFaCoSma == 1) ChFi3d_EnlargeBox(DStr,SmaCD,SmaFD,bco,bmil,isfirstSma);
551 else ChFi3d_EnlargeBox(DStr,SmaCD,SmaFD,bmil,bco,isfirstSma);
552 ChFi3d_EnlargeBox(BigHS,PGc2,WFirst,WLast,bco,bmil);
554 // Intersection of the big with the face at end :
555 // -------------------------------------------
557 // Pardeb (parameters of PMil)
558 // The intersection curve surface is tried again, now with representation
559 // pcurve on face of the curve to be sure.
560 TopoDS_Face F = TopoDS::Face(DStr.Shape(SmaFD->Index(IFaArcSma)));
561 Handle(BRepAdaptor_HSurface) HF = new BRepAdaptor_HSurface(F);
562 Standard_Real fsma = FiArcSma.FirstParameter();
563 Standard_Real lsma = FiArcSma.LastParameter();
564 Standard_Real deltSma = 0.05 * (lsma - fsma);
565 Handle(Geom2d_Curve) pcpc = SmaFD->Interference(IFaArcSma).PCurveOnFace();
566 fsma = Max(pcpc->FirstParameter(),wi-deltSma);
567 lsma = Min(pcpc->LastParameter(),wi+deltSma);
572 Handle(Geom2dAdaptor_HCurve) c2df =
573 new Geom2dAdaptor_HCurve(SmaFD->Interference(IFaArcSma).PCurveOnFace(),fsma,lsma);
574 Adaptor3d_CurveOnSurface consf(c2df,HF);
575 Handle(Adaptor3d_HCurveOnSurface) Hconsf = new Adaptor3d_HCurveOnSurface(consf);
576 if(!ChFi3d_IntCS(BigHS,Hconsf,UVi,wi)) {
578 cout<<"bevel : failed inter C S"<<endl;
583 Pardeb(3) = UVi.X(); Pardeb(4) = UVi.Y();
584 UVi = SmaFD->Interference(IFaArcSma).PCurveOnFace()->Value(wi);
585 Pardeb(1) = UVi.X(); Pardeb(2) = UVi.Y();
586 gp_Pnt2d ppff1 = UVi;
588 // Parfin (parameters of the point cpend)
589 Standard_Real ptg = BigFD->Interference(IFaArcBig).Parameter(isfirstBig);
590 UVi = BigFD->Interference(IFaArcBig).PCurveOnSurf()->Value(ptg);
591 Parfin(3) = UVi.X(); Parfin(4) = UVi.Y();
592 ChFiDS_CommonPoint& cpend = BigFD->ChangeVertex(isfirstBig,IFaArcBig);
593 TopoDS_Edge etest = cpend.Arc();
594 if(BRep_Tool::IsClosed(etest,F)) etest.Reverse();
595 BRepAdaptor_Curve2d arc(etest,F);
596 UVi = arc.Value(cpend.ParameterOnArc());
597 Parfin(1) = UVi.X(); Parfin(2) = UVi.Y();
598 gp_Pnt2d ppff2 = UVi;
601 Standard_Real uu1,uu2,vv1,vv2;
602 ChFi3d_Boite(ppff1,ppff2,uu1,uu2,vv1,vv2);
603 // for the case when two chamfers are on two edges OnSame,
604 // it is necessary to extend the surface carrying F, or at least
606 ChFi3d_BoundFac(HF->ChangeSurface(),uu1,uu2,vv1,vv2,Standard_True);
608 if (!ChFi3d_ComputeCurves(HF,BigHS,Pardeb,Parfin,Gc,
609 PGc1,PGc2,tolesp,tol2d,tolreached)) {
611 cout<<"fail calculation bevel fail interSS"<<endl;
617 // End of update of the BigCD and the DS.
618 WFirst = Gc->FirstParameter();
619 WLast = Gc->LastParameter();
620 ICurv = DStr.AddCurve(TopOpeBRepDS_Curve(Gc,tolreached));
621 cpend.SetTolerance(Max(cpend.Tolerance(),tolreached));
622 IpointArc = ChFi3d_IndexPointInDS(cpend,DStr);
623 BigCD->SetIndexPoint(IpointArc,isfirstBig,IFaArcBig);
625 TopOpeBRepDS_ListOfInterference& Li7 = DStr.ChangeCurveInterferences(ICurv);
626 Interfp = ChFi3d_FilPointInDS(TopAbs_FORWARD,ICurv,IpointMil,WFirst);
628 Interfp = ChFi3d_FilPointInDS(TopAbs_REVERSED,ICurv,IpointArc,WLast);
630 Interfc = ChFi3d_FilCurveInDS (ICurv,ISurf,PGc2,tracurv);
631 DStr.ChangeSurfaceInterferences(ISurf).Append(Interfc);
632 BigCD->InDS(isfirstBig);
634 // Finally the information on faces is placed in the DS.
635 Standard_Integer IShape = DStr.AddShape(F);
636 if(SmaFD->Surf() == BigFD->Surf()){
637 tracurv = TopAbs::Compose(etest.Orientation(),
638 cpend.TransitionOnArc());
642 for (Exp.Init(F.Oriented(TopAbs_FORWARD),
643 TopAbs_EDGE);Exp.More();Exp.Next()) {
644 if (Exp.Current().IsSame(etest)) {
645 tracurv = TopAbs::Compose(Exp.Current().Orientation(),
646 cpend.TransitionOnArc());
651 Interfc = ChFi3d_FilCurveInDS(ICurv,IShape,PGc1,tracurv);
652 DStr.ChangeShapeInterferences(IShape).Append(Interfc);
654 //The tolerances of points are updated (end).
655 Handle(ChFiDS_Stripe) bidst;
656 if(IFaCoBig == 1) ChFi3d_EnlargeBox(DStr,bidst,BigFD,bco,barc,isfirstBig);
657 else ChFi3d_EnlargeBox(DStr,bidst,BigFD,barc,bco,isfirstBig);
658 ChFi3d_EnlargeBox(BigHS,PGc2,WFirst,WLast,bmil,barc);
659 ChFi3d_EnlargeBox(HF,PGc1,WFirst,WLast,bmil,barc);
660 ChFi3d_EnlargeBox(Gc,WFirst,WLast,bmil,barc);
661 const ChFiDS_CommonPoint& cparc = BigFD->Vertex(isfirstBig,IFaArcBig);
662 ChFi3d_EnlargeBox(cparc.Arc(),myEFMap(cparc.Arc()),cparc.ParameterOnArc(),barc);
664 ChFi3d_SetPointTolerance(DStr,bco,SmaCD->IndexPoint(isfirstSma,IFaCoSma));
665 ChFi3d_SetPointTolerance(DStr,bmil,SmaCD->IndexPoint(isfirstSma,IFaArcSma));
666 ChFi3d_SetPointTolerance(DStr,barc,BigCD->IndexPoint(isfirstBig,IFaArcBig));