[vtkusers] How to open a vtk file using mayavi with out getting no scalar data represented error

Uma Sindhura usindhura at yahoo.com
Sat May 21 03:28:14 EDT 2005


Hi friends,
 
 
 
I wanted to open the .vtk file using mayavi visualizer.But iam getting no scalar data represented erro when i was trying to watch the isosurface in the modules of mayavi.What changes i should made? 
 
#include <vtkImageImport.h>
#include <vtkImageDataGeometryFilter.h>
#include <fstream.h>
#include <vtkPolyDataWriter.h>
class dcmvtk
{
private:
 vtkImageImport *imageim;
 vtkImageDataGeometryFilter *gfil;
 vtkPolyDataWriter *vw;
 const char* s;
public:
 dcmvtk();
 ~dcmvtk();
};
dcmvtk::dcmvtk()
{
 unsigned char* p = NULL;
 if(p != NULL)
 {
  delete []p;
  p = NULL;
 }
 p = new unsigned char[256*256*2*9];
 s="D:/vtk/PET_after_preFilter.raw";
 ifstream is(s,ios::in | ios::out | ios::binary);
 is.read(p,256*256*2*9);
 is.close();
    imageim=vtkImageImport::New();
 imageim->SetImportVoidPointer((void*)p,1);
 imageim->SetDataExtent(0,255,0,255,0,8);
 imageim->SetWholeExtent(0,255,0,255,0,8);
 imageim->SetDataSpacing(1.96,1.96,3.92);
 imageim->SetDataOrigin(0.0,0.0,0.0);
 imageim->SetDataScalarTypeToUnsignedShort();
 gfil=vtkImageDataGeometryFilter::New();
 gfil->SetInput(imageim->GetOutput());
 ofstream ofile;
 
 const char* f=new char[256*256*9*2];
  f="d:/dcm2.vtk";
  ofile.open(f,ios::in | ios::out | ios::binary);
  vw=vtkPolyDataWriter::New();
  vw->SetInput(gfil->GetOutput());
  vw->SetFileName(f);
  vw->SetFileTypeToBinary();
  vw->Write();
}
dcmvtk::~dcmvtk()
{
 imageim->Delete();
 gfil->Delete();
    vw->Delete();
}
int main(int argc, char *argv[])
{
 dcmvtk dc;
 return 0;
}

		
---------------------------------
Yahoo! Mail Mobile
 Take Yahoo! Mail with you! Check email on your mobile phone.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050521/f7133fc6/attachment.htm>


More information about the vtkusers mailing list