Utah TeapotΒΆ

../../_images/teapot1.png

View of the Utah Teapot test model using an obj format file with Matplotlib rendering.

To smooth the interface between the neck and body of the teapot, the surface was triangulated, indicated in the highlighted line.

import matplotlib.pyplot as plt
import s3dlib.surface as s3d

# Utah Teapot Obj datafile

# Setup surface ................................................

surface = s3d.get_surfgeom_from_obj("data/utah_teapot.obj")
presurf = str(surface)
surface.triangulate(2)
surface.map_cmap_from_op()
label = presurf +'\n' + str(surface)

# Construct figure, add surface, plot ..........................

fig = plt.figure(figsize=plt.figaspect(1))
fig.text(0.975,0.975,label, ha='right', va='top', fontsize='smaller', multialignment='right')
ax = plt.axes(projection='3d')
ax.set_axis_off()

s3d.auto_scale(ax,surface,uscale=.55)
ax.add_collection3d(surface.shade().hilite())

fig.tight_layout(pad=0)

plt.show()