Skip to content

Commit aab53b0

Browse files
author
Onur Rauf Bingol
committed
Code reorganization
1 parent 615f91b commit aab53b0

33 files changed

+118
-117
lines changed

bezier/ex_bezier_curve2d.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
Examples for the NURBS-Python Package
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2018
8+
9+
2nd degree and 3rd degree 2-dimensional Bezier curves
810
"""
11+
912
import os
1013
from geomdl import BSpline
1114
from geomdl import utilities
12-
13-
# Try to load the visualization module
14-
try:
15-
render_curve = True
16-
from geomdl.visualization import VisMPL
17-
except ImportError:
18-
render_curve = False
15+
from geomdl.visualization import VisMPL
1916

2017
# Fix file path
2118
os.chdir(os.path.dirname(os.path.realpath(__file__)))
@@ -41,10 +38,9 @@
4138
curve1.evaluate()
4239

4340
# Draw the control point polygon and the evaluated curve
44-
if render_curve:
45-
vis_comp1 = VisMPL.VisCurve2D()
46-
curve1.vis = vis_comp1
47-
curve1.render()
41+
vis_comp1 = VisMPL.VisCurve2D()
42+
curve1.vis = vis_comp1
43+
curve1.render()
4844

4945
#
5046
# 2D CURVE 2
@@ -67,7 +63,8 @@
6763
curve2.evaluate()
6864

6965
# Draw the control point polygon and the evaluated curve
70-
if render_curve:
71-
vis_comp2 = VisMPL.VisCurve2D()
72-
curve2.vis = vis_comp2
73-
curve2.render()
66+
vis_comp2 = VisMPL.VisCurve2D()
67+
curve2.vis = vis_comp2
68+
curve2.render()
69+
70+
pass

bezier/ex_bezier_curve3d.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
Examples for the NURBS-Python Package
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2018
8+
9+
3rd degree 3-dimensional Bezier curve
810
"""
11+
912
import os
1013
from geomdl import BSpline
1114
from geomdl import utilities
@@ -36,3 +39,5 @@
3639

3740
# Don't pop up the plot window, instead save it as a PDF file
3841
curve.render(filename="bezier.pdf", plot=False)
42+
43+
pass

bezier/ex_bezier_surface.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
Examples for the NURBS-Python Package
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2018
8+
9+
A cubic-quadratic Bezier surface
810
"""
11+
912
import os
1013
from geomdl import BSpline
1114
from geomdl import utilities
@@ -38,3 +41,5 @@
3841
vis_comp = VisMPL.VisSurface()
3942
surf.vis = vis_comp
4043
surf.render()
44+
45+
pass

compat/ex_convert01.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
Examples for the NURBS-Python Package
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2018
8+
9+
Demonstration of the compatibility module
810
"""
911

1012
from geomdl import NURBS

curve2d/ex_curve01.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2016-2018
88
"""
9+
910
import os
1011
from geomdl import BSpline
1112
from geomdl import utilities

curve2d/ex_curve01_split.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2018
88
"""
9+
910
import os
1011
from geomdl import BSpline
1112
from geomdl import utilities
1213
from geomdl import exchange
14+
from geomdl.visualization import VisMPL
1315

14-
# Try to load the visualization module
15-
try:
16-
render_curve = True
17-
from geomdl.visualization import VisMPL
18-
except ImportError:
19-
render_curve = False
2016

2117
# Fix file path
2218
os.chdir(os.path.dirname(os.path.realpath(__file__)))
@@ -42,10 +38,10 @@
4238
# Plot the curves using the curve container
4339
curves.sample_size = 40
4440

45-
if render_curve:
46-
vis_comp = VisMPL.VisCurve2D()
47-
curves.vis = vis_comp
48-
curves.render()
41+
# Plot the curve
42+
vis_comp = VisMPL.VisCurve2D()
43+
curves.vis = vis_comp
44+
curves.render()
4945

5046
# Good to have something here to put a breakpoint
5147
pass

curve2d/ex_curve02.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2016-2018
88
"""
9+
910
import os
1011
from geomdl import BSpline
1112
from geomdl import utilities
1213
from geomdl import exchange
1314
from geomdl import evaluators
15+
from geomdl.visualization import VisMPL
1416

15-
# Try to load the visualization module
16-
try:
17-
render_curve = True
18-
from geomdl.visualization import VisMPL
19-
except ImportError:
20-
render_curve = False
2117

2218
# Fix file path
2319
os.chdir(os.path.dirname(os.path.realpath(__file__)))
@@ -38,11 +34,10 @@
3834
# Evaluate curve
3935
curve.evaluate()
4036

41-
# Draw the control point polygon and the evaluated curve
42-
if render_curve:
43-
vis_comp = VisMPL.VisCurve2D()
44-
curve.vis = vis_comp
45-
curve.render()
37+
# Plot the control point polygon and the evaluated curve
38+
vis_comp = VisMPL.VisCurve2D()
39+
curve.vis = vis_comp
40+
curve.render()
4641

4742
# Evaluate derivatives at u = 0.6
4843
ders1 = curve.derivatives(0.6, 4)

curve2d/ex_curve02_decompose.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@
1010
from geomdl import BSpline
1111
from geomdl import utilities
1212
from geomdl import exchange
13+
from geomdl.visualization import VisMPL
1314

14-
# Try to load the visualization module
15-
try:
16-
render_curve = True
17-
from geomdl.visualization import VisMPL
18-
except ImportError:
19-
render_curve = False
2015

2116
# Fix file path
2217
os.chdir(os.path.dirname(os.path.realpath(__file__)))
@@ -43,13 +38,13 @@
4338
c2tanvec2 = [1 * p for p in c2tan2[1]]
4439
bezier[2].translate(c2tanvec2)
4540

46-
# Plot the curves using the curve container
41+
# Set sample size of the Bezier curves
4742
bezier.sample_size = 20
4843

49-
if render_curve:
50-
vis_comp = VisMPL.VisCurve2D()
51-
bezier.vis = vis_comp
52-
bezier.render()
44+
# Plot the Bezier curves
45+
vis_comp = VisMPL.VisCurve2D()
46+
bezier.vis = vis_comp
47+
bezier.render()
5348

5449
# Good to have something here to put a breakpoint
5550
pass

curve2d/ex_curve02_split.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2018
88
"""
9+
910
import os
1011
from geomdl import BSpline
1112
from geomdl import utilities
1213
from geomdl import Multi
1314
from geomdl import exchange
15+
from geomdl.visualization import VisMPL
1416

15-
# Try to load the visualization module
16-
try:
17-
render_curve = True
18-
from geomdl.visualization import VisMPL
19-
except ImportError:
20-
render_curve = False
2117

2218
# Fix file path
2319
os.chdir(os.path.dirname(os.path.realpath(__file__)))
@@ -45,10 +41,10 @@
4541
curves.sample_size = 40
4642
curves.add(curve1)
4743
curves.add(curve2)
48-
if render_curve:
49-
vis_comp = VisMPL.VisCurve2D()
50-
curves.vis = vis_comp
51-
curves.render()
44+
45+
vis_comp = VisMPL.VisCurve2D()
46+
curves.vis = vis_comp
47+
curves.render()
5248

5349
# Good to have something here to put a breakpoint
5450
pass

curve2d/ex_curve04_convert3d.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2018
88
"""
9+
910
import os
1011
from geomdl import NURBS
1112
from geomdl import exchange
13+
from geomdl.visualization import VisMPL
1214

13-
# Try to load the visualization module
14-
try:
15-
render_curve = True
16-
from geomdl.visualization import VisMPL
17-
except ImportError:
18-
render_curve = False
1915

2016
# Fix file path
2117
os.chdir(os.path.dirname(os.path.realpath(__file__)))
@@ -38,12 +34,11 @@
3834
# Translate curve to z = 5
3935
curve3d.translate((0, 0, 5))
4036

41-
# Draw the control point polygon and the evaluated curve
42-
if render_curve:
43-
vis_config = VisMPL.VisConfig(ctrlpts=True)
44-
vis_comp = VisMPL.VisCurve3D(vis_config)
45-
curve3d.vis = vis_comp
46-
curve3d.render()
37+
# Plot the control point polygon and the evaluated curve
38+
vis_config = VisMPL.VisConfig(ctrlpts=True)
39+
vis_comp = VisMPL.VisCurve3D(vis_config)
40+
curve3d.vis = vis_comp
41+
curve3d.render()
4742

4843
# Good to have something here to put a breakpoint
4944
pass

curve2d/ex_curve04_decompose.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2017
88
"""
9+
910
import os
1011
from geomdl import NURBS
1112
from geomdl import exchange
13+
from geomdl.visualization import VisMPL
1214

13-
# Try to load the visualization module
14-
try:
15-
render_curve = True
16-
from geomdl.visualization import VisMPL
17-
except ImportError:
18-
render_curve = False
1915

2016
# Fix file path
2117
os.chdir(os.path.dirname(os.path.realpath(__file__)))
@@ -35,14 +31,14 @@
3531
# Decompose the curve into Bezier curve segments
3632
bezier = curve.decompose()
3733

38-
# Plot the curves using the curve container
34+
# Set sample size of the Bezier curves
3935
bezier.sample_size = 20
4036

41-
if render_curve:
42-
vis_config = VisMPL.VisConfig(figure_size=[8, 8])
43-
vis_comp = VisMPL.VisCurve2D(vis_config)
44-
bezier.vis = vis_comp
45-
bezier.render()
37+
# Plot the Bezier curves
38+
vis_config = VisMPL.VisConfig(figure_size=[8, 8])
39+
vis_comp = VisMPL.VisCurve2D(vis_config)
40+
bezier.vis = vis_comp
41+
bezier.render()
4642

4743
# Good to have something here to put a breakpoint
4844
pass

curve2d/ex_curve05_clamped.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2018
88
"""
9+
910
import os
1011
from geomdl import BSpline
11-
from geomdl import utilities
12+
from geomdl.visualization import VisMPL
1213

13-
# Try to load the visualization module
14-
try:
15-
render_curve = True
16-
from geomdl.visualization import VisMPL
17-
except ImportError:
18-
render_curve = False
1914

2015
# Fix file path
2116
os.chdir(os.path.dirname(os.path.realpath(__file__)))
@@ -38,11 +33,10 @@
3833
# Evaulate curve
3934
curve.evaluate()
4035

41-
# Draw the control point polygon and the evaluated curve
42-
if render_curve:
43-
vis_comp = VisMPL.VisCurve2D()
44-
curve.vis = vis_comp
45-
curve.render()
36+
# Plot the control point polygon and the evaluated curve
37+
vis_comp = VisMPL.VisCurve2D()
38+
curve.vis = vis_comp
39+
curve.render()
4640

4741
# Good to have something here to put a breakpoint
4842
pass

curve2d/ex_curve05_periodic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
Released under MIT License
77
Developed by Onur Rauf Bingol (c) 2018
88
"""
9+
910
import os
1011
from geomdl import BSpline
1112
from geomdl import utilities
1213
from geomdl.visualization import VisMPL
1314

15+
1416
# Fix file path
1517
os.chdir(os.path.dirname(os.path.realpath(__file__)))
1618

0 commit comments

Comments
 (0)