------------------------------------------------------------------------------
| 46 | |
| 47 | //------------------------------------------------------------------------------ |
| 48 | int vtkImageToStructuredGrid::RequestData(vtkInformation* vtkNotUsed(request), |
| 49 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 50 | { |
| 51 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 52 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 53 | assert(inInfo != nullptr); |
| 54 | assert(outInfo != nullptr); |
| 55 | |
| 56 | vtkImageData* img = vtkImageData::SafeDownCast(inInfo->Get(vtkImageData::DATA_OBJECT())); |
| 57 | assert(img != nullptr); |
| 58 | |
| 59 | vtkStructuredGrid* grid = |
| 60 | vtkStructuredGrid::SafeDownCast(outInfo->Get(vtkStructuredGrid::DATA_OBJECT())); |
| 61 | assert(grid != nullptr); |
| 62 | |
| 63 | int dims[3]; |
| 64 | img->GetDimensions(dims); |
| 65 | |
| 66 | vtkPoints* gridPoints = vtkPoints::New(); |
| 67 | assert(gridPoints != nullptr); |
| 68 | gridPoints->SetDataTypeToDouble(); |
| 69 | gridPoints->SetNumberOfPoints(img->GetNumberOfPoints()); |
| 70 | |
| 71 | double pnt[3]; |
| 72 | for (int i = 0; i < img->GetNumberOfPoints(); ++i) |
| 73 | { |
| 74 | img->GetPoint(i, pnt); |
| 75 | gridPoints->SetPoint(i, pnt); |
| 76 | } |
| 77 | grid->SetDimensions(dims); |
| 78 | grid->SetPoints(gridPoints); |
| 79 | gridPoints->Delete(); |
| 80 | |
| 81 | this->CopyPointData(img, grid); |
| 82 | this->CopyCellData(img, grid); |
| 83 | |
| 84 | return 1; |
| 85 | } |
| 86 | |
| 87 | //------------------------------------------------------------------------------ |
| 88 | void vtkImageToStructuredGrid::CopyPointData(vtkImageData* img, vtkStructuredGrid* sgrid) |
nothing calls this directly
no test coverage detected