------------------------------------------------------------------------------
| 84 | } |
| 85 | //------------------------------------------------------------------------------ |
| 86 | int vtkContinuousScatterplot::RequestData( |
| 87 | vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) |
| 88 | { |
| 89 | // get the input and output ports information. |
| 90 | vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); |
| 91 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 92 | |
| 93 | // get the input data set, which is required to be a vtkUnstructuredGrid. |
| 94 | vtkUnstructuredGrid* input = |
| 95 | vtkUnstructuredGrid::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 96 | // get the output data set, which is required to be a vtkImageData. |
| 97 | vtkImageData* output = vtkImageData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 98 | |
| 99 | // get the number of points and cells of the input grid. |
| 100 | vtkIdType numCells = input->GetNumberOfCells(); |
| 101 | vtkIdType numPts = input->GetNumberOfPoints(); |
| 102 | |
| 103 | // get the dataset statistics and check if it is not an empty grid. |
| 104 | if (numCells < 1 || numPts < 1) |
| 105 | { |
| 106 | vtkErrorMacro("No input data."); |
| 107 | return 1; |
| 108 | } |
| 109 | |
| 110 | // check if the output image resolution is a valid number. |
| 111 | if (this->ResX <= 0 || this->ResY <= 0) |
| 112 | { |
| 113 | vtkErrorMacro("The resolution of the output image has to be a positive number."); |
| 114 | return 1; |
| 115 | } |
| 116 | |
| 117 | // check if the names of the input scalar fields are specified. |
| 118 | if (!this->Fields[0] || !this->Fields[1]) |
| 119 | { |
| 120 | vtkErrorMacro("At least two fields need to be specified."); |
| 121 | return 1; |
| 122 | } |
| 123 | |
| 124 | // Input point data, which should include the arrays defining the range space. |
| 125 | vtkDataSetAttributes* inPD = input->GetPointData(); |
| 126 | // current data array of the given array names from the user input. |
| 127 | vtkSmartPointer<vtkDataArray> array; |
| 128 | // scalar range in two fields, where fieldInterval[0] = f1_max - f1_min, |
| 129 | // fieldInterval[1] = f2_max - f2_min |
| 130 | float fieldInterval[2]; |
| 131 | |
| 132 | // fragment width of two fields, where fragWidth[0] = fieldInterval[0] / resX, |
| 133 | // fragWidth[0] = fieldInterval[1] / resY, (resX, resY) is the output image |
| 134 | // resolution. |
| 135 | float fragWidth[2]; |
| 136 | |
| 137 | // Collect the first scalar field based on array names, |
| 138 | array = inPD->GetArray(this->Fields[0]); |
| 139 | // confirming that this field is present in the input. |
| 140 | if (array) |
| 141 | { |
| 142 | // Collect field ranges for later use. |
| 143 | fieldInterval[0] = array->GetRange()[1] - array->GetRange()[0]; |
nothing calls this directly
no test coverage detected