One thing: make sure you set Output Data Set Type to vtkPolyData before the first time you apply (a long standing bug in ParaView).<div><br></div><div>Second thing: there are four problems with your script:</div><div>1) You need to protect against divide by zero when i = 0, </div>
<div>2) There are parenthesis mismatch in the polygons.InsertCellPoint(i * j + j + 1)) line</div><div>3) vtkPolyData doesn't have an AllocateScalars() method.</div><div>4) your input is called inputImage, not input</div>
<div><br></div><div>After that you should get a polydata output, but the transformation isn't right.</div><div><br></div><div>good luck!</div><div><br>
David E DeMarle<br>Kitware, Inc.<br>R&D Engineer<br>21 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4909<br>
<br><br><div class="gmail_quote">On Fri, Jan 13, 2012 at 3:05 AM, Habbinga, Sonja <span dir="ltr"><<a href="mailto:s.habbinga@fz-juelich.de">s.habbinga@fz-juelich.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":1tv">#create a vtkPolyData output<br>
#and populate its cells with the point centered<br>
#scalars of the input dataset<br>
<br>
inputImage = self.GetInput()<br>
output = self.GetOutput()<br>
<br>
numPts = inputImage.GetNumberOfPoints()<br>
<br>
lat = 1024<br>
lon = 2048<br>
PI = math.atan2( 0, -1 )<br>
<br>
dlat = 180/(lat - 1)<br>
dlon = 360/(lon - 1)<br>
lon = lon + 1<br>
nrpoints = lon*lat<br>
<br>
points = vtk.vtkPoints()<br>
polygons = vtk.vtkCellArray()<br>
points.SetDataTypeToFloat()<br>
points.SetNumberOfPoints( nrpoints )<br>
num = 0<br>
<br>
for i in range(0, lat) :<br>
for j in range(0, lon) :<br>
x = math.cos( j*dlon / 180*PI ) * math.cos( (90/i*dlat)/180*PI)<br>
y = math.sin( j*dlon / 180*PI ) * math.cos( (90/i*dlat)/180*PI)<br>
z = math.sin( (90-i*dlat)/180*PI)<br>
<br>
num = i*lon+j<br>
points.SetPoint( num, x, y, z )<br>
<br>
for i in range(0, lat) :<br>
for j in range(0, lon) :<br>
polygons.InsertNextCell( 4 )<br>
polygons.InsertCellPoint( i * lon + j )<br>
polygons.InsertCellPoint((i + 1) * lon + j)<br>
polygons.InsertCellPoint( (i + 1) * lon + j + 1)<br>
polygons.InsertCellPoint(i * j + j + 1) )<br>
<br>
output.SetPoints( points )<br>
output.SetPolys( polygons )<br>
output.AllocateScalars()<br>
<br>
<br>
#add the new array to the output<br>
output.GetCellData().AddArray(input.GetPointData().GetScalars())<br>
<br></div></blockquote></div><br></div>