vtk类之vtkPointSource:创建一些点集合围成的球体poly data

vtkPointSource用来创建围绕特定中心点,特定直径的和特定数量点集合组成的球体。默认点是随机分布在球体里面。也可以生产的点只分布在球面上。

基本用法:

SetRadius()设置球体半径
SetCenter()设置球体中心点
SetNumberOfPoints()设置球中的点的个数
SetDistributionToUniform()设置点的分布在球体内

SetDistributionToShell()设置点分布在球面上。
 

例子:

#-*- 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 生产点的球体集合
class PointActorFactory(ActorFactory):
    def __init__(self):
        ActorFactory.__init__(self)        
        self.__PointSource = vtkPointSource()        
        
    def _MakeActors(self):
        self.__PointSource.SetRadius(20)
        self.__PointSource.SetCenter(0, 0, 0)
        self.__PointSource.SetNumberOfPoints(10000)
        self.__PointSource.SetDistributionToUniform()
#        self.__PointSource.SetDistributionToShell()
        
        polyDataMapper = vtkPolyDataMapper()
        polyDataMapper.SetInput(self.__PointSource.GetOutput())
        
        actor = self._NewActor()
        actor.SetMapper(polyDataMapper)
        actor.GetProperty().SetColor((1.0, 0.7, 0.2))
        
        return [actor]
    
    def __del__(self):
        del self.__PointSource

运行结果:

 

posted on 2012-12-10 21:21  |残阳|露  阅读(1966)  评论(0编辑  收藏  举报

导航