One thing: make sure you set Output Data Set Type to vtkPolyData before the first time you apply (a long standing bug in ParaView).
Second thing: there are four problems with your script: 1) You need to protect against divide by zero when i = 0, 2) There are parenthesis mismatch in the polygons.InsertCellPoint(i * j + j + 1)) line 3) vtkPolyData doesn't have an AllocateScalars() method. 4) your input is called inputImage, not input After that you should get a polydata output, but the transformation isn't right. good luck! David E DeMarle Kitware, Inc. R&D Engineer 21 Corporate Drive Clifton Park, NY 12065-8662 Phone: 518-881-4909 On Fri, Jan 13, 2012 at 3:05 AM, Habbinga, Sonja <[email protected]>wrote: > #create a vtkPolyData output > #and populate its cells with the point centered > #scalars of the input dataset > > inputImage = self.GetInput() > output = self.GetOutput() > > numPts = inputImage.GetNumberOfPoints() > > lat = 1024 > lon = 2048 > PI = math.atan2( 0, -1 ) > > dlat = 180/(lat - 1) > dlon = 360/(lon - 1) > lon = lon + 1 > nrpoints = lon*lat > > points = vtk.vtkPoints() > polygons = vtk.vtkCellArray() > points.SetDataTypeToFloat() > points.SetNumberOfPoints( nrpoints ) > num = 0 > > for i in range(0, lat) : > for j in range(0, lon) : > x = math.cos( j*dlon / 180*PI ) * math.cos( > (90/i*dlat)/180*PI) > y = math.sin( j*dlon / 180*PI ) * math.cos( > (90/i*dlat)/180*PI) > z = math.sin( (90-i*dlat)/180*PI) > > num = i*lon+j > points.SetPoint( num, x, y, z ) > > for i in range(0, lat) : > for j in range(0, lon) : > polygons.InsertNextCell( 4 ) > polygons.InsertCellPoint( i * lon + j ) > polygons.InsertCellPoint((i + 1) * lon + j) > polygons.InsertCellPoint( (i + 1) * lon + j + 1) > polygons.InsertCellPoint(i * j + j + 1) ) > > output.SetPoints( points ) > output.SetPolys( polygons ) > output.AllocateScalars() > > > #add the new array to the output > output.GetCellData().AddArray(input.GetPointData().GetScalars()) > >
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview
