Extrusion filters and Back faces
Randall Hopper
aa8vb at yahoo.com
Mon May 15 12:19:54 EDT 2000
While trying another method to generate a cylinder in VTK, another question
that came up pertains to assignment of front and back faces with polygons
generated by the extrusion filters.
The attached demo shows what I'm talking about. The half-cylinder was
generated via rotational extrusion of a line, and linear extrusion of
the resulting curve. Ideally I wanted just the inside of the cylinder to
be back facing, but one cap and one side were back faces as well.
What's the best way, during or after extrusion, to customize the front/back
facing status of polygons?
Thanks,
Randall
--
Randall Hopper
aa8vb at yahoo.com
-------------- next part --------------
#!/usr/bin/env python
"""
CylinderByExtrusion.py : Generate a half-cylinder using Extrusion filters
"""
import sys, string
from libVTKCommonPython import *
from libVTKGraphicsPython import *
from libVTKImagingPython import *
banana = ( 0.8900, 0.8100, 0.3400 )
peacock = ( 0.2000, 0.6300, 0.7900 )
#------------------------------------------------------------------------------
# Create the RenderWindow, Renderer, and Interactor
#
ren = vtkRenderer()
ren_win = vtkRenderWindow()
ren_win.AddRenderer( ren )
# Create interactor
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow( ren_win )
#iren.LightFollowCameraOn()
# Change interactor style
style = vtkInteractorStyleTrackball()
iren.SetInteractorStyle( style )
style.SetTrackballModeToTrackball()
#------------------------------------------------------------------------------
line = vtkLineSource()
line.SetPoint1( 1 , 0, 0 )
line.SetPoint2( 1.1, 0, 0 )
rot_extr = vtkRotationalExtrusionFilter()
rot_extr.SetInput( line.GetOutput() )
rot_extr.SetResolution( 50 )
rot_extr.SetAngle( 180 )
rot_extr.CappingOn()
lin_extr = vtkLinearExtrusionFilter()
lin_extr.SetInput( rot_extr.GetOutput() )
lin_extr.CappingOn()
cyl_trans = vtkTransform()
cyl_trans.Identity()
cyl_trans.RotateY( -30 )
cyl_trans.RotateX( -135 )
cyl_trans_filter = vtkTransformPolyDataFilter()
cyl_trans_filter.SetInput( lin_extr.GetOutput() )
cyl_trans_filter.SetTransform( cyl_trans )
mapper = vtkPolyDataMapper()
mapper.SetInput( cyl_trans_filter.GetOutput() )
mapper.ScalarVisibilityOff()
back = vtkProperty()
back.SetDiffuseColor( peacock )
actor = vtkLODActor()
actor.SetMapper( mapper )
actor.SetBackfaceProperty( back )
actor.GetProperty().SetDiffuseColor( banana )
ren.AddActor( actor )
ren.GetActiveCamera().Zoom(2)
ren.SetBackground( 0.2, 0.2, 0.8 )
ren_win.SetPosition( 0, 0 )
ren_win.SetSize( 640, 480 )
ren_win.Render()
# enable user interface interactor
iren.Initialize()
iren.Start()
More information about the vtkusers
mailing list