------------------------------------------------------------------------------
| 40 | |
| 41 | //------------------------------------------------------------------------------ |
| 42 | int vtkImageDataToPointSet::RequestData(vtkInformation* vtkNotUsed(request), |
| 43 | vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 44 | { |
| 45 | // Retrieve input and output |
| 46 | vtkImageData* inData = vtkImageData::GetData(inputVector[0]); |
| 47 | vtkStructuredGrid* outData = vtkStructuredGrid::GetData(outputVector); |
| 48 | |
| 49 | if (inData == nullptr) |
| 50 | { |
| 51 | vtkErrorMacro(<< "Input data is nullptr."); |
| 52 | return 0; |
| 53 | } |
| 54 | if (outData == nullptr) |
| 55 | { |
| 56 | vtkErrorMacro(<< "Output data is nullptr."); |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | // Copy input point and cell data to output |
| 61 | outData->GetPointData()->PassData(inData->GetPointData()); |
| 62 | outData->GetCellData()->PassData(inData->GetCellData()); |
| 63 | |
| 64 | // Extract points coordinates from the image |
| 65 | vtkIdType nbPoints = inData->GetNumberOfPoints(); |
| 66 | vtkNew<vtkPoints> points; |
| 67 | points->SetDataTypeToDouble(); |
| 68 | points->SetNumberOfPoints(nbPoints); |
| 69 | for (vtkIdType i = 0; i < nbPoints; i++) |
| 70 | { |
| 71 | if (this->CheckAbort()) |
| 72 | { |
| 73 | break; |
| 74 | } |
| 75 | double p[3]; |
| 76 | inData->GetPoint(i, p); |
| 77 | points->SetPoint(i, p); |
| 78 | } |
| 79 | outData->SetPoints(points); |
| 80 | |
| 81 | // Copy Extent |
| 82 | int extent[6]; |
| 83 | inData->GetExtent(extent); |
| 84 | outData->SetExtent(extent); |
| 85 | |
| 86 | return 1; |
| 87 | } |
| 88 | VTK_ABI_NAMESPACE_END |
nothing calls this directly
no test coverage detected