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

prepare to make atoms and or bonds instead of just atoms

also makes Don't RenderAtoms work
parent 93379a1e
......@@ -34,10 +34,7 @@
vtkStandardNewMacro(vtkOSPRayMoleculeMapperNode);
//----------------------------------------------------------------------------
vtkOSPRayMoleculeMapperNode::vtkOSPRayMoleculeMapperNode()
{
this->OSPMesh = nullptr;
}
vtkOSPRayMoleculeMapperNode::vtkOSPRayMoleculeMapperNode() {}
//----------------------------------------------------------------------------
vtkOSPRayMoleculeMapperNode::~vtkOSPRayMoleculeMapperNode()
......@@ -48,7 +45,11 @@ vtkOSPRayMoleculeMapperNode::~vtkOSPRayMoleculeMapperNode()
RTW::Backend* backend = orn->GetBackend();
if (backend != nullptr)
{
ospRelease(this->OSPMesh);
for (auto g : this->Geometries)
{
ospRelease(g);
}
this->Geometries.clear();
}
}
delete this->Cache;
......@@ -87,10 +88,16 @@ void vtkOSPRayMoleculeMapperNode::Render(bool prepass)
vtkMolecule* molecule = mapper->GetInput();
if (mapper->GetMTime() > this->BuildTime || molecule->GetMTime() > this->BuildTime)
{
ospRelease(this->OSPMesh);
for (auto g : this->Geometries)
{
ospRelease(g);
}
this->Geometries.clear();
if (mapper->GetRenderAtoms())
{
OSPGeometry atoms;
vtkPoints* allPoints = molecule->GetAtomicPositionArray();
float* mdata = new float[molecule->GetNumberOfAtoms() * 5];
int* idata = (int*)mdata;
......@@ -121,16 +128,18 @@ void vtkOSPRayMoleculeMapperNode::Render(bool prepass)
OSPData colors = ospNewData(molecule->GetNumberOfAtoms(), OSP_FLOAT4, &_colors[0]);
ospCommit(colors);
this->OSPMesh = ospNewGeometry("spheres");
ospSetObject(this->OSPMesh, "spheres", mesh);
ospSet1f(this->OSPMesh, "radius", 1.0);
ospSet1i(this->OSPMesh, "bytes_per_sphere", 5 * sizeof(float));
ospSet1i(this->OSPMesh, "offset_center", 0 * sizeof(float));
ospSet1i(this->OSPMesh, "offset_radius", 3 * sizeof(float));
ospSet1i(this->OSPMesh, "offset_colorID", 4 * sizeof(float));
ospSetData(this->OSPMesh, "color", colors);
atoms = ospNewGeometry("spheres");
ospSetObject(atoms, "spheres", mesh);
ospSet1f(atoms, "radius", 1.0);
ospSet1i(atoms, "bytes_per_sphere", 5 * sizeof(float));
ospSet1i(atoms, "offset_center", 0 * sizeof(float));
ospSet1i(atoms, "offset_radius", 3 * sizeof(float));
ospSet1i(atoms, "offset_colorID", 4 * sizeof(float));
ospSetData(atoms, "color", colors);
this->Geometries.emplace_back(atoms);
ospCommit(this->OSPMesh);
ospCommit(atoms);
ospRelease(mesh);
ospRelease(colors);
......@@ -140,5 +149,8 @@ void vtkOSPRayMoleculeMapperNode::Render(bool prepass)
this->BuildTime.Modified();
}
ospAddGeometry(oModel, this->OSPMesh);
for (auto g : this->Geometries)
{
ospAddGeometry(oModel, g);
}
}
......@@ -27,6 +27,7 @@
#include "vtkRenderingRayTracingModule.h" // For export macro
#include "RTWrapper/RTWrapper.h" // for handle types
#include <vector>
class VTKRENDERINGRAYTRACING_EXPORT vtkOSPRayMoleculeMapperNode : public vtkPolyDataMapperNode
{
......@@ -45,9 +46,10 @@ protected:
~vtkOSPRayMoleculeMapperNode() override;
vtkOSPRayCache<vtkOSPRayCacheItemObject>* Cache;
OSPGeometry OSPMesh;
vtkTimeStamp BuildTime;
std::vector<OSPGeometry> Geometries;
private:
vtkOSPRayMoleculeMapperNode(const vtkOSPRayMoleculeMapperNode&) = delete;
void operator=(const vtkOSPRayMoleculeMapperNode&) = delete;
......
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