------------------------------------------------------------------------------
| 296 | |
| 297 | //------------------------------------------------------------------------------ |
| 298 | bool vtkPlotHistogram2D::UpdateCache() |
| 299 | { |
| 300 | if (!this->Input) |
| 301 | { |
| 302 | return false; |
| 303 | } |
| 304 | if (!this->Output) |
| 305 | { |
| 306 | this->Output = vtkSmartPointer<vtkImageData>::New(); |
| 307 | } |
| 308 | this->Output->SetExtent(this->Input->GetExtent()); |
| 309 | this->Output->AllocateScalars(VTK_UNSIGNED_CHAR, 4); |
| 310 | |
| 311 | if (this->TransferFunction) |
| 312 | { |
| 313 | vtkDataArray* inputDataArray = nullptr; |
| 314 | void* const inputVoidArray = this->GetInputArrayPointer(inputDataArray); |
| 315 | |
| 316 | if (!inputVoidArray || !inputDataArray) |
| 317 | { |
| 318 | return false; |
| 319 | } |
| 320 | |
| 321 | const int inputType = inputDataArray->GetDataType(); |
| 322 | const int nbComponents = inputDataArray->GetNumberOfComponents(); |
| 323 | const int dimension = this->Input->GetDimensions()[0] * this->Input->GetDimensions()[1]; |
| 324 | unsigned char* output = reinterpret_cast<unsigned char*>(this->Output->GetScalarPointer()); |
| 325 | |
| 326 | this->TransferFunction->MapScalarsThroughTable2( |
| 327 | inputVoidArray, output, inputType, dimension, nbComponents, 4); |
| 328 | } |
| 329 | |
| 330 | return true; |
| 331 | } |
| 332 | |
| 333 | //------------------------------------------------------------------------------ |
| 334 | void* vtkPlotHistogram2D::GetInputArrayPointer(vtkDataArray*& inputArray) |
no test coverage detected