1 // Copyright (c) 1997-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <Adaptor3d_TopolTool.hxx>
17 #include <BRep_Tool.hxx>
18 #include <BRepAdaptor_HCurve.hxx>
19 #include <BRepAdaptor_HCurve2d.hxx>
20 #include <BRepAdaptor_HSurface.hxx>
21 #include <BRepBlend_ConstRad.hxx>
22 #include <BRepBlend_ConstRadInv.hxx>
23 #include <BRepBlend_Line.hxx>
24 #include <BRepExtrema_DistShapeShape.hxx>
25 #include <ChFi3d_Builder_0.hxx>
26 #include <ChFi3d_FilBuilder.hxx>
27 #include <ChFiDS_CircSection.hxx>
28 #include <ChFiDS_CommonPoint.hxx>
29 #include <ChFiDS_FaceInterference.hxx>
30 #include <ChFiDS_FilSpine.hxx>
31 #include <ChFiDS_HData.hxx>
32 #include <ChFiDS_HElSpine.hxx>
33 #include <ChFiDS_ListIteratorOfListOfStripe.hxx>
34 #include <ChFiDS_ListOfStripe.hxx>
35 #include <ChFiDS_SecHArray1.hxx>
36 #include <ChFiDS_SequenceOfSurfData.hxx>
37 #include <ChFiDS_Spine.hxx>
38 #include <ChFiDS_Stripe.hxx>
39 #include <ChFiDS_SurfData.hxx>
41 #include <FilletSurf_ErrorTypeStatus.hxx>
42 #include <FilletSurf_InternalBuilder.hxx>
43 #include <FilletSurf_StatusDone.hxx>
44 #include <FilletSurf_StatusType.hxx>
45 #include <Geom2d_Curve.hxx>
46 #include <Geom_Circle.hxx>
47 #include <Geom_Curve.hxx>
48 #include <Geom_Plane.hxx>
49 #include <Geom_Surface.hxx>
50 #include <Geom_TrimmedCurve.hxx>
51 #include <GeomAbs_Shape.hxx>
52 #include <GeomAdaptor_HCurve.hxx>
53 #include <GeomAdaptor_HSurface.hxx>
54 #include <GeomAdaptor_Surface.hxx>
55 #include <gp_Circ.hxx>
57 #include <IntCurveSurface_HInter.hxx>
58 #include <IntCurveSurface_IntersectionPoint.hxx>
59 #include <Precision.hxx>
60 #include <Standard_ConstructionError.hxx>
62 #include <TopoDS_Face.hxx>
63 #include <TopoDS_Shape.hxx>
64 #include <TopOpeBRepDS_HDataStructure.hxx>
65 #include <TopTools_ListIteratorOfListOfShape.hxx>
67 static Standard_Boolean isinlist(const TopoDS_Shape& E,
68 const TopTools_ListOfShape& L){
69 TopTools_ListIteratorOfListOfShape It;
70 for (It.Initialize(L); It.More(); It.Next()){
71 if(E.IsSame(It.Value())) return 1;
76 static Standard_Boolean IntPlanEdge(Handle(BRepAdaptor_HCurve)& Ed,
79 const Standard_Real tol3d)
81 Standard_Boolean done = 0;
82 Standard_Real f = Ed->FirstParameter();
83 Standard_Real l = Ed->LastParameter();
84 gp_Pnt Or = P.Location();
85 Handle(Geom_Plane) Pln = new Geom_Plane(P);
86 Handle(GeomAdaptor_HSurface)
87 Plan = new GeomAdaptor_HSurface(GeomAdaptor_Surface(Pln));
89 IntCurveSurface_HInter Intersection;
90 Standard_Integer nbp ,iip;
91 IntCurveSurface_IntersectionPoint IP;
92 Standard_Real dist = RealLast();
94 Intersection.Perform(Ed,Plan);
96 if(Intersection.IsDone()){
97 nbp = Intersection.NbPoints();
98 for (iip = 1; iip <= nbp; iip++){
99 IP = Intersection.Point(iip);
100 gp_Pnt pint = IP.Pnt();
101 Standard_Real d = pint.Distance(Or);
109 gp_Pnt pdeb = Ed->Value(f);
110 gp_Pnt pfin = Ed->Value(l);
112 //check if the extremities are not solution
113 ElSLib::Parameters(P,pdeb,u,v);
114 gp_Pnt projdeb = ElSLib::Value(u,v,P);
115 Standard_Real dprojdeb = pdeb.Distance(projdeb);
117 Standard_Real d = pdeb.Distance(Or);
124 ElSLib::Parameters(P,pfin,u,v);
125 gp_Pnt projfin = ElSLib::Value(u,v,P);
126 Standard_Real dprojfin = pfin.Distance(projfin);
128 Standard_Real d = pfin.Distance(Or);
138 static Standard_Boolean ComputeEdgeParameter(const Handle(ChFiDS_Spine)& Spine,
139 const Standard_Integer ind,
140 const Standard_Real pelsp,
142 const Standard_Real tol3d)
144 Handle(ChFiDS_HElSpine) Guide = Spine->ElSpine(ind);
146 Guide->D1(pelsp,P,V);
148 Handle(BRepAdaptor_HCurve) ed = new BRepAdaptor_HCurve();
149 ed->ChangeCurve() = Spine->CurrentElementarySpine(ind);
150 return IntPlanEdge(ed,pln,ped,tol3d);
153 //=======================================================================
154 //function : FilletSurf_InternalBuilder
156 //=======================================================================
158 FilletSurf_InternalBuilder::FilletSurf_InternalBuilder
159 (const TopoDS_Shape& S,
160 const ChFi3d_FilletShape FShape,
161 const Standard_Real Ta,
162 const Standard_Real Tapp3d,
163 const Standard_Real Tapp2d):ChFi3d_FilBuilder(S,FShape,Ta)
165 SetParams(Ta,Tapp3d,Tapp2d,
166 Tapp3d,Tapp2d,1.e-3);
167 SetContinuity(GeomAbs_C2,Ta);
170 //=======================================================================
172 //purpose : creation of spine on a set of edges
177 // 3 : non G1 adjacent faces
178 // 4 : edge is not on the shape
179 // 5 : edge is not alive
180 //=======================================================================
182 Standard_Integer FilletSurf_InternalBuilder::Add(const TopTools_ListOfShape& E,
183 const Standard_Real R)
185 if(E.IsEmpty()) return 1;
186 TopTools_ListIteratorOfListOfShape It;
187 for(It.Initialize(E); It.More(); It.Next()){
188 TopoDS_Edge cured = TopoDS::Edge(It.Value());
189 if(cured.IsNull()) return 4;
190 if(!myEFMap.Contains(cured)) return 4;
191 //check if the edge is a fracture edge
193 for(It.Initialize(myEFMap(cured));It.More();It.Next()){
195 ff1 = TopoDS::Face(It.Value());
198 ff2 = TopoDS::Face(It.Value());
199 if(!ff2.IsSame(ff1)){
204 if(ff1.IsNull() || ff2.IsNull()) return 5;
205 if(ff1.IsSame(ff2)) return 5;
206 if(BRep_Tool::Continuity(cured,ff1,ff2) != GeomAbs_C0) return 5;
208 TopoDS_Edge ed = TopoDS::Edge(E.First());
209 ed.Orientation(TopAbs_FORWARD);
210 ChFi3d_FilBuilder::Add(R,ed);
211 Handle(ChFiDS_Stripe) st = myListStripe.First();
212 Handle(ChFiDS_Spine)& sp = st->ChangeSpine();
213 Standard_Boolean periodic = sp->IsPeriodic();
215 //It is checked if edges of list E are in the contour,
216 //the edges that arenot in the list are removed from the contour,
217 //it is checked that the remainder is monoblock.
219 for(It.Initialize(E); It.More(); It.Next()){
220 TopoDS_Edge cured = TopoDS::Edge(It.Value());
221 if(!Contains(cured)) return 2;
224 Handle(ChFiDS_FilSpine) newsp = new ChFiDS_FilSpine();
225 Standard_Boolean debut = 0;
226 Standard_Integer premierquinyestpas = 0;
227 Standard_Integer yatrou = 0;
228 for(Standard_Integer i = 1; i <= sp->NbEdges(); i++){
229 TopoDS_Edge cured = sp->Edges(i);
230 if(isinlist(cured,E)){
232 if(premierquinyestpas) {
236 newsp->SetEdges(cured);
238 else if(debut && !premierquinyestpas) premierquinyestpas = i;
240 if(!periodic && yatrou) return 2;
241 if(periodic && yatrou){
242 Standard_Boolean vraitrou = 0, aLocalDebut = 0;
243 for(Standard_Integer i = sp->NbEdges(); i > yatrou; i--){
244 TopoDS_Edge cured = sp->Edges(i);
245 if(isinlist(cured,E)){
246 if(vraitrou) return 2;
247 newsp->PutInFirst(cured);
249 else if(aLocalDebut) vraitrou = 1;
254 if(newsp->NbEdges() != sp->NbEdges()) {
260 //ElSpine is immediately constructed
261 Handle(ChFiDS_HElSpine) hels = new ChFiDS_HElSpine();
264 sp->D1(sp->FirstParameter(),PFirst,TFirst);
265 sp->D1(sp->LastParameter(),PLast,TLast);
266 hels->ChangeCurve().FirstParameter(sp->FirstParameter());
267 hels->ChangeCurve().SetFirstPointAndTgt(PFirst,TFirst);
268 hels->ChangeCurve().LastParameter(sp->LastParameter());
269 hels->ChangeCurve().SetLastPointAndTgt(PLast,TLast);
270 ChFi3d_PerformElSpine(hels,sp,myConti,tolesp);
271 sp->AppendElSpine(hels);
272 sp->SplitDone(Standard_True);
276 //=======================================================================
279 //=======================================================================
281 void FilletSurf_InternalBuilder::Perform()
283 //PerformSetOfSurfOnElSpine is enough.
285 Handle(ChFiDS_Stripe) Stripe = myListStripe.First();
286 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
287 HData = new ChFiDS_HData();
288 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
289 TopAbs_Orientation RefOr1,RefOr2;
290 Standard_Integer RefChoix;
291 StripeOrientations(Spine,RefOr1,RefOr2,RefChoix);
292 Stripe->OrientationOnFace1(RefOr1);
293 Stripe->OrientationOnFace2(RefOr2);
294 Stripe->Choix(RefChoix);
295 PerformSetOfKGen(Stripe,0);
298 //=======================================================================
299 //function : PerformSurf
301 //=======================================================================
304 FilletSurf_InternalBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData,
305 const Handle(ChFiDS_HElSpine)& Guide,
306 const Handle(ChFiDS_Spine)& Spine,
307 const Standard_Integer Choix,
308 const Handle(BRepAdaptor_HSurface)& S1,
309 const Handle(Adaptor3d_TopolTool)& I1,
310 const Handle(BRepAdaptor_HSurface)& S2,
311 const Handle(Adaptor3d_TopolTool)& I2,
312 const Standard_Real MaxStep,
313 const Standard_Real Fleche,
314 const Standard_Real TolGuide,
315 Standard_Real& First,
317 const Standard_Boolean Inside,
318 const Standard_Boolean Appro,
319 const Standard_Boolean Forward,
320 const Standard_Boolean RecOnS1,
321 const Standard_Boolean RecOnS2,
322 const math_Vector& Soldep,
323 Standard_Integer& Intf,
324 Standard_Integer& Intl)
326 Handle(ChFiDS_SurfData) Data = SeqData(1);
327 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
328 if(fsp.IsNull()) throw Standard_ConstructionError("PerformSurf : this is not the spine of a fillet");
329 Handle(BRepBlend_Line) lin;
330 TopAbs_Orientation Or = S1->ChangeSurface().Face().Orientation();
331 if(!fsp->IsConstant()) throw Standard_ConstructionError("PerformSurf : no variable radiuses");
332 // Standard_Boolean maybesingular; //pour scinder les Surfdata singulieres
334 BRepBlend_ConstRad Func(S1,S2,Guide);
335 BRepBlend_ConstRadInv FInv(S1,S2,Guide);
336 Func.Set(fsp->Radius(),Choix);
337 FInv.Set(fsp->Radius(),Choix);
338 switch (GetFilletShape()) {
339 case ChFi3d_Rational:
340 Func.Set(BlendFunc_Rational);
342 case ChFi3d_QuasiAngular:
343 Func.Set(BlendFunc_QuasiAngular);
345 case ChFi3d_Polynomial:
346 Func.Set(BlendFunc_Polynomial);
348 Standard_Real PFirst = First;
349 done = SimulData(Data,Guide,lin,S1,I1,
350 S2,I2,Func,FInv,PFirst,MaxStep,Fleche,
351 TolGuide,First,Last,Inside,Appro,Forward,Soldep,
353 if(!done) return Standard_False;
354 if(lin->StartPointOnFirst().NbPointOnRst() !=0){
355 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
356 Standard_True, Data->ChangeVertexFirstOnS1(), tolesp);
358 if(lin->EndPointOnFirst().NbPointOnRst() !=0){
359 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
360 Standard_False,Data->ChangeVertexLastOnS1(), tolesp);
362 if(lin->StartPointOnSecond().NbPointOnRst() !=0){
363 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
364 Standard_True, Data->ChangeVertexFirstOnS2(), tolesp);
366 if(lin->EndPointOnSecond().NbPointOnRst() !=0){
367 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
368 Standard_False, Data->ChangeVertexLastOnS2(), tolesp);
370 done = CompleteData(Data,Func,lin,S1,S2,Or,0,0,0,0);
371 if(!done) throw Standard_Failure("PerformSurf : Failed approximation!");
372 // maybesingular = (Func.GetMinimalDistance()<=100*tolapp3d);
373 Standard_Boolean ok = Standard_False;
376 const ChFiDS_CommonPoint& cpf1 = Data->VertexFirstOnS1();
378 TopoDS_Face F1 = S1->ChangeSurface().Face();
380 Intf = !SearchFace(Spine,cpf1,F1,bid);
383 const ChFiDS_CommonPoint& cpf2 = Data->VertexFirstOnS2();
384 if(cpf2.IsOnArc() && !ok){
385 TopoDS_Face F2 = S2->ChangeSurface().Face();
387 Intf = !SearchFace(Spine,cpf2,F2,bid);
392 const ChFiDS_CommonPoint& cpl1 = Data->VertexLastOnS1();
394 TopoDS_Face F1 = S1->ChangeSurface().Face();
396 Intl = !SearchFace(Spine,cpl1,F1,bid);
399 const ChFiDS_CommonPoint& cpl2 = Data->VertexLastOnS2();
400 if(cpl2.IsOnArc() && !ok){
401 TopoDS_Face F2 = S2->ChangeSurface().Face();
403 Intl = !SearchFace(Spine,cpl2,F2,bid);
405 Data->FirstSpineParam(First);
406 Data->LastSpineParam (Last);
408 // if (maybesingular) SplitSurf(SeqData, lin);
409 // Necessite de trimer resultats : A faire
410 return Standard_True;
413 void FilletSurf_InternalBuilder::PerformSurf (ChFiDS_SequenceOfSurfData& , const Handle(ChFiDS_HElSpine)& , const Handle(ChFiDS_Spine)& , const Standard_Integer , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const Handle(BRepAdaptor_HCurve2d)& , const Handle(BRepAdaptor_HSurface)& , const Handle(BRepAdaptor_HCurve2d)& , Standard_Boolean& , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const TopAbs_Orientation , const Standard_Real , const Standard_Real , const Standard_Real , Standard_Real& , Standard_Real& , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const math_Vector& )
415 throw Standard_DomainError("BlendFunc_CSConstRad::Section : Not implemented");
418 void FilletSurf_InternalBuilder::PerformSurf (ChFiDS_SequenceOfSurfData& , const Handle(ChFiDS_HElSpine)& , const Handle(ChFiDS_Spine)& , const Standard_Integer , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const TopAbs_Orientation , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const Handle(BRepAdaptor_HCurve2d)& , const Handle(BRepAdaptor_HSurface)& , const Handle(BRepAdaptor_HCurve2d)& , Standard_Boolean& , const Standard_Real , const Standard_Real , const Standard_Real , Standard_Real& , Standard_Real& , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const math_Vector& )
420 throw Standard_DomainError("BlendFunc_CSConstRad::Section : Not implemented");
423 void FilletSurf_InternalBuilder::PerformSurf (ChFiDS_SequenceOfSurfData& , const Handle(ChFiDS_HElSpine)& , const Handle(ChFiDS_Spine)& , const Standard_Integer , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const Handle(BRepAdaptor_HCurve2d)& , const Handle(BRepAdaptor_HSurface)& , const Handle(BRepAdaptor_HCurve2d)& , Standard_Boolean& , const TopAbs_Orientation , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const Handle(BRepAdaptor_HCurve2d)& , const Handle(BRepAdaptor_HSurface)& , const Handle(BRepAdaptor_HCurve2d)& , Standard_Boolean& , const TopAbs_Orientation , const Standard_Real , const Standard_Real , const Standard_Real , Standard_Real& , Standard_Real& , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const math_Vector& )
425 throw Standard_DomainError("BlendFunc_CSConstRad::Section : Not implemented");
428 Standard_Boolean FilletSurf_InternalBuilder::Done() const
432 //=======================================================================
433 //function : NbSurface
434 //purpose : gives the number of NUBS surfaces of the Fillet
435 //=======================================================================
437 Standard_Integer FilletSurf_InternalBuilder::NbSurface() const
439 return myListStripe.First()->SetOfSurfData()->Length();
442 //=======================================================================
443 //function : SurfaceFillet
444 //purpose : gives the NUBS surface of index Index
445 //=======================================================================
447 const Handle(Geom_Surface)& FilletSurf_InternalBuilder::SurfaceFillet(const Standard_Integer Index) const
449 Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->Surf();
451 return myDS->Surface(isurf).Surface();
454 //=======================================================================
455 //function : TolApp3d
456 //purpose : gives the 3d tolerance reached during approximation
457 //=======================================================================
459 Standard_Real FilletSurf_InternalBuilder::TolApp3d(const Standard_Integer Index) const
461 Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->Surf();
463 return myDS->Surface(isurf).Tolerance();
466 //=======================================================================
467 //function : SupportFace1
468 //purpose : gives the first support face relative to SurfaceFillet(Index)
469 //=======================================================================
470 const TopoDS_Face& FilletSurf_InternalBuilder::SupportFace1(const Standard_Integer Index) const
472 Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->IndexOfS1();
474 return TopoDS::Face(myDS->Shape(isurf));
476 //=======================================================================
477 //function : SupportFace2
478 //purpose : gives the second support face relative to SurfaceFillet(Index)
479 //=======================================================================
480 const TopoDS_Face& FilletSurf_InternalBuilder::SupportFace2(const Standard_Integer Index) const
482 Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->IndexOfS2();
484 return TopoDS::Face(myDS->Shape(isurf));
486 //===============================================================================
487 //function : CurveOnSup1
488 //purpose : gives the 3d curve of SurfaceFillet(Index) on SupportFace1(Index)
489 //===============================================================================
491 const Handle(Geom_Curve)& FilletSurf_InternalBuilder::CurveOnFace1(const Standard_Integer Index) const
493 Standard_Integer icurv = myListStripe.First()->SetOfSurfData()->Value(Index)->
494 InterferenceOnS1().LineIndex();
495 return myDS->Curve(icurv).Curve();
498 //=======================================================================
499 //function : CurveOnSup2
500 //purpose : gives the 3d curve of SurfaceFillet(Index) on SupportFace2(Index
501 //=======================================================================
503 const Handle(Geom_Curve)& FilletSurf_InternalBuilder::CurveOnFace2(const Standard_Integer Index) const
505 Standard_Integer icurv=myListStripe.First()->SetOfSurfData()->Value(Index)->
506 InterferenceOnS2().LineIndex();
507 return myDS->Curve(icurv).Curve();
509 //=======================================================================
510 //function : PCurveOnFace1
511 //purpose : gives the PCurve associated to CurvOnSup1(Index) on the support face
512 //=======================================================================
513 const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurveOnFace1(const Standard_Integer Index) const
515 return myListStripe.First()->SetOfSurfData()->Value(Index)->
516 InterferenceOnS1().PCurveOnFace();
520 //=======================================================================
521 //function : PCurveOnFillet1
522 //purpose : gives the PCurve associated to CurveOnFace1(Index) on the Fillet
523 //=======================================================================
525 const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurve1OnFillet(const Standard_Integer Index) const
526 {return myListStripe.First()->SetOfSurfData()->Value(Index)->
527 InterferenceOnS1().PCurveOnSurf();
531 //=======================================================================
532 //function : PCurveOnFace2
533 //purpose : gives the PCurve associated to CurvOnSup2(Index) on the support face
534 //=======================================================================
535 const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurveOnFace2(const Standard_Integer Index) const
537 return myListStripe.First()->SetOfSurfData()->Value(Index)->
538 InterferenceOnS2().PCurveOnFace();
541 //=======================================================================
542 //function : PCurveOnFillet2
543 //purpose : gives the PCurve associated to CurveOnFace2(Index) on the Fillet
544 //=======================================================================
545 const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurve2OnFillet(const Standard_Integer Index) const
546 {return myListStripe.First()->SetOfSurfData()->Value(Index)->
547 InterferenceOnS2().PCurveOnSurf();
551 //=======================================================================
552 //function : FirstParameter
553 //purpose : gives the parameter of the fillet on the first edge
554 //=======================================================================
556 Standard_Real FilletSurf_InternalBuilder::FirstParameter() const
558 const Handle(ChFiDS_Stripe)& st = myListStripe.First();
559 const Handle(ChFiDS_Spine)& sp = st->Spine();
560 const Handle(ChFiDS_SurfData)& sd = st->SetOfSurfData()->Value(1);
561 Standard_Real p = sd->FirstSpineParam();
562 Standard_Integer ind = 1;
563 if(sp->IsPeriodic()) ind = sp->Index(p);
565 if(ComputeEdgeParameter(sp,ind,p,ep,tolesp)) return ep;
568 //=======================================================================
569 //function : LastParameter
570 //purpose : gives the parameter of the fillet on the last edge
571 //=======================================================================
572 Standard_Real FilletSurf_InternalBuilder::LastParameter() const
574 const Handle(ChFiDS_Stripe)& st = myListStripe.First();
575 const Handle(ChFiDS_Spine)& sp = st->Spine();
576 const Handle(ChFiDS_SurfData)& sd = st->SetOfSurfData()->Value(NbSurface());
577 Standard_Real p = sd->LastSpineParam();
578 Standard_Integer ind = sp->NbEdges();
579 if(sp->IsPeriodic()) ind = sp->Index(p);
581 if(ComputeEdgeParameter(sp,ind,p,ep,tolesp)) return ep;
585 //=======================================================================
586 //function : StatusStartSection
588 // twoExtremityonEdge: each extremity of start section of the Fillet is
589 // on the edge of the corresponding support face.
590 // OneExtremityOnEdge: only one of the extremities of start section of the Fillet
591 // is on the edge of the corresponding support face.
592 // NoExtremityOnEdge: any extremity of start section of the fillet is on
593 // the edge of the corresponding support face.
594 //=======================================================================
597 FilletSurf_StatusType FilletSurf_InternalBuilder::StartSectionStatus() const
600 Standard_Boolean isonedge1 = myListStripe.First()->SetOfSurfData()->Value(1)->
601 VertexFirstOnS1().IsOnArc();
602 Standard_Boolean isonedge2= myListStripe.First()->SetOfSurfData()->Value(1)->
603 VertexFirstOnS2().IsOnArc();;
605 if (isonedge1 && isonedge2)
606 {return FilletSurf_TwoExtremityOnEdge;}
607 else if ((!isonedge1)&& (!isonedge2))
608 {return FilletSurf_NoExtremityOnEdge ;}
610 {return FilletSurf_OneExtremityOnEdge;}
612 //=======================================================================
613 //function : StatusEndSection()
615 // twoExtremityonEdge: each extremity of end section of the Fillet is
616 // on the edge of the corresponding support face.
617 // OneExtremityOnEdge: only one of the extremities of end section of the Fillet
618 // is on the edge of the corresponding support face.
619 // NoExtremityOnEdge: any extremity of end section of the fillet is on
620 // the edge of the corresponding support face.
621 //=======================================================================
622 FilletSurf_StatusType FilletSurf_InternalBuilder::EndSectionStatus() const
624 Standard_Boolean isonedge1 = myListStripe.First()->SetOfSurfData()->Value(NbSurface())->
625 VertexLastOnS1().IsOnArc();
626 Standard_Boolean isonedge2= myListStripe.First()->SetOfSurfData()->Value(NbSurface())->
627 VertexLastOnS2().IsOnArc();
629 if (isonedge1 && isonedge2)
630 { return FilletSurf_TwoExtremityOnEdge;}
631 else if ((!isonedge1)&& (!isonedge2))
632 { return FilletSurf_NoExtremityOnEdge;}
634 { return FilletSurf_OneExtremityOnEdge;}
638 //=======================================================================
639 //function : Simulate
640 //purpose : computes only the sections used in the computation of the fillet
641 //=======================================================================
642 void FilletSurf_InternalBuilder::Simulate()
644 //ChFi3d_FilBuilder::Simulate(1);
645 Handle(ChFiDS_Stripe) Stripe = myListStripe.First();
646 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
647 HData = new ChFiDS_HData();
648 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
649 TopAbs_Orientation RefOr1,RefOr2;
650 Standard_Integer RefChoix;
651 StripeOrientations(Spine,RefOr1,RefOr2,RefChoix);
652 Stripe->OrientationOnFace1(RefOr1);
653 Stripe->OrientationOnFace2(RefOr2);
654 Stripe->Choix(RefChoix);
655 PerformSetOfKGen(Stripe,1);
659 //=======================================================================
660 //function : NbSection
661 //purpose : gives the number of sections relative to SurfaceFillet(IndexSurf)
662 //=======================================================================
663 Standard_Integer FilletSurf_InternalBuilder::NbSection(const Standard_Integer IndexSurf) const
665 return Sect(1,IndexSurf)->Length();
668 //=======================================================================
670 //purpose : gives the arc of circle corresponding to section number
671 // IndexSec of SurfaceFillet(IndexSurf) (The basis curve of the
672 // trimmed curve is a Geom_Circle)
673 //=======================================================================
674 void FilletSurf_InternalBuilder::Section(const Standard_Integer IndexSurf, const Standard_Integer IndexSec, Handle(Geom_TrimmedCurve)& Circ) const
677 Standard_Real deb,fin;
678 Sect(1,IndexSurf)->Value(IndexSec).Get(c,deb,fin);
679 Handle(Geom_Circle) Gc = new Geom_Circle(c);
680 Circ= new Geom_TrimmedCurve(Gc,deb,fin);