e75a5f0abc8de58617350cad1fab16e4dda03d83
[occt.git] / src / Geom / Geom_BSplineCurve.cdl
1 -- Created on: 1993-03-09
2 -- Created by: JCV
3 -- Copyright (c) 1993-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
5 --
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
10 --
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 --
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
20
21 -- xab : modified 15-Mar-95 : added cache mecanism to speed up evaluation
22 -- mei : modified 08-Jun-95 : added method MovePoint
23
24
25 class BSplineCurve from Geom inherits BoundedCurve from Geom
26
27         ---Purpose : Definition of the B_spline curve.
28         --       A B-spline curve can be  
29         --         Uniform  or non-uniform
30         --         Rational or non-rational
31         --         Periodic or non-periodic
32         --  
33         --  a b-spline curve is defined by :
34         --  its degree; the degree for a
35         --   Geom_BSplineCurve is limited to a value (25)
36         --   which is defined and controlled by the system.
37         --   This value is returned by the function MaxDegree;
38         -- - its periodic or non-periodic nature;
39         -- - a table of poles (also called control points), with
40         --   their associated weights if the BSpline curve is
41         --   rational. The poles of the curve are "control
42         --   points" used to deform the curve. If the curve is
43         --   non-periodic, the first pole is the start point of
44         --   the curve, and the last pole is the end point of
45         --   the curve. The segment which joins the first pole
46         --   to the second pole is the tangent to the curve at
47         --   its start point, and the segment which joins the
48         --   last pole to the second-from-last pole is the
49         --   tangent to the curve at its end point. If the curve
50         --   is periodic, these geometric properties are not
51         --   verified. It is more difficult to give a geometric
52         --   signification to the weights but are useful for
53         --   providing exact representations of the arcs of a
54         --   circle or ellipse. Moreover, if the weights of all the
55         --   poles are equal, the curve has a polynomial
56         --   equation; it is therefore a non-rational curve.
57         -- - a table of knots with their multiplicities. For a
58         --   Geom_BSplineCurve, the table of knots is an
59         --   increasing sequence of reals without repetition;
60         --   the multiplicities define the repetition of the knots.
61         --   A BSpline curve is a piecewise polynomial or
62         --   rational curve. The knots are the parameters of
63         --   junction points between two pieces. The
64         --   multiplicity Mult(i) of the knot Knot(i) of
65         --   the BSpline curve is related to the degree of
66         --   continuity of the curve at the knot Knot(i),
67         --   which is equal to Degree - Mult(i)
68         --   where Degree is the degree of the BSpline curve.
69         --   If the knots are regularly spaced (i.e. the difference
70         --   between two consecutive knots is a constant), three
71         --   specific and frequently used cases of knot
72         --   distribution can be identified:
73         -- - "uniform" if all multiplicities are equal to 1,
74         -- - "quasi-uniform" if all multiplicities are equal to 1,
75         --   except the first and the last knot which have a
76         --   multiplicity of Degree + 1, where Degree is
77         --   the degree of the BSpline curve,
78         -- - "Piecewise Bezier" if all multiplicities are equal to
79         --   Degree except the first and last knot which
80         --   have a multiplicity of Degree + 1, where
81         --   Degree is the degree of the BSpline curve. A
82         --   curve of this type is a concatenation of arcs of Bezier curves.
83         -- If the BSpline curve is not periodic:
84         -- - the bounds of the Poles and Weights tables are 1
85         --   and NbPoles, where NbPoles is the number
86         --   of poles of the BSpline curve,
87         -- - the bounds of the Knots and Multiplicities tables
88         --   are 1 and NbKnots, where NbKnots is the
89         --   number of knots of the BSpline curve.
90         -- If the BSpline curve is periodic, and if there are k
91         -- periodic knots and p periodic poles, the period is:
92         -- period = Knot(k + 1) - Knot(1)
93         -- and the poles and knots tables can be considered
94         -- as infinite tables, verifying:
95         -- - Knot(i+k) = Knot(i) + period
96         -- - Pole(i+p) = Pole(i)
97         -- Note: data structures of a periodic BSpline curve
98         -- are more complex than those of a non-periodic one.
99         -- Warning
100         -- In this class, weight value is considered to be zero if
101         -- the weight is less than or equal to gp::Resolution().
102         --    
103         -- References :
104         --  . A survey of curve and surface methods in CADG Wolfgang BOHM
105         --    CAGD 1 (1984)
106         --  . On de Boor-like algorithms and blossoming Wolfgang BOEHM
107         --    cagd 5 (1988)
108         --  . Blossoming and knot insertion algorithms for B-spline curves
109         --    Ronald N. GOLDMAN
110         --  . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA   
111         --  . Curves and Surfaces for Computer Aided Geometric Design,
112         --    a practical guide Gerald Farin
113
114 uses  Array1OfInteger      from TColStd,
115       Array1OfReal         from TColStd,
116       HArray1OfInteger     from TColStd,
117       HArray1OfReal        from TColStd,
118       Array1OfPnt          from TColgp,
119       Ax1                  from gp,
120       Ax2                  from gp, 
121       Pnt                  from gp,
122       HArray1OfPnt         from TColgp,
123       Trsf                 from gp,
124       Vec                  from gp,
125       BSplKnotDistribution from GeomAbs,
126       Geometry             from Geom,
127       Shape                from GeomAbs
128
129
130 raises ConstructionError   from Standard,
131        DimensionError      from Standard,
132        DomainError         from Standard,
133        OutOfRange          from Standard,
134        RangeError          from Standard,
135        NoSuchObject        from Standard,
136        UndefinedDerivative from Geom
137
138 is
139  
140   Create (Poles          : Array1OfPnt     from TColgp; 
141           Knots          : Array1OfReal    from TColStd; 
142           Multiplicities : Array1OfInteger from TColStd; 
143           Degree         : Integer;
144           Periodic       : Boolean = Standard_False)
145           
146   returns mutable BSplineCurve from Geom
147
148         ---Purpose :  Creates a  non-rational B_spline curve   on  the
149         --         basis <Knots, Multiplicities> of degree <Degree>.
150
151   raises ConstructionError;
152
153         -- The following conditions must be verified.
154
155         --  0 < Degree <= MaxDegree.
156         --  
157         --  Knots.Length() == Mults.Length() >= 2
158         --  
159         --  Knots(i) < Knots(i+1) (Knots are increasing)
160         --  
161         --  1 <= Mults(i) <= Degree
162         --  
163         --   On a non periodic curve the first and last multiplicities
164         --   may be Degree+1 (this is even recommanded if you want the
165         --   curve to start and finish on the first and last pole).
166         --   
167         --   On a periodic  curve the first  and  the last multicities
168         --   must be the same.
169         --   
170         --   on non-periodic curves
171         --   
172         --     Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2
173         --     
174         --   on periodic curves 
175         --   
176         --     Poles.Length() == Sum(Mults(i)) except the first or last
177
178
179   Create (Poles          : Array1OfPnt     from TColgp; 
180           Weights        : Array1OfReal    from TColStd;
181           Knots          : Array1OfReal    from TColStd; 
182           Multiplicities : Array1OfInteger from TColStd; 
183           Degree         : Integer;
184           Periodic       : Boolean = Standard_False; 
185           CheckRational  : Boolean = Standard_True)
186           
187   returns mutable BSplineCurve from Geom
188
189         ---Purpose : Creates  a rational B_spline  curve  on the basis
190         --         <Knots, Multiplicities> of degree <Degree>.
191         --  Raises ConstructionError subject to the following conditions 
192         --  0 < Degree <= MaxDegree.
193         --  
194         --  Weights.Length() == Poles.Length()
195         --  
196         --  Knots.Length() == Mults.Length() >= 2
197         --  
198         --  Knots(i) < Knots(i+1) (Knots are increasing)
199         --  
200         --  1 <= Mults(i) <= Degree
201         --  
202         --   On a non periodic curve the first and last multiplicities
203         --   may be Degree+1 (this is even recommanded if you want the
204         --   curve to start and finish on the first and last pole).
205         --   
206         --   On a periodic  curve the first  and  the last multicities
207         --   must be the same.
208         --   
209         --   on non-periodic curves
210         --   
211         --     Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2
212         --     
213         --   on periodic curves 
214         --   
215         --     Poles.Length() == Sum(Mults(i)) except the first or last
216
217   raises ConstructionError;
218
219         
220
221
222   IncreaseDegree (me : mutable; Degree : Integer)
223   
224         ---Purpose: Increases the degree of this BSpline curve to
225         -- Degree. As a result, the poles, weights and
226         -- multiplicities tables are modified; the knots table is
227         -- not changed. Nothing is done if Degree is less than
228         -- or equal to the current degree.
229         -- Exceptions
230         -- Standard_ConstructionError if Degree is greater than
231         -- Geom_BSplineCurve::MaxDegree().
232   raises ConstructionError;
233
234  IncreaseMultiplicity (me : mutable; Index : Integer; M : Integer)
235  
236         ---Purpose :Increases the multiplicity  of the knot <Index> to
237         --         <M>.   
238         --         
239         --         If   <M>   is   lower   or  equal   to  the current
240         --         multiplicity nothing is done. If <M> is higher than
241         --         the degree the degree is used.
242
243  raises OutOfRange;
244         
245         ---Purpose: If <Index> is not in [FirstUKnotIndex, LastUKnotIndex]
246
247
248   IncreaseMultiplicity (me : mutable; I1, I2 : Integer; M : Integer) 
249   
250         ---Purpose :Increases  the  multiplicities   of  the knots  in
251         --         [I1,I2] to <M>.
252         --         
253         --         For each knot if  <M>  is  lower  or equal  to  the
254         --         current multiplicity  nothing  is  done. If <M>  is
255         --         higher than the degree the degree is used.
256
257  raises OutOfRange;
258         
259         ---Purpose: If <I1,I2> are not in [FirstUKnotIndex, LastUKnotIndex]
260
261   IncrementMultiplicity (me : mutable; I1, I2 : Integer; M : Integer) 
262   
263         ---Purpose :Increment  the  multiplicities   of  the knots  in
264         --         [I1,I2] by <M>.
265         --         
266         --         If <M> is not positive nithing is done.
267         --         
268         --         For   each  knot   the resulting   multiplicity  is
269         --         limited to the Degree.
270
271  raises OutOfRange;
272         
273         ---Purpose: If <I1,I2> are not in [FirstUKnotIndex, LastUKnotIndex]
274
275
276
277
278   InsertKnot (me : mutable; 
279               U : Real; 
280               M : Integer = 1; 
281               ParametricTolerance : Real = 0.0;
282               Add : Boolean = Standard_True); 
283   
284         ---Purpose: Inserts a knot value in the sequence of knots.  If
285         --          <U>  is an  existing knot     the multiplicity  is
286         --          increased by <M>.
287         --          
288         --          If U  is  not  on the parameter  range  nothing is
289         --          done.
290         --          
291         --          If the multiplicity is negative or null nothing is
292         --          done. The  new   multiplicity  is limited  to  the
293         --          degree.
294         --          
295         --          The  tolerance criterion  for  knots  equality  is
296         --          the max of Epsilon(U) and ParametricTolerance.
297
298
299   InsertKnots (me : mutable; Knots : Array1OfReal    from TColStd; 
300                              Mults : Array1OfInteger from TColStd;
301                              ParametricTolerance : Real = 0.0;
302                              Add : Boolean = Standard_False);
303                              
304         ---Purpose: Inserts a set of knots  values in  the sequence of
305         --          knots.    
306         --          
307         --          For each U = Knots(i), M = Mults(i)
308         --          
309         --          If <U>  is an existing  knot  the  multiplicity is
310         --          increased by  <M> if  <Add>  is True, increased to
311         --          <M> if <Add> is False.
312         --          
313         --          If U  is  not  on the parameter  range  nothing is
314         --          done.
315         --          
316         --          If the multiplicity is negative or null nothing is
317         --          done. The  new   multiplicity  is limited  to  the
318         --          degree.
319         --          
320         --          The  tolerance criterion  for  knots  equality  is
321         --          the max of Epsilon(U) and ParametricTolerance.
322
323
324                              
325
326
327   RemoveKnot(me : mutable; Index     : Integer; 
328                            M         : Integer;
329                            Tolerance : Real) returns Boolean
330                            
331         ---Purpose : Reduces the multiplicity of the knot of index Index
332         -- to M. If M is equal to 0, the knot is removed.
333         -- With a modification of this type, the array of poles is also modified.
334         -- Two different algorithms are systematically used to
335         -- compute the new poles of the curve. If, for each
336         -- pole, the distance between the pole calculated
337         -- using the first algorithm and the same pole
338         -- calculated using the second algorithm, is less than
339         -- Tolerance, this ensures that the curve is not
340         -- modified by more than Tolerance. Under these
341         -- conditions, true is returned; otherwise, false is returned.
342         -- A low tolerance is used to prevent modification of
343         -- the curve. A high tolerance is used to "smooth" the curve.
344         -- Exceptions
345         -- Standard_OutOfRange if Index is outside the
346         -- bounds of the knots table.
347      raises OutOfRange;
348      
349
350         ---Purpose : pole insertion and pole removing
351         --  this operation is limited to the Uniform or QuasiUniform
352         --  BSplineCurve. The knot values are modified . If the BSpline is
353         --  NonUniform or Piecewise Bezier an exception Construction error
354         --  is raised.
355
356
357   Reverse (me : mutable);
358         ---Purpose :
359         --  Changes the direction of parametrization of <me>. The Knot
360         --  sequence is modified, the FirstParameter and the 
361         --  LastParameter are not modified. The StartPoint of the 
362         --  initial curve becomes the EndPoint of the reversed curve 
363         --  and the EndPoint of the initial curve becomes the StartPoint
364         --  of the reversed curve.
365
366
367   ReversedParameter(me; U : Real) returns Real;
368         ---Purpose: Returns the  parameter on the  reversed  curve for
369         --          the point of parameter U on <me>.
370         --          
371         --          returns UFirst + ULast - U
372
373   Segment (me : mutable; U1, U2 : Real)
374         ---Purpose : Modifies this BSpline curve by segmenting it between
375         -- U1 and U2. Either of these values can be outside the
376         -- bounds of the curve, but U2 must be greater than U1.
377         -- All data structure tables of this BSpline curve are
378         -- modified, but the knots located between U1 and U2
379         -- are retained. The degree of the curve is not modified.
380         --  Warnings :
381         --  Even if <me> is not closed it can become closed after the 
382         --  segmentation for example if U1 or U2 are out of the bounds 
383         --  of the curve <me> or if the curve makes loop.
384         --  After the segmentation the length of a curve can be null.
385     raises DomainError from Standard;
386         ---Purpose: raises if U2 < U1.
387
388
389   SetKnot (me : mutable; Index : Integer; K : Real)
390         ---Purpose : Modifies this BSpline curve by assigning the value K
391         -- to the knot of index Index in the knots table. This is a
392         -- relatively local modification because K must be such that:
393         -- Knots(Index - 1) < K < Knots(Index + 1)
394         -- The second syntax allows you also to increase the
395         -- multiplicity of the knot to M (but it is not possible to
396         -- decrease the multiplicity of the knot with this function).
397         -- Standard_ConstructionError if:
398         -- - K is not such that:
399         -- Knots(Index - 1) < K < Knots(Index + 1)
400         -- - M is greater than the degree of this BSpline curve
401         --   or lower than the previous multiplicity of knot of
402         --   index Index in the knots table.
403         --  Standard_OutOfRange if Index is outside the bounds of the knots table.
404      raises ConstructionError,
405                     OutOfRange;
406
407
408   SetKnots (me : mutable; K : Array1OfReal from TColStd)
409         ---Purpose :  Modifies this BSpline curve by assigning the array
410         -- K to its knots table. The multiplicity of the knots is not modified.
411         -- Exceptions
412         -- Standard_ConstructionError if the values in the
413         -- array K are not in ascending order.
414         -- Standard_OutOfRange if the bounds of the array
415         -- K are not respectively 1 and the number of knots of this BSpline curve.
416      raises ConstructionError,
417                     OutOfRange;
418   
419   SetKnot (me : mutable; Index : Integer; K : Real; M : Integer)
420         ---Purpose :
421         --  Changes the knot of range Index with its multiplicity.
422         --  You can increase the multiplicity of a knot but it is
423         --  not allowed to decrease the multiplicity of an existing knot.
424      raises ConstructionError,
425         ---Purpose :
426         --  Raised if K >= Knots(Index+1) or K <= Knots(Index-1).
427         --  Raised if M is greater than Degree or lower than the previous
428         --  multiplicity of knot of range Index. 
429             OutOfRange;
430         ---Purpose : Raised if Index < 1 || Index > NbKnots
431
432   PeriodicNormalization(me ;  U : in out Real) ; 
433        
434         ---Purpose : returns the parameter normalized within
435         --         the period if the curve is periodic : otherwise
436         --         does not do anything
437     
438   SetPeriodic (me : mutable)
439         ---Purpose : Changes this BSpline curve into a periodic curve.
440         -- To become periodic, the curve must first be closed.
441         -- Next, the knot sequence must be periodic. For this,
442         -- FirstUKnotIndex and LastUKnotIndex are used
443         -- to compute I1 and I2, the indexes in the knots
444         -- array of the knots corresponding to the first and
445         -- last parameters of this BSpline curve.
446         -- The period is therefore: Knots(I2) - Knots(I1).
447         -- Consequently, the knots and poles tables are modified.
448         -- Exceptions
449         -- Standard_ConstructionError if this BSpline curve is not closed.
450      raises ConstructionError;
451
452
453   SetOrigin (me : mutable; Index : Integer)
454         ---Purpose: Assigns the knot of index Index in the knots table as
455         -- the origin of this periodic BSpline curve. As a
456         -- consequence, the knots and poles tables are modified.
457         -- Exceptions
458         -- Standard_NoSuchObject if this curve is not periodic.
459         -- Standard_DomainError if Index is outside the bounds of the knots table.
460     raises NoSuchObject,
461            DomainError;
462         
463   SetOrigin (me  : mutable; 
464              U   : Real from Standard;
465              Tol : Real from Standard)
466         ---Purpose: Set the origin of a periodic curve at Knot U. If U
467         --          is  not a  knot  of  the  BSpline  a  new knot  is
468         --          inseted. KnotVector and poles are modified.
469     raises NoSuchObject;
470         ---Purpose: Raised if the curve is not periodic
471
472
473   SetNotPeriodic (me : mutable);
474         ---Purpose : Changes this BSpline curve into a non-periodic
475         -- curve. If this curve is already non-periodic, it is not modified.
476         -- Note: the poles and knots tables are modified.
477         -- Warning
478         -- If this curve is periodic, as the multiplicity of the first
479         -- and last knots is not modified, and is not equal to
480         -- Degree + 1, where Degree is the degree of
481         -- this BSpline curve, the start and end points of the
482         -- curve are not its first and last poles.
483    
484                 
485  
486   SetPole (me : mutable; Index : Integer; P : Pnt)
487         ---Purpose : Modifies this BSpline curve by assigning P to the pole
488         -- of index Index in the poles table.
489         -- Exceptions
490         -- Standard_OutOfRange if Index is outside the
491         -- bounds of the poles table.
492         -- Standard_ConstructionError if Weight is negative or null.
493      raises OutOfRange;
494      
495   SetPole (me : mutable; Index : Integer; P : Pnt; Weight : Real)
496         ---Purpose: Modifies this BSpline curve by assigning P to the pole
497         -- of index Index in the poles table.
498         -- This syntax also allows you to modify the
499         -- weight of the modified pole, which becomes Weight.
500         -- In this case, if this BSpline curve is non-rational, it
501         -- can become rational and vice versa.
502         -- Exceptions
503         -- Standard_OutOfRange if Index is outside the
504         -- bounds of the poles table.
505         -- Standard_ConstructionError if Weight is negative or null.
506      raises OutOfRange,
507                ConstructionError;
508
509
510   SetWeight (me : mutable; Index : Integer; Weight : Real)
511         ---Purpose :
512         --  Changes the weight for the pole of range Index.
513         --  If the curve was non rational it can become rational.
514         --  If the curve was rational it can become non rational.
515      raises OutOfRange,
516         ---Purpose:
517         --  Raised if Index < 1 || Index > NbPoles
518             ConstructionError;
519         ---Purpose : Raised if Weight <= 0.0
520
521   MovePoint (me : mutable; U: Real; P: Pnt; Index1, Index2: Integer;
522              FirstModifiedPole, LastModifiedPole: out Integer)
523         ---Purpose : Moves the point of parameter U of this BSpline curve
524         -- to P. Index1 and Index2 are the indexes in the table
525         -- of poles of this BSpline curve of the first and last
526         -- poles designated to be moved.
527         -- FirstModifiedPole and LastModifiedPole are the
528         -- indexes of the first and last poles which are effectively modified.
529         -- In the event of incompatibility between Index1, Index2 and the value U:
530         -- - no change is made to this BSpline curve, and
531         -- - the FirstModifiedPole and LastModifiedPole are returned null.
532         --   Exceptions
533         -- Standard_OutOfRange if:
534         -- - Index1 is greater than or equal to Index2, or
535         -- - Index1 or Index2 is less than 1 or greater than the
536         --   number of poles of this BSpline curve.
537          raises OutOfRange;
538       
539   MovePointAndTangent (me : mutable; 
540                        U                 : Real; 
541                        P                 : Pnt; 
542                        Tangent           : Vec ;
543                        Tolerance         : Real ; 
544                        StartingCondition, 
545                        EndingCondition   : Integer; 
546                        ErrorStatus       : out Integer) 
547
548         ---Purpose : 
549         -- Move a point with parameter U to P.
550         -- and makes it tangent at U be Tangent.
551         -- StartingCondition = -1 means first can move
552         -- EndingCondition   = -1 means last point can move
553         -- StartingCondition = 0 means the first point cannot move
554         -- EndingCondition   = 0 means the last point cannot move
555         -- StartingCondition = 1 means the first point and tangent cannot move
556         -- EndingCondition   = 1 means the last point and tangent cannot move  
557         -- and so forth
558         -- ErrorStatus != 0 means that there are not enought degree of freedom
559         -- with the constrain to deform the curve accordingly
560         -- 
561      raises OutOfRange;
562      
563   IsCN (me; N : Integer)   returns Boolean
564         ---Purpose :
565         --  Returns the continuity of the curve, the curve is at least C0.
566      raises RangeError;
567         ---Purpose : Raised if N < 0.
568
569
570   IsClosed (me)  returns Boolean;
571         ---Purpose :
572         --  Returns true if the distance between the first point and the 
573         --  last point of the curve is lower or equal to Resolution 
574         --  from package gp.
575         --- Warnings :
576         --  The first and the last point can be different from the first
577         --  pole and the last pole of the curve.
578
579
580   IsPeriodic (me)  returns Boolean;
581         ---Purpose : Returns True if the curve is periodic.
582
583
584   IsRational (me)  returns Boolean;
585         ---Purpose :
586         --  Returns True if the weights are not identical.
587         --  The tolerance criterion is Epsilon of the class Real.
588     
589   IsCacheValid(me;  Parameter : Real) returns Boolean
590   
591         ---Purpose :
592         --           Tells whether the Cache is valid for the
593         --           given parameter 
594         -- Warnings : the parameter must be normalized within
595         -- the period if the curve is periodic. Otherwise
596         -- the answer will be false
597         -- 
598         is static private;
599   
600   Continuity (me)  returns Shape from GeomAbs;
601         ---Purpose :
602         --  Returns the global continuity of the curve :
603         --  C0 : only geometric continuity,
604         --  C1 : continuity of the first derivative all along the Curve,
605         --  C2 : continuity of the second derivative all along the Curve,
606         --  C3 : continuity of the third derivative all along the Curve,
607         --  CN : the order of continuity is infinite.
608         --  For a B-spline curve of degree d if a knot Ui has a
609         --  multiplicity p the B-spline curve is only Cd-p continuous 
610         --  at Ui. So the global continuity of the curve can't be greater 
611         --  than Cd-p where p is the maximum multiplicity of the interior
612         --  Knots. In the interior of a knot span the curve is infinitely
613         --  continuously differentiable.
614
615
616   Degree (me)  returns Integer;
617         ---Purpose: Returns the degree of this BSpline curve.
618         -- The degree of a Geom_BSplineCurve curve cannot
619         -- be greater than Geom_BSplineCurve::MaxDegree().
620
621         ---Purpose : Computation of value and derivatives
622
623   D0 (me ; U : Real; P : out Pnt);
624         ---Purpose: Returns in P the point of parameter U.
625
626   D1 (me; U : Real; P : out Pnt; V1 : out Vec)
627      raises UndefinedDerivative;
628         ---Purpose : Raised if the continuity of the curve is not C1.
629
630
631   D2 (me; U : Real; P : out Pnt; V1, V2 : out Vec)
632      raises UndefinedDerivative;
633         ---Purpose : Raised if the continuity of the curve is not C2.
634
635
636   D3 (me; U : Real; P : out Pnt; V1, V2, V3 : out Vec)
637      raises UndefinedDerivative;
638         ---Purpose : Raised if the continuity of the curve is not C3.
639         
640
641   DN (me; U : Real; N : Integer)  returns Vec
642         ---Purpose : For the point of parameter U of this BSpline curve,
643         -- computes the vector corresponding to the Nth derivative.
644         -- Warning
645         -- On a point where the continuity of the curve is not the
646         -- one requested, this function impacts the part defined
647         -- by the parameter with a value greater than U, i.e. the
648         -- part of the curve to the "right" of the singularity.
649         -- Exceptions
650         -- Standard_RangeError if N is less than 1.
651      raises  UndefinedDerivative,
652                     RangeError;
653
654         ---Purpose  :
655         --  The following functions compute the point of parameter U 
656         --  and the derivatives at this point on the B-spline curve 
657         --  arc defined between the knot FromK1 and the knot ToK2. 
658         --  U can be out of bounds [Knot (FromK1),  Knot (ToK2)] but
659         --  for the computation we only use the definition of the curve
660         --  between these two knots. This method is useful to compute 
661         --  local derivative, if the order of continuity of the whole 
662         --  curve is not greater enough.    Inside the parametric
663         --  domain Knot (FromK1), Knot (ToK2) the evaluations are
664         --  the same as if we consider the whole definition of the
665         --  curve. Of course the evaluations are different outside
666         --  this parametric domain.
667
668
669   LocalValue (me; U : Real; FromK1, ToK2 : Integer)   returns Pnt
670      raises DomainError,
671         ---Purpose : Raised if FromK1 = ToK2.
672             OutOfRange;
673         ---Purpose :
674         --  Raised if FromK1 and ToK2 are not in the range 
675         --  [FirstUKnotIndex, LastUKnotIndex].
676
677   LocalD0 (me; U : Real; FromK1, ToK2 : Integer; P : out Pnt)
678      raises DomainError,
679         ---Purpose : Raised if FromK1 = ToK2.
680             OutOfRange;
681         ---Purpose :
682         --  Raised if FromK1 and ToK2 are not in the range 
683         --  [FirstUKnotIndex, LastUKnotIndex].
684
685   LocalD1 (me; U : Real; FromK1, ToK2 : Integer; P : out Pnt; V1 : out Vec)
686      raises UndefinedDerivative,
687         ---Purpose :
688         --  Raised if the local continuity of the curve is not C1 
689         --  between the knot K1 and the knot K2. 
690             DomainError,
691         ---Purpose : Raised if FromK1 = ToK2.
692             OutOfRange;
693         ---Purpose :
694         --  Raised if FromK1 and ToK2 are not in the range 
695         --  [FirstUKnotIndex, LastUKnotIndex].
696
697
698   LocalD2 (me; U : Real; FromK1, ToK2 : Integer; P : out Pnt; V1, V2 : out Vec)
699      raises UndefinedDerivative,
700         ---Purpose :
701         --  Raised if the local continuity of the curve is not C2 
702         --  between the knot K1 and the knot K2. 
703             DomainError,
704         ---Purpose : Raised if FromK1 = ToK2.
705             OutOfRange;
706         ---Purpose :
707         --  Raised if FromK1 and ToK2 are not in the range 
708         --  [FirstUKnotIndex, LastUKnotIndex].
709
710
711
712   LocalD3 (me; U : Real;  FromK1, ToK2 : Integer;
713            P : out Pnt; V1, V2, V3 : out Vec)
714      raises UndefinedDerivative,
715         ---Purpose :
716         --  Raised if the local continuity of the curve is not C3
717         --  between the knot K1 and the knot K2. 
718             DomainError,
719         ---Purpose : Raised if FromK1 = ToK2.
720             OutOfRange;
721         ---Purpose :
722         --  Raised if FromK1 and ToK2 are not in the range
723         --  [FirstUKnotIndex, LastUKnotIndex].
724
725
726   LocalDN (me; U : Real;  FromK1, ToK2 : Integer; N : Integer)  returns Vec
727      raises  UndefinedDerivative,
728         ---Purpose :
729         --  Raised if the local continuity of the curve is not CN
730         --  between the knot K1 and the knot K2. 
731             DomainError,
732         ---Purpose : Raised if FromK1 = ToK2.
733              RangeError,
734         ---Purpose : Raised if N < 1.
735              OutOfRange;
736         ---Purpose :
737         --  Raises if FromK1 and ToK2 are not in the range 
738         --  [FirstUKnotIndex, LastUKnotIndex].
739
740
741   EndPoint (me)   returns Pnt;
742         ---Purpose :
743         --  Returns the last point of the curve.
744         -- Warnings :
745         --  The last point of the curve is different from the last 
746         --  pole of the curve if the multiplicity of the last knot
747         --  is lower than Degree.
748
749
750   FirstUKnotIndex (me)   returns Integer;
751         ---Purpose : Returns the index in the knot array of the knot
752         -- corresponding to the first or last parameter of this BSpline curve.
753         -- For a BSpline curve, the first (or last) parameter
754         -- (which gives the start (or end) point of the curve) is a
755         -- knot value. However, if the multiplicity of the first (or
756         -- last) knot is less than Degree + 1, where
757         -- Degree is the degree of the curve, it is not the first
758         -- (or last) knot of the curve.
759       
760
761   FirstParameter (me)   returns Real;
762         ---Purpose : Returns the value of the first parameter of this
763         -- BSpline curve. This is a knot value.
764         -- The first parameter is the one of the start point of the BSpline curve. 
765        
766
767
768   Knot (me; Index : Integer)   returns Real
769         ---Purpose :
770         --  Returns the knot of range Index. When there is a knot 
771         --  with a multiplicity greater than 1 the knot is not repeated.
772         --  The method Multiplicity can be used to get the multiplicity 
773         --  of the Knot.
774      raises OutOfRange;
775         ---Purpose : Raised if Index < 1 or Index > NbKnots
776
777
778   Knots (me; K : out Array1OfReal from TColStd)
779         ---Purpose : returns the knot values of the B-spline curve; 
780         -- Warning
781         -- A knot with a multiplicity greater than 1 is not
782         -- repeated in the knot table. The Multiplicity function
783         -- can be used to obtain the multiplicity of each knot.
784      raises DimensionError;
785         ---Purpose :
786         --  Raised if the length of K is not equal to the number of knots.
787
788
789   KnotSequence (me; K : out Array1OfReal from TColStd)
790         ---Purpose : Returns K, the knots sequence of this BSpline curve.
791         -- In this sequence, knots with a multiplicity greater than 1 are repeated.
792         -- In the case of a non-periodic curve the length of the
793         -- sequence must be equal to the sum of the NbKnots
794         -- multiplicities of the knots of the curve (where
795         -- NbKnots is the number of knots of this BSpline
796         -- curve). This sum is also equal to : NbPoles + Degree + 1
797         -- where NbPoles is the number of poles and
798         -- Degree the degree of this BSpline curve.
799         -- In the case of a periodic curve, if there are k periodic
800         -- knots, the period is Knot(k+1) - Knot(1).
801         -- The initial sequence is built by writing knots 1 to k+1,
802         -- which are repeated according to their corresponding multiplicities.
803         -- If Degree is the degree of the curve, the degree of
804         -- continuity of the curve at the knot of index 1 (or k+1)
805         -- is equal to c = Degree + 1 - Mult(1). c
806         -- knots are then inserted at the beginning and end of
807         -- the initial sequence:
808         -- - the c values of knots preceding the first item
809         --   Knot(k+1) in the initial sequence are inserted
810         --   at the beginning; the period is subtracted from these c values;
811         -- - the c values of knots following the last item
812         --   Knot(1) in the initial sequence are inserted at
813         --   the end; the period is added to these c values.
814         -- The length of the sequence must therefore be equal to:
815         -- NbPoles + 2*Degree - Mult(1) + 2.
816         -- Example
817         -- For a non-periodic BSpline curve of degree 2 where:
818         -- - the array of knots is: { k1 k2 k3 k4 },
819         -- - with associated multiplicities: { 3 1 2 3 },
820         -- the knot sequence is:
821         -- K = { k1 k1 k1 k2 k3 k3 k4 k4 k4 }
822         -- For a periodic BSpline curve of degree 4 , which is
823         -- "C1" continuous at the first knot, and where :
824         -- - the periodic knots are: { k1 k2 k3 (k4) }
825         --   (3 periodic knots: the points of parameter k1 and k4
826         --   are identical, the period is p = k4 - k1),
827         -- - with associated multiplicities: { 3 1 2 (3) },
828         -- the degree of continuity at knots k1 and k4 is:
829         -- Degree + 1 - Mult(i) = 2.
830         -- 2 supplementary knots are added at the beginning
831         -- and end of the sequence:
832         -- - at the beginning: the 2 knots preceding k4 minus
833         --   the period; in this example, this is k3 - p both times;
834         -- - at the end: the 2 knots following k1 plus the period;
835         --   in this example, this is k2 + p and k3 + p.
836         -- The knot sequence is therefore:
837         -- K = { k3-p k3-p k1 k1 k1 k2 k3 k3
838         -- k4 k4 k4 k2+p k3+p }
839         -- Exceptions
840         -- Standard_DimensionError if the array K is not of
841         -- the appropriate length.Returns the knots sequence.
842              raises DimensionError;
843        
844
845
846   KnotDistribution (me)   returns BSplKnotDistribution from GeomAbs;
847         ---Purpose :
848         --  Returns NonUniform or Uniform or QuasiUniform or PiecewiseBezier.
849         --  If all the knots differ by a positive constant from the 
850         --  preceding knot the BSpline Curve can be :
851         --  - Uniform if all the knots are of multiplicity 1,
852         --  - QuasiUniform if all the knots are of multiplicity 1 except for
853         --    the first and last knot which are of multiplicity Degree + 1,
854         --  - PiecewiseBezier if the first and last knots have multiplicity
855         --    Degree + 1 and if interior knots have multiplicity Degree
856         --    A piecewise Bezier with only two knots is a BezierCurve. 
857         --  else the curve is non uniform.
858         --  The tolerance criterion is Epsilon from class Real.
859
860
861   LastUKnotIndex (me)  returns Integer;
862         ---Purpose :
863         --  For a BSpline curve the last parameter (which gives the 
864         --  end point of the curve) is a knot value but if the 
865         --  multiplicity of the last knot index is lower than 
866         --  Degree + 1 it is not the last knot of the curve. This
867         --  method computes the index of the knot corresponding to
868         --  the last parameter.
869
870
871   LastParameter (me)   returns Real;
872         ---Purpose :
873         --  Computes the parametric value of the end point of the curve.
874         --  It is a knot value.
875
876
877   LocateU (me;
878            U                   : Real; 
879            ParametricTolerance : Real; 
880            I1, I2              : in out Integer;
881            WithKnotRepetition  : Boolean = Standard_False);
882         ---Purpose :
883         --  Locates the parametric value U in the sequence of knots.
884         --  If "WithKnotRepetition" is True we consider the knot's
885         --  representation with repetition of multiple knot value,
886         --  otherwise  we consider the knot's representation with
887         --  no repetition of multiple knot values.
888         --  Knots (I1) <= U <= Knots (I2)
889         --  . if I1 = I2  U is a knot value (the tolerance criterion 
890         --    ParametricTolerance is used).
891         --  . if I1 < 1  => U < Knots (1) - Abs(ParametricTolerance)
892         --  . if I2 > NbKnots => U > Knots (NbKnots) + Abs(ParametricTolerance)
893
894
895   Multiplicity (me; Index : Integer)   returns Integer
896         ---Purpose :
897         --  Returns the multiplicity of the knots of range Index.
898      raises OutOfRange;
899         ---Purpose : Raised if Index < 1 or Index > NbKnots
900
901
902   Multiplicities (me; M : out Array1OfInteger from TColStd)
903         ---Purpose :
904         --  Returns the multiplicity of the knots of the curve.
905      raises DimensionError;
906         ---Purpose :
907         --  Raised if the length of M is not equal to NbKnots.
908
909
910   NbKnots (me)  returns Integer;
911         ---Purpose :
912         --  Returns the number of knots. This method returns the number of 
913         --  knot without repetition of multiple knots.
914
915
916   NbPoles (me)  returns Integer;
917         ---Purpose : Returns the number of poles
918
919
920   Pole (me; Index : Integer)   returns Pnt
921         ---Purpose : Returns the pole of range Index.
922      raises OutOfRange;
923         ---Purpose : Raised if Index < 1 or Index > NbPoles.
924
925
926   Poles (me; P : out Array1OfPnt from TColgp)
927         ---Purpose : Returns the poles of the B-spline curve;
928      raises DimensionError;
929         ---Purpose : 
930         --  Raised if the length of P is not equal to the number of poles.
931
932
933   StartPoint (me)  returns Pnt;
934         ---Purpose :
935         --  Returns the start point of the curve.
936         -- Warnings :
937         --  This point is different from the first pole of the curve if the
938         --  multiplicity of the first knot is lower than Degree.
939
940
941   Weight (me; Index : Integer)  returns Real  
942         ---Purpose : Returns the weight of the pole of range Index .
943      raises OutOfRange;
944         ---Purpose : Raised if Index < 1 or Index > NbPoles.
945
946
947   Weights (me; W : out Array1OfReal from TColStd)
948         ---Purpose : Returns the weights of the B-spline curve;
949      raises DimensionError;
950         ---Purpose :
951         --  Raised if the length of W is not equal to NbPoles.
952
953
954
955
956
957
958
959   Transform (me : mutable; T : Trsf);
960         ---Purpose: Applies the transformation T to this BSpline curve.
961   MaxDegree (myclass)  returns Integer;
962         ---Purpose :
963         --  Returns the value of the maximum degree of the normalized 
964         --  B-spline basis functions in this package.
965
966   Resolution(me          : mutable; 
967              Tolerance3D : Real;
968              UTolerance  : out Real) 
969         ---Purpose:  Computes for this BSpline curve the parametric
970         -- tolerance UTolerance for a given 3D tolerance Tolerance3D.
971         -- If f(t) is the equation of this BSpline curve,
972         -- UTolerance ensures that:
973         --           | t1 - t0| < Utolerance ===> 
974         --           |f(t1) - f(t0)| < Tolerance3D
975   ;
976
977   Copy (me)  returns mutable like me;
978         ---Purpose: Creates a new object which is a copy of this BSpline curve.
979     
980   InvalidateCache(me : mutable)
981         ---Purpose : Invalidates the cache. This has to be private
982         -- this has to be private
983       is static private;
984
985   UpdateKnots(me : mutable)
986         ---Purpose : Recompute  the  flatknots,  the knotsdistribution, the continuity.
987     is static private;
988   
989   ValidateCache(me : mutable ; Parameter : Real) 
990   
991     is static private;
992         ---Purpose : updates the cache and validates it
993
994   
995         
996
997
998 fields
999
1000   rational        : Boolean;
1001   periodic        : Boolean;
1002   knotSet         : BSplKnotDistribution from GeomAbs; 
1003   smooth          : Shape from GeomAbs;
1004   deg             : Integer;
1005   poles           : HArray1OfPnt     from TColgp;
1006   weights         : HArray1OfReal    from TColStd;
1007   flatknots       : HArray1OfReal    from TColStd;
1008   knots           : HArray1OfReal    from TColStd;
1009   mults           : HArray1OfInteger from TColStd;
1010   cachepoles      : HArray1OfPnt     from TColgp;
1011   -- Taylor expansion of the poles function, in homogeneous
1012   -- form if the curve is rational. The taylor expansion
1013   -- is normalized so that the span corresponds to
1014   -- [0 1] see below
1015   cacheweights    : HArray1OfReal    from TColStd;
1016   -- Taylor expansion of the poles function, in homogeneous
1017   -- form if the curve is rational. The taylor expansion
1018   -- is normalized so that the span corresponds to
1019   -- [0 1] see below
1020   validcache      : Integer;
1021   -- = 1 the cache is valid 
1022   -- = 0 the cache is invalid
1023   parametercache    : Real;
1024   -- Parameter at which the Taylor expension is stored in 
1025   -- the cache
1026   spanlenghtcache   : Real;
1027   -- Since the Taylor expansion is normalized in the 
1028   -- cache to evaluate the cache one has to use
1029   -- (Parameter - parametercache) / nspanlenghtcache
1030   spanindexcache : Integer;
1031   -- the span for which the cache is valid if 
1032   -- validcache is 1 
1033
1034   -- usefull to evaluate the parametric resolution
1035   maxderivinv   : Real from Standard;
1036   maxderivinvok : Boolean from Standard;
1037
1038 end;