Commit 3d45971d authored by Carson Brownlee's avatar Carson Brownlee
Browse files

adding isosurface support

parent bd32197f
......@@ -300,42 +300,57 @@ void vtkOSPRayVolumeMapperNode::Render(bool prepass)
this->BuildTime.Modified();
// todo: add isosurfaces
// vtkContourValues* contours = volProperty->GetIsoSurfaceValues();
// if (mapper->GetBlendMode() == vtkVolumeMapper::ISOSURFACE_BLEND)
// {
// int nbContours = contours->GetNumberOfContours();
// if (nbContours > 0)
// {
// double* p = contours->GetValues();
// std::vector<float> values(p, p + nbContours);
// // this->OSPRayIsosurface = ospNewGeometry("isosurfaces");
// // OSPData isosurfaces = ospNewData(values.size(), OSP_FLOAT, values.data());
// // ospSetData(this->OSPRayIsosurface, "isovalues", isosurfaces);
// // ospSetObject(this->OSPRayIsosurface, "volume", this->OSPRayVolume);
// // ospCommit(this->OSPRayIsosurface);
// // ospAddGeometry(OSPRayModel, this->OSPRayIsosurface);
// }
// else
// {
// vtkWarningMacro("Isosurface mode is selected but no contour is defined");
// }
// }
// else
// {
// orn->VolumetricModels.emplace_back(this->OSPRayVolumeModel);
OSPGroup group = ospNewGroup();
OSPInstance instance = ospNewInstance(group);
ospCommit(instance);
OSPData instanceData = ospNewCopyData1D(1, OSP_VOLUMETRIC_MODEL, &this->OSPRayVolumeModel);
ospCommit(instanceData);
ospSetObject(group, "volume", instanceData);
ospCommit(group);
orn->Instances.emplace_back(instance);
this->OSPRayInstance = instance;
// }
vtkContourValues* contours = volProperty->GetIsoSurfaceValues();
if (mapper->GetBlendMode() == vtkVolumeMapper::ISOSURFACE_BLEND)
{
int nbContours = contours->GetNumberOfContours();
if (nbContours > 0)
{
double* p = contours->GetValues();
std::vector<float> values(p, p + nbContours);
this->OSPRayIsosurface = ospNewGeometry("isosurface");
OSPData isosurfaces = ospNewCopyData1D(values.size(), OSP_FLOAT, values.data());
ospCommit(isosurfaces);
ospSetObject(this->OSPRayIsosurface, "isovalue", isosurfaces);
ospSetObject(this->OSPRayIsosurface, "volume", this->OSPRayVolumeModel);
ospCommit(this->OSPRayIsosurface);
OSPGroup group = ospNewGroup();
OSPInstance instance = ospNewInstance(group);
ospCommit(instance);
ospRelease(group);
this->OSPRayGeometricModel = ospNewGeometricModel(this->OSPRayIsosurface);
ospCommit(this->OSPRayGeometricModel);
ospRelease(this->OSPRayIsosurface);
OSPData instanceData =
ospNewCopyData1D(1, OSP_GEOMETRIC_MODEL, &this->OSPRayGeometricModel);
ospRelease(this->OSPRayGeometricModel);
ospCommit(instanceData);
ospSetObject(group, "geometry", instanceData);
ospCommit(group);
orn->Instances.emplace_back(instance);
this->OSPRayInstance = instance;
}
else
{
vtkWarningMacro("Isosurface mode is selected but no contour is defined");
}
}
else
{
OSPGroup group = ospNewGroup();
OSPInstance instance = ospNewInstance(group);
ospCommit(instance);
ospRelease(group);
OSPData instanceData = ospNewCopyData1D(1, OSP_VOLUMETRIC_MODEL, &this->OSPRayVolumeModel);
ospCommit(instanceData);
ospSetObject(group, "volume", instanceData);
ospCommit(group);
orn->Instances.emplace_back(instance);
this->OSPRayInstance = instance;
}
if (sca)
{
......
......@@ -75,6 +75,7 @@ protected:
OSPGeometry OSPRayIsosurface;
OSPVolume OSPRayVolume{ nullptr };
OSPVolumetricModel OSPRayVolumeModel{ nullptr };
OSPGeometricModel OSPRayGeometricModel{ nullptr };
OSPInstance OSPRayInstance{ nullptr };
OSPTransferFunction TransferFunction;
std::vector<float> TFVals;
......
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