Skip to content

Commit 297a8b2

Browse files
committed
Add visualization code to ex_curve04.py
1 parent 9f6d53f commit 297a8b2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

curve2d/ex_curve04.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
import os
1010
from geomdl import NURBS
1111

12+
# Try to load the visualization module
13+
try:
14+
render_curve = True
15+
from geomdl.visualization import VisMPL
16+
except ImportError:
17+
render_curve = False
18+
1219
# Fix file path
1320
os.chdir(os.path.dirname(os.path.realpath(__file__)))
1421

@@ -27,6 +34,13 @@
2734
# Evaluate curve
2835
curve.evaluate()
2936

37+
# Draw the control point polygon and the evaluated curve
38+
if render_curve:
39+
vis_comp = VisMPL.VisCurve2D(plot_ctrlpts=True)
40+
vis_comp.figure_size([8, 8])
41+
curve.vis = vis_comp
42+
curve.render()
43+
3044
# Save control points and evaluated curve points
3145
curve.save_curvepts_to_csv("curvepts04_orig.csv")
3246
curve.save_ctrlpts_to_csv("ctrlpts04_orig.csv")

0 commit comments

Comments
 (0)