VTK-class vtktexturemaptocylinder: texture ing algorithm, ing of the cylindrical texture

Source: Internet
Author: User
Tags xform
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.