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


    产生映射点集合到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]

    运行结果:

  • 相关阅读:
    数据结构-栈与队列
    数据结构-选择排序
    数据结构-冒泡排序
    数据结构-插入排序
    mysql安装最后一步不响应解决
    ScvQ常用的网站(持续更新...)
    排序算法(二)
    排序算法(一)
    原码、反码、补码
    进制转换
  • 原文地址:https://www.cnblogs.com/ankier/p/2849934.html
Copyright © 2020-2023  润新知