code: def evolve_visual3d(msnake, fig=None, levelset=None, num_iters=20,
                      animate_ui=True, animate_delay=250):
      
      from mayavi import mlab
  
      if levelset is not None:
          msnake.levelset = levelset
  
      if fig is None:
          fig = mlab.gcf()
      mlab.clf()
      src = mlab.pipeline.scalar_field(msnake.data)
      mlab.pipeline.image_plane_widget(src, plane_orientation='x_axes', colormap='gray')
      cnt = mlab.contour3d(msnake.levelset, contours=[0.5])
      
      @mlab.animate(ui=animate_ui, delay=animate_delay)
      def anim():
          for i in range(num_iters):
              msnake.step()
              cnt.mlab_source.scalars = msnake.levelset
              print("Iteration %i/%i..." % (i + 1, num_iters))
              yield
      
      anim()
      mlab.show()
      
      # Return the last levelset.
      return msnake.levelset
docs: Visual evolution of a three-dimensional morphological snake.
      
      Parameters
      ----------
      msnake : MorphGAC or MorphACWE instance
          The morphological snake solver.
      fig: object, optional
          Handles to actual figure.
      levelset : array-like, optional
          If given, the levelset of the solver is initialized to this. If not
          given, the evolution will use the levelset already set in msnake.
      num_iters : int, optional
          The number of iterations.
      animate_ui : bool, optional
          Show the animation interface
      animate_delay : int, optional
          The number of delay between frames.