Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int dg_reader::RequestData(vtkInformation * request, vtkInformationVector ** inVec, vtkInformationVector *outVec)
- {
- vtkInformation *info = outVec->GetInformationObject(0);
- // get the output
- vtkStructuredGrid *grid = vtkStructuredGrid::SafeDownCast(info->Get(vtkStructuredGrid::DATA_OBJECT()));
- // create data
- vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
- size_t numi = 2;
- size_t numj = 3;
- size_t numk = 1;
- grid->SetExtent(0, numj, 0, numj, 0, numj);
- for(size_t k = 0; k < numk; ++k)
- {
- for(size_t j = 0; j < numj; ++j)
- {
- for(size_t i = 0; i < numi; ++i)
- {
- points->InsertNextPoint(i, j, k);
- }
- }
- }
- grid->SetDimensions(numi, numj, numk);
- grid->SetPoints(points);
- vtkSmartPointer<vtkDoubleArray> density = vtkSmartPointer<vtkDoubleArray>::New();
- density->SetName("density");
- density->SetNumberOfComponents(1);
- density->SetNumberOfValues(points->GetNumberOfPoints());
- for(size_t i = 0; i < points->GetNumberOfPoints(); ++i)
- {
- density->SetComponent(i, 0, i);
- }
- grid->GetPointData()->AddArray(density);
- std::cout << grid->GetNumberOfPoints() << " points" << std::endl;
- std::cout << grid->GetNumberOfCells() << " cells" << std::endl;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement