[vtkusers] Establishing transparency among a set of 3D points..
Judith Tony
contactjudith at yahoo.co.in
Fri Aug 23 01:07:31 EDT 2013
> Hi,
> I need to align a set of 3D points and would like to render the points separately as "non-aligned" and "aligned" data.
I have created an array of mappers and actors one for each set of points.
> Also have set opacity for each actor .But I could not establish the
> transparency among the different set of points before alignment.I can view
> only the last set of 3D points.
> Here is the code:
>
> lm3Mapper=[]
> lm3Actor=[]
>
> ren = vtk.vtkRenderer()
>
> colors=vtk.vtkUnsignedCharArray()
>
colors.SetNumberOfComponents(4)
> colors.SetName("Colors")
> i=0
> for files in lm3List:
> lm3pts=get_3Dlandmark(files) #Get the 3D points in a numpy array
> lm3Point = vtk.vtkPolyData()
> lm3Point.SetPoints(gen_3DVTKPts(lm3pts)) #Create vtkPoints usingdouble
> array
> delny = vtk.vtkDelaunay3D()
> delny.SetInput(lm3Point)
> delny.SetTolerance(0.001)
> delny.Update()
>
> usg=vtk.vtkUnstructuredGrid()
> usg=delny.GetOutput()
>
> lm3Point1=vtk.vtkPolyData()
> lm3Point1.SetPoints(usg.GetPoints())
> lm3Point1.SetVerts(usg.GetCells())
># Also tried setting colour and scalar values for each point
>
> scalars = vtk.vtkFloatArray()
> scalars.SetNumberOfComponents(1)
>
scalars.SetName("3DLMK Scalars")
>
> for s in range(22):# total no.of 3D points=22
> scalars.InsertNextValue(vtk.vtkMath.Random(0.0,1.0))
> colors.InsertNextTupleValue((0,255,0,128))
>
> lm3Point1.GetPointData().AddArray(colors)
> lm3Point1.GetPointData().SetScalars(scalars)
>
> lm3Mapper+= [vtk.vtkPolyDataMapper()]
> lm3Mapper[i].SetInput(lm3Point1)
> lm3Mapper[i].ScalarVisibilityOn()
> lm3Mapper[i].SetScalarModeToUsePointFieldData()
> lm3Mapper[i].SelectColorArray("Colors")
>
> lm3Actor+=[vtk.vtkActor()]
> lm3Actor[i].SetMapper(lm3Mapper[i])
> lm3Actor[i].GetProperty().SetPointSize(6)
>
#lm3Actor[i].GetProperty().SetColor(200.0,0.0,0.0)
> #lm3Actor[i].GetProperty().SetOpacity(0.5)
>
> ren.AddActor(lm3Actor[i])
> ren.SetBackground(0.0, 0.0, 210.0)
> i=i+1
>
> Please throw light on this.
>
> -Judith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130823/ee2890f5/attachment.htm>
More information about the vtkusers
mailing list