<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hi,</FONT></DIV>
<DIV><FONT size=2>I used vtkStructuredPoints to render few 2D data to form 
3D</FONT></DIV>
<DIV><FONT size=2>instead&nbsp;of using volume rendering.</FONT></DIV>
<DIV><FONT size=2>But I have problem to render it.</FONT></DIV>
<DIV><FONT size=2>This is the function for rendering few 2D files into 3D, 
</FONT></DIV>
<DIV><FONT size=2>can anybody find what is the problem with my function?I'm 
stuck.</FONT></DIV>
<DIV><FONT size=2>I hope somebody can help me to find it.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>1. m_XDim,m_YDim are file dimensions</FONT></DIV>
<DIV><FONT size=2>2. m_ZDim is the number of 2D files that has been 
read</FONT></DIV>
<DIV><FONT size=2>3. Number is the counter to count how many files that has been 
read</FONT></DIV>
<DIV><FONT size=2>4. m_XScale,m_YScale,m_ZScale are the file 
spacing</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>My program is reading the 2D file one by one, every time 
reading one file it will</FONT></DIV>
<DIV><FONT size=2>store it into vtkStructuredPoints. I also check with the 
vtkVolumeReader, it seems</FONT></DIV>
<DIV><FONT size=2>correct, but my prog only can view 2D instead of 3D. It seems 
the storing part</FONT></DIV>
<DIV><FONT size=2>not succesful, but I can't find why, so anybody can find 
it?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>Thanks a lot,</FONT></DIV>
<DIV><FONT size=2>Audi</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>BOOL 
CPointsVisualizationView::LoadRawDataMul(vtkStructuredPoints **StructuredPoints) 
<BR>{&nbsp;<BR>&nbsp;GetDocument()-&gt;Cleanup();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;CWaitCursor *cursor;<BR>&nbsp;CString 
FileName;<BR>&nbsp;unsigned char *Image;<BR>&nbsp;unsigned short 
*Image2;<BR>&nbsp;int Number=1;<BR>&nbsp;bool ImageFlag=false;<BR>&nbsp;bool 
ImageFlag2=false;<BR>&nbsp;<BR>&nbsp;cursor=new CWaitCursor; 
<BR>&nbsp;CFileDialog filedialog(TRUE,"*.raw",NULL,NULL,"Raw Data File(*.raw) 
|*.raw||",NULL);<BR>&nbsp;<BR>&nbsp;if(filedialog.DoModal()==IDCANCEL)<BR>&nbsp;return 
FALSE;<BR>&nbsp;<BR>&nbsp;delete 
cursor;<BR>&nbsp;cursor=NULL;<BR>&nbsp;cursor=new 
CWaitCursor;<BR>&nbsp;<BR>&nbsp;FILE 
*fin;<BR>&nbsp;<BR>&nbsp;fin=fopen(filedialog.GetFileName(),"rb");<BR>&nbsp;<BR>&nbsp;if(fin==NULL)<BR>&nbsp;{<BR>&nbsp;AfxMessageBox("I 
was not able to open the file...");<BR>&nbsp;return 
FALSE;<BR>&nbsp;}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;FileName=filedialog.GetFileName();<BR>&nbsp;CInfoDialog 
datainfo;<BR>&nbsp;if(datainfo.DoModal()==IDCANCEL)<BR>&nbsp;&nbsp;return 
FALSE;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT 
size=2>&nbsp;if((*StructuredPoints)!=NULL)<BR>&nbsp;{<BR>&nbsp;(*StructuredPoints)-&gt;Delete();<BR>&nbsp;(*StructuredPoints)=NULL;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;(*StructuredPoints)=vtkStructuredPoints::New();<BR>&nbsp;<BR>&nbsp;if(datainfo.m_ByteCount==1)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;(*StructuredPoints)-&gt;SetScalarType(VTK_UNSIGNED_CHAR);<BR>&nbsp;&nbsp;&nbsp;Image=new 
unsigned 
char[datainfo.m_XDim*datainfo.m_YDim*datainfo.m_ZDim];<BR>&nbsp;&nbsp;&nbsp;ImageFlag=true;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;(*StructuredPoints)-&gt;SetScalarType(VTK_UNSIGNED_SHORT);<BR>&nbsp;&nbsp;&nbsp;Image2=new 
unsigned 
short[datainfo.m_XDim*datainfo.m_YDim*datainfo.m_ZDim];<BR>&nbsp;&nbsp;&nbsp;ImageFlag2=true;<BR>&nbsp;&nbsp;}<BR>&nbsp; 
<BR>&nbsp;(*StructuredPoints)-&gt;SetDimensions(datainfo.m_XDim,datainfo.m_YDim,datainfo.m_ZDim);<BR>&nbsp;(*StructuredPoints)-&gt;SetSpacing(datainfo.m_XScale,datainfo.m_YScale,datainfo.m_ZScale);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;(*StructuredPoints)-&gt;AllocateScalars();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;while 
(Number!=datainfo.m_ZDim)<BR>&nbsp;{<BR>&nbsp;&nbsp;if(datainfo.m_ByteCount==1)<BR>&nbsp;&nbsp;{&nbsp;<BR>&nbsp;&nbsp;&nbsp;fread(Image,1,datainfo.m_XDim*datainfo.m_YDim,fin);<BR>&nbsp;&nbsp;&nbsp;fclose(fin);<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;vtkScalars 
*scalars=(*StructuredPoints)-&gt;GetPointData()-&gt;GetScalars();<BR>&nbsp;&nbsp;&nbsp;scalars-&gt;SetDataType(VTK_UNSIGNED_CHAR);<BR>&nbsp;&nbsp;&nbsp;scalars-&gt;Allocate(datainfo.m_XDim*datainfo.m_YDim*datainfo.m_ZDim);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;&nbsp;&nbsp;int i,j,k;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT 
size=2>&nbsp;&nbsp;&nbsp;for(k=Number-1;k&lt;Number;k++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;for(j=0;j&lt;datainfo.m_YDim;j++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(i=0;i&lt;datainfo.m_XDim;i++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scalars-&gt;InsertScalar(k*(datainfo.m_YDim*datainfo.m_XDim)+j*(datainfo.m_XDim)+i,Image[k*(datainfo.m_YDim*datainfo.m_XDim)+j*(datainfo.m_XDim)+i]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</FONT></DIV>
<DIV><FONT 
size=2>&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;{&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;fread(Image2,2,datainfo.m_XDim*datainfo.m_YDim,fin);<BR>&nbsp;&nbsp;&nbsp;fclose(fin);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;&nbsp;&nbsp;vtkScalars 
*scalars=(*StructuredPoints)-&gt;GetPointData()-&gt;GetScalars();<BR>&nbsp;&nbsp;&nbsp;scalars-&gt;SetDataType(VTK_UNSIGNED_SHORT);<BR>&nbsp;&nbsp;&nbsp;scalars-&gt;Allocate(datainfo.m_XDim*datainfo.m_YDim*datainfo.m_ZDim);<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;int 
i,j,k;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT 
size=2>&nbsp;&nbsp;&nbsp;for(k=Number-1;k&lt;Number;k++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;for(j=0;j&lt;datainfo.m_YDim;j++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(i=0;i&lt;datainfo.m_XDim;i++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scalars-&gt;SetScalar(k*(datainfo.m_YDim*datainfo.m_XDim)+j*(datainfo.m_XDim)+i,Image2[k*(datainfo.m_YDim*datainfo.m_XDim)+j*(datainfo.m_XDim)+i]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;<BR>&nbsp;&nbsp;if(filedialog.DoModal()==IDCANCEL)<BR>&nbsp;&nbsp;&nbsp;return 
FALSE;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT 
size=2>&nbsp;&nbsp;fin=fopen(filedialog.GetFileName(),"rb");<BR>&nbsp;<BR>&nbsp;&nbsp;if(fin==NULL)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;AfxMessageBox("I 
was not able to open the file...");<BR>&nbsp;&nbsp;&nbsp;return 
FALSE;<BR>&nbsp;&nbsp;}<BR>&nbsp;<BR>&nbsp;&nbsp;Number=Number+1;<BR>&nbsp;}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;(*StructuredPoints)-&gt;Modified();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;delete cursor;<BR>&nbsp;cursor=NULL;<BR>&nbsp;cursor=new 
CWaitCursor;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp;<BR>&nbsp;if (ImageFlag==true)<BR>&nbsp;&nbsp;delete [] 
Image;<BR>&nbsp;if (ImageFlag2==true)<BR>&nbsp;&nbsp;delete [] 
Image2;<BR>&nbsp;<BR>&nbsp;cursor-&gt;Restore();<BR>&nbsp;delete 
cursor;<BR>&nbsp;<BR>&nbsp;return TRUE;<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV></BODY></HTML>