Replacing french comments by english one
[occt.git] / src / FilletSurf / FilletSurf_InternalBuilder.cxx
CommitLineData
7fd59977 1#include <FilletSurf_InternalBuilder.ixx>
2#include <FilletSurf_StatusDone.hxx>
3#include <FilletSurf_ErrorTypeStatus.hxx>
4#include <FilletSurf_StatusType.hxx>
5
6#include <ChFi3d_FilBuilder.hxx>
7#include <ChFi3d_Builder_0.hxx>
8
9#include <ChFiDS_HData.hxx>
10#include <ChFiDS_FilSpine.hxx>
11#include <ChFiDS_HElSpine.hxx>
12#include <ChFiDS_Stripe.hxx>
13#include <ChFiDS_ListOfStripe.hxx>
14#include <ChFiDS_ListIteratorOfListOfStripe.hxx>
15#include <ChFiDS_SurfData.hxx>
16#include <ChFiDS_SequenceOfSurfData.hxx>
17#include <ChFiDS_FaceInterference.hxx>
18#include <ChFiDS_CommonPoint.hxx>
19#include <ChFiDS_CircSection.hxx>
20#include <ChFiDS_SecHArray1.hxx>
21
22#include <BRepBlend_Line.hxx>
23#include <BRepBlend_ConstRad.hxx>
24#include <BRepBlend_ConstRadInv.hxx>
25
26#include <TopoDS.hxx>
27#include <TopTools_ListIteratorOfListOfShape.hxx>
28
29#include <BRep_Tool.hxx>
30
31#include <BRepAdaptor_HCurve.hxx>
32#include <GeomAdaptor_HSurface.hxx>
33#include <GeomAdaptor_Surface.hxx>
34#include <GeomAbs_Shape.hxx>
35
36#include <TopOpeBRepDS_HDataStructure.hxx>
37
38#include <Geom_Surface.hxx>
39#include <Geom_Plane.hxx>
40#include <Geom_Curve.hxx>
41#include <Geom_TrimmedCurve.hxx>
42#include <Geom_Circle.hxx>
43#include <GeomAdaptor_HCurve.hxx>
44
45#include <ElSLib.hxx>
46
47#include <gp_Circ.hxx>
48#include <gp_Pln.hxx>
49
50#include <IntCurveSurface_HInter.hxx>
51#include <IntCurveSurface_IntersectionPoint.hxx>
52#include <BRepExtrema_DistShapeShape.hxx>
53
54#include <Standard_ConstructionError.hxx>
55#include <Precision.hxx>
56
57static Standard_Boolean isinlist(const TopoDS_Shape& E,
58 const TopTools_ListOfShape& L){
59 TopTools_ListIteratorOfListOfShape It;
60 for (It.Initialize(L); It.More(); It.Next()){
61 if(E.IsSame(It.Value())) return 1;
62 }
63 return 0;
64}
65
66static Standard_Boolean IntPlanEdge(Handle(BRepAdaptor_HCurve)& Ed,
67 const gp_Pln& P,
68 Standard_Real& w,
69 const Standard_Real tol3d)
70{
71 Standard_Boolean done = 0;
72 Standard_Real f = Ed->FirstParameter();
73 Standard_Real l = Ed->LastParameter();
74 gp_Pnt Or = P.Location();
75 Handle(Geom_Plane) Pln = new Geom_Plane(P);
76 Handle(GeomAdaptor_HSurface)
77 Plan = new GeomAdaptor_HSurface(GeomAdaptor_Surface(Pln));
78
79 IntCurveSurface_HInter Intersection;
80 Standard_Integer nbp ,iip;
81 IntCurveSurface_IntersectionPoint IP;
82 Standard_Real dist = RealLast();
83
84 Intersection.Perform(Ed,Plan);
85
86 if(Intersection.IsDone()){
87 nbp = Intersection.NbPoints();
88 for (iip = 1; iip <= nbp; iip++){
89 IP = Intersection.Point(iip);
90 gp_Pnt pint = IP.Pnt();
91 Standard_Real d = pint.Distance(Or);
92 if(d<dist){
93 done = 1;
94 w = IP.W();
95 dist = d;
96 }
97 }
98 }
99 gp_Pnt pdeb = Ed->Value(f);
100 gp_Pnt pfin = Ed->Value(l);
101 Standard_Real u,v;
81bba717 102 //check if the extremities are not solution
7fd59977 103 ElSLib::Parameters(P,pdeb,u,v);
104 gp_Pnt projdeb = ElSLib::Value(u,v,P);
105 Standard_Real dprojdeb = pdeb.Distance(projdeb);
106 if(dprojdeb<tol3d){
107 Standard_Real d = pdeb.Distance(Or);
108 if(d<dist){
109 done = 1;
110 w = f;
111 dist = d;
112 }
113 }
114 ElSLib::Parameters(P,pfin,u,v);
115 gp_Pnt projfin = ElSLib::Value(u,v,P);
116 Standard_Real dprojfin = pfin.Distance(projfin);
117 if(dprojfin<tol3d){
118 Standard_Real d = pfin.Distance(Or);
119 if(d<dist){
120 done = 1;
121 w = l;
122 dist = d;
123 }
124 }
125 return done;
126}
127
128static Standard_Boolean ComputeEdgeParameter(const Handle(ChFiDS_Spine)& Spine,
129 const Standard_Integer ind,
130 const Standard_Real pelsp,
131 Standard_Real& ped,
132 const Standard_Real tol3d)
133{
134 Handle(ChFiDS_HElSpine) Guide = Spine->ElSpine(ind);
135 gp_Pnt P; gp_Vec V;
136 Guide->D1(pelsp,P,V);
137 gp_Pln pln(P,V);
138 Handle(BRepAdaptor_HCurve) ed = new BRepAdaptor_HCurve();
139 ed->ChangeCurve() = Spine->CurrentElementarySpine(ind);
140 return IntPlanEdge(ed,pln,ped,tol3d);
141}
142
143//=======================================================================
144//function : FilletSurf_InternalBuilder
145//purpose :
146//=======================================================================
147
148FilletSurf_InternalBuilder::FilletSurf_InternalBuilder
149(const TopoDS_Shape& S,
150 const ChFi3d_FilletShape FShape,
151 const Standard_Real Ta,
152 const Standard_Real Tapp3d,
153 const Standard_Real Tapp2d):ChFi3d_FilBuilder(S,FShape,Ta)
154{
155 SetParams(Ta,Tapp3d,Tapp2d,
156 Tapp3d,Tapp2d,1.e-3);
157 SetContinuity(GeomAbs_C2,Ta);
158}
159
160//=======================================================================
161//function : Add
81bba717 162//purpose : creation of spine on a set of edges
7fd59977 163//
81bba717 164// 0 : no problem
165// 1 : empty list
166// 2 : non g1 edges
167// 3 : non G1 adjacent faces
168// 4 : edge is not on the shape
169// 5 : edge is not alive
7fd59977 170//=======================================================================
171
172Standard_Integer FilletSurf_InternalBuilder::Add(const TopTools_ListOfShape& E,
173 const Standard_Real R)
174{
175 if(E.IsEmpty()) return 1;
176 TopTools_ListIteratorOfListOfShape It;
177 for(It.Initialize(E); It.More(); It.Next()){
178 TopoDS_Edge cured = TopoDS::Edge(It.Value());
179 if(cured.IsNull()) return 4;
180 if(!myEFMap.Contains(cured)) return 4;
81bba717 181 //check if the edge is a fracture edge
7fd59977 182 TopoDS_Face ff1,ff2;
183 for(It.Initialize(myEFMap(cured));It.More();It.Next()){
184 if (ff1.IsNull()) {
185 ff1 = TopoDS::Face(It.Value());
186 }
187 else {
188 ff2 = TopoDS::Face(It.Value());
189 if(!ff2.IsSame(ff1)){
190 break;
191 }
192 }
193 }
194 if(ff1.IsNull() || ff2.IsNull()) return 5;
195 if(ff1.IsSame(ff2)) return 5;
196 if(BRep_Tool::Continuity(cured,ff1,ff2) != GeomAbs_C0) return 5;
197 }
198 TopoDS_Edge ed = TopoDS::Edge(E.First());
199 ed.Orientation(TopAbs_FORWARD);
200 ChFi3d_FilBuilder::Add(R,ed);
201 Handle(ChFiDS_Stripe) st = myListStripe.First();
202 Handle(ChFiDS_Spine)& sp = st->ChangeSpine();
203 Standard_Boolean periodic = sp->IsPeriodic();
204
81bba717 205 //It is checked if edges of list E are in the contour,
206 //the edges that arenot in the list are removed from the contour,
207 //it is checked that the remainder is monoblock.
7fd59977 208
209 for(It.Initialize(E); It.More(); It.Next()){
210 TopoDS_Edge cured = TopoDS::Edge(It.Value());
211 if(!Contains(cured)) return 2;
212 }
213
214 Handle(ChFiDS_FilSpine) newsp = new ChFiDS_FilSpine();
215 Standard_Boolean debut = 0;
216 Standard_Integer premierquinyestpas = 0;
217 Standard_Integer yatrou = 0;
218 for(Standard_Integer i = 1; i <= sp->NbEdges(); i++){
219 TopoDS_Edge cured = sp->Edges(i);
220 if(isinlist(cured,E)){
221 debut = 1;
222 if(premierquinyestpas) {
223 yatrou = 1;
224 break;
225 }
226 newsp->SetEdges(cured);
227 }
228 else if(debut && !premierquinyestpas) premierquinyestpas = i;
229 }
230 if(!periodic && yatrou) return 2;
231 if(periodic && yatrou){
232 Standard_Boolean vraitrou = 0, debut = 0;
233 for(Standard_Integer i = sp->NbEdges(); i > yatrou; i--){
234 TopoDS_Edge cured = sp->Edges(i);
235 if(isinlist(cured,E)){
236 if(vraitrou) return 2;
237 newsp->PutInFirst(cured);
238 }
239 else if(debut) vraitrou = 1;
240 debut = 1;
241 }
242 }
243
244 if(newsp->NbEdges() != sp->NbEdges()) {
245 newsp->Load();
246 newsp->SetRadius(R);
247 sp = newsp;
248 }
249
81bba717 250 //ElSpine is immediately constructed
7fd59977 251 Handle(ChFiDS_HElSpine) hels = new ChFiDS_HElSpine();
252 gp_Vec TFirst,TLast;
253 gp_Pnt PFirst,PLast;
254 sp->D1(sp->FirstParameter(),PFirst,TFirst);
255 sp->D1(sp->LastParameter(),PLast,TLast);
256 hels->ChangeCurve().FirstParameter(sp->FirstParameter());
257 hels->ChangeCurve().SetFirstPointAndTgt(PFirst,TFirst);
258 hels->ChangeCurve().LastParameter(sp->LastParameter());
259 hels->ChangeCurve().SetLastPointAndTgt(PLast,TLast);
260 ChFi3d_PerformElSpine(hels,sp,myConti,tolesp);
261 sp->AppendElSpine(hels);
262 sp->SplitDone(Standard_True);
263 return 0;
264}
265
266//=======================================================================
267//function : Perform
268//purpose :
269//=======================================================================
270
271void FilletSurf_InternalBuilder::Perform()
272{
81bba717 273 //PerformSetOfSurfOnElSpine is enough.
7fd59977 274
275 Handle(ChFiDS_Stripe) Stripe = myListStripe.First();
276 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
277 HData = new ChFiDS_HData();
278 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
279 TopAbs_Orientation RefOr1,RefOr2;
280 Standard_Integer RefChoix;
281 StripeOrientations(Spine,RefOr1,RefOr2,RefChoix);
282 Stripe->OrientationOnFace1(RefOr1);
283 Stripe->OrientationOnFace2(RefOr2);
284 Stripe->Choix(RefChoix);
285 PerformSetOfKGen(Stripe,0);
286}
287
288//=======================================================================
289//function : PerformSurf
290//purpose :
291//=======================================================================
292
293Standard_Boolean
294 FilletSurf_InternalBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData,
295 const Handle(ChFiDS_HElSpine)& Guide,
296 const Handle(ChFiDS_Spine)& Spine,
297 const Standard_Integer Choix,
298 const Handle(BRepAdaptor_HSurface)& S1,
299 const Handle(Adaptor3d_TopolTool)& I1,
300 const Handle(BRepAdaptor_HSurface)& S2,
301 const Handle(Adaptor3d_TopolTool)& I2,
302 const Standard_Real MaxStep,
303 const Standard_Real Fleche,
304 const Standard_Real TolGuide,
305 Standard_Real& First,
306 Standard_Real& Last,
307 const Standard_Boolean Inside,
308 const Standard_Boolean Appro,
309 const Standard_Boolean Forward,
310 const Standard_Boolean RecOnS1,
311 const Standard_Boolean RecOnS2,
312 const math_Vector& Soldep,
313 Standard_Boolean& Intf,
314 Standard_Boolean& Intl)
315{
316 Handle(ChFiDS_SurfData) Data = SeqData(1);
317 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
318 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 319 ("PerformSurf : this is not the spine of a fillet");
7fd59977 320 Handle(BRepBlend_Line) lin;
321 TopAbs_Orientation Or = S1->ChangeSurface().Face().Orientation();
322 if(!fsp->IsConstant()) Standard_ConstructionError::Raise
81bba717 323 ("PerformSurf : no variable radiuses");
7fd59977 324 // Standard_Boolean maybesingular; //pour scinder les Surfdata singulieres
325
326 BRepBlend_ConstRad Func(S1,S2,Guide);
327 BRepBlend_ConstRadInv FInv(S1,S2,Guide);
328 Func.Set(fsp->Radius(),Choix);
329 FInv.Set(fsp->Radius(),Choix);
330 switch (GetFilletShape()) {
331 case ChFi3d_Rational:
332 Func.Set(BlendFunc_Rational);
333 break;
334 case ChFi3d_QuasiAngular:
335 Func.Set(BlendFunc_QuasiAngular);
336 break;
337 case ChFi3d_Polynomial:
338 Func.Set(BlendFunc_Polynomial);
339 }
340 Standard_Real PFirst = First;
341 done = SimulData(Data,Guide,lin,S1,I1,
342 S2,I2,Func,FInv,PFirst,MaxStep,Fleche,
343 TolGuide,First,Last,Inside,Appro,Forward,Soldep,
344 20,RecOnS1,RecOnS2);
345 if(!done) return Standard_False;
346 if(lin->StartPointOnFirst().NbPointOnRst() !=0){
347 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
348 Standard_True, Data->ChangeVertexFirstOnS1(), tolesp);
349 }
350 if(lin->EndPointOnFirst().NbPointOnRst() !=0){
351 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
352 Standard_False,Data->ChangeVertexLastOnS1(), tolesp);
353 }
354 if(lin->StartPointOnSecond().NbPointOnRst() !=0){
355 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
356 Standard_True, Data->ChangeVertexFirstOnS2(), tolesp);
357 }
358 if(lin->EndPointOnSecond().NbPointOnRst() !=0){
359 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
360 Standard_False, Data->ChangeVertexLastOnS2(), tolesp);
361 }
362 done = CompleteData(Data,Func,lin,S1,S2,Or,0,0,0,0);
81bba717 363 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 364// maybesingular = (Func.GetMinimalDistance()<=100*tolapp3d);
365 Standard_Boolean ok = 0;
366 if(!Forward){
367 Intf = 0;
368 const ChFiDS_CommonPoint& cpf1 = Data->VertexFirstOnS1();
369 if(cpf1.IsOnArc()){
370 TopoDS_Face F1 = S1->ChangeSurface().Face();
371 TopoDS_Face bid;
372 ok = Intf = !SearchFace(Spine,cpf1,F1,bid);
373 }
374 const ChFiDS_CommonPoint& cpf2 = Data->VertexFirstOnS2();
375 if(cpf2.IsOnArc() && !ok){
376 TopoDS_Face F2 = S2->ChangeSurface().Face();
377 TopoDS_Face bid;
378 Intf = !SearchFace(Spine,cpf2,F2,bid);
379 }
380 }
381 Intl = 0;
382 ok = 0;
383 const ChFiDS_CommonPoint& cpl1 = Data->VertexLastOnS1();
384 if(cpl1.IsOnArc()){
385 TopoDS_Face F1 = S1->ChangeSurface().Face();
386 TopoDS_Face bid;
387 ok = Intl = !SearchFace(Spine,cpl1,F1,bid);
388 }
389 const ChFiDS_CommonPoint& cpl2 = Data->VertexLastOnS2();
390 if(cpl2.IsOnArc() && !ok){
391 TopoDS_Face F2 = S2->ChangeSurface().Face();
392 TopoDS_Face bid;
393 Intl = !SearchFace(Spine,cpl2,F2,bid);
394 }
395 Data->FirstSpineParam(First);
396 Data->LastSpineParam (Last);
397
398// if (maybesingular) SplitSurf(SeqData, lin);
399// Necessite de trimer resultats : A faire
400 return Standard_True;
401}
402
403void FilletSurf_InternalBuilder::PerformSurf(ChFiDS_SequenceOfSurfData&, const Handle_ChFiDS_HElSpine&, const Handle_ChFiDS_Spine&, const int, const Handle_BRepAdaptor_HSurface&, const Handle_Adaptor3d_TopolTool&, const Handle_BRepAdaptor_HCurve2d&, const Handle_BRepAdaptor_HSurface&, const Handle_BRepAdaptor_HCurve2d&, unsigned int&, const Handle_BRepAdaptor_HSurface&, const Handle_Adaptor3d_TopolTool&, const TopAbs_Orientation, const double, const double, const double, double&, double&, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const math_Vector&)
404{
405 Standard_DomainError::Raise("BlendFunc_CSConstRad::Section : Not implemented");
406}
407
408void FilletSurf_InternalBuilder::PerformSurf(ChFiDS_SequenceOfSurfData&, const Handle_ChFiDS_HElSpine&, const Handle_ChFiDS_Spine&, const int, const Handle_BRepAdaptor_HSurface&, const Handle_Adaptor3d_TopolTool&, const Handle_BRepAdaptor_HCurve2d&, const Handle_BRepAdaptor_HSurface&, const Handle_BRepAdaptor_HCurve2d&, unsigned int&, const TopAbs_Orientation, const Handle_BRepAdaptor_HSurface&, const Handle_Adaptor3d_TopolTool&, const Handle_BRepAdaptor_HCurve2d&, const Handle_BRepAdaptor_HSurface&, const Handle_BRepAdaptor_HCurve2d&, unsigned int&, const TopAbs_Orientation, const double, const double, const double, double&, double&, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const math_Vector&)
409{
410 Standard_DomainError::Raise("BlendFunc_CSConstRad::Section : Not implemented");
411}
412
413void FilletSurf_InternalBuilder::PerformSurf(ChFiDS_SequenceOfSurfData&, const Handle_ChFiDS_HElSpine&, const Handle_ChFiDS_Spine&, const int, 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&, unsigned int&, const double, const double, const double, double&, double&, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int, const math_Vector&)
414{
415 Standard_DomainError::Raise("BlendFunc_CSConstRad::Section : Not implemented");
416}
417
418Standard_Boolean FilletSurf_InternalBuilder::Done() const
419{
420 return done;
421}
422//=======================================================================
423//function : NbSurface
424//purpose : gives the number of NUBS surfaces of the Fillet
425//=======================================================================
426
427Standard_Integer FilletSurf_InternalBuilder::NbSurface() const
428{
429 return myListStripe.First()->SetOfSurfData()->Length();
430}
431
432//=======================================================================
433//function : SurfaceFillet
434//purpose : gives the NUBS surface of index Index
435//=======================================================================
436
437const Handle(Geom_Surface)& FilletSurf_InternalBuilder::SurfaceFillet(const Standard_Integer Index) const
438{
439 Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->Surf();
440
441 return myDS->Surface(isurf).Surface();
442}
443
444 //=======================================================================
445//function : TolApp3d
446//purpose : gives the 3d tolerance reached during approximation
447//=======================================================================
448
449Standard_Real FilletSurf_InternalBuilder::TolApp3d(const Standard_Integer Index) const
450{
451 Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->Surf();
452
453 return myDS->Surface(isurf).Tolerance();
454}
455
456//=======================================================================
457//function : SupportFace1
458//purpose : gives the first support face relative to SurfaceFillet(Index)
459//=======================================================================
460const TopoDS_Face& FilletSurf_InternalBuilder::SupportFace1(const Standard_Integer Index) const
461{
462 Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->IndexOfS1();
463
464 return TopoDS::Face(myDS->Shape(isurf));
465}
466//=======================================================================
467//function : SupportFace2
468//purpose : gives the second support face relative to SurfaceFillet(Index)
469//=======================================================================
470const TopoDS_Face& FilletSurf_InternalBuilder::SupportFace2(const Standard_Integer Index) const
471{
472 Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->IndexOfS2();
473
474 return TopoDS::Face(myDS->Shape(isurf));
475}
476//===============================================================================
477//function : CurveOnSup1
478//purpose : gives the 3d curve of SurfaceFillet(Index) on SupportFace1(Index)
479//===============================================================================
480
481const Handle(Geom_Curve)& FilletSurf_InternalBuilder::CurveOnFace1(const Standard_Integer Index) const
482{
483 Standard_Integer icurv = myListStripe.First()->SetOfSurfData()->Value(Index)->
484 InterferenceOnS1().LineIndex();
485 return myDS->Curve(icurv).Curve();
486}
487
488//=======================================================================
489//function : CurveOnSup2
490//purpose : gives the 3d curve of SurfaceFillet(Index) on SupportFace2(Index
491//=======================================================================
492
493const Handle(Geom_Curve)& FilletSurf_InternalBuilder::CurveOnFace2(const Standard_Integer Index) const
494{
495 Standard_Integer icurv=myListStripe.First()->SetOfSurfData()->Value(Index)->
496 InterferenceOnS2().LineIndex();
497 return myDS->Curve(icurv).Curve();
498}
499//=======================================================================
500//function : PCurveOnFace1
501//purpose : gives the PCurve associated to CurvOnSup1(Index) on the support face
502//=======================================================================
503const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurveOnFace1(const Standard_Integer Index) const
504{
505 return myListStripe.First()->SetOfSurfData()->Value(Index)->
506 InterferenceOnS1().PCurveOnFace();
507
508}
509
510//=======================================================================
511//function : PCurveOnFillet1
512//purpose : gives the PCurve associated to CurveOnFace1(Index) on the Fillet
513//=======================================================================
514
515const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurve1OnFillet(const Standard_Integer Index) const
516{return myListStripe.First()->SetOfSurfData()->Value(Index)->
517 InterferenceOnS1().PCurveOnSurf();
518
519}
520
521//=======================================================================
522//function : PCurveOnFace2
523//purpose : gives the PCurve associated to CurvOnSup2(Index) on the support face
524//=======================================================================
525const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurveOnFace2(const Standard_Integer Index) const
526{
527 return myListStripe.First()->SetOfSurfData()->Value(Index)->
528 InterferenceOnS2().PCurveOnFace();
529}
530
531//=======================================================================
532//function : PCurveOnFillet2
533//purpose : gives the PCurve associated to CurveOnFace2(Index) on the Fillet
534//=======================================================================
535const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurve2OnFillet(const Standard_Integer Index) const
536{return myListStripe.First()->SetOfSurfData()->Value(Index)->
537 InterferenceOnS2().PCurveOnSurf();
538
539}
540
541//=======================================================================
542//function : FirstParameter
543//purpose : gives the parameter of the fillet on the first edge
544//=======================================================================
545
546Standard_Real FilletSurf_InternalBuilder::FirstParameter() const
547{
548 const Handle(ChFiDS_Stripe)& st = myListStripe.First();
549 const Handle(ChFiDS_Spine)& sp = st->Spine();
550 const Handle(ChFiDS_SurfData)& sd = st->SetOfSurfData()->Value(1);
551 Standard_Real p = sd->FirstSpineParam();
552 Standard_Integer ind = 1;
553 if(sp->IsPeriodic()) ind = sp->Index(p);
554 Standard_Real ep;
555 if(ComputeEdgeParameter(sp,ind,p,ep,tolesp)) return ep;
556 return 0.0;
557}
558//=======================================================================
559//function : LastParameter
560//purpose : gives the parameter of the fillet on the last edge
561//=======================================================================
562Standard_Real FilletSurf_InternalBuilder::LastParameter() const
563{
564 const Handle(ChFiDS_Stripe)& st = myListStripe.First();
565 const Handle(ChFiDS_Spine)& sp = st->Spine();
566 const Handle(ChFiDS_SurfData)& sd = st->SetOfSurfData()->Value(NbSurface());
567 Standard_Real p = sd->LastSpineParam();
568 Standard_Integer ind = sp->NbEdges();
569 if(sp->IsPeriodic()) ind = sp->Index(p);
570 Standard_Real ep;
571 if(ComputeEdgeParameter(sp,ind,p,ep,tolesp)) return ep;
572 return 0.0;
573}
574
575//=======================================================================
576//function : StatusStartSection
577//purpose : returns:
578// twoExtremityonEdge: each extremity of start section of the Fillet is
579// on the edge of the corresponding support face.
580// OneExtremityOnEdge: only one of the extremities of start section of the Fillet
581// is on the edge of the corresponding support face.
582// NoExtremityOnEdge: any extremity of start section of the fillet is on
583// the edge of the corresponding support face.
584//=======================================================================
585
586
587FilletSurf_StatusType FilletSurf_InternalBuilder::StartSectionStatus() const
588{
589
590 Standard_Boolean isonedge1 = myListStripe.First()->SetOfSurfData()->Value(1)->
591 VertexFirstOnS1().IsOnArc();
592 Standard_Boolean isonedge2= myListStripe.First()->SetOfSurfData()->Value(1)->
593 VertexFirstOnS2().IsOnArc();;
594
595 if (isonedge1 && isonedge2)
596 {return FilletSurf_TwoExtremityOnEdge;}
597 else if ((!isonedge1)&& (!isonedge2))
598 {return FilletSurf_NoExtremityOnEdge ;}
599 else
600 {return FilletSurf_OneExtremityOnEdge;}
601}
602//=======================================================================
603//function : StatusEndSection()
604//purpose : returns:
605// twoExtremityonEdge: each extremity of end section of the Fillet is
606// on the edge of the corresponding support face.
607// OneExtremityOnEdge: only one of the extremities of end section of the Fillet
608// is on the edge of the corresponding support face.
609// NoExtremityOnEdge: any extremity of end section of the fillet is on
610// the edge of the corresponding support face.
611//=======================================================================
612FilletSurf_StatusType FilletSurf_InternalBuilder::EndSectionStatus() const
613{
614 Standard_Boolean isonedge1 = myListStripe.First()->SetOfSurfData()->Value(NbSurface())->
615 VertexLastOnS1().IsOnArc();
616 Standard_Boolean isonedge2= myListStripe.First()->SetOfSurfData()->Value(NbSurface())->
617 VertexLastOnS2().IsOnArc();
618
619 if (isonedge1 && isonedge2)
620 { return FilletSurf_TwoExtremityOnEdge;}
621 else if ((!isonedge1)&& (!isonedge2))
622 { return FilletSurf_NoExtremityOnEdge;}
623 else
624 { return FilletSurf_OneExtremityOnEdge;}
625}
626
627
628//=======================================================================
629//function : Simulate
630//purpose : computes only the sections used in the computation of the fillet
631//=======================================================================
632void FilletSurf_InternalBuilder::Simulate()
633{
634 //ChFi3d_FilBuilder::Simulate(1);
635 Handle(ChFiDS_Stripe) Stripe = myListStripe.First();
636 Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData();
637 HData = new ChFiDS_HData();
638 Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine();
639 TopAbs_Orientation RefOr1,RefOr2;
640 Standard_Integer RefChoix;
641 StripeOrientations(Spine,RefOr1,RefOr2,RefChoix);
642 Stripe->OrientationOnFace1(RefOr1);
643 Stripe->OrientationOnFace2(RefOr2);
644 Stripe->Choix(RefChoix);
645 PerformSetOfKGen(Stripe,1);
646}
647
648
649//=======================================================================
650//function : NbSection
651//purpose : gives the number of sections relative to SurfaceFillet(IndexSurf)
652//=======================================================================
653Standard_Integer FilletSurf_InternalBuilder::NbSection(const Standard_Integer IndexSurf) const
654{
655return Sect(1,IndexSurf)->Length();
656}
657
658//=======================================================================
659//function : Section
660//purpose : gives the arc of circle corresponding to section number
661// IndexSec of SurfaceFillet(IndexSurf) (The basis curve of the
662// trimmed curve is a Geom_Circle)
663//=======================================================================
664void FilletSurf_InternalBuilder::Section(const Standard_Integer IndexSurf, const Standard_Integer IndexSec, Handle(Geom_TrimmedCurve)& Circ) const
665{
666 gp_Circ c;
667 Standard_Real deb,fin;
668 Sect(1,IndexSurf)->Value(IndexSec).Get(c,deb,fin);
669 Handle(Geom_Circle) Gc = new Geom_Circle(c);
670 Circ= new Geom_TrimmedCurve(Gc,deb,fin);
671}
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686