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