From f84401243a81c97b1b9a5567828663a55815fad6 Mon Sep 17 00:00:00 2001 From: Dave Pugmire Date: Tue, 9 Feb 2016 08:59:26 -0500 Subject: [PATCH] Initial checkin for rendering infrastructure. This largely follows things from EAVL. This is going to change going forward. Most of the stuff is inside Window.h right now for convenience. --- CMake/FindMESA.cmake | 47 +++ CMakeLists.txt | 2 + vtkm/rendering/CMakeLists.txt | 7 + vtkm/rendering/Makefile | 354 ------------------ vtkm/rendering/Plot.h | 62 +++ vtkm/rendering/RenderSurface.h | 199 ++++++++++ vtkm/rendering/Scene.h | 73 ++++ vtkm/rendering/SceneRenderer.h | 52 ++- vtkm/rendering/SceneRendererOSMesa.h | 216 +++++++++++ vtkm/rendering/SceneRendererVolume.h | 4 +- vtkm/rendering/View.h | 18 +- vtkm/rendering/Window.h | 108 ++++++ vtkm/rendering/testing/CMakeLists.txt | 1 + vtkm/rendering/testing/Makefile | 273 -------------- .../testing/UnitTestSceneRendererOSMesa.cxx | 99 +++++ .../testing/UnitTestSceneRendererVolume.cxx | 7 +- 16 files changed, 880 insertions(+), 642 deletions(-) create mode 100644 CMake/FindMESA.cmake delete mode 100644 vtkm/rendering/Makefile create mode 100644 vtkm/rendering/Plot.h create mode 100644 vtkm/rendering/RenderSurface.h create mode 100644 vtkm/rendering/Scene.h create mode 100644 vtkm/rendering/SceneRendererOSMesa.h create mode 100644 vtkm/rendering/Window.h delete mode 100644 vtkm/rendering/testing/Makefile create mode 100644 vtkm/rendering/testing/UnitTestSceneRendererOSMesa.cxx diff --git a/CMake/FindMESA.cmake b/CMake/FindMESA.cmake new file mode 100644 index 000000000..6e3c3611b --- /dev/null +++ b/CMake/FindMESA.cmake @@ -0,0 +1,47 @@ +# Try to find Mesa off-screen library and include dir. +# Once done this will define +# +# OSMESA_FOUND - true if OSMesa has been found +# OSMESA_INCLUDE_DIR - where the GL/osmesa.h can be found +# OSMESA_LIBRARY - Link this to use OSMesa + + +if(NOT OSMESA_INCLUDE_DIR) + + # If we have a root defined look there first + if(OSMESA_ROOT) + find_path(OSMESA_INCLUDE_DIR GL/osmesa.h PATHS ${OSMESA_ROOT}/include + NO_DEFAULT_PATH + ) + endif() + + if(NOT OSMESA_INCLUDE_DIR) + find_path(OSMESA_INCLUDE_DIR GL/osmesa.h PATHS + /usr/openwin/share/include + /opt/graphics/OpenGL/include + ) + endif() +endif() + +# This may be left blank if OSMesa symbols are included +# in the main Mesa library +if(NOT OSMESA_LIBRARY) + # If we have a root defined look there first + if(OSMESA_ROOT) + find_library(OSMESA_LIBRARY OSMesa PATHS ${OSMESA_ROOT}/lib + NO_DEFAULT_PATH + ) + endif() + + if(NOT OSMESA_LIBRARY) + find_library(OSMESA_LIBRARY OSMesa PATHS + /opt/graphics/OpenGL/lib + /usr/openwin/lib + ) + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OSMesa DEFAULT_MSG OSMESA_LIBRARY OSMESA_INCLUDE_DIR) + +mark_as_advanced(OSMESA_INCLUDE_DIR OSMESA_LIBRARY) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81b0e4084..63fa6dc7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,8 @@ if(NOT Boost_FOUND) message(FATAL_ERROR "Please specify where to find boost headers (${VTKm_REQUIRED_BOOST_VERSION}+)" ) endif() +find_package(MESA REQUIRED) + #----------------------------------------------------------------------------- # Check for Cxx11 support. option(VTKm_FORCE_ANSI diff --git a/vtkm/rendering/CMakeLists.txt b/vtkm/rendering/CMakeLists.txt index 993fe848d..a5a8332c7 100644 --- a/vtkm/rendering/CMakeLists.txt +++ b/vtkm/rendering/CMakeLists.txt @@ -21,14 +21,21 @@ set(headers Color.h ColorTable.h + Plot.h + RenderSurface.h + Scene.h + SceneRenderer.h + SceneRendererOSMesa.h SceneRendererVolume.h Triangulator.h View.h + Window.h ) #----------------------------------------------------------------------------- vtkm_declare_headers(${headers}) add_subdirectory(raytracing) +include_directories(${OSMESA_INCLUDE_DIR}) diff --git a/vtkm/rendering/Makefile b/vtkm/rendering/Makefile deleted file mode 100644 index c81528aff..000000000 --- a/vtkm/rendering/Makefile +++ /dev/null @@ -1,354 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.1 - -# Default target executed when no arguments are given to make. -default_target: all -.PHONY : default_target - -# Allow only one "make -f Makefile2" at a time, but pass parallelism. -.NOTPARALLEL: -.PHONY : .NOTPARALLEL - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - -# A target that is always out of date. -cmake_force: -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/local/tools/cmake-3.1.2/bin/cmake - -# The command to remove a file. -RM = /usr/local/tools/cmake-3.1.2/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /g/g19/larsen30/vtk-m - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /g/g19/larsen30/vtk-m - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target install/strip -install/strip: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." - /usr/local/tools/cmake-3.1.2/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake -.PHONY : install/strip - -# Special rule for the target install/strip -install/strip/fast: install/strip -.PHONY : install/strip/fast - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." - /usr/local/tools/cmake-3.1.2/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache -.PHONY : edit_cache/fast - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/local/tools/cmake-3.1.2/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache -.PHONY : rebuild_cache/fast - -# Special rule for the target install -install: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/local/tools/cmake-3.1.2/bin/cmake -P cmake_install.cmake -.PHONY : install - -# Special rule for the target install -install/fast: preinstall/fast - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/local/tools/cmake-3.1.2/bin/cmake -P cmake_install.cmake -.PHONY : install/fast - -# Special rule for the target list_install_components -list_install_components: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" -.PHONY : list_install_components - -# Special rule for the target list_install_components -list_install_components/fast: list_install_components -.PHONY : list_install_components/fast - -# Special rule for the target package -package: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Run CPack packaging tool..." - cd /g/g19/larsen30/vtk-m && /usr/local/tools/cmake-3.1.2/bin/cpack --config ./CPackConfig.cmake -.PHONY : package - -# Special rule for the target package -package/fast: package -.PHONY : package/fast - -# Special rule for the target test -test: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..." - /usr/local/tools/cmake-3.1.2/bin/ctest --force-new-ctest-process $(ARGS) -.PHONY : test - -# Special rule for the target test -test/fast: test -.PHONY : test/fast - -# Special rule for the target package_source -package_source: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Run CPack packaging tool for source..." - cd /g/g19/larsen30/vtk-m && /usr/local/tools/cmake-3.1.2/bin/cpack --config ./CPackSourceConfig.cmake /g/g19/larsen30/vtk-m/CPackSourceConfig.cmake -.PHONY : package_source - -# Special rule for the target package_source -package_source/fast: package_source -.PHONY : package_source/fast - -# Special rule for the target install/local -install/local: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." - /usr/local/tools/cmake-3.1.2/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake -.PHONY : install/local - -# Special rule for the target install/local -install/local/fast: install/local -.PHONY : install/local/fast - -# The main all target -all: cmake_check_build_system - cd /g/g19/larsen30/vtk-m && $(CMAKE_COMMAND) -E cmake_progress_start /g/g19/larsen30/vtk-m/CMakeFiles /g/g19/larsen30/vtk-m/vtkm/rendering/CMakeFiles/progress.marks - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/all - $(CMAKE_COMMAND) -E cmake_progress_start /g/g19/larsen30/vtk-m/CMakeFiles 0 -.PHONY : all - -# The main clean target -clean: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/clean -.PHONY : clean - -# The main clean target -clean/fast: clean -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - cd /g/g19/larsen30/vtk-m && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -# Convenience name for target. -vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/rule: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/rule -.PHONY : vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/rule - -# Convenience name for target. -TestBuild_vtkm_rendering: vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/rule -.PHONY : TestBuild_vtkm_rendering - -# fast build rule for target. -TestBuild_vtkm_rendering/fast: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build -.PHONY : TestBuild_vtkm_rendering/fast - -TB_Color.o: TB_Color.cxx.o -.PHONY : TB_Color.o - -# target to build an object file -TB_Color.cxx.o: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_Color.cxx.o -.PHONY : TB_Color.cxx.o - -TB_Color.i: TB_Color.cxx.i -.PHONY : TB_Color.i - -# target to preprocess a source file -TB_Color.cxx.i: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_Color.cxx.i -.PHONY : TB_Color.cxx.i - -TB_Color.s: TB_Color.cxx.s -.PHONY : TB_Color.s - -# target to generate assembly for a file -TB_Color.cxx.s: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_Color.cxx.s -.PHONY : TB_Color.cxx.s - -TB_ColorTable.o: TB_ColorTable.cxx.o -.PHONY : TB_ColorTable.o - -# target to build an object file -TB_ColorTable.cxx.o: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_ColorTable.cxx.o -.PHONY : TB_ColorTable.cxx.o - -TB_ColorTable.i: TB_ColorTable.cxx.i -.PHONY : TB_ColorTable.i - -# target to preprocess a source file -TB_ColorTable.cxx.i: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_ColorTable.cxx.i -.PHONY : TB_ColorTable.cxx.i - -TB_ColorTable.s: TB_ColorTable.cxx.s -.PHONY : TB_ColorTable.s - -# target to generate assembly for a file -TB_ColorTable.cxx.s: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_ColorTable.cxx.s -.PHONY : TB_ColorTable.cxx.s - -TB_SceneRendererVolume.o: TB_SceneRendererVolume.cxx.o -.PHONY : TB_SceneRendererVolume.o - -# target to build an object file -TB_SceneRendererVolume.cxx.o: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_SceneRendererVolume.cxx.o -.PHONY : TB_SceneRendererVolume.cxx.o - -TB_SceneRendererVolume.i: TB_SceneRendererVolume.cxx.i -.PHONY : TB_SceneRendererVolume.i - -# target to preprocess a source file -TB_SceneRendererVolume.cxx.i: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_SceneRendererVolume.cxx.i -.PHONY : TB_SceneRendererVolume.cxx.i - -TB_SceneRendererVolume.s: TB_SceneRendererVolume.cxx.s -.PHONY : TB_SceneRendererVolume.s - -# target to generate assembly for a file -TB_SceneRendererVolume.cxx.s: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_SceneRendererVolume.cxx.s -.PHONY : TB_SceneRendererVolume.cxx.s - -TB_Triangulator.o: TB_Triangulator.cxx.o -.PHONY : TB_Triangulator.o - -# target to build an object file -TB_Triangulator.cxx.o: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_Triangulator.cxx.o -.PHONY : TB_Triangulator.cxx.o - -TB_Triangulator.i: TB_Triangulator.cxx.i -.PHONY : TB_Triangulator.i - -# target to preprocess a source file -TB_Triangulator.cxx.i: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_Triangulator.cxx.i -.PHONY : TB_Triangulator.cxx.i - -TB_Triangulator.s: TB_Triangulator.cxx.s -.PHONY : TB_Triangulator.s - -# target to generate assembly for a file -TB_Triangulator.cxx.s: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_Triangulator.cxx.s -.PHONY : TB_Triangulator.cxx.s - -TB_View.o: TB_View.cxx.o -.PHONY : TB_View.o - -# target to build an object file -TB_View.cxx.o: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_View.cxx.o -.PHONY : TB_View.cxx.o - -TB_View.i: TB_View.cxx.i -.PHONY : TB_View.i - -# target to preprocess a source file -TB_View.cxx.i: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_View.cxx.i -.PHONY : TB_View.cxx.i - -TB_View.s: TB_View.cxx.s -.PHONY : TB_View.s - -# target to generate assembly for a file -TB_View.cxx.s: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/build.make vtkm/rendering/CMakeFiles/TestBuild_vtkm_rendering.dir/TB_View.cxx.s -.PHONY : TB_View.cxx.s - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... install/strip" - @echo "... edit_cache" - @echo "... rebuild_cache" - @echo "... install" - @echo "... list_install_components" - @echo "... package" - @echo "... TestBuild_vtkm_rendering" - @echo "... test" - @echo "... package_source" - @echo "... install/local" - @echo "... TB_Color.o" - @echo "... TB_Color.i" - @echo "... TB_Color.s" - @echo "... TB_ColorTable.o" - @echo "... TB_ColorTable.i" - @echo "... TB_ColorTable.s" - @echo "... TB_SceneRendererVolume.o" - @echo "... TB_SceneRendererVolume.i" - @echo "... TB_SceneRendererVolume.s" - @echo "... TB_Triangulator.o" - @echo "... TB_Triangulator.i" - @echo "... TB_Triangulator.s" - @echo "... TB_View.o" - @echo "... TB_View.i" - @echo "... TB_View.s" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - cd /g/g19/larsen30/vtk-m && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system - diff --git a/vtkm/rendering/Plot.h b/vtkm/rendering/Plot.h new file mode 100644 index 000000000..d213fa4cb --- /dev/null +++ b/vtkm/rendering/Plot.h @@ -0,0 +1,62 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#ifndef vtk_m_rendering_Plot_h +#define vtk_m_rendering_Plot_h + +#include +#include + +namespace vtkm { +namespace rendering { + +class Plot +{ +public: + //Plot(points, cells, field, colortable) {} + VTKM_CONT_EXPORT + Plot(const vtkm::cont::DynamicCellSet &cs, + const vtkm::cont::CoordinateSystem &c, + const vtkm::cont::Field &f, + const vtkm::rendering::ColorTable &ct) : + cellSet(cs), coords(c), scalarField(f), colorTable(ct) + { + f.GetBounds(scalarBounds, + VTKM_DEFAULT_DEVICE_ADAPTER_TAG()); + } + + template + VTKM_CONT_EXPORT + void Render(SceneRendererType &sr) + { + sr.RenderCells(cellSet, coords, scalarField, + colorTable, scalarBounds); + } + + vtkm::cont::DynamicCellSet cellSet; + vtkm::cont::CoordinateSystem coords; + vtkm::cont::Field scalarField; + vtkm::rendering::ColorTable colorTable; + + vtkm::Float64 scalarBounds[2]; +}; + +}} //namespace vtkm::rendering + +#endif //vtk_m_rendering_Plot_h diff --git a/vtkm/rendering/RenderSurface.h b/vtkm/rendering/RenderSurface.h new file mode 100644 index 000000000..af17156dd --- /dev/null +++ b/vtkm/rendering/RenderSurface.h @@ -0,0 +1,199 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#ifndef vtk_m_rendering_RenderSurface_h +#define vtk_m_rendering_RenderSurface_h + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace vtkm { +namespace rendering { + +class RenderSurface +{ +public: + VTKM_CONT_EXPORT + RenderSurface():bgColor(0.0f,0.0f,0.0f,1.0f) {} + + VTKM_CONT_EXPORT + virtual void Initialize() {} + VTKM_CONT_EXPORT + virtual void Activate() {} + VTKM_CONT_EXPORT + virtual void Clear() {} + VTKM_CONT_EXPORT + virtual void Finish() {} + + VTKM_CONT_EXPORT + virtual void SaveAs(const std::string &) {} + + vtkm::Vec bgColor; +}; + +class RenderSurfaceOSMesa : public RenderSurface +{ +public: + VTKM_CONT_EXPORT + RenderSurfaceOSMesa() + { + ctx = NULL; + width = 1024; + height = 1024; + rgba.resize(width*height*4); + zbuff.resize(width*height*4); + } + + VTKM_CONT_EXPORT + virtual void Initialize() + { + ctx = OSMesaCreateContextExt(OSMESA_RGBA, 32, 0, 0, NULL); + if (!ctx) + throw vtkm::cont::ErrorControlBadValue("OSMesa context creation failed."); + rgba.resize(width*height*4); + if (!OSMesaMakeCurrent(ctx, &rgba[0], GL_FLOAT, width, height)) + throw vtkm::cont::ErrorControlBadValue("OSMesa context activation failed."); + } + + VTKM_CONT_EXPORT + virtual void Clear() + { + glClearColor(bgColor[0],bgColor[1],bgColor[2], 1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + VTKM_CONT_EXPORT + virtual void Finish() + { + glFinish(); + + //Copy zbuff into floating point array. + unsigned int *raw_zbuff; + int zbytes, w, h; + OSMesaGetDepthBuffer(ctx, &w, &h, &zbytes, (void**)&raw_zbuff); + if (w!=width || h!=height) + throw vtkm::cont::ErrorControlBadValue("Wrong width/height in ZBuffer"); + int npixels = width*height; + for (int i=0; i &mtx, + vtkm::Float32 *oglM) + { + oglM[ 0] = mtx[0][0]; + oglM[ 1] = mtx[1][0]; + oglM[ 2] = mtx[2][0]; + oglM[ 3] = mtx[3][0]; + oglM[ 4] = mtx[0][1]; + oglM[ 5] = mtx[1][1]; + oglM[ 6] = mtx[2][1]; + oglM[ 7] = mtx[3][1]; + oglM[ 8] = mtx[0][2]; + oglM[ 9] = mtx[1][2]; + oglM[10] = mtx[2][2]; + oglM[11] = mtx[3][2]; + oglM[12] = mtx[0][3]; + oglM[13] = mtx[1][3]; + oglM[14] = mtx[2][3]; + oglM[15] = mtx[3][3]; + } + + VTKM_CONT_EXPORT + virtual void SaveAs(const std::string &fileName) + { + std::ofstream of(fileName.c_str()); + of<<"P6"<=0; i--) + for (int j=0; j < width; j++) + { + const vtkm::Float32 *tuple = &(rgba[i*width*4 + j*4]); + unsigned char r = (unsigned char)(tuple[0]*255); + unsigned char g = (unsigned char)(tuple[1]*255); + unsigned char b = (unsigned char)(tuple[2]*255); + of< rgba; + std::vector zbuff; + int width, height; +}; + +}} //namespace vtkm::rendering + +#endif //vtk_m_rendering_RenderSurface_h diff --git a/vtkm/rendering/Scene.h b/vtkm/rendering/Scene.h new file mode 100644 index 000000000..caf77584a --- /dev/null +++ b/vtkm/rendering/Scene.h @@ -0,0 +1,73 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#ifndef vtk_m_rendering_Scene_h +#define vtk_m_rendering_Scene_h + +#include +#include + +namespace vtkm { +namespace rendering { + +class Scene +{ +public: + std::vector plots; + + VTKM_CONT_EXPORT + Scene() {} + +}; + +class Scene3D : public Scene +{ +public: + Scene3D() {} + + template + VTKM_CONT_EXPORT + void Render(SceneRendererType &sceneRenderer) + { + for (int i = 0; i < plots.size(); i++) + { + sceneRenderer.StartScene(); + + plots[i].Render(sceneRenderer); + sceneRenderer.EndScene(); + } + } +}; + +class Scene2D : public Scene +{ +public: + Scene2D() {} + + template + VTKM_CONT_EXPORT + void Render(vtkm::rendering::View3D &view, + SceneRendererType &sceneRenderer) + { + } +}; + +}} //namespace vtkm::rendering + +#endif //vtk_m_rendering_Scene_h diff --git a/vtkm/rendering/SceneRenderer.h b/vtkm/rendering/SceneRenderer.h index d4a5ccbcd..d9cc16d4e 100644 --- a/vtkm/rendering/SceneRenderer.h +++ b/vtkm/rendering/SceneRenderer.h @@ -33,16 +33,18 @@ public: VTKM_CONT_EXPORT SceneRenderer() { - BackgroundColor[0] = 1.f; - BackgroundColor[1] = 1.f; - BackgroundColor[2] = 1.f; - BackgroundColor[3] = 1.f; } VTKM_CONT_EXPORT virtual ~SceneRenderer() {} + VTKM_CONT_EXPORT + virtual void SetView(vtkm::rendering::View3D &v) + { + View = v; + } + VTKM_CONT_EXPORT virtual vtkm::rendering::View3D& GetView() { @@ -52,24 +54,50 @@ public: VTKM_CONT_EXPORT virtual void RenderCells(const vtkm::cont::DynamicCellSet &cellset, const vtkm::cont::CoordinateSystem &coords, - vtkm::cont::Field &scalarField) = 0; + vtkm::cont::Field &scalarField, //This should be const + const vtkm::rendering::ColorTable &colorTable, + vtkm::Float64 *scalarBounds=NULL) = 0; VTKM_CONT_EXPORT - virtual void SetActiveColorTable(const ColorTable &colorTable) + virtual void SetActiveColorTable(const ColorTable &ct) { - colorTable.Sample(1024, ColorMap); + ct.Sample(1024, ColorMap); } + // needed for volume... Can we have a volume render surface?? VTKM_CONT_EXPORT virtual void SetBackgroundColor(const vtkm::Vec &backgroundColor) { - BackgroundColor = backgroundColor; + BackgroundColor = backgroundColor; + } + VTKM_CONT_EXPORT + virtual void SetBackgroundColor(const vtkm::rendering::Color &backgroundColor) + { + BackgroundColor[0] = backgroundColor.Components[0]; + BackgroundColor[1] = backgroundColor.Components[1]; + BackgroundColor[2] = backgroundColor.Components[2]; + BackgroundColor[3] = backgroundColor.Components[3]; } + VTKM_CONT_EXPORT + virtual void Render() {} + VTKM_CONT_EXPORT + virtual void Finish() {} + VTKM_CONT_EXPORT + virtual void StartScene() + { + std::cout<<__LINE__<<": TODO"< > ColorMap; - vtkm::Vec BackgroundColor; - View3D View; + vtkm::cont::ArrayHandle > ColorMap; + vtkm::Vec BackgroundColor; + View3D View; }; }} //namespace vtkm::rendering -#endif //vtk_m_rendering_SceneRenderer_h \ No newline at end of file +#endif //vtk_m_rendering_SceneRenderer_h diff --git a/vtkm/rendering/SceneRendererOSMesa.h b/vtkm/rendering/SceneRendererOSMesa.h new file mode 100644 index 000000000..d91a8280e --- /dev/null +++ b/vtkm/rendering/SceneRendererOSMesa.h @@ -0,0 +1,216 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#ifndef vtk_m_rendering_SceneRendererOSMesa_h +#define vtk_m_rendering_SceneRendererOSMesa_h + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +namespace vtkm { +namespace rendering { + +template +class SceneRendererOSMesa : public SceneRenderer +{ +public: + VTKM_CONT_EXPORT + SceneRendererOSMesa() + { + ctx = NULL; + width = 1024; + height = 1024; + rgba.resize(width*height*4); + } + + VTKM_CONT_EXPORT + virtual void RenderCells(const vtkm::cont::DynamicCellSet &cellset, + const vtkm::cont::CoordinateSystem &coords, + vtkm::cont::Field &scalarField, + const vtkm::rendering::ColorTable &colorTable, + vtkm::Float64 *scalarBounds) + { + //Doesn't work if you take the Init() out...... + //Init(); + SetupView(); + + vtkm::cont::DynamicArrayHandleCoordinateSystem dcoords = coords.GetData(); + if (!dcoords.IsArrayHandleType(vtkm::cont::ArrayHandleUniformPointCoordinates())) + { + std::cout<<"NOT UNIFORM!"< > indices; + vtkm::Id numTri; + Triangulator triangulator; + triangulator.run(cellset, indices, numTri); + std::cout<<"NumTris= "< sf; + scalarField.GetData().CastToArrayHandle(sf); + //printSummary_ArrayHandle(sf, std::cout); + + vtkm::cont::ArrayHandleUniformPointCoordinates uVerts; + dcoords.CastToArrayHandle(uVerts); + vtkm::rendering::ColorTable ct = colorTable; + vtkm::Float32 sMin = vtkm::Float32(scalarBounds[0]); + vtkm::Float32 sMax = vtkm::Float32(scalarBounds[1]); + vtkm::Float32 sDiff = sMax-sMin; + + glBegin(GL_TRIANGLES); + for (int i = 0; i < numTri; i++) + { + vtkm::Vec idx = indices.GetPortalConstControl().Get(i); + vtkm::Id si = indices.GetPortalConstControl().Get(i)[0]; + vtkm::Id i1 = indices.GetPortalConstControl().Get(i)[1]; + vtkm::Id i2 = indices.GetPortalConstControl().Get(i)[2]; + vtkm::Id i3 = indices.GetPortalConstControl().Get(i)[3]; + + vtkm::Vec p1 = uVerts.GetPortalConstControl().Get(i1); + vtkm::Vec p2 = uVerts.GetPortalConstControl().Get(i2); + vtkm::Vec p3 = uVerts.GetPortalConstControl().Get(i3); + + vtkm::Float32 s = sf.GetPortalConstControl().Get(si); + vtkm::Float32 sn = (s-sMin)/sDiff; + //Color color = ct.MapRGB(s); + Color color = colorTable.MapRGB(s); + std::cout< vm = GetView().CreateViewMatrix(); + vtkm::Matrix pm = GetView().CreateProjectionMatrix(); + oglP[ 0] = pm[0][0]; + oglP[ 1] = pm[1][0]; + oglP[ 2] = pm[2][0]; + oglP[ 3] = pm[3][0]; + oglP[ 4] = pm[0][1]; + oglP[ 5] = pm[1][1]; + oglP[ 6] = pm[2][1]; + oglP[ 7] = pm[3][1]; + oglP[ 8] = pm[0][2]; + oglP[ 9] = pm[1][2]; + oglP[10] = pm[2][2]; + oglP[11] = pm[3][2]; + oglP[12] = pm[0][3]; + oglP[13] = pm[1][3]; + oglP[14] = pm[2][3]; + oglP[15] = pm[3][3]; + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(oglP); + + oglV[ 0] = vm[0][0]; + oglV[ 1] = vm[1][0]; + oglV[ 2] = vm[2][0]; + oglV[ 3] = vm[3][0]; + oglV[ 4] = vm[0][1]; + oglV[ 5] = vm[1][1]; + oglV[ 6] = vm[2][1]; + oglV[ 7] = vm[3][1]; + oglV[ 8] = vm[0][2]; + oglV[ 9] = vm[1][2]; + oglV[10] = vm[2][2]; + oglV[11] = vm[3][2]; + oglV[12] = vm[0][3]; + oglV[13] = vm[1][3]; + oglV[14] = vm[2][3]; + oglV[15] = vm[3][3]; + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(oglV); + } + + VTKM_CONT_EXPORT + void DumpImage() + { + std::ofstream of("output.pnm"); + of<<"P6"<=0; i--) + for (int j=0; j < width; j++) + { + const unsigned char *tuple = &(rgba[i*width*4 + j*4]); + of< rgba; + std::vector zbuff; + int width, height; +}; + +}} //namespace vtkm::rendering + +#endif //vtk_m_rendering_SceneRendererOSMesa_h diff --git a/vtkm/rendering/SceneRendererVolume.h b/vtkm/rendering/SceneRendererVolume.h index 9b7be2a73..f5269c573 100644 --- a/vtkm/rendering/SceneRendererVolume.h +++ b/vtkm/rendering/SceneRendererVolume.h @@ -49,7 +49,9 @@ public: VTKM_CONT_EXPORT virtual void RenderCells(const vtkm::cont::DynamicCellSet &cellset, const vtkm::cont::CoordinateSystem &coords, - vtkm::cont::Field &scalarField) + vtkm::cont::Field &scalarField, + const vtkm::rendering::ColorTable &, //colorTable + vtkm::Float64 *) //scalarBounds=NULL) { vtkm::cont::DynamicArrayHandleCoordinateSystem dynamicCoordsHandle = coords.GetData(); vtkm::Float64 coordsBounds[6]; // Xmin,Xmax,Ymin.. diff --git a/vtkm/rendering/View.h b/vtkm/rendering/View.h index 62f6e18c1..e7764c252 100644 --- a/vtkm/rendering/View.h +++ b/vtkm/rendering/View.h @@ -107,6 +107,16 @@ public: this->Width = other.Width; } + VTKM_CONT_EXPORT + void GetRealViewport(vtkm::Float32 &l, vtkm::Float32 &r, + vtkm::Float32 &b, vtkm::Float32 &t) + { + l = -1; + b = -1; + r = 1; + t = 1; + } + VTKM_CONT_EXPORT static void PrintMatrix(const vtkm::Matrix &mat) { @@ -117,5 +127,11 @@ public: } }; +class View2D +{ +public: + View2D() {} +}; + }} // namespace vtkm::rendering -#endif // vtk_m_rendering_View_h \ No newline at end of file +#endif // vtk_m_rendering_View_h diff --git a/vtkm/rendering/Window.h b/vtkm/rendering/Window.h new file mode 100644 index 000000000..2fb72cf1e --- /dev/null +++ b/vtkm/rendering/Window.h @@ -0,0 +1,108 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#ifndef vtk_m_rendering_Window_h +#define vtk_m_rendering_Window_h + +#include +#include +#include +#include +#include + +namespace vtkm { +namespace rendering { + +// Window2D Window3D +template +class Window3D +{ +public: + Color bgColor; + vtkm::rendering::Scene3D scene; + SceneRendererType sceneRenderer; + SurfaceType surface; + //vtkm::rendering::View3D view; + + VTKM_CONT_EXPORT + Window3D(const vtkm::rendering::Scene3D &s, + const SceneRendererType &sr, + const SurfaceType &surf, + const vtkm::rendering::Color &bg=vtkm::rendering::Color(0,0,0,1)) : + scene(s), sceneRenderer(sr), bgColor(bg), surface(surf) + { + sceneRenderer.SetBackgroundColor(bgColor); + } + + VTKM_CONT_EXPORT + void Initialize() + { + surface.Initialize(); + } + + VTKM_CONT_EXPORT + void Paint() + { + surface.Activate(); + surface.Clear(); + SetupForWorldSpace(); + + scene.Render(sceneRenderer); + + surface.Finish(); + } + + VTKM_CONT_EXPORT + void SaveAs(const std::string &fileName) + { + surface.SaveAs(fileName); + } + +private: + VTKM_CONT_EXPORT + void SetupForWorldSpace(bool viewportClip=true) + { + //view.SetupMatrices(); + surface.SetViewToWorldSpace(sceneRenderer.GetView(), + viewportClip); + } +}; + + +template +class Window2D +{ +public: + Color bgColor; + vtkm::rendering::Scene2D scene; + SceneRendererType sceneRenderer; + vtkm::rendering::View2D view; + + VTKM_CONT_EXPORT + Window2D(const vtkm::rendering::Scene2D &s, + const SceneRendererType &sr, + const vtkm::rendering::Color &bg=vtkm::rendering::Color(0,0,0,1)) : + scene(s), sceneRenderer(sr), bgColor(bg) + { + } +}; + +}} //namespace vtkm::rendering + +#endif //vtk_m_rendering_Window_h diff --git a/vtkm/rendering/testing/CMakeLists.txt b/vtkm/rendering/testing/CMakeLists.txt index f5bcb15f0..496289631 100644 --- a/vtkm/rendering/testing/CMakeLists.txt +++ b/vtkm/rendering/testing/CMakeLists.txt @@ -19,6 +19,7 @@ ##============================================================================ set(unit_tests + UnitTestSceneRendererOSMesa.cxx UnitTestSceneRendererVolume.cxx ) diff --git a/vtkm/rendering/testing/Makefile b/vtkm/rendering/testing/Makefile deleted file mode 100644 index 00aab9563..000000000 --- a/vtkm/rendering/testing/Makefile +++ /dev/null @@ -1,273 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.1 - -# Default target executed when no arguments are given to make. -default_target: all -.PHONY : default_target - -# Allow only one "make -f Makefile2" at a time, but pass parallelism. -.NOTPARALLEL: -.PHONY : .NOTPARALLEL - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - -# A target that is always out of date. -cmake_force: -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/local/tools/cmake-3.1.2/bin/cmake - -# The command to remove a file. -RM = /usr/local/tools/cmake-3.1.2/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /g/g19/larsen30/vtk-m - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /g/g19/larsen30/vtk-m - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target install/strip -install/strip: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." - /usr/local/tools/cmake-3.1.2/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake -.PHONY : install/strip - -# Special rule for the target install/strip -install/strip/fast: install/strip -.PHONY : install/strip/fast - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." - /usr/local/tools/cmake-3.1.2/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache -.PHONY : edit_cache/fast - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/local/tools/cmake-3.1.2/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache -.PHONY : rebuild_cache/fast - -# Special rule for the target install -install: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/local/tools/cmake-3.1.2/bin/cmake -P cmake_install.cmake -.PHONY : install - -# Special rule for the target install -install/fast: preinstall/fast - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/local/tools/cmake-3.1.2/bin/cmake -P cmake_install.cmake -.PHONY : install/fast - -# Special rule for the target list_install_components -list_install_components: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" -.PHONY : list_install_components - -# Special rule for the target list_install_components -list_install_components/fast: list_install_components -.PHONY : list_install_components/fast - -# Special rule for the target package -package: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Run CPack packaging tool..." - cd /g/g19/larsen30/vtk-m && /usr/local/tools/cmake-3.1.2/bin/cpack --config ./CPackConfig.cmake -.PHONY : package - -# Special rule for the target package -package/fast: package -.PHONY : package/fast - -# Special rule for the target test -test: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..." - /usr/local/tools/cmake-3.1.2/bin/ctest --force-new-ctest-process $(ARGS) -.PHONY : test - -# Special rule for the target test -test/fast: test -.PHONY : test/fast - -# Special rule for the target package_source -package_source: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Run CPack packaging tool for source..." - cd /g/g19/larsen30/vtk-m && /usr/local/tools/cmake-3.1.2/bin/cpack --config ./CPackSourceConfig.cmake /g/g19/larsen30/vtk-m/CPackSourceConfig.cmake -.PHONY : package_source - -# Special rule for the target package_source -package_source/fast: package_source -.PHONY : package_source/fast - -# Special rule for the target install/local -install/local: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." - /usr/local/tools/cmake-3.1.2/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake -.PHONY : install/local - -# Special rule for the target install/local -install/local/fast: install/local -.PHONY : install/local/fast - -# The main all target -all: cmake_check_build_system - cd /g/g19/larsen30/vtk-m && $(CMAKE_COMMAND) -E cmake_progress_start /g/g19/larsen30/vtk-m/CMakeFiles /g/g19/larsen30/vtk-m/vtkm/rendering/testing/CMakeFiles/progress.marks - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/testing/all - $(CMAKE_COMMAND) -E cmake_progress_start /g/g19/larsen30/vtk-m/CMakeFiles 0 -.PHONY : all - -# The main clean target -clean: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/testing/clean -.PHONY : clean - -# The main clean target -clean/fast: clean -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/testing/preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/testing/preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - cd /g/g19/larsen30/vtk-m && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -# Convenience name for target. -vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/rule: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f CMakeFiles/Makefile2 vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/rule -.PHONY : vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/rule - -# Convenience name for target. -UnitTests_kit_vtkm_rendering_testing: vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/rule -.PHONY : UnitTests_kit_vtkm_rendering_testing - -# fast build rule for target. -UnitTests_kit_vtkm_rendering_testing/fast: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/build.make vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/build -.PHONY : UnitTests_kit_vtkm_rendering_testing/fast - -UnitTestSceneRendererVolume.o: UnitTestSceneRendererVolume.cxx.o -.PHONY : UnitTestSceneRendererVolume.o - -# target to build an object file -UnitTestSceneRendererVolume.cxx.o: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/build.make vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/UnitTestSceneRendererVolume.cxx.o -.PHONY : UnitTestSceneRendererVolume.cxx.o - -UnitTestSceneRendererVolume.i: UnitTestSceneRendererVolume.cxx.i -.PHONY : UnitTestSceneRendererVolume.i - -# target to preprocess a source file -UnitTestSceneRendererVolume.cxx.i: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/build.make vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/UnitTestSceneRendererVolume.cxx.i -.PHONY : UnitTestSceneRendererVolume.cxx.i - -UnitTestSceneRendererVolume.s: UnitTestSceneRendererVolume.cxx.s -.PHONY : UnitTestSceneRendererVolume.s - -# target to generate assembly for a file -UnitTestSceneRendererVolume.cxx.s: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/build.make vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/UnitTestSceneRendererVolume.cxx.s -.PHONY : UnitTestSceneRendererVolume.cxx.s - -UnitTests_kit_vtkm_rendering_testing.o: UnitTests_kit_vtkm_rendering_testing.cxx.o -.PHONY : UnitTests_kit_vtkm_rendering_testing.o - -# target to build an object file -UnitTests_kit_vtkm_rendering_testing.cxx.o: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/build.make vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/UnitTests_kit_vtkm_rendering_testing.cxx.o -.PHONY : UnitTests_kit_vtkm_rendering_testing.cxx.o - -UnitTests_kit_vtkm_rendering_testing.i: UnitTests_kit_vtkm_rendering_testing.cxx.i -.PHONY : UnitTests_kit_vtkm_rendering_testing.i - -# target to preprocess a source file -UnitTests_kit_vtkm_rendering_testing.cxx.i: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/build.make vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/UnitTests_kit_vtkm_rendering_testing.cxx.i -.PHONY : UnitTests_kit_vtkm_rendering_testing.cxx.i - -UnitTests_kit_vtkm_rendering_testing.s: UnitTests_kit_vtkm_rendering_testing.cxx.s -.PHONY : UnitTests_kit_vtkm_rendering_testing.s - -# target to generate assembly for a file -UnitTests_kit_vtkm_rendering_testing.cxx.s: - cd /g/g19/larsen30/vtk-m && $(MAKE) -f vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/build.make vtkm/rendering/testing/CMakeFiles/UnitTests_kit_vtkm_rendering_testing.dir/UnitTests_kit_vtkm_rendering_testing.cxx.s -.PHONY : UnitTests_kit_vtkm_rendering_testing.cxx.s - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... install/strip" - @echo "... edit_cache" - @echo "... rebuild_cache" - @echo "... install" - @echo "... UnitTests_kit_vtkm_rendering_testing" - @echo "... list_install_components" - @echo "... package" - @echo "... test" - @echo "... package_source" - @echo "... install/local" - @echo "... UnitTestSceneRendererVolume.o" - @echo "... UnitTestSceneRendererVolume.i" - @echo "... UnitTestSceneRendererVolume.s" - @echo "... UnitTests_kit_vtkm_rendering_testing.o" - @echo "... UnitTests_kit_vtkm_rendering_testing.i" - @echo "... UnitTests_kit_vtkm_rendering_testing.s" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - cd /g/g19/larsen30/vtk-m && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system - diff --git a/vtkm/rendering/testing/UnitTestSceneRendererOSMesa.cxx b/vtkm/rendering/testing/UnitTestSceneRendererOSMesa.cxx new file mode 100644 index 000000000..091667046 --- /dev/null +++ b/vtkm/rendering/testing/UnitTestSceneRendererOSMesa.cxx @@ -0,0 +1,99 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt 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. +// +// Copyright 2015 Sandia Corporation. +// Copyright 2015 UT-Battelle, LLC. +// Copyright 2015 Los Alamos National Security. +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ +#include +#include +#include +#include +#include +#include +#include +#include +namespace { + +void TestSceneRendererOSMesa() +{ + // test regular grid data set + { + vtkm::cont::testing::MakeTestDataSet maker; + vtkm::cont::DataSet regularGrid = maker.Make3DRegularDataSet0(); + regularGrid.PrintSummary(std::cout); + vtkm::cont::Field scalarField = regularGrid.GetField("pointvar"); + const vtkm::cont::CoordinateSystem coords = regularGrid.GetCoordinateSystem(); + + vtkm::rendering::SceneRendererOSMesa sceneRenderer; + vtkm::rendering::View3D &view = sceneRenderer.GetView(); + + vtkm::Float64 coordsBounds[6]; // Xmin,Xmax,Ymin.. + coords.GetBounds(coordsBounds,VTKM_DEFAULT_DEVICE_ADAPTER_TAG()); + //set up a default view + 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); + std::cout<<"Magnitude "< lookAt = totalExtent * (mag * .5f); + view.LookAt = totalExtent * (mag * .5f); + vtkm::Vec up; + up[0] = 0.f; + up[1] = 1.f; + up[2] = 0.f; + view.Up = up; + view.NearPlane = 1.f; + view.FarPlane = 100.f; + view.FieldOfView = 60.f; + view.Height = 500; + view.Width = 500; + view.Position = totalExtent * (mag * 2.f); + vtkm::rendering::ColorTable colorTable("thermal"); + sceneRenderer.SetActiveColorTable(colorTable); + + std::cout<<"pos: "<, + vtkm::rendering::RenderSurfaceOSMesa> + w(scene, sceneRenderer, surface, bg); + + w.Initialize(); + w.Paint(); + std::string fn("output.pnm"); + w.SaveAs("output.pnm"); + } +} + +} //namespace +int UnitTestSceneRendererOSMesa(int, char *[]) +{ + return vtkm::cont::testing::Testing::Run(TestSceneRendererOSMesa); +} diff --git a/vtkm/rendering/testing/UnitTestSceneRendererVolume.cxx b/vtkm/rendering/testing/UnitTestSceneRendererVolume.cxx index fe8287762..1fa289710 100644 --- a/vtkm/rendering/testing/UnitTestSceneRendererVolume.cxx +++ b/vtkm/rendering/testing/UnitTestSceneRendererVolume.cxx @@ -60,9 +60,14 @@ void TestSceneRendererVolume() view.Height = 500; view.Width = 500; view.Position = totalExtent * (mag * 2.f); + + vtkm::Float64 scalarBounds[2]; + scalarField.GetBounds(scalarBounds, + VTKM_DEFAULT_DEVICE_ADAPTER_TAG()); vtkm::rendering::ColorTable colorTable("thermal"); sceneRenderer.SetActiveColorTable(colorTable); - sceneRenderer.RenderCells(regularGrid.GetCellSet(), coords, scalarField); + sceneRenderer.RenderCells(regularGrid.GetCellSet(), coords, scalarField, + colorTable, scalarBounds); } }//TestMortonCodes