Commit a2279ab2 authored by Carson Brownlee's avatar Carson Brownlee
Browse files

fix for rendering lines in polydatamapper with ospray. linewidth and pointsize fixed.

parent 2d6abac4
......@@ -206,8 +206,9 @@ OSPGeometricModel RenderAsSpheres(osp::vec3f* vertices, std::vector<unsigned int
}
OSPData positionData = ospNewCopyData1D(indexArray.size(), OSP_VEC3F, mdata.data());
ospCommit(positionData);
ospSetObject(ospMesh, "sphere.position", positionData);
ospSetFloat(ospMesh, "sphere.radius", pointSize);
ospSetFloat(ospMesh, "radius", pointSize);
// send the texture map and texture coordinates over
bool _hastm = false;
......@@ -227,6 +228,7 @@ OSPGeometricModel RenderAsSpheres(osp::vec3f* vertices, std::vector<unsigned int
tc[i] = osp::vec2f{ t1, 0 };
}
OSPData tcs = ospNewCopyData1D(indexArray.size(), OSP_VEC2F, tc.data());
ospCommit(tcs);
ospSetObject(ospMesh, "sphere.texcoord", tcs);
}
else if (numTextureCoordinates)
......@@ -243,6 +245,7 @@ OSPGeometricModel RenderAsSpheres(osp::vec3f* vertices, std::vector<unsigned int
tc[i] = osp::vec2f{ t1, t2 };
}
OSPData tcs = ospNewCopyData1D(indexArray.size(), OSP_VEC2F, tc.data());
ospCommit(tcs);
ospSetObject(ospMesh, "sphere.texcoord", tcs);
}
}
......@@ -262,23 +265,18 @@ OSPGeometricModel RenderAsSpheres(osp::vec3f* vertices, std::vector<unsigned int
{
// per cell color
// TODO: add materiallist for ospray 2.0
// ospSetInt(ospMesh, "offset_materialID", 3 * sizeof(float));
// ospSetObject(ospMesh, "materialList", CellMaterials);
}
else if (numPointColors)
{
// per point color
// ospSetInt(ospMesh, "offset_colorID", 3 * sizeof(float));
ospSetObject(ospGeoModel, "color", _PointColors);
}
else
{
// per actor color
ospSetMaterial(ospMesh, actorMaterial);
}
ospCommit(ospMesh);
// ospRelease(_PointColors);
ospSetObject(ospGeoModel, "material", actorMaterial);
ospCommit(ospGeoModel);
......@@ -307,78 +305,55 @@ OSPGeometricModel RenderAsCylinders(std::vector<osp::vec3f>& vertices,
width = 4;
scaleOffset = 3 * sizeof(float);
}
if (width > 3)
{
std::cout << "vtkPDMN: renderascylinders width 4\n";
std::vector<float> mdata(indexArray.size() * width);
std::vector<unsigned int> idata(indexArray.size());
std::vector<osp::vec4f> mdata;
mdata.reserve(indexArray.size());
for (size_t i = 0; i < indexArray.size(); i++)
{
mdata[i * width + 0] = static_cast<float>(vertices[indexArray[i]].x);
mdata[i * width + 1] = static_cast<float>(vertices[indexArray[i]].y);
mdata[i * width + 2] = static_cast<float>(vertices[indexArray[i]].z);
// mdata[i * width + 0] = static_cast<float>(vertices[i].x);
// mdata[i * width + 1] = static_cast<float>(vertices[i].y);
// mdata[i * width + 2] = static_cast<float>(vertices[i].z);
idata[i] = i;
int mat = 0;
if (numCellMaterials)
{
// TODO: handle rIndexArray
}
else if (numPointColors)
{
// TODO: handle point color array
}
if (scaleArray != nullptr)
{
double avg =
(*scaleArray->GetTuple(indexArray[i]) + *scaleArray->GetTuple(indexArray[i])) * 0.5;
mdata[i * width + 3] = MapThroughPWF(avg, scaleFunction);
}
const double avg =
(*scaleArray->GetTuple(indexArray[i]) + *scaleArray->GetTuple(indexArray[i])) * 0.5;
const double r = MapThroughPWF(avg, scaleFunction);
const osp::vec3f& v = vertices[indexArray[i]];
mdata.emplace_back(osp::vec4f({ v.x, v.y, v.z, r }));
}
OSPData _mdata = ospNewCopyData1D(indexArray.size(), OSP_VEC4F, indexArray.data());
OSPData _mdata = ospNewCopyData1D(mdata.size(), OSP_VEC4F, mdata.data());
ospCommit(_mdata);
ospSetObject(ospMesh, "vertex.position_radius", _mdata);
ospRelease(_mdata);
OSPData _idata = ospNewCopyData1D(idata.size(), OSP_UINT, idata.data());
ospCommit(_idata);
ospSetObject(ospMesh, "index", _idata);
ospRelease(_idata);
}
else
{
std::cout << "vtkPDMN: renderascylinders width 3\n";
std::cout << "vertices: ";
for (auto v : vertices)
std::cout << v.x << " " << v.y << " " << v.z << std::endl;
std::cout << endl;
OSPData _mdata = ospNewCopyData1D(vertices.size(), OSP_VEC3F, vertices.data());
std::vector<osp::vec3f> mdata;
mdata.reserve(indexArray.size());
for (size_t i = 0; i < indexArray.size(); i++)
{
mdata.emplace_back(vertices[indexArray[i]]);
}
OSPData _mdata = ospNewCopyData1D(mdata.size(), OSP_VEC3F, mdata.data());
ospCommit(_mdata);
ospSetObject(ospMesh, "vertex.position", _mdata);
ospRelease(_mdata);
std::vector<unsigned int> itest;
for (int i = 0; i < indexArray.size(); i += 2)
{
itest.push_back(indexArray[i]);
}
std::cout << "indices: ";
for (auto i : itest)
std::cout << i << " ";
std::cout << endl;
OSPData _idata = ospNewCopyData1D(itest.size(), OSP_UINT, itest.data());
// OSPData _idata = ospNewCopyData1D(indexArray.size(), OSP_UINT, indexArray.data());
ospCommit(_idata);
ospSetObject(ospMesh, "index", _idata);
ospRelease(_idata);
}
std::vector<unsigned int> indices;
indices.reserve(indexArray.size() / 2);
for (int i = 0; i < indexArray.size(); i += 2)
{
indices.push_back(i);
}
OSPData _idata = ospNewCopyData1D(indices.size(), OSP_UINT, indices.data());
ospCommit(_idata);
ospSetObject(ospMesh, "index", _idata);
ospRelease(_idata);
OSPData _PointColors = nullptr;
if (numPointColors)
{
_PointColors = ospNewCopyData1D(numPointColors, OSP_VEC4F, &PointColors[0]);
}
ospSetInt(ospMesh, "radius", lineWidth);
ospSetFloat(ospMesh, "radius", lineWidth);
ospSetInt(ospMesh, "type", OSP_ROUND);
ospSetInt(ospMesh, "basis", OSP_LINEAR);
......@@ -446,7 +421,6 @@ OSPGeometricModel RenderAsCylinders(std::vector<osp::vec3f>& vertices,
else if (numPointColors)
{
// per point color
ospSetObject(ospMesh, "vertex.color", _PointColors);
}
else
{
......
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