Exemplo n.º 1
0
 def sphere(self,
            center,
            color,
            scale,
            opacity=1.0,
            resolution=8,
            backface_culling=False,
            radius=None):
     factor = 1.0 if radius is not None else scale
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore", category=FutureWarning)
         sphere = vtk.vtkSphereSource()
         sphere.SetThetaResolution(resolution)
         sphere.SetPhiResolution(resolution)
         if radius is not None:
             sphere.SetRadius(radius)
         sphere.Update()
         geom = sphere.GetOutput()
         mesh = PolyData(np.array(center))
         glyph = mesh.glyph(orient=False,
                            scale=False,
                            factor=factor,
                            geom=geom)
         actor = _add_mesh(self.plotter,
                           mesh=glyph,
                           color=color,
                           opacity=opacity,
                           backface_culling=backface_culling,
                           smooth_shading=self.figure.smooth_shading)
         return actor, glyph
Exemplo n.º 2
0
 def sphere(self, center, color, scale, opacity=1.0,
            resolution=8, backface_culling=False,
            radius=None):
     factor = 1.0 if radius is not None else scale
     center = np.array(center, dtype=float)
     if len(center) == 0:
         return None, None
     _check_option('center.ndim', center.ndim, (1, 2))
     _check_option('center.shape[-1]', center.shape[-1], (3,))
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore", category=FutureWarning)
         sphere = vtk.vtkSphereSource()
         sphere.SetThetaResolution(resolution)
         sphere.SetPhiResolution(resolution)
         if radius is not None:
             sphere.SetRadius(radius)
         sphere.Update()
         geom = sphere.GetOutput()
         mesh = PolyData(center)
         glyph = mesh.glyph(orient=False, scale=False,
                            factor=factor, geom=geom)
         actor = _add_mesh(
             self.plotter,
             mesh=glyph, color=color, opacity=opacity,
             backface_culling=backface_culling,
             smooth_shading=self.smooth_shading
         )
         return actor, glyph
Exemplo n.º 3
0
 def sphere(self, center, color, scale, opacity=1.0,
            resolution=8, backface_culling=False):
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore", category=FutureWarning)
         from pyvista import PolyData
         sphere = vtk.vtkSphereSource()
         sphere.SetThetaResolution(resolution)
         sphere.SetPhiResolution(resolution)
         sphere.Update()
         geom = sphere.GetOutput()
         pd = PolyData(center)
         self.plotter.add_mesh(pd.glyph(orient=False, scale=False,
                                        factor=scale, geom=geom),
                               color=color, opacity=opacity,
                               backface_culling=backface_culling,
                               smooth_shading=self.figure.smooth_shading)