您的位置:首页 > 运维架构

vtk类之vtkTextureMapToPlane:纹理映射算法, 映射2D平面上的纹理

2013-01-07 19:32 681 查看
产生映射点集合到2D平面表面的纹理坐标
vtkTextureMapToPlane是一个筛选器,将 2D 纹理坐标生成映射输入的纹理数据集点至一个2D平面上。范围可以是用户指定或自动生成的。(2D平面是由自动生成计算2D平面的中心 )。请注意生成的纹理坐标 (0,1) 之间的范围。

实例:

#-*- coding: UTF-8 -*-
#-------------------------------------------------------------------------------
# Name:        模块2
# Purpose:
#
# Author:      ankier
#
# Created:     07-01-2013
# Copyright:   (c) Ankier 2013
# Licence:     <your licence>
#-------------------------------------------------------------------------------

from ActorFactory import ActorFactory
from vtk import *

class TextureMapToPlaneActorFactory(ActorFactory):
def __init__(self):
ActorFactory.__init__(self)
#定义一块板子
self.__PlaneSource = vtkPlaneSource()
self.__PlaneSource.SetOrigin(-50, -50, 0)
self.__PlaneSource.SetPoint1(50, -50 , 0)
self.__PlaneSource.SetPoint2(-50 , 50 , 0)
self.__PlaneSource.SetXResolution(50)
self.__PlaneSource.SetYResolution(50)

#设置板子的纹理映射类
self.__TexturePlane= vtkTextureMapToPlane()
self.__TexturePlane.SetInput(self.__PlaneSource.GetOutput())

#设置纹理类。
self.__Texture = vtkTexture()
self.__Texture.InterpolateOn()

#设置Poly Data,从纹理映射器重,得到被filter的输出数据
self.__PolyDataMapper = vtkPolyDataMapper()
self.__PolyDataMapper.SetInput(self.__TexturePlane.GetOutput())

def __del__(self):
del self.__PolyDataMapper
del self.__Texture

def __ReadJPEG(self):
read = vtkJPEGReader()
read.SetFileName("D:\\girl.jpg")
self.__Texture.SetInput(read.GetOutput())

def _MakeActors(self):
self.__ReadJPEG()
actor = self._NewActor()
actor.SetMapper(self.__PolyDataMapper)
actor.SetTexture(self.__Texture)
return [actor]


运行结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: