------------------------------------------------------------------------------
| 294 | |
| 295 | //------------------------------------------------------------------------------ |
| 296 | bool vtkVolumeTexture::LoadTexture(int interpolation, VolumeBlock* volBlock) |
| 297 | { |
| 298 | int const noOfComponents = this->Scalars->GetNumberOfComponents(); |
| 299 | int scalarType = this->Scalars->GetDataType(); |
| 300 | |
| 301 | auto dataSet = volBlock->DataSet; |
| 302 | auto imBlock = vtkImageData::SafeDownCast(dataSet); |
| 303 | auto rgBlock = vtkRectilinearGrid::SafeDownCast(dataSet); |
| 304 | int blockExt[6]; |
| 305 | if (imBlock) |
| 306 | { |
| 307 | imBlock->GetExtent(blockExt); |
| 308 | } |
| 309 | else if (rgBlock) |
| 310 | { |
| 311 | rgBlock->GetExtent(blockExt); |
| 312 | } |
| 313 | Size3 const& blockSize = volBlock->TextureSize; |
| 314 | vtkTextureObject* texture = volBlock->TextureObject; |
| 315 | vtkIdType const& tupleIdx = volBlock->TupleIndex; |
| 316 | |
| 317 | auto ostate = texture->GetContext()->GetState(); |
| 318 | |
| 319 | bool success = true; |
| 320 | if (!this->HandleLargeDataTypes) |
| 321 | { |
| 322 | // Adjust strides used by OpenGL to load the data (X and Y strides in case the |
| 323 | // texture had to be split on those axis). |
| 324 | bool const useXStride = blockSize[0] != this->FullSize[0]; |
| 325 | if (useXStride) |
| 326 | { |
| 327 | ostate->vtkglPixelStorei(GL_UNPACK_ROW_LENGTH, this->FullSize[0]); |
| 328 | } |
| 329 | |
| 330 | bool const useYStride = blockSize[1] != this->FullSize[1]; |
| 331 | if (useYStride) |
| 332 | { |
| 333 | ostate->vtkglPixelStorei(GL_UNPACK_IMAGE_HEIGHT, this->FullSize[1]); |
| 334 | } |
| 335 | |
| 336 | // Account for component offset |
| 337 | // index = ( z0 * Dx * Dy + y0 * Dx + x0 ) * numComp |
| 338 | vtkIdType const dataIdx = tupleIdx * noOfComponents; |
| 339 | void* dataPtr = this->Scalars->GetVoidPointer(dataIdx); |
| 340 | |
| 341 | if (this->StreamBlocks) |
| 342 | { |
| 343 | success = texture->Create3DFromRaw( |
| 344 | blockSize[0], blockSize[1], blockSize[2], noOfComponents, scalarType, dataPtr); |
| 345 | } |
| 346 | else |
| 347 | { |
| 348 | success = SafeLoadTexture( |
| 349 | texture, blockSize[0], blockSize[1], blockSize[2], noOfComponents, scalarType, dataPtr); |
| 350 | } |
| 351 | texture->Activate(); |
| 352 | texture->SetWrapS(vtkTextureObject::ClampToEdge); |
| 353 | texture->SetWrapT(vtkTextureObject::ClampToEdge); |
no test coverage detected