Generate texture coordinates from the ing point set to the surface of the cylinder
Vtktexturemaptocylinder is a filter that generates 2D texture coordinates and maps the input texture dataset to a cylindrical string. The range can be specified by the user or automatically generated. (A cylinder is the center of an automatically generated computing cylinder ). Note the range between the generated texture coordinates (0, 1.
Instance:
#-*-Coding: UTF-8-*-# features # Name: module 2 # purpose: # Author: ankier # created: # copyright: (c) ankier 2013 # licence: <your licence> # revoke from actorfactory import actorfactoryfrom VTK import * class texturemaptocylinderactorfactory (actorfactory): Def _ init _ (Self): actorfactory. _ init _ (Self) self. _ spheresource = vtkspheresource () self. _ spheresource. setthetaresolution (100) self. _ spheresource. setphiresolution (100) self. _ spheresource. setradius (10) # define a board plane1 = vtkplane () plane1.setnormal (0, 0, 1) plane1.setorigin (0, 0, 8) # define clip poly data clipper = vtkclippolydata () clipper. setinputconnection (self. _ spheresource. getoutputport ()) Clipper. setclipfunction (plane1) Clipper. insideoutoff () # normalization set data normals = vtkpolydatanormals () normals. setinputconnection (clipper. getoutputport () normals. flipnormalson () tmapper = vtktexturemaptocylinder () tmapper. setinput (normals. getoutput () tmapper. preventseamon () XForm = vtktransformtexturecoords () XForm. setinputconnection (tmapper. getoutputport () XForm. setscale (1, 1, 1) # Set poly data, from texture er weight, Obtain the output data self. _ polydatamapper = vtkpolydatamapper () self. _ polydatamapper. setinput (XForm. getoutput () # Set the texture class. Self. _ texture = vtktexture () self. _ texture. interpolateon () def _ readjpeg (Self): Read = vtkw.reader () read. setfilename ("D: \ girl.jpg") self. _ texture. setinput (read. getoutput () def _ del _ (Self): del self. _ spheresource del self. _ polydatamapper del self. _ texture def _ makeactors (Self): Self. _ readjpeg () actor = self. _ newactor () actor. setmapper (self. _ polydatamapper) actor. settexture (self. _ texture) return [Actor]
Running result: