FreeCAD

Форк
0
/
BSplineCurvePy.xml 
478 строк · 21.0 Кб
1
<?xml version="1.0" encoding="UTF-8"?>
2
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
3
    <PythonExport
4
                Father="BoundedCurvePy"
5
        Name="BSplineCurvePy"
6
                PythonName="Part.BSplineCurve"
7
        Twin="GeomBSplineCurve"
8
        TwinPointer="GeomBSplineCurve"
9
        Include="Mod/Part/App/Geometry.h"
10
        Namespace="Part"
11
                FatherInclude="Mod/Part/App/BoundedCurvePy.h"
12
        FatherNamespace="Part"
13
        Constructor="true">
14
        <Documentation>
15
            <Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" />
16
            <UserDocu>Describes a B-Spline curve in 3D space</UserDocu>
17
        </Documentation>
18
        <Methode Name="__reduce__" Const="true">
19
            <Documentation>
20
                <UserDocu>__reduce__()
21
Serialization of Part.BSplineCurve objects
22
                </UserDocu>
23
            </Documentation>
24
        </Methode>
25
        <Attribute Name="Degree" ReadOnly="true">
26
            <Documentation>
27
                <UserDocu>Returns the polynomial degree of this B-Spline curve.</UserDocu>
28
            </Documentation>
29
            <Parameter Name="Degree" Type="Long"/>
30
        </Attribute>
31
        <Attribute Name="MaxDegree" ReadOnly="true">
32
            <Documentation>
33
                <UserDocu>Returns the value of the maximum polynomial degree of any
34
B-Spline curve curve. This value is 25.</UserDocu>
35
            </Documentation>
36
            <Parameter Name="MaxDegree" Type="Long"/>
37
        </Attribute>
38
        <Attribute Name="NbPoles" ReadOnly="true">
39
            <Documentation>
40
                <UserDocu>Returns the number of poles of this B-Spline curve.
41
                </UserDocu>
42
            </Documentation>
43
            <Parameter Name="NbPoles" Type="Long"/>
44
        </Attribute>
45
        <Attribute Name="NbKnots" ReadOnly="true">
46
            <Documentation>
47
                <UserDocu>
48
                    Returns the number of knots of this B-Spline curve.
49
                </UserDocu>
50
            </Documentation>
51
            <Parameter Name="NbPoles" Type="Long"/>
52
        </Attribute>
53
        <Attribute Name="StartPoint" ReadOnly="true">
54
            <Documentation>
55
                <UserDocu>Returns the start point of this B-Spline curve.</UserDocu>
56
            </Documentation>
57
            <Parameter Name="StartPoint" Type="Object"/>
58
        </Attribute>
59
        <Attribute Name="EndPoint" ReadOnly="true">
60
            <Documentation>
61
                <UserDocu>Returns the end point of this B-Spline curve.</UserDocu>
62
            </Documentation>
63
            <Parameter Name="EndPoint" Type="Object"/>
64
        </Attribute>
65
        <Attribute Name="FirstUKnotIndex" ReadOnly="true">
66
            <Documentation>
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>
70
            </Documentation>
71
            <Parameter Name="FirstUKnotIndex" Type="Object"/>
72
        </Attribute>
73
        <Attribute Name="LastUKnotIndex" ReadOnly="true">
74
            <Documentation>
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>
78
            </Documentation>
79
            <Parameter Name="LastUKnotIndex" Type="Object"/>
80
        </Attribute>
81
        <Attribute Name="KnotSequence" ReadOnly="true">
82
            <Documentation>
83
                <UserDocu>Returns the knots sequence of this B-Spline curve.</UserDocu>
84
            </Documentation>
85
            <Parameter Name="KnotSequence" Type="List"/>
86
        </Attribute>
87
        <Methode Name="isRational" Const="true">
88
            <Documentation>
89
                <UserDocu>
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.
93
                </UserDocu>
94
            </Documentation>
95
        </Methode>
96
        <Methode Name="isPeriodic" Const="true">
97
            <Documentation>
98
                <UserDocu>Returns true if this BSpline curve is periodic.</UserDocu>
99
            </Documentation>
100
        </Methode>
101
        <Methode Name="isClosed" Const="true">
102
            <Documentation>
103
                <UserDocu>
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().
106
                </UserDocu>
107
            </Documentation>
108
        </Methode>
109
        <Methode Name="increaseDegree">
110
            <Documentation>
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>
116
            </Documentation>
117
        </Methode>
118
        <Methode Name="increaseMultiplicity">
119
            <Documentation>
120
                <UserDocu>
121
                increaseMultiplicity(int index, int mult)
122
                increaseMultiplicity(int start, int end, int mult)
123
                Increases multiplicity of knots up to mult.
124

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.
128
                </UserDocu>
129
            </Documentation>
130
        </Methode>
131
        <Methode Name="incrementMultiplicity">
132
            <Documentation>
133
                <UserDocu>
134
                incrementMultiplicity(int start, int end, int mult)
135
                Raises multiplicity of knots by mult.
136

137
                start, end: index range of knots to modify.
138
                </UserDocu>
139
            </Documentation>
140
        </Methode>
141
        <Methode Name="insertKnot">
142
            <Documentation>
143
                <UserDocu>
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>
147
            </Documentation>
148
        </Methode>
149
        <Methode Name="insertKnots">
150
            <Documentation>
151
                <UserDocu>
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.
154

155
                For each u = list_of_floats[i], mult = list_of_ints[i]
156

157
                If u is an existing knot the multiplicity is increased by mult if bool_add is
158
                True, otherwise increased to mult.
159

160
                If u is not on the parameter range nothing is done.
161

162
                If the multiplicity is negative or null nothing is done. The new multiplicity
163
                is limited to the degree.
164

165
                The tolerance criterion for knots equality is the max of Epsilon(U) and ParametricTolerance.
166
                </UserDocu>
167
            </Documentation>
168
        </Methode>
169
        <Methode Name="removeKnot">
170
            <Documentation>
171
                <UserDocu>
172
                    removeKnot(Index, M, tol)
173

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.
183

184
                    A low tolerance is used to prevent modification of the curve.
185
                    A high tolerance is used to 'smooth' the curve.
186
                </UserDocu>
187
            </Documentation>
188
        </Methode>
189
        <Methode Name="segment">
190
            <Documentation>
191
                <UserDocu>
192
                    segment(u1,u2)
193
                    Modifies this B-Spline curve by segmenting it.</UserDocu>
194
            </Documentation>
195
        </Methode>
196
        <Methode Name="setKnot">
197
            <Documentation>
198
                <UserDocu>Set a knot of the B-Spline curve.</UserDocu>
199
            </Documentation>
200
        </Methode>
201
        <Methode Name="getKnot" Const="true">
202
            <Documentation>
203
                <UserDocu>Get a knot of the B-Spline curve.</UserDocu>
204
            </Documentation>
205
        </Methode>
206
        <Methode Name="setKnots">
207
            <Documentation>
208
                <UserDocu>Set knots of the B-Spline curve.</UserDocu>
209
            </Documentation>
210
        </Methode>
211
        <Methode Name="getKnots" Const="true">
212
            <Documentation>
213
                <UserDocu>Get all knots of the B-Spline curve.</UserDocu>
214
            </Documentation>
215
        </Methode>
216
        <Methode Name="setPole">
217
            <Documentation>
218
                <UserDocu>Modifies this B-Spline curve by assigning P
219
to the pole of index Index in the poles table.</UserDocu>
220
            </Documentation>
221
        </Methode>
222
        <Methode Name="getPole" Const="true">
223
            <Documentation>
224
                <UserDocu>Get a pole of the B-Spline curve.</UserDocu>
225
            </Documentation>
226
        </Methode>
227
        <Methode Name="getPoles" Const="true">
228
            <Documentation>
229
                <UserDocu>Get all poles of the B-Spline curve.</UserDocu>
230
            </Documentation>
231
        </Methode>
232
        <Methode Name="setWeight">
233
            <Documentation>
234
                <UserDocu>Set a weight of the B-Spline curve.</UserDocu>
235
            </Documentation>
236
        </Methode>
237
        <Methode Name="getWeight" Const="true">
238
            <Documentation>
239
                <UserDocu>Get a weight of the B-Spline curve.</UserDocu>
240
            </Documentation>
241
        </Methode>
242
        <Methode Name="getWeights" Const="true">
243
            <Documentation>
244
                <UserDocu>Get all weights of the B-Spline curve.</UserDocu>
245
            </Documentation>
246
        </Methode>
247
        <Methode Name="getPolesAndWeights" Const="true">
248
            <Documentation>
249
                <UserDocu>Returns the table of poles and weights in homogeneous coordinates.</UserDocu>
250
            </Documentation>
251
        </Methode>
252
        <Methode Name="getResolution" Const="true">
253
            <Documentation>
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
257
ensures that:
258
|t1-t0| &lt; UTolerance =""==&gt; |f(t1)-f(t0)| &lt; Tolerance3D</UserDocu>
259
            </Documentation>
260
        </Methode>
261
        <Methode Name="movePoint">
262
            <Documentation>
263
                <UserDocu>
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.
268

269
Returns: (FirstModifiedPole, LastModifiedPole). They are the indexes of the
270
first and last poles which are effectively modified.</UserDocu>
271
            </Documentation>
272
        </Methode>
273
        <Methode Name="setNotPeriodic">
274
            <Documentation>
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>
277
            </Documentation>
278
        </Methode>
279
        <Methode Name="setPeriodic">
280
            <Documentation>
281
                <UserDocu>Changes this B-Spline curve into a periodic curve.</UserDocu>
282
            </Documentation>
283
        </Methode>
284
        <Methode Name="setOrigin">
285
            <Documentation>
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>
289
            </Documentation>
290
        </Methode>
291
        <Methode Name="getMultiplicity" Const="true">
292
            <Documentation>
293
                <UserDocu>Returns the multiplicity of the knot of index
294
from the knots table of this B-Spline curve.</UserDocu>
295
            </Documentation>
296
        </Methode>
297
        <Methode Name="getMultiplicities" Const="true">
298
            <Documentation>
299
                <UserDocu>
300
                    Returns the multiplicities table M of the knots of this B-Spline curve.
301
                </UserDocu>
302
            </Documentation>
303
        </Methode>
304
        <Methode Name="approximate" Keyword="true">
305
            <Documentation>
306
                <UserDocu>
307
                    Replaces this B-Spline curve by approximating a set of points.
308
                    The function accepts keywords as arguments.
309

310
                    approximate(Points = list_of_points)
311

312
                    Optional arguments :
313

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'
319

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).
326

327
                    Parameters = list of floats : knot sequence of the approximated points.
328
                    This argument is only used if the weights above are all null.
329

330
                    ParamType = string ('Uniform','Centripetal' or 'ChordLength')
331
                    Parameterization type. Only used if weights and Parameters above aren't specified.
332

333
                    Note : Continuity of the spline defaults to C2. However, it may not be applied if
334
                    it conflicts with other parameters ( especially DegMax ).
335
                </UserDocu>
336
            </Documentation>
337
        </Methode>
338
        <Methode Name="getCardinalSplineTangents" Keyword="true" Const="true">
339
            <Documentation>
340
                <UserDocu>Compute the tangents for a Cardinal spline</UserDocu>
341
            </Documentation>
342
        </Methode>
343
        <Methode Name="interpolate" Keyword="true">
344
            <Documentation>
345
                <UserDocu>
346
                    Replaces this B-Spline curve by interpolating a set of points.
347
                    The function accepts keywords as arguments.
348

349
                    interpolate(Points = list_of_points)
350

351
                    Optional arguments :
352

353
                    PeriodicFlag = bool (False) : Sets the curve closed or opened.
354
                    Tolerance = float (1e-6) : interpolating tolerance
355

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.
359

360
                    EndPoint Tangent constraints :
361

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.
365

366
                    Full Tangent constraints :
367

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.
373

374
                    Note : Continuity of the spline defaults to C2. However, if periodic, or tangents
375
                    are supplied, the continuity will drop to C1.
376
                </UserDocu>
377
            </Documentation>
378
        </Methode>
379
        <Methode Name="buildFromPoles">
380
            <Documentation>
381
                <UserDocu>
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)]
384

385
                    Examples:
386
                    from FreeCAD import Base
387
                    import Part
388
                    V = Base.Vector
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)]
390

391
                    # non-periodic spline
392
                    n=Part.BSplineCurve()
393
                    n.buildFromPoles(poles)
394
                    Part.show(n.toShape())
395

396
                    # periodic spline
397
                    n=Part.BSplineCurve()
398
                    n.buildFromPoles(poles, True)
399
                    Part.show(n.toShape())
400
                </UserDocu>
401
            </Documentation>
402
        </Methode>
403
    <Methode Name="buildFromPolesMultsKnots" Keyword="true">
404
        <Documentation>
405
            <UserDocu>
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]
408

409
                Examples:
410
                from FreeCAD import Base
411
                import Part
412
                V=Base.Vector
413
                poles=[V(-10,-10),V(10,-10),V(10,10),V(-10,10)]
414

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())
419

420
                # periodic spline
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())
424

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())
429
            </UserDocu>
430
        </Documentation>
431
    </Methode>
432
        <Methode Name="toBezier" Const="true">
433
            <Documentation>
434
                <UserDocu>
435
                    Build a list of Bezier splines.
436
                </UserDocu>
437
            </Documentation>
438
        </Methode>
439
        <Methode Name="toBiArcs" Const="true">
440
            <Documentation>
441
                <UserDocu>
442
                    Build a list of arcs and lines to approximate the B-spline.
443
                    toBiArcs(tolerance) -> list.
444
                </UserDocu>
445
            </Documentation>
446
        </Methode>
447
        <Methode Name="join">
448
            <Documentation>
449
                <UserDocu>
450
                    Build a new spline by joining this and a second spline.
451
                </UserDocu>
452
            </Documentation>
453
        </Methode>
454
        <Methode Name="makeC1Continuous">
455
            <Documentation>
456
                <UserDocu>
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.
464
                </UserDocu>
465
            </Documentation>
466
        </Methode>
467
        <Methode Name="scaleKnotsToBounds">
468
            <Documentation>
469
                <UserDocu>
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)
474
                </UserDocu>
475
            </Documentation>
476
        </Methode>
477
    </PythonExport>
478
</GenerateModel>
479

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.