<div dir="ltr">Pass the output through a trianglr filterand then add to actor.<br><br>Cheers,<br><br>Jothy<br><br><div class="gmail_quote">On Tue, Aug 24, 2010 at 4:54 PM, Jothy <span dir="ltr">&lt;<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr">Hi all,<br><br>Could anyone turn the black sphere into some other color!!<br>
<br>Should I specify anythging to the DataSetMapper?<br><br>Here is the code<br><br>import vtk<br>import numpy as np<br><br>def CreateSphere(Theta,Phi,Radius):<br>
    sphere=vtk.vtkSphereSource()<br>    sphere.SetThetaResolution(Theta)<br>    sphere.SetPhiResolution(Phi)<br>    sphere.SetRadius(Radius)<br>    #sphere.SetCenter(0,0,0)<br>    return sphere.GetOutput()<br><br><br>CTV=CreateSphere(100,100,20)<br>

b=CTV.GetBounds()#CTVBounds<br>SourcePoints=vtk.vtkPoints()<br>SourcePoints.SetNumberOfPoints(8)<br>SourcePoints.SetPoint( 0, b[0], b[3], b[5])<br>SourcePoints.SetPoint( 1, b[1], b[3], b[5])<br>SourcePoints.SetPoint( 2, b[0], b[3], b[4])<br>

SourcePoints.SetPoint( 3, b[1], b[3], b[4])<br>SourcePoints.SetPoint( 4, b[0], b[2], b[5])<br>SourcePoints.SetPoint( 5, b[1], b[2], b[5])<br>SourcePoints.SetPoint( 6, b[0], b[2], b[4])<br>SourcePoints.SetPoint( 7, b[1], b[2], b[4])<br>

<br><br>TargetPoints=vtk.vtkPoints()<br>TargetPoints.SetNumberOfPoints(8)<br>xm,ym,zm,xp,yp,zp=10,10,10,20,20,20<br>TargetPoints.SetPoint( 0, b[0]+xm, b[3]+yp, b[5]+zp )<br>TargetPoints.SetPoint( 1, b[1]+xp, b[3]+yp, b[5]+zp )<br>

TargetPoints.SetPoint( 2, b[0]+xm, b[3]+yp, b[4]+zm )<br>TargetPoints.SetPoint( 3, b[1]+xp, b[3]+yp, b[4]+zm )<br>TargetPoints.SetPoint( 4, b[0]+xm, b[2]+ym, b[5]+zp )<br>TargetPoints.SetPoint( 5, b[1]+xp, b[2]+ym, b[5]+zp )<br>

TargetPoints.SetPoint( 6, b[0]+xm, b[2]+ym, b[4]+zm )<br>TargetPoints.SetPoint( 7, b[1]+xp, b[2]+ym, b[4]+zm )<br><br><br><br>ThinPlateTransform=vtk.vtkThinPlateSplineTransform()    <br>ThinPlateTransform.SetSourceLandmarks(SourcePoints)<br>

ThinPlateTransform.SetTargetLandmarks(TargetPoints)<br>ThinPlateTransform.SetBasisToR2LogR()<br><br>GeneralTransform=vtk.vtkGeneralTransform()<br>GeneralTransform.SetInput(ThinPlateTransform )<br>#GeneralTransform.Concatenate(ThinPlateTransform.GetInverse())<br>

#GeneralTransform.Concatenate(ThinPlateTransform)<br><br>TransformFilter = vtk.vtkTransformPolyDataFilter()<br>TransformFilter.SetInput(CTV)<br>TransformFilter.SetTransform(GeneralTransform )<br><br>CTV.Modified()<br>ThinPlateTransform.Modified()<br>

<br>Mapper1=vtk.vtkDataSetMapper()<br>Mapper1.SetInputConnection(TransformFilter.GetOutputPort())<br><br>Mapper2=vtk.vtkDataSetMapper()<br>Mapper2.SetInput(CTV)<br>                          <br>                          <br>

Actor1=vtk.vtkActor()<br>Actor1.GetProperty().SetColor(1,1,0)<br>Actor1.SetMapper(Mapper1)<br><br><br>Actor2=vtk.vtkActor()<br>Actor2.GetProperty().SetColor(1,1,0)<br>Actor2.SetMapper(Mapper2)<br><br>#Create a renderer, render window, and interactor<br>

renderer =vtk.vtkRenderer();<br>renderWindow =vtk.vtkRenderWindow();<br>renderWindow.AddRenderer(renderer);<br>renderWindowInteractor =vtk.vtkRenderWindowInteractor();<br>renderWindowInteractor.SetRenderWindow(renderWindow);<br>

<br>#Add the actor to the scene<br>renderer.AddActor(Actor1);<br>renderer.AddActor(Actor2);<br>renderer.SetBackground(1,1,1); # Background color white<br><br>#Render and interact<br>renderWindow.Render();<br>renderWindowInteractor.Start();                        <br>

<br>                                         <br>Many thanks!<br><br>Jothy<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></div>
</blockquote></div><br></div>