Commit e989eb1a authored by Carson Brownlee's avatar Carson Brownlee Committed by Carson Brownlee
Browse files

removing debug output. adding cylinders back in

parent e722d1db
......@@ -103,6 +103,18 @@ std::set<RTWBackendType> rtwGetAvailableBackends();
#define OSP_FB_NORMAL RTW_FB_NORMAL
#define OSP_FB_ALBEDO RTW_FB_ALBEDO
#define OSP_ROUND RTW_ROUND
#define OSP_FLAT RTW_FLAT
#define OSP_RIBBON RTW_RIBBON
#define OSP_UNKNOWN_CURVE_TYPE RTW_UNKNOWN_CURVE_TYPE
#define OSP_LINEAR RTW_LINEAR
#define OSP_BEZIER RTW_BEZIER
#define OSP_BSPLINE RTW_BSPLINE
#define OSP_HERMITE RTW_HERMITE
#define OSP_CATMULL_ROM RTW_CATMULL_ROM
#define OSP_UNKNOWN_CURVE_BASIS RTW_UNKOWN_CURVE_BASIS
#define ospSetFloat backend->SetFloat
#define ospSetBool backend->SetBool
#define ospSetInt backend->SetInt
......
......@@ -71,6 +71,32 @@ typedef enum
RTW_STEREO_UNKNOWN = 255
} RTWStereoMode;
// OSPRay Curves geometry types
typedef enum
#if __cplusplus >= 201103L
: uint8_t
#endif
{
RTW_ROUND,
RTW_FLAT,
RTW_RIBBON,
RTW_UNKNOWN_CURVE_TYPE = 255
} RTWCurveType;
// OSPRay Curves geometry bases
typedef enum
#if __cplusplus >= 201103L
: uint8_t
#endif
{
RTW_LINEAR,
RTW_BEZIER,
RTW_BSPLINE,
RTW_HERMITE,
RTW_CATMULL_ROM,
RTW_UNKNOWN_CURVE_BASIS = 255
} RTWCurveBasis;
// AMR Volume rendering methods
typedef enum
# if __cplusplus >= 201103L
......
......@@ -298,6 +298,7 @@ OSPGeometricModel RenderAsCylinders(osp::vec3f* vertices, std::vector<unsigned i
return OSPGeometry();
OSPGeometry ospMesh = ospNewGeometry("curve");
OSPGeometricModel ospGeoModel = ospNewGeometricModel(ospMesh);
ospRelease(ospMesh);
int width = 3;
int scaleOffset = -1;
if (scaleArray != nullptr)
......@@ -309,9 +310,9 @@ OSPGeometricModel RenderAsCylinders(osp::vec3f* vertices, std::vector<unsigned i
std::vector<unsigned int> idata(indexArray.size());
for (size_t i = 0; i < indexArray.size(); i++)
{
mdata[i * width + 0] = static_cast<float>(vertices[indexArray[i * 2 + 0]].x);
mdata[i * width + 1] = static_cast<float>(vertices[indexArray[i * 2 + 0]].y);
mdata[i * width + 2] = static_cast<float>(vertices[indexArray[i * 2 + 0]].z);
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);
idata[i] = i;
int mat = 0;
if (numCellMaterials)
......@@ -320,13 +321,12 @@ OSPGeometricModel RenderAsCylinders(osp::vec3f* vertices, std::vector<unsigned i
}
else if (numPointColors)
{
mat = indexArray[i * 2];
// mat = indexArray[i * 2];
}
if (scaleArray != nullptr)
{
double avg = (*scaleArray->GetTuple(indexArray[i * 2 + 0]) +
*scaleArray->GetTuple(indexArray[i * 2 + 1])) *
0.5;
double avg =
(*scaleArray->GetTuple(indexArray[i]) + *scaleArray->GetTuple(indexArray[i])) * 0.5;
mdata[i * width + 3] = MapThroughPWF(avg, scaleFunction);
}
}
......@@ -338,18 +338,20 @@ OSPGeometricModel RenderAsCylinders(osp::vec3f* vertices, std::vector<unsigned i
if (width == 3)
{
OSPData _mdata = ospNewCopyData1D(indexArray.size(), OSP_VEC3F, mdata.data());
ospCommit(_mdata);
ospSetObject(ospMesh, "vertex.position", _mdata);
}
else
{
OSPData _mdata = ospNewCopyData1D(indexArray.size(), OSP_VEC4F, mdata.data());
ospCommit(_mdata);
ospSetObject(ospMesh, "vertex.position_radius", _mdata);
}
ospSetInt(ospMesh, "radius", lineWidth);
OSPData _idata = ospNewCopyData1D(indexArray.size(), OSP_UINT, idata.data());
ospSetObject(ospMesh, "index", _idata);
// ospSetInt(ospMesh, "type", OSP_ROUND);
// ospSetInt(ospMesh, "basis", OSP_LINEAR);
ospSetInt(ospMesh, "type", OSP_ROUND);
ospSetInt(ospMesh, "basis", OSP_LINEAR);
// send the texture map and texture coordinates over
bool _hastm = false;
......@@ -372,6 +374,7 @@ OSPGeometricModel RenderAsCylinders(osp::vec3f* vertices, std::vector<unsigned i
tc[i + 1] = osp::vec2f{ t2, 0 };
}
OSPData tcs = ospNewCopyData1D(indexArray.size(), OSP_VEC2F, tc.data());
ospCommit(tcs);
ospSetObject(ospMesh, "vertex.texcoord", tcs);
}
else if (numTextureCoordinates)
......@@ -392,40 +395,38 @@ OSPGeometricModel RenderAsCylinders(osp::vec3f* vertices, std::vector<unsigned i
tc[i + 1] = osp::vec2f{ t1, t2 };
}
OSPData tcs = ospNewCopyData1D(indexArray.size(), OSP_VEC2F, tc.data());
ospCommit(tcs);
ospSetObject(ospMesh, "vertex.texcoord", tcs);
}
}
// if (useCustomMaterial)
// {
// }
// else if (vColorTextureMap && _hastm)
// {
// OSPTexture t2d = vtkOSPRayMaterialHelpers::VTKToOSPTexture(backend, vColorTextureMap);
// ospSetObject(actorMaterial, "map_kd", ((OSPTexture)(t2d)));
// ospRelease(t2d);
// ospCommit(actorMaterial);
// }
// else if (numCellMaterials)
// {
// // per cell color
// // ospSetInt(ospMesh, "offset_materialID", 6 * sizeof(float));
// // ospSetObject(ospMesh, "materialList", CellMaterials);
// }
// else if (numPointColors)
// {
// // per point color
// // ospSetInt(ospMesh, "offset_colorID", 6 * sizeof(float));
// ospSetObject(ospMesh, "color", _PointColors);
// }
// else
// {
// // per actor color
// }
if (useCustomMaterial)
{
}
else if (vColorTextureMap && _hastm)
{
OSPTexture t2d = vtkOSPRayMaterialHelpers::VTKToOSPTexture(backend, vColorTextureMap);
ospSetObject(actorMaterial, "map_kd", ((OSPTexture)(t2d)));
ospRelease(t2d);
ospCommit(actorMaterial);
}
else if (numCellMaterials)
{
// per cell color
}
else if (numPointColors)
{
// per point color
ospSetObject(ospMesh, "vertex.color", _PointColors);
}
else
{
// per actor color
}
ospCommit(ospMesh);
ospSetObject(ospGeoModel, "material", actorMaterial);
ospSetObjectAsData(ospGeoModel, "material", OSP_MATERIAL, actorMaterial);
ospCommit(ospGeoModel);
return ospGeoModel;
......@@ -465,6 +466,7 @@ OSPGeometricModel RenderAsTriangles(OSPData vertices, std::vector<unsigned int>&
if (numNormals)
{
_normals = ospNewCopyData1D(numNormals, OSP_VEC3F, normals.data());
ospCommit(_normals);
ospSetObject(ospMesh, "vertex.normal", _normals);
ospRelease(_normals);
}
......@@ -486,6 +488,7 @@ OSPGeometricModel RenderAsTriangles(OSPData vertices, std::vector<unsigned int>&
tc[i] = osp::vec2f{ pointValueTextureCoords[i], 0 };
}
tcs = ospNewCopyData1D(numPointValueTextureCoords, OSP_VEC2F, tc.data());
ospCommit(tcs);
ospSetObject(ospMesh, "vertex.texcoord", tcs);
ospRelease(tcs);
}
......@@ -504,6 +507,7 @@ OSPGeometricModel RenderAsTriangles(OSPData vertices, std::vector<unsigned int>&
tc[i / 2] = osp::vec2f{ t1, t2 };
}
tcs = ospNewCopyData1D(numTextureCoordinates / 2, OSP_VEC2F, tc.data());
ospCommit(tcs);
ospSetObject(ospMesh, "vertex.texcoord", tcs);
ospRelease(tcs);
}
......@@ -566,7 +570,6 @@ OSPGeometricModel RenderAsTriangles(OSPData vertices, std::vector<unsigned int>&
if (vColorTextureMap && _hastm)
{
std::cout << "has vcolortexturmap\n";
// Note: this will only have an affect on OBJMaterials
OSPTexture t2d = vtkOSPRayMaterialHelpers::VTKToOSPTexture(backend, vColorTextureMap);
if (interpolationType == VTK_PBR)
......@@ -577,14 +580,12 @@ OSPGeometricModel RenderAsTriangles(OSPData vertices, std::vector<unsigned int>&
}
else
{
std::cout << "vColorTextureMap\n";
ospSetObject(actorMaterial, "map_kd", ((OSPTexture)(t2d)));
ospSetVec4f(actorMaterial, "map_kd.transform", textureTransform.x, textureTransform.y,
textureTransform.z, textureTransform.w);
}
ospRelease(t2d);
ospCommit(actorMaterial);
std::cout << "vcolortexturmap end\n";
}
else if (numCellMaterials)
{
......@@ -600,24 +601,18 @@ OSPGeometricModel RenderAsTriangles(OSPData vertices, std::vector<unsigned int>&
}
else if (numPointColors)
{
std::cout << "numpointcolors\n";
_PointColors = ospNewCopyData1D(numPointColors, OSP_VEC4F, &PointColors[0]);
ospCommit(_PointColors);
ospSetObject(ospMesh, "vertex.color", _PointColors);
ospRelease(_PointColors);
std::cout << "numpointcolors end\n";
}
}
std::cout << "setting material\n";
ospSetObjectAsData(ospGeoModel, "material", OSP_MATERIAL, actorMaterial);
std::cout << "commit mesh\n";
ospCommit(ospMesh);
std::cout << "commit geomodel\n";
ospCommit(ospGeoModel);
std::cout << "commit geomodel done\n";
std::cout << "ospPDMN::RenderAsTriangles done\n";
return ospGeoModel;
}
......@@ -734,7 +729,6 @@ vtkOSPRayPolyDataMapperNode::vtkOSPRayPolyDataMapperNode()
this->UseGeometryCache = true;
this->GeometryCache = new vtkOSPRayCache<vtkOSPRayCacheItemGeometricModels>;
this->InstanceCache = new vtkOSPRayCache<vtkOSPRayCacheItemObject>;
std::cout << "vtkOSPDMN new (" << this << ")\n";
}
//----------------------------------------------------------------------------
......@@ -742,7 +736,6 @@ vtkOSPRayPolyDataMapperNode::~vtkOSPRayPolyDataMapperNode()
{
delete this->GeometryCache;
delete this->InstanceCache;
std::cout << "vtkOSPDMN delete (" << this << ")\n";
}
//----------------------------------------------------------------------------
......@@ -937,7 +930,6 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
}
else if (cellFlag == 1)
{
std::cout << "cellMaterial\n";
// color or material on cell
vtkScalarsToColors* s2c = mapper->GetLookupTable();
std::vector<OSPMaterial> cellColors;
......@@ -971,7 +963,6 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
{
if (vColorCoordinates && pColorTextureMap)
{
std::cout << "vcolorcoordinates\n";
// color on point interpolated values (subsequently colormapped via 1D LUT)
numPointValueTextureCoords = vColorCoordinates->GetNumberOfTuples();
pointValueTextureCoords.resize(numPointValueTextureCoords);
......@@ -1013,12 +1004,11 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
}
else
{
// this->GeometricModels.emplace_back(vtkosp::RenderAsCylinders(vertices.data(),
// conn.line_index,
// conn.line_reverse, lineWidth, scaleArray, scaleFunction, useCustomMaterial, oMaterial,
// vColorTextureMap, numTextureCoordinates, (float*)textureCoordinates.data(),
// numCellMaterials, cellMaterials, numPointColors, pointColors.data(),
// numPointValueTextureCoords, (float*)pointValueTextureCoords.data(), backend));
this->GeometricModels.emplace_back(vtkosp::RenderAsCylinders(vertices.data(), conn.line_index,
conn.line_reverse, lineWidth, scaleArray, scaleFunction, useCustomMaterial, oMaterial,
vColorTextureMap, numTextureCoordinates, (float*)textureCoordinates.data(),
numCellMaterials, cellMaterials, numPointColors, pointColors.data(),
numPointValueTextureCoords, (float*)pointValueTextureCoords.data(), backend));
}
}
......@@ -1040,12 +1030,12 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
}
case VTK_WIREFRAME:
{
// this->GeometricModels.emplace_back(vtkosp::RenderAsCylinders(vertices.data(),
// conn.triangle_index,
// conn.triangle_reverse, lineWidth, scaleArray, scaleFunction, useCustomMaterial,
// oMaterial, vColorTextureMap, numTextureCoordinates, (float*)textureCoordinates.data(),
// numCellMaterials, cellMaterials, numPointColors, pointColors.data(),
// numPointValueTextureCoords, (float*)pointValueTextureCoords.data(), backend));
this->GeometricModels.emplace_back(
vtkosp::RenderAsCylinders(vertices.data(), conn.triangle_index, conn.triangle_reverse,
lineWidth, scaleArray, scaleFunction, useCustomMaterial, oMaterial, vColorTextureMap,
numTextureCoordinates, (float*)textureCoordinates.data(), numCellMaterials,
cellMaterials, numPointColors, pointColors.data(), numPointValueTextureCoords,
(float*)pointValueTextureCoords.data(), backend));
break;
}
default:
......@@ -1062,12 +1052,12 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
vtkosp::MakeActorMaterial(orn, oRenderer, property, eColor, eColor, specularf, opacity);
ospCommit(oMaterial2);
// this->GeometricModels.emplace_back(vtkosp::RenderAsCylinders(vertices.data(),
// conn2.triangle_index, conn2.triangle_reverse, lineWidth, scaleArray, scaleFunction,
// false, oMaterial2, vColorTextureMap, 0, (float*)textureCoordinates.data(),
// numCellMaterials, cellMaterials, numPointColors, pointColors.data(), 0,
// (float*)pointValueTextureCoords.data(), backend));
// uniqueMats.insert(oMaterial2);
this->GeometricModels.emplace_back(
vtkosp::RenderAsCylinders(vertices.data(), conn2.triangle_index, conn2.triangle_reverse,
lineWidth, scaleArray, scaleFunction, false, oMaterial2, vColorTextureMap, 0,
(float*)textureCoordinates.data(), numCellMaterials, cellMaterials, numPointColors,
pointColors.data(), 0, (float*)pointValueTextureCoords.data(), backend));
uniqueMats.insert(oMaterial2);
}
std::vector<osp::vec3f> normals;
......@@ -1136,12 +1126,12 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
}
case VTK_WIREFRAME:
{
// this->GeometricModels.emplace_back(vtkosp::RenderAsCylinders(vertices.data(),
// conn.strip_index,
// conn.strip_reverse, lineWidth, scaleArray, scaleFunction, useCustomMaterial, oMaterial,
// vColorTextureMap, numTextureCoordinates, (float*)textureCoordinates.data(),
// numCellMaterials, cellMaterials, numPointColors, pointColors.data(),
// numPointValueTextureCoords, (float*)pointValueTextureCoords.data(), backend));
this->GeometricModels.emplace_back(
vtkosp::RenderAsCylinders(vertices.data(), conn.strip_index, conn.strip_reverse,
lineWidth, scaleArray, scaleFunction, useCustomMaterial, oMaterial, vColorTextureMap,
numTextureCoordinates, (float*)textureCoordinates.data(), numCellMaterials,
cellMaterials, numPointColors, pointColors.data(), numPointValueTextureCoords,
(float*)pointValueTextureCoords.data(), backend));
break;
}
default:
......@@ -1158,12 +1148,11 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
vtkosp::MakeActorMaterial(orn, oRenderer, property, eColor, eColor, specularf, opacity);
ospCommit(oMaterial2);
// this->GeometricModels.emplace_back(vtkosp::RenderAsCylinders(vertices.data(),
// conn2.strip_index,
// conn2.strip_reverse, lineWidth, scaleArray, scaleFunction, false, oMaterial2,
// vColorTextureMap, 0, (float*)textureCoordinates.data(), numCellMaterials,
// cellMaterials, numPointColors, pointColors.data(), 0,
// (float*)pointValueTextureCoords.data(), backend));
this->GeometricModels.emplace_back(
vtkosp::RenderAsCylinders(vertices.data(), conn2.strip_index, conn2.strip_reverse,
lineWidth, scaleArray, scaleFunction, false, oMaterial2, vColorTextureMap, 0,
(float*)textureCoordinates.data(), numCellMaterials, cellMaterials, numPointColors,
pointColors.data(), 0, (float*)pointValueTextureCoords.data(), backend));
uniqueMats.insert(oMaterial2);
}
......@@ -1200,7 +1189,6 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
}
}
}
std::cout << "ospPDMN::ORenderPoly freeing data\n";
if (position)
ospRelease(position);
if (cellMaterials)
......@@ -1366,6 +1354,7 @@ void vtkOSPRayPolyDataMapperNode::RenderGeometricModels()
orn->Instances.emplace_back(instance);
this->Instances.emplace_back(instance);
}
this->GeometricModels.clear();
}
//----------------------------------------------------------------------------
......
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