Problem with vtkExtractVOI and vtkExtractGrid
pahsieh at usgs.gov
pahsieh at usgs.gov
Sat Mar 25 15:28:18 EST 2000
The filters vtkExtractVOI and vtkExtractGrid appear to
lose cell data. This is illustrated by the attached
sample code. A structured points data set is created
with point and cell data (scalars). After filtering with
vtkExtractVOI, there are point scalars but no cell
scalars. The same thing happens for a structured grid
data set that is extracted by vtkExtractGrid (sample
code not attached).
As always, many thanks for you help and best regards,
Paul
// ==== sample code ====
// The output is:
// The extracted grid has 27 point scalars.
// The extracted grid has no cell scalars.
#include "vtkStructuredPoints.h"
#include "vtkExtractVOI.h"
void main()
{
// Create a structured points data set
vtkStructuredPoints *sp = vtkStructuredPoints::New();
sp->SetDimensions(5, 5, 5);
sp->SetSpacing(1, 1, 1);
sp->SetOrigin(0, 0, 0);
// Create cell scalar data.
vtkScalars *scalars = vtkScalars::New();
for (int i=0; i<64; i++)
{
scalars->InsertNextScalar(0.01 * i);
}
sp->GetCellData()->SetScalars(scalars);
scalars->Delete();
// Create point scalar data
scalars = vtkScalars::New();
for (i=0; i<125; i++)
{
scalars->InsertNextScalar(0.01 * i);
}
sp->GetPointData()->SetScalars(scalars);
scalars->Delete();
// Extract a portion of the grid
vtkExtractVOI *voi = vtkExtractVOI::New();
voi->SetInput(sp);
voi->SetVOI(2, 4, 2, 4, 2, 4);
voi->SetSampleRate(1, 1, 1);
voi->Update();
// Print the number of point scalars
scalars = voi->GetOutput()->GetPointData()->GetScalars();
if (scalars)
{
cout << "The extracted grid has " << scalars->GetNumberOfScalars()
<< " point scalars." << endl;
}
else
{
cout << "The extracted grid has no point scalars" << endl;
}
// Print the number of cell scalars
scalars = voi->GetOutput()->GetCellData()->GetScalars();
if (scalars)
{
cout << "The extracted grid has " << scalars->GetNumberOfScalars()
<< " cell scalars." << endl;
}
else
{
cout << "The extracted grid has no cell scalars." << endl;
}
// Clean up
sp->Delete();
voi->Delete();
}
--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------
More information about the vtkusers
mailing list