Merge topic 'release-resources'

55be1fcb examples: ensure cleanup occurs before main ends.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !697
This commit is contained in:
Robert Maynard 2017-02-16 14:29:53 +00:00 committed by Kitware Robot
commit d10081272e
6 changed files with 47 additions and 30 deletions

@ -48,12 +48,12 @@
#include <vector> #include <vector>
vtkm::Id3 dims(256, 256, 256); static vtkm::Id3 dims(256, 256, 256);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,3> > verticesArray, normalsArray; static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,3> > verticesArray, normalsArray;
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray; static vtkm::cont::ArrayHandle<vtkm::Float32> scalarsArray;
Quaternion qrot; static Quaternion qrot;
int lastx, lasty; static int lastx, lasty;
int mouse_state = 1; static int mouse_state = 1;
namespace { namespace {
@ -275,6 +275,9 @@ int main(int argc, char* argv[])
glutMouseFunc(mouseCall); glutMouseFunc(mouseCall);
glutMainLoop(); glutMainLoop();
verticesArray.ReleaseResources();
normalsArray.ReleaseResources();
scalarsArray.ReleaseResources();
return 0; return 0;
} }

@ -51,8 +51,8 @@
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter; typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
// Output data set shared with opengl // Output data set shared with opengl
vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32, DeviceAdapter> *streamLineFilter; static vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32, DeviceAdapter> *streamLineFilter;
vtkm::cont::DataSet outDataSet; static vtkm::cont::DataSet outDataSet;
// Input parameters // Input parameters
const vtkm::Id nSeeds = 25; const vtkm::Id nSeeds = 25;
@ -61,7 +61,7 @@ const vtkm::Float32 tStep = 0.5f;
const vtkm::Id direction = vtkm::worklet::internal::BOTH; const vtkm::Id direction = vtkm::worklet::internal::BOTH;
// Point location of vertices from a CastAndCall but needs a static cast eventually // Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3> > vertexArray; static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3> > vertexArray;
// OpenGL display variables // OpenGL display variables
Quaternion qrot; Quaternion qrot;
@ -313,6 +313,9 @@ int main(int argc, char* argv[])
glutMouseFunc(mouseCall); glutMouseFunc(mouseCall);
glutMainLoop(); glutMainLoop();
delete streamLineFilter;
outDataSet.Clear();
vertexArray.ReleaseResources();
return 0; return 0;
} }

@ -49,11 +49,11 @@ typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
namespace { namespace {
// Takes input uniform grid and outputs unstructured grid of tets // Takes input uniform grid and outputs unstructured grid of tets
vtkm::cont::DataSet outDataSet; static vtkm::cont::DataSet outDataSet;
vtkm::Id numberOfInPoints; vtkm::Id numberOfInPoints;
// Point location of vertices from a CastAndCall but needs a static cast eventually // Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray; static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
// OpenGL display variables // OpenGL display variables
Quaternion qrot; Quaternion qrot;
@ -330,6 +330,8 @@ int main(int argc, char* argv[])
glutMouseFunc(mouseCall); glutMouseFunc(mouseCall);
glutMainLoop(); glutMainLoop();
outDataSet.Clear();
vertexArray.ReleaseResources();
return 0; return 0;
} }

@ -46,21 +46,21 @@
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter; typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
// Default size of the example // Default size of the example
vtkm::Id3 dims(4,4,4); static vtkm::Id3 dims(4,4,4);
vtkm::Id cellsToDisplay = 64; static vtkm::Id cellsToDisplay = 64;
vtkm::Id numberOfInPoints; static vtkm::Id numberOfInPoints;
// Takes input uniform grid and outputs unstructured grid of tets // Takes input uniform grid and outputs unstructured grid of tets
vtkm::worklet::TetrahedralizeFilterUniformGrid<DeviceAdapter> *tetrahedralizeFilter; static vtkm::worklet::TetrahedralizeFilterUniformGrid<DeviceAdapter> *tetrahedralizeFilter;
vtkm::cont::DataSet tetDataSet; static vtkm::cont::DataSet tetDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually // Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray; static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
// OpenGL display variables // OpenGL display variables
Quaternion qrot; static Quaternion qrot;
int lastx, lasty; static int lastx, lasty;
int mouse_state = 1; static int mouse_state = 1;
// //
// Construct an input data set with uniform grid of indicated dimensions, origin and spacing // Construct an input data set with uniform grid of indicated dimensions, origin and spacing
@ -318,6 +318,9 @@ int main(int argc, char* argv[])
glutMouseFunc(mouseCall); glutMouseFunc(mouseCall);
glutMainLoop(); glutMainLoop();
delete tetrahedralizeFilter;
tetDataSet.Clear();
vertexArray.ReleaseResources();
return 0; return 0;
} }

@ -46,12 +46,12 @@ typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
namespace { namespace {
// Takes input uniform grid and outputs unstructured grid of triangles // Takes input uniform grid and outputs unstructured grid of triangles
vtkm::worklet::TetrahedralizeFilterExplicitGrid<DeviceAdapter> *tetrahedralizeFilter; static vtkm::worklet::TetrahedralizeFilterExplicitGrid<DeviceAdapter> *tetrahedralizeFilter;
vtkm::cont::DataSet outDataSet; static vtkm::cont::DataSet outDataSet;
vtkm::Id numberOfInPoints; static vtkm::Id numberOfInPoints;
// Point location of vertices from a CastAndCall but needs a static cast eventually // Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray; static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
} // anonymous namespace } // anonymous namespace
@ -248,6 +248,9 @@ int main(int argc, char* argv[])
glutDisplayFunc(displayCall); glutDisplayFunc(displayCall);
glutMainLoop(); glutMainLoop();
delete tetrahedralizeFilter;
outDataSet.Clear();
vertexArray.ReleaseResources();
return 0; return 0;
} }

@ -44,16 +44,16 @@
typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter; typedef VTKM_DEFAULT_DEVICE_ADAPTER_TAG DeviceAdapter;
// Default size of the example // Default size of the example
vtkm::Id2 dims(4,4); static vtkm::Id2 dims(4,4);
vtkm::Id cellsToDisplay = 16; static vtkm::Id cellsToDisplay = 16;
vtkm::Id numberOfInPoints; static vtkm::Id numberOfInPoints;
// Takes input uniform grid and outputs unstructured grid of triangles // Takes input uniform grid and outputs unstructured grid of triangles
vtkm::worklet::TetrahedralizeFilterUniformGrid<DeviceAdapter> *tetrahedralizeFilter; static vtkm::worklet::TetrahedralizeFilterUniformGrid<DeviceAdapter> *tetrahedralizeFilter;
vtkm::cont::DataSet tetDataSet; static vtkm::cont::DataSet tetDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually // Point location of vertices from a CastAndCall but needs a static cast eventually
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray; static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3> > vertexArray;
// //
// Construct an input data set with uniform grid of indicated dimensions, origin and spacing // Construct an input data set with uniform grid of indicated dimensions, origin and spacing
@ -223,6 +223,9 @@ int main(int argc, char* argv[])
glutDisplayFunc(displayCall); glutDisplayFunc(displayCall);
glutMainLoop(); glutMainLoop();
delete tetrahedralizeFilter;
tetDataSet.Clear();
vertexArray.ReleaseResources();
return 0; return 0;
} }