vtkTexturedSphereSource创建一个中心点在原点球体的。在两个(φ)的纬度和经度(θ)方向上,可以分别设定分辨率(多边形离散化)。它也可以通过指定部分领域最大φ和θ波的角度,创建半球体。
基本方法:
SetRadius(20) 设置球体直径
SetThetaResolution(40) 设置维度上的分辨率
SetPhiResolution(40)设置经度上的分辨率
SetTheta(100)设置最大的经度角
SetPhi(10)设置最大的维度角
例子:
#-*- coding: UTF-8 -*- #------------------------------------------------------------------------------- # Name: 模块2 # Purpose: # # Author: ankier # # Created: 12-12-2012 # Copyright: (c) Ankier 2012 # Licence: <your licence> #------------------------------------------------------------------------------- from ActorFactory import ActorFactory from vtk import * ## @detal 创建球体的actory factory class TexturedSphereActorFactory(ActorFactory): def __init__(self): ActorFactory.__init__(self) self.__TexturedSphereSource = vtkTexturedSphereSource() def _MakeActors(self): self.__TexturedSphereSource.SetRadius(20) self.__TexturedSphereSource.SetThetaResolution(40) self.__TexturedSphereSource.SetPhiResolution(40) self.__TexturedSphereSource.SetTheta(100) self.__TexturedSphereSource.SetPhi(10) polyDataMapper = vtkPolyDataMapper() polyDataMapper.SetInput(self.__TexturedSphereSource.GetOutput()) actor = self._NewActor() actor.SetMapper(polyDataMapper) actor.GetProperty().SetColor((1.0, 0.7, 0.2)) actor.SetPosition(-27.0, 0, 0) return [actor] def __del__(self): del self.__TexturedSphereSource
运行效果图: