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.
This commit is contained in:
Dave Pugmire 2016-02-09 08:59:26 -05:00 committed by Robert Maynard
parent 03a95c44b1
commit f84401243a
16 changed files with 880 additions and 642 deletions

47
CMake/FindMESA.cmake Normal file

@ -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)

@ -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

@ -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})

@ -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

62
vtkm/rendering/Plot.h Normal file

@ -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 <vtkm/rendering/SceneRenderer.h>
#include <vector>
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<typename SceneRendererType>
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

@ -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 <vtkm/Types.h>
#include <vtkm/cont/ErrorControlBadValue.h>
#include <vtkm/rendering/View.h>
#include <vector>
#include <GL/osmesa.h>
#include <GL/gl.h>
#include <iostream>
#include <fstream>
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<vtkm::Float32,4> 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<npixels; i++)
zbuff[i] = float(raw_zbuff[i]) / float(UINT_MAX);
}
VTKM_CONT_EXPORT
void SetViewToWorldSpace(vtkm::rendering::View3D &v, bool clip)
{
vtkm::Float32 oglP[16], oglM[16];
CreateOGLMatrix(v.CreateProjectionMatrix(), oglP);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(oglP);
CreateOGLMatrix(v.CreateViewMatrix(), oglM);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(oglM);
//std::cout<<"proj matrix: "<<std::endl; printMatrix(oglP);
//std::cout<<"view matrix: "<<std::endl; printMatrix(oglM);
SetViewportClipping(v, clip);
}
VTKM_CONT_EXPORT
void SetViewportClipping(vtkm::rendering::View3D &v, bool clip)
{
if (clip)
{
vtkm::Float32 vl, vr, vt, vb;
v.GetRealViewport(vl,vr,vt,vb);
double x = vtkm::Float32(v.Width)*(1.+vl)/2.;
double y = vtkm::Float32(v.Height)*(1.+vb)/2.;
double a = vtkm::Float32(v.Width)*(vr-vl)/2.;
double b = vtkm::Float32(v.Height)*(vt-vb)/2.;
glViewport(int(float(v.Width)*(1.+vl)/2.),
int(float(v.Height)*(1.+vb)/2.),
int(float(v.Width)*(vr-vl)/2.),
int(float(v.Height)*(vt-vb)/2.));
}
else
{
glViewport(0,0, v.Width, v.Height);
}
}
VTKM_CONT_EXPORT
void CreateOGLMatrix(const vtkm::Matrix<vtkm::Float32,4,4> &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"<<std::endl<<width<<" "<<height<<std::endl<<255<<std::endl;
for (int i=height-1; i>=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<<r<<g<<b;
}
of.close();
}
VTKM_CONT_EXPORT
void printMatrix(vtkm::Float32 *m)
{
std::cout<<"["<<m[0]<<" "<<m[1]<<" "<<m[2]<<" "<<m[3]<<std::endl;
std::cout<<" "<<m[4]<<" "<<m[5]<<" "<<m[6]<<" "<<m[7]<<std::endl;
std::cout<<" "<<m[8]<<" "<<m[9]<<" "<<m[10]<<" "<<m[11]<<std::endl;
std::cout<<" "<<m[12]<<" "<<m[13]<<" "<<m[14]<<" "<<m[15]<<"]"<<std::endl;
}
private:
OSMesaContext ctx;
std::vector<vtkm::Float32> rgba;
std::vector<vtkm::Float32> zbuff;
int width, height;
};
}} //namespace vtkm::rendering
#endif //vtk_m_rendering_RenderSurface_h

73
vtkm/rendering/Scene.h Normal file

@ -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 <vtkm/rendering/Plot.h>
#include <vector>
namespace vtkm {
namespace rendering {
class Scene
{
public:
std::vector<vtkm::rendering::Plot> plots;
VTKM_CONT_EXPORT
Scene() {}
};
class Scene3D : public Scene
{
public:
Scene3D() {}
template<typename SceneRendererType>
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<typename SceneRendererType>
VTKM_CONT_EXPORT
void Render(vtkm::rendering::View3D &view,
SceneRendererType &sceneRenderer)
{
}
};
}} //namespace vtkm::rendering
#endif //vtk_m_rendering_Scene_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<vtkm::Float32,4> &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"<<std::endl;
}
VTKM_CONT_EXPORT
virtual void EndScene()
{
std::cout<<__LINE__<<": TODO"<<std::endl;
}
protected:
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > ColorMap;
vtkm::Vec<vtkm::Float32,4> BackgroundColor;
View3D View;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > ColorMap;
vtkm::Vec<vtkm::Float32,4> BackgroundColor;
View3D View;
};
}} //namespace vtkm::rendering
#endif //vtk_m_rendering_SceneRenderer_h
#endif //vtk_m_rendering_SceneRenderer_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 <vtkm/cont/DataSet.h>
#include <vtkm/rendering/SceneRenderer.h>
#include <vtkm/rendering/ColorTable.h>
#include <vtkm/rendering/View.h>
#include <vtkm/rendering/Triangulator.h>
#include <GL/osmesa.h>
#include <GL/gl.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
namespace vtkm {
namespace rendering {
template<typename DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
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!"<<std::endl;
return;
}
std::cout<<"RenderCells()"<<std::endl;
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id, 4> > indices;
vtkm::Id numTri;
Triangulator<DeviceAdapter> triangulator;
triangulator.run(cellset, indices, numTri);
std::cout<<"NumTris= "<<numTri<<std::endl;
//printSummary_ArrayHandle(indices, std::cout);
vtkm::cont::ArrayHandle<vtkm::Float32> 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<vtkm::Id, 4> 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<vtkm::Float32, 3> p1 = uVerts.GetPortalConstControl().Get(i1);
vtkm::Vec<vtkm::Float32, 3> p2 = uVerts.GetPortalConstControl().Get(i2);
vtkm::Vec<vtkm::Float32, 3> 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<<i<<": "<<i1<<" "<<i2<<" "<<i3<<" si= "<<si<<" sn= "<<sn<<std::endl;
//std::cout<<" color= "<<color.Components[0]<<" "<<color.Components[1]<<" "<<color.Components[2]<<std::endl;
s = sf.GetPortalConstControl().Get(i1);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
color.Components[0] = 0;
glColor3fv(color.Components);
glVertex3f(p1[0],p1[1],p1[2]);
s = sf.GetPortalConstControl().Get(i2);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
color.Components[0] = 0;
glColor3fv(color.Components);
glVertex3f(p2[0],p2[1],p2[2]);
s = sf.GetPortalConstControl().Get(i3);
s = (s-sMin)/sDiff;
color = ct.MapRGB(s);
color.Components[0] = 0;
glColor3fv(color.Components);
glVertex3f(p3[0],p3[1],p3[2]);
}
glEnd();
glFinish();
glFlush();
}
private:
VTKM_CONT_EXPORT
virtual void Init()
{
ctx = OSMesaCreateContextExt(OSMESA_RGBA, 32, 0, 0, NULL);
if (!ctx) std::cout<<"ERROR 0"<<std::endl;
rgba.resize(width*height*4);
if (!OSMesaMakeCurrent(ctx, &rgba[0], GL_UNSIGNED_BYTE, width, height))
std::cout<<"ERROR 1"<<std::endl;
SetupView();
}
VTKM_CONT_EXPORT
void SetupView()
{
vtkm::Float32 oglV[16], oglP[16];
vtkm::Matrix<vtkm::Float32,4,4> vm = GetView().CreateViewMatrix();
vtkm::Matrix<vtkm::Float32,4,4> 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"<<std::endl<<width<<" "<<height<<std::endl<<255<<std::endl;
for (int i=height-1; i>=0; i--)
for (int j=0; j < width; j++)
{
const unsigned char *tuple = &(rgba[i*width*4 + j*4]);
of<<tuple[0]<<tuple[1]<<tuple[2];
}
of.close();
}
OSMesaContext ctx;
std::vector<unsigned char> rgba;
std::vector<float> zbuff;
int width, height;
};
}} //namespace vtkm::rendering
#endif //vtk_m_rendering_SceneRendererOSMesa_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..

@ -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<vtkm::Float32,4,4> &mat)
{
@ -117,5 +127,11 @@ public:
}
};
class View2D
{
public:
View2D() {}
};
}} // namespace vtkm::rendering
#endif // vtk_m_rendering_View_h
#endif // vtk_m_rendering_View_h

108
vtkm/rendering/Window.h Normal file

@ -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 <vtkm/cont/DataSet.h>
#include <vtkm/rendering/SceneRenderer.h>
#include <vtkm/rendering/Color.h>
#include <vtkm/rendering/View.h>
#include <vtkm/rendering/Scene.h>
namespace vtkm {
namespace rendering {
// Window2D Window3D
template<typename SceneRendererType, typename SurfaceType>
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<typename SceneRendererType>
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

@ -19,6 +19,7 @@
##============================================================================
set(unit_tests
UnitTestSceneRendererOSMesa.cxx
UnitTestSceneRendererVolume.cxx
)

@ -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

@ -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 <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/rendering/Window.h>
#include <vtkm/rendering/RenderSurface.h>
#include <vtkm/rendering/Scene.h>
#include <vtkm/rendering/Plot.h>
#include <vtkm/rendering/SceneRendererOSMesa.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/testing/Testing.h>
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<VTKM_DEFAULT_DEVICE_ADAPTER_TAG> 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<vtkm::Float32,3> 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 "<<mag<<std::endl;
vtkm::Normalize(totalExtent);
vtkm::Vec<vtkm::Float32,3> lookAt = totalExtent * (mag * .5f);
view.LookAt = totalExtent * (mag * .5f);
vtkm::Vec<vtkm::Float32,3> 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: "<<view.Position<<std::endl;
std::cout<<"at_: "<<view.LookAt<<std::endl;
sceneRenderer.SetView(view);
//sceneRenderer.RenderCells(regularGrid.GetCellSet(), coords, scalarField, colorTable);
//New way.
vtkm::rendering::RenderSurfaceOSMesa surface;
vtkm::rendering::Scene3D scene;
vtkm::rendering::Color bg(0.0f, 1.0f, 0.0f, 1.0f);
scene.plots.push_back(vtkm::rendering::Plot(regularGrid.GetCellSet(),
coords,
scalarField,
colorTable));
vtkm::rendering::Window3D<vtkm::rendering::SceneRendererOSMesa<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>,
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);
}

@ -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