From e8b17eb947d7e93c00c30b6bf9f05e47dd2bdee4 Mon Sep 17 00:00:00 2001 From: Mark Kim Date: Tue, 2 Aug 2016 13:10:32 -0400 Subject: [PATCH 1/4] OSMesa, not OSMESA. --- examples/demo/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/demo/CMakeLists.txt b/examples/demo/CMakeLists.txt index a861b0953..f5773330f 100644 --- a/examples/demo/CMakeLists.txt +++ b/examples/demo/CMakeLists.txt @@ -20,7 +20,7 @@ ## ##============================================================================= vtkm_configure_component_OSMESA() -if(VTKm_OSMESA_FOUND) +if(VTKm_OSMesa_FOUND) if(VTKm_CUDA_FOUND) # Cuda compiles do not respect target_include_directories From 293ba569e739c774aecca67d2442d77cce17b7fb Mon Sep 17 00:00:00 2001 From: Mark Kim Date: Tue, 2 Aug 2016 13:22:02 -0400 Subject: [PATCH 2/4] Demo.cxx has not been updated in a while (pre-ResultDataSet change). --- examples/demo/Demo.cxx | 64 ++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/examples/demo/Demo.cxx b/examples/demo/Demo.cxx index 3adb27d7d..20a5ee851 100644 --- a/examples/demo/Demo.cxx +++ b/examples/demo/Demo.cxx @@ -65,57 +65,65 @@ int main(int argc, char* argv[]) fieldName = "SCALARS:pointvar"; } - typedef vtkm::rendering::MapperGL< > Mapper; + typedef vtkm::rendering::MapperGL Mapper; typedef vtkm::rendering::CanvasOSMesa Canvas; // Set up a camera for rendering the input data const vtkm::cont::CoordinateSystem coords = inputData.GetCoordinateSystem(); Mapper mapper; - vtkm::rendering::Camera3D &camera = mapper.GetCamera(); - vtkm::Float64 coordsBounds[6]; + vtkm::rendering::Camera camera = vtkm::rendering::Camera(); + + //Set3DView + vtkm::Bounds coordsBounds = coords.GetBounds(VTKM_DEFAULT_DEVICE_ADAPTER_TAG()); coords.GetBounds(coordsBounds,VTKM_DEFAULT_DEVICE_ADAPTER_TAG()); - vtkm::Vec totalExtent; - totalExtent[0] = vtkm::Float32(coordsBounds[1] - coordsBounds[0]); - totalExtent[1] = vtkm::Float32(coordsBounds[3] - coordsBounds[2]); - totalExtent[2] = vtkm::Float32(coordsBounds[5] - coordsBounds[4]); - vtkm::Float32 mag = vtkm::Magnitude(totalExtent); - vtkm::Normalize(totalExtent); - camera.LookAt = totalExtent * (mag * .5f); - camera.Up = vtkm::make_Vec(0.f, 1.f, 0.f); - camera.NearPlane = 1.f; - camera.FarPlane = 100.f; - camera.FieldOfView = 60.f; - camera.Height = 512; - camera.Width = 512; - camera.Position = totalExtent * (mag * 2.f); + + camera.ResetToBounds(coordsBounds); + camera.Azimuth(45.0f); + camera.Elevation(45.0f); + +// vtkm::Vec totalExtent; +// totalExtent[0] = vtkm::Float32(coordsBounds[1] - coordsBounds[0]); +// totalExtent[1] = vtkm::Float32(coordsBounds[3] - coordsBounds[2]); +// totalExtent[2] = vtkm::Float32(coordsBounds[5] - coordsBounds[4]); +// vtkm::Float32 mag = vtkm::Magnitude(totalExtent); +// vtkm::Normalize(totalExtent); +// camera.LookAt = totalExtent * (mag * .5f); +// camera.Up = vtkm::make_Vec(0.f, 1.f, 0.f); +// camera.NearPlane = 1.f; +// camera.FarPlane = 100.f; +// camera.FieldOfView = 60.f; +// camera.Height = 512; +// camera.Width = 512; +// camera.Position = totalExtent * (mag * 2.f); vtkm::rendering::ColorTable colorTable("thermal"); - mapper.SetActiveColorTable(colorTable); - mapper.SetCamera(camera); + //mapper.SetActiveColorTable(colorTable); + //mapper.SetCamera(camera); // Create a scene for rendering the input data - vtkm::rendering::Scene3D scene; + vtkm::rendering::Scene scene; vtkm::rendering::Color bg(0.2f, 0.2f, 0.2f, 1.0f); - vtkm::rendering::CanvasOSMesa surface(512,512,bg); - scene.Actors.push_back(vtkm::rendering::Actor(inputData.GetCellSet(), + vtkm::rendering::CanvasOSMesa canvas(512,512); + scene.AddActor(vtkm::rendering::Actor(inputData.GetCellSet(), inputData.GetCoordinateSystem(), inputData.GetField(fieldName), colorTable)); // Create a view and use it to render the input data using OS Mesa - vtkm::rendering::View3D view1(scene, + vtkm::rendering::View3D view(scene, mapper, - surface, + canvas, + camera, bg); - view1.Initialize(); - view1.Paint(); - view1.SaveAs("demo_input.pnm"); + view.Initialize(); + view.Paint(); + view.SaveAs("demo_input.pnm"); // Create an isosurface filter vtkm::filter::MarchingCubes filter; filter.SetGenerateNormals(false); filter.SetMergeDuplicatePoints(false); filter.SetIsoValue(isovalue); - vtkm::filter::DataSetResult result = filter.Execute( inputData, + vtkm::filter::ResultDataSet result = filter.Execute( inputData, inputData.GetField(fieldName) ); filter.MapFieldOntoOutput(result, inputData.GetField(fieldName)); vtkm::cont::DataSet& outputData = result.GetDataSet(); From df0e64572ab4e8fa6db6dfd2f74a3042285f49a8 Mon Sep 17 00:00:00 2001 From: Mark Kim Date: Tue, 2 Aug 2016 16:27:55 -0400 Subject: [PATCH 3/4] Demo.cxx compiles, at least. But, the background isn't even correct. --- examples/demo/Demo.cxx | 87 +++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/examples/demo/Demo.cxx b/examples/demo/Demo.cxx index 20a5ee851..b7fafd3be 100644 --- a/examples/demo/Demo.cxx +++ b/examples/demo/Demo.cxx @@ -34,6 +34,19 @@ #include +void makeScene(const vtkm::cont::DataSet &inputData, + const vtkm::rendering::ColorTable &colorTable, + const std::string &fieldName, + vtkm::rendering::Scene &scene) +{ + scene.AddActor(vtkm::rendering::Actor(inputData.GetCellSet(), + inputData.GetCoordinateSystem(), + inputData.GetField(fieldName), + colorTable)); + + +} + // This example reads an input vtk file specified on the command-line (or generates a default // input data set if none is provided), uses VTK-m's rendering engine to render it to an // output file using OS Mesa, instantiates an isosurface filter using VTK-m's filter @@ -75,39 +88,36 @@ int main(int argc, char* argv[]) //Set3DView vtkm::Bounds coordsBounds = coords.GetBounds(VTKM_DEFAULT_DEVICE_ADAPTER_TAG()); - coords.GetBounds(coordsBounds,VTKM_DEFAULT_DEVICE_ADAPTER_TAG()); camera.ResetToBounds(coordsBounds); - camera.Azimuth(45.0f); - camera.Elevation(45.0f); -// vtkm::Vec totalExtent; -// totalExtent[0] = vtkm::Float32(coordsBounds[1] - coordsBounds[0]); -// totalExtent[1] = vtkm::Float32(coordsBounds[3] - coordsBounds[2]); -// totalExtent[2] = vtkm::Float32(coordsBounds[5] - coordsBounds[4]); -// vtkm::Float32 mag = vtkm::Magnitude(totalExtent); -// vtkm::Normalize(totalExtent); -// camera.LookAt = totalExtent * (mag * .5f); -// camera.Up = vtkm::make_Vec(0.f, 1.f, 0.f); + vtkm::Vec totalExtent; + totalExtent[0] = vtkm::Float32(coordsBounds.X.Max - coordsBounds.X.Min); + totalExtent[1] = vtkm::Float32(coordsBounds.Y.Max - coordsBounds.Y.Min); + totalExtent[2] = vtkm::Float32(coordsBounds.Z.Max - coordsBounds.Z.Min); + vtkm::Float32 mag = vtkm::Magnitude(totalExtent); + vtkm::Normalize(totalExtent); + camera.SetLookAt(totalExtent * (mag * .5f)); + camera.SetViewUp(vtkm::make_Vec(0.f, 1.f, 0.f)); // camera.NearPlane = 1.f; // camera.FarPlane = 100.f; + camera.SetClippingRange(1.f, 100.f); // camera.FieldOfView = 60.f; + camera.SetFieldOfView(60.f); // camera.Height = 512; // camera.Width = 512; // camera.Position = totalExtent * (mag * 2.f); + camera.SetPosition(totalExtent * (mag * 2.f)); vtkm::rendering::ColorTable colorTable("thermal"); //mapper.SetActiveColorTable(colorTable); //mapper.SetCamera(camera); // Create a scene for rendering the input data vtkm::rendering::Scene scene; - vtkm::rendering::Color bg(0.2f, 0.2f, 0.2f, 1.0f); + vtkm::rendering::Color bg(1.f, 0.2f, 0.2f, 1.0f); vtkm::rendering::CanvasOSMesa canvas(512,512); - scene.AddActor(vtkm::rendering::Actor(inputData.GetCellSet(), - inputData.GetCoordinateSystem(), - inputData.GetField(fieldName), - colorTable)); + makeScene(inputData, colorTable, fieldName, scene); // Create a view and use it to render the input data using OS Mesa vtkm::rendering::View3D view(scene, mapper, @@ -118,30 +128,29 @@ int main(int argc, char* argv[]) view.Paint(); view.SaveAs("demo_input.pnm"); - // Create an isosurface filter - vtkm::filter::MarchingCubes filter; - filter.SetGenerateNormals(false); - filter.SetMergeDuplicatePoints(false); - filter.SetIsoValue(isovalue); - vtkm::filter::ResultDataSet result = filter.Execute( inputData, - inputData.GetField(fieldName) ); - filter.MapFieldOntoOutput(result, inputData.GetField(fieldName)); - vtkm::cont::DataSet& outputData = result.GetDataSet(); - // Render a separate image with the output isosurface - std::cout << "about to render the results of the MarchingCubes filter" << std::endl; - scene.Actors.clear(); - scene.Actors.push_back(vtkm::rendering::Actor(outputData.GetCellSet(), - outputData.GetCoordinateSystem(), - outputData.GetField(fieldName), - colorTable)); +// // Create an isosurface filter +// vtkm::filter::MarchingCubes filter; +// filter.SetGenerateNormals(false); +// filter.SetMergeDuplicatePoints(false); +// filter.SetIsoValue(isovalue); +// vtkm::filter::ResultDataSet result = filter.Execute( inputData, +// inputData.GetField(fieldName) ); +// filter.MapFieldOntoOutput(result, inputData.GetField(fieldName)); +// vtkm::cont::DataSet& outputData = result.GetDataSet(); +// // Render a separate image with the output isosurface +// std::cout << "about to render the results of the MarchingCubes filter" << std::endl; +// vtkm::rendering::Scene scene2; +// makeScene(outputData, colorTable, fieldName, scene2); - vtkm::rendering::View3D< Mapper, Canvas> view2(scene, - mapper, - surface, - bg); - view2.Initialize(); - view2.Paint(); - view2.SaveAs("demo_output.pnm"); + +// vtkm::rendering::View3D view2(scene2, +// mapper, +// canvas, +// camera, +// bg); +// view2.Initialize(); +// view2.Paint(); +// view2.SaveAs("demo_output.pnm"); return 0; } From 447295e79bc3a5cc25ee785ef35f873979fc593f Mon Sep 17 00:00:00 2001 From: Mark Kim Date: Tue, 2 Aug 2016 18:28:53 -0400 Subject: [PATCH 4/4] Switch from OSMesa to ray tracer for demo because OSMesa is not working atm. --- examples/demo/Demo.cxx | 62 ++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/examples/demo/Demo.cxx b/examples/demo/Demo.cxx index b7fafd3be..197a07130 100644 --- a/examples/demo/Demo.cxx +++ b/examples/demo/Demo.cxx @@ -20,8 +20,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -78,8 +78,8 @@ int main(int argc, char* argv[]) fieldName = "SCALARS:pointvar"; } - typedef vtkm::rendering::MapperGL Mapper; - typedef vtkm::rendering::CanvasOSMesa Canvas; + typedef vtkm::rendering::MapperRayTracer Mapper; + typedef vtkm::rendering::CanvasRayTracer Canvas; // Set up a camera for rendering the input data const vtkm::cont::CoordinateSystem coords = inputData.GetCoordinateSystem(); @@ -99,23 +99,15 @@ int main(int argc, char* argv[]) vtkm::Normalize(totalExtent); camera.SetLookAt(totalExtent * (mag * .5f)); camera.SetViewUp(vtkm::make_Vec(0.f, 1.f, 0.f)); -// camera.NearPlane = 1.f; -// camera.FarPlane = 100.f; camera.SetClippingRange(1.f, 100.f); -// camera.FieldOfView = 60.f; camera.SetFieldOfView(60.f); -// camera.Height = 512; -// camera.Width = 512; -// camera.Position = totalExtent * (mag * 2.f); camera.SetPosition(totalExtent * (mag * 2.f)); vtkm::rendering::ColorTable colorTable("thermal"); - //mapper.SetActiveColorTable(colorTable); - //mapper.SetCamera(camera); // Create a scene for rendering the input data vtkm::rendering::Scene scene; - vtkm::rendering::Color bg(1.f, 0.2f, 0.2f, 1.0f); - vtkm::rendering::CanvasOSMesa canvas(512,512); + vtkm::rendering::Color bg(0.2f, 0.2f, 0.2f, 1.0f); + Canvas canvas(512,512); makeScene(inputData, colorTable, fieldName, scene); // Create a view and use it to render the input data using OS Mesa @@ -128,29 +120,29 @@ int main(int argc, char* argv[]) view.Paint(); view.SaveAs("demo_input.pnm"); -// // Create an isosurface filter -// vtkm::filter::MarchingCubes filter; -// filter.SetGenerateNormals(false); -// filter.SetMergeDuplicatePoints(false); -// filter.SetIsoValue(isovalue); -// vtkm::filter::ResultDataSet result = filter.Execute( inputData, -// inputData.GetField(fieldName) ); -// filter.MapFieldOntoOutput(result, inputData.GetField(fieldName)); -// vtkm::cont::DataSet& outputData = result.GetDataSet(); -// // Render a separate image with the output isosurface -// std::cout << "about to render the results of the MarchingCubes filter" << std::endl; -// vtkm::rendering::Scene scene2; -// makeScene(outputData, colorTable, fieldName, scene2); + // Create an isosurface filter + vtkm::filter::MarchingCubes filter; + filter.SetGenerateNormals(false); + filter.SetMergeDuplicatePoints(false); + filter.SetIsoValue(isovalue); + vtkm::filter::ResultDataSet result = filter.Execute( inputData, + inputData.GetField(fieldName) ); + filter.MapFieldOntoOutput(result, inputData.GetField(fieldName)); + vtkm::cont::DataSet& outputData = result.GetDataSet(); + // Render a separate image with the output isosurface + std::cout << "about to render the results of the MarchingCubes filter" << std::endl; + vtkm::rendering::Scene scene2; + makeScene(outputData, colorTable, fieldName, scene2); -// vtkm::rendering::View3D view2(scene2, -// mapper, -// canvas, -// camera, -// bg); -// view2.Initialize(); -// view2.Paint(); -// view2.SaveAs("demo_output.pnm"); + vtkm::rendering::View3D view2(scene2, + mapper, + canvas, + camera, + bg); + view2.Initialize(); + view2.Paint(); + view2.SaveAs("demo_output.pnm"); return 0; }