<div class="gmail_quote">On Wed, Feb 10, 2010 at 5:31 AM, Liam Kurmos <span dir="ltr"><<a href="mailto:quantum.leaf@googlemail.com">quantum.leaf@googlemail.com</a>></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'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'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->SetDimensions(xDim,yDim,zDim);<br>
vol->SetOrigin(-1,-1,-1);<br>
<br>
float sp=(float)1.0/(xDim-1);<br>
vol->SetSpacing(sp,sp,sp);<br>
<br>
vtkFloatArray *scalars=vtkFloatArray::New();<br>
for (int k=0;k<zDim;k++){<br>
<br>
z=-0.5+k*sp;<br>
kOffset= k*xDim*yDim;<br>
for(int j=0;j<yDim;j++){<br>
y=-0.5+j*sp;<br>
jOffset=j*xDim;<br>
for (int i=0;i<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->InsertTuple1(offset,s);<br>
}<br>
}<br>
}<br>
<br>
vol->GetPointData()->SetScalars(scalars);<br>
<br>
scalars->Delete();<br>
<br>
vtkMarchingCubes *iso = vtkMarchingCubes::New();<br>
iso->SetInput(vol);<br>
iso->SetNumberOfContours(1);<br>
iso->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't try it right now)</div><div><br></div><div>double* volValue = static_cast<double*>vol->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>