Problem with vtkExtractVOI and vtkExtractGrid

Bill Lorensen wlorens1 at nycap.rr.com
Sun Mar 26 08:18:37 EST 2000


Thanks again. The fixes should appear tonight.

Bill

At 12:28 PM 3/25/00 -0800, pahsieh at usgs.gov wrote:
>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