Commit 1c8cb6e0 authored by Burlen Loring's avatar Burlen Loring
Browse files

Surface LIC: dashboard clean up and bug fix

cleanup dashboard warnings, make sure examples build, and also
renamed examples to match new module. fixed bug where invalid
extent was used when aabb points are behind near clip plane.
For in-place compositor make decomposition locally disjoint
to avoid redundant computations. Fixed unbalanced timer calls
added metrics for comparing domain decomp efficiecny and reporting
number of guard pixels used.

Change-Id: Ie8bf6d2ecbabecbf087d7b2171705a81565df573
parent ad4dddfc
......@@ -19,7 +19,7 @@ else()
add_subdirectory(Annotation/Cxx/LabeledMesh)
add_subdirectory(MultiBlock/Cxx)
add_subdirectory(DataManipulation/Cxx)
add_subdirectory(Hybrid/Cxx)
add_subdirectory(LIC/Cxx)
add_subdirectory(ImageProcessing/Cxx)
add_subdirectory(IO/Cxx)
add_subdirectory(Medical/Cxx)
......
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
PROJECT (Hybrid)
PROJECT(LIC)
if(NOT VTK_SOURCE_DIR)
message(ERROR "Cannot build Hybrid examples without VTK_SOURCE_DIR")
message(ERROR "Cannot build LIC examples without VTK_SOURCE_DIR")
endif()
if(NOT VTK_BINARY_DIR)
......@@ -11,21 +11,21 @@ if(NOT VTK_BINARY_DIR)
include(${VTK_USE_FILE})
endif()
# these demos are simply repackaged ctests
# by #include'ing the test implementation
include_directories(
# ImageDataLIC2DDemo and StructuredGridLIC2DDemo include
# TestImageDataLIC2D.h and TestStructuredGridLIC2DSlice
# from the dir below
${VTK_SOURCE_DIR}/Rendering/LIC/Testing/Cxx
)
)
set(HYBRID_EXAMPLES_SRCS
ImageDataLIC2DDemo
StructuredGridLIC2DDemo
SurfaceLICDemo
)
if(vtkTestingCore_LOADED)
foreach(name ${HYBRID_EXAMPLES_SRCS})
add_executable(${name} MACOSX_BUNDLE ${name}.cxx)
target_link_libraries(${name} ${VTK_LIBRARIES} )
target_link_libraries(${name} ${VTK_LIBRARIES})
endforeach()
endif()
......@@ -12,9 +12,7 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "TestImageDataLIC2D.h"
extern int ImageDataLIC2D(int argc, char* argv[]);
#include "TestImageDataLIC2D.cxx"
int main( int argc, char * argv[] )
{
......
......@@ -12,12 +12,9 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "TestStructuredGridLIC2DSlice.h"
#include "vtkStructuredGridLIC2DTestDriver.cxx"
extern int StructuredGridLIC2DSlice(int argc, char* argv[]);
int main( int argc, char * argv[] )
int main(int argc, char * argv[])
{
RenderingMode = STRUCTURED_GRID_LIC2D_SLICE_DEMO;
return StructuredGridLIC2DSlice( argc, argv );
return StructuredGridLIC2DDemo(argc, argv);
}
/*=========================================================================
Program: Visualization Toolkit
Module: SurfaceLICDemo.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.
=========================================================================*/
#include "vtkSurfaceLICTestDriver.cxx"
#include "TestSurfaceLIC.cxx"
int main( int argc, char * argv[] )
{
return TestSurfaceLIC( argc, argv );
}
......@@ -20,6 +20,7 @@ set_property(
vtk_test_cxx_executable(
${vtk-module}CxxTests
RENDERING_FACTORY
vtkStructuredGridLIC2DTestDriver.cxx
vtkSurfaceLICTestDriver.cxx
)
# surface lic on a curved surface
......
......@@ -12,15 +12,12 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "TestStructuredGridLIC2DSlice.h"
#include <vtksys/SystemTools.hxx>
#include "vtkStructuredGridLIC2DTestDriver.h"
#include "vtkTestUtilities.h"
#include "vtksys/SystemTools.hxx"
int TestStructuredGridLIC2DXSlice(int argc, char* argv[])
{
ZoomFactor = 3.0;
RenderingMode = STRUCTURED_GRID_LIC2D_SLICE_TEST;
char* fname =
vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/timestep_0_15.vts");
......@@ -33,7 +30,7 @@ int TestStructuredGridLIC2DXSlice(int argc, char* argv[])
noise = "--noise=" + noise;
delete [] fname;
char** new_argv = new char*[argc+10];
char** new_argv = new char*[argc+12];
for (int cc=0; cc < argc; cc++)
{
new_argv[cc] = vtksys::SystemTools::DuplicateString(argv[cc]);
......@@ -45,7 +42,9 @@ int TestStructuredGridLIC2DXSlice(int argc, char* argv[])
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--num-steps=100");
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--slice-dir=0");
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--slice=98");
int status = ::StructuredGridLIC2DSlice(argc, new_argv);
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--zoom-factor=3.0");
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--test-mode=1");
int status = vtkStructuredGridLIC2DTestDriver(argc, new_argv);
for (int kk=0; kk < argc; kk++)
{
delete [] new_argv[kk];
......
......@@ -12,15 +12,12 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "TestStructuredGridLIC2DSlice.h"
#include <vtksys/SystemTools.hxx>
#include "vtkStructuredGridLIC2DTestDriver.h"
#include "vtkTestUtilities.h"
#include "vtksys/SystemTools.hxx"
int TestStructuredGridLIC2DYSlice(int argc, char* argv[])
{
ZoomFactor = 3.0;
RenderingMode = STRUCTURED_GRID_LIC2D_SLICE_TEST;
char* fname =
vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/timestep_0_15.vts");
......@@ -33,7 +30,7 @@ int TestStructuredGridLIC2DYSlice(int argc, char* argv[])
noise = "--noise=" + noise;
delete [] fname;
char** new_argv = new char*[argc+10];
char** new_argv = new char*[argc+12];
for (int cc=0; cc < argc; cc++)
{
new_argv[cc] = vtksys::SystemTools::DuplicateString(argv[cc]);
......@@ -45,7 +42,9 @@ int TestStructuredGridLIC2DYSlice(int argc, char* argv[])
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--num-steps=100");
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--slice-dir=1");
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--slice=0");
int status = ::StructuredGridLIC2DSlice(argc, new_argv);
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--zoom-factor=3.0");
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--test-mode=1");
int status = vtkStructuredGridLIC2DTestDriver(argc, new_argv);
for (int kk=0; kk < argc; kk++)
{
delete [] new_argv[kk];
......
......@@ -12,15 +12,12 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "TestStructuredGridLIC2DSlice.h"
#include <vtksys/SystemTools.hxx>
#include "vtkStructuredGridLIC2DTestDriver.h"
#include "vtkTestUtilities.h"
#include "vtksys/SystemTools.hxx"
int TestStructuredGridLIC2DZSlice(int argc, char* argv[])
{
ZoomFactor = 3.8;
RenderingMode = STRUCTURED_GRID_LIC2D_SLICE_TEST;
char* fname =
vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/timestep_0_15.vts");
......@@ -33,7 +30,7 @@ int TestStructuredGridLIC2DZSlice(int argc, char* argv[])
noise = "--noise=" + noise;
delete [] fname;
char** new_argv = new char*[argc+10];
char** new_argv = new char*[argc+12];
for (int cc=0; cc < argc; cc++)
{
new_argv[cc] = vtksys::SystemTools::DuplicateString(argv[cc]);
......@@ -45,7 +42,9 @@ int TestStructuredGridLIC2DZSlice(int argc, char* argv[])
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--num-steps=100");
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--slice-dir=2");
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--slice=10");
int status = ::StructuredGridLIC2DSlice(argc, new_argv);
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--zoom-factor=3.8");
new_argv[argc++] = vtksys::SystemTools::DuplicateString("--test-mode=1");
int status = vtkStructuredGridLIC2DTestDriver(argc, new_argv);
for (int kk=0; kk < argc; kk++)
{
delete [] new_argv[kk];
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestStructuredGridLIC2DSlice.h
Module: TestStructuredGridLIC2DSlice.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
......@@ -13,9 +13,6 @@
=========================================================================*/
#ifndef __TestStructuredGridLIC2DSlice_h
#define __TestStructuredGridLIC2DSlice_h
#include "vtkStructuredGridLIC2D.h"
#include "vtkPNGReader.h"
#include "vtkXMLStructuredGridReader.h"
......@@ -44,19 +41,17 @@
#include <vtksys/CommandLineArguments.hxx>
#include <string>
enum { STRUCTURED_GRID_LIC2D_SLICE_DEMO = 0, STRUCTURED_GRID_LIC2D_SLICE_TEST = 1 };
static int RenderingMode = STRUCTURED_GRID_LIC2D_SLICE_TEST;
static double ZoomFactor = 2.8;
#define CREATE_NEW(var, class) vtkSmartPointer<class> var = vtkSmartPointer<class>::New();
inline int CLAMP(int a, int min, int max)
// --------------------------------------------------------------------------
static inline
int CLAMP(int a, int low, int high)
{
a = (a < min)? min : a;
a = (a > max)? max : a;
a = (a < low)? low : a;
a = (a > high)? high : a;
return a;
}
static int StructuredGridLIC2DSlice(int argc, char* argv[])
// --------------------------------------------------------------------------
int vtkStructuredGridLIC2DTestDriver(int argc, char* argv[])
{
std::string filename;
std::string noise_filename;
......@@ -67,6 +62,8 @@ static int StructuredGridLIC2DSlice(int argc, char* argv[])
int num_steps = 40;
int slice_dir = 2; // 0 == X, 1 == Y, 2 == Z
int slice = 0;
int test_mode = 0;
double zoom_factor = 2.8;
vtksys::CommandLineArguments arg;
arg.StoreUnusedArguments(1);
......@@ -93,6 +90,10 @@ static int StructuredGridLIC2DSlice(int argc, char* argv[])
arg.AddArgument("--slice-dir", argT::EQUAL_ARGUMENT, &slice_dir,
"(optional: default 2 (Z slices)) The slice direction: 0 for X slices, 1 for Y slices and 2 for Z slices. "
"This is ignored for 2D data.");
arg.AddArgument("--test-mode", argT::EQUAL_ARGUMENT, &test_mode,
"(optional: default 0) run as ctest or demo");
arg.AddArgument("--zoom-factor", argT::EQUAL_ARGUMENT, &zoom_factor,
"(optional: default 2.8) set camera zoom");
if (!arg.Parse() || filename=="")
{
......@@ -120,7 +121,9 @@ static int StructuredGridLIC2DSlice(int argc, char* argv[])
slice_dir = 2;
}
CREATE_NEW(reader, vtkXMLStructuredGridReader);
vtkSmartPointer<vtkXMLStructuredGridReader> reader
= vtkSmartPointer<vtkXMLStructuredGridReader>::New();
reader->SetFileName(filename.c_str());
reader->Update();
......@@ -177,19 +180,29 @@ static int StructuredGridLIC2DSlice(int argc, char* argv[])
}
}
CREATE_NEW(extractVOI, vtkExtractGrid);
vtkSmartPointer<vtkExtractGrid> extractVOI
= vtkSmartPointer<vtkExtractGrid>::New();
extractVOI->SetInputConnection(reader->GetOutputPort());
extractVOI->SetVOI(voi);
CREATE_NEW(renWin, vtkRenderWindow);
CREATE_NEW(renderer, vtkRenderer);
vtkSmartPointer<vtkRenderWindow> renWin
= vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderer> renderer
= vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindowInteractor> iren
= vtkSmartPointer<vtkRenderWindowInteractor>::New();
renWin->AddRenderer(renderer);
CREATE_NEW(iren, vtkRenderWindowInteractor);
iren->SetRenderWindow(renWin);
renWin->Render();
CREATE_NEW(filter, vtkStructuredGridLIC2D);
vtkSmartPointer<vtkStructuredGridLIC2D> filter
= vtkSmartPointer<vtkStructuredGridLIC2D>::New();
if ( filter->SetContext( renWin ) == 0 )
{
cout << "Required OpenGL extensions / GPU not supported." << endl;
......@@ -200,7 +213,9 @@ static int StructuredGridLIC2DSlice(int argc, char* argv[])
if (noise_filename != "")
{
CREATE_NEW(pngReader, vtkPNGReader);
vtkSmartPointer<vtkPNGReader> pngReader
= vtkSmartPointer<vtkPNGReader>::New();
pngReader->SetFileName(noise_filename.c_str());
filter->SetInputConnection(1, pngReader->GetOutputPort(0));
}
......@@ -221,46 +236,63 @@ static int StructuredGridLIC2DSlice(int argc, char* argv[])
return 0;
}
CREATE_NEW(clone, vtkImageData);
vtkSmartPointer<vtkImageData> clone
= vtkSmartPointer<vtkImageData>::New();
clone->ShallowCopy(filter->GetOutputDataObject(1));
double range[2];
clone->GetPointData()->GetScalars()->GetRange(range);
CREATE_NEW(caster, vtkImageShiftScale);
vtkSmartPointer<vtkImageShiftScale> caster
= vtkSmartPointer<vtkImageShiftScale>::New();
caster->SetInputData(clone);
caster->SetOutputScalarTypeToUnsignedChar();
caster->SetShift(-range[0]);
caster->SetScale(255.0/(range[1]-range[0]));
caster->Update();
//vtkPNGWriter* writer = vtkPNGWriter::New();
//writer->SetFileName("/tmp/lic.png");
//writer->SetInputConnection(caster->GetOutputPort());
//writer->Write();
//writer->Delete();
CREATE_NEW(texture, vtkTexture);
vtkSmartPointer<vtkTexture> texture
= vtkSmartPointer<vtkTexture>::New();
texture->SetInputConnection(caster->GetOutputPort());
CREATE_NEW(clone2, vtkStructuredGrid);
vtkSmartPointer<vtkStructuredGrid> clone2
= vtkSmartPointer<vtkStructuredGrid>::New();
clone2->ShallowCopy(filter->GetOutput(0));
CREATE_NEW(surfaceFilter, vtkDataSetSurfaceFilter);
vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter
= vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
surfaceFilter->SetInputData(clone2);
CREATE_NEW(mapper, vtkPolyDataMapper);
vtkSmartPointer<vtkPolyDataMapper> mapper
= vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(surfaceFilter->GetOutputPort());
mapper->SetScalarVisibility(0);
CREATE_NEW(actor, vtkActor);
vtkSmartPointer<vtkActor> actor
= vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->SetTexture(texture);
renderer->AddActor(actor);
}
CREATE_NEW(tester, vtkTesting);
vtkSmartPointer<vtkTesting> tester
= vtkSmartPointer<vtkTesting>::New();
for (int cc=0; cc < argc; cc++)
{
tester->AddArgument(argv[cc]);
......@@ -269,9 +301,9 @@ static int StructuredGridLIC2DSlice(int argc, char* argv[])
renderer->SetBackground(0.2,0.1,0.2);
renderer->ResetCamera();
renderer->GetActiveCamera()->Zoom( ZoomFactor );
renderer->GetActiveCamera()->Zoom( zoom_factor );
if ( RenderingMode == STRUCTURED_GRID_LIC2D_SLICE_TEST )
if ( test_mode )
{
switch (dataDesc)
{
......@@ -288,17 +320,16 @@ static int StructuredGridLIC2DSlice(int argc, char* argv[])
int reply = (!tester->IsValidImageSpecified() ||
(tester->RegressionTest(10) == vtkTesting::PASSED))? /*success*/ 0 : /*failure*/ 1;
if (tester->IsInteractiveModeSpecified())
if ( tester->IsInteractiveModeSpecified() || !test_mode )
{
iren->Start();
}
if ( RenderingMode != STRUCTURED_GRID_LIC2D_SLICE_TEST )
{
iren->Start();
}
return reply;
}
#endif
// --------------------------------------------------------------------------
int StructuredGridLIC2DDemo(int argc, char* argv[])
{
return vtkStructuredGridLIC2DTestDriver(argc, argv);
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestStructuredGridLIC2DSlice.h
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.
=========================================================================*/
#ifndef __vtkStructuredGridLIC2DTestDriver_h
#define __vtkStructuredGridLIC2DTestDriver_h
// Description:
// For demo.
int StructuredGridLIC2DDemo(int argc, char* argv[]);
// Description:
// For ctests
int vtkStructuredGridLIC2DTestDriver(int argc, char* argv[]);
#endif
......@@ -1054,6 +1054,13 @@ bool vtkLineIntegralConvolution2D::IsSupported(vtkRenderWindow *renWin)
return false;
}
vtkOpenGLExtensionManager *manager = context->GetExtensionManager();
if (manager->DriverIsNvidia() && manager->DriverVersionIs(1,6))
{
// mac osx 10.6 glsl doesn't support array initializer
return false;
}
return vtkTextureObject::IsSupported(renWin, true, false, false)
&& vtkFrameBufferObject2::IsSupported(renWin)
&& vtkShaderProgram2::IsSupported(renWin)
......
......@@ -203,7 +203,7 @@ int vtkSurfaceLICComposite::MakeDecompDisjoint(
deque<vtkPixelExtent> &in,
deque<vtkPixelExtent> &out)
{
while ( !in.empty() )
while (!in.empty())
{
// for each element
deque<vtkPixelExtent> tmpOut(1, in.back());
......
......@@ -98,44 +98,44 @@ public:
// Get the number of new extents assigned to this rank after
// the decomposition.
int GetNumberOfCompositeExtents() const
{ return static_cast<int>(this->CompositeExt.size()); }
{ return static_cast<int>(this->CompositeExt.size()); }
// Description:
// Get the extent of the domain over which to compute the LIC. This can
// be querried only after the Composite takes place.
const vtkPixelExtent &GetGuardExtent(int i=0) const
{ return this->GuardExt[i]; }
{ return this->GuardExt[i]; }
const std::deque<vtkPixelExtent> &GetGuardExtents() const
{ return this->GuardExt; }
{ return this->GuardExt; }
// Description:
// Get the extent of the domain over which to compute the LIC. This can
// be querried only after the Composite takes place.
const vtkPixelExtent &GetDisjointGuardExtent(int i=0) const
{ return this->DisjointGuardExt[i]; }
{ return this->DisjointGuardExt[i]; }
const std::deque<vtkPixelExtent> &GetDisjointGuardExtents() const
{ return this->GuardExt; }
{ return this->GuardExt; }
// Description:
// Get the extent of the domain over which to compute the LIC. This can
// be querried only after the Composite takes place.
const vtkPixelExtent &GetCompositeExtent(int i=0) const
{ return this->CompositeExt[i]; }
{ return this->CompositeExt[i]; }
const std::deque<vtkPixelExtent> &GetCompositeExtents() const
{ return this->CompositeExt; }
{ return this->CompositeExt; }
// Description:
// Get the whole dataset extent (all blocks).
const vtkPixelExtent &GetDataSetExtent() const
{ return this->DataSetExt; }
{ return this->DataSetExt; }
// Description:
// Get the whole window extent.
const vtkPixelExtent &GetWindowExtent() const
{ return this->WindowExt; }
{ return this->WindowExt; }
// Description:
// Set up for a serial run, makes the decomp disjoint and adds
......@@ -177,6 +177,15 @@ public:
virtual int Scatter(void *, int, int, vtkTextureObject *&)
{ return -1; }
// Description:
// Make a decomposition disjoint with respect to itself. Extents are
// removed from the input array and disjoint extents are appened onto
// the output array. This is a local operation.
static
int MakeDecompDisjoint(
std::deque<vtkPixelExtent> &in,
std::deque<vtkPixelExtent> &out);
protected:
vtkSurfaceLICComposite();
~vtkSurfaceLICComposite();
......@@ -193,14 +202,6 @@ protected:
std::deque<vtkPixelExtent> &out,
float *vectors);
// Description:
// Make a decomposition disjoint with respect to itself. Extents are
// removed from the input array and disjoint extents are appened onto
// the output array. This is a local operation.
int MakeDecompDisjoint(
std::deque<vtkPixelExtent> &in,
std::deque<vtkPixelExtent> &out);
// Description:
// Compute max(V) on the given extent.
float VectorMax(
......
......@@ -1329,6 +1329,18 @@ public:
ndcBBox[qq+1] = wx * PMV[idx(1,0)] + wy * PMV[idx(1,1)] + wz * PMV[idx(1,2)] + PMV[idx(1,3)];
ndcBBox[qq+2] = wx * PMV[idx(2,0)] + wy * PMV[idx(2,1)] + wz * PMV[idx(2,2)] + PMV[idx(2,3)];
double ndcw = wx * PMV[idx(3,0)] + wy * PMV[idx(3,1)] +