From 38bbbb3a8666d54f9b08f27c940245ed11f9479f Mon Sep 17 00:00:00 2001 From: Greg Abram Date: Tue, 29 Dec 2015 10:25:42 -0600 Subject: [PATCH 1/6] changes for ospray-0.9 --- CMake/FindOSPRay.cmake | 122 +++++++++----------------- VTK/vtkOSPRayCamera.cxx | 2 - VTK/vtkOSPRayLight.cxx | 1 - VTK/vtkOSPRayPolyDataMapper.cxx | 125 ++++++++++++++++----------- VTK/vtkOSPRayProperty.cxx | 7 +- VTK/vtkOSPRayRenderable.h | 5 +- VTK/vtkOSPRayRenderer.cxx | 27 +++--- VTK/vtkOSPRayTexture.cxx | 5 +- VTK/vtkOSPRayVolumeRayCastMapper.cxx | 25 +++--- 9 files changed, 158 insertions(+), 161 deletions(-) diff --git a/CMake/FindOSPRay.cmake b/CMake/FindOSPRay.cmake index 8239721..8a1350d 100644 --- a/CMake/FindOSPRay.cmake +++ b/CMake/FindOSPRay.cmake @@ -16,7 +16,6 @@ ## limitations under the License. ## ## ======================================================================================= ## - ############################################################################### # Find OSPRay # defines: @@ -24,92 +23,57 @@ # OSPRAY_INCLUDE_DIRS # OSPRAY_LIBRARIES -# guess that OSPRay is installed in a peer directory (if in dev) or in a peer to the ParaView source -FIND_PATH(OSPRAY_DIR ospray - HINTS ${PROJECT_SOURCE_DIR}/../OSPRay ${PROJECT_SOURCE_DIR}/../../../OSPRay - DOC "OSPRay base directory" - ) -IF(NOT OSPRAY_DIR) - MESSAGE("Could not find OSPRay base directory. Please set OSPRAY_DIR to the root of your local OSPRay git repository.") -ENDIF(NOT OSPRAY_DIR) +SET(OSPRAY_FOUND, FALSE) +SET(OSPRAY_SOURCE "" CACHE FILEPATH "path to OSPRay source") +SET(OSPRAY_BUILD "" CACHE FILEPATH "path to OSPRay build") -FIND_PATH(OSPRAY_CMAKE_DIR ospray.cmake - HINTS ${PROJECT_SOURCE_DIR}/../OSPRay/cmake ${PROJECT_SOURCE_DIR}/../../../OSPRay/cmake ${OSPRAY_DIR}/cmake - DOC "OSPRay cmake directory" - ) -IF(NOT OSPRAY_CMAKE_DIR) - MESSAGE("Could not find OSPRay cmake directory. Please set OSPRAY_CMAKE_DIR to the cmake directory of your local OSPRay git repository, usually /cmake.") -ENDIF(NOT OSPRAY_CMAKE_DIR) +IF(NOT OSPRAY_SOURCE OR NOT OSPRAY_BUILD) + MESSAGE(SEND_ERROR "OSPRAY_SOURCE and OSPRAY_BUILD are required") + RETURN() +ENDIF(NOT OSPRAY_SOURCE OR NOT OSPRAY_BUILD) -IF(WIN32) - SET(LIB_DIR /Release) -ELSE() - SET(LIB_DIR "") -ENDIF() +FIND_PATH(OSPRAY_SOURCE_DIR ospray HINTS ${OSPRAY_SOURCE} DOC "OSPRay base directory") +FILE(GLOB EMBREE_DIR ${OSPRAY_SOURCE_DIR}/ospray/embree*) -# SET(OSPRAY_LIB_DIRS ${OSPRAY_DIR}/build${LIB_DIR} ${PROJECT_SOURCE_DIR}/../OSPRay/build${LIB_DIR} ${PROJECT_SOURCE_DIR}/../OSPRay${LIB_DIR} ${PROJECT_SOURCE_DIR}/../../../OSPRay/build${LIB_DIR} ${PROJECT_SOURCE_DIR}/../../../OSPRay${LIB_DIR}) -SET(OSPRAY_BUILD_DIR ${OSPRAY_BUILD_DIR} CACHE PATH "OSPRay build directory") -IF(NOT OSPRAY_BUILD_DIR) - MESSAGE("Could not find OSPRay build directory. Please set OSPRAY_BUILD_DIR to the directory where OSPRay was built.") -ENDIF(NOT OSPRAY_BUILD_DIR) -SET(OSPRAY_LIB_DIRS ${OSPRAY_BUILD_DIR}) +IF(NOT OSPRAY_SOURCE_DIR OR NOT EMBREE_DIR) + MESSAGE(SEND_ERROR "Invalid OSPRAY_SOURCE") + RETURN() +ENDIF(NOT OSPRAY_SOURCE_DIR OR NOT EMBREE_DIR) -SET(LIB_OSPRAY_EMBREE LIB_OSPRAY_EMBREE-NOTFOUND) -SET(LIB_OSPRAY LIB_OSPRAY-NOTFOUND) -SET(LIB_OSPRAY_MODULE_OPENGL_UTIL LIB_OSPRAY_MODULE_OPENGL_UTIL-NOTFOUND) -FIND_LIBRARY(LIB_OSPRAY_EMBREE ospray_embree ${OSPRAY_LIB_DIRS}) -FIND_LIBRARY(LIB_OSPRAY ospray ${OSPRAY_LIB_DIRS}) -FIND_LIBRARY(LIB_OSPRAY_MODULE_OPENGL_UTIL ospray_module_opengl_util ${OSPRAY_LIB_DIRS}) -IF (OSPRAY_MIC) - # Xeon Phi specific build ops here -ENDIF(OSPRAY_MIC) +FIND_LIBRARY(LIB_OSPRAY_EMBREE ospray_embree ${OSPRAY_BUILD}) +FIND_LIBRARY(LIB_OSPRAY ospray ${OSPRAY_BUILD}) +FIND_LIBRARY(LIB_OSPRAY_MODULE_OPENGL_UTIL ospray_module_opengl_util ${OSPRAY_BUILD}) -SET(OSPRAY_LIBRARIES - ${LIB_OSPRAY_EMBREE} - ${LIB_OSPRAY} - ${LIB_OSPRAY_MODULE_OPENGL_UTIL} - ) +IF(NOT LIB_OSPRAY OR NOT LIB_OSPRAY_EMBREE OR NOT LIB_OSPRAY_MODULE_OPENGL_UTIL) + MESSAGE(SEND_ERROR "Invalid OSPRAY_BUILD") + RETURN() +ENDIF(NOT LIB_OSPRAY OR NOT LIB_OSPRAY_EMBREE OR NOT LIB_OSPRAY_MODULE_OPENGL_UTIL) -GET_FILENAME_COMPONENT(OSPRAY_LIB_DIR ${LIB_OSPRAY} PATH) -IF(NOT OSPRAY_BUILD_DIR) - IF(WIN32) - SET(OSPRAY_BUILD_DIR ${OSPRAY_LIB_DIR}/..) - ELSE() - SET(OSPRAY_BUILD_DIR ${OSPRAY_LIB_DIR}) - ENDIF() -ENDIF() +SET(OSPRAY_LIBRARIES ${LIB_OSPRAY} ${LIB_OSPRAY_EMBREE} ${LIB_OSPRAY_MODULE_OPENGL_UTIL}) -if (OSPRAY_BUILD_DIR) - LOAD_CACHE(${OSPRAY_BUILD_DIR} READ_WITH_PREFIX OSP_ - OSPRAY_BUILD_MIC_SUPPORT - OSPRAY_BUILD_MPI_DEVICE - OSPRAY_COMPILER - OSPRAY_XEON_TARGET - ) +SET(OSPRAY_INCLUDE_DIRS + ${OSPRAY_SOURCE_DIR} + ${EMBREE_DIR} + ${OSPRAY_SOURCE_DIR}/ospray + ${EMBREE_DIR}/common + ${OSPRAY_SOURCE_DIR}/ospray/include + ${OSPRAY_BUILD} + ) + +IF(WIN32) + SET(LIB_DIR /Release) +ELSE() + SET(LIB_DIR "") +ENDIF(WIN32) - SET(OSPRAY_INCLUDE_DIRS - ${OSPRAY_DIR} - ${OSPRAY_DIR}/ospray - ${OSPRAY_DIR}/ospray/embree/common - ${OSPRAY_DIR}/ospray/embree - ${OSPRAY_DIR}/ospray/include - ${OSPRAY_BUILD_DIR} - ) +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OSPRAY_CMAKE_DIR} ${OSPRAY_DIR}) +SET(OSPRAY_CC ${OSP_OSPRAY_COMPILER} CACHE STRING "OSPRay Compiler (ICC, GCC, CLANG)") +SET(OSPRAY_MIC ${OSP_OSPRAY_BUILD_MIC_SUPPORT} CACHE BOOL "Was OSPRay buit with Xeon Phi Support?") +SET(OSPRAY_MPI ${OSP_OSPRAY_BUILD_MPI_DEVICE} CACHE BOOL "Was OSPRay built with MPI Remote/Distributed rendering support?") +SET(OSPRAY_XEON_TARGET ${OSP_OSPRAY_XEON_TARGET} CACHE STRING "OSPRay target ISA on host (SSE,AVX,AVX2)") - SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OSPRAY_CMAKE_DIR} ${OSPRAY_DIR}) - # which compiler was used to build OSPRay - SET(OSPRAY_CC ${OSP_OSPRAY_COMPILER} CACHE STRING "OSPRay Compiler (ICC, GCC, CLANG)") - # whehter to build in MIC/xeon phi support - SET(OSPRAY_MIC ${OSP_OSPRAY_BUILD_MIC_SUPPORT} CACHE BOOL "Was OSPRay buit with Xeon Phi Support?") - # whehter to build in MIC/xeon phi support - SET(OSPRAY_MPI ${OSP_OSPRAY_BUILD_MPI_DEVICE} CACHE BOOL "Was OSPRay built with MPI Remote/Distributed rendering support?") - # the arch we're targeting for the non-MIC/non-xeon phi part of ospray - SET(OSPRAY_XEON_TARGET ${OSP_OSPRAY_XEON_TARGET} CACHE STRING "OSPRay target ISA on host (SSE,AVX,AVX2)") +MARK_AS_ADVANCED(LIB_OSPRAY LIB_OSPRAY_EMBREE LIB_OSPRAY_MODULE_OPENGL_UTIL OSPRAY_CC OSPRAY_MIC OSPRAY_MPI OSPRAY_SOURCE_DIR OSPRAY_XEON_TARGET) - ADD_DEFINITIONS(${OSPRAY_EMBREE_CXX_FLAGS}) -endif(OSPRAY_BUILD_DIR) +ADD_DEFINITIONS(${OSPRAY_EMBREE_CXX_FLAGS}) -if(OSPRAY_CMAKE_DIR) - INCLUDE(${OSPRAY_CMAKE_DIR}/ospray.cmake) - INCLUDE(${OSPRAY_CMAKE_DIR}/mpi.cmake) -endif(OSPRAY_CMAKE_DIR) +SET(OSPRAY_FOUND, TRUE) diff --git a/VTK/vtkOSPRayCamera.cxx b/VTK/vtkOSPRayCamera.cxx index 6b9f5ec..572df26 100644 --- a/VTK/vtkOSPRayCamera.cxx +++ b/VTK/vtkOSPRayCamera.cxx @@ -20,7 +20,6 @@ ======================================================================================= */ #include "ospray/ospray.h" -#include "ospray/common/OSPCommon.h" #include "vtkOSPRay.h" #include "vtkOSPRayCamera.h" @@ -115,7 +114,6 @@ void vtkOSPRayCamera::OrientOSPRayCamera(vtkRenderer *ren) return; ospSetf(ospCamera,"aspect",float(usize)/float(vsize)); ospSetf(ospCamera,"fovy",vfov); - Assert(ospCamera != NULL && "could not create camera"); ospSet3f(ospCamera,"pos",eye[0], eye[1], eye[2]); ospSet3f(ospCamera,"up",up[0], up[1], up[2]); ospSet3f(ospCamera,"dir",lookat[0]-eye[0],lookat[1]-eye[1],lookat[2]-eye[2]); diff --git a/VTK/vtkOSPRayLight.cxx b/VTK/vtkOSPRayLight.cxx index bb4a56d..18926ae 100644 --- a/VTK/vtkOSPRayLight.cxx +++ b/VTK/vtkOSPRayLight.cxx @@ -20,7 +20,6 @@ ======================================================================================= */ #include "ospray/ospray.h" -#include "ospray/common/OSPCommon.h" #include "vtkOSPRay.h" #include "vtkOSPRayLight.h" diff --git a/VTK/vtkOSPRayPolyDataMapper.cxx b/VTK/vtkOSPRayPolyDataMapper.cxx index f63fc62..068813a 100644 --- a/VTK/vtkOSPRayPolyDataMapper.cxx +++ b/VTK/vtkOSPRayPolyDataMapper.cxx @@ -28,7 +28,6 @@ */ #include "ospray/ospray.h" -#include "ospray/common/OSPCommon.h" #include "vtkOSPRay.h" #include "vtkOSPRayActor.h" @@ -124,9 +123,9 @@ class Mesh { std::vector texture_indices; std::vector normal_indices; std::vector colors; - std::vector wireframe_vertex; + std::vector wireframe_vertex; std::vector wireframe_index; - std::vector points_vertex; + std::vector points_vertex; }; } @@ -275,13 +274,13 @@ void vtkOSPRayPolyDataMapper::DrawPolygons(vtkPolyData *polys, double coord[3]; for (cells->InitTraversal(); cells->GetNextCell(npts, index); cellNum++) { ptarray->GetPoint(index[0], coord); - mesh->points_vertex.push_back - (ospray::vec3f(coord[0], coord[1], coord[2])); + osp::vec3f v; + v.x = coord[0], v.y = coord[1], v.y = coord[2]; + mesh->points_vertex.push_back((const osp::vec3f)v); for (vtkIdType i = 1; i < npts; i++) { - ptarray->GetPoint(index[i], coord); - mesh->points_vertex.push_back - (ospray::vec3f(coord[0], coord[1], coord[2])); + v.x = coord[0], v.y = coord[1], v.y = coord[2]; + mesh->points_vertex.push_back((const osp::vec3f)v); } } } // VTK_POINTS; @@ -290,14 +289,15 @@ void vtkOSPRayPolyDataMapper::DrawPolygons(vtkPolyData *polys, double coord0[3]; for (cells->InitTraversal(); cells->GetNextCell(npts, index); cellNum++) { ptarray->GetPoint(index[0], coord0); - mesh->wireframe_vertex.push_back( - ospray::vec3fa(coord0[0], coord0[1], coord0[2])); + osp::vec3fa v; + v.x = coord0[0], v.y = coord0[1], v.z = coord0[2]; + mesh->wireframe_vertex.push_back((const osp::vec3fa)v); for (vtkIdType i = 1; i < npts; i++) { mesh->wireframe_index.push_back(mesh->wireframe_vertex.size() - 1); ptarray->GetPoint(index[i], coord0); - mesh->wireframe_vertex.push_back( - ospray::vec3fa(coord0[0], coord0[1], coord0[2])); + v.x = coord0[0], v.y = coord0[1], v.z = coord0[2]; + mesh->wireframe_vertex.push_back((const osp::vec3fa)v); } } } // VTK_WIREFRAME: @@ -373,13 +373,14 @@ void vtkOSPRayPolyDataMapper::DrawPolygons(vtkPolyData *polys, this->Edges && cells->GetNextCell(npts, index); cellNum++) { double coord0[3]; ptarray->GetPoint(index[0], coord0); - mesh->wireframe_vertex.push_back( - ospray::vec3fa(coord0[0], coord0[1], coord0[2])); + osp::vec3fa v; + v.x = coord0[0], v.y = coord0[1], v.z = coord0[2]; + mesh->wireframe_vertex.push_back((const osp::vec3fa)v); for (vtkIdType i = 1; i < npts; i++) { mesh->wireframe_index.push_back(mesh->wireframe_vertex.size() - 1); ptarray->GetPoint(index[i], coord0); - mesh->wireframe_vertex.push_back( - ospray::vec3fa(coord0[0], coord0[1], coord0[2])); + v.x = coord0[0], v.y = coord0[1], v.z = coord0[2]; + mesh->wireframe_vertex.push_back((const osp::vec3fa)v); } } @@ -422,13 +423,14 @@ void vtkOSPRayPolyDataMapper::DrawTStrips(vtkPolyData *polys, double coord2[3]; for (cells->InitTraversal(); cells->GetNextCell(npts, index); cellNum++) { ptarray->GetPoint(index[0], coord0); - mesh->wireframe_vertex.push_back( - ospray::vec3fa(coord0[0], coord0[1], coord0[2])); + osp::vec3fa v; + v.x = coord0[0], v.y = coord0[1], v.z = coord0[2]; + mesh->wireframe_vertex.push_back((const osp::vec3fa)v); for (vtkIdType i = 2; i < npts; i++) { mesh->wireframe_index.push_back(mesh->wireframe_vertex.size() - 1); ptarray->GetPoint(index[0], coord0); - mesh->wireframe_vertex.push_back( - ospray::vec3fa(coord0[0], coord0[1], coord0[2])); + v.x = coord0[0], v.y = coord0[1], v.z = coord0[2]; + mesh->wireframe_vertex.push_back((const osp::vec3fa)v); } } } // VTK_WIREFRAME: @@ -649,7 +651,11 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { } else if (this->ColorCoordinates) { osp::Texture2D *texture = this->InternalColorTexture->GetOSPRayTexture(); - Assert(texture); + if (! texture) + { + std::cerr << "bad return from this->InternalColorTexture->GetOSPRayTexture()\n"; + exit(1); + } ospSetObject(ospMaterial, "map_Kd", ((OSPTexture2D)(texture))); ospCommit(ospMaterial); @@ -711,14 +717,15 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { { point = pts[p]; ptarray->GetPoint(point, coord); - mesh->points_vertex.push_back - (ospray::vec3f(coord[0], coord[1], coord[2])); + osp::vec3f v; + v.x = coord[0], v.y = coord[1], v.y = coord[2]; + mesh->points_vertex.push_back(v); } } } - std::vector slVertex; - std::vector slColors; + std::vector slVertex; + std::vector slColors; std::vector slIndex; float slRadius; @@ -729,7 +736,7 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { vtkIdType npts; vtkIdType *pts; vtkPoints *ptarray = points; - std::vector tmpColors; + std::vector tmpColors; int scalarSize = ptarray->GetNumberOfPoints(); double coord0[3]; vtkIdType cell; @@ -748,7 +755,9 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { for (int jj = 0; jj < 3; jj++) { color[jj] = float(output[ii * 4 + jj]) / 255.0; } - tmpColors.push_back(ospray::vec3fa(color[0], color[1], color[2])); + osp::vec3fa v; + v.x = color[0], v.y = color[1], v.z = color[2]; + tmpColors.push_back((const osp::vec3fa)v); } } else if (vstc) { std::cout << "I have a lookup table" << std::endl; @@ -763,23 +772,28 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { for (int i = 0; i < scalarSize; i++) { double *tcoord = this->ColorCoordinates->GetTuple(i); double *color = vstc->GetColor((tcoord[0] * scale) + minmax[0]); - tmpColors.push_back(ospray::vec3fa(color[0], color[1], color[2])); + osp::vec3fa v; + v.x = color[0], v.y = color[1], v.z = color[2]; + tmpColors.push_back((const osp::vec3fa)v); } } else { double solidColor[3]; OSPRayProperty->GetDiffuseColor(solidColor); for (int i = 0; i < scalarSize; i++) { - tmpColors.push_back( - ospray::vec3fa(solidColor[0], solidColor[1], solidColor[2])); + osp::vec3fa v; + v.x = solidColor[0], v.y = solidColor[1], v.z = solidColor[2]; + tmpColors.push_back((const osp::vec3fa)v); } } } - std::vector tmpPoints; + std::vector tmpPoints; for (int ii = 0; ii < ptarray->GetNumberOfPoints(); ii++) { ptarray->GetPoint(ii, coord0); - tmpPoints.push_back(ospray::vec3fa(coord0[0], coord0[1], coord0[2])); + osp::vec3fa p; + p.x = coord0[0], p.y = coord0[1], p.z = coord0[2]; + tmpPoints.push_back((const osp::vec3fa)p); } slRadius = this->LineWidth / 0.005; @@ -872,32 +886,31 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { // printf("building mesh with numTriangles %d\n", numTriangles); - - ospray::vec3fa *vertices = (ospray::vec3fa *)alignedMalloc( - sizeof(ospray::vec3fa) * numPositions); - ospray::vec3i *triangles = (ospray::vec3i *)alignedMalloc( - sizeof(ospray::vec3i) * numTriangles); - ospray::vec3fa *normals = (ospray::vec3fa *)alignedMalloc( - sizeof(ospray::vec3fa) * numNormals); + osp::vec3fa *vertices = (osp::vec3fa *)alignedMalloc( + sizeof(osp::vec3fa) * numPositions); + osp::vec3i *triangles = (osp::vec3i *)alignedMalloc( + sizeof(osp::vec3i) * numTriangles); + osp::vec3fa *normals = (osp::vec3fa *)alignedMalloc( + sizeof(osp::vec3fa) * numNormals); for (size_t i = 0; i < numPositions; i++) { - vertices[i] = - ospray::vec3fa(mesh->vertices[i].x(), mesh->vertices[i].y(), - mesh->vertices[i].z()); + vertices[i].x = mesh->vertices[i].x(); + vertices[i].y = mesh->vertices[i].y(); + vertices[i].z = mesh->vertices[i].z(); } for (size_t i = 0, mi = 0; i < numTriangles; i++, mi += 3) { - triangles[i] = embree::Vec3i(mesh->vertex_indices[mi + 0], - mesh->vertex_indices[mi + 1], - mesh->vertex_indices[mi + 2]); + triangles[i].x = mesh->vertex_indices[mi + 0]; + triangles[i].y = mesh->vertex_indices[mi + 1]; + triangles[i].z = mesh->vertex_indices[mi + 2]; } for (size_t i = 0; i < numNormals; i++) { - normals[i] = ospray::vec3fa(mesh->vertexNormals[i].x(), - mesh->vertexNormals[i].y(), - mesh->vertexNormals[i].z()); + normals[i].x = mesh->vertexNormals[i].x(); + normals[i].y = mesh->vertexNormals[i].y(); + normals[i].z = mesh->vertexNormals[i].z(); } - OSPGeometry ospMesh = ospNewTriangleMesh(); + OSPGeometry ospMesh = ospNewGeometry("triangles"); OSPData position = ospNewData(numPositions, OSP_FLOAT3A, &vertices[0]); ospSetData(ospMesh, "position", position); @@ -933,6 +946,8 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { ospAddGeometry(OSPRayActor->OSPRayModel, ospMesh); + delete[] vertices, triangles, normals; + } if (mesh->points_vertex.size()) { @@ -973,7 +988,11 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { ospCommit(wireMat); } OSPGeometry wireGeometry = ospNewGeometry("streamlines"); - Assert(wireGeometry); + if (! wireGeometry) + { + std::cerr << "bad streamlines geometry 0\n"; + exit(0); + } OSPData vertex = ospNewData(mesh->wireframe_vertex.size(), OSP_FLOAT3A, &mesh->wireframe_vertex[0]); OSPData index = ospNewData(mesh->wireframe_index.size(), OSP_INT, @@ -991,7 +1010,11 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { if (slVertex.size()) { double solidColor[3]; OSPGeometry slGeometry = ospNewGeometry("streamlines"); - Assert(slGeometry); + if (! slGeometry) + { + std::cerr << "bad streamlines geometry 1\n"; + exit(0); + } OSPData vertex = ospNewData(slVertex.size(), OSP_FLOAT3A, &slVertex[0]); OSPData color = ospNewData(slColors.size(), OSP_FLOAT3A, &slColors[0]); OSPData index = ospNewData(slIndex.size(), OSP_INT, &slIndex[0]); diff --git a/VTK/vtkOSPRayProperty.cxx b/VTK/vtkOSPRayProperty.cxx index efd77e4..6061251 100644 --- a/VTK/vtkOSPRayProperty.cxx +++ b/VTK/vtkOSPRayProperty.cxx @@ -20,7 +20,6 @@ ======================================================================================= */ #include "ospray/ospray.h" -#include "ospray/common/OSPCommon.h" #include "vtkOSPRay.h" #include "vtkOSPRayManager.h" @@ -123,7 +122,11 @@ void vtkOSPRayProperty::CreateOSPRayProperty() this->OSPRayMaterial = ospNewMaterial(renderer,"OBJMaterial"); OSPMaterial oMaterial = (OSPMaterial)this->OSPRayMaterial; - Assert(oMaterial); + if (! oMaterial) + { + std::cerr << "Unable to create material\n"; + exit(1); + } float diffusef[] = {(float)diffuse[0], (float)diffuse[1], (float)diffuse[2]}; float specularf[] = {(float)specular[0],(float)specular[1],(float)specular[2]}; ospSet3fv(oMaterial,"Kd",diffusef); diff --git a/VTK/vtkOSPRayRenderable.h b/VTK/vtkOSPRayRenderable.h index b725612..8fed39d 100644 --- a/VTK/vtkOSPRayRenderable.h +++ b/VTK/vtkOSPRayRenderable.h @@ -31,10 +31,11 @@ class vtkOSPRayRenderable vtkOSPRayRenderable(OSPModel model) : model(model) { -instance = ospNewInstance(model, osp::affine3f(embree::one)); +// instance = ospNewInstance(model, osp::affine3f(embree::one)); +instance = ospNewInstance(model, osp::affine3f{1.0F}); } OSPGeometry instance; OSPModel model; }; -#endif \ No newline at end of file +#endif diff --git a/VTK/vtkOSPRayRenderer.cxx b/VTK/vtkOSPRayRenderer.cxx index 091e67c..ea33eff 100644 --- a/VTK/vtkOSPRayRenderer.cxx +++ b/VTK/vtkOSPRayRenderer.cxx @@ -25,7 +25,6 @@ #include "vtkRenderingOpenGLConfigure.h" #include "ospray/ospray.h" -#include "ospray/common/OSPCommon.h" #include "vtkOSPRay.h" #include "vtkOSPRayCamera.h" @@ -154,6 +153,10 @@ Accumulate(false) ospSetObject(vRenderer,"camera",oCamera); ospCommit(vRenderer); +#if !defined(Assert) +#define Assert if (0) +#endif + Assert(oRenderer != NULL && "could not create renderer"); Assert(vRenderer != NULL && "could not create renderer"); @@ -271,7 +274,7 @@ int vtkOSPRayRenderer::UpdateLights() } vtkLight* light = vLight; - double *color, *position, *focal, direction[3]; + double *color, *position, *focal; // OSPRay Lights only have one "color" color = light->GetDiffuseColor(); @@ -289,16 +292,20 @@ int vtkOSPRayRenderer::UpdateLights() } else { - direction[0] = position[0] - focal[0]; - direction[1] = position[1] - focal[1]; - direction[2] = position[2] - focal[2]; OSPLight ospLight = ospNewLight(renderer, "DirectionalLight"); ospSetString(ospLight, "name", "directional" ); float scale = 0.8; ospSet3f(ospLight, "color", color[0]*scale,color[1]*scale,color[2]*scale); - osp::vec3f dir(-direction[0],-direction[1],-direction[2]); - dir = normalize(dir); - ospSet3f(ospLight, "direction", dir.x,dir.y,dir.z); + + float x = position[0] - focal[0]; + float y = position[1] - focal[1]; + float z = position[2] - focal[2]; + float d = x*x + y*y + z*z; + + if (d != 0.0) + d = 1.0 / d; + + ospSet3f(ospLight, "direction", x*d, y*d, z*d); ospCommit(ospLight); lights.push_back(ospLight); } @@ -481,7 +488,7 @@ void vtkOSPRayRenderer::LayerRender() this->DepthBuffer = new float[ size ]; if (this->osp_framebuffer) ospFreeFrameBuffer(this->osp_framebuffer); - this->osp_framebuffer = ospNewFrameBuffer(osp::vec2i(renderSize[0], renderSize[1]), OSP_RGBA_I8, OSP_FB_COLOR | (ComputeDepth ? OSP_FB_DEPTH : 0) | OSP_FB_ACCUM); + this->osp_framebuffer = ospNewFrameBuffer(osp::vec2i{renderSize[0], renderSize[1]}, OSP_RGBA_I8, OSP_FB_COLOR | (ComputeDepth ? OSP_FB_DEPTH : 0) | OSP_FB_ACCUM); ospFrameBufferClear(osp_framebuffer, OSP_FB_COLOR | (ComputeDepth ? OSP_FB_DEPTH : 0) | OSP_FB_ACCUM); AccumCounter=0; } @@ -1244,4 +1251,4 @@ int vtkOSPRayRenderer::SetRGBACharPixelData(int x1, int y1, int x2, { return VTK_OK; } -} \ No newline at end of file +} diff --git a/VTK/vtkOSPRayTexture.cxx b/VTK/vtkOSPRayTexture.cxx index ba6c6f0..83adf51 100644 --- a/VTK/vtkOSPRayTexture.cxx +++ b/VTK/vtkOSPRayTexture.cxx @@ -20,7 +20,6 @@ ======================================================================================= */ #include "ospray/ospray.h" -#include "ospray/common/OSPCommon.h" #include "vtkOSPRay.h" #include "vtkOSPRayManager.h" @@ -196,6 +195,10 @@ void vtkOSPRayTexture::Load(vtkRenderer *ren, bool nearest) else { printf("error! bytesperpixel !=4\n"); +#if !defined(Assert) +#define Assert if (0) +#endif + Assert(0); type = OSP_UCHAR3; } diff --git a/VTK/vtkOSPRayVolumeRayCastMapper.cxx b/VTK/vtkOSPRayVolumeRayCastMapper.cxx index ba9f8ea..f5b4fd6 100644 --- a/VTK/vtkOSPRayVolumeRayCastMapper.cxx +++ b/VTK/vtkOSPRayVolumeRayCastMapper.cxx @@ -15,8 +15,6 @@ See Copyright.txt or http://www.kitware.com/Copyright.htm for details. #include "vtkOSPRayVolumeRayCastMapper.h" #include "ospray/ospray.h" -#include "ospray/common/OSPCommon.h" -#include "ospray/volume/BlockBrickedVolume.h" #include "vtkCamera.h" #include "vtkDataArray.h" @@ -428,7 +426,10 @@ void vtkOSPRayVolumeRayCastMapper::Render( vtkRenderer *ren, vtkVolume *vol ) } else { - ospSetRegion(OSPRayVolume, ScalarDataPointer, osp::vec3i(0,0,0), osp::vec3i(dim[0],dim[1],dim[2])); + osp::vec3i ll, uu; + ll.x = 0, ll.y = 0, ll.z = 0; + uu.x = dim[0], uu.y = dim[1], uu.z = dim[2]; + ospSetRegion(OSPRayVolume, ScalarDataPointer, ll, uu); } } OSPRayVolume = cacheEntry->Volume; @@ -485,16 +486,14 @@ void vtkOSPRayVolumeRayCastMapper::Render( vtkRenderer *ren, vtkVolume *vol ) std::cout << "clipValue: " << clipValue << std::endl; std::cout << "clipAxis: " << clipAxis << std::endl; - osp::vec3f upper(dim[0],dim[1],dim[2]); - if (clipAxis == 0) - upper.x = clipValue; - else if (clipAxis == 1) - upper.y = clipValue; - else if (clipAxis == 2) - upper.z = clipValue; - osp::box3f value(osp::vec3f(0,0,0), upper); - ospSet3fv(OSPRayVolume, "volumeClippingBoxLower", &value.lower.x); - ospSet3fv(OSPRayVolume, "volumeClippingBoxUpper", &value.upper.x); + + float uu[3], ll[3]; + uu[0] = dim[0], uu[1] = dim[1], uu[2] = dim[2]; + ll[0] = 0, ll[0] = 0, ll[0] = 0; + if (clipAxis >= 0 && clipAxis <= 2) + uu[clipAxis] = clipValue; + ospSet3fv(OSPRayVolume, "volumeClippingBoxLower", ll); + ospSet3fv(OSPRayVolume, "volumeClippingBoxUpper", uu); } ospSet2f(transferFunction, "valueRange", data->GetScalarRange()[0], data->GetScalarRange()[1]); From 88811356a5cf88f6407f2ffefdd87209fe2e81bb Mon Sep 17 00:00:00 2001 From: Greg Abram Date: Mon, 4 Jan 2016 14:14:59 -0600 Subject: [PATCH 2/6] CMake fixes: removed unneeded include dirs, added LINK_PRIVATEs --- CMake/FindOSPRay.cmake | 4 ---- ParaView/CMakeLists.txt | 2 +- VTK/CMakeLists.txt | 8 ++------ 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/CMake/FindOSPRay.cmake b/CMake/FindOSPRay.cmake index 8a1350d..c474d2b 100644 --- a/CMake/FindOSPRay.cmake +++ b/CMake/FindOSPRay.cmake @@ -53,11 +53,7 @@ SET(OSPRAY_LIBRARIES ${LIB_OSPRAY} ${LIB_OSPRAY_EMBREE} ${LIB_OSPRAY_MODULE_OPEN SET(OSPRAY_INCLUDE_DIRS ${OSPRAY_SOURCE_DIR} - ${EMBREE_DIR} - ${OSPRAY_SOURCE_DIR}/ospray - ${EMBREE_DIR}/common ${OSPRAY_SOURCE_DIR}/ospray/include - ${OSPRAY_BUILD} ) IF(WIN32) diff --git a/ParaView/CMakeLists.txt b/ParaView/CMakeLists.txt index f47599c..d0aeabf 100644 --- a/ParaView/CMakeLists.txt +++ b/ParaView/CMakeLists.txt @@ -78,7 +78,7 @@ add_paraview_plugin( vtkQtProgressiveRenderer.cxx OSPRayDisplay.cxx ) -target_link_libraries(pvOSPRay ${OSPRAY_LIBRARIES} ${QT_LIBRARIES} ${VTK_LIBRARIES} ${PARAVIEW_LIBRARIES}) +target_link_libraries(pvOSPRay LINK_PRIVATE ${OSPRAY_LIBRARIES} ${QT_LIBRARIES} ${VTK_LIBRARIES} ${PARAVIEW_LIBRARIES}) # if (BUILD_TESTING) # add_subdirectory(Testing) diff --git a/VTK/CMakeLists.txt b/VTK/CMakeLists.txt index 00f9e71..07759e4 100644 --- a/VTK/CMakeLists.txt +++ b/VTK/CMakeLists.txt @@ -36,9 +36,6 @@ if (BUILD_AGAINST_PARAVIEW) add_definitions(-DVTKOSPRAY_FOR_PARAVIEW) endif(BUILD_AGAINST_PARAVIEW) - - - # Set vtkOSPRay source files. SET ( OSPRAY_CLASSES vtkOSPRayActor.cxx @@ -85,7 +82,6 @@ set(OSPRAY_SRCS vtk_module_library(${vtk-module} ${OSPRAY_SRCS} ${MOCSrcs} ${UISrcs}) find_package(OSPRay) - # setup include paths INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) @@ -99,8 +95,8 @@ if(VTK_USE_X) vtk_module_link_libraries(${vtk-module} LINK_PRIVATE ${OSPRAY_LIBRARIES} ${QT_LIBRARIES} ${X11_LIBRARIES} ${X11_Xt_LIB}) elseif(VTK_USE_COCOA) - vtk_module_link_libraries(${vtk-module} ${OSPRAY_LIBRARIES} ${QT_LIBRARIES} "-framework OpenGL -framework Cocoa") - target_link_libraries(${vtk-module} ${OSPRAY_LIBRARIES} ${QT_LIBRARIES} ${VTK_LIBRARIES}) + vtk_module_link_libraries(${vtk-module} LINK_PRIVATE ${OSPRAY_LIBRARIES} ${QT_LIBRARIES} "-framework OpenGL -framework Cocoa") + target_link_libraries(${vtk-module} LINK_PRIVATE ${OSPRAY_LIBRARIES} ${QT_LIBRARIES} ${VTK_LIBRARIES}) endif() # OSPRay_Core uses MMTime which is in it's own special library. From ff124e91e23442ba4913bebc83049416e0cf3eec Mon Sep 17 00:00:00 2001 From: Greg Abram Date: Mon, 4 Jan 2016 14:16:27 -0600 Subject: [PATCH 3/6] removed Glyph3DRepresentation --- ParaView/OSPRayView.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ParaView/OSPRayView.xml b/ParaView/OSPRayView.xml index ffa3d98..e16fb47 100644 --- a/ParaView/OSPRayView.xml +++ b/ParaView/OSPRayView.xml @@ -28,7 +28,7 @@ - + @@ -857,11 +857,11 @@ --> + +--> + --> + Date: Mon, 4 Jan 2016 14:35:55 -0600 Subject: [PATCH 4/6] use alignedFree rather than delete[] --- VTK/vtkOSPRayPolyDataMapper.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/VTK/vtkOSPRayPolyDataMapper.cxx b/VTK/vtkOSPRayPolyDataMapper.cxx index 068813a..cc5992e 100644 --- a/VTK/vtkOSPRayPolyDataMapper.cxx +++ b/VTK/vtkOSPRayPolyDataMapper.cxx @@ -946,7 +946,9 @@ void vtkOSPRayPolyDataMapper::Draw(vtkRenderer *renderer, vtkActor *actor) { ospAddGeometry(OSPRayActor->OSPRayModel, ospMesh); - delete[] vertices, triangles, normals; + alignedFree(vertices); + alignedFree(triangles); + alignedFree(normals); } From d6d1e8ced28ef30fa510eb76ce1977b7223a2fb0 Mon Sep 17 00:00:00 2001 From: Greg Abram Date: Mon, 4 Jan 2016 15:55:37 -0600 Subject: [PATCH 5/6] back off cxx11 initialization for osp::affine3f in vtkOSPRayRenderable creator --- VTK/vtkOSPRay.h | 11 +++++++++++ VTK/vtkOSPRayRenderable.h | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/VTK/vtkOSPRay.h b/VTK/vtkOSPRay.h index f39a395..a17705a 100644 --- a/VTK/vtkOSPRay.h +++ b/VTK/vtkOSPRay.h @@ -40,4 +40,15 @@ #define USE_OSPRAY 1 #define USE_VBOS 0 +inline osp::affine3f +Affine3fIdentity() +{ + osp::affine3f x; + x.l.vx.x = 1.0; x.l.vx.y = 0.0; x.l.vx.z = 0.0; + x.l.vy.x = 0.0; x.l.vy.y = 1.0; x.l.vy.z = 0.0; + x.l.vz.x = 0.0; x.l.vz.y = 0.0; x.l.vz.z = 1.0; + x.p.x = 0.0; x.p.y = 0.0; x.p.z = 0.0; + return x; +} + #endif diff --git a/VTK/vtkOSPRayRenderable.h b/VTK/vtkOSPRayRenderable.h index 8fed39d..172110c 100644 --- a/VTK/vtkOSPRayRenderable.h +++ b/VTK/vtkOSPRayRenderable.h @@ -31,8 +31,12 @@ class vtkOSPRayRenderable vtkOSPRayRenderable(OSPModel model) : model(model) { -// instance = ospNewInstance(model, osp::affine3f(embree::one)); -instance = ospNewInstance(model, osp::affine3f{1.0F}); + osp::affine3f identity; + identity.l.vx.x = 1.0; identity.l.vx.y = 0.0; identity.l.vx.z = 0.0; + identity.l.vy.x = 0.0; identity.l.vy.y = 1.0; identity.l.vy.z = 0.0; + identity.l.vz.x = 0.0; identity.l.vz.y = 0.0; identity.l.vz.z = 1.0; + identity.p.x = 0.0; identity.p.y = 0.0; identity.p.z = 0.0; + instance = ospNewInstance(model, identity); } OSPGeometry instance; OSPModel model; From 79ea567ede093af7a8c4778e6aa1d28a3c6e7a1e Mon Sep 17 00:00:00 2001 From: Greg Abram Date: Mon, 4 Jan 2016 15:57:20 -0600 Subject: [PATCH 6/6] just use in-line code for initialization of osp::affine3f in vtkOSPRayRenderable creator --- VTK/vtkOSPRay.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/VTK/vtkOSPRay.h b/VTK/vtkOSPRay.h index a17705a..f39a395 100644 --- a/VTK/vtkOSPRay.h +++ b/VTK/vtkOSPRay.h @@ -40,15 +40,4 @@ #define USE_OSPRAY 1 #define USE_VBOS 0 -inline osp::affine3f -Affine3fIdentity() -{ - osp::affine3f x; - x.l.vx.x = 1.0; x.l.vx.y = 0.0; x.l.vx.z = 0.0; - x.l.vy.x = 0.0; x.l.vy.y = 1.0; x.l.vy.z = 0.0; - x.l.vz.x = 0.0; x.l.vz.y = 0.0; x.l.vz.z = 1.0; - x.p.x = 0.0; x.p.y = 0.0; x.p.z = 0.0; - return x; -} - #endif