Update opacity transfer function texture. ------------------------------------------------------------------------------
| 13 | // Update opacity transfer function texture. |
| 14 | //------------------------------------------------------------------------------ |
| 15 | void vtkOpenGLVolumeOpacityTable::InternalUpdate( |
| 16 | vtkObject* func, int blendMode, double sampleDistance, double unitDistance, int filterValue) |
| 17 | { |
| 18 | vtkPiecewiseFunction* scalarOpacity = vtkPiecewiseFunction::SafeDownCast(func); |
| 19 | if (!scalarOpacity) |
| 20 | { |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | scalarOpacity->GetTable(this->LastRange[0], this->LastRange[1], this->TextureWidth, this->Table); |
| 25 | |
| 26 | // Correct the opacity array for the spacing between the planes if we |
| 27 | // are using a composite blending operation |
| 28 | // TODO Fix this code for sample distance in three dimensions |
| 29 | if (this->LastBlendMode == vtkVolumeMapper::COMPOSITE_BLEND) |
| 30 | { |
| 31 | float* ptr = this->Table; |
| 32 | double factor = sampleDistance / unitDistance; |
| 33 | int i = 0; |
| 34 | while (i < this->TextureWidth) |
| 35 | { |
| 36 | if (*ptr > 0.0001f) |
| 37 | { |
| 38 | *ptr = static_cast<float>(1.0 - pow(1.0 - static_cast<double>(*ptr), factor)); |
| 39 | } |
| 40 | ++ptr; |
| 41 | ++i; |
| 42 | } |
| 43 | } |
| 44 | else if (blendMode == vtkVolumeMapper::ADDITIVE_BLEND) |
| 45 | { |
| 46 | float* ptr = this->Table; |
| 47 | double factor = sampleDistance / unitDistance; |
| 48 | int i = 0; |
| 49 | while (i < this->TextureWidth) |
| 50 | { |
| 51 | if (*ptr > 0.0001f) |
| 52 | { |
| 53 | *ptr = static_cast<float>(static_cast<double>(*ptr) * factor); |
| 54 | } |
| 55 | ++ptr; |
| 56 | ++i; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | this->TextureObject->SetWrapS(vtkTextureObject::ClampToEdge); |
| 61 | this->TextureObject->SetMagnificationFilter(filterValue); |
| 62 | this->TextureObject->SetMinificationFilter(filterValue); |
| 63 | this->TextureObject->Create2DFromRaw( |
| 64 | this->TextureWidth, 1, this->NumberOfColorComponents, VTK_FLOAT, this->Table); |
| 65 | } |
| 66 | |
| 67 | //------------------------------------------------------------------------------ |
| 68 | bool vtkOpenGLVolumeOpacityTable::NeedsUpdate( |
nothing calls this directly
no test coverage detected