NURBS-Python icon indicating copy to clipboard operation
NURBS-Python copied to clipboard

Visualization (VisMPL) is showing an empty figure

Open curiouscivilengineer opened this issue 2 years ago • 4 comments

Describe the bug I want to create NURBS/Bezier Surfaces with geomdl. I installed the package via conda and started by trying to run the example given here : https://nurbs-python.readthedocs.io/en/5.x/visualization.html

This is the given code: `from geomdl import BSpline from geomdl.visualization import VisMPL

ctrlpts = [ [[-25.0, -25.0, -10.0], [-25.0, -15.0, -5.0], [-25.0, -5.0, 0.0], [-25.0, 5.0, 0.0], [-25.0, 15.0, -5.0], [-25.0, 25.0, -10.0]], [[-15.0, -25.0, -8.0], [-15.0, -15.0, -4.0], [-15.0, -5.0, -4.0], [-15.0, 5.0, -4.0], [-15.0, 15.0, -4.0], [-15.0, 25.0, -8.0]], [[-5.0, -25.0, -5.0], [-5.0, -15.0, -3.0], [-5.0, -5.0, -8.0], [-5.0, 5.0, -8.0], [-5.0, 15.0, -3.0], [-5.0, 25.0, -5.0]], [[5.0, -25.0, -3.0], [5.0, -15.0, -2.0], [5.0, -5.0, -8.0], [5.0, 5.0, -8.0], [5.0, 15.0, -2.0], [5.0, 25.0, -3.0]], [[15.0, -25.0, -8.0], [15.0, -15.0, -4.0], [15.0, -5.0, -4.0], [15.0, 5.0, -4.0], [15.0, 15.0, -4.0], [15.0, 25.0, -8.0]], [[25.0, -25.0, -10.0], [25.0, -15.0, -5.0], [25.0, -5.0, 2.0], [25.0, 5.0, 2.0], [25.0, 15.0, -5.0], [25.0, 25.0, -10.0]] ] surf = BSpline.Surface()

surf.degree_u = 3 surf.degree_v = 3

surf.ctrlpts2d = ctrlpts

surf.knotvector_u = [0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0, 3.0] surf.knotvector_v = [0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0, 3.0]

surf.delta = 0.025

surf.evaluate()

from matplotlib import cm

surf.vis = VisMPL.VisSurface() surf.render(colormap=cm.cool)`

The code runs with without an error.

Expected Behavior It should look like this: image But it just looks like this: image

The example in 2D work without a problem but as soon as i try to plot a Curve or Surface in 3D it shows an empty figure.

Configuration:

  • OS: [Windows 11]
  • Python distribution: [Anaconda]
  • Python version: 3.10.10
  • geomdl install source: Anaconda
  • geomdl version/branch: 5.3.1
  • I also tried deleting and reinstalling both anaconda and geomdl, without succes

It would be really appreciate your help.

curiouscivilengineer avatar Apr 14 '23 14:04 curiouscivilengineer

I was able to fix it, temporarily at least, by replacing line 431 in visMPL.py,

ax = Axes3D(fig)

to

ax = fig.add_subplot( 111, projection='3d' )

jcs15c avatar May 23 '23 00:05 jcs15c

Thank you! Same problem and this also solve my issue :)

dalbenzioG avatar May 26 '23 17:05 dalbenzioG

Same and solved. Also, for anyone having the error that np.float is deprecated, just replace with the inbuilt float type as NumPy prompts and you're good.

Siltyx avatar Jun 02 '23 19:06 Siltyx

ax=Axes3D(fig);fig.add_axes(ax)

Lan998 avatar Oct 31 '23 08:10 Lan998