Dodgy UpdateExtent
John Biddiscombe
j.biddiscombe at rl.ac.uk
Tue Nov 30 06:47:23 EST 1999
Dear vtk...
If you do
1) Create a StructuredPoints dataset
2) Set dimensions/spacing and origin
3) Set correct scalars in sp data
4) Create a DatasetWriter
5) writer->SetInput(structuredpoints)
6) writer->Write
you get a dataset (file) with dimensions 1,1,1 nomatter what you do <gulp>.
It seems that DataSetWriter calls MakeImageToStructurdPoints and it in turn
checks UpdateExtent (on itself effectively) in its Execute method, which by
default is {0,0,0,0,0,0)
consequently nothing gets copied from the structured points dataset to the
(new copy of the) structuredpoints dataset and the writer doesn't bother
writing anything impressive.
here's some code
vtkStructuredPoints *coverage = vtkStructuredPoints::New();
int newdims[3] = {1400,2000,1};
float origin[3] = {0,0,0};
float spacing[3] = {500,500,1};
coverage->SetDimensions(newdims);
coverage->SetOrigin(origin);
coverage->SetSpacing(spacing);
//
vtkScalars *coveragescalars = vtkScalars::New(VTK_FLOAT,2);
coveragescalars->SetNumberOfScalars(newdims[0]*newdims[1]);
//
// large loop filling scalars with data goes here
//
coverage->GetPointData()->SetScalars(coveragescalars);
coveragescalars->SetActiveComponent(0);
//
vtkDataSetWriter *wri = vtkDataSetWriter::New();
wri->SetFileName("E:\\Final_plot.vtk");
wri->SetInput(coverage);
wri->Update(); // or Write();
To my mind the code above seems OK, but clearly I need to insert an extra
SetUpdateExtent somewhere. For now I'll do this, but is this a flaw or have
I (yet again!) missed something. <sigh>
John B
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list