------------------------------------------------------------------------------
| 162 | |
| 163 | //------------------------------------------------------------------------------ |
| 164 | int vtkImageDataToUniformGrid::Process( |
| 165 | vtkImageData* input, int association, const char* arrayName, vtkUniformGrid* output) |
| 166 | { |
| 167 | if (vtkUniformGrid* uniformGrid = vtkUniformGrid::SafeDownCast(input)) |
| 168 | { |
| 169 | output->ShallowCopy(uniformGrid); |
| 170 | } |
| 171 | else |
| 172 | { |
| 173 | output->ShallowCopy(input); |
| 174 | } |
| 175 | |
| 176 | vtkDataArray* inScalars = nullptr; |
| 177 | if (association == vtkDataObject::FIELD_ASSOCIATION_POINTS) |
| 178 | { |
| 179 | inScalars = input->GetPointData()->GetArray(arrayName); |
| 180 | } |
| 181 | else if (association == vtkDataObject::FIELD_ASSOCIATION_CELLS) |
| 182 | { |
| 183 | inScalars = input->GetCellData()->GetArray(arrayName); |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | vtkErrorMacro("Wrong association type: " << association); |
| 188 | return VTK_ERROR; |
| 189 | } |
| 190 | |
| 191 | if (!inScalars) |
| 192 | { |
| 193 | vtkErrorMacro("No scalar data to use for blanking."); |
| 194 | return VTK_ERROR; |
| 195 | } |
| 196 | else if (inScalars->GetNumberOfComponents() != 1) |
| 197 | { |
| 198 | vtkErrorMacro("Scalar data must be a single component array."); |
| 199 | return VTK_ERROR; |
| 200 | } |
| 201 | |
| 202 | vtkNew<vtkUnsignedCharArray> blankingArray; |
| 203 | blankingArray->SetNumberOfTuples(inScalars->GetNumberOfTuples()); |
| 204 | blankingArray->SetNumberOfComponents(1); |
| 205 | blankingArray->FillValue(0); |
| 206 | blankingArray->SetName(vtkDataSetAttributes::GhostArrayName()); |
| 207 | |
| 208 | unsigned char value1; |
| 209 | unsigned char value2; |
| 210 | if (association == vtkDataObject::FIELD_ASSOCIATION_CELLS) |
| 211 | { |
| 212 | if (this->Reverse) |
| 213 | { |
| 214 | value1 = 0; |
| 215 | value2 = vtkDataSetAttributes::HIDDENCELL; |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | value1 = vtkDataSetAttributes::HIDDENCELL; |
| 220 | value2 = 0; |
| 221 | } |
no test coverage detected