Commit 69bb2b15 authored by David C. Lonie's avatar David C. Lonie
Browse files

Allow vtkMoleculeMapper's color array to be changed.

No longer hardcoded to "Atomic Numbers".
parent 3cc2b845
Pipeline #23474 passed with stage
......@@ -370,10 +370,25 @@ void vtkMoleculeMapper::UpdateAtomGlyphPolyData()
vtkMolecule *molecule = this->GetInput();
const vtkIdType numAtoms = molecule->GetNumberOfAtoms();
int assoc; // output var for GetInputAbstractArrayToProcess
vtkAbstractArray *colorArray =
this->GetInputAbstractArrayToProcess(0, molecule, assoc);
if (colorArray)
{
if (colorArray->GetNumberOfTuples() != molecule->GetNumberOfAtoms())
{
vtkErrorMacro("Color array size does not match number of atoms.");
}
else
{
int colorArrayIdx =
this->AtomGlyphPolyData->GetPointData()->AddArray(colorArray);
this->AtomGlyphMapper->SelectColorArray(colorArrayIdx);
}
}
vtkUnsignedShortArray *atomicNums = molecule->GetAtomicNumberArray();
this->AtomGlyphPolyData->GetPointData()->AddArray(atomicNums);
this->AtomGlyphPolyData->SetPoints(molecule->GetAtomicPositionArray());
this->AtomGlyphMapper->SelectColorArray("Atomic Numbers");
this->AtomGlyphMapper->SetLookupTable(this->LookupTable);
vtkNew<vtkFloatArray> scaleFactors;
......
......@@ -19,11 +19,11 @@
#include "vtkEventForwarderCommand.h"
#include "vtkGlyph3DMapper.h"
#include "vtkLookupTable.h"
#include "vtkMolecule.h"
#include "vtkObjectFactory.h"
#include "vtkPeriodicTable.h"
#include "vtkTrivialProducer.h"
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkOpenGLMoleculeMapper)
......@@ -100,9 +100,11 @@ void vtkOpenGLMoleculeMapper::UpdateAtomGlyphPolyData()
{
this->Superclass::UpdateAtomGlyphPolyData();
this->FastAtomMapper->SetLookupTable(this->AtomGlyphMapper->GetLookupTable());
this->FastAtomMapper->SelectColorArray("Atomic Numbers");
this->FastAtomMapper->SetScaleArray("Scale Factors");
this->FastAtomMapper->SetScalarMaterialMode(this->GetScalarMaterialMode());
// Copy the color array info:
this->FastAtomMapper->SelectColorArray(this->AtomGlyphMapper->GetArrayId());
}
//----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment