MCPcopy Create free account
hub / github.com/Kitware/VTK / CreateMappers

Method CreateMappers

Rendering/VolumeOpenGL2/vtkMultiBlockVolumeMapper.cxx:237–310  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

235
236//------------------------------------------------------------------------------
237void 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 }

Callers 1

LoadDataSetMethod · 0.95

Calls 15

CreateMapperMethod · 0.95
PreLoadDataMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
NewIteratorMethod · 0.45
GoToFirstItemMethod · 0.45
IsDoneWithTraversalMethod · 0.45
GetCurrentDataObjectMethod · 0.45
GoToNextItemMethod · 0.45
push_backMethod · 0.45
ShallowCopyMethod · 0.45

Tested by

no test coverage detected