[vtkusers] How to write volume which has more than one slice using STLWriter

Uma Sindhura usindhura at yahoo.com
Mon May 30 08:38:42 EDT 2005


Hi Friends,
 
 I was unable to write the volume which has more than one slice using VTKSTLWriter. But I was able to write .stl file for the volume which has one slice.Can any body help me !.Program follows....
 
//Console Program
 
void convert1::image(CS_Volume* vol1,LPCTSTR Out_path2)
{
 
   
BYTE* buffer=(BYTE*)vol1->Mem;
 
 vtkImageImport* importer = vtkImageImport::New();
 
     importer->SetImportVoidPointer(buffer);
   importer->SetDataExtent(0,vol1->Width-1,0,vol1->Height-1,0,vol1->Depth-1);
   importer->SetWholeExtent(0,vol1->Width-1,0,vol1->Height-1,0,vol1->Depth-1);
   importer->SetDataSpacing(vol1->voxelWidth,vol1->voxelHeight,vol1->voxelDepth);
   importer->SetDataOrigin(0.0,0.0,0.0);
   if (vol1->DataType == 1 || vol1->DataType ==128 || vol1->DataType == 2) 
    importer->SetDataScalarTypeToUnsignedChar();
   
   else if (vol1->DataType == 4 )
    importer->SetDataScalarTypeToUnsignedShort();
   else if (vol1->DataType == 8)
    importer->SetDataScalarTypeToShort();
   else if (vol1->DataType == 16 )
    importer->SetDataScalarTypeToInt();
   else if (vol1->DataType == 32)
    importer->SetDataScalarTypeToInt();
   else if (vol1->DataType == 64)
    importer->SetDataScalarTypeToFloat();
   vtkImageDataGeometryFilter* gfil=vtkImageDataGeometryFilter::New();
   gfil->SetInput(importer->GetOutput());
 
vtkSTLWriter* stl=vtkSTLWriter::New();
   
   ofstream ofile2;
         ofile2.open(Out_path2,ios::in | ios::out | ios::binary);
   stl->SetInput(gfil->GetOutput());
   stl->SetFileName(Out_path2);
   stl->SetFileTypeToBinary();
   stl->Write();
}
 
 
Regards
Sindhu..

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050530/2d61721a/attachment.htm>


More information about the vtkusers mailing list