1
<?xml version="1.0" encoding="UTF-8"?>
2
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
4
Father="BoundedCurvePy"
6
PythonName="Part.BSplineCurve"
7
Twin="GeomBSplineCurve"
8
TwinPointer="GeomBSplineCurve"
9
Include="Mod/Part/App/Geometry.h"
11
FatherInclude="Mod/Part/App/BoundedCurvePy.h"
12
FatherNamespace="Part"
15
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
16
<UserDocu>Describes a B-Spline curve in 3D space</UserDocu>
18
<Methode Name="__reduce__" Const="true">
20
<UserDocu>__reduce__()
21
Serialization of Part.BSplineCurve objects
25
<Attribute Name="Degree" ReadOnly="true">
27
<UserDocu>Returns the polynomial degree of this B-Spline curve.</UserDocu>
29
<Parameter Name="Degree" Type="Long"/>
31
<Attribute Name="MaxDegree" ReadOnly="true">
33
<UserDocu>Returns the value of the maximum polynomial degree of any
34
B-Spline curve curve. This value is 25.</UserDocu>
36
<Parameter Name="MaxDegree" Type="Long"/>
38
<Attribute Name="NbPoles" ReadOnly="true">
40
<UserDocu>Returns the number of poles of this B-Spline curve.
43
<Parameter Name="NbPoles" Type="Long"/>
45
<Attribute Name="NbKnots" ReadOnly="true">
48
Returns the number of knots of this B-Spline curve.
51
<Parameter Name="NbPoles" Type="Long"/>
53
<Attribute Name="StartPoint" ReadOnly="true">
55
<UserDocu>Returns the start point of this B-Spline curve.</UserDocu>
57
<Parameter Name="StartPoint" Type="Object"/>
59
<Attribute Name="EndPoint" ReadOnly="true">
61
<UserDocu>Returns the end point of this B-Spline curve.</UserDocu>
63
<Parameter Name="EndPoint" Type="Object"/>
65
<Attribute Name="FirstUKnotIndex" ReadOnly="true">
67
<UserDocu>Returns the index in the knot array of the knot
68
corresponding to the first or last parameter
69
of this B-Spline curve.</UserDocu>
71
<Parameter Name="FirstUKnotIndex" Type="Object"/>
73
<Attribute Name="LastUKnotIndex" ReadOnly="true">
75
<UserDocu>Returns the index in the knot array of the knot
76
corresponding to the first or last parameter
77
of this B-Spline curve.</UserDocu>
79
<Parameter Name="LastUKnotIndex" Type="Object"/>
81
<Attribute Name="KnotSequence" ReadOnly="true">
83
<UserDocu>Returns the knots sequence of this B-Spline curve.</UserDocu>
85
<Parameter Name="KnotSequence" Type="List"/>
87
<Methode Name="isRational" Const="true">
90
Returns true if this B-Spline curve is rational.
91
A B-Spline curve is rational if, at the time of construction,
92
the weight table has been initialized.
96
<Methode Name="isPeriodic" Const="true">
98
<UserDocu>Returns true if this BSpline curve is periodic.</UserDocu>
101
<Methode Name="isClosed" Const="true">
104
Returns true if the distance between the start point and end point of
105
this B-Spline curve is less than or equal to gp::Resolution().
109
<Methode Name="increaseDegree">
111
<UserDocu>increase(Int=Degree)
112
Increases the degree of this B-Spline curve to Degree.
113
As a result, the poles, weights and multiplicities tables
114
are modified; the knots table is not changed. Nothing is
115
done if Degree is less than or equal to the current degree.</UserDocu>
118
<Methode Name="increaseMultiplicity">
121
increaseMultiplicity(int index, int mult)
122
increaseMultiplicity(int start, int end, int mult)
123
Increases multiplicity of knots up to mult.
125
index: the index of a knot to modify (1-based)
126
start, end: index range of knots to modify.
127
If mult is lower or equal to the current multiplicity nothing is done. If mult is higher than the degree the degree is used.
131
<Methode Name="incrementMultiplicity">
134
incrementMultiplicity(int start, int end, int mult)
135
Raises multiplicity of knots by mult.
137
start, end: index range of knots to modify.
141
<Methode Name="insertKnot">
144
insertKnot(u, mult = 1, tol = 0.0)
145
Inserts a knot value in the sequence of knots. If u is an existing knot the
146
multiplicity is increased by mult. </UserDocu>
149
<Methode Name="insertKnots">
152
insertKnots(list_of_floats, list_of_ints, tol = 0.0, bool_add = True)
153
Inserts a set of knots values in the sequence of knots.
155
For each u = list_of_floats[i], mult = list_of_ints[i]
157
If u is an existing knot the multiplicity is increased by mult if bool_add is
158
True, otherwise increased to mult.
160
If u is not on the parameter range nothing is done.
162
If the multiplicity is negative or null nothing is done. The new multiplicity
163
is limited to the degree.
165
The tolerance criterion for knots equality is the max of Epsilon(U) and ParametricTolerance.
169
<Methode Name="removeKnot">
172
removeKnot(Index, M, tol)
174
Reduces the multiplicity of the knot of index Index to M.
175
If M is equal to 0, the knot is removed.
176
With a modification of this type, the array of poles is also modified.
177
Two different algorithms are systematically used to compute the new
178
poles of the curve. If, for each pole, the distance between the pole
179
calculated using the first algorithm and the same pole calculated using
180
the second algorithm, is less than Tolerance, this ensures that the curve
181
is not modified by more than Tolerance. Under these conditions, true is
182
returned; otherwise, false is returned.
184
A low tolerance is used to prevent modification of the curve.
185
A high tolerance is used to 'smooth' the curve.
189
<Methode Name="segment">
193
Modifies this B-Spline curve by segmenting it.</UserDocu>
196
<Methode Name="setKnot">
198
<UserDocu>Set a knot of the B-Spline curve.</UserDocu>
201
<Methode Name="getKnot" Const="true">
203
<UserDocu>Get a knot of the B-Spline curve.</UserDocu>
206
<Methode Name="setKnots">
208
<UserDocu>Set knots of the B-Spline curve.</UserDocu>
211
<Methode Name="getKnots" Const="true">
213
<UserDocu>Get all knots of the B-Spline curve.</UserDocu>
216
<Methode Name="setPole">
218
<UserDocu>Modifies this B-Spline curve by assigning P
219
to the pole of index Index in the poles table.</UserDocu>
222
<Methode Name="getPole" Const="true">
224
<UserDocu>Get a pole of the B-Spline curve.</UserDocu>
227
<Methode Name="getPoles" Const="true">
229
<UserDocu>Get all poles of the B-Spline curve.</UserDocu>
232
<Methode Name="setWeight">
234
<UserDocu>Set a weight of the B-Spline curve.</UserDocu>
237
<Methode Name="getWeight" Const="true">
239
<UserDocu>Get a weight of the B-Spline curve.</UserDocu>
242
<Methode Name="getWeights" Const="true">
244
<UserDocu>Get all weights of the B-Spline curve.</UserDocu>
247
<Methode Name="getPolesAndWeights" Const="true">
249
<UserDocu>Returns the table of poles and weights in homogeneous coordinates.</UserDocu>
252
<Methode Name="getResolution" Const="true">
254
<UserDocu>Computes for this B-Spline curve the parametric tolerance (UTolerance)
255
for a given 3D tolerance (Tolerance3D).
256
If f(t) is the equation of this B-Spline curve, the parametric tolerance
258
|t1-t0| < UTolerance =""==> |f(t1)-f(t0)| < Tolerance3D</UserDocu>
261
<Methode Name="movePoint">
264
movePoint(U, P, Index1, Index2)
265
Moves the point of parameter U of this B-Spline curve to P.
266
Index1 and Index2 are the indexes in the table of poles of this B-Spline curve
267
of the first and last poles designated to be moved.
269
Returns: (FirstModifiedPole, LastModifiedPole). They are the indexes of the
270
first and last poles which are effectively modified.</UserDocu>
273
<Methode Name="setNotPeriodic">
275
<UserDocu>Changes this B-Spline curve into a non-periodic curve.
276
If this curve is already non-periodic, it is not modified.</UserDocu>
279
<Methode Name="setPeriodic">
281
<UserDocu>Changes this B-Spline curve into a periodic curve.</UserDocu>
284
<Methode Name="setOrigin">
286
<UserDocu>Assigns the knot of index Index in the knots table
287
as the origin of this periodic B-Spline curve. As a consequence,
288
the knots and poles tables are modified.</UserDocu>
291
<Methode Name="getMultiplicity" Const="true">
293
<UserDocu>Returns the multiplicity of the knot of index
294
from the knots table of this B-Spline curve.</UserDocu>
297
<Methode Name="getMultiplicities" Const="true">
300
Returns the multiplicities table M of the knots of this B-Spline curve.
304
<Methode Name="approximate" Keyword="true">
307
Replaces this B-Spline curve by approximating a set of points.
308
The function accepts keywords as arguments.
310
approximate(Points = list_of_points)
314
DegMin = integer (3) : Minimum degree of the curve.
315
DegMax = integer (8) : Maximum degree of the curve.
316
Tolerance = float (1e-3) : approximating tolerance.
317
Continuity = string ('C2') : Desired continuity of the curve.
318
Possible values : 'C0','G1','C1','G2','C2','C3','CN'
320
LengthWeight = float, CurvatureWeight = float, TorsionWeight = float
321
If one of these arguments is not null, the functions approximates the
322
points using variational smoothing algorithm, which tries to minimize
323
additional criterium:
324
LengthWeight*CurveLength + CurvatureWeight*Curvature + TorsionWeight*Torsion
325
Continuity must be C0, C1(with DegMax >= 3) or C2(with DegMax >= 5).
327
Parameters = list of floats : knot sequence of the approximated points.
328
This argument is only used if the weights above are all null.
330
ParamType = string ('Uniform','Centripetal' or 'ChordLength')
331
Parameterization type. Only used if weights and Parameters above aren't specified.
333
Note : Continuity of the spline defaults to C2. However, it may not be applied if
334
it conflicts with other parameters ( especially DegMax ).
338
<Methode Name="getCardinalSplineTangents" Keyword="true" Const="true">
340
<UserDocu>Compute the tangents for a Cardinal spline</UserDocu>
343
<Methode Name="interpolate" Keyword="true">
346
Replaces this B-Spline curve by interpolating a set of points.
347
The function accepts keywords as arguments.
349
interpolate(Points = list_of_points)
353
PeriodicFlag = bool (False) : Sets the curve closed or opened.
354
Tolerance = float (1e-6) : interpolating tolerance
356
Parameters : knot sequence of the interpolated points.
357
If not supplied, the function defaults to chord-length parameterization.
358
If PeriodicFlag == True, one extra parameter must be appended.
360
EndPoint Tangent constraints :
362
InitialTangent = vector, FinalTangent = vector
363
specify tangent vectors for starting and ending points
364
of the BSpline. Either none, or both must be specified.
366
Full Tangent constraints :
368
Tangents = list_of_vectors, TangentFlags = list_of_bools
369
Both lists must have the same length as Points list.
370
Tangents specifies the tangent vector of each point in Points list.
371
TangentFlags (bool) activates or deactivates the corresponding tangent.
372
These arguments will be ignored if EndPoint Tangents (above) are also defined.
374
Note : Continuity of the spline defaults to C2. However, if periodic, or tangents
375
are supplied, the continuity will drop to C1.
379
<Methode Name="buildFromPoles">
382
Builds a B-Spline by a list of poles.
383
arguments: poles (sequence of Base.Vector), [periodic (default is False), degree (default is 3), interpolate (default is False)]
386
from FreeCAD import Base
389
poles = [V(-2, 2, 0),V(0, 2, 1),V(2, 2, 0),V(2, -2, 0),V(0, -2, 1),V(-2, -2, 0)]
391
# non-periodic spline
392
n=Part.BSplineCurve()
393
n.buildFromPoles(poles)
394
Part.show(n.toShape())
397
n=Part.BSplineCurve()
398
n.buildFromPoles(poles, True)
399
Part.show(n.toShape())
403
<Methode Name="buildFromPolesMultsKnots" Keyword="true">
406
Builds a B-Spline by a lists of Poles, Mults, Knots.
407
arguments: poles (sequence of Base.Vector), [mults , knots, periodic, degree, weights (sequence of float), CheckRational]
410
from FreeCAD import Base
413
poles=[V(-10,-10),V(10,-10),V(10,10),V(-10,10)]
415
# non-periodic spline
416
n=Part.BSplineCurve()
417
n.buildFromPolesMultsKnots(poles,(3,1,3),(0,0.5,1),False,2)
418
Part.show(n.toShape())
421
p=Part.BSplineCurve()
422
p.buildFromPolesMultsKnots(poles,(1,1,1,1,1),(0,0.25,0.5,0.75,1),True,2)
423
Part.show(p.toShape())
425
# periodic and rational spline
426
r=Part.BSplineCurve()
427
r.buildFromPolesMultsKnots(poles,(1,1,1,1,1),(0,0.25,0.5,0.75,1),True,2,(1,0.8,0.7,0.2))
428
Part.show(r.toShape())
432
<Methode Name="toBezier" Const="true">
435
Build a list of Bezier splines.
439
<Methode Name="toBiArcs" Const="true">
442
Build a list of arcs and lines to approximate the B-spline.
443
toBiArcs(tolerance) -> list.
447
<Methode Name="join">
450
Build a new spline by joining this and a second spline.
454
<Methode Name="makeC1Continuous">
457
makeC1Continuous(tol = 1e-6, ang_tol = 1e-7)
458
Reduces as far as possible the multiplicities of the knots of this BSpline
459
(keeping the geometry). It returns a new BSpline, which could still be C0.
460
tol is a geometrical tolerance.
461
The tol_ang is angular tolerance, in radians. It sets tolerable angle mismatch
462
of the tangents on the left and on the right to decide if the curve is G1 or
463
not at a given point.
467
<Methode Name="scaleKnotsToBounds">
470
Scales the knots list to fit the specified bounds.
471
The shape of the curve is not modified.
472
bspline_curve.scaleKnotsToBounds(u0, u1)
473
Default arguments are (0.0, 1.0)