0025369: Visualization, Image_AlienPixMap - handle UTF-8 names in image read/save...
[occt.git] / src / ChFi3d / ChFi3d_FilBuilder.cxx
CommitLineData
b311480e 1// Created on: 1995-04-25
2// Created by: Modelistation
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17// Modified: MPS : (10-04-97) portage WNT pour GetFilletShape
7fd59977 18
19
20#include <ChFi3d_FilBuilder.ixx>
21#include <ChFi3d_Builder_0.hxx>
22#include <ChFi3d_SearchSing.hxx>
23
24#include <Law_Composite.hxx>
25#include <Blend_Point.hxx>
26#include <BRepBlend_Walking.hxx>
27#include <BRepBlend_Line.hxx>
28#include <BRepBlend_ConstRad.hxx>
29#include <BRepBlend_ConstRadInv.hxx>
30#include <BRepBlend_EvolRad.hxx>
31#include <BRepBlend_EvolRadInv.hxx>
32#include <BRepBlend_SurfRstConstRad.hxx>
33#include <BRepBlend_SurfRstEvolRad.hxx>
34#include <BRepBlend_RstRstConstRad.hxx>
35#include <BRepBlend_RstRstEvolRad.hxx>
36#include <BRepBlend_SurfCurvConstRadInv.hxx>
37#include <BRepBlend_SurfCurvEvolRadInv.hxx>
38#include <BRepBlend_SurfPointConstRadInv.hxx>
39#include <BRepBlend_SurfPointEvolRadInv.hxx>
40#include <BRepBlend_CurvPointRadInv.hxx>
41#include <ChFiDS_SecHArray1.hxx>
42#include <ChFiDS_HData.hxx>
43#include <ChFiDS_FilSpine.hxx>
44#include <ChFiDS_Stripe.hxx>
45#include <ChFiDS_ListOfStripe.hxx>
46#include <ChFiDS_ListIteratorOfListOfStripe.hxx>
47#include <ChFiDS_ListIteratorOfRegularities.hxx>
48#include <ChFiDS_Regul.hxx>
49#include <ChFiDS_ErrorStatus.hxx>
50#include <TopTools_ListIteratorOfListOfShape.hxx>
51#include <TopOpeBRepDS_HDataStructure.hxx>
52#include <TopOpeBRepDS_Surface.hxx>
53#include <TopOpeBRepDS_Curve.hxx>
54#include <TopOpeBRepBuild_HBuilder.hxx>
55#include <ElSLib.hxx>
56#include <math_FunctionRoot.hxx>
57#include <TColStd_SequenceOfReal.hxx>
58#include <Precision.hxx>
59
60
61#include <GeomAdaptor_HCurve.hxx>
62#include <Geom_Curve.hxx>
63
64#include <Standard_ConstructionError.hxx>
65#include <Standard_Failure.hxx>
66#ifdef DEB
67extern Standard_Boolean ChFi3d_GettraceCHRON();
68extern Standard_Real t_computedata ,t_completedata;
69
70extern void ChFi3d_InitChron(OSD_Chronometer& ch);
71extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
72#endif
73
74static Standard_Real MaxRad(const Handle(ChFiDS_FilSpine)& fsp,
75
76 const TopoDS_Edge& E)
77{
78 Standard_Integer IE = fsp->Index(E);
79
80 // 1: case of constant R
81 if (fsp->IsConstant(IE))
82 return (fsp->Radius(IE));
83 else // 2,3: case of sequence ParAndRad and(or) Laws
84 return (fsp->MaxRadFromSeqAndLaws());
85
86/*
87 Handle(ChFiDS_HElSpine) HGuide = fsp->ElSpine(IE);
88 Standard_Real la = HGuide->LastParameter(), fi = HGuide->FirstParameter();
89 Standard_Real longueur = la - fi, temp, w;
90//#ifndef DEB
91 Standard_Real radiussect = 0.;
92//#else
93// Standard_Real radiussect;
94//#endif
95 Handle(Law_Composite) lc = fsp->Law(HGuide);
96 for(Standard_Integer i = 0; i <= 5; i++){
97 w = fi + i*longueur*0.2;
98 temp = lc->Value(w);
99 if(temp>radiussect) radiussect = temp;
100 }
101 return radiussect;
102*/
103}
104
105static void SimulParams(const Handle(ChFiDS_HElSpine)& HGuide,
106 const Handle(ChFiDS_FilSpine)& fsp,
107 Standard_Real& MaxStep,
108 Standard_Real& Fleche)
109{
110 Standard_Real la = HGuide->LastParameter(), fi = HGuide->FirstParameter();
111 Standard_Real longueur = la - fi;
112 MaxStep = longueur * 0.05;
113 Standard_Real w;
114 //gp_Pnt Pbid;
115 //gp_Vec d1,d2;
116 Standard_Real radiussect;
117 if(fsp->IsConstant()) radiussect = fsp->Radius();
118 else {
119 radiussect = 0.;
120 Handle(Law_Composite) lc = fsp->Law(HGuide);
121 for(Standard_Integer i = 0; i <= 5; i++){
122 w = fi + i*longueur*0.2;
123 Standard_Real temp = lc->Value(w);
124 if(temp>radiussect) radiussect = temp;
125 }
126 }
127 Fleche = radiussect * 0.05;
128}
129
130//=======================================================================
131//function : ChFi3d_FilBuilder
132//purpose :
133//=======================================================================
134
135ChFi3d_FilBuilder::ChFi3d_FilBuilder(const TopoDS_Shape& S,
136 const ChFi3d_FilletShape FShape,
137 const Standard_Real Ta):
138 ChFi3d_Builder(S, Ta)
139{
140 SetFilletShape(FShape);
141}
142
143//=======================================================================
144//function : SetFilletShape
145//purpose :
146//=======================================================================
147
148void ChFi3d_FilBuilder::SetFilletShape(const ChFi3d_FilletShape FShape)
149{
150 switch (FShape) {
151 case ChFi3d_Rational:
152 myShape = BlendFunc_Rational;
153 break;
154 case ChFi3d_QuasiAngular:
155 myShape = BlendFunc_QuasiAngular;
156 break;
157 case ChFi3d_Polynomial:
158 myShape = BlendFunc_Polynomial;
159 break;
160 }
161}
162
163//=======================================================================
164//function : GetFilletShape
165//purpose :
166//=======================================================================
167
168ChFi3d_FilletShape ChFi3d_FilBuilder::GetFilletShape() const
169{
7fd59977 170 ChFi3d_FilletShape filshape = ChFi3d_Rational; // need to set default value
7fd59977 171 switch (myShape) {
172 case BlendFunc_Rational:
173 filshape= ChFi3d_Rational;
174 break;
175 case BlendFunc_QuasiAngular:
176 filshape= ChFi3d_QuasiAngular;
177 break;
178 case BlendFunc_Polynomial:
179 filshape= ChFi3d_Polynomial;
180 break;
181 default:
182 break;
183 }
184 return filshape;
185}
186
187//=======================================================================
188//function : Add
189//purpose :
190//=======================================================================
191
192void ChFi3d_FilBuilder::Add(const TopoDS_Edge& E)
193{
194 if(!Contains(E) && myEFMap.Contains(E)){
195 Handle(ChFiDS_Stripe) Stripe = new ChFiDS_Stripe();
196 Handle(ChFiDS_Spine)& Sp = Stripe->ChangeSpine();
197 Sp = new ChFiDS_FilSpine(tolesp);
198 Handle(ChFiDS_FilSpine) Spine = Handle(ChFiDS_FilSpine)::DownCast(Sp);
199
200 TopoDS_Edge E_wnt = E;
201 E_wnt.Orientation(TopAbs_FORWARD);
202 Spine->SetEdges(E_wnt);
203 if(PerformElement(Spine)){
204 PerformExtremity(Spine);
205 Spine->Load();
206 myListStripe.Append(Stripe);
207 }
208 }
209}
210
211//=======================================================================
212//function : Add
213//purpose :
214//=======================================================================
215
216void ChFi3d_FilBuilder::Add(const Standard_Real Radius, const TopoDS_Edge& E)
217{
218 Add(E);
219 Standard_Integer IC = Contains(E);
220 if (IC)
221 SetRadius( Radius, IC, E );
222}
223
224//=======================================================================
225//function : SetRadius
226//purpose :
227//=======================================================================
228
229void ChFi3d_FilBuilder::SetRadius(const Handle(Law_Function)& C,
230 const Standard_Integer IC,
231 const Standard_Integer IinC)
232{
233 if(IC <= NbElements()) {
234 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
235 fsp->SetRadius(C, IinC);
236 }
237}
238
239//=======================================================================
240//function : IsConstant
241//purpose :
242//=======================================================================
243
244Standard_Boolean ChFi3d_FilBuilder::IsConstant(const Standard_Integer IC)
245{
246 if(IC <= NbElements()) {
247 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
248 return fsp->IsConstant();
249 }
250 return 0;
251}
252
253//=======================================================================
254//function : Radius
255//purpose :
256//=======================================================================
257
258Standard_Real ChFi3d_FilBuilder::Radius(const Standard_Integer IC)
259{
260 if(IC <= NbElements()) {
261 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
262 return fsp->Radius();
263 }
264 return -1.;
265}
266
267//=======================================================================
268//function : ResetContour
269//purpose :
270//=======================================================================
271
272void ChFi3d_FilBuilder::ResetContour(const Standard_Integer IC)
273{
274 if(IC <= NbElements()) {
275 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
276 fsp->Reset(Standard_True);
277 }
278}
279
280//=======================================================================
281//function : SetRadius
282//purpose :
283//=======================================================================
284
285void ChFi3d_FilBuilder::SetRadius(const Standard_Real Radius,
286 const Standard_Integer IC,
287 const TopoDS_Edge& E)
288{
289 if(IC <= NbElements()) {
290 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
291 fsp->SetRadius(Radius, E);
292 }
293}
294
295//=======================================================================
296//function : UnSet
297//purpose :
298//=======================================================================
299
300void ChFi3d_FilBuilder::UnSet(const Standard_Integer IC,
301 const TopoDS_Edge& E)
302{
303 if(IC <= NbElements()) {
304 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
305 fsp->UnSetRadius(E);
306 }
307}
308
309//=======================================================================
310//function : SetRadius
311//purpose :
312//=======================================================================
313
314void ChFi3d_FilBuilder::SetRadius(const Standard_Real Radius,
315 const Standard_Integer IC,
316 const TopoDS_Vertex& V)
317{
318 if(IC <= NbElements()) {
319 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
320 fsp->SetRadius(Radius, V);
321 }
322}
323
324//=======================================================================
325//function : UnSet
326//purpose :
327//=======================================================================
328
329void ChFi3d_FilBuilder::UnSet(const Standard_Integer IC,
330 const TopoDS_Vertex& V)
331{
332 if(IC <= NbElements()) {
333 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
334 fsp->UnSetRadius(V);
335 }
336}
337
338//=======================================================================
339//function : SetRadius
340//purpose :
341//=======================================================================
342
343void ChFi3d_FilBuilder::SetRadius(const gp_XY& UandR,
344 const Standard_Integer IC,
345 const Standard_Integer IinC)
346{
347 if(IC <= NbElements()) {
348 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
349 fsp->SetRadius( UandR, IinC );
350 }
351}
352
353//=======================================================================
354//function : IsConstant
355//purpose :
356//=======================================================================
357
358Standard_Boolean ChFi3d_FilBuilder::IsConstant(const Standard_Integer IC,
359 const TopoDS_Edge& E)
360{
361 if(IC <= NbElements()) {
362 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
363 return fsp->IsConstant(fsp->Index(E));
364 }
365 return 0;
366}
367
368//=======================================================================
369//function : Radius
370//purpose :
371//=======================================================================
372
373Standard_Real ChFi3d_FilBuilder::Radius(const Standard_Integer IC,
374 const TopoDS_Edge& E)
375{
376 if(IC <= NbElements()) {
377 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
378 return fsp->Radius(E);
379 }
380 return -1.;
381}
382
383//=======================================================================
384//function : GetBounds
385//purpose :
386//=======================================================================
387
388Standard_Boolean ChFi3d_FilBuilder::GetBounds(const Standard_Integer IC,
389 const TopoDS_Edge& E,
390 Standard_Real& F,
391 Standard_Real& L)
392{
393 if(IC <= NbElements()) {
394 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
395 Handle(Law_Function)& loi = fsp->ChangeLaw(E);
396 if(!loi.IsNull()){
397 loi->Bounds(F,L);
398 return Standard_True;
399 }
400 }
401 return Standard_False;
402}
403
404//=======================================================================
405//function : GetLaw
406//purpose :
407//=======================================================================
408
409Handle(Law_Function) ChFi3d_FilBuilder::GetLaw(const Standard_Integer IC,
410 const TopoDS_Edge& E)
411{
412 if(IC <= NbElements()) {
413 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
414 return fsp->ChangeLaw(E);
415 }
416 return Handle(Law_Function)();
417}
418
419//=======================================================================
420//function : SetLaw
421//purpose :
422//=======================================================================
423
424void ChFi3d_FilBuilder::SetLaw(const Standard_Integer IC,
425 const TopoDS_Edge& E,
426 const Handle(Law_Function)& L)
427{
81bba717 428 // Check if it is necessary to check borders!
7fd59977 429 if(IC <= NbElements()) {
430 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Value(IC));
431 fsp->ChangeLaw(E) = L;
432 }
433}
434
435//=======================================================================
436//function : Simulate
437//purpose :
438//=======================================================================
439
440void ChFi3d_FilBuilder::Simulate (const Standard_Integer IC)
441{
442#ifdef DEB
443 if(ChFi3d_GettraceCHRON()){
444 simul.Reset();elspine.Reset();chemine.Reset();
445 simul.Start();
446 }
447#endif
448 ChFiDS_ListIteratorOfListOfStripe itel;
449 Standard_Integer i = 1;
450 for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
451 if(i == IC){
452 PerformSetOfSurf(itel.Value(), Standard_True);
453 break;
454 }
455 }
456#ifdef DEB
457 if(ChFi3d_GettraceCHRON()){
458 simul.Stop();
81bba717 459 cout<<"Total simulation time : ";
7fd59977 460 simul.Show();
81bba717 461 cout<<"Spine construction time : ";
7fd59977 462 elspine.Show();
81bba717 463 cout<<"and process time : ";
7fd59977 464 chemine.Show();
465 }
466#endif
467}
468
469//=======================================================================
470//function : NbSurf
471//purpose :
472//=======================================================================
473
474Standard_Integer ChFi3d_FilBuilder::NbSurf (const Standard_Integer IC) const
475{
476 ChFiDS_ListIteratorOfListOfStripe itel;
477 Standard_Integer i = 1;
478 for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
479 if(i == IC){
480 return itel.Value()->SetOfSurfData()->Length();
481 }
482 }
483 return 0;
484}
485
486//=======================================================================
487//function : Sect
488//purpose :
489//=======================================================================
490
491Handle(ChFiDS_SecHArray1) ChFi3d_FilBuilder::Sect (const Standard_Integer IC,
492 const Standard_Integer IS) const
493{
494 ChFiDS_ListIteratorOfListOfStripe itel;
495 Standard_Integer i = 1;
496 Handle(ChFiDS_SecHArray1) res;
497 for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
498 if(i == IC){
499 Handle(MMgt_TShared) bid = itel.Value()->SetOfSurfData()->Value(IS)->Simul();
500 res = Handle(ChFiDS_SecHArray1)::DownCast(bid);
501 return res;
502 }
503 }
504 return Handle(ChFiDS_SecHArray1)();
505}
506
507//=======================================================================
508//function : SimulKPart
509//purpose :
510//=======================================================================
511
512void ChFi3d_FilBuilder::SimulKPart(const Handle(ChFiDS_SurfData)& SD) const
513{
514 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
515 Handle(Geom_Surface) S = DStr.Surface(SD->Surf()).Surface();
516 gp_Pnt2d p1f = SD->InterferenceOnS1().PCurveOnSurf()->
517 Value(SD->InterferenceOnS1().FirstParameter());
518 gp_Pnt2d p1l = SD->InterferenceOnS1().PCurveOnSurf()->
519 Value(SD->InterferenceOnS1().LastParameter());
520 gp_Pnt2d p2f = SD->InterferenceOnS2().PCurveOnSurf()->
521 Value(SD->InterferenceOnS2().FirstParameter());
522 gp_Pnt2d p2l = SD->InterferenceOnS2().PCurveOnSurf()->
523 Value(SD->InterferenceOnS2().LastParameter());
524 GeomAdaptor_Surface AS(S);
525 Handle(ChFiDS_SecHArray1) sec;
526 Standard_Real u1,v1,u2,v2;
527 GeomAbs_SurfaceType typ = AS.GetType();
528 switch (typ){
529 case GeomAbs_Cylinder:
530 {
531 u1 = p1f.X();
532 u2 = p2f.X();
533 v1 = Max(p1f.Y(),p2f.Y());
534 v2 = Min(p1l.Y(),p2l.Y());
535 sec = new ChFiDS_SecHArray1(1,2);
536 gp_Cylinder Cy = AS.Cylinder();
537 ChFiDS_CircSection& sec1 = sec->ChangeValue(1);
538 ChFiDS_CircSection& sec2 = sec->ChangeValue(2);
539 sec1.Set(ElSLib::CylinderVIso(Cy.Position(), Cy.Radius(), v1), u1, u2);
540 sec2.Set(ElSLib::CylinderVIso(Cy.Position(), Cy.Radius(), v2), u1, u2);
541 }
542 break;
543 case GeomAbs_Torus:
544 {
545 v1 = p1f.Y();
546 v2 = p2f.Y();
547 u1 = Max(p1f.X(),p2f.X());
548 u2 = Min(p1l.X(),p2l.X());
549 Standard_Real ang = (u2-u1);
550 gp_Torus To = AS.Torus();
551 Standard_Real majr = To.MajorRadius(), minr = To.MinorRadius();
c6541a0c 552 Standard_Integer n = (Standard_Integer) (36.*ang/M_PI + 1);
7fd59977 553 if(n<2) n = 2;
554 sec = new ChFiDS_SecHArray1(1, n);
555 for (Standard_Integer i = 1; i <= n; i++) {
556 ChFiDS_CircSection& isec = sec->ChangeValue(i);
557 Standard_Real u = u1 + (i - 1)*(u2 - u1)/(n-1);
558 isec.Set(ElSLib::TorusUIso(To.Position(), majr, minr, u), v1, v2);
559 }
560 }
561 break;
562 case GeomAbs_Sphere:
563 {
564 v1 = p1f.Y();
565 v2 = p2f.Y();
566 u1 = Max(p1f.X(),p2f.X());
567 u2 = Min(p1l.X(),p2l.X());
568 Standard_Real ang = (u2-u1);
569 gp_Sphere Sp = AS.Sphere();
570 Standard_Real rad = Sp.Radius();
c6541a0c 571 Standard_Integer n = (Standard_Integer) (36.*ang/M_PI + 1);
7fd59977 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 {
7fd59977 1403 BRepBlend_SurfRstEvolRad func(HS2,HS1,PC1,HGuide,fsp->Law(HGuide));
1404 func.Set(HSref1,PCref1);
1405 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
1406 HC->ChangeCurve().Load(HS1);
1407 HC->ChangeCurve().Load(PC1);
1408 BRepBlend_SurfCurvEvolRadInv finvc(HS2,HC,HGuide,fsp->Law(HGuide));
1409 BRepBlend_SurfPointEvolRadInv finvp(HS2,HGuide,fsp->Law(HGuide));
1410 BRepBlend_EvolRadInv finv(HS2,HSref1,HGuide,fsp->Law(HGuide));
1411 finv.Set(Standard_False,PCref1);
1412 Standard_Integer petitchoix = 1;
1413 if(Or2 == TopAbs_REVERSED) petitchoix = 3;
1414 if(Choix%2 == 0) petitchoix++;
1415 finv.Set(Choix);
1416 finvc.Set(petitchoix);
1417 finvp.Set(petitchoix);
1418 func.Set(petitchoix);
1419 func.Set(myShape);
7fd59977 1420 done = ComputeData(Data,HGuide,lin,HS2,I2,HS1,PC1,I1,Decroch1,
1421 func,finv,finvp,finvc,
1422 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1423 Soldep,Inside,Appro,Forward,RecP,RecS,RecRst);
1424 if(!done) {
1425 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1426 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1427 }
1428 TopAbs_Orientation Or = HS2->ChangeSurface().Face().Orientation();
1429 done = CompleteData(Data,func,lin,HS1,HS2,Or,1);
81bba717 1430 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1431 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1432 }
1433 if (maybesingular) SplitSurf(SeqData, lin);
1434}
1435
1436//=======================================================================
1437//function : PerformSurf
1438//purpose :
1439//=======================================================================
1440
1441void ChFi3d_FilBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData,
1442 const Handle(ChFiDS_HElSpine)& HGuide,
1443 const Handle(ChFiDS_Spine)& Spine,
1444 const Standard_Integer Choix,
1445 const Handle(BRepAdaptor_HSurface)& HS1,
1446 const Handle(Adaptor3d_TopolTool)& I1,
1447 const TopAbs_Orientation Or1,
1448 const Handle(BRepAdaptor_HSurface)& HS2,
1449 const Handle(Adaptor3d_TopolTool)& I2,
1450 const Handle(BRepAdaptor_HCurve2d)& PC2,
1451 const Handle(BRepAdaptor_HSurface)& HSref2,
1452 const Handle(BRepAdaptor_HCurve2d)& PCref2,
1453 Standard_Boolean& Decroch2,
1454 const Standard_Real MaxStep,
1455 const Standard_Real Fleche,
1456 const Standard_Real TolGuide,
1457 Standard_Real& First,
1458 Standard_Real& Last,
1459 const Standard_Boolean Inside,
1460 const Standard_Boolean Appro,
1461 const Standard_Boolean Forward,
1462 const Standard_Boolean RecP,
1463 const Standard_Boolean RecS,
1464 const Standard_Boolean RecRst,
1465 const math_Vector& Soldep)
1466{
1467 Handle(ChFiDS_SurfData) Data = SeqData(1);;
1468 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1469 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 1470 ("PerformSurf : this is not the spine of a fillet");
7fd59977 1471 Handle(BRepBlend_Line) lin;
1472 Standard_Real PFirst = First;
1473 Standard_Boolean maybesingular;
1474
1475 if(fsp->IsConstant()){
1476 BRepBlend_SurfRstConstRad func(HS1,HS2,PC2,HGuide);
1477 func.Set(HSref2,PCref2);
1478 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
1479 HC->ChangeCurve().Load(HS2);
1480 HC->ChangeCurve().Load(PC2);
1481 BRepBlend_SurfCurvConstRadInv finvc(HS1,HC,HGuide);
1482 BRepBlend_SurfPointConstRadInv finvp(HS1,HGuide);
1483 BRepBlend_ConstRadInv finv(HS1,HSref2,HGuide);
1484 finv.Set(Standard_False,PCref2);
1485
1486 Standard_Real rad = fsp->Radius();
1487 Standard_Integer petitchoix = 1;
1488 if(Or1 == TopAbs_REVERSED) petitchoix = 3;
1489 if(Choix%2 == 0) petitchoix++;
1490 finv.Set(rad,Choix);
1491 finvc.Set(rad,petitchoix);
1492 finvp.Set(rad,petitchoix);
1493 func.Set(rad,petitchoix);
1494 func.Set(myShape);
1495
1496 done = ComputeData(Data,HGuide,lin,HS1,I1,HS2,PC2,I2,Decroch2,
1497 func,finv,finvp,finvc,
1498 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1499 Soldep,Inside,Appro,Forward,RecP,RecS,RecRst);
1500 if(!done) {
1501 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1502 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1503 }
1504 TopAbs_Orientation Or = HS1->ChangeSurface().Face().Orientation();
1505 done = CompleteData(Data,func,lin,HS1,HS2,Or,0);
81bba717 1506 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1507 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1508 }
1509 else {
1510 BRepBlend_SurfRstEvolRad func(HS1,HS2,PC2,HGuide,fsp->Law(HGuide));
1511 func.Set(HSref2,PCref2);
1512 Handle(Adaptor3d_HCurveOnSurface) HC = new Adaptor3d_HCurveOnSurface();
1513 HC->ChangeCurve().Load(HS2);
1514 HC->ChangeCurve().Load(PC2);
1515 BRepBlend_SurfCurvEvolRadInv finvc(HS1,HC,HGuide,fsp->Law(HGuide));
1516 BRepBlend_SurfPointEvolRadInv finvp(HS1,HGuide,fsp->Law(HGuide));
1517 BRepBlend_EvolRadInv finv(HS1,HSref2,HGuide,fsp->Law(HGuide));
1518 finv.Set(Standard_False,PCref2);
1519 Standard_Integer petitchoix = 1;
1520 if(Or1 == TopAbs_REVERSED) petitchoix = 3;
1521 if(Choix%2 == 0) petitchoix++;
1522 finv.Set(Choix);
1523 finvc.Set(petitchoix);
1524 finvp.Set(petitchoix);
1525 func.Set(petitchoix);
1526 func.Set(myShape);
1527
1528 done = ComputeData(Data,HGuide,lin,HS1,I1,HS2,PC2,I2,Decroch2,
1529 func,finv,finvp,finvc,
1530 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1531 Soldep,Inside,Appro,Forward,RecP,RecS,RecRst);
1532 if(!done) {
1533 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1534 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1535 }
1536 TopAbs_Orientation Or = HS1->ChangeSurface().Face().Orientation();
1537 done = CompleteData(Data,func,lin,HS1,HS2,Or,0);
81bba717 1538 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1539 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1540 }
1541 if (maybesingular) SplitSurf(SeqData, lin);
1542}
1543
1544
1545
1546
1547
1548
1549//=======================================================================
1550//function : PerformSurf
1551//purpose :
1552//=======================================================================
1553
1554void ChFi3d_FilBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData,
1555 const Handle(ChFiDS_HElSpine)& HGuide,
1556 const Handle(ChFiDS_Spine)& Spine,
1557 const Standard_Integer Choix,
1558 const Handle(BRepAdaptor_HSurface)& HS1,
1559 const Handle(Adaptor3d_TopolTool)& I1,
1560 const Handle(BRepAdaptor_HCurve2d)& PC1,
1561 const Handle(BRepAdaptor_HSurface)& HSref1,
1562 const Handle(BRepAdaptor_HCurve2d)& PCref1,
1563 Standard_Boolean& Decroch1,
1564 const TopAbs_Orientation Or1,
1565 const Handle(BRepAdaptor_HSurface)& HS2,
1566 const Handle(Adaptor3d_TopolTool)& I2,
1567 const Handle(BRepAdaptor_HCurve2d)& PC2,
1568 const Handle(BRepAdaptor_HSurface)& HSref2,
1569 const Handle(BRepAdaptor_HCurve2d)& PCref2,
1570 Standard_Boolean& Decroch2,
1571 const TopAbs_Orientation Or2,
1572 const Standard_Real MaxStep,
1573 const Standard_Real Fleche,
1574 const Standard_Real TolGuide,
1575 Standard_Real& First,
1576 Standard_Real& Last,
1577 const Standard_Boolean Inside,
1578 const Standard_Boolean Appro,
1579 const Standard_Boolean Forward,
1580 const Standard_Boolean RecP1,
1581 const Standard_Boolean RecRst1,
1582 const Standard_Boolean RecP2,
1583 const Standard_Boolean RecRst2,
1584 const math_Vector& Soldep)
1585{
1586 Handle(ChFiDS_SurfData) Data = SeqData(1);;
1587 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1588 if(fsp.IsNull()) Standard_ConstructionError::Raise
81bba717 1589 ("PerformSurf : this is not the spine of a fillet");
7fd59977 1590 Handle(BRepBlend_Line) lin;
1591 Standard_Real PFirst = First;
1592 Standard_Boolean maybesingular;
1593
1594 if(fsp->IsConstant()){
1595 BRepBlend_RstRstConstRad func(HS1, PC1, HS2, PC2, HGuide);
1596 func.Set(HSref1, PCref1, HSref2, PCref2);
1597 Handle(Adaptor3d_HCurveOnSurface) HC1 = new Adaptor3d_HCurveOnSurface();
1598 HC1->ChangeCurve().Load(HS1);
1599 HC1->ChangeCurve().Load(PC1);
1600 Handle(Adaptor3d_HCurveOnSurface) HC2 = new Adaptor3d_HCurveOnSurface();
1601 HC2->ChangeCurve().Load(HS2);
1602 HC2->ChangeCurve().Load(PC2);
1603 BRepBlend_SurfCurvConstRadInv finv1(HSref1, HC2, HGuide);
1604 BRepBlend_CurvPointRadInv finvp1(HGuide, HC2);
1605 BRepBlend_SurfCurvConstRadInv finv2(HSref2, HC1, HGuide);
1606 BRepBlend_CurvPointRadInv finvp2(HGuide, HC1);
1607
1608 finv1.Set(PCref1);
1609 finv2.Set(PCref2);
1610
1611 Standard_Integer ch1 = 1, ch2 = 2;
1612 Standard_Real rad = fsp->Radius();
1613 if(Or1 == TopAbs_REVERSED) ch1 = 3;
1614 if(Or2 == TopAbs_REVERSED) ch2 = 3;
1615
1616 finv1.Set(rad, ch1);
1617 finvp1.Set(Choix);
1618 finv2.Set(rad, ch2);
1619 finvp2.Set(Choix);
1620 func.Set(rad, Choix);
1621 func.Set(myShape);
1622
1623 done = ComputeData(Data, HGuide, lin, HS1, PC1, I1, Decroch1, HS2, PC2, I2, Decroch2,
1624 func, finv1, finvp1, finv2, finvp2,
1625 PFirst, MaxStep, Fleche, TolGuide, First, Last,
1626 Soldep, Inside, Appro, Forward, RecP1, RecRst1, RecP2, RecRst2);
1627 if(!done) {
1628 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1629 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1630 }
1631 TopAbs_Orientation Or = HS1->ChangeSurface().Face().Orientation();
1632 done = CompleteData(Data, func, lin, HS1, HS2, Or);
81bba717 1633 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1634 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1635 }
1636 else {
1637 BRepBlend_RstRstEvolRad func(HS1,PC1, HS2, PC2, HGuide, fsp->Law(HGuide));
1638 func.Set(HSref1, PCref1, HSref2, PCref2);
1639 Handle(Adaptor3d_HCurveOnSurface) HC1 = new Adaptor3d_HCurveOnSurface();
1640 HC1->ChangeCurve().Load(HS1);
1641 HC1->ChangeCurve().Load(PC1);
1642 Handle(Adaptor3d_HCurveOnSurface) HC2 = new Adaptor3d_HCurveOnSurface();
1643 HC2->ChangeCurve().Load(HS2);
1644 HC2->ChangeCurve().Load(PC2);
1645
1646 BRepBlend_SurfCurvEvolRadInv finv1(HSref1, HC2, HGuide, fsp->Law(HGuide));
1647 BRepBlend_CurvPointRadInv finvp1(HGuide, HC2);
1648 BRepBlend_SurfCurvEvolRadInv finv2(HSref2, HC1, HGuide, fsp->Law(HGuide));
1649 BRepBlend_CurvPointRadInv finvp2(HGuide, HC1);
1650
1651 finv1.Set(PCref1);
1652 finv2.Set(PCref2);
1653
1654 Standard_Integer ch1 = 1, ch2 = 2;
1655
1656 if(Or1 == TopAbs_REVERSED) ch1 = 3;
1657 if(Or2 == TopAbs_REVERSED) ch2 = 3;
1658
1659
1660 finv1.Set(ch1);
1661 finvp1.Set(Choix);
1662 finv2.Set(ch2);
1663 finvp2.Set(Choix);
1664 func.Set(Choix);
1665 func.Set(myShape);
1666
1667 done = ComputeData(Data, HGuide, lin, HS1, PC1, I1, Decroch1, HS2, PC2,I2, Decroch2,
1668 func, finv1, finvp1, finv2, finvp2,
1669 PFirst, MaxStep, Fleche, TolGuide, First, Last,
1670 Soldep, Inside, Appro, Forward, RecP1, RecRst1, RecP2, RecRst2);
1671
1672 if(!done) {
1673 Spine->SetErrorStatus(ChFiDS_WalkingFailure);
81bba717 1674 Standard_Failure::Raise("PerformSurf : Failed processing!");
7fd59977 1675 }
1676 TopAbs_Orientation Or = HS1->ChangeSurface().Face().Orientation();
1677 done = CompleteData(Data, func, lin, HS1, HS2, Or);
81bba717 1678 if(!done) Standard_Failure::Raise("PerformSurf : Failed approximation!");
7fd59977 1679 maybesingular = (func.GetMinimalDistance()<=100*tolapp3d);
1680
1681
1682 }
1683 if (maybesingular) SplitSurf(SeqData, lin);
1684}
1685
1686
1687
1688
1689//=======================================================================
1690//function : SplitSurf
1691//purpose :
1692//=======================================================================
1693
1694void ChFi3d_FilBuilder::SplitSurf(ChFiDS_SequenceOfSurfData& SeqData,
1695 const Handle(BRepBlend_Line)& Line)
1696{
1697 Standard_Integer ii, Nbpnt=Line->NbPoints();
1698 if (Nbpnt <3) return;
1699 Standard_Real UFirst,ULast,VFirst,VLast;
1700 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
1701 Standard_Integer ISurf;
1702 Handle(ChFiDS_SurfData) ref = SeqData(1);
1703 Blend_Point P;
1704
1705 ISurf= ref->Surf();
1706 Handle(Geom_Surface) Surf = DStr.Surface(ISurf).Surface();
1707 Surf->Bounds(UFirst,ULast,VFirst,VLast);
1708 Handle(Geom_Curve) Courbe1 = Surf->UIso(UFirst);
1709 Handle(Geom_Curve) Courbe2 = Surf->UIso(ULast);
1710 ChFi3d_SearchSing Fonc(Courbe1, Courbe2);
1711
1712 TColStd_SequenceOfReal LesVi;
1713 Standard_Real precedant, suivant, courant;
1714 Standard_Real a, b, c;
1715
81bba717 1716 // (1) Finds vi so that iso v=vi is punctual
7fd59977 1717 VFirst = Min( ref->InterferenceOnS1().FirstParameter(),
1718 ref->InterferenceOnS2().FirstParameter() );
1719 VLast = Max( ref->InterferenceOnS1().LastParameter(),
1720 ref->InterferenceOnS2().LastParameter() );
1721
81bba717 1722 // (1.1) Finds the first point inside
7fd59977 1723 for (ii=1; ii<=Nbpnt && Line->Point(ii).Parameter()<VFirst; ii++) {}
1724 if (ii==1) ii++;
1725 P = Line->Point(ii);
1726 b = P.Parameter();
1727 courant = P.PointOnS1().Distance(P.PointOnS2());
1728 P = Line->Point(ii-1);
1729 a = P.Parameter();
1730 precedant = P.PointOnS1().Distance(P.PointOnS2());
1731 ii ++;
1732
81bba717 1733 // (1.2) Find a minimum by "points"
7fd59977 1734 for ( ; ii<=Nbpnt && Line->Point(ii).Parameter()<=VLast; ii++) {
1735 for (;ii<=Nbpnt &&
1736 Line->Point(ii).Parameter()<VLast &&
1737 Line->Point(ii).Parameter()-b<Precision::PConfusion(); ii++) {}
1738
1739 const Blend_Point& pnt = Line->Point(ii);
1740 c = pnt.Parameter();
1741 suivant = pnt.PointOnS1().Distance(pnt.PointOnS2());
1742 if ( (courant < precedant) && (courant < suivant) ) {
81bba717 1743 // (1.3) Find the exact minimum
7fd59977 1744 math_FunctionRoot Resol(Fonc, (a+c)/2,
1745 tol2d,//Surf->VResolution(toleps),
1746 a, c,
1747 50);
1748 if (Resol.IsDone()) {
1749 Standard_Real Val, racine=Resol.Root();
1750
1751 Fonc.Value(Resol.Root(), Val);
1752 if (Val< tolapp3d) {
81bba717 1753 // the solution (avoiding the risks of confusion)
7fd59977 1754 if (LesVi.Length()==0) {
1755 if ( (racine > VFirst+tol2d) &&
1756 (racine < VLast -tol2d) ) {
1757 LesVi.Append(racine);
1758 }
1759 }
1760 else {
1761 if ( (racine > LesVi(LesVi.Length()) + tol2d) &&
1762 (racine < VLast-tol2d) ) {
1763 LesVi.Append(racine);
1764 }
1765 }
1766 }
1767 }
1768 else {
1769# if DEB
81bba717 1770 cout << "Failed calculation of the minimum length" << endl;
7fd59977 1771# endif
1772 }
1773 }
81bba717 1774 // update if non duplication
7fd59977 1775 a = b;
1776 precedant = courant;
1777 b = c;
1778 courant = suivant;
1779 }
1780
81bba717 1781 // (2) Update of the sequence of SurfData
7fd59977 1782 if (LesVi.Length()>0) {
1783 TopOpeBRepDS_DataStructure& DStru = myDS->ChangeDS();
1784 Handle(ChFiDS_SurfData) SD;
1785 TopOpeBRepDS_Surface S;
1786 TopOpeBRepDS_Curve C1, C2;
1787 Standard_Real T, VertexTol;
1788 gp_Pnt P3d, P1, P2;
1789 ChFiDS_CommonPoint LePoint;
1790 for (ii=1 ; ii<=LesVi.Length(); ii++) {
1791
1792 T = LesVi(ii);
81bba717 1793 // (2.0) copy and insertion
7fd59977 1794 SD = new (ChFiDS_SurfData);
1795 SD->Copy(ref);
1796 SeqData.InsertBefore(ii, SD);
1797 S = DStru.Surface(ref->Surf());
1798 SD->ChangeSurf(DStru.AddSurface(S));
1799 C1 = DStru.Curve(SD->InterferenceOnS1().LineIndex());
1800 SD->ChangeInterferenceOnS1().SetLineIndex( DStru.AddCurve(C1));
1801 C2 = DStru.Curve(SD->InterferenceOnS2().LineIndex());
1802 SD->ChangeInterferenceOnS2().SetLineIndex(DStru.AddCurve(C2));
1803
81bba717 1804 // (2.1) Modification of common Point
7fd59977 1805 SD-> ChangeVertexLastOnS1().Reset();
1806 SD-> ChangeVertexLastOnS2().Reset();
1807 ref->ChangeVertexFirstOnS1().Reset();
1808 ref->ChangeVertexFirstOnS2().Reset();
1809 Courbe1->D0(T, P1);
1810 Courbe2->D0(T, P2);
1811 P3d.SetXYZ((P1.XYZ()+ P2.XYZ())/2);
1812 VertexTol = P1.Distance(P2);
1813 VertexTol += Max(C1.Tolerance(), C2.Tolerance());
1814
1815 SD->ChangeVertexLastOnS1().SetPoint(P3d);
1816 SD->ChangeVertexLastOnS2().SetPoint(P3d);
1817 ref->ChangeVertexFirstOnS1().SetPoint(P3d);
1818 ref->ChangeVertexFirstOnS2().SetPoint(P3d);
1819 SD->ChangeVertexLastOnS1().SetTolerance(VertexTol);
1820 SD->ChangeVertexLastOnS2().SetTolerance(VertexTol);
1821 ref->ChangeVertexFirstOnS1().SetTolerance(VertexTol);
1822 ref->ChangeVertexFirstOnS2().SetTolerance(VertexTol);
1823
81bba717 1824 // (2.2) Modification of interferences
7fd59977 1825 SD->ChangeInterferenceOnS1().SetLastParameter(T);
1826 SD->ChangeInterferenceOnS2().SetLastParameter(T);
1827 ref->ChangeInterferenceOnS1().SetFirstParameter(T);
1828 ref->ChangeInterferenceOnS2().SetFirstParameter(T);
1829
81bba717 1830 // Parameters on ElSpine
7fd59977 1831 SD->LastSpineParam(T);
1832 ref->FirstSpineParam(T);
1833 }
1834 }
1835}
1836
1837//=======================================================================
1838//function : ExtentOneCorner
1839//purpose :
1840//=======================================================================
1841
1842void ChFi3d_FilBuilder::ExtentOneCorner(const TopoDS_Vertex& V,
1843 const Handle(ChFiDS_Stripe)& S)
1844{
81bba717 1845 // review by using the data at end of fillets (point, radius, normal
1846 // to the faces and tangents of the guideline).
7fd59977 1847 Standard_Integer Sens = 0;
7fd59977 1848 Standard_Real Coeff = 0.5;
1849 Handle(ChFiDS_Spine) Spine = S->Spine();
1850 ChFi3d_IndexOfSurfData(V,S,Sens);
1851 Standard_Real dU = Spine->LastParameter(Spine->NbEdges());
1852 if (Spine->IsTangencyExtremity((Sens == 1)))
81bba717 1853 return; //No extension in the queue
7fd59977 1854
1855 if (Spine->Status((Sens == 1)) == ChFiDS_FreeBoundary) {
81bba717 1856 Coeff *= 2; // It is necessary to go to the end and to evaluate the length
7fd59977 1857 }
1858
1859 if (Sens == 1) {
1860 Spine->SetFirstParameter(-dU*Coeff);
1861 Spine->SetFirstTgt(0.);
1862 }
1863 else{
1864 Spine->SetLastParameter(dU*(1.+Coeff));
1865 Spine->SetLastTgt(dU);
1866 }
1867}
1868
1869//=======================================================================
1870//function : ExtentTwoCorner
1871//purpose :
1872//=======================================================================
1873
1874void ChFi3d_FilBuilder::ExtentTwoCorner(const TopoDS_Vertex& V,
1875 const ChFiDS_ListOfStripe& LS)
1876{
81bba717 1877 // Review by using the data at end of fillets (point, radius, normal
1878 // to faces and tangents to the guideline.
7fd59977 1879 Standard_Integer Sens;
1880 Standard_Real Coeff = 0.3, Eval=0.0, dU, rad;
7fd59977 1881 ChFiDS_ListIteratorOfListOfStripe itel(LS);
1882 Standard_Boolean FF = Standard_True;
1883 Handle(ChFiDS_Stripe) Stripe;
1884 Handle(ChFiDS_Spine) Spine;
1885
81bba717 1886 // A value of symetric extension is calculated
7fd59977 1887 for ( ; itel.More(); itel.Next()) {
1888 Stripe = itel.Value();
1889 Spine = Stripe->Spine();
1890 dU = Spine->LastParameter(Spine->NbEdges())*Coeff;
1891 Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine);
1892 if (fsp->IsConstant())
1893 rad = fsp->Radius();
1894 else
1895 {
1896 TopoDS_Edge E = ChFi3d_EdgeFromV1( V, itel.Value(), Sens);
1897 rad = MaxRad( fsp, E );
1898 /*
1899 IE = ChFi3d_IndexOfSurfData(V,itel.Value(),Sens);
1900 rad = MaxRad(fsp, IE);
1901 */
1902 }
1903 rad *= 1.5;
1904 if (rad > dU) dU = rad;
1905 if (dU > Eval) Eval = dU;
1906 }
1907
81bba717 1908 // One applies
7fd59977 1909 for (itel.Initialize(LS) ; itel.More(); itel.Next()) {
96a95605 1910 ChFi3d_IndexOfSurfData(V,itel.Value(),Sens);
7fd59977 1911 if (!FF && Stripe == itel.Value()) Sens = -Sens;
1912 Stripe = itel.Value();
1913 Spine = Stripe->Spine();
81bba717 1914 if (! Spine->IsTangencyExtremity((Sens == 1))) { //No extension on queue
7fd59977 1915 if (Sens == 1){
1916 Spine->SetFirstParameter(-Eval);
1917 Spine->SetFirstTgt(0.);
1918 }
1919 else{
1920 dU = Spine->LastParameter(Spine->NbEdges());
1921 Spine->SetLastParameter(dU+Eval);
1922 Spine->SetLastTgt(dU);
1923 }
1924 FF = Standard_False;
1925 }
1926 }
1927}
1928
1929
1930//=======================================================================
1931//function : ExtentThreeCorner
1932//purpose :
1933//=======================================================================
1934
1935void ChFi3d_FilBuilder::ExtentThreeCorner(const TopoDS_Vertex& V,
1936 const ChFiDS_ListOfStripe& LS)
1937{
81bba717 1938 // Review by using the data at end of fillets (point, radius, normal
1939 // to faces and tangents to the guideline.
7fd59977 1940 Standard_Integer Sens = 0;
7fd59977 1941 Standard_Real Coeff = 0.1;
1942 ChFiDS_ListOfStripe check;
1943// Standard_Boolean FF = Standard_True;
1944 for(ChFiDS_ListIteratorOfListOfStripe itel(LS); itel.More(); itel.Next()) {
1945 Handle(ChFiDS_Stripe) Stripe = itel.Value();
1946 ChFi3d_IndexOfSurfData(V,Stripe,Sens);
1947 for(ChFiDS_ListIteratorOfListOfStripe ich(check); ich.More(); ich.Next()){
1948 if(Stripe == ich.Value()){
1949 Sens = -Sens;
1950 break;
1951 }
1952 }
1953 Handle(ChFiDS_Spine) Spine = Stripe->Spine();
81bba717 1954 if (Spine->IsTangencyExtremity((Sens == 1))) return; //No extension on queue
7fd59977 1955 Standard_Real dU = Spine->LastParameter(Spine->NbEdges());
1956 if (Sens == 1){
1957 Spine->SetFirstParameter(-dU*Coeff);
1958 Spine->SetFirstTgt(0.);
1959 }
1960 else{
1961 Spine->SetLastParameter(dU*(1.+Coeff));
1962 Spine->SetLastTgt(dU);
1963 }
1964 check.Append(Stripe);
1965 }
1966}
1967
1968
1969//=======================================================================
1970//function : SetRegul
1971//purpose :
1972//=======================================================================
1973
1974void ChFi3d_FilBuilder::SetRegul()
1975
1976{
1977 ChFiDS_ListIteratorOfRegularities it;
1978 TopTools_ListIteratorOfListOfShape itc;
1979 TopTools_ListIteratorOfListOfShape its1;
1980 TopTools_ListIteratorOfListOfShape its2;
1981 BRep_Builder B;
1982 for (it.Initialize(myRegul); it.More(); it.Next()){
1983 const ChFiDS_Regul& reg = it.Value();
1984 itc.Initialize(myCoup->NewEdges(reg.Curve()));
1985 if(itc.More()){
1986 TopoDS_Edge E = TopoDS::Edge(itc.Value());
1987 if(reg.IsSurface1()) its1.Initialize(myCoup->NewFaces(reg.S1()));
1988 else its1.Initialize(myCoup->Merged(myDS->Shape(reg.S1()),TopAbs_IN));
1989 if(reg.IsSurface2()) its2.Initialize(myCoup->NewFaces(reg.S2()));
1990 else its2.Initialize(myCoup->Merged(myDS->Shape(reg.S2()),TopAbs_IN));
1991 if(its1.More() && its2.More()){
1992 TopoDS_Face F1 = TopoDS::Face(its1.Value());
1993 TopoDS_Face F2 = TopoDS::Face(its2.Value());
1994 GeomAbs_Shape cont = ChFi3d_evalconti(E,F1,F2);
1995 B.Continuity(E,F1,F2,cont);
1996 }
1997 }
1998 }
1999}