--------------------------------------------------------------------------
| 53 | |
| 54 | //-------------------------------------------------------------------------- |
| 55 | void Update(vtkRenderer* ren, vtkImageData* input, int cellFlag, int textureExtent[6], |
| 56 | int scalarMode, int arrayAccessMode, int arrayId, const char* arrayName, |
| 57 | vtkIdType maxMemoryInBytes) |
| 58 | { |
| 59 | bool needUpdate = false; |
| 60 | bool modified = false; |
| 61 | |
| 62 | if (!this->Texture) |
| 63 | { |
| 64 | this->Texture = vtkTextureObject::New(); |
| 65 | needUpdate = true; |
| 66 | } |
| 67 | |
| 68 | vtkOpenGLRenderWindow* renWin = vtkOpenGLRenderWindow::SafeDownCast(ren->GetRenderWindow()); |
| 69 | auto ostate = renWin->GetState(); |
| 70 | this->Texture->SetContext(renWin); |
| 71 | |
| 72 | if (!this->Texture->GetHandle()) |
| 73 | { |
| 74 | needUpdate = true; |
| 75 | } |
| 76 | |
| 77 | int obsolete = needUpdate || !this->Loaded || input->GetMTime() > this->BuildTime; |
| 78 | if (!obsolete) |
| 79 | { |
| 80 | obsolete = cellFlag != this->LoadedCellFlag; |
| 81 | int i = 0; |
| 82 | while (!obsolete && i < 6) |
| 83 | { |
| 84 | obsolete = obsolete || this->LoadedExtent[i] > textureExtent[i]; |
| 85 | ++i; |
| 86 | obsolete = obsolete || this->LoadedExtent[i] < textureExtent[i]; |
| 87 | ++i; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | if (obsolete) |
| 92 | { |
| 93 | this->Loaded = false; |
| 94 | int dim[3]; |
| 95 | input->GetDimensions(dim); |
| 96 | |
| 97 | vtkDataArray* scalars = vtkAbstractMapper::GetScalars( |
| 98 | input, scalarMode, arrayAccessMode, arrayId, arrayName, this->LoadedCellFlag); |
| 99 | |
| 100 | // DON'T USE GetScalarType() or GetNumberOfScalarComponents() on |
| 101 | // ImageData as it deals only with point data... |
| 102 | int scalarType = scalars->GetDataType(); |
| 103 | if (scalarType != VTK_UNSIGNED_CHAR) |
| 104 | { |
| 105 | std::cout << "Mask should be VTK_UNSIGNED_CHAR." << std::endl; |
| 106 | } |
| 107 | if (scalars->GetNumberOfComponents() != 1) |
| 108 | { |
| 109 | std::cout << "Mask should be a one-component scalar field." << std::endl; |
| 110 | } |
| 111 | |
| 112 | GLint internalFormat = GL_R8; |
no test coverage detected