<!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 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> </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> </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> </DIV>
<DIV><FONT size=2>Thanks a lot,</FONT></DIV>
<DIV><FONT size=2>Audi</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>BOOL
CPointsVisualizationView::LoadRawDataMul(vtkStructuredPoints **StructuredPoints)
<BR>{ <BR> GetDocument()->Cleanup();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> CWaitCursor *cursor;<BR> CString
FileName;<BR> unsigned char *Image;<BR> unsigned short
*Image2;<BR> int Number=1;<BR> bool ImageFlag=false;<BR> bool
ImageFlag2=false;<BR> <BR> cursor=new CWaitCursor;
<BR> CFileDialog filedialog(TRUE,"*.raw",NULL,NULL,"Raw Data File(*.raw)
|*.raw||",NULL);<BR> <BR> if(filedialog.DoModal()==IDCANCEL)<BR> return
FALSE;<BR> <BR> delete
cursor;<BR> cursor=NULL;<BR> cursor=new
CWaitCursor;<BR> <BR> FILE
*fin;<BR> <BR> fin=fopen(filedialog.GetFileName(),"rb");<BR> <BR> if(fin==NULL)<BR> {<BR> AfxMessageBox("I
was not able to open the file...");<BR> return
FALSE;<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> FileName=filedialog.GetFileName();<BR> CInfoDialog
datainfo;<BR> if(datainfo.DoModal()==IDCANCEL)<BR> return
FALSE;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT
size=2> if((*StructuredPoints)!=NULL)<BR> {<BR> (*StructuredPoints)->Delete();<BR> (*StructuredPoints)=NULL;<BR> }<BR> <BR> (*StructuredPoints)=vtkStructuredPoints::New();<BR> <BR> if(datainfo.m_ByteCount==1)<BR> {<BR> (*StructuredPoints)->SetScalarType(VTK_UNSIGNED_CHAR);<BR> Image=new
unsigned
char[datainfo.m_XDim*datainfo.m_YDim*datainfo.m_ZDim];<BR> ImageFlag=true;<BR> }<BR> else<BR> {<BR> (*StructuredPoints)->SetScalarType(VTK_UNSIGNED_SHORT);<BR> Image2=new
unsigned
short[datainfo.m_XDim*datainfo.m_YDim*datainfo.m_ZDim];<BR> ImageFlag2=true;<BR> }<BR>
<BR> (*StructuredPoints)->SetDimensions(datainfo.m_XDim,datainfo.m_YDim,datainfo.m_ZDim);<BR> (*StructuredPoints)->SetSpacing(datainfo.m_XScale,datainfo.m_YScale,datainfo.m_ZScale);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> (*StructuredPoints)->AllocateScalars();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> while
(Number!=datainfo.m_ZDim)<BR> {<BR> if(datainfo.m_ByteCount==1)<BR> { <BR> fread(Image,1,datainfo.m_XDim*datainfo.m_YDim,fin);<BR> fclose(fin);<BR> <BR> vtkScalars
*scalars=(*StructuredPoints)->GetPointData()->GetScalars();<BR> scalars->SetDataType(VTK_UNSIGNED_CHAR);<BR> scalars->Allocate(datainfo.m_XDim*datainfo.m_YDim*datainfo.m_ZDim);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> int i,j,k;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT
size=2> for(k=Number-1;k<Number;k++)<BR> for(j=0;j<datainfo.m_YDim;j++)<BR> for(i=0;i<datainfo.m_XDim;i++)<BR> {<BR> scalars->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> }</FONT></DIV>
<DIV><FONT
size=2> }<BR> else<BR> { <BR> fread(Image2,2,datainfo.m_XDim*datainfo.m_YDim,fin);<BR> fclose(fin);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> vtkScalars
*scalars=(*StructuredPoints)->GetPointData()->GetScalars();<BR> scalars->SetDataType(VTK_UNSIGNED_SHORT);<BR> scalars->Allocate(datainfo.m_XDim*datainfo.m_YDim*datainfo.m_ZDim);<BR> <BR> int
i,j,k;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT
size=2> for(k=Number-1;k<Number;k++)<BR> for(j=0;j<datainfo.m_YDim;j++)<BR> for(i=0;i<datainfo.m_XDim;i++)<BR> {<BR> scalars->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> }<BR> }<BR> <BR> if(filedialog.DoModal()==IDCANCEL)<BR> return
FALSE;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT
size=2> fin=fopen(filedialog.GetFileName(),"rb");<BR> <BR> if(fin==NULL)<BR> {<BR> AfxMessageBox("I
was not able to open the file...");<BR> return
FALSE;<BR> }<BR> <BR> Number=Number+1;<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> (*StructuredPoints)->Modified();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> delete cursor;<BR> cursor=NULL;<BR> cursor=new
CWaitCursor;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> <BR> if (ImageFlag==true)<BR> delete []
Image;<BR> if (ImageFlag2==true)<BR> delete []
Image2;<BR> <BR> cursor->Restore();<BR> delete
cursor;<BR> <BR> return TRUE;<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2></FONT> </DIV></BODY></HTML>