------------------------------------------------------------------------------
| 235 | |
| 236 | //------------------------------------------------------------------------------ |
| 237 | void vtkMultiBlockVolumeMapper::CreateMappers( |
| 238 | vtkDataObjectTree* input, vtkRenderer* ren, vtkVolume* vol) |
| 239 | { |
| 240 | // Hierarchical case |
| 241 | vtkCompositeDataIterator* it = input->NewIterator(); |
| 242 | it->GoToFirstItem(); |
| 243 | |
| 244 | bool warnedOnce = false; |
| 245 | bool allBlocksLoaded = true; |
| 246 | while (!it->IsDoneWithTraversal()) |
| 247 | { |
| 248 | vtkImageData* currentIm = vtkImageData::SafeDownCast(it->GetCurrentDataObject()); |
| 249 | vtkRectilinearGrid* currentRect = vtkRectilinearGrid::SafeDownCast(it->GetCurrentDataObject()); |
| 250 | if (!warnedOnce && !currentIm && !currentRect) |
| 251 | { |
| 252 | vtkErrorMacro("At least one block in the data object is not of type" |
| 253 | " vtkImageData or vtkRectilinearGrid. These blocks will be ignored."); |
| 254 | warnedOnce = true; |
| 255 | it->GoToNextItem(); |
| 256 | continue; |
| 257 | } |
| 258 | |
| 259 | vtkSmartVolumeMapper* mapper = this->CreateMapper(); |
| 260 | this->Mappers.push_back(mapper); |
| 261 | |
| 262 | if (currentIm) |
| 263 | { |
| 264 | vtkNew<vtkImageData> im; |
| 265 | im->ShallowCopy(currentIm); |
| 266 | mapper->SetInputData(im); |
| 267 | } |
| 268 | else if (currentRect) |
| 269 | { |
| 270 | vtkNew<vtkRectilinearGrid> rg; |
| 271 | rg->ShallowCopy(currentRect); |
| 272 | mapper->SetInputData(rg); |
| 273 | } |
| 274 | |
| 275 | // Try allocating GPU memory only while succeeding |
| 276 | if (allBlocksLoaded) |
| 277 | { |
| 278 | vtkOpenGLGPUVolumeRayCastMapper* glMapper = |
| 279 | vtkOpenGLGPUVolumeRayCastMapper::SafeDownCast(mapper->GetGPUMapper()); |
| 280 | |
| 281 | if (glMapper && currentIm) |
| 282 | { |
| 283 | vtkImageData* imageInternal = vtkImageData::New(); |
| 284 | imageInternal->ShallowCopy(currentIm); |
| 285 | |
| 286 | glMapper->SetInputData(imageInternal); |
| 287 | glMapper->SelectScalarArray(this->ArrayName); |
| 288 | glMapper->SelectScalarArray(this->ArrayId); |
| 289 | glMapper->SetScalarMode(this->ScalarMode); |
| 290 | glMapper->SetArrayAccessMode(this->ArrayAccessMode); |
| 291 | |
| 292 | allBlocksLoaded &= glMapper->PreLoadData(ren, vol); |
| 293 | imageInternal->Delete(); |
| 294 | } |
no test coverage detected