[vtkusers] Actor color not changing with ThinkpLAteSplineTransformFilter
Jothy
jothybasu at gmail.com
Tue Aug 24 12:30:26 EDT 2010
Pass the output through a trianglr filterand then add to actor.
Cheers,
Jothy
On Tue, Aug 24, 2010 at 4:54 PM, Jothy <jothybasu at gmail.com> wrote:
> Hi all,
>
> Could anyone turn the black sphere into some other color!!
>
> Should I specify anythging to the DataSetMapper?
>
> Here is the code
>
> import vtk
> import numpy as np
>
> def CreateSphere(Theta,Phi,Radius):
> sphere=vtk.vtkSphereSource()
> sphere.SetThetaResolution(Theta)
> sphere.SetPhiResolution(Phi)
> sphere.SetRadius(Radius)
> #sphere.SetCenter(0,0,0)
> return sphere.GetOutput()
>
>
> CTV=CreateSphere(100,100,20)
> b=CTV.GetBounds()#CTVBounds
> SourcePoints=vtk.vtkPoints()
> SourcePoints.SetNumberOfPoints(8)
> SourcePoints.SetPoint( 0, b[0], b[3], b[5])
> SourcePoints.SetPoint( 1, b[1], b[3], b[5])
> SourcePoints.SetPoint( 2, b[0], b[3], b[4])
> SourcePoints.SetPoint( 3, b[1], b[3], b[4])
> SourcePoints.SetPoint( 4, b[0], b[2], b[5])
> SourcePoints.SetPoint( 5, b[1], b[2], b[5])
> SourcePoints.SetPoint( 6, b[0], b[2], b[4])
> SourcePoints.SetPoint( 7, b[1], b[2], b[4])
>
>
> TargetPoints=vtk.vtkPoints()
> TargetPoints.SetNumberOfPoints(8)
> xm,ym,zm,xp,yp,zp=10,10,10,20,20,20
> TargetPoints.SetPoint( 0, b[0]+xm, b[3]+yp, b[5]+zp )
> TargetPoints.SetPoint( 1, b[1]+xp, b[3]+yp, b[5]+zp )
> TargetPoints.SetPoint( 2, b[0]+xm, b[3]+yp, b[4]+zm )
> TargetPoints.SetPoint( 3, b[1]+xp, b[3]+yp, b[4]+zm )
> TargetPoints.SetPoint( 4, b[0]+xm, b[2]+ym, b[5]+zp )
> TargetPoints.SetPoint( 5, b[1]+xp, b[2]+ym, b[5]+zp )
> TargetPoints.SetPoint( 6, b[0]+xm, b[2]+ym, b[4]+zm )
> TargetPoints.SetPoint( 7, b[1]+xp, b[2]+ym, b[4]+zm )
>
>
>
> ThinPlateTransform=vtk.vtkThinPlateSplineTransform()
> ThinPlateTransform.SetSourceLandmarks(SourcePoints)
> ThinPlateTransform.SetTargetLandmarks(TargetPoints)
> ThinPlateTransform.SetBasisToR2LogR()
>
> GeneralTransform=vtk.vtkGeneralTransform()
> GeneralTransform.SetInput(ThinPlateTransform )
> #GeneralTransform.Concatenate(ThinPlateTransform.GetInverse())
> #GeneralTransform.Concatenate(ThinPlateTransform)
>
> TransformFilter = vtk.vtkTransformPolyDataFilter()
> TransformFilter.SetInput(CTV)
> TransformFilter.SetTransform(GeneralTransform )
>
> CTV.Modified()
> ThinPlateTransform.Modified()
>
> Mapper1=vtk.vtkDataSetMapper()
> Mapper1.SetInputConnection(TransformFilter.GetOutputPort())
>
> Mapper2=vtk.vtkDataSetMapper()
> Mapper2.SetInput(CTV)
>
>
> Actor1=vtk.vtkActor()
> Actor1.GetProperty().SetColor(1,1,0)
> Actor1.SetMapper(Mapper1)
>
>
> Actor2=vtk.vtkActor()
> Actor2.GetProperty().SetColor(1,1,0)
> Actor2.SetMapper(Mapper2)
>
> #Create a renderer, render window, and interactor
> renderer =vtk.vtkRenderer();
> renderWindow =vtk.vtkRenderWindow();
> renderWindow.AddRenderer(renderer);
> renderWindowInteractor =vtk.vtkRenderWindowInteractor();
> renderWindowInteractor.SetRenderWindow(renderWindow);
>
> #Add the actor to the scene
> renderer.AddActor(Actor1);
> renderer.AddActor(Actor2);
> renderer.SetBackground(1,1,1); # Background color white
>
> #Render and interact
> renderWindow.Render();
> renderWindowInteractor.Start();
>
>
> Many thanks!
>
> Jothy
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100824/d9d1540b/attachment.htm>
More information about the vtkusers
mailing list