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

Method GenerateHash

Rendering/OpenGL2/vtkOpenGLLowMemoryPolyDataMapper.cxx:521–566  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

519
520//------------------------------------------------------------------------------
521vtkPolyDataMapper::MapperHashType vtkOpenGLLowMemoryPolyDataMapper::GenerateHash(
522 vtkPolyData* polydata)
523{
524 int cellFlag = 0;
525 vtkAbstractArray* scalars = this->GetAbstractScalars(
526 polydata, this->ScalarMode, this->ArrayAccessMode, this->ArrayId, this->ArrayName, cellFlag);
527 bool hasScalars = this->ScalarVisibility && (scalars != nullptr);
528 bool hasPointScalars = hasScalars && !cellFlag;
529 bool hasCellScalars = hasScalars && cellFlag == 1;
530
531 bool usesPointNormals = polydata->GetPointData()->GetNormals() != nullptr;
532 bool usesPointTexCoords = polydata->GetPointData()->GetTCoords() != nullptr;
533 bool usesPointColorsWithTextureMaps =
534 this->CanUseTextureMapForColoring(polydata) && hasPointScalars;
535 bool usesPointColors = !usesPointColorsWithTextureMaps && hasPointScalars;
536 bool usesCellColorTexture = !usesPointColorsWithTextureMaps && !usesPointColors && hasCellScalars;
537 bool usesCellNormalTexture =
538 !usesPointNormals && (polydata->GetCellData()->GetNormals() != nullptr);
539
540 // The hash is seeded from the address of the lookup table.
541 // WARNING: Technically, hash will overflow when
542 // &(lut) >= max_n_bit_ptr_address - 126, where n == 32 or n == 64
543 MapperHashType hash = 0;
544 // Get the lookup table.
545 vtkDataArray* dataArray = vtkArrayDownCast<vtkDataArray>(scalars);
546 vtkScalarsToColors* lut = nullptr;
547 if (dataArray && dataArray->GetLookupTable())
548 {
549 lut = vtkScalarsToColors::SafeDownCast(dataArray->GetLookupTable());
550 }
551 else
552 {
553 lut = this->LookupTable;
554 }
555 hash = std::hash<MapperHashType>{}(reinterpret_cast<std::uintptr_t>(lut));
556 hash += (usesPointColors << 1);
557 hash += (usesPointNormals << 2);
558 hash += (usesPointTexCoords << 3);
559 hash += (usesPointColorsWithTextureMaps << 4);
560 hash += (usesCellColorTexture << 5);
561 hash += (usesCellNormalTexture << 6);
562#ifdef vtkOpenGLLowMemoryPolyDataMapper_DEBUG
563 std::cout << "hash: " << hash << " for " << polydata << '\n';
564#endif
565 return hash;
566}
567
568//------------------------------------------------------------------------------
569bool vtkOpenGLLowMemoryPolyDataMapper::BindArraysToTextureBuffers(

Callers

nothing calls this directly

Calls 7

GetAbstractScalarsMethod · 0.80
GetNormalsMethod · 0.45
GetPointDataMethod · 0.45
GetTCoordsMethod · 0.45
GetCellDataMethod · 0.45
GetLookupTableMethod · 0.45

Tested by

no test coverage detected