Commit 1468fc37 authored by David DeMarle's avatar David DeMarle
Browse files

remove tests that wont work and add one that should

parent 2caa30b8
vtk_add_test_cxx(${vtk-module}CxxTests tests
# Surface rendering tests
TestOSPRayCompositePolyDataMapper2.cxx,
TestOSPRayDynamicObject.cxx,
TestOSPRayDynamicScene.cxx,
......@@ -10,24 +11,23 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestOSPRayPass.cxx,
TestOSPRayRenderMesh.cxx,
TestOSPRayScalarBar.cxx
TestSmartVolumeMapper.cxx
TestOSPRayTime.cxx,
TestOSPRayWindow.cxx
# Volume rendering tests
TestOSPRayVolumeRenderer.cxx
TestGPURayCastAdditive.cxx
TestGPURayCastCameraInside.cxx
TestGPURayCastCellData.cxx
TestGPURayCastCameraInsideSmallSpacing.cxx
TestGPURayCastMapperBenchmark.cxx
TestGPURayCastMapperSampleDistance.cxx
TestGPURayCastPerspectiveParallel.cxx
#TestGPURayCastPositionalLights.cxx
TestGPURayCastVolumeLightKit.cxx
TestGPURayCastVolumeRotation.cxx
TestGPURayCastVolumePolyData.cxx
TestGPURayCastVolumeScale.cxx
TestGPURayCastVolumeUpdate.cxx
TestGPUVolumeRayCastMapper.cxx
TestGPURayCastVolumePolyData.cxx
TestOSPRayVolumeRenderer.cxx
TestSmartVolumeMapper.cxx
)
vtk_test_cxx_executable(${vtk-module}CxxTests tests RENDERING_FACTORY
vtkOSPRayTestInteractor.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestGPURayCastAdditive.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This test covers additive method.
// This test volume renders a synthetic dataset with unsigned char values,
// with the additive method.
#include "vtkNew.h"
#include "vtkSphere.h"
#include "vtkSampleFunction.h"
#include "vtkGPUVolumeRayCastMapper.h"
#include "vtkTestUtilities.h"
#include "vtkColorTransferFunction.h"
#include "vtkPiecewiseFunction.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkVolumeProperty.h"
#include "vtkCamera.h"
#include "vtkRegressionTestImage.h"
#include "vtkImageShiftScale.h"
#include "vtkImageData.h"
#include "vtkPointData.h"
#include "vtkDataArray.h"
#include "vtkOSPRayPass.h"
#include "vtkProperty.h"
#include "vtkSmartPointer.h"
#include "vtkOSPRayTestInteractor.h"
int TestGPURayCastAdditive(int argc,
char *argv[])
{
cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl;
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
// Create a spherical implicit function.
vtkSphere *shape = vtkSphere::New();
shape->SetRadius(0.1);
shape->SetCenter(0.0,0.0,0.0);
vtkSampleFunction *source = vtkSampleFunction::New();
source->SetImplicitFunction(shape);
shape->Delete();
source->SetOutputScalarTypeToDouble();
source->SetSampleDimensions(127,127,127); // intentional NPOT dimensions.
source->SetModelBounds(-1.0,1.0,-1.0,1.0,-1.0,1.0);
source->SetCapping(false);
source->SetComputeNormals(false);
source->SetScalarArrayName("values");
source->Update();
vtkDataArray *a = source->GetOutput()->GetPointData()->GetScalars("values");
double range[2];
a->GetRange(range);
vtkImageShiftScale *t = vtkImageShiftScale::New();
t->SetInputConnection(source->GetOutputPort());
source->Delete();
t->SetShift(-range[0]);
double magnitude = range[1]-range[0];
if(magnitude == 0.0)
{
magnitude = 1.0;
}
t->SetScale(255.0/magnitude);
t->SetOutputScalarTypeToUnsignedChar();
t->Update();
vtkRenderWindow *renWin = vtkRenderWindow::New();
vtkRenderer *ren1 = vtkRenderer::New();
ren1->SetBackground(0.1,0.4,0.2);
renWin->AddRenderer(ren1);
ren1->Delete();
// intentional odd and NPOT width/height
renWin->SetSize(301,300);
vtkNew<vtkOSPRayPass> osprayPass;
if (useOSP)
{
ren1->SetPass(osprayPass.GetPointer());
}
vtkSmartPointer<vtkOSPRayTestInteractor> style =
vtkSmartPointer<vtkOSPRayTestInteractor>::New();
style->SetPipelineControlPoints((vtkOpenGLRenderer*)ren1, osprayPass.Get(), NULL);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetInteractorStyle(style);
iren->SetRenderWindow(renWin);
renWin->Delete();
// make sure we have an OpenGL context.
renWin->Render();
vtkGPUVolumeRayCastMapper *volumeMapper;
vtkVolumeProperty *volumeProperty;
vtkVolume *volume;
volumeMapper = vtkGPUVolumeRayCastMapper::New();
volumeMapper->SetAutoAdjustSampleDistances(0);
volumeMapper->SetSampleDistance(0.2);
volumeMapper->SetBlendModeToComposite(); // composite first
volumeMapper->SetInputConnection(
t->GetOutputPort());
volumeProperty = vtkVolumeProperty::New();
volumeProperty->ShadeOff();
volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);
vtkPiecewiseFunction *additiveOpacity = vtkPiecewiseFunction::New();
additiveOpacity->AddPoint(0.0,0.0);
additiveOpacity->AddPoint(200.0,0.5);
additiveOpacity->AddPoint(200.1,1.0);
additiveOpacity->AddPoint(255.0,1.0);
vtkPiecewiseFunction *compositeOpacity = vtkPiecewiseFunction::New();
compositeOpacity->AddPoint(0.0,0.0);
compositeOpacity->AddPoint(80.0,1.0);
compositeOpacity->AddPoint(80.1,0.0);
compositeOpacity->AddPoint(255.0,0.0);
volumeProperty->SetScalarOpacity(compositeOpacity); // composite first.
vtkColorTransferFunction *color = vtkColorTransferFunction::New();
color->AddRGBPoint(0.0 ,0.0,0.0,1.0);
color->AddRGBPoint(40.0 ,1.0,0.0,0.0);
color->AddRGBPoint(255.0,1.0,1.0,1.0);
volumeProperty->SetColor(color);
color->Delete();
volume = vtkVolume::New();
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
ren1->AddViewProp(volume);
int valid = volumeMapper->IsRenderSupported(renWin,volumeProperty);
int retVal;
if(valid)
{
ren1->ResetCamera();
// Render composite.
renWin->Render();
// TODO Uncommenting SetBlendModeToAdditive() makes OSPRay throw
// ospray::GhostBlockBrickedVolume<uchar> ERROR: no transfer function specified.
//
// // Switch to Additive
// volumeMapper->SetBlendModeToAdditive();
// volumeProperty->SetScalarOpacity(additiveOpacity);
// renWin->Render();
retVal = vtkTesting::Test(argc, argv, renWin, 75);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
}
else
{
retVal = vtkTesting::PASSED;
cout << "Required extensions not supported." << endl;
}
volumeMapper->Delete();
volumeProperty->Delete();
volume->Delete();
iren->Delete();
t->Delete();
additiveOpacity->Delete();
compositeOpacity->Delete();
return !((retVal == vtkTesting::PASSED) || (retVal == vtkTesting::DO_INTERACTOR));
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestGPURayCastVolumeRotation.cxx
Module: TestGPURayCastPositionalLights.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
......@@ -12,38 +12,32 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This test covers additive method.
// This test volume renders a synthetic dataset with unsigned char values,
// with the additive method.
// This test volume renders a synthetic dataset with four different
// positional lights in the scene.
#include <vtkCamera.h>
#include <vtkColorTransferFunction.h>
#include <vtkDataArray.h>
#include <vtkGPUVolumeRayCastMapper.h>
#include <vtkImageData.h>
#include <vtkImageReader.h>
#include <vtkImageShiftScale.h>
#include <vtkLight.h>
#include <vtkNew.h>
#include <vtkOutlineFilter.h>
#include "vtkOSPRayPass.h"
#include <vtkPiecewiseFunction.h>
#include <vtkPointData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRegressionTestImage.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkStructuredPointsReader.h>
#include <vtkTestUtilities.h>
#include <vtkTimerLog.h>
#include <vtkVolumeProperty.h>
#include <vtkXMLImageDataReader.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkOSPRayPass.h>
#include <vtkProperty.h>
#include <vtkLightActor.h>
#include <vtkContourFilter.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
int TestGPURayCastVolumeRotation(int argc, char *argv[])
int TestGPURayCastPositionalLights(int argc, char *argv[])
{
bool useOSP = true;
for (int i = 0; i < argc; i++)
......@@ -57,85 +51,95 @@ int TestGPURayCastVolumeRotation(int argc, char *argv[])
double scalarRange[2];
vtkNew<vtkActor> outlineActor;
vtkNew<vtkPolyDataMapper> outlineMapper;
vtkNew<vtkGPUVolumeRayCastMapper> volumeMapper;
vtkNew<vtkXMLImageDataReader> reader;
const char* volumeFile = vtkTestUtilities::ExpandDataFileName(
argc, argv, "Data/vase_1comp.vti");
reader->SetFileName(volumeFile);
volumeMapper->SetInputConnection(reader->GetOutputPort());
volumeMapper->SetSampleDistance(0.01);
// Add outline filter
vtkNew<vtkOutlineFilter> outlineFilter;
outlineFilter->SetInputConnection(reader->GetOutputPort());
outlineMapper->SetInputConnection(outlineFilter->GetOutputPort());
outlineActor->SetMapper(outlineMapper.GetPointer());
// OsprayPolyDataMapperNode requires transfer function spec.
vtkProperty* property = outlineActor->GetProperty();
property->SetColor(1.0, 1.0, 1.0);
volumeMapper->GetInput()->GetScalarRange(scalarRange);
volumeMapper->SetBlendModeToComposite();
volumeMapper->SetAutoAdjustSampleDistances(1);
volumeMapper->SetAutoAdjustSampleDistances(0);
volumeMapper->SetSampleDistance(0.1);
vtkNew<vtkRenderWindow> renWin;
renWin->SetMultiSamples(0);
vtkNew<vtkRenderer> ren;
ren->SetBackground(0.0, 0.0, 0.4);
ren->AutomaticLightCreationOff();
ren->RemoveAllLights();
vtkNew<vtkLight> light1;
light1->SetLightTypeToSceneLight();
light1->SetPositional(true);
light1->SetDiffuseColor(1,0,0);
light1->SetAmbientColor(0,0,0);
light1->SetSpecularColor(1,1,1);
light1->SetConeAngle(60);
light1->SetPosition(0.0, 0.0, 100.0);
light1->SetFocalPoint(0.0, 0.0, 0.0);
vtkNew<vtkLightActor> lightActor;
lightActor->SetLight(light1.GetPointer());
ren->AddViewProp(lightActor.GetPointer());
renWin->AddRenderer(ren.GetPointer());
ren->SetBackground(0.2, 0.2, 0.5);
renWin->SetSize(400, 400);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
// vtkNew<vtkInteractorStyleTrackballCamera> style;
// iren->SetInteractorStyle(style.GetPointer());
vtkNew<vtkPiecewiseFunction> scalarOpacity;
scalarOpacity->AddPoint(50, 0.0);
scalarOpacity->AddPoint(75, 0.1);
scalarOpacity->AddPoint(75, 1.0);
vtkNew<vtkVolumeProperty> volumeProperty;
volumeProperty->ShadeOff();
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);
volumeProperty->SetScalarOpacity(scalarOpacity.GetPointer());
vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction =
volumeProperty->GetRGBTransferFunction(0);
colorTransferFunction->RemoveAllPoints();
colorTransferFunction->AddRGBPoint(scalarRange[0], 0.0, 0.8, 0.1);
colorTransferFunction->AddRGBPoint(scalarRange[1], 0.0, 0.8, 0.1);
colorTransferFunction->AddRGBPoint(scalarRange[0], 1.0, 1.0, 1.0);
colorTransferFunction->AddRGBPoint(scalarRange[1], 1.0, 1.0, 1.0);
vtkNew<vtkVolume> volume;
volume->SetMapper(volumeMapper.GetPointer());
volume->SetProperty(volumeProperty.GetPointer());
/// Rotate the volume for testing purposes
volume->RotateY(45.0);
outlineActor->RotateY(45.0);
volume->RotateZ(-90.0);
outlineActor->RotateZ(-90.0);
volume->RotateX(90.0);
outlineActor->RotateX(90.0);
ren->AddViewProp(volume.GetPointer());
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
vtkNew<vtkPolyDataMapper> pm;
vtkNew<vtkActor> ac;
vtkNew<vtkContourFilter> cf;
ac->SetMapper(pm.GetPointer());
pm->SetInputConnection(cf->GetOutputPort());
pm->SetScalarVisibility(0);
cf->SetValue(0, 60.0);
cf->SetInputConnection(reader->GetOutputPort());
ac->SetPosition(-89.0, 0.0, 0.0);
volume->SetPosition(-30.0, 0.0, 0.0);
ren->AddActor(ac.GetPointer());
vtkNew<vtkActor> ac1;
ac1->SetMapper(pm.GetPointer());
ac1->SetPosition(0,0,0);
ren->SetTwoSidedLighting(0);
ren->AddLight(light1.GetPointer());
// Attach OSPRay render pass
vtkSmartPointer<vtkOSPRayPass> osprayPass =
vtkSmartPointer<vtkOSPRayPass>::New();
if (useOSP)
{
ren->SetPass(osprayPass.GetPointer());
}
ren->AddViewProp(volume.GetPointer());
ren->AddActor(outlineActor.GetPointer());
renWin->Render();
ren->ResetCamera();
ren->ResetCamera();
iren->Initialize();
iren->SetDesiredUpdateRate(30.0);
int retVal = vtkRegressionTestImage( renWin.GetPointer() );
if( retVal == vtkRegressionTester::DO_INTERACTOR)
......
......@@ -54,6 +54,7 @@ void vtkOSPRayVolumeMapperNode::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf(os, indent);
}
//----------------------------------------------------------------------------
void vtkOSPRayVolumeMapperNode::Render(bool prepass)
{
if (prepass)
......
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