[vtkusers] python 3d point

hubo_gmail hubowhu at gmail.com
Fri Apr 27 05:02:12 EDT 2012


dear
     i am a new user in vtk with python. i want to do point cloud visual 
with python-vtk tools, but i found that i can't do well.Could you give 
some advices?My code is following :

         numRows = self.DataGrid.GetNumberRows()
         vtkPtList = vtk.vtkPoints()
         ptver = vtk.vtkPolyVertex()
         ptver.GetPointIds().SetNumberOfIds(numRows);
         p=Proj('+proj=tmerc +lon_0=114 +lat_0=0 +x_0=500000 +ellps=krass')
         for i in range(0,numRows):
         x,y = 
p(float(self.DataGrid.GetCellValue(i,1)),float(self.DataGrid.GetCellValue(i,2)))
         print x , y
         vtkPtList.InsertPoint(i,x,y,1)
         ptver.GetPointIds().SetId(i,i)

         grid = vtk.vtkUnstructuredGrid()
         grid.SetPoints(vtkPtList)
         grid.InsertNextCell(ptver.GetCellType(),ptver.GetPointIds());
         vtptmap = vtk.vtkDataSetMapper()
         vtptmap.SetInput(grid)

         vtpro = vtk.vtkProperty();
         vtpro.SetColor(0.1, 0.8, 0.8);
         vtpro.SetAmbient(0.5);
         vtpro.SetPointSize(2);
         vtpro.SetOpacity(0.5);

         actor = vtk.vtkActor()
         actor.SetMapper(vtptmap)
         actor.SetProperty(vtpro)
         actor.SetPosition(525507,3388618,1)
         actor.SetScale(0.1)
         self.ren.RemoveAllViewProps()
         self.ren.AddActor(actor)
         self.widget.GetRenderWindow().BordersOn()
         self.widget.Render()
regrads



bo hu.





More information about the vtkusers mailing list