[vtkusers] Getting incorrect origin values from vtkStructuredPointsWriter
Gable, Todd (GE Indust, Security)
Todd.Gable at ge.com
Fri Apr 13 16:28:17 EDT 2007
I'm having a strange issue, the "Origin" values in the header of a VTK legacy file created vtkStructuredPointsWriter is twice as large as they are supposed to be. The code consist of an ITK image, made into a vtkImageData and save by vtkStructuredPointsWriter. The value of the Origin is correct all the way until it is written to disk, then it is 2x the value that was in memory.
Here is the relavent code:
***************************************************************
typedef itk::CastImageFilter<ImageType, ImageMaskType> CastType; // cast from unsigned short to unsigned char
CastType::Pointer caster = CastType::New();
caster->SetInput(compObjectList[ii]->GetObjectMask().GetVolImage());
try
{
caster->Update();
}
catch(itk::ExceptionObject & err){
//stuff
}
typedef itk::ImageToVTKImageFilter<ImageMaskType> ImageImportType;
ImageImportType::Pointer importer = ImageImportType::New();
importer->SetInput(caster->GetOutput());
importer->Update();
vtkImageData* volData = vtkImageData::New();
volData->DeepCopy(importer->GetOutput());
// different function that does writing ...
vtkwriter->SetInput((vtkDataObject *)volData );
vtkwriter->SetFileName(fullpath.c_str());
vtkwriter->SetFileTypeToBinary();
vtkwriter->Update();
***************************************************************
I tried eliminating the casting, but it made no difference. Writing with ITK produces the correct header.
Todd Gable
More information about the vtkusers
mailing list