Skip to content

Commit e58f639

Browse files
author
Onur R. Bingol
committed
Update split and decompose examples
1 parent 6bdae2a commit e58f639

6 files changed

+19
-38
lines changed

curve2d/ex_curve01_decompose.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import os
1010
from geomdl import BSpline
1111
from geomdl import utilities
12-
from geomdl import Multi
1312

1413
# Try to load the visualization module
1514
try:
@@ -38,14 +37,12 @@
3837
bezier = curve.decompose()
3938

4039
# Plot the curves using the curve container
41-
curves = Multi.MultiCurve()
42-
curves.delta = 0.01
43-
curves.add_list(bezier)
40+
bezier.delta = 0.01
4441

4542
if render_curve:
4643
vis_comp = VisMPL.VisCurve2D()
47-
curves.vis = vis_comp
48-
curves.render()
44+
bezier.vis = vis_comp
45+
bezier.render()
4946

5047
# Good to have something here to put a breakpoint
5148
pass

curve2d/ex_curve01_split.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import os
1010
from geomdl import BSpline
1111
from geomdl import utilities
12-
from geomdl import Multi
1312

1413
# Try to load the visualization module
1514
try:
@@ -35,18 +34,16 @@
3534
curve.knotvector = utilities.generate_knot_vector(curve.degree, len(curve.ctrlpts))
3635

3736
# Split the curve
38-
curve1, curve2 = curve.split(0.6)
37+
curves = curve.split(0.6)
3938

4039
# Move the 1st curve a little bit far away from the 2nd curve
41-
c2tan = curve2.tangent(0.0, normalize=True)
40+
c2tan = curves[1].tangent(0.0, normalize=True)
4241
c2tanvec = [-3 * p for p in c2tan[1]]
43-
curve1.translate(c2tanvec)
42+
curves[0].translate(c2tanvec)
4443

4544
# Plot the curves using the curve container
46-
curves = Multi.MultiCurve()
4745
curves.delta = 0.01
48-
curves.add(curve1)
49-
curves.add(curve2)
46+
5047
if render_curve:
5148
vis_comp = VisMPL.VisCurve2D()
5249
curves.vis = vis_comp

curve2d/ex_curve02_decompose.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import os
1010
from geomdl import BSpline
1111
from geomdl import utilities
12-
from geomdl import Multi
1312

1413
# Try to load the visualization module
1514
try:
@@ -47,14 +46,12 @@
4746
bezier[2].translate(c2tanvec2)
4847

4948
# Plot the curves using the curve container
50-
curves = Multi.MultiCurve()
51-
curves.delta = 0.01
52-
curves.add_list(bezier)
49+
bezier.delta = 0.01
5350

5451
if render_curve:
5552
vis_comp = VisMPL.VisCurve2D()
56-
curves.vis = vis_comp
57-
curves.render()
53+
bezier.vis = vis_comp
54+
bezier.render()
5855

5956
# Good to have something here to put a breakpoint
6057
pass

curve2d/ex_curve04_decompose.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"""
99
import os
1010
from geomdl import NURBS
11-
from geomdl import Multi
1211

1312
# Try to load the visualization module
1413
try:
@@ -36,15 +35,13 @@
3635
bezier = curve.decompose()
3736

3837
# Plot the curves using the curve container
39-
curves = Multi.MultiCurve()
40-
curves.delta = 0.01
41-
curves.add_list(bezier)
38+
bezier.delta = 0.01
4239

4340
if render_curve:
4441
vis_comp = VisMPL.VisCurve2D()
4542
vis_comp.figure_size([8, 8])
46-
curves.vis = vis_comp
47-
curves.render()
43+
bezier.vis = vis_comp
44+
bezier.render()
4845

4946
# Good to have something here to put a breakpoint
5047
pass

curve3d/ex_curve3d01_split.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import os
1010
from geomdl import BSpline
1111
from geomdl import utilities
12-
from geomdl import Multi
1312

1413
# Try to load the visualization module
1514
try:
@@ -35,18 +34,15 @@
3534
curve.knotvector = utilities.generate_knot_vector(curve.degree, len(curve.ctrlpts))
3635

3736
# Split the curve
38-
curve1, curve2 = curve.split(0.3)
37+
curves = curve.split(0.3)
3938

4039
# Move the 1st curve a little bit far away from the 2nd curve
41-
c2tan = curve2.tangent(0.0, normalize=True)
40+
c2tan = curves[1].tangent(0.0, normalize=True)
4241
c2tanvec = [-1 * p for p in c2tan[1]]
43-
curve1.translate(c2tanvec)
42+
curves[0].translate(c2tanvec)
4443

4544
# Plot the curves using the curve container
46-
curves = Multi.MultiCurve()
4745
curves.delta = 0.01
48-
curves.add(curve1)
49-
curves.add(curve2)
5046
if render_curve:
5147
vis_comp = VisMPL.VisCurve3D()
5248
curves.vis = vis_comp

shapes/ex_circle2d_2.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
Developed by Onur Rauf Bingol (c) 2018
88
"""
99
from geomdl.shapes import curve2d
10-
from geomdl import Multi
1110

1211
# Try to load the visualization module
1312
try:
@@ -31,16 +30,14 @@
3130
bezier_segments = circle.decompose()
3231

3332
# Prepare Bezier segments for plotting
34-
curves = Multi.MultiCurve()
35-
curves.add_list(bezier_segments)
36-
curves.delta = 0.01
33+
bezier_segments.delta = 0.01
3734

3835
# Render the Bezier curve segments and their control points polygons
3936
if render:
4037
vis_comp = VisMPL.VisCurve2D(plot_ctrlpts=True)
4138
vis_comp.figure_size([9, 8])
42-
curves.vis = vis_comp
43-
curves.render()
39+
bezier_segments.vis = vis_comp
40+
bezier_segments.render()
4441

4542
# Good to have something here to put a breakpoint
4643
pass

0 commit comments

Comments
 (0)