<div class="gmail_quote">On Wed, Feb 10, 2010 at 5:31 AM, Liam Kurmos <span dir="ltr">&lt;<a href="mailto:quantum.leaf@googlemail.com">quantum.leaf@googlemail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
I&#39;m still pretty new to vtk myself and not 100% sure if this is what<br>
you want but have a look at the code below. I think i adapted it from<br>
the guide. If it&#39;s useful i could make an example.<br>
<br>
    int xDim, yDim,zDim;<br>
    xDim=yDim=zDim=26;<br>
    float z,y,x,kOffset,jOffset,offset;<br>
    vtkImageData *vol = vtkImageData::New();<br>
    vol-&gt;SetDimensions(xDim,yDim,zDim);<br>
    vol-&gt;SetOrigin(-1,-1,-1);<br>
<br>
    float sp=(float)1.0/(xDim-1);<br>
    vol-&gt;SetSpacing(sp,sp,sp);<br>
<br>
    vtkFloatArray *scalars=vtkFloatArray::New();<br>
    for (int k=0;k&lt;zDim;k++){<br>
<br>
        z=-0.5+k*sp;<br>
        kOffset= k*xDim*yDim;<br>
        for(int j=0;j&lt;yDim;j++){<br>
            y=-0.5+j*sp;<br>
            jOffset=j*xDim;<br>
            for (int i=0;i&lt;xDim;i++){<br>
                x=-0.5+i*sp;<br>
                float s=x*x+y*y+z*z-(0.4*0.4);<br>
<br>
                offset=i+jOffset+kOffset;<br>
                scalars-&gt;InsertTuple1(offset,s);<br>
            }<br>
        }<br>
    }<br>
<br>
    vol-&gt;GetPointData()-&gt;SetScalars(scalars);<br>
<br>
    scalars-&gt;Delete();<br>
<br>
    vtkMarchingCubes *iso = vtkMarchingCubes::New();<br>
    iso-&gt;SetInput(vol);<br>
    iso-&gt;SetNumberOfContours(1);<br>
    iso-&gt;SetValue(0, 0);<br>
<font color="#888888"><br>
Liam<br>
</font><div><div></div><div class="h5"></div></div></blockquote></div><br><div>I believe you could also do this ( can&#39;t try it right now)</div><div><br></div><div>double* volValue = static_cast&lt;double*&gt;vol-&gt;GetScalarPointer(i, j, k);</div>
<div>volValue = whatever you want pixel (x,y,z) to equal</div><div></div><div><br></div><div>Setting pixels in linear order always just seems to me like it is asking for trouble :) This method (if it is legitimate) lets you set the pixels via their position in the image.</div>
<div><br>Thanks,<br><br>David<br></div>