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

Method GenerateHash

Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:239–281  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

237
238//------------------------------------------------------------------------------
239vtkPolyDataMapper::MapperHashType vtkOpenGLPolyDataMapper::GenerateHash(vtkPolyData* polydata)
240{
241 int cellFlag = 0;
242 vtkAbstractArray* scalars = this->GetAbstractScalars(
243 polydata, this->ScalarMode, this->ArrayAccessMode, this->ArrayId, this->ArrayName, cellFlag);
244 bool hasScalars = this->ScalarVisibility && (scalars != nullptr);
245 bool hasPointScalars = hasScalars && !cellFlag;
246 // Field data scalar mode treats field data like cell data
247 bool hasCellScalars = hasScalars && (cellFlag == 1 || cellFlag == 2);
248
249 bool usesPointNormals = polydata->GetPointData()->GetNormals() != nullptr;
250 bool usesPointTexCoords = polydata->GetPointData()->GetTCoords() != nullptr;
251 bool usesPointColorsWithTextureMaps =
252 this->CanUseTextureMapForColoring(polydata) && hasPointScalars;
253 bool usesPointColors = !usesPointColorsWithTextureMaps && hasPointScalars;
254 bool usesCellColorTexture = !usesPointColorsWithTextureMaps && !usesPointColors && hasCellScalars;
255 bool usesCellNormalTexture =
256 !usesPointNormals && (polydata->GetCellData()->GetNormals() != nullptr);
257
258 // The hash is seeded from the address of the lookup table.
259 // WARNING: Technically, hash will overflow when
260 // &(lut) >= max_n_bit_ptr_address - 126, where n == 32 or n == 64
261 MapperHashType hash = 0;
262 // Get the lookup table.
263 vtkDataArray* dataArray = vtkArrayDownCast<vtkDataArray>(scalars);
264 vtkScalarsToColors* lut = nullptr;
265 if (dataArray && dataArray->GetLookupTable())
266 {
267 lut = vtkScalarsToColors::SafeDownCast(dataArray->GetLookupTable());
268 }
269 else
270 {
271 lut = this->LookupTable;
272 }
273 hash = std::hash<MapperHashType>{}(reinterpret_cast<std::uintptr_t>(lut));
274 hash += (usesPointColors << 1);
275 hash += (usesPointNormals << 2);
276 hash += (usesPointTexCoords << 3);
277 hash += (usesPointColorsWithTextureMaps << 4);
278 hash += (usesCellColorTexture << 5);
279 hash += (usesCellNormalTexture << 6);
280 return hash;
281}
282
283//------------------------------------------------------------------------------
284void vtkOpenGLPolyDataMapper::BuildShaders(

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