[vtk] flipped normals question

Randy Heiland heiland at ncsa.uiuc.edu
Wed Oct 6 07:37:40 EDT 1999


In case anyone cares, I solved my problem...
basically, instead of doing a SetUserMatrix on an actor, one can use
vtkTransformPolyDataFilter instead, as the following Python script illustrates:

#!/usr/local/bin/python

from libVTKCommonPython import *
from libVTKGraphicsPython import *

ren = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(300,300)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

cone = vtkConeSource()
cone.SetResolution(8)

coneMapper = vtkPolyDataMapper()
coneMapper.SetInput(cone.GetOutput())

coneActor = vtkActor()
coneActor.SetMapper(coneMapper)

# ---- now do its evil inverse twin
xform=vtkTransform()
xform.Identity()
xform.Translate(2,0,0)
xform.Scale(1,1,-1)

xformFilter = vtkTransformPolyDataFilter()
xformFilter.SetInput(cone.GetOutput())
xformFilter.SetTransform(xform)

normals = vtkPolyDataNormals()
normals.SetInput(xformFilter.GetOutput())
normals.FlipNormalsOn()

coneInvMapper = vtkPolyDataMapper()
coneInvMapper.SetInput(normals.GetOutput())
coneInvMapper.ScalarVisibilityOff()

coneInvActor = vtkActor()
coneInvActor.SetMapper(coneInvMapper)
coneInvActor.GetProperty().SetColor(1,0,0)
#coneInvActor.SetUserMatrix(xform.GetMatrix())

#----------
ren.AddActor(coneActor)
ren.AddActor(coneInvActor)

iren.Initialize()
iren.Start()



On Oct 5,  5:05pm, Randy Heiland wrote:
> Subject: [vtk] flipped normals question
> When I apply a vtkTransform with a negative Scale component to an Actor, it
> seems to "lose its normals" (ever have days like that?) -- at least the
> transformed actor isn't lit (but you can see it by going into wireframe).
>
> Included is a simple Python script; below it, a similar Tcl script where I've
> tried introducing flipped normals, etc..  What am I missing?
>
> thanks,
> --Randy
>
> ----------------------------------------------------------
> #!/usr/local/bin/python
>
> from libVTKCommonPython import *
> from libVTKGraphicsPython import *
>
> ren = vtkRenderer()
> renWin = vtkRenderWindow()
> renWin.AddRenderer(ren)
> renWin.SetSize(300,300)
> iren = vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
>
> cone = vtkConeSource()
> cone.SetResolution(8)
> coneMapper = vtkPolyDataMapper()
> coneMapper.SetInput(cone.GetOutput())
>
> coneActor = vtkActor()
> coneActor.SetMapper(coneMapper)
>
> xform=vtkTransform()
> xform.Identity()
> xform.Translate(2,0,0)
> xform.Scale(1,1,-1)
>
> coneFlipActor = vtkActor()
> coneFlipActor.SetMapper(coneMapper)
> coneFlipActor.GetProperty().SetColor(1,0,0)
> coneFlipActor.SetUserMatrix(xform.GetMatrix())
>
> ren.AddActor(coneActor)
> ren.AddActor(coneFlipActor)
>
>
> # enable user interface interactor
> iren.Initialize()
>
> iren.Start()
> ----------------------------------------------------------




-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list