| 501 | } |
| 502 | |
| 503 | void vtkVolume::UpdateTransferFunctions(vtkRenderer* vtkNotUsed(ren)) |
| 504 | { |
| 505 | int dataType; |
| 506 | vtkPiecewiseFunction* sotf; |
| 507 | vtkPiecewiseFunction* gotf; |
| 508 | vtkPiecewiseFunction* graytf; |
| 509 | vtkColorTransferFunction* rgbtf; |
| 510 | int colorChannels; |
| 511 | |
| 512 | int arraySize; |
| 513 | |
| 514 | // Check that we have scalars |
| 515 | if (this->Mapper == nullptr || this->Mapper->GetDataSetInput() == nullptr || |
| 516 | this->Mapper->GetDataSetInput()->GetPointData() == nullptr || |
| 517 | this->Mapper->GetDataSetInput()->GetPointData()->GetScalars() == nullptr) |
| 518 | { |
| 519 | vtkErrorMacro(<< "Need scalar data to volume render"); |
| 520 | return; |
| 521 | } |
| 522 | |
| 523 | // What is the type of the data? |
| 524 | dataType = this->Mapper->GetDataSetInput()->GetPointData()->GetScalars()->GetDataType(); |
| 525 | |
| 526 | if (dataType == VTK_UNSIGNED_CHAR) |
| 527 | { |
| 528 | arraySize = 256; |
| 529 | } |
| 530 | else if (dataType == VTK_UNSIGNED_SHORT) |
| 531 | { |
| 532 | arraySize = 65536; |
| 533 | } |
| 534 | else |
| 535 | { |
| 536 | vtkErrorMacro("Unsupported data type"); |
| 537 | return; |
| 538 | } |
| 539 | |
| 540 | int numComponents = |
| 541 | this->Mapper->GetDataSetInput()->GetPointData()->GetScalars()->GetNumberOfComponents(); |
| 542 | |
| 543 | for (int c = 0; c < numComponents; c++) |
| 544 | { |
| 545 | |
| 546 | // Did our array size change? If so, free up all our previous arrays |
| 547 | // and create new ones for the scalar opacity and corrected scalar |
| 548 | // opacity |
| 549 | if (arraySize != this->ArraySize) |
| 550 | { |
| 551 | delete[] this->ScalarOpacityArray[c]; |
| 552 | this->ScalarOpacityArray[c] = nullptr; |
| 553 | |
| 554 | delete[] this->CorrectedScalarOpacityArray[c]; |
| 555 | this->CorrectedScalarOpacityArray[c] = nullptr; |
| 556 | |
| 557 | delete[] this->GrayArray[c]; |
| 558 | this->GrayArray[c] = nullptr; |
| 559 | |
| 560 | delete[] this->RGBArray[c]; |
nothing calls this directly
no test coverage detected