Commit 93379a1e authored by David E. DeMarle's avatar David E. DeMarle
Browse files

hook up atom scaling

Well at least VanderWaal scaling. As with color, most of the modes
are not fleshed out yet.
parent 141ebf36
......@@ -298,6 +298,8 @@ public:
*/
virtual void SetMapScalars(bool map);
vtkPeriodicTable* GetPeriodicTable() { return this->PeriodicTable; }
protected:
vtkMoleculeMapper();
~vtkMoleculeMapper() override;
......
......@@ -88,30 +88,34 @@ void vtkOSPRayMoleculeMapperNode::Render(bool prepass)
if (mapper->GetMTime() > this->BuildTime || molecule->GetMTime() > this->BuildTime)
{
ospRelease(this->OSPMesh);
if (mapper->GetRenderAtoms())
{
vtkPoints* allPoints = molecule->GetAtomicPositionArray();
float* mdata = new float[molecule->GetNumberOfAtoms() * 4];
float* mdata = new float[molecule->GetNumberOfAtoms() * 5];
int* idata = (int*)mdata;
vtkUnsignedShortArray* inputColorArray = molecule->GetAtomicNumberArray();
vtkUnsignedShortArray* atomicNumbers = molecule->GetAtomicNumberArray();
vtkScalarsToColors* lut = mapper->GetLookupTable();
float* _colors = new float[molecule->GetNumberOfAtoms() * 4];
float* _colors = new float[molecule->GetNumberOfAtoms() * 5];
for (size_t i = 0; i < molecule->GetNumberOfAtoms(); i++)
{
mdata[i * 4 + 0] = static_cast<float>(allPoints->GetPoint(i)[0]);
mdata[i * 4 + 1] = static_cast<float>(allPoints->GetPoint(i)[1]);
mdata[i * 4 + 2] = static_cast<float>(allPoints->GetPoint(i)[2]);
idata[i * 4 + 3] = i; // index into colors array
mdata[i * 5 + 0] = static_cast<float>(allPoints->GetPoint(i)[0]);
mdata[i * 5 + 1] = static_cast<float>(allPoints->GetPoint(i)[1]);
mdata[i * 5 + 2] = static_cast<float>(allPoints->GetPoint(i)[2]);
mdata[i * 5 + 3] = mapper->GetAtomicRadiusScaleFactor() *
mapper->GetPeriodicTable()->GetVDWRadius(atomicNumbers->GetValue(i));
const unsigned char* ucolor = lut->MapValue(inputColorArray->GetTuple1(i));
idata[i * 5 + 4] = i; // index into colors array
const unsigned char* ucolor = lut->MapValue(atomicNumbers->GetTuple1(i));
_colors[i * 4 + 0] = static_cast<float>(ucolor[0] / 255.0);
_colors[i * 4 + 1] = static_cast<float>(ucolor[1] / 255.0);
_colors[i * 4 + 2] = static_cast<float>(ucolor[2] / 255.0);
_colors[i * 4 + 3] = static_cast<float>(ucolor[3] / 255.0);
}
OSPData mesh = ospNewData(molecule->GetNumberOfAtoms(), OSP_FLOAT4, &mdata[0]);
OSPData mesh = ospNewData(molecule->GetNumberOfAtoms() * 5, OSP_FLOAT, &mdata[0]);
ospCommit(mesh);
OSPData colors = ospNewData(molecule->GetNumberOfAtoms(), OSP_FLOAT4, &_colors[0]);
......@@ -120,10 +124,12 @@ void vtkOSPRayMoleculeMapperNode::Render(bool prepass)
this->OSPMesh = ospNewGeometry("spheres");
ospSetObject(this->OSPMesh, "spheres", mesh);
ospSet1f(this->OSPMesh, "radius", 1.0);
ospSet1i(this->OSPMesh, "bytes_per_sphere", 4 * sizeof(float));
ospSet1i(this->OSPMesh, "bytes_per_sphere", 5 * sizeof(float));
ospSet1i(this->OSPMesh, "offset_center", 0 * sizeof(float));
ospSet1i(this->OSPMesh, "offset_colorID", 3 * sizeof(float));
ospSet1i(this->OSPMesh, "offset_radius", 3 * sizeof(float));
ospSet1i(this->OSPMesh, "offset_colorID", 4 * sizeof(float));
ospSetData(this->OSPMesh, "color", colors);
ospCommit(this->OSPMesh);
ospRelease(mesh);
ospRelease(colors);
......
Supports Markdown
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