<DIV>Hi Vtk users,</DIV>
<DIV>I wanted to convert an image into polydata and i wanted store it in .vtk format and i even wanted to open the corresponding .vtk file in Mayavi data visualizer.But iam getting the access voilation error by writing the following code.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>#include &lt;vtkImageImport.h&gt;<BR>#include &lt;vtkImageDataGeometryFilter.h&gt;<BR>#include &lt;fstream.h&gt;<BR>#include &lt;vtkPolyDataWriter.h&gt;<BR>#include &lt;iostream.h&gt;<BR>class dcmvtk<BR>{<BR>private:<BR>&nbsp;vtkImageImport *imageim;<BR>&nbsp;vtkImageDataGeometryFilter *gfil;<BR>&nbsp;vtkPolyDataWriter *vw;<BR>&nbsp;const char* s;<BR>public:<BR>&nbsp;dcmvtk();<BR>&nbsp;~dcmvtk();<BR>};<BR>dcmvtk::dcmvtk()<BR>{<BR>&nbsp;unsigned char* p = NULL;<BR>&nbsp;if(p != NULL)<BR>&nbsp;{<BR>&nbsp;&nbsp;delete []p;<BR>&nbsp;&nbsp;p = NULL;<BR>&nbsp;}<BR>&nbsp;p = new unsigned char[256*256*2*9];<BR>&nbsp;s="D:/vtk/PET_after_preFilter.raw";<BR>&nbsp;ifstream is(s,ios::in | ios::out | ios::binary);<BR>&nbsp;is.read(p,256*256*2*9);<BR>&nbsp;is.close();<BR>&nbsp;&nbsp;&nbsp;
 imageim=vtkImageImport::New();<BR>&nbsp;imageim-&gt;SetImportVoidPointer((void*)p,1);<BR>&nbsp;imageim-&gt;SetDataExtent(0,255,0,255,0,9);<BR>&nbsp;imageim-&gt;SetWholeExtent(0,255,0,255,0,9);<BR>&nbsp;imageim-&gt;SetDataSpacing(1.96,1.96,3.92);<BR>&nbsp;imageim-&gt;SetDataOrigin(0.0,0.0,0.0);<BR>&nbsp;gfil=vtkImageDataGeometryFilter::New();<BR>&nbsp;gfil-&gt;SetInput(imageim-&gt;GetOutput());<BR>&nbsp;ofstream ofile;<BR>&nbsp;<BR>&nbsp;const char* f=new char[256*256*9*2];<BR>&nbsp;&nbsp;f="d:/dcm2.vtk";<BR>&nbsp;&nbsp;ofile.open(f,ios::in | ios::out | ios::binary);<BR>&nbsp;&nbsp;vw=vtkPolyDataWriter::New();</DIV>
<DIV>&nbsp;&nbsp;vw-&gt;SetInput(gfil-&gt;GetOutput());<BR>&nbsp;&nbsp;vw-&gt;SetFileName(f);<BR>&nbsp;&nbsp;vw-&gt;Write();<BR>}<BR>dcmvtk::~dcmvtk()<BR>{<BR>&nbsp;imageim-&gt;Delete();<BR>&nbsp;gfil-&gt;Delete();<BR>&nbsp;&nbsp;&nbsp; vw-&gt;Delete();<BR>}<BR>int main(int argc, char *argv[])<BR>{<BR>&nbsp;dcmvtk dc;<BR>&nbsp;return 0;<BR>}</DIV><p>
                <hr size=1>Do you Yahoo!?<br> 
Yahoo! Mail - Find what you need with new enhanced search. <a href="http://us.rd.yahoo.com/evt=29917/*http://info.mail.yahoo.com/mail_250">Learn more.</a>