Example #1
0
 def contour(self, surface, scalars, contours, width=1.0, opacity=1.0,
             vmin=None, vmax=None, colormap=None,
             normalized_colormap=False, kind='line', color=None):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore", category=FutureWarning)
         if colormap is not None:
             colormap = _get_colormap_from_array(colormap,
                                                 normalized_colormap)
         vertices = np.array(surface['rr'])
         triangles = np.array(surface['tris'])
         n_triangles = len(triangles)
         triangles = np.c_[np.full(n_triangles, 3), triangles]
         mesh = PolyData(vertices, triangles)
         mesh.point_arrays['scalars'] = scalars
         contour = mesh.contour(isosurfaces=contours)
         line_width = width
         if kind == 'tube':
             contour = contour.tube(radius=width, n_sides=self.tube_n_sides)
             line_width = 1.0
         actor = _add_mesh(
             plotter=self.plotter,
             mesh=contour,
             show_scalar_bar=False,
             line_width=line_width,
             color=color,
             rng=[vmin, vmax],
             cmap=colormap,
             opacity=opacity,
             smooth_shading=self.figure.smooth_shading
         )
         return actor, contour
Example #2
0
 def contour(self,
             surface,
             scalars,
             contours,
             line_width=1.0,
             opacity=1.0,
             vmin=None,
             vmax=None,
             colormap=None,
             normalized_colormap=False):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore", category=FutureWarning)
         from pyvista import PolyData
         cmap = _get_colormap_from_array(colormap, normalized_colormap)
         vertices = np.array(surface['rr'])
         triangles = np.array(surface['tris'])
         n_triangles = len(triangles)
         triangles = np.c_[np.full(n_triangles, 3), triangles]
         pd = PolyData(vertices, triangles)
         pd.point_arrays['scalars'] = scalars
         self.plotter.add_mesh(pd.contour(isosurfaces=contours,
                                          rng=(vmin, vmax)),
                               show_scalar_bar=False,
                               line_width=line_width,
                               cmap=cmap,
                               opacity=opacity,
                               smooth_shading=self.figure.smooth_shading)