vtk类之vtkShrinkFilter :收缩构成对其质心任意数据集的单元格,返回vtkUnstructuredGrid数据集

收缩构成一个任意的数据集的单元格

vtkShrinkFilter 收缩构成对其质心任意数据集的单元格。单元格点的平均位置作为计算单元的质心。萎缩中断开另一个单元格的结果。此筛选器的输出是的一般数据集类型 vtkUnstructuredGrid。

警告:

它是可能打开细胞里面翻出来,或在特殊情况下造成自我交集。
例子:
#-*- coding: UTF-8 -*-
#-------------------------------------------------------------------------------
# Name:        模块2
# Purpose:
#
# Author:      ankier
#
# Created:     18-12-2012
# Copyright:   (c) Administrator 2012
# Licence:     <your licence>
#-------------------------------------------------------------------------------

from ActorFactory import ActorFactory

from vtk import *
## @detal 
class TransformActorFactory(ActorFactory):
    def __init__(self):
        ActorFactory.__init__(self)        
        self.__ElevationFilter = vtkElevationFilter()   
        
        self.__ElevationFilter.SetLowPoint(0, 0, -0.5)
        self.__ElevationFilter.SetHighPoint(0, 0, 0.5)     
        
    def _MakeActors(self):
        sphere = vtkSphereSource()
        sphere.SetThetaResolution(8)
        sphere.SetPhiResolution(8)
        sphere.SetRadius(20)
        transform = vtkTransform()
        transform.Scale(0.5, 1.5, 2.0)
        transformFilter = vtkTransformFilter()
        transformFilter.SetInput(sphere.GetOutput())
        transformFilter.SetTransform(transform)
        
        shrinkFilter = vtkShrinkFilter()
        shrinkFilter.SetInput(transformFilter.GetOutput())
        shrinkFilter.SetShrinkFactor(0.8)
        
        self.__ElevationFilter.SetInput(shrinkFilter.GetOutput())
        
        dataSetMapper = vtkDataSetMapper()
        dataSetMapper.SetInput(self.__ElevationFilter.GetOutput())
        actor = self._NewActor()
        actor.SetMapper(dataSetMapper)
        #actor.GetProperty().SetColor((0.5, 0.7, 0.2))
        
        return [actor]
    
    def __del__(self):
        del self.__EarthSource
        

运行结果:

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

导航