summaryrefslogtreecommitdiff
path: root/src/GeomFill/GeomFill_SweepSectionGenerator.cxx
blob: 8f7c00775c472d3c5699c43a6e5afc1854435780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
// File:	GeomFill_SweepSectionGenerator.cxx
// Created:	Mon Feb 28 14:14:53 1994
// Author:	Bruno DUMORTIER
//		<dub@fuegox>

#include <GeomFill_SweepSectionGenerator.ixx>

#include <GeomFill_Profiler.hxx>

#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <gp_Trsf.hxx>
#include <gp_Pnt.hxx>
#include <gp_Ax3.hxx>
#include <gp_Ax2.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Circle.hxx>
#include <GeomConvert.hxx>
#include <Precision.hxx>
#include <ElCLib.hxx>
#include <GeomAdaptor.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GCPnts_QuasiUniformDeflection.hxx>
#include <TColStd_Array1OfReal.hxx>

#include <stdio.h>

#ifdef DRAW
#include <DrawTrSurf.hxx>

static Standard_Boolean Affich     = Standard_False;
static Standard_Integer NbSECTIONS = 0;
#endif

//=======================================================================
//function : GeomFill_SweepSectionGenerator
//purpose  : 
//=======================================================================

GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator()
{
  myIsDone = Standard_False;
}


//=======================================================================
//function : GeomFill_SweepSectionGenerator
//purpose  : 
//=======================================================================

GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator
  (const Handle(Geom_Curve)& Path,
   const Standard_Real       Radius)
{
  Init(Path,Radius);
}


//=======================================================================
//function : GeomFill_SweepSectionGenerator
//purpose  : 
//=======================================================================

GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator
  (const Handle(Geom_Curve)& Path,
   const Handle(Geom_Curve)& FirstSect)
{
  Init(Path,FirstSect);
}


//=======================================================================
//function : GeomFill_SweepSectionGenerator
//purpose  : 
//=======================================================================

GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator
  (const Handle(Geom_Curve)& Path,
   const Handle(Geom_Curve)& FirstSect,
   const Handle(Geom_Curve)& LastSect  )
{
  Init(Path,FirstSect,LastSect);
}


//=======================================================================
//function : GeomFill_SweepSectionGenerator
//purpose  : 
//=======================================================================

GeomFill_SweepSectionGenerator::GeomFill_SweepSectionGenerator
  (const Handle(Adaptor3d_HCurve)& Path,
   const Handle(Adaptor3d_HCurve)& Curve1,
   const Handle(Adaptor3d_HCurve)& Curve2,
   const Standard_Real       Radius)
{
  Init(Path,Curve1,Curve2,Radius);
}


//=======================================================================
//function : Init
//purpose  : 
//=======================================================================

void GeomFill_SweepSectionGenerator::Init(const Handle(Geom_Curve)& Path,
					  const Standard_Real       Radius)
{
  myIsDone = Standard_False;
  myRadius = Radius;
  GeomAdaptor_Curve ThePath(Path);

  if (ThePath.GetType() == GeomAbs_Circle) {
    
    myCircPathAxis = ThePath.Circle().Axis();
    myType = 4;
  }
  else myType = 1;
  if ( Path->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
    myPath = Handle(Geom_BSplineCurve)::DownCast(Path->Copy());
  }
  else {
    myPath = GeomConvert::CurveToBSplineCurve(Path);
  }
}


//=======================================================================
//function : Init
//purpose  : 
//=======================================================================
void GeomFill_SweepSectionGenerator::Init
  (const Handle(Geom_Curve)& Path,
   const Handle(Geom_Curve)& FirstSect)
{
  myIsDone = Standard_False;
  myRadius = 0; 
  GeomAdaptor_Curve ThePath(Path);

  if (ThePath.GetType() == GeomAbs_Circle) {    
    myCircPathAxis = ThePath.Circle().Axis();
    myType = 5;
  }

  else  myType   = 2;
  
  if ( Path->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
    myPath = Handle(Geom_BSplineCurve)::DownCast(Path->Copy());
  }
  else {
    myPath = GeomConvert::CurveToBSplineCurve(Path);
  }
  if ( FirstSect->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
      myFirstSect = Handle(Geom_BSplineCurve)::DownCast(FirstSect->Copy());
    }
  else {
    // JAG
    myFirstSect = GeomConvert::CurveToBSplineCurve(FirstSect,
						   Convert_QuasiAngular);
  }
  if ( myFirstSect->IsPeriodic()) myFirstSect->SetNotPeriodic();
}


//=======================================================================
//function : Init
//purpose  : 
//=======================================================================

void GeomFill_SweepSectionGenerator::Init
  (const Handle(Geom_Curve)& Path,
   const Handle(Geom_Curve)& FirstSect,
   const Handle(Geom_Curve)& LastSect  )
{
  myIsDone = Standard_False;
  myRadius = 0;
  GeomAdaptor_Curve ThePath(Path);

  if (ThePath.GetType() == GeomAbs_Circle) {
    
    myCircPathAxis = ThePath.Circle().Axis();
    myType = 6;
  }
  else myType   = 3;
  
  if ( Path->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
    myPath = Handle(Geom_BSplineCurve)::DownCast(Path->Copy());
  }
  else {
    myPath = GeomConvert::CurveToBSplineCurve(Path);
  }
  
  // JAG
  if ( FirstSect->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
      myFirstSect = Handle(Geom_BSplineCurve)::DownCast(FirstSect->Copy());
    }
  else {
    myFirstSect = GeomConvert::CurveToBSplineCurve(FirstSect,
						   Convert_QuasiAngular);
  }
  if ( LastSect->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
      myLastSect = Handle(Geom_BSplineCurve)::DownCast(LastSect->Copy());
    }
  else {
    myLastSect = GeomConvert::CurveToBSplineCurve(LastSect,
						   Convert_QuasiAngular);
  }

  if ( myFirstSect->IsPeriodic()) myFirstSect->SetNotPeriodic();
  if ( myLastSect->IsPeriodic()) myLastSect->SetNotPeriodic();


  // JAG

  GeomFill_Profiler Profil;
  Profil.AddCurve(myFirstSect);
  Profil.AddCurve(myLastSect);
  Profil.Perform(Precision::Confusion());
  
  myFirstSect = Handle(Geom_BSplineCurve)::DownCast(Profil.Curve(1));
  myLastSect  = Handle(Geom_BSplineCurve)::DownCast(Profil.Curve(2));
}


//=======================================================================
//function : Init
//purpose  : 
//=======================================================================

void GeomFill_SweepSectionGenerator::Init
  (const Handle(Adaptor3d_HCurve)& Path,
   const Handle(Adaptor3d_HCurve)& Curve1,
   const Handle(Adaptor3d_HCurve)& Curve2,
   const Standard_Real       Radius)
{
  myIsDone = Standard_False;
  myRadius = Radius;
  myType   = 0;

  Handle(Geom_Curve) CC = GeomAdaptor::MakeCurve(Path->Curve());
  myPath         = GeomConvert::CurveToBSplineCurve(CC);
  myAdpPath      = Path;
  myAdpFirstSect = Curve1;
  myAdpLastSect  = Curve2;
}


//=======================================================================
//function : Perform
//purpose  : 
//=======================================================================

void GeomFill_SweepSectionGenerator::Perform(const Standard_Boolean Polynomial)
{
  myPolynomial = Polynomial;

  // eval myNbSections.
  Standard_Integer NSpans = myPath->NbKnots()-1;

  myNbSections = 21 * NSpans;

  Standard_Real U;

  Standard_Real U1 = myPath->FirstParameter();
  Standard_Real U2 = myPath->LastParameter();
  
  GCPnts_QuasiUniformDeflection Samp;
  // Calcul de la longueur approximative de la courbe
  GeomAdaptor_Curve AdpPath(myPath);
  gp_Pnt P1 = AdpPath.Value(U1);
  gp_Pnt P2 = AdpPath.Value((U1+U2)/2.);
  gp_Pnt P3 = AdpPath.Value(U2);
  Standard_Real Length = 
    P1.Distance(P2) + P2.Distance(P3);
  Standard_Real Fleche = 1.e-5 * Length;
  Samp.Initialize(AdpPath,Fleche);

  if ( Samp.IsDone() && (Samp.NbPoints() > myNbSections) ) {
    myNbSections = Samp.NbPoints();
  }
  // the transformations are calculate on differents points of <myPath>
  // corresponding to the path parameter uniformly reparted.
  Standard_Real DeltaU = (U2-U1)/(Standard_Real)(myNbSections-1);
  TColStd_Array1OfReal Parameters(1,myNbSections);
//  Parameters(1) = U1;
//  for (Standard_Integer i = 2; i < myNbSections; i++) {
//    Parameters(i) = U1 + (i-1) * DeltaU;
//  }
//  Parameters(myNbSections) = U2;
  
  Parameters(1) = 0.;
  for (Standard_Integer i = 2; i < myNbSections; i++) {
    Parameters(i) = (i-1) * DeltaU;
  }
  Parameters(myNbSections) = U2 - U1;

  gp_Vec D1Ref, D1;
  gp_Pnt PRef , P; 
  gp_Trsf TR, cumulTR, Trans;

  myPath->D1( U1, PRef, D1Ref); 

  if ( ( myType == 1) || (myType == 4) ) {
    // We create a circle with radius <myRadius>. This axis is create with
    // main direction <DRef> (first derivate vector of <myPath> on the first
    // point <PRef> ). This circle is, after transform to BSpline curve, 
    // put in <myFirstSect>.
			      
    gp_Ax2 CircleAxis (PRef,D1Ref);
/*
    Handle(Geom_Circle) Circ = new Geom_Circle( CircleAxis, myRadius); 
    
    myFirstSect = GeomConvert::CurveToBSplineCurve(Circ);
    // le cercle est segmente car AppBlend_AppSurf ne gere
    // pas les courbes periodiques.
    myFirstSect->Segment(0., 2.*PI);
*/
    Handle(Geom_TrimmedCurve) Circ = 
      new Geom_TrimmedCurve(new Geom_Circle( CircleAxis, myRadius), 
			    0., 2.*PI); 
    
    myFirstSect = GeomConvert::CurveToBSplineCurve(Circ,Convert_QuasiAngular);
  }
  
  if (myType <= 3 && myType >=1 ) {
    
    for (Standard_Integer i = 2; i <= myNbSections; i++) {

      U = Parameters(i) + U1;
      if (i == myNbSections) U = U2;

      myPath->D1( U, P, D1);
    
      // Eval the translation between the (i-1) section and the i-th.
      Trans.SetTranslation(PRef, P);

      gp_Trsf Rot;
      if (! D1Ref.IsParallel(D1, Precision::Angular())) {
	// Eval the Rotation between (i-1) section and the i-th.
	Rot.SetRotation(gp_Ax1(P, gp_Dir(D1Ref^D1)), 
			D1Ref.AngleWithRef(D1, D1Ref^D1));
      }
      else
	if (D1Ref.IsOpposite(D1, Precision::Angular()))
	  cout <<"Que fais-je ???? " << endl;

      // TR is the transformation between (i-1) section and the i-th.
      TR = Rot * Trans;
      // cumulTR is the transformation between <myFirstSec> and 
      // the i-th section.
      cumulTR = TR * cumulTR;

      myTrsfs.Append(cumulTR);
      
      PRef = P;
      D1Ref = D1;
    }
  }
  else if ( myType != 0) { 
    for (Standard_Integer i = 2; i<= myNbSections; i++) {
      cumulTR.SetRotation(myCircPathAxis, Parameters(i));
      myTrsfs.Append(cumulTR);      
    }
  }
    
  myIsDone = Standard_True;
}

//=======================================================================
//function : GetShape
//purpose  : 
//=======================================================================

void GeomFill_SweepSectionGenerator::GetShape
  (Standard_Integer& NbPoles,
   Standard_Integer& NbKnots,
   Standard_Integer& Degree,
   Standard_Integer& NbPoles2d) const 
{
/* 
 if ( myType == 1) {
    NbPoles   = 7;
    NbKnots   = 4;
    Degree    = 2;
  }
  else {
*/
  if ( myType != 0) {
    NbPoles = myFirstSect->NbPoles();
    NbKnots = myFirstSect->NbKnots();
    Degree  = myFirstSect->Degree();
  }
  else { // myType == 0
    NbPoles   = 7;
    NbKnots   = 2;
    Degree    = 6;
  }
  NbPoles2d = 0;
}


//=======================================================================
//function : Knots
//purpose  : 
//=======================================================================

void GeomFill_SweepSectionGenerator::Knots(TColStd_Array1OfReal& TKnots) const 
{
/*
  if (myType == 1) {
    Standard_Real U = 2.*PI/3.;
    for ( Standard_Integer i = 1; i <= 4; i++) 
      TKnots(i) = ( i-1) * U;
  }
  else {
*/
  if (myType !=0) {
    myFirstSect->Knots(TKnots);
  }
  else {
    TKnots(1) = 0.;
    TKnots(2) = 1.;
  }
//  }
}


//=======================================================================
//function : Mults
//purpose  : 
//=======================================================================

void GeomFill_SweepSectionGenerator::Mults(TColStd_Array1OfInteger& TMults)
  const 
{
/*
  if ( myType == 1) {
    TMults( 1) = TMults( 4) = 3;
    TMults( 2) = TMults( 3) = 2;
  }
  else {
*/
  if ( myType != 0) {
    myFirstSect->Multiplicities(TMults);
  }
  else {
    TMults( 1) = TMults( 2) = 7;
  }
//  }
}


//=======================================================================
//function : Section
//purpose  : 
//=======================================================================

Standard_Boolean GeomFill_SweepSectionGenerator::Section
  (const Standard_Integer      P,
         TColgp_Array1OfPnt&   Poles, 
         TColgp_Array1OfVec&   DPoles,
         TColgp_Array1OfPnt2d& Poles2d,
         TColgp_Array1OfVec2d& , //DPoles2d,
         TColStd_Array1OfReal& Weigths,
         TColStd_Array1OfReal& DWeigths
   ) const 
{
  Section( P, Poles, Poles2d, Weigths);

  // pour les tuyaux sur aretes pour l'instant on ne calcule pas les derivees
  if ( myType == 0 ) return Standard_False; // a voir pour mieux.

  // calcul des derivees sur la surface
  // on calcule les derivees en approximant le path au voisinage du point
  // P(u) par le cercle osculateur au path .

  // calcul du cercle osculateur.

  Standard_Real U;
  if ( P == 1) {
    U = myPath->FirstParameter();
  }
  else if ( P == myNbSections ) {
    U = myPath->LastParameter();
  }
  else
    return Standard_False;
    
  gp_Vec D1, D2;
  gp_Pnt Pt;

  myPath->D2(U,Pt,D1,D2);
  Standard_Real l = D1.Magnitude();
  
  if ( l < Epsilon(1.))
    return Standard_False;

  gp_Dir T = D1;
  Standard_Real m = D2.Dot(T);
  gp_Vec D = D2 - m * T;
  Standard_Real c = D.Magnitude() / (l*l);
  
  if ( c < Epsilon(1.)) { 
    // null curvature : equivalent to a translation of the section 
    for (Standard_Integer i = 1; i <= myFirstSect->NbPoles(); i++) {
      DPoles(i) = D1;
    }    
  }
  else {
    gp_Dir N = D;
    gp_Pnt Q = Pt.Translated( (1./c) * gp_Vec(N));
    Standard_Real x, y;
    gp_Vec V;
    for ( Standard_Integer i = 1; i <= myFirstSect->NbPoles(); i++) {
      V = gp_Vec(Q, Poles(i));
      x = V * gp_Vec(T);
      y = V * gp_Vec(N);
      DPoles(i) = x * gp_Vec(N) - y * gp_Vec(T);
      if ( DPoles(i).Magnitude() > Epsilon(1.)) {
	DPoles(i).Normalize();
	DPoles(i) *= Sqrt( x*x + y*y);
      }
    }
  }
  
  for ( Standard_Integer i = 1; i <= myFirstSect->NbPoles(); i++) {
    DWeigths(i) = 0.;
  }
  
  return Standard_True;
}


//=======================================================================
//function : Section
//purpose  : 
//=======================================================================

void GeomFill_SweepSectionGenerator::Section
  (const Standard_Integer      P,
         TColgp_Array1OfPnt&   Poles,
         TColgp_Array1OfPnt2d& , //Poles2d, 
         TColStd_Array1OfReal& Weigths) const 
{
  if (myType != 0) {
    myFirstSect->Poles(Poles);
    myFirstSect->Weights(Weigths);
    gp_Trsf cumulTR;
    if (P > 1) {
      cumulTR = myTrsfs(P - 1); 
      // <cumulTR> transform <myFirstSect> to the P ieme Section. In fact
      // each points of the array <poles> will be transformed.
      
      if ( (myType == 3 ) || (myType == 6) ){
	for (Standard_Integer i = 1; i <= myFirstSect->NbPoles(); i++) {
	  Poles(i).SetXYZ( (myNbSections - P) * myFirstSect->Pole(i).XYZ() +
			  (P - 1) * myLastSect->Pole(i).XYZ() );
	  Poles(i).SetXYZ( Poles(i).XYZ() / (myNbSections - 1));
	  
	  Weigths(i) = (myNbSections - P) * myFirstSect->Weight(i) +
	    (P - 1) * myLastSect->Weight(i);
	  Weigths(i) /= myNbSections - 1;
	}
      }
      
      for (Standard_Integer i = 1; i<=Poles.Length(); i++)
	Poles(i).Transform(cumulTR);
    }
#ifdef DRAW
    if ( Affich) {
//POP pour NT
//      char name[100];
      char* name = new char[100];
      sprintf(name,"SECTION_%d",++NbSECTIONS);
      DrawTrSurf::Set(name,myFirstSect->Transformed(cumulTR));
    }
#endif
  }
  else {

    Standard_Real Coef = (P -1. ) / ( myNbSections - 1.);
    Standard_Real U = 
      ( 1- Coef) * myAdpPath->FirstParameter() +
	Coef     * myAdpPath->LastParameter();

    gp_Pnt PPath = myAdpPath->Value(U);
    
    Standard_Real Alpha = U - myAdpPath->FirstParameter();
    Alpha /= myAdpPath->LastParameter() - myAdpPath->FirstParameter();
    
    Standard_Real U1 = 
      ( 1- Alpha) * myAdpFirstSect->FirstParameter() +
	Alpha     * myAdpFirstSect->LastParameter();
    
    gp_Pnt P1 = myAdpFirstSect->Value(U1);
    
    Standard_Real U2 = 
      ( 1- Alpha) * myAdpLastSect->FirstParameter() +
	Alpha     * myAdpLastSect->LastParameter();
    
    gp_Pnt P2 = myAdpLastSect->Value(U2);
    
    gp_Ax2 Axis;
    Standard_Real Angle;
    if ( P1.Distance(P2) < Precision::Confusion()) {
      Angle = 0.;
    }
    else {
      Axis = gp_Ax2(PPath, 
		    gp_Vec(PPath,P1) ^ gp_Vec(PPath,P2),
		    gp_Vec(PPath,P1));
      Angle = ElCLib::CircleParameter(Axis,P2);
    }
#ifdef DEB
    if (Standard_False) {
      gp_Vec dummyD1 = myAdpPath->DN(U,1);
      gp_Vec dummyTg = Axis.Direction();
      Standard_Real Cos = dummyD1.Dot(dummyTg);
      if ( Cos > 0.) cout << "+" ;
      else           cout << "-" ;
    }
#endif
    if ( Angle < Precision::Angular()) {
      for ( Standard_Integer i = 1; i <= Poles.Upper(); i++) {
	Poles(i) = P1;
	Weigths(i) = 1;
      }
    }
    else {
      Handle(Geom_Circle) Circ =
	new Geom_Circle( Axis, myRadius);
      Handle(Geom_TrimmedCurve) CT = 
	new Geom_TrimmedCurve(Circ, 0., Angle);
      Handle(Geom_BSplineCurve) BS;
      if ( myPolynomial) 
	BS = GeomConvert::CurveToBSplineCurve( CT, Convert_Polynomial);
      else 
	BS = GeomConvert::CurveToBSplineCurve( CT, Convert_QuasiAngular);

#ifdef DRAW
      if ( Affich) {
// POP pour NT
//	char name[100];
	char* name = new char[100];
	sprintf(name,"SECTION_%d",++NbSECTIONS);
	DrawTrSurf::Set(name,BS);
      }
#endif
      
      BS->Poles(Poles);
      BS->Weights(Weigths);
    }
  }
}

//=======================================================================
//function : Transformation
//purpose  : 
//=======================================================================
const gp_Trsf& GeomFill_SweepSectionGenerator::Transformation
  (const Standard_Integer Index) const 
{
  if (Index > myTrsfs.Length())
    Standard_RangeError::Raise
      ("GeomFill_SweepSectionGenerator::Transformation");
  
  return myTrsfs(Index);
}


//=======================================================================
//function : Parameter
//purpose  : 
//=======================================================================

Standard_Real GeomFill_SweepSectionGenerator::Parameter
  (const Standard_Integer P) const
{
  if (P == 1) {
    return myPath->FirstParameter();
  }
  else if (P == myNbSections) {
    return myPath->LastParameter();
  }
  else {
    Standard_Real U1 = myPath->FirstParameter();
    Standard_Real U2 = myPath->LastParameter();
    Standard_Real prm = ((myNbSections-P)*U1 + (P-1)*U2)/
      (Standard_Real)(myNbSections-1);
    return prm;
  }
}