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

Method BuildSelectionCache

Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:4419–4461  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

4417
4418//------------------------------------------------------------------------------
4419void vtkOpenGLPolyDataMapper::BuildSelectionCache(
4420 const char* arrayName, bool selectingPoints, vtkPolyData* poly)
4421{
4422 if (arrayName &&
4423 (this->SelectionCacheForPoints != selectingPoints || this->SelectionCacheName != arrayName ||
4424 this->SelectionCacheTime < poly->GetMTime() || poly != this->SelectionPolyData))
4425 {
4426 // the cache needs a rebuild
4427 this->SelectionCache.clear();
4428
4429 vtkDataSetAttributes* attr = selectingPoints
4430 ? static_cast<vtkDataSetAttributes*>(poly->GetPointData())
4431 : static_cast<vtkDataSetAttributes*>(poly->GetCellData());
4432
4433 auto idArray = vtkIdTypeArray::SafeDownCast(attr->GetArray(arrayName));
4434 vtkDataArray* compositeArray = attr->GetArray(this->CompositeIdArrayName);
4435 vtkDataArray* processArray = attr->GetArray(this->ProcessIdArrayName);
4436
4437 // a selection cache is built here to map a tuple (process id, composite id, value id) to the
4438 // the selected id. This will speed up look-ups at runtime.
4439 if (idArray && idArray->GetNumberOfComponents() == 1)
4440 {
4441 using UIntArrays =
4442 vtkTypeList::Create<vtkAOSDataArrayTemplate<unsigned int>, vtkConstantArray<unsigned int>>;
4443 using Dispatcher = vtkArrayDispatch::Dispatch2ByArray<UIntArrays, UIntArrays>;
4444 CompositeProcessFunctor functor;
4445 if (!Dispatcher::Execute(
4446 compositeArray, processArray, functor, idArray, this->SelectionCache))
4447 {
4448 if ((!compositeArray || compositeArray->GetDataType() == VTK_UNSIGNED_INT) &&
4449 (!processArray || processArray->GetDataType() == VTK_UNSIGNED_INT))
4450 {
4451 functor(compositeArray, processArray, idArray, this->SelectionCache);
4452 }
4453 }
4454 }
4455
4456 this->SelectionCacheForPoints = selectingPoints;
4457 this->SelectionCacheName = arrayName;
4458 this->SelectionCacheTime = poly->GetMTime();
4459 this->SelectionPolyData = poly;
4460 }
4461}
4462
4463//------------------------------------------------------------------------------
4464void vtkOpenGLPolyDataMapper::ShallowCopy(vtkAbstractMapper* mapper)

Calls 8

ExecuteFunction · 0.50
GetMTimeMethod · 0.45
clearMethod · 0.45
GetPointDataMethod · 0.45
GetCellDataMethod · 0.45
GetArrayMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetDataTypeMethod · 0.45

Tested by

no test coverage detected