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

Method UpdateAtomGlyphPolyData

Domains/Chemistry/vtkMoleculeMapper.cxx:355–507  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Generate scale and position information for each atom sphere

Source from the content-addressed store, hash-verified

353//------------------------------------------------------------------------------
354// Generate scale and position information for each atom sphere
355void vtkMoleculeMapper::UpdateAtomGlyphPolyData()
356{
357 this->AtomGlyphPolyData->Initialize();
358
359 vtkMolecule* molecule = this->GetInput();
360
361 vtkAbstractArray* inputColorArray = this->GetInputAbstractArrayToProcess(0, molecule);
362 vtkAbstractArray* colorArray = nullptr;
363 vtkUnsignedCharArray* singleColorArray = nullptr;
364 switch (this->AtomColorMode)
365 {
366 case SingleColor:
367 {
368 colorArray = vtkUnsignedCharArray::New();
369 colorArray->SetNumberOfComponents(3);
370 vtkIdType size = 3 * molecule->GetNumberOfAtoms();
371 colorArray->Allocate(size);
372 colorArray->SetName("Colors");
373 singleColorArray = vtkArrayDownCast<vtkUnsignedCharArray>(colorArray);
374 this->AtomGlyphPolyData->GetPointData()->SetScalars(singleColorArray);
375 break;
376 }
377 case DiscreteByAtom:
378 default:
379 if (inputColorArray != nullptr)
380 {
381 colorArray = inputColorArray->NewInstance();
382 colorArray->SetNumberOfComponents(inputColorArray->GetNumberOfComponents());
383 colorArray->Allocate(colorArray->GetNumberOfComponents() * molecule->GetNumberOfAtoms());
384 }
385 this->AtomGlyphMapper->SetLookupTable(this->LookupTable);
386 break;
387 }
388
389 vtkNew<vtkUnsignedShortArray> atomicNbWithoutGhostArray;
390 vtkUnsignedShortArray* atomicNbFullArray = molecule->GetAtomicNumberArray();
391 vtkNew<vtkPoints> points;
392 vtkPoints* allPoints = molecule->GetAtomicPositionArray();
393 vtkUnsignedCharArray* ghosts = molecule->GetAtomGhostArray();
394 for (vtkIdType i = 0; i < molecule->GetNumberOfAtoms(); i++)
395 {
396 /**
397 * Skip ghost atoms but not ghost bonds:
398 * - each atom is non-ghost for exactly one MPI node, that will handle it.
399 * - a ghost bond links an atom and a ghost atom. So there is exactly two MPI nodes
400 * that contain this ghost bond and no one that contains this bond as non-ghost.
401 * We let this two MPI nodes handle the ghost bond, as we cannot know if the bond
402 * was already handled.
403 */
404 if (ghosts && ghosts->GetValue(i) == 1)
405 {
406 continue;
407 }
408 atomicNbWithoutGhostArray->InsertNextValue(atomicNbFullArray->GetValue(i));
409 points->InsertNextPoint(allPoints->GetPoint(i));
410 if (this->AtomColorMode == SingleColor)
411 {
412 singleColorArray->InsertNextTypedTuple(this->AtomColor);

Callers 1

UpdateGlyphPolyDataMethod · 0.95

Calls 15

GetInputMethod · 0.95
GetNumberOfAtomsMethod · 0.80
SetScalarsMethod · 0.80
GetAtomicNumberArrayMethod · 0.80
GetAtomGhostArrayMethod · 0.80
GetVDWRadiusMethod · 0.80
GetCovalentRadiusMethod · 0.80
GetVertexDataMethod · 0.80
FillComponentMethod · 0.80
GetTuple1Method · 0.80

Tested by

no test coverage detected