0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / ChFi3d / ChFi3d_FilBuilder.cxx
CommitLineData
7fd59977 1// File: ChFi3d_FilBuilder.cxx
2// Created: Tue Apr 25 11:08:46 1995
3// Modified: MPS : (10-04-97) portage WNT pour GetFilletShape
4// Author: Modelistation
5// <model@phylox>
6
7
8#include <ChFi3d_FilBuilder.ixx>
9#include <ChFi3d_Builder_0.hxx>
10#include <ChFi3d_SearchSing.hxx>
11
12#include <Law_Composite.hxx>
13#include <Blend_Point.hxx>
14#include <BRepBlend_Walking.hxx>
15#include <BRepBlend_Line.hxx>
16#include <BRepBlend_ConstRad.hxx>
17#include <BRepBlend_ConstRadInv.hxx>
18#include <BRepBlend_EvolRad.hxx>
19#include <BRepBlend_EvolRadInv.hxx>
20#include <BRepBlend_SurfRstConstRad.hxx>
21#include <BRepBlend_SurfRstEvolRad.hxx>
22#include <BRepBlend_RstRstConstRad.hxx>
23#include <BRepBlend_RstRstEvolRad.hxx>
24#include <BRepBlend_SurfCurvConstRadInv.hxx>
25#include <BRepBlend_SurfCurvEvolRadInv.hxx>
26#include <BRepBlend_SurfPointConstRadInv.hxx>
27#include <BRepBlend_SurfPointEvolRadInv.hxx>
28#include <BRepBlend_CurvPointRadInv.hxx>
29#include <ChFiDS_SecHArray1.hxx>
30#include <ChFiDS_HData.hxx>
31#include <ChFiDS_FilSpine.hxx>
32#include <ChFiDS_Stripe.hxx>
33#include <ChFiDS_ListOfStripe.hxx>
34#include <ChFiDS_ListIteratorOfListOfStripe.hxx>
35#include <ChFiDS_ListIteratorOfRegularities.hxx>
36#include <ChFiDS_Regul.hxx>
37#include <ChFiDS_ErrorStatus.hxx>
38#include <TopTools_ListIteratorOfListOfShape.hxx>
39#include <TopOpeBRepDS_HDataStructure.hxx>
40#include <TopOpeBRepDS_Surface.hxx>
41#include <TopOpeBRepDS_Curve.hxx>
42#include <TopOpeBRepBuild_HBuilder.hxx>
43#include <ElSLib.hxx>
44#include <math_FunctionRoot.hxx>
45#include <TColStd_SequenceOfReal.hxx>
46#include <Precision.hxx>
47
48
49#include <GeomAdaptor_HCurve.hxx>
50#include <Geom_Curve.hxx>
51
52#include <Standard_ConstructionError.hxx>
53#include <Standard_Failure.hxx>
54#ifdef DEB
55extern Standard_Boolean ChFi3d_GettraceCHRON();
56extern Standard_Real t_computedata ,t_completedata;
57
58extern void ChFi3d_InitChron(OSD_Chronometer& ch);
59extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
60#endif
61
62static Standard_Real MaxRad(const Handle(ChFiDS_FilSpine)& fsp,
63
64 const TopoDS_Edge& E)
65{
66 Standard_Integer IE = fsp->Index(E);
67
68 // 1: case of constant R
69 if (fsp->IsConstant(IE))
70 return (fsp->Radius(IE));
71 else // 2,3: case of sequence ParAndRad and(or) Laws
72 return (fsp->MaxRadFromSeqAndLaws());
73
74/*
75 Handle(ChFiDS_HElSpine) HGuide = fsp->ElSpine(IE);
76 Standard_Real la = HGuide->LastParameter(), fi = HGuide->FirstParameter();
77 Standard_Real longueur = la - fi, temp, w;
78//#ifndef DEB
79 Standard_Real radiussect = 0.;
80//#else
81// Standard_Real radiussect;
82//#endif
83 Handle(Law_Composite) lc = fsp->Law(HGuide);
84 for(Standard_Integer i = 0; i <= 5; i++){
85 w = fi + i*longueur*0.2;
86 temp = lc->Value(w);
87 if(temp>radiussect) radiussect = temp;
88 }
89 return radiussect;
90*/
91}
92
93static void SimulParams(const Handle(ChFiDS_HElSpine)& HGuide,
94 const Handle(ChFiDS_FilSpine)& fsp,
95 Standard_Real& MaxStep,
96 Standard_Real& Fleche)
97{
98 Standard_Real la = HGuide->LastParameter(), fi = HGuide->FirstParameter();
99 Standard_Real longueur = la - fi;
100 MaxStep = longueur * 0.05;
101 Standard_Real w;
102 //gp_Pnt Pbid;
103 //gp_Vec d1,d2;
104 Standard_Real radiussect;
105 if(fsp->IsConstant()) radiussect = fsp->Radius();
106 else {
107 radiussect = 0.;
108 Handle(Law_Composite) lc = fsp->Law(HGuide);
109 for(Standard_Integer i = 0; i <= 5; i++){
110 w = fi + i*longueur*0.2;
111 Standard_Real temp = lc->Value(w);
112 if(temp>radiussect) radiussect = temp;
113 }
114 }
115 Fleche = radiussect * 0.05;
116}
117
118//=======================================================================
119//function : ChFi3d_FilBuilder
120//purpose :
121//=======================================================================
122
123ChFi3d_FilBuilder::ChFi3d_FilBuilder(const TopoDS_Shape& S,
124 const ChFi3d_FilletShape FShape,
125 const Standard_Real Ta):
126 ChFi3d_Builder(S, Ta)
127{
128 SetFilletShape(FShape);
129}
130
131//=======================================================================
132//function : SetFilletShape
133//purpose :
134//=======================================================================
135
136void ChFi3d_FilBuilder::SetFilletShape(const ChFi3d_FilletShape FShape)
137{
138 switch (FShape) {
139 case ChFi3d_Rational:
140 myShape = BlendFunc_Rational;
141 break;
142 case ChFi3d_QuasiAngular:
143 myShape = BlendFunc_QuasiAngular;
144 break;
145 case ChFi3d_Polynomial:
146 myShape = BlendFunc_Polynomial;
147 break;
148 }
149}
150
151//=======================================================================
152//function : GetFilletShape
153//purpose :
154//=======================================================================
155
156ChFi3d_FilletShape ChFi3d_FilBuilder::GetFilletShape() const
157{
158#ifndef DEB
159 ChFi3d_FilletShape filshape = ChFi3d_Rational; // need to set default value
160#else
161 ChFi3d_FilletShape filshape;
162#endif
163 switch (myShape) {
164 case BlendFunc_Rational:
165 filshape= ChFi3d_Rational;
166 break;
167 case BlendFunc_QuasiAngular:
168 filshape= ChFi3d_QuasiAngular;
169 break;
170 case BlendFunc_Polynomial:
171 filshape= ChFi3d_Polynomial;
172 break;
173 default:
174 break;
175 }
176 return filshape;
177}
178
179//=======================================================================
180//function : Add
181//purpose :
182//=======================================================================
183
184void ChFi3d_FilBuilder::Add(const TopoDS_Edge& E)
185{
186 if(!Contains(E) && myEFMap.Contains(E)){
187 Handle(ChFiDS_Stripe) Stripe = new ChFiDS_Stripe();
188 Handle(ChFiDS_Spine)& Sp = Stripe->ChangeSpine();
189 Sp = new ChFiDS_FilSpine(tolesp);
190 Handle(ChFiDS_FilSpine) Spine = Handle(ChFiDS_FilSpine)::DownCast(Sp);
191
192 TopoDS_Edge E_wnt = E;
193 E_wnt.Orientation(TopAbs_FORWARD);
194 Spine->SetEdges(E_wnt);
195 if(PerformElement(Spine)){
196 PerformExtremity(Spine);
197 Spine->Load();
198 myListStripe.Append(Stripe);
199 }
200 }
201}
202
203//=======================================================================
204//function : Add
205//purpose :
206//=======================================================================
207
208void ChFi3d_FilBuilder::Add(const Standard_Real Radius, const TopoDS_Edge& E)
209{
210 Add(E);
211 Standard_Integer IC = Contains(E);
212 if (IC)
213 SetRadius( Radius, IC, E );
214}
215
216//=======================================================================
217//function : SetRadius
218//purpose :
219//=======================================================================
220
221void ChFi3d_FilBuilder::SetRadius(const Handle(Law_Function)& C,
222 const Standard_Integer IC,
223 const Standard_Integer IinC)
224{
225 if(IC <= NbElements()) {
226 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
227 fsp->SetRadius(C, IinC);
228 }
229}
230
231//=======================================================================
232//function : IsConstant
233//purpose :
234//=======================================================================
235
236Standard_Boolean ChFi3d_FilBuilder::IsConstant(const Standard_Integer IC)
237{
238 if(IC <= NbElements()) {
239 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
240 return fsp->IsConstant();
241 }
242 return 0;
243}
244
245//=======================================================================
246//function : Radius
247//purpose :
248//=======================================================================
249
250Standard_Real ChFi3d_FilBuilder::Radius(const Standard_Integer IC)
251{
252 if(IC <= NbElements()) {
253 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
254 return fsp->Radius();
255 }
256 return -1.;
257}
258
259//=======================================================================
260//function : ResetContour
261//purpose :
262//=======================================================================
263
264void ChFi3d_FilBuilder::ResetContour(const Standard_Integer IC)
265{
266 if(IC <= NbElements()) {
267 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
268 fsp->Reset(Standard_True);
269 }
270}
271
272//=======================================================================
273//function : SetRadius
274//purpose :
275//=======================================================================
276
277void ChFi3d_FilBuilder::SetRadius(const Standard_Real Radius,
278 const Standard_Integer IC,
279 const TopoDS_Edge& E)
280{
281 if(IC <= NbElements()) {
282 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
283 fsp->SetRadius(Radius, E);
284 }
285}
286
287//=======================================================================
288//function : UnSet
289//purpose :
290//=======================================================================
291
292void ChFi3d_FilBuilder::UnSet(const Standard_Integer IC,
293 const TopoDS_Edge& E)
294{
295 if(IC <= NbElements()) {
296 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
297 fsp->UnSetRadius(E);
298 }
299}
300
301//=======================================================================
302//function : SetRadius
303//purpose :
304//=======================================================================
305
306void ChFi3d_FilBuilder::SetRadius(const Standard_Real Radius,
307 const Standard_Integer IC,
308 const TopoDS_Vertex& V)
309{
310 if(IC <= NbElements()) {
311 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
312 fsp->SetRadius(Radius, V);
313 }
314}
315
316//=======================================================================
317//function : UnSet
318//purpose :
319//=======================================================================
320
321void ChFi3d_FilBuilder::UnSet(const Standard_Integer IC,
322 const TopoDS_Vertex& V)
323{
324 if(IC <= NbElements()) {
325 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
326 fsp->UnSetRadius(V);
327 }
328}
329
330//=======================================================================
331//function : SetRadius
332//purpose :
333//=======================================================================
334
335void ChFi3d_FilBuilder::SetRadius(const gp_XY& UandR,
336 const Standard_Integer IC,
337 const Standard_Integer IinC)
338{
339 if(IC <= NbElements()) {
340 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
341 fsp->SetRadius( UandR, IinC );
342 }
343}
344
345//=======================================================================
346//function : IsConstant
347//purpose :
348//=======================================================================
349
350Standard_Boolean ChFi3d_FilBuilder::IsConstant(const Standard_Integer IC,
351 const TopoDS_Edge& E)
352{
353 if(IC <= NbElements()) {
354 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
355 return fsp->IsConstant(fsp->Index(E));
356 }
357 return 0;
358}
359
360//=======================================================================
361//function : Radius
362//purpose :
363//=======================================================================
364
365Standard_Real ChFi3d_FilBuilder::Radius(const Standard_Integer IC,
366 const TopoDS_Edge& E)
367{
368 if(IC <= NbElements()) {
369 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
370 return fsp->Radius(E);
371 }
372 return -1.;
373}
374
375//=======================================================================
376//function : GetBounds
377//purpose :
378//=======================================================================
379
380Standard_Boolean ChFi3d_FilBuilder::GetBounds(const Standard_Integer IC,
381 const TopoDS_Edge& E,
382 Standard_Real& F,
383 Standard_Real& L)
384{
385 if(IC <= NbElements()) {
386 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
387 Handle(Law_Function)& loi = fsp->ChangeLaw(E);
388 if(!loi.IsNull()){
389 loi->Bounds(F,L);
390 return Standard_True;
391 }
392 }
393 return Standard_False;
394}
395
396//=======================================================================
397//function : GetLaw
398//purpose :
399//=======================================================================
400
401Handle(Law_Function) ChFi3d_FilBuilder::GetLaw(const Standard_Integer IC,
402 const TopoDS_Edge& E)
403{
404 if(IC <= NbElements()) {
405 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
406 return fsp->ChangeLaw(E);
407 }
408 return Handle(Law_Function)();
409}
410
411//=======================================================================
412//function : SetLaw
413//purpose :
414//=======================================================================
415
416void ChFi3d_FilBuilder::SetLaw(const Standard_Integer IC,
417 const TopoDS_Edge& E,
418 const Handle(Law_Function)& L)
419{
81bba717 420 // Check if it is necessary to check borders!
7fd59977 421 if(IC <= NbElements()) {
422 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
423 fsp->ChangeLaw(E) = L;
424 }
425}
426
427//=======================================================================
428//function : Simulate
429//purpose :
430//=======================================================================
431
432void ChFi3d_FilBuilder::Simulate (const Standard_Integer IC)
433{
434#ifdef DEB
435 if(ChFi3d_GettraceCHRON()){
436 simul.Reset();elspine.Reset();chemine.Reset();
437 simul.Start();
438 }
439#endif
440 ChFiDS_ListIteratorOfListOfStripe itel;
441 Standard_Integer i = 1;
442 for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
443 if(i == IC){
444 PerformSetOfSurf(itel.Value(), Standard_True);
445 break;
446 }
447 }
448#ifdef DEB
449 if(ChFi3d_GettraceCHRON()){
450 simul.Stop();
81bba717 451 cout<<"Total simulation time : ";
7fd59977 452 simul.Show();
81bba717 453 cout<<"Spine construction time : ";
7fd59977 454 elspine.Show();
81bba717 455 cout<<"and process time : ";
7fd59977 456 chemine.Show();
457 }
458#endif
459}
460
461//=======================================================================
462//function : NbSurf
463//purpose :
464//=======================================================================
465
466Standard_Integer ChFi3d_FilBuilder::NbSurf (const Standard_Integer IC) const
467{
468 ChFiDS_ListIteratorOfListOfStripe itel;
469 Standard_Integer i = 1;
470 for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
471 if(i == IC){
472 return itel.Value()->SetOfSurfData()->Length();
473 }
474 }
475 return 0;
476}
477
478//=======================================================================
479//function : Sect
480//purpose :
481//=======================================================================
482
483Handle(ChFiDS_SecHArray1) ChFi3d_FilBuilder::Sect (const Standard_Integer IC,
484 const Standard_Integer IS) const
485{
486 ChFiDS_ListIteratorOfListOfStripe itel;
487 Standard_Integer i = 1;
488 Handle(ChFiDS_SecHArray1) res;
489 for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
490 if(i == IC){
491 Handle(MMgt_TShared) bid = itel.Value()->SetOfSurfData()->Value(IS)->Simul();
492 res = Handle(ChFiDS_SecHArray1)::DownCast(bid);
493 return res;
494 }
495 }
496 return Handle(ChFiDS_SecHArray1)();
497}
498
499//=======================================================================
500//function : SimulKPart
501//purpose :
502//=======================================================================
503
504void ChFi3d_FilBuilder::SimulKPart(const Handle(ChFiDS_SurfData)& SD) const
505{
506 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
507 Handle(Geom_Surface) S = DStr.Surface(SD->Surf()).Surface();
508 gp_Pnt2d p1f = SD->InterferenceOnS1().PCurveOnSurf()->
509 Value(SD->InterferenceOnS1().FirstParameter());
510 gp_Pnt2d p1l = SD->InterferenceOnS1().PCurveOnSurf()->
511 Value(SD->InterferenceOnS1().LastParameter());
512 gp_Pnt2d p2f = SD->InterferenceOnS2().PCurveOnSurf()->
513 Value(SD->InterferenceOnS2().FirstParameter());
514 gp_Pnt2d p2l = SD->InterferenceOnS2().PCurveOnSurf()->
515 Value(SD->InterferenceOnS2().LastParameter());
516 GeomAdaptor_Surface AS(S);
517 Handle(ChFiDS_SecHArray1) sec;
518 Standard_Real u1,v1,u2,v2;
519 GeomAbs_SurfaceType typ = AS.GetType();
520 switch (typ){
521 case GeomAbs_Cylinder:
522 {
523 u1 = p1f.X();
524 u2 = p2f.X();
525 v1 = Max(p1f.Y(),p2f.Y());
526 v2 = Min(p1l.Y(),p2l.Y());
527 sec = new ChFiDS_SecHArray1(1,2);
528 gp_Cylinder Cy = AS.Cylinder();
529 ChFiDS_CircSection& sec1 = sec->ChangeValue(1);
530 ChFiDS_CircSection& sec2 = sec->ChangeValue(2);
531 sec1.Set(ElSLib::CylinderVIso(Cy.Position(), Cy.Radius(), v1), u1, u2);
532 sec2.Set(ElSLib::CylinderVIso(Cy.Position(), Cy.Radius(), v2), u1, u2);
533 }
534 break;
535 case GeomAbs_Torus:
536 {
537 v1 = p1f.Y();
538 v2 = p2f.Y();
539 u1 = Max(p1f.X(),p2f.X());
540 u2 = Min(p1l.X(),p2l.X());
541 Standard_Real ang = (u2-u1);
542 gp_Torus To = AS.Torus();
543 Standard_Real majr = To.MajorRadius(), minr = To.MinorRadius();
544//#ifndef DEB
c6541a0c 545 Standard_Integer n = (Standard_Integer) (36.*ang/M_PI + 1);
7fd59977 546//#else
c6541a0c 547// Standard_Integer n = 36.*ang/M_PI + 1;
7fd59977 548//#endif
549 if(n<2) n = 2;
550 sec = new ChFiDS_SecHArray1(1, n);
551 for (Standard_Integer i = 1; i <= n; i++) {
552 ChFiDS_CircSection& isec = sec->ChangeValue(i);
553 Standard_Real u = u1 + (i - 1)*(u2 - u1)/(n-1);
554 isec.Set(ElSLib::TorusUIso(To.Position(), majr, minr, u), v1, v2);
555 }
556 }
557 break;
558 case GeomAbs_Sphere:
559 {
560 v1 = p1f.Y();
561 v2 = p2f.Y();
562 u1 = Max(p1f.X(),p2f.X());
563 u2 = Min(p1l.X(),p2l.X());
564 Standard_Real ang = (u2-u1);
565 gp_Sphere Sp = AS.Sphere();
566 Standard_Real rad = Sp.Radius();
567//#ifndef DEB
c6541a0c 568 Standard_Integer n = (Standard_Integer) (36.*ang/M_PI + 1);
7fd59977 569//#else
c6541a0c 570// Standard_Integer n = 36.*ang/M_PI + 1;
7fd59977 571//#endif
572 if(n<2) n = 2;
573 sec = new ChFiDS_SecHArray1(1, n);
574 for (Standard_Integer i = 1; i <= n; i++) {
575 ChFiDS_CircSection& isec = sec->ChangeValue(i);
576 Standard_Real u = u1 + (i - 1)*(u2 - u1)/(n-1);
577 isec.Set(ElSLib::SphereUIso(Sp.Position(), rad, u), v1, v2);
578 }
579 }
580 break;
581 default:
582 break;
583 }
584 SD->SetSimul(sec);
585}
586
587
588//=======================================================================
589//function : SimulSurf
590//purpose :
591//=======================================================================
592
593Standard_Boolean
594ChFi3d_FilBuilder::SimulSurf(Handle(ChFiDS_SurfData)& Data,
595 const Handle(ChFiDS_HElSpine)& HGuide,
596 const Handle(ChFiDS_Spine)& Spine,
597 const Standard_Integer Choix,
598 const Handle(BRepAdaptor_HSurface)& S1,
599 const Handle(Adaptor3d_TopolTool)& I1,
600 const Handle(BRepAdaptor_HSurface)& S2,
601 const Handle(Adaptor3d_TopolTool)& I2,
602 const Standard_Real TolGuide,
603 Standard_Real& First,
604 Standard_Real& Last,
605 const Standard_Boolean Inside,
606 const Standard_Boolean Appro,
607 const Standard_Boolean Forward,
608 const Standard_Boolean RecOnS1,
609 const Standard_Boolean RecOnS2,
610 const math_Vector& Soldep,
611 Standard_Boolean& intf,
612 Standard_Boolean& intl)
613{
614 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
615 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 616 ("SimulSurf : this is not the spine of the fillet");
7fd59977 617 Handle(BRepBlend_Line) lin;
618#ifdef DEB
619// TopAbs_Orientation Or = S1->ChangeSurface().Face().Orientation();
620#endif
81bba717 621 // Flexible parameters!!!
7fd59977 622 Standard_Real locfleche, MaxStep;
623 SimulParams(HGuide,fsp,MaxStep,locfleche);
624 Handle(ChFiDS_SecHArray1) sec;
625 gp_Pnt2d pf1,pl1,pf2,pl2;
626
627 Standard_Real PFirst = First;
628 if(intf) First = fsp->FirstParameter(1);
629 if(intl) Last = fsp->LastParameter(fsp->NbEdges());
630 if (fsp->IsConstant()) {
631 BRepBlend_ConstRad Func(S1,S2,HGuide);
632 BRepBlend_ConstRadInv FInv(S1,S2,HGuide);
633 Func.Set(fsp->Radius(),Choix);
634 FInv.Set(fsp->Radius(),Choix);
635 Func.Set(myShape);
636 done = SimulData(Data,HGuide,lin,S1,I1 ,
637 S2,I2,Func,FInv,PFirst,MaxStep,locfleche,
638 TolGuide,First,Last,Inside,Appro,Forward,
639 Soldep,4,RecOnS1,RecOnS2);
640 if(!done) return Standard_False;
641 Standard_Integer nbp = lin->NbPoints();
642 sec = new ChFiDS_SecHArray1(1,nbp);
643 for(Standard_Integer i = 1; i <= nbp; i++){
644 ChFiDS_CircSection& isec = sec->ChangeValue(i);
645 Standard_Real u1,v1,u2,v2,w,p1,p2;
646 gp_Circ ci;
647 const Blend_Point& p = lin->Point(i);
648 p.ParametersOnS1(u1,v1);
649 p.ParametersOnS2(u2,v2);
650 w = p.Parameter();
651 Func.Section(w,u1,v1,u2,v2,p1,p2,ci);
652 isec.Set(ci,p1,p2);
653 if(i == 1) {pf1.SetCoord(u1,v1); pf2.SetCoord(u2,v2);}
654 if(i == nbp) {pl1.SetCoord(u1,v1); pl2.SetCoord(u2,v2);}
655 }
656 }
657 else{
658 BRepBlend_EvolRad Func(S1,S2,HGuide,fsp->Law(HGuide));
659 BRepBlend_EvolRadInv FInv(S1,S2,HGuide,fsp->Law(HGuide));
660 Func.Set(Choix);
661 FInv.Set(Choix);
662 Func.Set(myShape);
663 done = SimulData(Data,HGuide,lin,S1,I1 ,
664 S2,I2,Func,FInv,PFirst,MaxStep,locfleche,
665 TolGuide,First,Last,Inside,Appro,Forward,
666 Soldep,4,RecOnS1,RecOnS2);
667 if(!done) return Standard_False;
668 Standard_Integer nbp = lin->NbPoints();
669 sec = new ChFiDS_SecHArray1(1,nbp);
670 for(Standard_Integer i = 1; i <= nbp; i++){
671 ChFiDS_CircSection& isec = sec->ChangeValue(i);
672 Standard_Real u1,v1,u2,v2,w,p1,p2;
673 gp_Circ ci;
674 const Blend_Point& p = lin->Point(i);
675 p.ParametersOnS1(u1,v1);
676 p.ParametersOnS2(u2,v2);
677 w = p.Parameter();
678 Func.Section(w,u1,v1,u2,v2,p1,p2,ci);
679 isec.Set(ci,p1,p2);
680 if(i == 1) {pf1.SetCoord(u1,v1); pf2.SetCoord(u2,v2);}
681 if(i == nbp) {pl1.SetCoord(u1,v1); pl2.SetCoord(u2,v2);}
682 }
683 }
684 Data->SetSimul(sec);
685 Data->Set2dPoints(pf1,pl1,pf2,pl2);
686 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
687 Standard_True, Data->ChangeVertexFirstOnS1(),tolesp);
688 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
689 Standard_False,Data->ChangeVertexLastOnS1(),tolesp);
690 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
691 Standard_True, Data->ChangeVertexFirstOnS2(),tolesp);
692 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
693 Standard_False, Data->ChangeVertexLastOnS2(),tolesp);
694 Standard_Boolean reverse = (!Forward || Inside);
695 if(intf && reverse){
696 Standard_Boolean ok = 0;
697 const ChFiDS_CommonPoint& cp1 = Data->VertexFirstOnS1();
698 if(cp1.IsOnArc()){
699 TopoDS_Face F1 = S1->ChangeSurface().Face();
700 TopoDS_Face bid;
701 ok = intf = !SearchFace(Spine,cp1,F1,bid);
702 }
703 const ChFiDS_CommonPoint& cp2 = Data->VertexFirstOnS2();
704 if(cp2.IsOnArc() && !ok){
705 TopoDS_Face F2 = S2->ChangeSurface().Face();
706 TopoDS_Face bid;
707 intf = !SearchFace(Spine,cp2,F2,bid);
708 }
709 }
710 if(intl){
711 Standard_Boolean ok = 0;
712 const ChFiDS_CommonPoint& cp1 = Data->VertexLastOnS1();
713 if(cp1.IsOnArc()){
714 TopoDS_Face F1 = S1->ChangeSurface().Face();
715 TopoDS_Face bid;
716 ok = intl = !SearchFace(Spine,cp1,F1,bid);
717 }
718 const ChFiDS_CommonPoint& cp2 = Data->VertexLastOnS2();
719 if(cp2.IsOnArc() && !ok){
720 TopoDS_Face F2 = S2->ChangeSurface().Face();
721 TopoDS_Face bid;
722 intl = !SearchFace(Spine,cp2,F2,bid);
723 }
724 }
725 return Standard_True;
726}
727
728//=======================================================================
729//function : SimulSurf
730//purpose :
731//=======================================================================
732
733void ChFi3d_FilBuilder::SimulSurf(Handle(ChFiDS_SurfData)& Data,
734 const Handle(ChFiDS_HElSpine)& HGuide,
735 const Handle(ChFiDS_Spine)& Spine,
736 const Standard_Integer Choix,
737 const Handle(BRepAdaptor_HSurface)& HS1,
738 const Handle(Adaptor3d_TopolTool)& I1,
739 const Handle(BRepAdaptor_HCurve2d)& PC1,
740 const Handle(BRepAdaptor_HSurface)& HSref1,
741 const Handle(BRepAdaptor_HCurve2d)& PCref1,
742 Standard_Boolean& Decroch1,
743 const Handle(BRepAdaptor_HSurface)& HS2,
744 const Handle(Adaptor3d_TopolTool)& I2,
745 const TopAbs_Orientation Or2,
746 const Standard_Real /*Fleche*/,
747 const Standard_Real TolGuide,
748 Standard_Real& First,
749 Standard_Real& Last,
750 const Standard_Boolean Inside,
751 const Standard_Boolean Appro,
752 const Standard_Boolean Forward,
753 const Standard_Boolean RecP,
754 const Standard_Boolean RecS,
755 const Standard_Boolean RecRst,
756 const math_Vector& Soldep)
757{
758 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
759 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 760 ("PerformSurf : this is not the spine of the fillet");
7fd59977 761 Handle(BRepBlend_Line) lin;
762
81bba717 763 // Flexible parameters!
7fd59977 764 Standard_Real locfleche, MaxStep;
765 SimulParams(HGuide,fsp,MaxStep,locfleche);
766 Handle(ChFiDS_SecHArray1) sec;
767 gp_Pnt2d pf,pl,ppcf,ppcl;
768
769 Standard_Real PFirst = First;
770 if(fsp->IsConstant()){
771 BRepBlend_SurfRstConstRad func(HS2,HS1,PC1,HGuide);
772 func.Set(HSref1,PCref1);
773 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
774 HC->ChangeCurve().Load(HS1);
775 HC->ChangeCurve().Load(PC1);
776 BRepBlend_SurfCurvConstRadInv finvc(HS2,HC,HGuide);
777 BRepBlend_SurfPointConstRadInv finvp(HS2,HGuide);
778 BRepBlend_ConstRadInv finv(HS2,HSref1,HGuide);
779 finv.Set(Standard_False,PCref1);
780
781 Standard_Real rad = fsp->Radius();
782 Standard_Integer petitchoix = 1;
783 if(Or2 == TopAbs_REVERSED) petitchoix = 3;
784 if(Choix%2 == 0) petitchoix++;
785 finv.Set(rad,Choix);
786 finvc.Set(rad,petitchoix);
787 finvp.Set(rad,petitchoix);
788 func.Set(rad,petitchoix);
789 func.Set(myShape);
790
791 done = SimulData(Data,HGuide,lin,HS2,I2,HS1,PC1,I1,Decroch1,
792 func,finv,finvp,finvc,
793 PFirst,MaxStep,locfleche,TolGuide,First,Last,
794 Soldep,4,Inside,Appro,Forward,RecP,RecS,RecRst);
795 if(!done) {
81bba717 796 Standard_Failure::Raise("SimulSurf : Failed process!");
7fd59977 797 }
798 Standard_Integer nbp = lin->NbPoints();
799 sec = new ChFiDS_SecHArray1(1,nbp);
800 for(Standard_Integer i = 1; i <= nbp; i++){
801 ChFiDS_CircSection& isec = sec->ChangeValue(i);
802 Standard_Real u,v,w,param,p1,p2;
803 gp_Circ ci;
804 const Blend_Point& p = lin->Point(i);
805 p.ParametersOnS(u,v);
806 w = p.ParameterOnC();
807 param = p.Parameter();
808 func.Section(param,u,v,w,p1,p2,ci);
809 isec.Set(ci,p1,p2);
810 if(i == 1) {pf.SetCoord(u,v);p.ParametersOnS2(u,v);ppcf.SetCoord(u,v);}
811 if(i == nbp) {pl.SetCoord(u,v);p.ParametersOnS2(u,v);ppcl.SetCoord(u,v);}
812 }
813 }
814 else {
815 BRepBlend_SurfRstEvolRad func(HS2,HS1,PC1,HGuide,fsp->Law(HGuide));
816 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
817 HC->ChangeCurve().Load(HS1);
818 HC->ChangeCurve().Load(PC1);
819 BRepBlend_SurfCurvEvolRadInv finvc(HS2,HC,HGuide,fsp->Law(HGuide));
820 BRepBlend_SurfPointEvolRadInv finvp(HS2,HGuide,fsp->Law(HGuide));
821 BRepBlend_EvolRadInv finv(HS2,HSref1,HGuide,fsp->Law(HGuide));
822 finv.Set(Standard_False,PCref1);
823 Standard_Integer petitchoix = 1;
824 if(Or2 == TopAbs_REVERSED) petitchoix = 3;
825 if(Choix%2 == 0) petitchoix++;
826 finv.Set(Choix);
827 finvc.Set(petitchoix);
828 finvp.Set(petitchoix);
829 func.Set(petitchoix);
830 func.Set(myShape);
831 done = SimulData(Data,HGuide,lin,HS2,I2,HS1,PC1,I1,Decroch1,
832 func,finv,finvp,finvc,
833 PFirst,MaxStep,locfleche,TolGuide,First,Last,
834 Soldep,4,Inside,Appro,Forward,RecP,RecS,RecRst);
81bba717 835 if(!done) Standard_Failure::Raise("SimulSurf : Fail !");
7fd59977 836 Standard_Integer nbp = lin->NbPoints();
837 sec = new ChFiDS_SecHArray1(1,nbp);
838 for(Standard_Integer i = 1; i <= nbp; i++){
839 ChFiDS_CircSection& isec = sec->ChangeValue(i);
840 Standard_Real u,v,w,param,p1,p2;
841 gp_Circ ci;
842 const Blend_Point& p = lin->Point(i);
843 p.ParametersOnS(u,v);
844 w = p.ParameterOnC();
845 param = p.Parameter();
846 func.Section(param,u,v,w,p1,p2,ci);
847 isec.Set(ci,p1,p2);
848 if(i == 1) {pf.SetCoord(u,v);p.ParametersOnS2(u,v);ppcf.SetCoord(u,v);}
849 if(i == nbp) {pl.SetCoord(u,v);p.ParametersOnS2(u,v);ppcl.SetCoord(u,v);}
850 }
851 }
852 Data->SetSimul(sec);
853// gp_Pnt2d pbid;
854 Data->Set2dPoints(ppcf,ppcl,pf,pl);
855 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
856 Standard_True, Data->ChangeVertexFirstOnS2(),tolesp);
857 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
858 Standard_False,Data->ChangeVertexLastOnS2(),tolesp);
859 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
860 Standard_True, Data->ChangeVertexFirstOnS1(),tolesp);
861 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
862 Standard_False, Data->ChangeVertexLastOnS1(),tolesp);
863}
864
865//=======================================================================
866//function : SimulSurf
867//purpose :
868//=======================================================================
869
870void ChFi3d_FilBuilder::SimulSurf(Handle(ChFiDS_SurfData)& Data,
871 const Handle(ChFiDS_HElSpine)& HGuide,
872 const Handle(ChFiDS_Spine)& Spine,
873 const Standard_Integer Choix,
874 const Handle(BRepAdaptor_HSurface)& HS1,
875 const Handle(Adaptor3d_TopolTool)& I1,
876 const TopAbs_Orientation Or1,
877 const Handle(BRepAdaptor_HSurface)& HS2,
878 const Handle(Adaptor3d_TopolTool)& I2,
879 const Handle(BRepAdaptor_HCurve2d)& PC2,
880 const Handle(BRepAdaptor_HSurface)& HSref2,
881 const Handle(BRepAdaptor_HCurve2d)& PCref2,
882 Standard_Boolean& Decroch2,
81bba717 883 const Standard_Real /*Arrow*/,
7fd59977 884 const Standard_Real TolGuide,
885 Standard_Real& First,
886 Standard_Real& Last,
887 const Standard_Boolean Inside,
888 const Standard_Boolean Appro,
889 const Standard_Boolean Forward,
890 const Standard_Boolean RecP,
891 const Standard_Boolean RecS,
892 const Standard_Boolean RecRst,
893 const math_Vector& Soldep)
894{
895 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
896 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 897 ("PerformSurf : it is not the spine of a fillet");
7fd59977 898 Handle(BRepBlend_Line) lin;
899
81bba717 900 // Flexible parameters!
7fd59977 901 Standard_Real locfleche, MaxStep;
902 SimulParams(HGuide,fsp,MaxStep,locfleche);
903 Handle(ChFiDS_SecHArray1) sec;
904 gp_Pnt2d pf,pl,ppcf,ppcl;
905
906 Standard_Real PFirst = First;
907 if(fsp->IsConstant()){
908 BRepBlend_SurfRstConstRad func(HS1,HS2,PC2,HGuide);
909 func.Set(HSref2,PCref2);
910 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
911 HC->ChangeCurve().Load(HS2);
912 HC->ChangeCurve().Load(PC2);
913 BRepBlend_SurfCurvConstRadInv finvc(HS1,HC,HGuide);
914 BRepBlend_SurfPointConstRadInv finvp(HS1,HGuide);
915 BRepBlend_ConstRadInv finv(HS1,HSref2,HGuide);
916 finv.Set(Standard_False,PCref2);
917
918 Standard_Real rad = fsp->Radius();
919 Standard_Integer petitchoix = 1;
920 if(Or1 == TopAbs_REVERSED) petitchoix = 3;
921 if(Choix%2 == 0) petitchoix++;
922 finv.Set(rad,Choix);
923 finvc.Set(rad,petitchoix);
924 finvp.Set(rad,petitchoix);
925 func.Set(rad,petitchoix);
926 func.Set(myShape);
927
928 done = SimulData(Data,HGuide,lin,HS1,I1,HS2,PC2,I2,Decroch2,
929 func,finv,finvp,finvc,
930 PFirst,MaxStep,locfleche,TolGuide,First,Last,
931 Soldep,4,Inside,Appro,Forward,RecP,RecS,RecRst);
81bba717 932 if(!done) Standard_Failure::Raise("SimulSurf : Failed Processing!");
7fd59977 933 Standard_Integer nbp = lin->NbPoints();
934 sec = new ChFiDS_SecHArray1(1,nbp);
935 for(Standard_Integer i = 1; i <= nbp; i++){
936 ChFiDS_CircSection& isec = sec->ChangeValue(i);
937 Standard_Real u,v,w,param,p1,p2;
938 gp_Circ ci;
939 const Blend_Point& p = lin->Point(i);
940 p.ParametersOnS(u,v);
941 w = p.ParameterOnC();
942 param = p.Parameter();
943 func.Section(param,u,v,w,p1,p2,ci);
944 isec.Set(ci,p1,p2);
945 if(i == 1) {pf.SetCoord(u,v);p.ParametersOnS2(u,v);ppcf.SetCoord(u,v);}
946 if(i == nbp) {pl.SetCoord(u,v);p.ParametersOnS2(u,v);ppcl.SetCoord(u,v);}
947 }
948 }
949 else {
950 BRepBlend_SurfRstEvolRad func(HS1,HS2,PC2,HGuide,fsp->Law(HGuide));
951 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
952 HC->ChangeCurve().Load(HS2);
953 HC->ChangeCurve().Load(PC2);
954 BRepBlend_SurfCurvEvolRadInv finvc(HS1,HC,HGuide,fsp->Law(HGuide));
955 BRepBlend_SurfPointEvolRadInv finvp(HS1,HGuide,fsp->Law(HGuide));
956 BRepBlend_EvolRadInv finv(HS1,HSref2,HGuide,fsp->Law(HGuide));
957 finv.Set(Standard_False,PCref2);
958 Standard_Integer petitchoix = 1;
959 if(Or1 == TopAbs_REVERSED) petitchoix = 3;
960 if(Choix%2 == 0) petitchoix++;
961 finv.Set(Choix);
962 finvc.Set(petitchoix);
963 finvp.Set(petitchoix);
964 func.Set(petitchoix);
965 func.Set(myShape);
966 done = SimulData(Data,HGuide,lin,HS1,I1,HS2,PC2,I2,Decroch2,
967 func,finv,finvp,finvc,
968 PFirst,MaxStep,locfleche,TolGuide,First,Last,
969 Soldep,4,Inside,Appro,Forward,RecP,RecS,RecRst);
81bba717 970 if(!done) Standard_Failure::Raise("SimulSurf : Fail !");
7fd59977 971 Standard_Integer nbp = lin->NbPoints();
972 sec = new ChFiDS_SecHArray1(1,nbp);
973 for(Standard_Integer i = 1; i <= nbp; i++){
974 ChFiDS_CircSection& isec = sec->ChangeValue(i);
975 Standard_Real u,v,w,param,p1,p2;
976 gp_Circ ci;
977 const Blend_Point& p = lin->Point(i);
978 p.ParametersOnS(u,v);
979 w = p.ParameterOnC();
980 param = p.Parameter();
981 func.Section(param,u,v,w,p1,p2,ci);
982 isec.Set(ci,p1,p2);
983 if(i == 1) {pf.SetCoord(u,v);p.ParametersOnS2(u,v);ppcf.SetCoord(u,v);}
984 if(i == nbp) {pl.SetCoord(u,v);p.ParametersOnS2(u,v);ppcl.SetCoord(u,v);}
985 }
986 }
987 Data->SetSimul(sec);
988 //gp_Pnt2d pbid;
989 Data->Set2dPoints(pf,pl,ppcf,ppcl);
990 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
991 Standard_True, Data->ChangeVertexFirstOnS1(),tolesp);
992 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
993 Standard_False,Data->ChangeVertexLastOnS1(),tolesp);
994 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
995 Standard_True, Data->ChangeVertexFirstOnS2(),tolesp);
996 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
997 Standard_False, Data->ChangeVertexLastOnS2(),tolesp);
998}
999
1000
1001
1002//=======================================================================
1003//function : SimulSurf
1004//purpose :
1005//=======================================================================
1006
1007void ChFi3d_FilBuilder::SimulSurf(Handle(ChFiDS_SurfData)& Data,
1008 const Handle(ChFiDS_HElSpine)& HGuide,
1009 const Handle(ChFiDS_Spine)& Spine,
1010 const Standard_Integer Choix,
1011 const Handle(BRepAdaptor_HSurface)& HS1,
1012 const Handle(Adaptor3d_TopolTool)& I1,
1013 const Handle(BRepAdaptor_HCurve2d)& PC1,
1014 const Handle(BRepAdaptor_HSurface)& HSref1,
1015 const Handle(BRepAdaptor_HCurve2d)& PCref1,
1016 Standard_Boolean& Decroch1,
1017 const TopAbs_Orientation Or1,
1018 const Handle(BRepAdaptor_HSurface)& HS2,
1019 const Handle(Adaptor3d_TopolTool)& I2,
1020 const Handle(BRepAdaptor_HCurve2d)& PC2,
1021 const Handle(BRepAdaptor_HSurface)& HSref2,
1022 const Handle(BRepAdaptor_HCurve2d)& PCref2,
1023 Standard_Boolean& Decroch2,
1024 const TopAbs_Orientation Or2,
1025 const Standard_Real /*Fleche*/,
1026 const Standard_Real TolGuide,
1027 Standard_Real& First,
1028 Standard_Real& Last,
1029 const Standard_Boolean Inside,
1030 const Standard_Boolean Appro,
1031 const Standard_Boolean Forward,
1032 const Standard_Boolean RecP1,
1033 const Standard_Boolean RecRst1,
1034 const Standard_Boolean RecP2,
1035 const Standard_Boolean RecRst2,
1036 const math_Vector& Soldep)
1037{
1038 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1039 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 1040 ("PerformSurf : it is not the spine of a fillet");
7fd59977 1041 Handle(BRepBlend_Line) lin;
1042
81bba717 1043 // Flexible parameters!
7fd59977 1044 Standard_Real locfleche, MaxStep;
1045 SimulParams(HGuide,fsp,MaxStep,locfleche);
1046 Handle(ChFiDS_SecHArray1) sec;
1047// gp_Pnt2d pf,pl;
1048
1049 Standard_Integer ch1 = 1, ch2 = 2;
1050 Standard_Real PFirst = First;
1051
1052 if(fsp->IsConstant()){
1053 BRepBlend_RstRstConstRad func(HS1, PC1, HS2, PC2, HGuide);
1054 func.Set(HSref1, PCref1, HSref2, PCref2);
1055 Handle(Adaptor3d_HCurveOnSurface) HC1 = new Adaptor3d_HCurveOnSurface();
1056 HC1->ChangeCurve().Load(HS1);
1057 HC1->ChangeCurve().Load(PC1);
1058 Handle(Adaptor3d_HCurveOnSurface) HC2 = new Adaptor3d_HCurveOnSurface();
1059 HC2->ChangeCurve().Load(HS2);
1060 HC2->ChangeCurve().Load(PC2);
1061 BRepBlend_SurfCurvConstRadInv finv1(HSref1, HC2, HGuide);
1062 BRepBlend_CurvPointRadInv finvp1(HGuide, HC2);
1063 BRepBlend_SurfCurvConstRadInv finv2(HSref2, HC1, HGuide);
1064 BRepBlend_CurvPointRadInv finvp2(HGuide, HC1);
1065
1066 finv1.Set(PCref1);
1067 finv2.Set(PCref2);
1068
1069
1070 Standard_Real rad = fsp->Radius();
1071 if(Or1 == TopAbs_REVERSED) ch1 = 3;
1072 if(Or2 == TopAbs_REVERSED) ch2 = 3;
1073
1074 finv1.Set(rad, ch1);
1075 finvp1.Set(Choix);
1076 finv2.Set(rad, ch2);
1077 finvp2.Set(Choix);
1078 func.Set(rad, Choix);
1079 func.Set(myShape);
1080
1081 done = SimulData(Data, HGuide, lin, HS1, PC1, I1, Decroch1, HS2, PC2, I2, Decroch2,
1082 func, finv1, finvp1, finv2, finvp2,
1083 PFirst, MaxStep, locfleche, TolGuide, First, Last,
1084 Soldep, 4, Inside, Appro, Forward, RecP1, RecRst1, RecP2, RecRst2);
81bba717 1085 if(!done) Standard_Failure::Raise("SimulSurf : Failed processing!");
7fd59977 1086 Standard_Integer nbp = lin->NbPoints();
1087 sec = new ChFiDS_SecHArray1(1,nbp);
1088 for(Standard_Integer i = 1; i <= nbp; i++){
1089 ChFiDS_CircSection& isec = sec->ChangeValue(i);
1090 Standard_Real u, v, param, p1, p2;
1091 gp_Circ ci;
1092 const Blend_Point& p = lin->Point(i);
1093 u = p.ParameterOnC1();
1094 v = p.ParameterOnC2();
1095 param = p.Parameter();
1096 func.Section(param, u, v, p1, p2, ci);
1097 isec.Set(ci, p1, p2);
1098// if(i == 1) {pf.SetCoord(u,v);}
1099// if(i == nbp) {pl.SetCoord(u,v);}
1100 }
1101 }
1102 else {
1103 BRepBlend_RstRstEvolRad func(HS1,PC1, HS2, PC2, HGuide, fsp->Law(HGuide));
1104 func.Set(HSref1, PCref1, HSref2, PCref2);
1105 Handle(Adaptor3d_HCurveOnSurface) HC1 = new Adaptor3d_HCurveOnSurface();
1106 HC1->ChangeCurve().Load(HS1);
1107 HC1->ChangeCurve().Load(PC1);
1108 Handle(Adaptor3d_HCurveOnSurface) HC2 = new Adaptor3d_HCurveOnSurface();
1109 HC2->ChangeCurve().Load(HS2);
1110 HC2->ChangeCurve().Load(PC2);
1111
1112 BRepBlend_SurfCurvEvolRadInv finv1(HSref1, HC2, HGuide, fsp->Law(HGuide));
1113 BRepBlend_CurvPointRadInv finvp1(HGuide, HC2);
1114 BRepBlend_SurfCurvEvolRadInv finv2(HSref2, HC1, HGuide, fsp->Law(HGuide));
1115 BRepBlend_CurvPointRadInv finvp2(HGuide, HC1);
1116
1117 finv1.Set(PCref1);
1118 finv2.Set(PCref2);
1119
1120 Standard_Integer ch11 = 1, ch22 = 2;
1121
1122 if(Or1 == TopAbs_REVERSED) ch11 = 3;
1123 if(Or2 == TopAbs_REVERSED) ch22 = 3;
1124
1125
1126 finv1.Set(ch11);
1127 finvp1.Set(Choix);
1128 finv2.Set(ch22);
1129 finvp2.Set(Choix);
1130 func.Set(Choix);
1131 func.Set(myShape);
1132
1133 done = SimulData(Data, HGuide, lin, HS1, PC1, I1, Decroch1, HS2, PC2, I2, Decroch2,
1134 func, finv1, finvp1, finv2, finvp2,
1135 PFirst, MaxStep, locfleche, TolGuide, First, Last,
1136 Soldep, 4, Inside, Appro, Forward, RecP1, RecRst1, RecP2, RecRst2);
1137
81bba717 1138 if(!done) Standard_Failure::Raise("SimulSurf : Fail !");
7fd59977 1139 Standard_Integer nbp = lin->NbPoints();
1140 sec = new ChFiDS_SecHArray1(1, nbp);
1141 for(Standard_Integer i = 1; i <= nbp; i++){
1142 ChFiDS_CircSection& isec = sec->ChangeValue(i);
1143 Standard_Real u, v, param, p1, p2;
1144 gp_Circ ci;
1145 const Blend_Point& p = lin->Point(i);
1146 u = p.ParameterOnC1();
1147 v = p.ParameterOnC2();
1148 param = p.Parameter();
1149 func.Section(param, u, v, p1, p2, ci);
1150 isec.Set(ci, p1, p2);
1151// if(i == 1) {pf.SetCoord(u,v);}
1152// if(i == nbp) {pl.SetCoord(u,v);}
1153 }
1154 }
1155 Data->SetSimul(sec);
1156// gp_Pnt2d pbid;
1157// Data->Set2dPoints(pf,pl,pbid,pbid);
1158
1159 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
1160 Standard_True, Data->ChangeVertexFirstOnS1(),tolesp);
1161 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
1162 Standard_False,Data->ChangeVertexLastOnS1(),tolesp);
1163 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
1164 Standard_True, Data->ChangeVertexFirstOnS2(),tolesp);
1165 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
1166 Standard_False, Data->ChangeVertexLastOnS2(),tolesp);
1167}
1168
1169
1170
1171
1172
1173
1174
1175//=======================================================================
1176//function : PerformFirstSection
1177//purpose :
1178//=======================================================================
1179
1180Standard_Boolean ChFi3d_FilBuilder::PerformFirstSection
1181(const Handle(ChFiDS_Spine)& Spine,
1182 const Handle(ChFiDS_HElSpine)& HGuide,
1183 const Standard_Integer Choix,
1184 Handle(BRepAdaptor_HSurface)& S1,
1185 Handle(BRepAdaptor_HSurface)& S2,
1186 const Handle(Adaptor3d_TopolTool)& I1,
1187 const Handle(Adaptor3d_TopolTool)& I2,
1188 const Standard_Real Par,
1189 math_Vector& SolDep,
1190 TopAbs_State& Pos1,
1191 TopAbs_State& Pos2) const
1192{
1193 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1194 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 1195 ("PerformSurf : this is not the spine of a fillet");
7fd59977 1196 Standard_Real TolGuide = HGuide->Resolution(tolesp);
1197 if(fsp->IsConstant()){
1198 BRepBlend_ConstRad Func(S1,S2,HGuide);
1199 Func.Set(fsp->Radius(),Choix);
1200 Func.Set(myShape);
1201 BRepBlend_Walking TheWalk(S1,S2,I1,I2);
1202 return TheWalk.PerformFirstSection(Func,Par,SolDep,
1203 tolesp,TolGuide,Pos1,Pos2);
1204 }
1205 else {
1206 BRepBlend_EvolRad Func(S1,S2,HGuide,fsp->Law(HGuide));
1207 Func.Set(Choix);
1208 Func.Set(myShape);
1209 BRepBlend_Walking TheWalk(S1,S2,I1,I2);
1210 return TheWalk.PerformFirstSection(Func,Par,SolDep,
1211 tolesp,TolGuide,Pos1,Pos2);
1212 }
1213}
1214
1215//=======================================================================
1216//function : PerformSurf
1217//purpose :
1218//=======================================================================
1219
1220Standard_Boolean
1221ChFi3d_FilBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData,
1222 const Handle(ChFiDS_HElSpine)& HGuide,
1223 const Handle(ChFiDS_Spine)& Spine,
1224 const Standard_Integer Choix,
1225 const Handle(BRepAdaptor_HSurface)& S1,
1226 const Handle(Adaptor3d_TopolTool)& I1,
1227 const Handle(BRepAdaptor_HSurface)& S2,
1228 const Handle(Adaptor3d_TopolTool)& I2,
1229 const Standard_Real MaxStep,
1230 const Standard_Real Fleche,
1231 const Standard_Real TolGuide,
1232 Standard_Real& First,
1233 Standard_Real& Last,
1234 const Standard_Boolean Inside,
1235 const Standard_Boolean Appro,
1236 const Standard_Boolean Forward,
1237 const Standard_Boolean RecOnS1,
1238 const Standard_Boolean RecOnS2,
1239 const math_Vector& Soldep,
1240 Standard_Boolean& intf,
1241 Standard_Boolean& intl)
1242{
1243#ifdef DEB
1244 OSD_Chronometer ch;
1245#endif
1246 Handle(ChFiDS_SurfData) Data = SeqData(1);
1247 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1248 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 1249 ("PerformSurf : this is not the spine of a fillet");
7fd59977 1250 Standard_Boolean gd1,gd2,gf1,gf2, maybesingular;
1251 Handle(BRepBlend_Line) lin;
1252 TopAbs_Orientation Or = S1->ChangeSurface().Face().Orientation();
1253 Standard_Real PFirst = First;
1254 if(intf) First = fsp->FirstParameter(1);
1255 if(intl) Last = fsp->LastParameter(fsp->NbEdges());
1256 if(fsp->IsConstant()){
1257 BRepBlend_ConstRad Func(S1,S2,HGuide);
1258 BRepBlend_ConstRadInv FInv(S1,S2,HGuide);
1259 Func.Set(fsp->Radius(),Choix);
1260 FInv.Set(fsp->Radius(),Choix);
1261 Func.Set(myShape);
1262
1263#ifdef DEB
1264 ChFi3d_InitChron(ch); //init perf ComputeData
1265#endif
1266
1267 done = ComputeData(Data,HGuide,Spine,lin,S1,I1,S2,I2,Func,FInv,
1268 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1269 Inside,Appro,Forward,Soldep,intf,intl,
1270 gd1,gd2,gf1,gf2,RecOnS1,RecOnS2);
1271
1272#ifdef DEB
1273 ChFi3d_ResultChron(ch , t_computedata);// result perf ComputeData
1274#endif
1275
81bba717 1276 if(!done) return Standard_False; // recovery is possible PMN 14/05/1998
7fd59977 1277
1278#ifdef DEB
1279 ChFi3d_InitChron(ch);// init perf CompleteData
1280#endif
1281
1282 done = CompleteData(Data,Func,lin,S1,S2,Or,gd1,gd2,gf1,gf2);
1283
1284#ifdef DEB
1285 ChFi3d_ResultChron(ch , t_completedata);// result perf CompleteData
1286#endif
1287
81bba717 1288 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1289 maybesingular = (Func.GetMinimalDistance()<=100*tolapp3d);
1290 }
1291 else {
1292 BRepBlend_EvolRad Func(S1, S2, HGuide, fsp->Law(HGuide));
1293 BRepBlend_EvolRadInv FInv(S1, S2, HGuide, fsp->Law(HGuide));
1294 Func.Set(Choix);
1295 FInv.Set(Choix);
1296 Func.Set(myShape);
1297
1298#ifdef DEB
1299 ChFi3d_InitChron(ch);// init perf ComputeData
1300#endif
1301
1302 done = ComputeData(Data,HGuide,Spine,lin,S1,I1,S2,I2,Func,FInv,
1303 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1304 Inside,Appro,Forward,Soldep,intf,intl,
1305 gd1,gd2,gf1,gf2,RecOnS1,RecOnS2);
1306#ifdef DEB
1307 ChFi3d_ResultChron(ch , t_computedata); //result perf ComputeData
1308#endif
1309
1310 if(!done) return Standard_False;
1311
1312#ifdef DEB
1313 ChFi3d_InitChron(ch);// init perf CompleteData
1314#endif
1315
1316 done = CompleteData(Data,Func,lin,S1,S2,Or,gd1,gd2,gf1,gf2);
1317
1318#ifdef DEB
1319 ChFi3d_ResultChron(ch , t_completedata);// result perf CompleteData
1320#endif
1321
81bba717 1322 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1323 maybesingular = (Func.GetMinimalDistance()<=100*tolapp3d);
1324 }
1325 if (maybesingular) SplitSurf(SeqData, lin);
1326 return Standard_True;
1327}
1328
1329//=======================================================================
1330//function : PerformSurf
1331//purpose :
1332//=======================================================================
1333
1334void ChFi3d_FilBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData,
1335 const Handle(ChFiDS_HElSpine)& HGuide,
1336 const Handle(ChFiDS_Spine)& Spine,
1337 const Standard_Integer Choix,
1338 const Handle(BRepAdaptor_HSurface)& HS1,
1339 const Handle(Adaptor3d_TopolTool)& I1,
1340 const Handle(BRepAdaptor_HCurve2d)& PC1,
1341 const Handle(BRepAdaptor_HSurface)& HSref1,
1342 const Handle(BRepAdaptor_HCurve2d)& PCref1,
1343 Standard_Boolean& Decroch1,
1344 const Handle(BRepAdaptor_HSurface)& HS2,
1345 const Handle(Adaptor3d_TopolTool)& I2,
1346 const TopAbs_Orientation Or2,
1347 const Standard_Real MaxStep,
1348 const Standard_Real Fleche,
1349 const Standard_Real TolGuide,
1350 Standard_Real& First,
1351 Standard_Real& Last,
1352 const Standard_Boolean Inside,
1353 const Standard_Boolean Appro,
1354 const Standard_Boolean Forward,
1355 const Standard_Boolean RecP,
1356 const Standard_Boolean RecS,
1357 const Standard_Boolean RecRst,
1358 const math_Vector& Soldep)
1359{
1360 Handle(ChFiDS_SurfData) Data = SeqData(1);
1361 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1362 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 1363 ("PerformSurf : this is not the spine of a fillet");
7fd59977 1364 Handle(BRepBlend_Line) lin;
1365 Standard_Real PFirst = First;
1366 Standard_Boolean maybesingular;
1367
1368 if(fsp->IsConstant()){
1369 BRepBlend_SurfRstConstRad func(HS2,HS1,PC1,HGuide);
1370 func.Set(HSref1,PCref1);
1371 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
1372 HC->ChangeCurve().Load(HS1);
1373 HC->ChangeCurve().Load(PC1);
1374 BRepBlend_SurfCurvConstRadInv finvc(HS2,HC,HGuide);
1375 BRepBlend_SurfPointConstRadInv finvp(HS2,HGuide);
1376 BRepBlend_ConstRadInv finv(HS2,HSref1,HGuide);
1377 finv.Set(Standard_False,PCref1);
1378
1379 Standard_Real rad = fsp->Radius();
1380 Standard_Integer petitchoix = 1;
1381 if(Or2 == TopAbs_REVERSED) petitchoix = 3;
1382 if(Choix%2 == 0) petitchoix++;
1383 finv.Set(rad,Choix);
1384 finvc.Set(rad,petitchoix);
1385 finvp.Set(rad,petitchoix);
1386 func.Set(rad,petitchoix);
1387 func.Set(myShape);
1388
1389 done = ComputeData(Data,HGuide,lin,HS2,I2,HS1,PC1,I1,Decroch1,
1390 func,finv,finvp,finvc,
1391 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1392 Soldep,Inside,Appro,Forward,RecP,RecS,RecRst);
1393 if(!done) {
1394 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1395 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1396 }
1397 TopAbs_Orientation Or = HS2->ChangeSurface().Face().Orientation();
1398 done = CompleteData(Data,func,lin,HS1,HS2,Or,1);
81bba717 1399 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1400 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1401 }
1402 else {
1403 Standard_Real SpFirst = HGuide->FirstParameter();
1404 Standard_Real SpLast = HGuide->LastParameter();
1405 BRepBlend_SurfRstEvolRad func(HS2,HS1,PC1,HGuide,fsp->Law(HGuide));
1406 func.Set(HSref1,PCref1);
1407 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
1408 HC->ChangeCurve().Load(HS1);
1409 HC->ChangeCurve().Load(PC1);
1410 BRepBlend_SurfCurvEvolRadInv finvc(HS2,HC,HGuide,fsp->Law(HGuide));
1411 BRepBlend_SurfPointEvolRadInv finvp(HS2,HGuide,fsp->Law(HGuide));
1412 BRepBlend_EvolRadInv finv(HS2,HSref1,HGuide,fsp->Law(HGuide));
1413 finv.Set(Standard_False,PCref1);
1414 Standard_Integer petitchoix = 1;
1415 if(Or2 == TopAbs_REVERSED) petitchoix = 3;
1416 if(Choix%2 == 0) petitchoix++;
1417 finv.Set(Choix);
1418 finvc.Set(petitchoix);
1419 finvp.Set(petitchoix);
1420 func.Set(petitchoix);
1421 func.Set(myShape);
1422 SpFirst = HGuide->FirstParameter();SpLast = HGuide->LastParameter();
1423 done = ComputeData(Data,HGuide,lin,HS2,I2,HS1,PC1,I1,Decroch1,
1424 func,finv,finvp,finvc,
1425 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1426 Soldep,Inside,Appro,Forward,RecP,RecS,RecRst);
1427 if(!done) {
1428 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1429 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1430 }
1431 TopAbs_Orientation Or = HS2->ChangeSurface().Face().Orientation();
1432 done = CompleteData(Data,func,lin,HS1,HS2,Or,1);
81bba717 1433 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1434 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1435 }
1436 if (maybesingular) SplitSurf(SeqData, lin);
1437}
1438
1439//=======================================================================
1440//function : PerformSurf
1441//purpose :
1442//=======================================================================
1443
1444void ChFi3d_FilBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData,
1445 const Handle(ChFiDS_HElSpine)& HGuide,
1446 const Handle(ChFiDS_Spine)& Spine,
1447 const Standard_Integer Choix,
1448 const Handle(BRepAdaptor_HSurface)& HS1,
1449 const Handle(Adaptor3d_TopolTool)& I1,
1450 const TopAbs_Orientation Or1,
1451 const Handle(BRepAdaptor_HSurface)& HS2,
1452 const Handle(Adaptor3d_TopolTool)& I2,
1453 const Handle(BRepAdaptor_HCurve2d)& PC2,
1454 const Handle(BRepAdaptor_HSurface)& HSref2,
1455 const Handle(BRepAdaptor_HCurve2d)& PCref2,
1456 Standard_Boolean& Decroch2,
1457 const Standard_Real MaxStep,
1458 const Standard_Real Fleche,
1459 const Standard_Real TolGuide,
1460 Standard_Real& First,
1461 Standard_Real& Last,
1462 const Standard_Boolean Inside,
1463 const Standard_Boolean Appro,
1464 const Standard_Boolean Forward,
1465 const Standard_Boolean RecP,
1466 const Standard_Boolean RecS,
1467 const Standard_Boolean RecRst,
1468 const math_Vector& Soldep)
1469{
1470 Handle(ChFiDS_SurfData) Data = SeqData(1);;
1471 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1472 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 1473 ("PerformSurf : this is not the spine of a fillet");
7fd59977 1474 Handle(BRepBlend_Line) lin;
1475 Standard_Real PFirst = First;
1476 Standard_Boolean maybesingular;
1477
1478 if(fsp->IsConstant()){
1479 BRepBlend_SurfRstConstRad func(HS1,HS2,PC2,HGuide);
1480 func.Set(HSref2,PCref2);
1481 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
1482 HC->ChangeCurve().Load(HS2);
1483 HC->ChangeCurve().Load(PC2);
1484 BRepBlend_SurfCurvConstRadInv finvc(HS1,HC,HGuide);
1485 BRepBlend_SurfPointConstRadInv finvp(HS1,HGuide);
1486 BRepBlend_ConstRadInv finv(HS1,HSref2,HGuide);
1487 finv.Set(Standard_False,PCref2);
1488
1489 Standard_Real rad = fsp->Radius();
1490 Standard_Integer petitchoix = 1;
1491 if(Or1 == TopAbs_REVERSED) petitchoix = 3;
1492 if(Choix%2 == 0) petitchoix++;
1493 finv.Set(rad,Choix);
1494 finvc.Set(rad,petitchoix);
1495 finvp.Set(rad,petitchoix);
1496 func.Set(rad,petitchoix);
1497 func.Set(myShape);
1498
1499 done = ComputeData(Data,HGuide,lin,HS1,I1,HS2,PC2,I2,Decroch2,
1500 func,finv,finvp,finvc,
1501 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1502 Soldep,Inside,Appro,Forward,RecP,RecS,RecRst);
1503 if(!done) {
1504 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1505 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1506 }
1507 TopAbs_Orientation Or = HS1->ChangeSurface().Face().Orientation();
1508 done = CompleteData(Data,func,lin,HS1,HS2,Or,0);
81bba717 1509 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1510 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1511 }
1512 else {
1513 BRepBlend_SurfRstEvolRad func(HS1,HS2,PC2,HGuide,fsp->Law(HGuide));
1514 func.Set(HSref2,PCref2);
1515 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
1516 HC->ChangeCurve().Load(HS2);
1517 HC->ChangeCurve().Load(PC2);
1518 BRepBlend_SurfCurvEvolRadInv finvc(HS1,HC,HGuide,fsp->Law(HGuide));
1519 BRepBlend_SurfPointEvolRadInv finvp(HS1,HGuide,fsp->Law(HGuide));
1520 BRepBlend_EvolRadInv finv(HS1,HSref2,HGuide,fsp->Law(HGuide));
1521 finv.Set(Standard_False,PCref2);
1522 Standard_Integer petitchoix = 1;
1523 if(Or1 == TopAbs_REVERSED) petitchoix = 3;
1524 if(Choix%2 == 0) petitchoix++;
1525 finv.Set(Choix);
1526 finvc.Set(petitchoix);
1527 finvp.Set(petitchoix);
1528 func.Set(petitchoix);
1529 func.Set(myShape);
1530
1531 done = ComputeData(Data,HGuide,lin,HS1,I1,HS2,PC2,I2,Decroch2,
1532 func,finv,finvp,finvc,
1533 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1534 Soldep,Inside,Appro,Forward,RecP,RecS,RecRst);
1535 if(!done) {
1536 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1537 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1538 }
1539 TopAbs_Orientation Or = HS1->ChangeSurface().Face().Orientation();
1540 done = CompleteData(Data,func,lin,HS1,HS2,Or,0);
81bba717 1541 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1542 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1543 }
1544 if (maybesingular) SplitSurf(SeqData, lin);
1545}
1546
1547
1548
1549
1550
1551
1552//=======================================================================
1553//function : PerformSurf
1554//purpose :
1555//=======================================================================
1556
1557void ChFi3d_FilBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData,
1558 const Handle(ChFiDS_HElSpine)& HGuide,
1559 const Handle(ChFiDS_Spine)& Spine,
1560 const Standard_Integer Choix,
1561 const Handle(BRepAdaptor_HSurface)& HS1,
1562 const Handle(Adaptor3d_TopolTool)& I1,
1563 const Handle(BRepAdaptor_HCurve2d)& PC1,
1564 const Handle(BRepAdaptor_HSurface)& HSref1,
1565 const Handle(BRepAdaptor_HCurve2d)& PCref1,
1566 Standard_Boolean& Decroch1,
1567 const TopAbs_Orientation Or1,
1568 const Handle(BRepAdaptor_HSurface)& HS2,
1569 const Handle(Adaptor3d_TopolTool)& I2,
1570 const Handle(BRepAdaptor_HCurve2d)& PC2,
1571 const Handle(BRepAdaptor_HSurface)& HSref2,
1572 const Handle(BRepAdaptor_HCurve2d)& PCref2,
1573 Standard_Boolean& Decroch2,
1574 const TopAbs_Orientation Or2,
1575 const Standard_Real MaxStep,
1576 const Standard_Real Fleche,
1577 const Standard_Real TolGuide,
1578 Standard_Real& First,
1579 Standard_Real& Last,
1580 const Standard_Boolean Inside,
1581 const Standard_Boolean Appro,
1582 const Standard_Boolean Forward,
1583 const Standard_Boolean RecP1,
1584 const Standard_Boolean RecRst1,
1585 const Standard_Boolean RecP2,
1586 const Standard_Boolean RecRst2,
1587 const math_Vector& Soldep)
1588{
1589 Handle(ChFiDS_SurfData) Data = SeqData(1);;
1590 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1591 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 1592 ("PerformSurf : this is not the spine of a fillet");
7fd59977 1593 Handle(BRepBlend_Line) lin;
1594 Standard_Real PFirst = First;
1595 Standard_Boolean maybesingular;
1596
1597 if(fsp->IsConstant()){
1598 BRepBlend_RstRstConstRad func(HS1, PC1, HS2, PC2, HGuide);
1599 func.Set(HSref1, PCref1, HSref2, PCref2);
1600 Handle(Adaptor3d_HCurveOnSurface) HC1 = new Adaptor3d_HCurveOnSurface();
1601 HC1->ChangeCurve().Load(HS1);
1602 HC1->ChangeCurve().Load(PC1);
1603 Handle(Adaptor3d_HCurveOnSurface) HC2 = new Adaptor3d_HCurveOnSurface();
1604 HC2->ChangeCurve().Load(HS2);
1605 HC2->ChangeCurve().Load(PC2);
1606 BRepBlend_SurfCurvConstRadInv finv1(HSref1, HC2, HGuide);
1607 BRepBlend_CurvPointRadInv finvp1(HGuide, HC2);
1608 BRepBlend_SurfCurvConstRadInv finv2(HSref2, HC1, HGuide);
1609 BRepBlend_CurvPointRadInv finvp2(HGuide, HC1);
1610
1611 finv1.Set(PCref1);
1612 finv2.Set(PCref2);
1613
1614 Standard_Integer ch1 = 1, ch2 = 2;
1615 Standard_Real rad = fsp->Radius();
1616 if(Or1 == TopAbs_REVERSED) ch1 = 3;
1617 if(Or2 == TopAbs_REVERSED) ch2 = 3;
1618
1619 finv1.Set(rad, ch1);
1620 finvp1.Set(Choix);
1621 finv2.Set(rad, ch2);
1622 finvp2.Set(Choix);
1623 func.Set(rad, Choix);
1624 func.Set(myShape);
1625
1626 done = ComputeData(Data, HGuide, lin, HS1, PC1, I1, Decroch1, HS2, PC2, I2, Decroch2,
1627 func, finv1, finvp1, finv2, finvp2,
1628 PFirst, MaxStep, Fleche, TolGuide, First, Last,
1629 Soldep, Inside, Appro, Forward, RecP1, RecRst1, RecP2, RecRst2);
1630 if(!done) {
1631 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1632 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1633 }
1634 TopAbs_Orientation Or = HS1->ChangeSurface().Face().Orientation();
1635 done = CompleteData(Data, func, lin, HS1, HS2, Or);
81bba717 1636 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1637 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1638 }
1639 else {
1640 BRepBlend_RstRstEvolRad func(HS1,PC1, HS2, PC2, HGuide, fsp->Law(HGuide));
1641 func.Set(HSref1, PCref1, HSref2, PCref2);
1642 Handle(Adaptor3d_HCurveOnSurface) HC1 = new Adaptor3d_HCurveOnSurface();
1643 HC1->ChangeCurve().Load(HS1);
1644 HC1->ChangeCurve().Load(PC1);
1645 Handle(Adaptor3d_HCurveOnSurface) HC2 = new Adaptor3d_HCurveOnSurface();
1646 HC2->ChangeCurve().Load(HS2);
1647 HC2->ChangeCurve().Load(PC2);
1648
1649 BRepBlend_SurfCurvEvolRadInv finv1(HSref1, HC2, HGuide, fsp->Law(HGuide));
1650 BRepBlend_CurvPointRadInv finvp1(HGuide, HC2);
1651 BRepBlend_SurfCurvEvolRadInv finv2(HSref2, HC1, HGuide, fsp->Law(HGuide));
1652 BRepBlend_CurvPointRadInv finvp2(HGuide, HC1);
1653
1654 finv1.Set(PCref1);
1655 finv2.Set(PCref2);
1656
1657 Standard_Integer ch1 = 1, ch2 = 2;
1658
1659 if(Or1 == TopAbs_REVERSED) ch1 = 3;
1660 if(Or2 == TopAbs_REVERSED) ch2 = 3;
1661
1662
1663 finv1.Set(ch1);
1664 finvp1.Set(Choix);
1665 finv2.Set(ch2);
1666 finvp2.Set(Choix);
1667 func.Set(Choix);
1668 func.Set(myShape);
1669
1670 done = ComputeData(Data, HGuide, lin, HS1, PC1, I1, Decroch1, HS2, PC2,I2, Decroch2,
1671 func, finv1, finvp1, finv2, finvp2,
1672 PFirst, MaxStep, Fleche, TolGuide, First, Last,
1673 Soldep, Inside, Appro, Forward, RecP1, RecRst1, RecP2, RecRst2);
1674
1675 if(!done) {
1676 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1677 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1678 }
1679 TopAbs_Orientation Or = HS1->ChangeSurface().Face().Orientation();
1680 done = CompleteData(Data, func, lin, HS1, HS2, Or);
81bba717 1681 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1682 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1683
1684
1685 }
1686 if (maybesingular) SplitSurf(SeqData, lin);
1687}
1688
1689
1690
1691
1692//=======================================================================
1693//function : SplitSurf
1694//purpose :
1695//=======================================================================
1696
1697void ChFi3d_FilBuilder::SplitSurf(ChFiDS_SequenceOfSurfData& SeqData,
1698 const Handle(BRepBlend_Line)& Line)
1699{
1700 Standard_Integer ii, Nbpnt=Line->NbPoints();
1701 if (Nbpnt <3) return;
1702 Standard_Real UFirst,ULast,VFirst,VLast;
1703 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1704 Standard_Integer ISurf;
1705 Handle(ChFiDS_SurfData) ref = SeqData(1);
1706 Blend_Point P;
1707
1708 ISurf= ref->Surf();
1709 Handle(Geom_Surface) Surf = DStr.Surface(ISurf).Surface();
1710 Surf->Bounds(UFirst,ULast,VFirst,VLast);
1711 Handle(Geom_Curve) Courbe1 = Surf->UIso(UFirst);
1712 Handle(Geom_Curve) Courbe2 = Surf->UIso(ULast);
1713 ChFi3d_SearchSing Fonc(Courbe1, Courbe2);
1714
1715 TColStd_SequenceOfReal LesVi;
1716 Standard_Real precedant, suivant, courant;
1717 Standard_Real a, b, c;
1718
81bba717 1719 // (1) Finds vi so that iso v=vi is punctual
7fd59977 1720 VFirst = Min( ref->InterferenceOnS1().FirstParameter(),
1721 ref->InterferenceOnS2().FirstParameter() );
1722 VLast = Max( ref->InterferenceOnS1().LastParameter(),
1723 ref->InterferenceOnS2().LastParameter() );
1724
81bba717 1725 // (1.1) Finds the first point inside
7fd59977 1726 for (ii=1; ii<=Nbpnt && Line->Point(ii).Parameter()<VFirst; ii++) {}
1727 if (ii==1) ii++;
1728 P = Line->Point(ii);
1729 b = P.Parameter();
1730 courant = P.PointOnS1().Distance(P.PointOnS2());
1731 P = Line->Point(ii-1);
1732 a = P.Parameter();
1733 precedant = P.PointOnS1().Distance(P.PointOnS2());
1734 ii ++;
1735
81bba717 1736 // (1.2) Find a minimum by "points"
7fd59977 1737 for ( ; ii<=Nbpnt && Line->Point(ii).Parameter()<=VLast; ii++) {
1738 for (;ii<=Nbpnt &&
1739 Line->Point(ii).Parameter()<VLast &&
1740 Line->Point(ii).Parameter()-b<Precision::PConfusion(); ii++) {}
1741
1742 const Blend_Point& pnt = Line->Point(ii);
1743 c = pnt.Parameter();
1744 suivant = pnt.PointOnS1().Distance(pnt.PointOnS2());
1745 if ( (courant < precedant) && (courant < suivant) ) {
81bba717 1746 // (1.3) Find the exact minimum
7fd59977 1747 math_FunctionRoot Resol(Fonc, (a+c)/2,
1748 tol2d,//Surf->VResolution(toleps),
1749 a, c,
1750 50);
1751 if (Resol.IsDone()) {
1752 Standard_Real Val, racine=Resol.Root();
1753
1754 Fonc.Value(Resol.Root(), Val);
1755 if (Val< tolapp3d) {
81bba717 1756 // the solution (avoiding the risks of confusion)
7fd59977 1757 if (LesVi.Length()==0) {
1758 if ( (racine > VFirst+tol2d) &&
1759 (racine < VLast -tol2d) ) {
1760 LesVi.Append(racine);
1761 }
1762 }
1763 else {
1764 if ( (racine > LesVi(LesVi.Length()) + tol2d) &&
1765 (racine < VLast-tol2d) ) {
1766 LesVi.Append(racine);
1767 }
1768 }
1769 }
1770 }
1771 else {
1772# if DEB
81bba717 1773 cout << "Failed calculation of the minimum length" << endl;
7fd59977 1774# endif
1775 }
1776 }
81bba717 1777 // update if non duplication
7fd59977 1778 a = b;
1779 precedant = courant;
1780 b = c;
1781 courant = suivant;
1782 }
1783
81bba717 1784 // (2) Update of the sequence of SurfData
7fd59977 1785 if (LesVi.Length()>0) {
1786 TopOpeBRepDS_DataStructure& DStru = myDS->ChangeDS();
1787 Handle(ChFiDS_SurfData) SD;
1788 TopOpeBRepDS_Surface S;
1789 TopOpeBRepDS_Curve C1, C2;
1790 Standard_Real T, VertexTol;
1791 gp_Pnt P3d, P1, P2;
1792 ChFiDS_CommonPoint LePoint;
1793 for (ii=1 ; ii<=LesVi.Length(); ii++) {
1794
1795 T = LesVi(ii);
81bba717 1796 // (2.0) copy and insertion
7fd59977 1797 SD = new (ChFiDS_SurfData);
1798 SD->Copy(ref);
1799 SeqData.InsertBefore(ii, SD);
1800 S = DStru.Surface(ref->Surf());
1801 SD->ChangeSurf(DStru.AddSurface(S));
1802 C1 = DStru.Curve(SD->InterferenceOnS1().LineIndex());
1803 SD->ChangeInterferenceOnS1().SetLineIndex( DStru.AddCurve(C1));
1804 C2 = DStru.Curve(SD->InterferenceOnS2().LineIndex());
1805 SD->ChangeInterferenceOnS2().SetLineIndex(DStru.AddCurve(C2));
1806
81bba717 1807 // (2.1) Modification of common Point
7fd59977 1808 SD-> ChangeVertexLastOnS1().Reset();
1809 SD-> ChangeVertexLastOnS2().Reset();
1810 ref->ChangeVertexFirstOnS1().Reset();
1811 ref->ChangeVertexFirstOnS2().Reset();
1812 Courbe1->D0(T, P1);
1813 Courbe2->D0(T, P2);
1814 P3d.SetXYZ((P1.XYZ()+ P2.XYZ())/2);
1815 VertexTol = P1.Distance(P2);
1816 VertexTol += Max(C1.Tolerance(), C2.Tolerance());
1817
1818 SD->ChangeVertexLastOnS1().SetPoint(P3d);
1819 SD->ChangeVertexLastOnS2().SetPoint(P3d);
1820 ref->ChangeVertexFirstOnS1().SetPoint(P3d);
1821 ref->ChangeVertexFirstOnS2().SetPoint(P3d);
1822 SD->ChangeVertexLastOnS1().SetTolerance(VertexTol);
1823 SD->ChangeVertexLastOnS2().SetTolerance(VertexTol);
1824 ref->ChangeVertexFirstOnS1().SetTolerance(VertexTol);
1825 ref->ChangeVertexFirstOnS2().SetTolerance(VertexTol);
1826
81bba717 1827 // (2.2) Modification of interferences
7fd59977 1828 SD->ChangeInterferenceOnS1().SetLastParameter(T);
1829 SD->ChangeInterferenceOnS2().SetLastParameter(T);
1830 ref->ChangeInterferenceOnS1().SetFirstParameter(T);
1831 ref->ChangeInterferenceOnS2().SetFirstParameter(T);
1832
81bba717 1833 // Parameters on ElSpine
7fd59977 1834 SD->LastSpineParam(T);
1835 ref->FirstSpineParam(T);
1836 }
1837 }
1838}
1839
1840//=======================================================================
1841//function : ExtentOneCorner
1842//purpose :
1843//=======================================================================
1844
1845void ChFi3d_FilBuilder::ExtentOneCorner(const TopoDS_Vertex& V,
1846 const Handle(ChFiDS_Stripe)& S)
1847{
81bba717 1848 // review by using the data at end of fillets (point, radius, normal
1849 // to the faces and tangents of the guideline).
7fd59977 1850#ifndef DEB
1851 Standard_Integer Sens = 0;
1852#else
1853 Standard_Integer Sens;
1854#endif
1855 Standard_Real Coeff = 0.5;
1856 Handle(ChFiDS_Spine) Spine = S->Spine();
1857 ChFi3d_IndexOfSurfData(V,S,Sens);
1858 Standard_Real dU = Spine->LastParameter(Spine->NbEdges());
1859 if (Spine->IsTangencyExtremity((Sens == 1)))
81bba717 1860 return; //No extension in the queue
7fd59977 1861
1862 if (Spine->Status((Sens == 1)) == ChFiDS_FreeBoundary) {
81bba717 1863 Coeff *= 2; // It is necessary to go to the end and to evaluate the length
7fd59977 1864 }
1865
1866 if (Sens == 1) {
1867 Spine->SetFirstParameter(-dU*Coeff);
1868 Spine->SetFirstTgt(0.);
1869 }
1870 else{
1871 Spine->SetLastParameter(dU*(1.+Coeff));
1872 Spine->SetLastTgt(dU);
1873 }
1874}
1875
1876//=======================================================================
1877//function : ExtentTwoCorner
1878//purpose :
1879//=======================================================================
1880
1881void ChFi3d_FilBuilder::ExtentTwoCorner(const TopoDS_Vertex& V,
1882 const ChFiDS_ListOfStripe& LS)
1883{
81bba717 1884 // Review by using the data at end of fillets (point, radius, normal
1885 // to faces and tangents to the guideline.
7fd59977 1886 Standard_Integer Sens;
1887 Standard_Real Coeff = 0.3, Eval=0.0, dU, rad;
1888 Standard_Integer IE;
1889 ChFiDS_ListIteratorOfListOfStripe itel(LS);
1890 Standard_Boolean FF = Standard_True;
1891 Handle(ChFiDS_Stripe) Stripe;
1892 Handle(ChFiDS_Spine) Spine;
1893
81bba717 1894 // A value of symetric extension is calculated
7fd59977 1895 for ( ; itel.More(); itel.Next()) {
1896 Stripe = itel.Value();
1897 Spine = Stripe->Spine();
1898 dU = Spine->LastParameter(Spine->NbEdges())*Coeff;
1899 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1900 if (fsp->IsConstant())
1901 rad = fsp->Radius();
1902 else
1903 {
1904 TopoDS_Edge E = ChFi3d_EdgeFromV1( V, itel.Value(), Sens);
1905 rad = MaxRad( fsp, E );
1906 /*
1907 IE = ChFi3d_IndexOfSurfData(V,itel.Value(),Sens);
1908 rad = MaxRad(fsp, IE);
1909 */
1910 }
1911 rad *= 1.5;
1912 if (rad > dU) dU = rad;
1913 if (dU > Eval) Eval = dU;
1914 }
1915
81bba717 1916 // One applies
7fd59977 1917 for (itel.Initialize(LS) ; itel.More(); itel.Next()) {
1918 IE = ChFi3d_IndexOfSurfData(V,itel.Value(),Sens);
1919 if (!FF && Stripe == itel.Value()) Sens = -Sens;
1920 Stripe = itel.Value();
1921 Spine = Stripe->Spine();
81bba717 1922 if (! Spine->IsTangencyExtremity((Sens == 1))) { //No extension on queue
7fd59977 1923 if (Sens == 1){
1924 Spine->SetFirstParameter(-Eval);
1925 Spine->SetFirstTgt(0.);
1926 }
1927 else{
1928 dU = Spine->LastParameter(Spine->NbEdges());
1929 Spine->SetLastParameter(dU+Eval);
1930 Spine->SetLastTgt(dU);
1931 }
1932 FF = Standard_False;
1933 }
1934 }
1935}
1936
1937
1938//=======================================================================
1939//function : ExtentThreeCorner
1940//purpose :
1941//=======================================================================
1942
1943void ChFi3d_FilBuilder::ExtentThreeCorner(const TopoDS_Vertex& V,
1944 const ChFiDS_ListOfStripe& LS)
1945{
81bba717 1946 // Review by using the data at end of fillets (point, radius, normal
1947 // to faces and tangents to the guideline.
7fd59977 1948#ifndef DEB
1949 Standard_Integer Sens = 0;
1950#else
1951 Standard_Integer Sens;
1952#endif
1953 Standard_Real Coeff = 0.1;
1954 ChFiDS_ListOfStripe check;
1955// Standard_Boolean FF = Standard_True;
1956 for(ChFiDS_ListIteratorOfListOfStripe itel(LS); itel.More(); itel.Next()) {
1957 Handle(ChFiDS_Stripe) Stripe = itel.Value();
1958 ChFi3d_IndexOfSurfData(V,Stripe,Sens);
1959 for(ChFiDS_ListIteratorOfListOfStripe ich(check); ich.More(); ich.Next()){
1960 if(Stripe == ich.Value()){
1961 Sens = -Sens;
1962 break;
1963 }
1964 }
1965 Handle(ChFiDS_Spine) Spine = Stripe->Spine();
81bba717 1966 if (Spine->IsTangencyExtremity((Sens == 1))) return; //No extension on queue
7fd59977 1967 Standard_Real dU = Spine->LastParameter(Spine->NbEdges());
1968 if (Sens == 1){
1969 Spine->SetFirstParameter(-dU*Coeff);
1970 Spine->SetFirstTgt(0.);
1971 }
1972 else{
1973 Spine->SetLastParameter(dU*(1.+Coeff));
1974 Spine->SetLastTgt(dU);
1975 }
1976 check.Append(Stripe);
1977 }
1978}
1979
1980
1981//=======================================================================
1982//function : SetRegul
1983//purpose :
1984//=======================================================================
1985
1986void ChFi3d_FilBuilder::SetRegul()
1987
1988{
1989 ChFiDS_ListIteratorOfRegularities it;
1990 TopTools_ListIteratorOfListOfShape itc;
1991 TopTools_ListIteratorOfListOfShape its1;
1992 TopTools_ListIteratorOfListOfShape its2;
1993 BRep_Builder B;
1994 for (it.Initialize(myRegul); it.More(); it.Next()){
1995 const ChFiDS_Regul& reg = it.Value();
1996 itc.Initialize(myCoup->NewEdges(reg.Curve()));
1997 if(itc.More()){
1998 TopoDS_Edge E = TopoDS::Edge(itc.Value());
1999 if(reg.IsSurface1()) its1.Initialize(myCoup->NewFaces(reg.S1()));
2000 else its1.Initialize(myCoup->Merged(myDS->Shape(reg.S1()),TopAbs_IN));
2001 if(reg.IsSurface2()) its2.Initialize(myCoup->NewFaces(reg.S2()));
2002 else its2.Initialize(myCoup->Merged(myDS->Shape(reg.S2()),TopAbs_IN));
2003 if(its1.More() && its2.More()){
2004 TopoDS_Face F1 = TopoDS::Face(its1.Value());
2005 TopoDS_Face F2 = TopoDS::Face(its2.Value());
2006 GeomAbs_Shape cont = ChFi3d_evalconti(E,F1,F2);
2007 B.Continuity(E,F1,F2,cont);
2008 }
2009 }
2010 }
2011}