mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 21:33:55 +00:00
adding rendering from other branch
This commit is contained in:
parent
1adb5d287c
commit
03a95c44b1
@ -75,3 +75,7 @@ add_subdirectory(benchmarking)
|
||||
#-----------------------------------------------------------------------------
|
||||
#add the io folder
|
||||
add_subdirectory(io)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#add the rendering folder
|
||||
add_subdirectory(rendering)
|
||||
|
@ -115,6 +115,12 @@ public:
|
||||
return Helper::LogicalToFlatToIndex(this->Internals, logicalToIndex);
|
||||
}
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
vtkm::Vec<vtkm::Id,Dimension> GetPointDimensions() const
|
||||
{
|
||||
return this->Internals.GetPointDimensions();
|
||||
}
|
||||
|
||||
private:
|
||||
InternalsType Internals;
|
||||
};
|
||||
|
37
vtkm/rendering/CMakeLists.txt
Normal file
37
vtkm/rendering/CMakeLists.txt
Normal file
@ -0,0 +1,37 @@
|
||||
##============================================================================
|
||||
## 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 2014 Sandia Corporation.
|
||||
## Copyright 2014 UT-Battelle, LLC.
|
||||
## Copyright 2014 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.
|
||||
##============================================================================
|
||||
|
||||
set(headers
|
||||
Color.h
|
||||
ColorTable.h
|
||||
SceneRendererVolume.h
|
||||
Triangulator.h
|
||||
View.h
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
vtkm_declare_headers(${headers})
|
||||
add_subdirectory(raytracing)
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
add_subdirectory(testing)
|
126
vtkm/rendering/Color.h
Normal file
126
vtkm/rendering/Color.h
Normal file
@ -0,0 +1,126 @@
|
||||
//============================================================================
|
||||
// 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_Color_h
|
||||
#define vtk_m_rendering_Color_h
|
||||
|
||||
#include <iostream>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
/// \brief It's a color!
|
||||
///
|
||||
/// This class provides the basic representation of a color. This class was
|
||||
/// Ported from EAVL. Originally created by Jeremy Meredith, Dave Pugmire,
|
||||
/// and Sean Ahern.
|
||||
///
|
||||
class Color
|
||||
{
|
||||
public:
|
||||
vtkm::Float32 Components[4];
|
||||
Color()
|
||||
{
|
||||
Components[0] = 0;
|
||||
Components[1] = 0;
|
||||
Components[2] = 0;
|
||||
Components[3] = 1;
|
||||
}
|
||||
Color(vtkm::Float32 r_,
|
||||
vtkm::Float32 g_,
|
||||
vtkm::Float32 b_,
|
||||
vtkm::Float32 a_ = 1.f)
|
||||
{
|
||||
Components[0] = r_;
|
||||
Components[1] = g_;
|
||||
Components[2] = b_;
|
||||
Components[3] = a_;
|
||||
}
|
||||
inline void SetComponentFromByte(vtkm::Int32 i, vtkm::UInt8 v)
|
||||
{
|
||||
// Note that though GetComponentAsByte below
|
||||
// multiplies by 256, we're dividing by 255. here.
|
||||
// This is, believe it or not, still correct.
|
||||
// That's partly because we always round down in
|
||||
// that method. For example, if we set the float
|
||||
// here using byte(1), /255 gives us .00392, which
|
||||
// *256 gives us 1.0035, which is then rounded back
|
||||
// down to byte(1) below. Or, if we set the float
|
||||
// here using byte(254), /255 gives us .99608, which
|
||||
// *256 gives us 254.996, which is then rounded
|
||||
// back down to 254 below. So it actually reverses
|
||||
// correctly, even though the mutliplier and
|
||||
// divider don't match between these two methods.
|
||||
//
|
||||
// Of course, converting in GetComponentAsByte from
|
||||
// 1.0 gives 256, so we need to still clamp to 255
|
||||
// anyway. Again, this is not a problem, because it
|
||||
// doesn't really extend the range of floating point
|
||||
// values which map to 255.
|
||||
Components[i] = float(v) / 255.f;
|
||||
// clamp?
|
||||
if (Components[i]<0) Components[i] = 0;
|
||||
if (Components[i]>1) Components[i] = 1;
|
||||
}
|
||||
inline vtkm::UInt8 GetComponentAsByte(int i)
|
||||
{
|
||||
// We need this to match what OpenGL/Mesa do.
|
||||
// Why? Well, we need to set glClearColor
|
||||
// using floats, but the frame buffer comes
|
||||
// back as bytes (and is internally such) in
|
||||
// most cases. In one example -- parallel
|
||||
// compositing -- we need the byte values
|
||||
// returned from here to match the byte values
|
||||
// returned in the frame buffer. Though
|
||||
// a quick source code inspection of Mesa
|
||||
// led me to believe I should do *255., in
|
||||
// fact this led to a mismatch. *256. was
|
||||
// actually closer. (And arguably more correct
|
||||
// if you think the byte value 255 should share
|
||||
// approximately the same range in the float [0,1]
|
||||
// space as the other byte values.) Note in the
|
||||
// inverse method above, though, we still use 255;
|
||||
// see SetComponentFromByte for an explanation of
|
||||
// why that is correct, if non-obvious.
|
||||
|
||||
int tv = vtkm::Int32(Components[i] * 256.f);
|
||||
// Converting even from valid values (i.e 1.0)
|
||||
// can give a result outside the range (i.e. 256),
|
||||
// but we have to clamp anyway.
|
||||
return vtkm::UInt8((tv < 0) ? 0 : (tv > 255) ? 255 : tv);
|
||||
}
|
||||
void GetRGBA(vtkm::UInt8 &r, vtkm::UInt8 &g,
|
||||
vtkm::UInt8 &b, vtkm::UInt8 &a)
|
||||
{
|
||||
r = GetComponentAsByte(0);
|
||||
g = GetComponentAsByte(1);
|
||||
b = GetComponentAsByte(2);
|
||||
a = GetComponentAsByte(3);
|
||||
}
|
||||
vtkm::Float64 RawBrightness()
|
||||
{
|
||||
return (Components[0]+Components[1]+Components[2])/3.;
|
||||
}
|
||||
friend std::ostream &operator<<(std::ostream &out, const Color &c)
|
||||
{
|
||||
out << "["<<c.Components[0]<<","<<c.Components[1]<<","<<c.Components[2]<<","<<c.Components[3]<<"]";
|
||||
return out;
|
||||
}
|
||||
};
|
||||
}}//namespace vtkm::rendering
|
||||
#endif //vtk_m_rendering_Color_h
|
865
vtkm/rendering/ColorTable.h
Normal file
865
vtkm/rendering/ColorTable.h
Normal file
@ -0,0 +1,865 @@
|
||||
//============================================================================
|
||||
// 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_ColorTable_h
|
||||
#define vtk_m_rendering_ColorTable_h
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <vtkm/rendering/Color.h>
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
/// \brief It's a color table!
|
||||
///
|
||||
/// This class provides the basic representation of a color table. This class was
|
||||
/// Ported from EAVL. Originally created by Jeremy Meredith, Dave Pugmire,
|
||||
/// and Sean Ahern. This class uses seperate RGB and alpha control points and can
|
||||
/// be used as a transfer function.
|
||||
///
|
||||
class ColorTable
|
||||
{
|
||||
public:
|
||||
class ColorControlPoint
|
||||
{
|
||||
public:
|
||||
vtkm::Float32 Position;
|
||||
Color RGBA;
|
||||
ColorControlPoint(vtkm::Float32 position, const Color &rgba)
|
||||
: Position(position), RGBA(rgba)
|
||||
{ }
|
||||
};
|
||||
|
||||
class AlphaControlPoint
|
||||
{
|
||||
public:
|
||||
vtkm::Float32 Position;
|
||||
vtkm::Float32 AlphaValue;
|
||||
AlphaControlPoint(vtkm::Float32 position, const vtkm::Float32 &alphaValue)
|
||||
: Position(position), AlphaValue(alphaValue)
|
||||
{ }
|
||||
};
|
||||
|
||||
protected:
|
||||
std::string uniquename;
|
||||
bool smooth;
|
||||
std::vector<ColorControlPoint> RBGPoints;
|
||||
std::vector<AlphaControlPoint> AlphaPoints;
|
||||
typedef std::vector<AlphaControlPoint>::size_type AlphaType;
|
||||
typedef std::vector<ColorControlPoint>::size_type ColorType;
|
||||
public:
|
||||
const std::string &GetName() const
|
||||
{
|
||||
return uniquename;
|
||||
}
|
||||
bool GetSmooth() const
|
||||
{
|
||||
return smooth;
|
||||
}
|
||||
void Sample(int n, vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > &colors) const
|
||||
{
|
||||
colors.Allocate(n);
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
vtkm::Vec<vtkm::Float32,4> color;
|
||||
Color c = MapRGB(float(i)/float(n-1));
|
||||
color[0] = c.Components[0];
|
||||
color[1] = c.Components[1];
|
||||
color[2] = c.Components[2];
|
||||
color[3] = MapAlpha(float(i)/float(n-1));
|
||||
colors.GetPortalControl().Set(i,color);
|
||||
}
|
||||
}
|
||||
Color MapRGB(vtkm::Float32 c) const
|
||||
{
|
||||
ColorType n = RBGPoints.size();
|
||||
if (n == 0)
|
||||
return Color(0.5f, 0.5f, 0.5f);
|
||||
if (n == 1 || c <= RBGPoints[0].Position)
|
||||
return RBGPoints[0].RGBA;
|
||||
if (c >= RBGPoints[n - 1].Position)
|
||||
return RBGPoints[n - 1].RGBA;
|
||||
ColorType second;
|
||||
for (second = 1; second < n - 1; second++)
|
||||
{
|
||||
if (c < RBGPoints[second].Position)
|
||||
break;
|
||||
}
|
||||
ColorType first = second - 1;
|
||||
vtkm::Float32 seg = RBGPoints[second].Position-RBGPoints[first].Position;
|
||||
vtkm::Float32 alpha;
|
||||
if (seg == 0.f)
|
||||
alpha = .5f;
|
||||
else
|
||||
alpha = (c - RBGPoints[first].Position)/seg;
|
||||
if (smooth)
|
||||
{
|
||||
return Color(RBGPoints[first].RGBA.Components[0] * (1.f-alpha) + RBGPoints[second].RGBA.Components[0] * alpha,
|
||||
RBGPoints[first].RGBA.Components[1] * (1.f-alpha) + RBGPoints[second].RGBA.Components[1] * alpha,
|
||||
RBGPoints[first].RGBA.Components[2] * (1.f-alpha) + RBGPoints[second].RGBA.Components[2] * alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alpha < .5)
|
||||
return RBGPoints[first].RGBA;
|
||||
else
|
||||
return RBGPoints[second].RGBA;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
vtkm::Float32 MapAlpha(vtkm::Float32 c) const
|
||||
{
|
||||
AlphaType n = AlphaPoints.size();
|
||||
// If no alpha control points were set, just return full opacity
|
||||
if (n == 0)
|
||||
return 1.f;
|
||||
if (n == 1 || c <= AlphaPoints[0].Position)
|
||||
return AlphaPoints[0].AlphaValue;
|
||||
if (c >= AlphaPoints[n-1].Position)
|
||||
return AlphaPoints[n-1].AlphaValue;
|
||||
AlphaType second;
|
||||
for (second=1; second<n-1; second++)
|
||||
{
|
||||
if (c < AlphaPoints[second].Position)
|
||||
break;
|
||||
}
|
||||
AlphaType first = second - 1;
|
||||
vtkm::Float32 seg = AlphaPoints[second].Position-AlphaPoints[first].Position;
|
||||
vtkm::Float32 alpha;
|
||||
if (seg == 0.f)
|
||||
alpha = .5;
|
||||
else
|
||||
alpha = (c - AlphaPoints[first].Position)/seg;
|
||||
if (smooth)
|
||||
{
|
||||
return (AlphaPoints[first].AlphaValue * (1.f-alpha) + AlphaPoints[second].AlphaValue * alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (alpha < .5)
|
||||
return AlphaPoints[first].AlphaValue;
|
||||
else
|
||||
return AlphaPoints[second].AlphaValue;
|
||||
}
|
||||
|
||||
}
|
||||
ColorTable() :
|
||||
uniquename(""), smooth(false)
|
||||
{
|
||||
}
|
||||
ColorTable(const ColorTable &ct) :
|
||||
uniquename(ct.uniquename), smooth(ct.smooth), RBGPoints(ct.RBGPoints.begin(), ct.RBGPoints.end())
|
||||
{
|
||||
}
|
||||
void operator=(const ColorTable &ct)
|
||||
{
|
||||
uniquename = ct.uniquename;
|
||||
smooth = ct.smooth;
|
||||
RBGPoints.clear();
|
||||
RBGPoints.insert(RBGPoints.end(), ct.RBGPoints.begin(), ct.RBGPoints.end());
|
||||
AlphaPoints.insert(AlphaPoints.end(), ct.AlphaPoints.begin(), ct.AlphaPoints.end());
|
||||
}
|
||||
void Clear()
|
||||
{
|
||||
RBGPoints.clear();
|
||||
AlphaPoints.clear();
|
||||
}
|
||||
void AddControlPoint(vtkm::Float32 position, Color color)
|
||||
{
|
||||
RBGPoints.push_back(ColorControlPoint(position, color));
|
||||
}
|
||||
void AddControlPoint(vtkm::Float32 position, Color color, vtkm::Float32 alpha)
|
||||
{
|
||||
RBGPoints.push_back(ColorControlPoint(position, color));
|
||||
AlphaPoints.push_back(AlphaControlPoint(position, alpha));
|
||||
}
|
||||
void AddAlphaControlPoint(vtkm::Float32 position, vtkm::Float32 alpha)
|
||||
{
|
||||
AlphaPoints.push_back(AlphaControlPoint(position, alpha));
|
||||
}
|
||||
void Reverse()
|
||||
{
|
||||
// copy old control points
|
||||
std::vector<ColorControlPoint> tmp(RBGPoints.begin(), RBGPoints.end());
|
||||
std::vector<AlphaControlPoint> tmpAlpha(AlphaPoints.begin(), AlphaPoints.end());
|
||||
Clear();
|
||||
vtkm::Int32 vectorSize = vtkm::Int32(tmp.size());
|
||||
for (vtkm::Int32 i = vectorSize - 1; i >= 0; --i)
|
||||
AddControlPoint(1.0f - tmp[ColorType(i)].Position, tmp[ColorType(i)].RGBA);
|
||||
vectorSize = vtkm::Int32(tmpAlpha.size());
|
||||
for (vtkm::Int32 i = vectorSize - 1; i >= 0; --i)
|
||||
AddAlphaControlPoint(1.0f - tmpAlpha[AlphaType(i)].Position, tmpAlpha[AlphaType(i)].AlphaValue);
|
||||
if (uniquename[1] == '0')
|
||||
uniquename[1] = '1';
|
||||
else
|
||||
uniquename[1] = '0';
|
||||
}
|
||||
ColorTable(std::string name)
|
||||
{
|
||||
if (name == "" || name == "default")
|
||||
name = "dense";
|
||||
|
||||
smooth = true;
|
||||
if (name == "grey" || name == "gray")
|
||||
{
|
||||
AddControlPoint(0.0f, Color( 0.f, 0.f, 0.f));
|
||||
AddControlPoint(1.0f, Color( 1.f, 1.f, 1.f));
|
||||
}
|
||||
else if (name == "blue")
|
||||
{
|
||||
AddControlPoint(0.00f, Color( 0.f, 0.f, 0.f));
|
||||
AddControlPoint(0.33f, Color( 0.f, 0.f, .5f));
|
||||
AddControlPoint(0.66f, Color( 0.f, .5f, 1.f));
|
||||
AddControlPoint(1.00f, Color( 1.f, 1.f, 1.f));
|
||||
}
|
||||
else if (name == "orange")
|
||||
{
|
||||
AddControlPoint(0.00f, Color( 0.f, 0.f, 0.f));
|
||||
AddControlPoint(0.33f, Color( .5f, 0.f, 0.f));
|
||||
AddControlPoint(0.66f, Color( 1.f, .5f, 0.f));
|
||||
AddControlPoint(1.00f, Color( 1.f, 1.f, 1.f));
|
||||
}
|
||||
else if (name == "temperature")
|
||||
{
|
||||
AddControlPoint(0.05f, Color( 0.f, 0.f, 1.f));
|
||||
AddControlPoint(0.35f, Color( 0.f, 1.f, 1.f));
|
||||
AddControlPoint(0.50f, Color( 1.f, 1.f, 1.f));
|
||||
AddControlPoint(0.65f, Color( 1.f, 1.f, 0.f));
|
||||
AddControlPoint(0.95f, Color( 1.f, 0.f, 0.f));
|
||||
}
|
||||
else if (name == "rainbow")
|
||||
{
|
||||
AddControlPoint(0.00f, Color( 0.f, 0.f, 1.f));
|
||||
AddControlPoint(0.20f, Color( 0.f, 1.f, 1.f));
|
||||
AddControlPoint(0.45f, Color( 0.f, 1.f, 0.f));
|
||||
AddControlPoint(0.55f, Color( .7f, 1.f, 0.f));
|
||||
AddControlPoint(0.6f, Color( 1.f, 1.f, 0.f));
|
||||
AddControlPoint(0.75f, Color( 1.f, .5f, 0.f));
|
||||
AddControlPoint(0.9f, Color( 1.f, 0.f, 0.f));
|
||||
AddControlPoint(0.98f, Color( 1.f, 0.f, .5F));
|
||||
AddControlPoint(1.0f, Color( 1.f, 0.f, 1.f));
|
||||
}
|
||||
else if (name == "levels")
|
||||
{
|
||||
AddControlPoint(0.0f, Color( 0.f, 0.f, 1.f));
|
||||
AddControlPoint(0.2f, Color( 0.f, 0.f, 1.f));
|
||||
AddControlPoint(0.2f, Color( 0.f, 1.f, 1.f));
|
||||
AddControlPoint(0.4f, Color( 0.f, 1.f, 1.f));
|
||||
AddControlPoint(0.4f, Color( 0.f, 1.f, 0.f));
|
||||
AddControlPoint(0.6f, Color( 0.f, 1.f, 0.f));
|
||||
AddControlPoint(0.6f, Color( 1.f, 1.f, 0.f));
|
||||
AddControlPoint(0.8f, Color( 1.f, 1.f, 0.f));
|
||||
AddControlPoint(0.8f, Color( 1.f, 0.f, 0.f));
|
||||
AddControlPoint(1.0f, Color( 1.f, 0.f, 0.f));
|
||||
}
|
||||
else if (name == "dense" || name == "sharp")
|
||||
{
|
||||
smooth = (name == "dense") ? true : false;
|
||||
AddControlPoint(0.0f, Color(0.26f, 0.22f, 0.92f));
|
||||
AddControlPoint(0.1f, Color(0.00f, 0.00f, 0.52f));
|
||||
AddControlPoint(0.2f, Color(0.00f, 1.00f, 1.00f));
|
||||
AddControlPoint(0.3f, Color(0.00f, 0.50f, 0.00f));
|
||||
AddControlPoint(0.4f, Color(1.00f, 1.00f, 0.00f));
|
||||
AddControlPoint(0.5f, Color(0.60f, 0.47f, 0.00f));
|
||||
AddControlPoint(0.6f, Color(1.00f, 0.47f, 0.00f));
|
||||
AddControlPoint(0.7f, Color(0.61f, 0.18f, 0.00f));
|
||||
AddControlPoint(0.8f, Color(1.00f, 0.03f, 0.17f));
|
||||
AddControlPoint(0.9f, Color(0.63f, 0.12f, 0.34f));
|
||||
AddControlPoint(1.0f, Color(1.00f, 0.40f, 1.00f));
|
||||
}
|
||||
else if (name == "thermal")
|
||||
{
|
||||
AddControlPoint(0.0f, Color(0.30f, 0.00f, 0.00f));
|
||||
AddControlPoint(0.25f,Color(1.00f, 0.00f, 0.00f));
|
||||
AddControlPoint(0.50f,Color(1.00f, 1.00f, 0.00f));
|
||||
AddControlPoint(0.55f,Color(0.80f, 0.55f, 0.20f));
|
||||
AddControlPoint(0.60f,Color(0.60f, 0.37f, 0.40f));
|
||||
AddControlPoint(0.65f,Color(0.40f, 0.22f, 0.60f));
|
||||
AddControlPoint(0.75f,Color(0.00f, 0.00f, 1.00f));
|
||||
AddControlPoint(1.00f,Color(1.00f, 1.00f, 1.00f));
|
||||
}
|
||||
// The following five tables are perceeptually linearized colortables
|
||||
// (4 rainbow, one heatmap) from BSD-licensed code by Matteo Niccoli.
|
||||
// See: http://mycarta.wordpress.com/2012/05/29/the-rainbow-is-dead-long-live-the-rainbow-series-outline/
|
||||
else if (name == "IsoL")
|
||||
{
|
||||
vtkm::Float32 n = 5;
|
||||
AddControlPoint(0.f/n, Color(0.9102f, 0.2236f, 0.8997f));
|
||||
AddControlPoint(1.f/n, Color(0.4027f, 0.3711f, 1.0000f));
|
||||
AddControlPoint(2.f/n, Color(0.0422f, 0.5904f, 0.5899f));
|
||||
AddControlPoint(3.f/n, Color(0.0386f, 0.6206f, 0.0201f));
|
||||
AddControlPoint(4.f/n, Color(0.5441f, 0.5428f, 0.0110f));
|
||||
AddControlPoint(5.f/n, Color(1.0000f, 0.2288f, 0.1631f));
|
||||
}
|
||||
else if (name == "CubicL")
|
||||
{
|
||||
vtkm::Float32 n = 15;
|
||||
AddControlPoint(0.f/n, Color(0.4706f, 0.0000f, 0.5216f));
|
||||
AddControlPoint(1.f/n, Color(0.5137f, 0.0527f, 0.7096f));
|
||||
AddControlPoint(2.f/n, Color(0.4942f, 0.2507f, 0.8781f));
|
||||
AddControlPoint(3.f/n, Color(0.4296f, 0.3858f, 0.9922f));
|
||||
AddControlPoint(4.f/n, Color(0.3691f, 0.5172f, 0.9495f));
|
||||
AddControlPoint(5.f/n, Color(0.2963f, 0.6191f, 0.8515f));
|
||||
AddControlPoint(6.f/n, Color(0.2199f, 0.7134f, 0.7225f));
|
||||
AddControlPoint(7.f/n, Color(0.2643f, 0.7836f, 0.5756f));
|
||||
AddControlPoint(8.f/n, Color(0.3094f, 0.8388f, 0.4248f));
|
||||
AddControlPoint(9.f/n, Color(0.3623f, 0.8917f, 0.2858f));
|
||||
AddControlPoint(10.f/n, Color(0.5200f, 0.9210f, 0.3137f));
|
||||
AddControlPoint(11.f/n, Color(0.6800f, 0.9255f, 0.3386f));
|
||||
AddControlPoint(12.f/n, Color(0.8000f, 0.9255f, 0.3529f));
|
||||
AddControlPoint(13.f/n, Color(0.8706f, 0.8549f, 0.3608f));
|
||||
AddControlPoint(14.f/n, Color(0.9514f, 0.7466f, 0.3686f));
|
||||
AddControlPoint(15.f/n, Color(0.9765f, 0.5887f, 0.3569f));
|
||||
}
|
||||
else if (name == "CubicYF")
|
||||
{
|
||||
vtkm::Float32 n = 15;
|
||||
AddControlPoint(0.f/n, Color(0.5151f, 0.0482f, 0.6697f));
|
||||
AddControlPoint(1.f/n, Color(0.5199f, 0.1762f, 0.8083f));
|
||||
AddControlPoint(2.f/n, Color(0.4884f, 0.2912f, 0.9234f));
|
||||
AddControlPoint(3.f/n, Color(0.4297f, 0.3855f, 0.9921f));
|
||||
AddControlPoint(4.f/n, Color(0.3893f, 0.4792f, 0.9775f));
|
||||
AddControlPoint(5.f/n, Color(0.3337f, 0.5650f, 0.9056f));
|
||||
AddControlPoint(6.f/n, Color(0.2795f, 0.6419f, 0.8287f));
|
||||
AddControlPoint(7.f/n, Color(0.2210f, 0.7123f, 0.7258f));
|
||||
AddControlPoint(8.f/n, Color(0.2468f, 0.7612f, 0.6248f));
|
||||
AddControlPoint(9.f/n, Color(0.2833f, 0.8125f, 0.5069f));
|
||||
AddControlPoint(10.f/n, Color(0.3198f, 0.8492f, 0.3956f));
|
||||
AddControlPoint(11.f/n, Color(0.3602f, 0.8896f, 0.2919f));
|
||||
AddControlPoint(12.f/n, Color(0.4568f, 0.9136f, 0.3018f));
|
||||
AddControlPoint(13.f/n, Color(0.6033f, 0.9255f, 0.3295f));
|
||||
AddControlPoint(14.f/n, Color(0.7066f, 0.9255f, 0.3414f));
|
||||
AddControlPoint(15.f/n, Color(0.8000f, 0.9255f, 0.3529f));
|
||||
}
|
||||
else if (name == "LinearL")
|
||||
{
|
||||
vtkm::Float32 n = 15;
|
||||
AddControlPoint(0.f/n, Color(0.0143f, 0.0143f, 0.0143f));
|
||||
AddControlPoint(1.f/n, Color(0.1413f, 0.0555f, 0.1256f));
|
||||
AddControlPoint(2.f/n, Color(0.1761f, 0.0911f, 0.2782f));
|
||||
AddControlPoint(3.f/n, Color(0.1710f, 0.1314f, 0.4540f));
|
||||
AddControlPoint(4.f/n, Color(0.1074f, 0.2234f, 0.4984f));
|
||||
AddControlPoint(5.f/n, Color(0.0686f, 0.3044f, 0.5068f));
|
||||
AddControlPoint(6.f/n, Color(0.0008f, 0.3927f, 0.4267f));
|
||||
AddControlPoint(7.f/n, Color(0.0000f, 0.4763f, 0.3464f));
|
||||
AddControlPoint(8.f/n, Color(0.0000f, 0.5565f, 0.2469f));
|
||||
AddControlPoint(9.f/n, Color(0.0000f, 0.6381f, 0.1638f));
|
||||
AddControlPoint(10.f/n, Color(0.2167f, 0.6966f, 0.0000f));
|
||||
AddControlPoint(11.f/n, Color(0.3898f, 0.7563f, 0.0000f));
|
||||
AddControlPoint(12.f/n, Color(0.6912f, 0.7795f, 0.0000f));
|
||||
AddControlPoint(13.f/n, Color(0.8548f, 0.8041f, 0.4555f));
|
||||
AddControlPoint(14.f/n, Color(0.9712f, 0.8429f, 0.7287f));
|
||||
AddControlPoint(15.f/n, Color(0.9692f, 0.9273f, 0.8961f));
|
||||
}
|
||||
else if (name == "LinLhot")
|
||||
{
|
||||
vtkm::Float32 n = 15;
|
||||
AddControlPoint(0.f/n, Color(0.0225f, 0.0121f, 0.0121f));
|
||||
AddControlPoint(1.f/n, Color(0.1927f, 0.0225f, 0.0311f));
|
||||
AddControlPoint(2.f/n, Color(0.3243f, 0.0106f, 0.0000f));
|
||||
AddControlPoint(3.f/n, Color(0.4463f, 0.0000f, 0.0091f));
|
||||
AddControlPoint(4.f/n, Color(0.5706f, 0.0000f, 0.0737f));
|
||||
AddControlPoint(5.f/n, Color(0.6969f, 0.0000f, 0.1337f));
|
||||
AddControlPoint(6.f/n, Color(0.8213f, 0.0000f, 0.1792f));
|
||||
AddControlPoint(7.f/n, Color(0.8636f, 0.0000f, 0.0565f));
|
||||
AddControlPoint(8.f/n, Color(0.8821f, 0.2555f, 0.0000f));
|
||||
AddControlPoint(9.f/n, Color(0.8720f, 0.4182f, 0.0000f));
|
||||
AddControlPoint(10.f/n, Color(0.8424f, 0.5552f, 0.0000f));
|
||||
AddControlPoint(11.f/n, Color(0.8031f, 0.6776f, 0.0000f));
|
||||
AddControlPoint(12.f/n, Color(0.7659f, 0.7870f, 0.0000f));
|
||||
AddControlPoint(13.f/n, Color(0.8170f, 0.8296f, 0.0000f));
|
||||
AddControlPoint(14.f/n, Color(0.8853f, 0.8896f, 0.4113f));
|
||||
AddControlPoint(15.f/n, Color(0.9481f, 0.9486f, 0.7165f));
|
||||
}
|
||||
// ColorBrewer tables here. (See LICENSE.txt)
|
||||
else if (name == "PuRd")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.9686f, 0.9569f, 0.9765f));
|
||||
AddControlPoint(0.1250f, Color(0.9059f, 0.8824f, 0.9373f));
|
||||
AddControlPoint(0.2500f, Color(0.8314f, 0.7255f, 0.8549f));
|
||||
AddControlPoint(0.3750f, Color(0.7882f, 0.5804f, 0.7804f));
|
||||
AddControlPoint(0.5000f, Color(0.8745f, 0.3961f, 0.6902f));
|
||||
AddControlPoint(0.6250f, Color(0.9059f, 0.1608f, 0.5412f));
|
||||
AddControlPoint(0.7500f, Color(0.8078f, 0.0706f, 0.3373f));
|
||||
AddControlPoint(0.8750f, Color(0.5961f, 0.0000f, 0.2627f));
|
||||
AddControlPoint(1.0000f, Color(0.4039f, 0.0000f, 0.1216f));
|
||||
}
|
||||
else if (name == "Accent")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.4980f, 0.7882f, 0.4980f));
|
||||
AddControlPoint(0.1429f, Color(0.7451f, 0.6824f, 0.8314f));
|
||||
AddControlPoint(0.2857f, Color(0.9922f, 0.7529f, 0.5255f));
|
||||
AddControlPoint(0.4286f, Color(1.0000f, 1.0000f, 0.6000f));
|
||||
AddControlPoint(0.5714f, Color(0.2196f, 0.4235f, 0.6902f));
|
||||
AddControlPoint(0.7143f, Color(0.9412f, 0.0078f, 0.4980f));
|
||||
AddControlPoint(0.8571f, Color(0.7490f, 0.3569f, 0.0902f));
|
||||
AddControlPoint(1.0000f, Color(0.4000f, 0.4000f, 0.4000f));
|
||||
}
|
||||
else if (name == "Blues")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.9686f, 0.9843f, 1.0000f));
|
||||
AddControlPoint(0.1250f, Color(0.8706f, 0.9216f, 0.9686f));
|
||||
AddControlPoint(0.2500f, Color(0.7765f, 0.8588f, 0.9373f));
|
||||
AddControlPoint(0.3750f, Color(0.6196f, 0.7922f, 0.8824f));
|
||||
AddControlPoint(0.5000f, Color(0.4196f, 0.6824f, 0.8392f));
|
||||
AddControlPoint(0.6250f, Color(0.2588f, 0.5725f, 0.7765f));
|
||||
AddControlPoint(0.7500f, Color(0.1294f, 0.4431f, 0.7098f));
|
||||
AddControlPoint(0.8750f, Color(0.0314f, 0.3176f, 0.6118f));
|
||||
AddControlPoint(1.0000f, Color(0.0314f, 0.1882f, 0.4196f));
|
||||
}
|
||||
else if (name == "BrBG")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.3294f, 0.1882f, 0.0196f));
|
||||
AddControlPoint(0.1000f, Color(0.5490f, 0.3176f, 0.0392f));
|
||||
AddControlPoint(0.2000f, Color(0.7490f, 0.5059f, 0.1765f));
|
||||
AddControlPoint(0.3000f, Color(0.8745f, 0.7608f, 0.4902f));
|
||||
AddControlPoint(0.4000f, Color(0.9647f, 0.9098f, 0.7647f));
|
||||
AddControlPoint(0.5000f, Color(0.9608f, 0.9608f, 0.9608f));
|
||||
AddControlPoint(0.6000f, Color(0.7804f, 0.9176f, 0.8980f));
|
||||
AddControlPoint(0.7000f, Color(0.5020f, 0.8039f, 0.7569f));
|
||||
AddControlPoint(0.8000f, Color(0.2078f, 0.5922f, 0.5608f));
|
||||
AddControlPoint(0.9000f, Color(0.0039f, 0.4000f, 0.3686f));
|
||||
AddControlPoint(1.0000f, Color(0.0000f, 0.2353f, 0.1882f));
|
||||
}
|
||||
else if (name == "BuGn")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.9686f, 0.9882f, 0.9922f));
|
||||
AddControlPoint(0.1250f, Color(0.8980f, 0.9608f, 0.9765f));
|
||||
AddControlPoint(0.2500f, Color(0.8000f, 0.9255f, 0.9020f));
|
||||
AddControlPoint(0.3750f, Color(0.6000f, 0.8471f, 0.7882f));
|
||||
AddControlPoint(0.5000f, Color(0.4000f, 0.7608f, 0.6431f));
|
||||
AddControlPoint(0.6250f, Color(0.2549f, 0.6824f, 0.4627f));
|
||||
AddControlPoint(0.7500f, Color(0.1373f, 0.5451f, 0.2706f));
|
||||
AddControlPoint(0.8750f, Color(0.0000f, 0.4275f, 0.1725f));
|
||||
AddControlPoint(1.0000f, Color(0.0000f, 0.2667f, 0.1059f));
|
||||
}
|
||||
else if (name == "BuPu")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.9686f, 0.9882f, 0.9922f));
|
||||
AddControlPoint(0.1250f, Color(0.8784f, 0.9255f, 0.9569f));
|
||||
AddControlPoint(0.2500f, Color(0.7490f, 0.8275f, 0.9020f));
|
||||
AddControlPoint(0.3750f, Color(0.6196f, 0.7373f, 0.8549f));
|
||||
AddControlPoint(0.5000f, Color(0.5490f, 0.5882f, 0.7765f));
|
||||
AddControlPoint(0.6250f, Color(0.5490f, 0.4196f, 0.6941f));
|
||||
AddControlPoint(0.7500f, Color(0.5333f, 0.2549f, 0.6157f));
|
||||
AddControlPoint(0.8750f, Color(0.5059f, 0.0588f, 0.4863f));
|
||||
AddControlPoint(1.0000f, Color(0.3020f, 0.0000f, 0.2941f));
|
||||
}
|
||||
else if (name == "Dark2")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.1059f, 0.6196f, 0.4667f));
|
||||
AddControlPoint(0.1429f, Color(0.8510f, 0.3725f, 0.0078f));
|
||||
AddControlPoint(0.2857f, Color(0.4588f, 0.4392f, 0.7020f));
|
||||
AddControlPoint(0.4286f, Color(0.9059f, 0.1608f, 0.5412f));
|
||||
AddControlPoint(0.5714f, Color(0.4000f, 0.6510f, 0.1176f));
|
||||
AddControlPoint(0.7143f, Color(0.9020f, 0.6706f, 0.0078f));
|
||||
AddControlPoint(0.8571f, Color(0.6510f, 0.4627f, 0.1137f));
|
||||
AddControlPoint(1.0000f, Color(0.4000f, 0.4000f, 0.4000f));
|
||||
}
|
||||
else if (name == "GnBu")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.9686f, 0.9882f, 0.9412f));
|
||||
AddControlPoint(0.1250f, Color(0.8784f, 0.9529f, 0.8588f));
|
||||
AddControlPoint(0.2500f, Color(0.8000f, 0.9216f, 0.7725f));
|
||||
AddControlPoint(0.3750f, Color(0.6588f, 0.8667f, 0.7098f));
|
||||
AddControlPoint(0.5000f, Color(0.4824f, 0.8000f, 0.7686f));
|
||||
AddControlPoint(0.6250f, Color(0.3059f, 0.7020f, 0.8275f));
|
||||
AddControlPoint(0.7500f, Color(0.1686f, 0.5490f, 0.7451f));
|
||||
AddControlPoint(0.8750f, Color(0.0314f, 0.4078f, 0.6745f));
|
||||
AddControlPoint(1.0000f, Color(0.0314f, 0.2510f, 0.5059f));
|
||||
}
|
||||
else if (name == "Greens")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.9686f, 0.9882f, 0.9608f));
|
||||
AddControlPoint(0.1250f, Color(0.8980f, 0.9608f, 0.8784f));
|
||||
AddControlPoint(0.2500f, Color(0.7804f, 0.9137f, 0.7529f));
|
||||
AddControlPoint(0.3750f, Color(0.6314f, 0.8510f, 0.6078f));
|
||||
AddControlPoint(0.5000f, Color(0.4549f, 0.7686f, 0.4627f));
|
||||
AddControlPoint(0.6250f, Color(0.2549f, 0.6706f, 0.3647f));
|
||||
AddControlPoint(0.7500f, Color(0.1373f, 0.5451f, 0.2706f));
|
||||
AddControlPoint(0.8750f, Color(0.0000f, 0.4275f, 0.1725f));
|
||||
AddControlPoint(1.0000f, Color(0.0000f, 0.2667f, 0.1059f));
|
||||
}
|
||||
else if (name == "Greys")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 1.0000f, 1.0000f));
|
||||
AddControlPoint(0.1250f, Color(0.9412f, 0.9412f, 0.9412f));
|
||||
AddControlPoint(0.2500f, Color(0.8510f, 0.8510f, 0.8510f));
|
||||
AddControlPoint(0.3750f, Color(0.7412f, 0.7412f, 0.7412f));
|
||||
AddControlPoint(0.5000f, Color(0.5882f, 0.5882f, 0.5882f));
|
||||
AddControlPoint(0.6250f, Color(0.4510f, 0.4510f, 0.4510f));
|
||||
AddControlPoint(0.7500f, Color(0.3216f, 0.3216f, 0.3216f));
|
||||
AddControlPoint(0.8750f, Color(0.1451f, 0.1451f, 0.1451f));
|
||||
AddControlPoint(1.0000f, Color(0.0000f, 0.0000f, 0.0000f));
|
||||
}
|
||||
else if (name == "Oranges")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 0.9608f, 0.9216f));
|
||||
AddControlPoint(0.1250f, Color(0.9961f, 0.9020f, 0.8078f));
|
||||
AddControlPoint(0.2500f, Color(0.9922f, 0.8157f, 0.6353f));
|
||||
AddControlPoint(0.3750f, Color(0.9922f, 0.6824f, 0.4196f));
|
||||
AddControlPoint(0.5000f, Color(0.9922f, 0.5529f, 0.2353f));
|
||||
AddControlPoint(0.6250f, Color(0.9451f, 0.4118f, 0.0745f));
|
||||
AddControlPoint(0.7500f, Color(0.8510f, 0.2824f, 0.0039f));
|
||||
AddControlPoint(0.8750f, Color(0.6510f, 0.2118f, 0.0118f));
|
||||
AddControlPoint(1.0000f, Color(0.4980f, 0.1529f, 0.0157f));
|
||||
}
|
||||
else if (name == "OrRd")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 0.9686f, 0.9255f));
|
||||
AddControlPoint(0.1250f, Color(0.9961f, 0.9098f, 0.7843f));
|
||||
AddControlPoint(0.2500f, Color(0.9922f, 0.8314f, 0.6196f));
|
||||
AddControlPoint(0.3750f, Color(0.9922f, 0.7333f, 0.5176f));
|
||||
AddControlPoint(0.5000f, Color(0.9882f, 0.5529f, 0.3490f));
|
||||
AddControlPoint(0.6250f, Color(0.9373f, 0.3961f, 0.2824f));
|
||||
AddControlPoint(0.7500f, Color(0.8431f, 0.1882f, 0.1216f));
|
||||
AddControlPoint(0.8750f, Color(0.7020f, 0.0000f, 0.0000f));
|
||||
AddControlPoint(1.0000f, Color(0.4980f, 0.0000f, 0.0000f));
|
||||
}
|
||||
else if (name == "Paired")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.6510f, 0.8078f, 0.8902f));
|
||||
AddControlPoint(0.0909f, Color(0.1216f, 0.4706f, 0.7059f));
|
||||
AddControlPoint(0.1818f, Color(0.6980f, 0.8745f, 0.5412f));
|
||||
AddControlPoint(0.2727f, Color(0.2000f, 0.6275f, 0.1725f));
|
||||
AddControlPoint(0.3636f, Color(0.9843f, 0.6039f, 0.6000f));
|
||||
AddControlPoint(0.4545f, Color(0.8902f, 0.1020f, 0.1098f));
|
||||
AddControlPoint(0.5455f, Color(0.9922f, 0.7490f, 0.4353f));
|
||||
AddControlPoint(0.6364f, Color(1.0000f, 0.4980f, 0.0000f));
|
||||
AddControlPoint(0.7273f, Color(0.7922f, 0.6980f, 0.8392f));
|
||||
AddControlPoint(0.8182f, Color(0.4157f, 0.2392f, 0.6039f));
|
||||
AddControlPoint(0.9091f, Color(1.0000f, 1.0000f, 0.6000f));
|
||||
AddControlPoint(1.0000f, Color(0.6941f, 0.3490f, 0.1569f));
|
||||
}
|
||||
else if (name == "Pastel1")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.9843f, 0.7059f, 0.6824f));
|
||||
AddControlPoint(0.1250f, Color(0.7020f, 0.8039f, 0.8902f));
|
||||
AddControlPoint(0.2500f, Color(0.8000f, 0.9216f, 0.7725f));
|
||||
AddControlPoint(0.3750f, Color(0.8706f, 0.7961f, 0.8941f));
|
||||
AddControlPoint(0.5000f, Color(0.9961f, 0.8510f, 0.6510f));
|
||||
AddControlPoint(0.6250f, Color(1.0000f, 1.0000f, 0.8000f));
|
||||
AddControlPoint(0.7500f, Color(0.8980f, 0.8471f, 0.7412f));
|
||||
AddControlPoint(0.8750f, Color(0.9922f, 0.8549f, 0.9255f));
|
||||
AddControlPoint(1.0000f, Color(0.9490f, 0.9490f, 0.9490f));
|
||||
}
|
||||
else if (name == "Pastel2")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.7020f, 0.8863f, 0.8039f));
|
||||
AddControlPoint(0.1429f, Color(0.9922f, 0.8039f, 0.6745f));
|
||||
AddControlPoint(0.2857f, Color(0.7961f, 0.8353f, 0.9098f));
|
||||
AddControlPoint(0.4286f, Color(0.9569f, 0.7922f, 0.8941f));
|
||||
AddControlPoint(0.5714f, Color(0.9020f, 0.9608f, 0.7882f));
|
||||
AddControlPoint(0.7143f, Color(1.0000f, 0.9490f, 0.6824f));
|
||||
AddControlPoint(0.8571f, Color(0.9451f, 0.8863f, 0.8000f));
|
||||
AddControlPoint(1.0000f, Color(0.8000f, 0.8000f, 0.8000f));
|
||||
}
|
||||
else if (name == "PiYG")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.5569f, 0.0039f, 0.3216f));
|
||||
AddControlPoint(0.1000f, Color(0.7725f, 0.1059f, 0.4902f));
|
||||
AddControlPoint(0.2000f, Color(0.8706f, 0.4667f, 0.6824f));
|
||||
AddControlPoint(0.3000f, Color(0.9451f, 0.7137f, 0.8549f));
|
||||
AddControlPoint(0.4000f, Color(0.9922f, 0.8784f, 0.9373f));
|
||||
AddControlPoint(0.5000f, Color(0.9686f, 0.9686f, 0.9686f));
|
||||
AddControlPoint(0.6000f, Color(0.9020f, 0.9608f, 0.8157f));
|
||||
AddControlPoint(0.7000f, Color(0.7216f, 0.8824f, 0.5255f));
|
||||
AddControlPoint(0.8000f, Color(0.4980f, 0.7373f, 0.2549f));
|
||||
AddControlPoint(0.9000f, Color(0.3020f, 0.5725f, 0.1294f));
|
||||
AddControlPoint(1.0000f, Color(0.1529f, 0.3922f, 0.0980f));
|
||||
}
|
||||
else if (name == "PRGn")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.2510f, 0.0000f, 0.2941f));
|
||||
AddControlPoint(0.1000f, Color(0.4627f, 0.1647f, 0.5137f));
|
||||
AddControlPoint(0.2000f, Color(0.6000f, 0.4392f, 0.6706f));
|
||||
AddControlPoint(0.3000f, Color(0.7608f, 0.6471f, 0.8118f));
|
||||
AddControlPoint(0.4000f, Color(0.9059f, 0.8314f, 0.9098f));
|
||||
AddControlPoint(0.5000f, Color(0.9686f, 0.9686f, 0.9686f));
|
||||
AddControlPoint(0.6000f, Color(0.8510f, 0.9412f, 0.8275f));
|
||||
AddControlPoint(0.7000f, Color(0.6510f, 0.8588f, 0.6275f));
|
||||
AddControlPoint(0.8000f, Color(0.3529f, 0.6824f, 0.3804f));
|
||||
AddControlPoint(0.9000f, Color(0.1059f, 0.4706f, 0.2157f));
|
||||
AddControlPoint(1.0000f, Color(0.0000f, 0.2667f, 0.1059f));
|
||||
}
|
||||
else if (name == "PuBu")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 0.9686f, 0.9843f));
|
||||
AddControlPoint(0.1250f, Color(0.9255f, 0.9059f, 0.9490f));
|
||||
AddControlPoint(0.2500f, Color(0.8157f, 0.8196f, 0.9020f));
|
||||
AddControlPoint(0.3750f, Color(0.6510f, 0.7412f, 0.8588f));
|
||||
AddControlPoint(0.5000f, Color(0.4549f, 0.6627f, 0.8118f));
|
||||
AddControlPoint(0.6250f, Color(0.2118f, 0.5647f, 0.7529f));
|
||||
AddControlPoint(0.7500f, Color(0.0196f, 0.4392f, 0.6902f));
|
||||
AddControlPoint(0.8750f, Color(0.0157f, 0.3529f, 0.5529f));
|
||||
AddControlPoint(1.0000f, Color(0.0078f, 0.2196f, 0.3451f));
|
||||
}
|
||||
else if (name == "PuBuGn")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 0.9686f, 0.9843f));
|
||||
AddControlPoint(0.1250f, Color(0.9255f, 0.8863f, 0.9412f));
|
||||
AddControlPoint(0.2500f, Color(0.8157f, 0.8196f, 0.9020f));
|
||||
AddControlPoint(0.3750f, Color(0.6510f, 0.7412f, 0.8588f));
|
||||
AddControlPoint(0.5000f, Color(0.4039f, 0.6627f, 0.8118f));
|
||||
AddControlPoint(0.6250f, Color(0.2118f, 0.5647f, 0.7529f));
|
||||
AddControlPoint(0.7500f, Color(0.0078f, 0.5059f, 0.5412f));
|
||||
AddControlPoint(0.8750f, Color(0.0039f, 0.4235f, 0.3490f));
|
||||
AddControlPoint(1.0000f, Color(0.0039f, 0.2745f, 0.2118f));
|
||||
}
|
||||
else if (name == "PuOr")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.4980f, 0.2314f, 0.0314f));
|
||||
AddControlPoint(0.1000f, Color(0.7020f, 0.3451f, 0.0235f));
|
||||
AddControlPoint(0.2000f, Color(0.8784f, 0.5098f, 0.0784f));
|
||||
AddControlPoint(0.3000f, Color(0.9922f, 0.7216f, 0.3882f));
|
||||
AddControlPoint(0.4000f, Color(0.9961f, 0.8784f, 0.7137f));
|
||||
AddControlPoint(0.5000f, Color(0.9686f, 0.9686f, 0.9686f));
|
||||
AddControlPoint(0.6000f, Color(0.8471f, 0.8549f, 0.9216f));
|
||||
AddControlPoint(0.7000f, Color(0.6980f, 0.6706f, 0.8235f));
|
||||
AddControlPoint(0.8000f, Color(0.5020f, 0.4510f, 0.6745f));
|
||||
AddControlPoint(0.9000f, Color(0.3294f, 0.1529f, 0.5333f));
|
||||
AddControlPoint(1.0000f, Color(0.1765f, 0.0000f, 0.2941f));
|
||||
}
|
||||
else if (name == "PuRd")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.9686f, 0.9569f, 0.9765f));
|
||||
AddControlPoint(0.1250f, Color(0.9059f, 0.8824f, 0.9373f));
|
||||
AddControlPoint(0.2500f, Color(0.8314f, 0.7255f, 0.8549f));
|
||||
AddControlPoint(0.3750f, Color(0.7882f, 0.5804f, 0.7804f));
|
||||
AddControlPoint(0.5000f, Color(0.8745f, 0.3961f, 0.6902f));
|
||||
AddControlPoint(0.6250f, Color(0.9059f, 0.1608f, 0.5412f));
|
||||
AddControlPoint(0.7500f, Color(0.8078f, 0.0706f, 0.3373f));
|
||||
AddControlPoint(0.8750f, Color(0.5961f, 0.0000f, 0.2627f));
|
||||
AddControlPoint(1.0000f, Color(0.4039f, 0.0000f, 0.1216f));
|
||||
}
|
||||
else if (name == "Purples")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.9882f, 0.9843f, 0.9922f));
|
||||
AddControlPoint(0.1250f, Color(0.9373f, 0.9294f, 0.9608f));
|
||||
AddControlPoint(0.2500f, Color(0.8549f, 0.8549f, 0.9216f));
|
||||
AddControlPoint(0.3750f, Color(0.7373f, 0.7412f, 0.8627f));
|
||||
AddControlPoint(0.5000f, Color(0.6196f, 0.6039f, 0.7843f));
|
||||
AddControlPoint(0.6250f, Color(0.5020f, 0.4902f, 0.7294f));
|
||||
AddControlPoint(0.7500f, Color(0.4157f, 0.3176f, 0.6392f));
|
||||
AddControlPoint(0.8750f, Color(0.3294f, 0.1529f, 0.5608f));
|
||||
AddControlPoint(1.0000f, Color(0.2471f, 0.0000f, 0.4902f));
|
||||
}
|
||||
else if (name == "RdBu")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.4039f, 0.0000f, 0.1216f));
|
||||
AddControlPoint(0.1000f, Color(0.6980f, 0.0941f, 0.1686f));
|
||||
AddControlPoint(0.2000f, Color(0.8392f, 0.3765f, 0.3020f));
|
||||
AddControlPoint(0.3000f, Color(0.9569f, 0.6471f, 0.5098f));
|
||||
AddControlPoint(0.4000f, Color(0.9922f, 0.8588f, 0.7804f));
|
||||
AddControlPoint(0.5000f, Color(0.9686f, 0.9686f, 0.9686f));
|
||||
AddControlPoint(0.6000f, Color(0.8196f, 0.8980f, 0.9412f));
|
||||
AddControlPoint(0.7000f, Color(0.5725f, 0.7725f, 0.8706f));
|
||||
AddControlPoint(0.8000f, Color(0.2627f, 0.5765f, 0.7647f));
|
||||
AddControlPoint(0.9000f, Color(0.1294f, 0.4000f, 0.6745f));
|
||||
AddControlPoint(1.0000f, Color(0.0196f, 0.1882f, 0.3804f));
|
||||
}
|
||||
else if (name == "RdGy")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.4039f, 0.0000f, 0.1216f));
|
||||
AddControlPoint(0.1000f, Color(0.6980f, 0.0941f, 0.1686f));
|
||||
AddControlPoint(0.2000f, Color(0.8392f, 0.3765f, 0.3020f));
|
||||
AddControlPoint(0.3000f, Color(0.9569f, 0.6471f, 0.5098f));
|
||||
AddControlPoint(0.4000f, Color(0.9922f, 0.8588f, 0.7804f));
|
||||
AddControlPoint(0.5000f, Color(1.0000f, 1.0000f, 1.0000f));
|
||||
AddControlPoint(0.6000f, Color(0.8784f, 0.8784f, 0.8784f));
|
||||
AddControlPoint(0.7000f, Color(0.7294f, 0.7294f, 0.7294f));
|
||||
AddControlPoint(0.8000f, Color(0.5294f, 0.5294f, 0.5294f));
|
||||
AddControlPoint(0.9000f, Color(0.3020f, 0.3020f, 0.3020f));
|
||||
AddControlPoint(1.0000f, Color(0.1020f, 0.1020f, 0.1020f));
|
||||
}
|
||||
else if (name == "RdPu")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 0.9686f, 0.9529f));
|
||||
AddControlPoint(0.1250f, Color(0.9922f, 0.8784f, 0.8667f));
|
||||
AddControlPoint(0.2500f, Color(0.9882f, 0.7725f, 0.7529f));
|
||||
AddControlPoint(0.3750f, Color(0.9804f, 0.6235f, 0.7098f));
|
||||
AddControlPoint(0.5000f, Color(0.9686f, 0.4078f, 0.6314f));
|
||||
AddControlPoint(0.6250f, Color(0.8667f, 0.2039f, 0.5922f));
|
||||
AddControlPoint(0.7500f, Color(0.6824f, 0.0039f, 0.4941f));
|
||||
AddControlPoint(0.8750f, Color(0.4784f, 0.0039f, 0.4667f));
|
||||
AddControlPoint(1.0000f, Color(0.2863f, 0.0000f, 0.4157f));
|
||||
}
|
||||
else if (name == "RdYlBu")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.6471f, 0.0000f, 0.1490f));
|
||||
AddControlPoint(0.1000f, Color(0.8431f, 0.1882f, 0.1529f));
|
||||
AddControlPoint(0.2000f, Color(0.9569f, 0.4275f, 0.2627f));
|
||||
AddControlPoint(0.3000f, Color(0.9922f, 0.6824f, 0.3804f));
|
||||
AddControlPoint(0.4000f, Color(0.9961f, 0.8784f, 0.5647f));
|
||||
AddControlPoint(0.5000f, Color(1.0000f, 1.0000f, 0.7490f));
|
||||
AddControlPoint(0.6000f, Color(0.8784f, 0.9529f, 0.9725f));
|
||||
AddControlPoint(0.7000f, Color(0.6706f, 0.8510f, 0.9137f));
|
||||
AddControlPoint(0.8000f, Color(0.4549f, 0.6784f, 0.8196f));
|
||||
AddControlPoint(0.9000f, Color(0.2706f, 0.4588f, 0.7059f));
|
||||
AddControlPoint(1.0000f, Color(0.1922f, 0.2118f, 0.5843f));
|
||||
}
|
||||
else if (name == "RdYlGn")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.6471f, 0.0000f, 0.1490f));
|
||||
AddControlPoint(0.1000f, Color(0.8431f, 0.1882f, 0.1529f));
|
||||
AddControlPoint(0.2000f, Color(0.9569f, 0.4275f, 0.2627f));
|
||||
AddControlPoint(0.3000f, Color(0.9922f, 0.6824f, 0.3804f));
|
||||
AddControlPoint(0.4000f, Color(0.9961f, 0.8784f, 0.5451f));
|
||||
AddControlPoint(0.5000f, Color(1.0000f, 1.0000f, 0.7490f));
|
||||
AddControlPoint(0.6000f, Color(0.8510f, 0.9373f, 0.5451f));
|
||||
AddControlPoint(0.7000f, Color(0.6510f, 0.8510f, 0.4157f));
|
||||
AddControlPoint(0.8000f, Color(0.4000f, 0.7412f, 0.3882f));
|
||||
AddControlPoint(0.9000f, Color(0.1020f, 0.5961f, 0.3137f));
|
||||
AddControlPoint(1.0000f, Color(0.0000f, 0.4078f, 0.2157f));
|
||||
}
|
||||
else if (name == "Reds")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 0.9608f, 0.9412f));
|
||||
AddControlPoint(0.1250f, Color(0.9961f, 0.8784f, 0.8235f));
|
||||
AddControlPoint(0.2500f, Color(0.9882f, 0.7333f, 0.6314f));
|
||||
AddControlPoint(0.3750f, Color(0.9882f, 0.5725f, 0.4471f));
|
||||
AddControlPoint(0.5000f, Color(0.9843f, 0.4157f, 0.2902f));
|
||||
AddControlPoint(0.6250f, Color(0.9373f, 0.2314f, 0.1725f));
|
||||
AddControlPoint(0.7500f, Color(0.7961f, 0.0941f, 0.1137f));
|
||||
AddControlPoint(0.8750f, Color(0.6471f, 0.0588f, 0.0824f));
|
||||
AddControlPoint(1.0000f, Color(0.4039f, 0.0000f, 0.0510f));
|
||||
}
|
||||
else if (name == "Set1")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.8941f, 0.1020f, 0.1098f));
|
||||
AddControlPoint(0.1250f, Color(0.2157f, 0.4941f, 0.7216f));
|
||||
AddControlPoint(0.2500f, Color(0.3020f, 0.6863f, 0.2902f));
|
||||
AddControlPoint(0.3750f, Color(0.5961f, 0.3059f, 0.6392f));
|
||||
AddControlPoint(0.5000f, Color(1.0000f, 0.4980f, 0.0000f));
|
||||
AddControlPoint(0.6250f, Color(1.0000f, 1.0000f, 0.2000f));
|
||||
AddControlPoint(0.7500f, Color(0.6510f, 0.3373f, 0.1569f));
|
||||
AddControlPoint(0.8750f, Color(0.9686f, 0.5059f, 0.7490f));
|
||||
AddControlPoint(1.0000f, Color(0.6000f, 0.6000f, 0.6000f));
|
||||
}
|
||||
else if (name == "Set2")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.4000f, 0.7608f, 0.6471f));
|
||||
AddControlPoint(0.1429f, Color(0.9882f, 0.5529f, 0.3843f));
|
||||
AddControlPoint(0.2857f, Color(0.5529f, 0.6275f, 0.7961f));
|
||||
AddControlPoint(0.4286f, Color(0.9059f, 0.5412f, 0.7647f));
|
||||
AddControlPoint(0.5714f, Color(0.6510f, 0.8471f, 0.3294f));
|
||||
AddControlPoint(0.7143f, Color(1.0000f, 0.8510f, 0.1843f));
|
||||
AddControlPoint(0.8571f, Color(0.8980f, 0.7686f, 0.5804f));
|
||||
AddControlPoint(1.0000f, Color(0.7020f, 0.7020f, 0.7020f));
|
||||
}
|
||||
else if (name == "Set3")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.5529f, 0.8275f, 0.7804f));
|
||||
AddControlPoint(0.0909f, Color(1.0000f, 1.0000f, 0.7020f));
|
||||
AddControlPoint(0.1818f, Color(0.7451f, 0.7294f, 0.8549f));
|
||||
AddControlPoint(0.2727f, Color(0.9843f, 0.5020f, 0.4471f));
|
||||
AddControlPoint(0.3636f, Color(0.5020f, 0.6941f, 0.8275f));
|
||||
AddControlPoint(0.4545f, Color(0.9922f, 0.7059f, 0.3843f));
|
||||
AddControlPoint(0.5455f, Color(0.7020f, 0.8706f, 0.4118f));
|
||||
AddControlPoint(0.6364f, Color(0.9882f, 0.8039f, 0.8980f));
|
||||
AddControlPoint(0.7273f, Color(0.8510f, 0.8510f, 0.8510f));
|
||||
AddControlPoint(0.8182f, Color(0.7373f, 0.5020f, 0.7412f));
|
||||
AddControlPoint(0.9091f, Color(0.8000f, 0.9216f, 0.7725f));
|
||||
AddControlPoint(1.0000f, Color(1.0000f, 0.9294f, 0.4353f));
|
||||
}
|
||||
else if (name == "Spectral")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(0.6196f, 0.0039f, 0.2588f));
|
||||
AddControlPoint(0.1000f, Color(0.8353f, 0.2431f, 0.3098f));
|
||||
AddControlPoint(0.2000f, Color(0.9569f, 0.4275f, 0.2627f));
|
||||
AddControlPoint(0.3000f, Color(0.9922f, 0.6824f, 0.3804f));
|
||||
AddControlPoint(0.4000f, Color(0.9961f, 0.8784f, 0.5451f));
|
||||
AddControlPoint(0.5000f, Color(1.0000f, 1.0000f, 0.7490f));
|
||||
AddControlPoint(0.6000f, Color(0.9020f, 0.9608f, 0.5961f));
|
||||
AddControlPoint(0.7000f, Color(0.6706f, 0.8667f, 0.6431f));
|
||||
AddControlPoint(0.8000f, Color(0.4000f, 0.7608f, 0.6471f));
|
||||
AddControlPoint(0.9000f, Color(0.1961f, 0.5333f, 0.7412f));
|
||||
AddControlPoint(1.0000f, Color(0.3686f, 0.3098f, 0.6353f));
|
||||
}
|
||||
else if (name == "YlGnBu")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 1.0000f, 0.8510f));
|
||||
AddControlPoint(0.1250f, Color(0.9294f, 0.9725f, 0.6941f));
|
||||
AddControlPoint(0.2500f, Color(0.7804f, 0.9137f, 0.7059f));
|
||||
AddControlPoint(0.3750f, Color(0.4980f, 0.8039f, 0.7333f));
|
||||
AddControlPoint(0.5000f, Color(0.2549f, 0.7137f, 0.7686f));
|
||||
AddControlPoint(0.6250f, Color(0.1137f, 0.5686f, 0.7529f));
|
||||
AddControlPoint(0.7500f, Color(0.1333f, 0.3686f, 0.6588f));
|
||||
AddControlPoint(0.8750f, Color(0.1451f, 0.2039f, 0.5804f));
|
||||
AddControlPoint(1.0000f, Color(0.0314f, 0.1137f, 0.3451f));
|
||||
}
|
||||
else if (name == "YlGn")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 1.0000f, 0.8980f));
|
||||
AddControlPoint(0.1250f, Color(0.9686f, 0.9882f, 0.7255f));
|
||||
AddControlPoint(0.2500f, Color(0.8510f, 0.9412f, 0.6392f));
|
||||
AddControlPoint(0.3750f, Color(0.6784f, 0.8667f, 0.5569f));
|
||||
AddControlPoint(0.5000f, Color(0.4706f, 0.7765f, 0.4745f));
|
||||
AddControlPoint(0.6250f, Color(0.2549f, 0.6706f, 0.3647f));
|
||||
AddControlPoint(0.7500f, Color(0.1373f, 0.5176f, 0.2627f));
|
||||
AddControlPoint(0.8750f, Color(0.0000f, 0.4078f, 0.2157f));
|
||||
AddControlPoint(1.0000f, Color(0.0000f, 0.2706f, 0.1608f));
|
||||
}
|
||||
else if (name == "YlOrBr")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 1.0000f, 0.8980f));
|
||||
AddControlPoint(0.1250f, Color(1.0000f, 0.9686f, 0.7373f));
|
||||
AddControlPoint(0.2500f, Color(0.9961f, 0.8902f, 0.5686f));
|
||||
AddControlPoint(0.3750f, Color(0.9961f, 0.7686f, 0.3098f));
|
||||
AddControlPoint(0.5000f, Color(0.9961f, 0.6000f, 0.1608f));
|
||||
AddControlPoint(0.6250f, Color(0.9255f, 0.4392f, 0.0784f));
|
||||
AddControlPoint(0.7500f, Color(0.8000f, 0.2980f, 0.0078f));
|
||||
AddControlPoint(0.8750f, Color(0.6000f, 0.2039f, 0.0157f));
|
||||
AddControlPoint(1.0000f, Color(0.4000f, 0.1451f, 0.0235f));
|
||||
}
|
||||
else if (name == "YlOrRd")
|
||||
{
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 1.0000f, 0.8000f));
|
||||
AddControlPoint(0.1250f, Color(1.0000f, 0.9294f, 0.6275f));
|
||||
AddControlPoint(0.2500f, Color(0.9961f, 0.8510f, 0.4627f));
|
||||
AddControlPoint(0.3750f, Color(0.9961f, 0.6980f, 0.2980f));
|
||||
AddControlPoint(0.5000f, Color(0.9922f, 0.5529f, 0.2353f));
|
||||
AddControlPoint(0.6250f, Color(0.9882f, 0.3059f, 0.1647f));
|
||||
AddControlPoint(0.7500f, Color(0.8902f, 0.1020f, 0.1098f));
|
||||
AddControlPoint(0.8750f, Color(0.7412f, 0.0000f, 0.1490f));
|
||||
AddControlPoint(1.0000f, Color(0.5020f, 0.0000f, 0.1490f));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Unknown Color Table"<<std::endl;
|
||||
AddControlPoint(0.0000f, Color(1.0000f, 1.0000f, 0.8000f));
|
||||
AddControlPoint(0.1250f, Color(1.0000f, 0.9294f, 0.6275f));
|
||||
AddControlPoint(0.2500f, Color(0.9961f, 0.8510f, 0.4627f));
|
||||
AddControlPoint(0.3750f, Color(0.9961f, 0.6980f, 0.2980f));
|
||||
AddControlPoint(0.5000f, Color(0.9922f, 0.5529f, 0.2353f));
|
||||
AddControlPoint(0.6250f, Color(0.9882f, 0.3059f, 0.1647f));
|
||||
AddControlPoint(0.7500f, Color(0.8902f, 0.1020f, 0.1098f));
|
||||
AddControlPoint(0.8750f, Color(0.7412f, 0.0000f, 0.1490f));
|
||||
AddControlPoint(1.0000f, Color(0.5020f, 0.0000f, 0.1490f));
|
||||
}
|
||||
uniquename = std::string("00") + name;
|
||||
if (smooth)
|
||||
uniquename[0] = '1';
|
||||
}
|
||||
};
|
||||
}}//namespace vtkm::rendering
|
||||
#endif //vtk_m_rendering_ColorTable_h
|
||||
|
||||
|
354
vtkm/rendering/Makefile
Normal file
354
vtkm/rendering/Makefile
Normal file
@ -0,0 +1,354 @@
|
||||
# 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
|
||||
|
752
vtkm/rendering/Rasterizer.h
Normal file
752
vtkm/rendering/Rasterizer.h
Normal file
@ -0,0 +1,752 @@
|
||||
//============================================================================
|
||||
// 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_Rasterizer_h
|
||||
#define vtk_m_rendering_Rasterizer_h
|
||||
#include <stdio.h>
|
||||
#include <vtkm/exec/DepthBufferArray.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
#include <vtkm/cont/Timer.h>
|
||||
#include <vtkm/exec/ExecutionWholeArray.h>
|
||||
#include <vtkm/rendering/View.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/Matrix.h>
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
//Unary predicate for StreamCompact
|
||||
struct IsVisible
|
||||
{
|
||||
VTKM_EXEC_CONT_EXPORT bool operator()(const vtkm::Id &x) const
|
||||
{
|
||||
return (x >= 0);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class MemSet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
T Value;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
MemSet(T value)
|
||||
: Value(value)
|
||||
{
|
||||
std::cout<<"Memset value "<<value<<"\n";
|
||||
}
|
||||
typedef void ControlSignature(FieldOut<>);
|
||||
typedef void ExecutionSignature(_1);
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(T &outValue) const
|
||||
{
|
||||
outValue = Value;
|
||||
}
|
||||
}; //class MemSet
|
||||
|
||||
// void WriteColorBuffer(vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > &rgba,
|
||||
// vtkm::Int32 width,
|
||||
// vtkm::Int32 height)
|
||||
// {
|
||||
// FILE *pnm;
|
||||
// pnm = fopen("Color.pnm", "w");
|
||||
// if( !pnm ) std::cout<<"Could not open pnm file\n";
|
||||
// fprintf(pnm, "P%c %d %d 255\n",'6', width, height);
|
||||
// vtkm::Int32 size = height * width;
|
||||
// unsigned char pixel[3];
|
||||
// for(int i = 0; i < size; i++)
|
||||
// {
|
||||
// vtkm::Vec<vtkm::Float32,4> color = rgba.GetPortalControl().Get(i);
|
||||
// pixel[0] = (unsigned char) (color[0]*255.f);
|
||||
// pixel[1] = (unsigned char) (color[1]*255.f);
|
||||
// pixel[2] = (unsigned char) (color[2]*255.f);
|
||||
// fwrite(pixel, sizeof(unsigned char), 3, pnm);
|
||||
// }
|
||||
// fclose(pnm);
|
||||
// }
|
||||
|
||||
typedef union
|
||||
{
|
||||
vtkm::Float32 floats[2];
|
||||
vtkm::UInt32 ints[2];
|
||||
vtkm::UInt64 ulong;
|
||||
} Unpacker;
|
||||
class writer {
|
||||
public:
|
||||
static void WriteDepthBufferUnPack(vtkm::cont::ArrayHandle<vtkm::UInt64> &rgba,
|
||||
vtkm::Int32 width,
|
||||
vtkm::Int32 height)
|
||||
{
|
||||
FILE *pnm;
|
||||
pnm = fopen("DepthPacked.pnm", "w");
|
||||
if( !pnm ) std::cout<<"Could not open pnm file\n";
|
||||
fprintf(pnm, "P%c %d %d 255\n",'6', width, height);
|
||||
vtkm::Int32 size = height * width;
|
||||
unsigned char pixel[3];
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
Unpacker packed;
|
||||
packed.ulong = rgba.GetPortalControl().Get(i);
|
||||
float depth = packed.floats[1] * 0.5f + 0.5f;
|
||||
pixel[0] = (unsigned char)(depth * 255.f);
|
||||
pixel[1] = (unsigned char)(depth * 255.f);
|
||||
pixel[2] = (unsigned char)(depth * 255.f);
|
||||
fwrite(pixel, sizeof(unsigned char), 3, pnm);
|
||||
}
|
||||
fclose(pnm);
|
||||
}
|
||||
|
||||
static void RasterWriteColorBufferUnPack(vtkm::cont::ArrayHandle<vtkm::UInt64> &rgba,
|
||||
vtkm::Int32 width,
|
||||
vtkm::Int32 height)
|
||||
{
|
||||
FILE *pnm;
|
||||
pnm = fopen("Packed.pnm", "w");
|
||||
if( !pnm ) std::cout<<"Could not open pnm file\n";
|
||||
fprintf(pnm, "P%c %d %d 255\n",'6', width, height);
|
||||
vtkm::Int32 size = height * width;
|
||||
unsigned char pixel[3];
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
Unpacker packed;
|
||||
packed.ulong = rgba.GetPortalControl().Get(i);
|
||||
//std::cout<<"Color "<<((packed.ints[0] & 0x00FF0000)>>16)<<" "<<((packed.ints[0] & 0x0000FF00)>>8)<<" "<<(packed.ints[0] & 0x000000FF)<<std::endl;
|
||||
pixel[0] = (unsigned char)((packed.ints[0] & 0x00FF0000)>>16);
|
||||
pixel[1] = (unsigned char)((packed.ints[0] & 0x0000FF00)>>8);
|
||||
pixel[2] = (unsigned char)(packed.ints[0] & 0x000000FF);
|
||||
fwrite(pixel, sizeof(unsigned char), 3, pnm);
|
||||
}
|
||||
fclose(pnm);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename DeviceAdapter>
|
||||
class Rasterizer
|
||||
{
|
||||
private:
|
||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > FrameBufferHandle;
|
||||
typedef typename FrameBufferHandle::ExecutionTypes<DeviceAdapter>::Portal FrameBufferPortal;
|
||||
|
||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > ColorArrayHandle;
|
||||
typedef typename ColorArrayHandle::ExecutionTypes<DeviceAdapter>::PortalConst ColorArrayPortal;
|
||||
|
||||
typedef typename vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > Points32Handle;
|
||||
typedef typename Points32Handle::ExecutionTypes<DeviceAdapter>::PortalConst Points32ConstPortal;
|
||||
|
||||
typedef typename vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,3> > Points64Handle;
|
||||
typedef typename Points64Handle::ExecutionTypes<DeviceAdapter>::PortalConst Points64ConstPortal;
|
||||
|
||||
typedef typename vtkm::cont::ArrayHandleUniformPointCoordinates UniformArrayHandle;
|
||||
typedef typename UniformArrayHandle::ExecutionTypes<DeviceAdapter>::PortalConst UniformConstPortal;
|
||||
|
||||
public:
|
||||
|
||||
template<typename HandleType, typename PortalType>
|
||||
class RasterUniform : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
private:
|
||||
typedef typename vtkm::cont::ArrayHandleUniformPointCoordinates UniformArrayHandle;
|
||||
typedef typename UniformArrayHandle::ExecutionTypes<DeviceAdapter>::PortalConst UniformConstPortal;
|
||||
PortalType Points;
|
||||
FrameBufferPortal FrameBuffer;
|
||||
vtkm::Matrix<vtkm::Float32,4,4> ViewProjectionMat;
|
||||
vtkm::Float32 ScreenWidth;
|
||||
vtkm::Float32 ScreenHeight;
|
||||
ColorArrayPortal ColorMap;
|
||||
vtkm::Float32 ColorMapSize;
|
||||
vtkm::Float32 InverseDeltaScalar;
|
||||
vtkm::Float32 MinScalar;
|
||||
vtkm::exec::DepthBuffer<DeviceAdapter> AArray;
|
||||
vtkm::Vec<vtkm::Float32,3> CameraPosition;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
RasterUniform(HandleType &points,
|
||||
FrameBufferHandle &frameBuffer,
|
||||
vtkm::Matrix<vtkm::Float32,4,4> viewProjectionMat,
|
||||
vtkm::Int32 screenWidth,
|
||||
vtkm::Int32 screenHeight,
|
||||
ColorArrayHandle colorMap,
|
||||
const vtkm::Float64 scalarBounds[2],
|
||||
const vtkm::exec::DepthBuffer<DeviceAdapter> &aArray,
|
||||
const vtkm::Vec<vtkm::Float32,3> &cameraPosition)
|
||||
: Points(points.PrepareForInput( DeviceAdapter() )),
|
||||
ViewProjectionMat(viewProjectionMat),
|
||||
ColorMap( colorMap.PrepareForInput( DeviceAdapter() )),
|
||||
AArray(aArray),
|
||||
CameraPosition(cameraPosition)
|
||||
{
|
||||
this->FrameBuffer
|
||||
= frameBuffer.PrepareForOutput(frameBuffer.GetNumberOfValues(), DeviceAdapter() );
|
||||
vtkm::rendering::View3D::PrintMatrix(ViewProjectionMat);
|
||||
ScreenWidth = vtkm::Float32(screenWidth);
|
||||
ScreenHeight = vtkm::Float32(screenHeight);
|
||||
InverseDeltaScalar = 1.f / (vtkm::Float32(scalarBounds[1]-scalarBounds[0]));
|
||||
MinScalar = vtkm::Float32(scalarBounds[0]);
|
||||
ColorMapSize = vtkm::Float32(colorMap.GetNumberOfValues()-1);
|
||||
std::cout<<"Raster uniform constructor\n";
|
||||
TransformPoint(CameraPosition);
|
||||
}
|
||||
typedef void ControlSignature(FieldIn<IdType>,
|
||||
ExecObject,
|
||||
ExecObject);
|
||||
typedef void ExecutionSignature(_1,_2,_3);
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
void TransformPoint(vtkm::Vec<Float32,3> &point) const
|
||||
{
|
||||
vtkm::Vec<Float32,4> temp;
|
||||
temp[0] = point[0];
|
||||
temp[1] = point[1];
|
||||
temp[2] = point[2];
|
||||
temp[3] = 1.f;
|
||||
temp = vtkm::MatrixMultiply(ViewProjectionMat,temp);
|
||||
// perform the perspective divide
|
||||
for (vtkm::Int32 i = 0; i < 3; ++i)
|
||||
{
|
||||
point[i] = temp[i] / temp[3];
|
||||
}
|
||||
}
|
||||
VTKM_EXEC_EXPORT
|
||||
void ColorPacker(const vtkm::Float32 &r,
|
||||
const vtkm::Float32 &g,
|
||||
const vtkm::Float32 &b,
|
||||
vtkm::UInt32 &packedValue) const
|
||||
{
|
||||
packedValue = 0;
|
||||
vtkm::UInt32 temp = vtkm::UInt32(r*255.f);
|
||||
temp = temp << 16;
|
||||
packedValue = temp | packedValue;
|
||||
temp = vtkm::UInt32(g*255.f);
|
||||
temp = temp << 8;
|
||||
packedValue = temp | packedValue;
|
||||
temp = vtkm::UInt32(b*255.f);
|
||||
packedValue = temp | packedValue;
|
||||
}
|
||||
|
||||
template<typename IndicesStorageType,
|
||||
typename ScalarType, typename ScalarStorageTag>
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const vtkm::Id &triangleId,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Vec<vtkm::Id,4>, IndicesStorageType > &indices,
|
||||
vtkm::exec::ExecutionWholeArrayConst<ScalarType, ScalarStorageTag> &scalars) const
|
||||
{
|
||||
vtkm::Vec<vtkm::Id,4> traingleIndices = indices.Get(triangleId);
|
||||
vtkm::Vec<Float32,3> a = Points.Get(traingleIndices[1]);
|
||||
vtkm::Vec<Float32,3> b = Points.Get(traingleIndices[2]);
|
||||
vtkm::Vec<Float32,3> c = Points.Get(traingleIndices[3]);
|
||||
//vtkm::Vec<Float32,4> aColor = ColorMap.Get(traingleIndices[1]);
|
||||
//vtkm::Vec<Float32,4> bColor = ColorMap.Get(traingleIndices[2]);
|
||||
//vtkm::Vec<Float32,4> cColor = ColorMap.Get(traingleIndices[3]);
|
||||
vtkm::Float32 aScalar= scalars.Get(traingleIndices[1]);
|
||||
vtkm::Float32 bScalar= scalars.Get(traingleIndices[2]);
|
||||
vtkm::Float32 cScalar= scalars.Get(traingleIndices[3]);
|
||||
//std::cout<<"Triange Before"<<a<<b<<c<<std::endl;
|
||||
//std::cout<<"Triange Scalars"<<aScalar<<" "<<bScalar<<" "<<cScalar<<std::endl;
|
||||
TransformPoint(a);
|
||||
TransformPoint(b);
|
||||
TransformPoint(c);
|
||||
vtkm::Vec<vtkm::Int32,2> ai,bi,ci;
|
||||
ai[0] = vtkm::Int32((a[0] *.5f + .5f) * ScreenWidth);
|
||||
bi[0] = vtkm::Int32((b[0] *.5f + .5f) * ScreenWidth);
|
||||
ci[0] = vtkm::Int32((c[0] *.5f + .5f) * ScreenWidth);
|
||||
|
||||
ai[1] = vtkm::Int32((a[1] *.5f + .5f) * ScreenHeight);
|
||||
bi[1] = vtkm::Int32((b[1] *.5f + .5f) * ScreenHeight);
|
||||
ci[1] = vtkm::Int32((c[1] *.5f + .5f) * ScreenHeight);
|
||||
|
||||
vtkm::Int32 triangleArea =((bi[0]-ai[0])*(ci[1]-ai[1]))-((bi[1]-ai[1])*(ci[0]-ai[0]));
|
||||
vtkm::Int32 ymin = vtkm::Min(ai[1],vtkm::Min(bi[1],ci[1]));
|
||||
vtkm::Int32 xmin = vtkm::Min(ai[0],vtkm::Min(bi[0],ci[0]));
|
||||
vtkm::Int32 ymax = vtkm::Max(ai[1],vtkm::Max(bi[1],ci[1]));
|
||||
vtkm::Int32 xmax = vtkm::Max(ai[0],vtkm::Max(bi[0],ci[0]));
|
||||
vtkm::Float32 zmax = vtkm::Max(a[2],vtkm::Max(b[2],c[2]));
|
||||
vtkm::Float32 zmin = vtkm::Min(a[2],vtkm::Min(b[2],c[2]));
|
||||
ymin = vtkm::Max(0,ymin);
|
||||
xmin = vtkm::Max(0,xmin);
|
||||
ymax = vtkm::Min(vtkm::Int32(ScreenHeight)-1,ymax);
|
||||
xmax = vtkm::Min(vtkm::Int32(ScreenWidth)-1,xmax);
|
||||
vtkm::Float32 invTriangleArea = 1.f / vtkm::Float32(triangleArea); //vtkm::Magnitude(vtkm::Cross(bi-ai, ci-ai));
|
||||
bScalar = (bScalar - aScalar) * invTriangleArea;
|
||||
cScalar = (cScalar - aScalar) * invTriangleArea;
|
||||
vtkm::Float32 z0 = a[2];
|
||||
vtkm::Float32 z1 = (b[2] - a[2]) * invTriangleArea;
|
||||
vtkm::Float32 z2 = (c[2] - a[2]) * invTriangleArea;
|
||||
|
||||
vtkm::Vec<vtkm::Float32,3> e1,e2, normal;
|
||||
e1 = b - a;
|
||||
e2 = c - a;
|
||||
normal = vtkm::Cross(e1,e2);
|
||||
if(invTriangleArea > 0) normal = -normal;
|
||||
vtkm::Normalize(normal);
|
||||
vtkm::Vec<vtkm::Float32,3> cA = CameraPosition - a;
|
||||
vtkm::Normalize(cA);
|
||||
vtkm::Vec<vtkm::Float32,3> cB = CameraPosition - b;
|
||||
vtkm::Normalize(cB);
|
||||
vtkm::Vec<vtkm::Float32,3> cC = CameraPosition - c;
|
||||
vtkm::Normalize(cC);
|
||||
|
||||
vtkm::Float32 aDot = vtkm::dot(normal, cA);
|
||||
vtkm::Float32 bDot = vtkm::dot(normal, cB);
|
||||
vtkm::Float32 cDot = vtkm::dot(normal, cC);
|
||||
aDot = vtkm::Max(0.f, aDot);
|
||||
bDot = vtkm::Max(0.f, bDot);
|
||||
cDot = vtkm::Max(0.f, cDot);
|
||||
|
||||
// std::cout<<normal<<CameraPosition<<std::endl;
|
||||
// std::cout<<cA<<cB<<cC<<std::endl;
|
||||
// std::cout<<"sDot "<<aDot<<" "<<bDot<<" "<<cDot<<std::endl;
|
||||
|
||||
|
||||
|
||||
bDot = (bDot - aDot) * invTriangleArea;
|
||||
cDot = (cDot - aDot) * invTriangleArea;
|
||||
|
||||
invTriangleArea = vtkm::Abs(invTriangleArea);
|
||||
//std::cout<<"inv area "<<invTriangleArea<<" "<<std::endl;
|
||||
//std::cout<<"Triange After"<<ai<<bi<<ci<<std::endl;
|
||||
|
||||
|
||||
//It would be nice to know if these were ccw or cw
|
||||
|
||||
//find the line coefficients
|
||||
vtkm::Vec<vtkm::Int32,2> ab0,ab1,ab2;
|
||||
ab0[0] = (bi[0] - ai[0]); //change for pixel to right
|
||||
ab0[1] = (ai[1] - bi[1]); //change for pixel up
|
||||
ab1[0] = (ci[0] - bi[0]);
|
||||
ab1[1] = (bi[1] - ci[1]);
|
||||
ab2[0] = (ai[0] - ci[0]);
|
||||
ab2[1] = (ci[1] - ai[1]);
|
||||
//int A01 = v0.y - v1.y, B01 = v1.x - v0.x;
|
||||
//int A12 = v1.y - v2.y, B12 = v2.x - v1.x;
|
||||
//int A20 = v2.y - v0.y, B20 = v0.x - v2.x;
|
||||
|
||||
vtkm::Int32 w0Start = ab1[0]*(ymin-bi[1]) + ab1[1]*(xmin-bi[0]); // orient2d(v1, v2, p);
|
||||
vtkm::Int32 w1Start = ab2[0]*(ymin-ci[1]) + ab2[1]*(xmin-ci[0]);//orient2d(v2, v0, p); //(b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x)
|
||||
vtkm::Int32 w2Start = ab0[0]*(ymin-ai[1]) + ab0[1]*(xmin-ai[0]);// orient2d(v0, v1, p); //(b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x)
|
||||
//std::cout<<"Triangle BBOX ["<<xmin<<","<<ymin<<"]["<<xmax<<","<<ymax<<"]"<<w0Start<<" "<<w1Start<<" "<<w2Start<<"\n";
|
||||
// Rasterize
|
||||
for (vtkm::Int32 y = ymin; y <= ymax; y++)
|
||||
{
|
||||
// Barycentric coordinates at start of row
|
||||
vtkm::Int32 w0 = w0Start;
|
||||
vtkm::Int32 w1 = w1Start;
|
||||
vtkm::Int32 w2 = w2Start;
|
||||
|
||||
for(vtkm::Int32 x = xmin; x <= xmax; x++)
|
||||
{
|
||||
// If p is on or inside all edges, render pixel.
|
||||
//if ((sign(w0) == sign(w1))&&(sign(w1) == sign(w2)))
|
||||
if ((w0 >= 0 && w1 >=0 && w2>=0) || (w0 <= 0 && w1<= 0 && w2 <= 0))
|
||||
{
|
||||
vtkm::Float32 lerpedScalar = vtkm::Abs(aScalar +
|
||||
bScalar * vtkm::Float32(w1) +
|
||||
cScalar * vtkm::Float32(w2));
|
||||
vtkm::Float32 depth = vtkm::Abs(z0 +
|
||||
z1 * vtkm::Float32(w1) +
|
||||
z2 * vtkm::Float32(w2));
|
||||
vtkm::Float32 lerpedDot = vtkm::Abs(aDot +
|
||||
bDot * vtkm::Float32(w1) +
|
||||
cDot * vtkm::Float32(w2));
|
||||
lerpedScalar = (lerpedScalar - MinScalar) * InverseDeltaScalar;
|
||||
vtkm::Int32 colorIdx = vtkm::Int32(lerpedScalar * ColorMapSize);
|
||||
|
||||
// if(colorIdx <0 || colorIdx > ColorMapSize) std::cout<<"COOOOOOLLLLOOROROROROROOROR "<<colorIdx<<" "<<lerpedScalar<<" = "<<vtkm::Abs(aScalar +
|
||||
// bScalar * vtkm::Float32(w1) +
|
||||
// cScalar * vtkm::Float32(w2))<<" - "<<MinScalar<<" / "<<InverseDeltaScalar<<" "<<aScalar<<" "<<bScalar<<" "<<cScalar<<" "<<traingleIndices<<" "<<invTriangleArea<<std::endl;
|
||||
vtkm::Vec<vtkm::Float32,4> color = lerpedDot * ColorMap.Get(colorIdx);
|
||||
//vtkm::Vec<vtkm::Float32,4> color = ColorMap.Get(colorIdx);
|
||||
//std::cout<<"x "<<x<<" y "<<y<<"["<<lerpedScalar<<" "<<depth<<" "<<colorIdx<<" "<<color<<std::endl;
|
||||
vtkm::UInt32 packedColor;
|
||||
ColorPacker(color[0],color[1],color[2], packedColor);
|
||||
AArray.DepthCheck(y*vtkm::Int32(ScreenWidth) +x,depth,packedColor );
|
||||
//FrameBuffer.Set(y*ScreenWidth +x, ColorMap.Get(colorIdx));
|
||||
}
|
||||
|
||||
// One step to the right
|
||||
w0 += ab1[1];
|
||||
w1 += ab2[1];
|
||||
w2 += ab0[1];
|
||||
}
|
||||
|
||||
// One row step
|
||||
w0Start += ab1[0];
|
||||
w1Start += ab2[0];
|
||||
w2Start += ab0[0];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}; //class Raster Uniform
|
||||
|
||||
template<typename HandleType, typename PortalType>
|
||||
class IsVisibleWorklet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
vtkm::Float32 ScreenWidth;
|
||||
vtkm::Float32 ScreenHeight;
|
||||
vtkm::Matrix<vtkm::Float32,4,4> ViewProjectionMat;
|
||||
PortalType Points;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
IsVisibleWorklet(vtkm::Int32 &screenWidth,
|
||||
vtkm::Int32 &screenHeight,
|
||||
vtkm::Matrix<vtkm::Float32,4,4> &viewProjectionMat,
|
||||
HandleType &points)
|
||||
: ScreenWidth(vtkm::Float32(screenWidth)),
|
||||
ScreenHeight(vtkm::Float32(screenHeight)),
|
||||
ViewProjectionMat(viewProjectionMat),
|
||||
Points( points.PrepareForInput( DeviceAdapter() ))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
void TransformPoint(vtkm::Vec<Float32,3> &point) const
|
||||
{
|
||||
vtkm::Vec<Float32,4> temp;
|
||||
temp[0] = point[0];
|
||||
temp[1] = point[1];
|
||||
temp[2] = point[2];
|
||||
temp[3] = 1.f;
|
||||
temp = vtkm::MatrixMultiply(ViewProjectionMat,temp);
|
||||
// perform the perspective divide
|
||||
for (vtkm::Int32 i = 0; i < 3; ++i)
|
||||
{
|
||||
point[i] = temp[i] / temp[3];
|
||||
}
|
||||
}
|
||||
|
||||
typedef void ControlSignature(FieldIn<>,
|
||||
FieldOut<>);
|
||||
typedef void ExecutionSignature(_1,
|
||||
_2,
|
||||
WorkIndex);
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const vtkm::Vec<vtkm::Id,4> &traingleIndices,
|
||||
vtkm::Id &outputIndex,
|
||||
vtkm::Id &inputIndex) const
|
||||
{
|
||||
vtkm::Vec<Float32,3> a = Points.Get(traingleIndices[1]);
|
||||
vtkm::Vec<Float32,3> b = Points.Get(traingleIndices[2]);
|
||||
vtkm::Vec<Float32,3> c = Points.Get(traingleIndices[3]);
|
||||
|
||||
TransformPoint(a);
|
||||
TransformPoint(b);
|
||||
TransformPoint(c);
|
||||
vtkm::Float32 xmin = vtkm::Min(a[0],b[0]);
|
||||
vtkm::Float32 xmax = vtkm::Max(a[0],b[0]);
|
||||
vtkm::Float32 ymin = vtkm::Min(a[1],b[1]);
|
||||
vtkm::Float32 ymax = vtkm::Max(a[1],b[1]);
|
||||
vtkm::Float32 zmin = vtkm::Min(a[2],b[2]);
|
||||
vtkm::Float32 zmax = vtkm::Max(a[2],b[2]);
|
||||
|
||||
xmin = vtkm::Min(xmin,c[0]);
|
||||
xmin = vtkm::Max(xmax,c[0]);
|
||||
ymin = vtkm::Min(ymin,c[1]);
|
||||
ymin = vtkm::Max(ymax,c[1]);
|
||||
zmin = vtkm::Min(zmin,c[2]);
|
||||
zmin = vtkm::Max(zmax,c[2]);
|
||||
|
||||
vtkm::Vec<vtkm::Int32,2> ai,bi,ci;
|
||||
ai[0] = vtkm::Int32((a[0] *.5f + .5f) * ScreenWidth);
|
||||
bi[0] = vtkm::Int32((b[0] *.5f + .5f) * ScreenWidth);
|
||||
ci[0] = vtkm::Int32((c[0] *.5f + .5f) * ScreenWidth);
|
||||
|
||||
ai[1] = vtkm::Int32((a[1] *.5f + .5f) * ScreenHeight);
|
||||
bi[1] = vtkm::Int32((b[1] *.5f + .5f) * ScreenHeight);
|
||||
ci[1] = vtkm::Int32((c[1] *.5f + .5f) * ScreenHeight);
|
||||
|
||||
vtkm::Int32 triangleArea =((bi[0]-ai[0])*(ci[1]-ai[1]))-((bi[1]-ai[1])*(ci[0]-ai[0]));
|
||||
|
||||
bool visible = true;
|
||||
//valid range is -1 to 1
|
||||
//if(triangleArea != 0) std::cout<<" A "<<triangleAre
|
||||
if(triangleArea == 0) visible = false;
|
||||
if(xmin > 1) visible = false;
|
||||
if(xmax < -1) visible = false;
|
||||
if(ymin > 1) visible = false;
|
||||
if(ymax < -1) visible = false;
|
||||
if(zmin > 1) visible = false;
|
||||
if(zmax < -1) visible = false;
|
||||
//std::cout<<"Area "<<triangleArea<<"ssp "<<xmin<<","<<ymin<<","<<zmin<<" "<<xmax<<","<<ymax<<","<<zmax<<" | "<<traingleIndices<<std::endl;
|
||||
//else
|
||||
// if(visible) std::cout<<"Visable\n";
|
||||
outputIndex = visible ? inputIndex : -1;
|
||||
}
|
||||
}; //class TransformPointsExplicit
|
||||
|
||||
vtkm::rendering::View3D RasterView;
|
||||
vtkm::Matrix<vtkm::Float32,4,4> ViewMatrix;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > ColorMap;
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
Rasterizer(){}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::rendering::View3D& GetView()
|
||||
{
|
||||
return RasterView;
|
||||
}
|
||||
VTKM_CONT_EXPORT
|
||||
void CullNonVisible(const vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id, 4> > &indices,
|
||||
vtkm::cont::DynamicArrayHandleCoordinateSystem &coordsHandle,
|
||||
vtkm::cont::ArrayHandle< vtkm::Id> &visibleIndexs)
|
||||
{
|
||||
vtkm::cont::ArrayHandle< vtkm::Id> indexes;
|
||||
indexes.Allocate(indices.GetNumberOfValues()); //TODO make this a member so there is no realloc
|
||||
if(coordsHandle.IsArrayHandleType(vtkm::cont::ArrayHandleUniformPointCoordinates()))
|
||||
{
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates vertices;
|
||||
coordsHandle.CastToArrayHandle(vertices);
|
||||
vtkm::worklet::DispatcherMapField< IsVisibleWorklet<UniformArrayHandle, UniformConstPortal> >
|
||||
( IsVisibleWorklet<UniformArrayHandle, UniformConstPortal>
|
||||
(RasterView.Width,
|
||||
RasterView.Height,
|
||||
ViewMatrix,
|
||||
vertices)
|
||||
)
|
||||
.Invoke( indices,
|
||||
indexes );
|
||||
}
|
||||
else if(coordsHandle.IsArrayHandleType(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> >()))
|
||||
{
|
||||
|
||||
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > vertices;
|
||||
coordsHandle.CastToArrayHandle(vertices);
|
||||
vtkm::worklet::DispatcherMapField< IsVisibleWorklet<Points32Handle, Points32ConstPortal> >
|
||||
( IsVisibleWorklet<Points32Handle, Points32ConstPortal>
|
||||
(RasterView.Width,
|
||||
RasterView.Height,
|
||||
ViewMatrix,
|
||||
vertices)
|
||||
)
|
||||
.Invoke( indices,
|
||||
indexes );
|
||||
}
|
||||
else if(coordsHandle.IsArrayHandleType(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,3> >()))
|
||||
{
|
||||
|
||||
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,3> > vertices;
|
||||
coordsHandle.CastToArrayHandle(vertices);
|
||||
vtkm::worklet::DispatcherMapField< IsVisibleWorklet<Points64Handle, Points64ConstPortal> >
|
||||
( IsVisibleWorklet<Points64Handle, Points64ConstPortal>
|
||||
(RasterView.Width,
|
||||
RasterView.Height,
|
||||
ViewMatrix,
|
||||
vertices)
|
||||
)
|
||||
.Invoke( indices,
|
||||
indexes );
|
||||
}
|
||||
IsVisible predicate;
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::StreamCompact(indexes,
|
||||
indexes,
|
||||
visibleIndexs,
|
||||
predicate);
|
||||
std::cout<<"Number of visible triangles "<<visibleIndexs.GetNumberOfValues()<<std::endl;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void Run(vtkm::cont::DynamicArrayHandleCoordinateSystem &coordsHandle,
|
||||
const vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id, 4> > &indices,
|
||||
vtkm::cont::Field &scalarField)
|
||||
{
|
||||
vtkm::Float64 scalarBounds[2];
|
||||
scalarField.GetBounds(scalarBounds, DeviceAdapter() );
|
||||
vtkm::cont::ArrayHandle< vtkm::Float32> scalars;
|
||||
// std::cout<<"Casting scalars\n";
|
||||
// scalarField.GetData().CastToArrayHandle(scalars);
|
||||
// std::cout<<"Done Casting scalars\n";
|
||||
// printSummary_ArrayHandle(scalars, std::cout); std::cout<<"\n";
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > frameBuffer;
|
||||
vtkm::cont::ArrayHandle<vtkm::UInt64> packedBuffer;
|
||||
frameBuffer.Allocate(RasterView.Height * RasterView.Width);
|
||||
packedBuffer.Allocate(RasterView.Height * RasterView.Width);
|
||||
vtkm::UInt64 packedInitialValue = 0x3f800000FFFFFFFF;
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::UInt64> >( MemSet<vtkm::UInt64>( packedInitialValue ) )
|
||||
.Invoke( packedBuffer );
|
||||
vtkm::exec::DepthBuffer<DeviceAdapter> zBuffer(packedBuffer);
|
||||
//create the view projection matrix
|
||||
vtkm::rendering::View3D::PrintMatrix(RasterView.CreateViewMatrix());
|
||||
vtkm::rendering::View3D::PrintMatrix(RasterView.CreateProjectionMatrix());
|
||||
ViewMatrix
|
||||
= vtkm::MatrixMultiply(RasterView.CreateProjectionMatrix(),
|
||||
RasterView.CreateViewMatrix());
|
||||
std::cout<<"ViewProj\n";
|
||||
vtkm::rendering::View3D::PrintMatrix(ViewMatrix);
|
||||
vtkm::cont::ArrayHandle< vtkm::Id> visibleTriangles;
|
||||
CullNonVisible(indices,coordsHandle,visibleTriangles);
|
||||
//if(true) {} else
|
||||
if(coordsHandle.IsArrayHandleType(vtkm::cont::ArrayHandleUniformPointCoordinates()))
|
||||
{
|
||||
std::cout<<"Uniform Raster\n";
|
||||
if(scalarField.GetData().IsTypeAndStorage(vtkm::Float64(), VTKM_DEFAULT_STORAGE_TAG()))
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> scalars = scalarField.GetData().CastToArrayHandle(vtkm::Float64(), VTKM_DEFAULT_STORAGE_TAG());
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates vertices;
|
||||
coordsHandle.CastToArrayHandle(vertices);
|
||||
vtkm::worklet::DispatcherMapField< RasterUniform<UniformArrayHandle, UniformConstPortal> >
|
||||
( RasterUniform<UniformArrayHandle, UniformConstPortal>(vertices,
|
||||
frameBuffer,
|
||||
ViewMatrix,
|
||||
RasterView.Width,
|
||||
RasterView.Height,
|
||||
ColorMap,
|
||||
scalarBounds,
|
||||
zBuffer,
|
||||
RasterView.Position)
|
||||
)
|
||||
.Invoke(visibleTriangles,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Vec<vtkm::Id,4> >(indices),
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float64>(scalars) );
|
||||
}
|
||||
else if(scalarField.GetData().IsTypeAndStorage(vtkm::Float32(), VTKM_DEFAULT_STORAGE_TAG()))
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalars = scalarField.GetData().CastToArrayHandle(vtkm::Float32(), VTKM_DEFAULT_STORAGE_TAG());
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates vertices;
|
||||
coordsHandle.CastToArrayHandle(vertices);
|
||||
vtkm::worklet::DispatcherMapField< RasterUniform<UniformArrayHandle, UniformConstPortal> >
|
||||
( RasterUniform<UniformArrayHandle, UniformConstPortal>(vertices,
|
||||
frameBuffer,
|
||||
ViewMatrix,
|
||||
RasterView.Width,
|
||||
RasterView.Height,
|
||||
ColorMap,
|
||||
scalarBounds,
|
||||
zBuffer,
|
||||
RasterView.Position)
|
||||
)
|
||||
.Invoke(visibleTriangles,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Vec<vtkm::Id,4> >(indices),
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float32>(scalars) );
|
||||
}
|
||||
}
|
||||
else if(coordsHandle.IsArrayHandleType(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> >()))
|
||||
{
|
||||
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float32,3> > vertices;
|
||||
coordsHandle.CastToArrayHandle(vertices);
|
||||
if(scalarField.GetData().IsTypeAndStorage(vtkm::Float64(), VTKM_DEFAULT_STORAGE_TAG()))
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> scalars = scalarField.GetData().CastToArrayHandle(vtkm::Float64(), VTKM_DEFAULT_STORAGE_TAG());
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::UInt64> >( MemSet<vtkm::UInt64>( packedInitialValue ) )
|
||||
.Invoke( packedBuffer );
|
||||
vtkm::worklet::DispatcherMapField< RasterUniform<Points32Handle, Points32ConstPortal> >
|
||||
( RasterUniform<Points32Handle, Points32ConstPortal>(vertices,
|
||||
frameBuffer,
|
||||
ViewMatrix,
|
||||
RasterView.Width,
|
||||
RasterView.Height,
|
||||
ColorMap,
|
||||
scalarBounds,
|
||||
zBuffer,
|
||||
RasterView.Position)
|
||||
)
|
||||
.Invoke(visibleTriangles,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Vec<vtkm::Id,4> >(indices),
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float64>(scalars) );
|
||||
}
|
||||
else if(scalarField.GetData().IsTypeAndStorage(vtkm::Float32(), VTKM_DEFAULT_STORAGE_TAG()))
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalars = scalarField.GetData().CastToArrayHandle(vtkm::Float32(), VTKM_DEFAULT_STORAGE_TAG());
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::UInt64> >( MemSet<vtkm::UInt64>( packedInitialValue ) )
|
||||
.Invoke( packedBuffer );
|
||||
vtkm::worklet::DispatcherMapField< RasterUniform<Points32Handle, Points32ConstPortal> >
|
||||
( RasterUniform<Points32Handle, Points32ConstPortal>(vertices,
|
||||
frameBuffer,
|
||||
ViewMatrix,
|
||||
RasterView.Width,
|
||||
RasterView.Height,
|
||||
ColorMap,
|
||||
scalarBounds,
|
||||
zBuffer,
|
||||
RasterView.Position)
|
||||
)
|
||||
.Invoke(visibleTriangles,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Vec<vtkm::Id,4> >(indices),
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float32>(scalars) );
|
||||
}
|
||||
|
||||
}
|
||||
else if(coordsHandle.IsArrayHandleType(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,3> >()))
|
||||
{
|
||||
if(scalarField.GetData().IsTypeAndStorage(vtkm::Float64(), VTKM_DEFAULT_STORAGE_TAG()))
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> scalars = scalarField.GetData().CastToArrayHandle(vtkm::Float64(), VTKM_DEFAULT_STORAGE_TAG());
|
||||
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,3> > vertices;
|
||||
coordsHandle.CastToArrayHandle(vertices);
|
||||
vtkm::worklet::DispatcherMapField< RasterUniform<Points64Handle, Points64ConstPortal> >
|
||||
( RasterUniform<Points64Handle, Points64ConstPortal>(vertices,
|
||||
frameBuffer,
|
||||
ViewMatrix,
|
||||
RasterView.Width,
|
||||
RasterView.Height,
|
||||
ColorMap,
|
||||
scalarBounds,
|
||||
zBuffer,
|
||||
RasterView.Position)
|
||||
)
|
||||
.Invoke(visibleTriangles,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Vec<vtkm::Id,4> >(indices),
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float64>(scalars) );
|
||||
}
|
||||
else if(scalarField.GetData().IsTypeAndStorage(vtkm::Float32(), VTKM_DEFAULT_STORAGE_TAG()))
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalars = scalarField.GetData().CastToArrayHandle(vtkm::Float32(), VTKM_DEFAULT_STORAGE_TAG());
|
||||
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Float64,3> > vertices;
|
||||
coordsHandle.CastToArrayHandle(vertices);
|
||||
vtkm::worklet::DispatcherMapField< RasterUniform<Points64Handle, Points64ConstPortal> >
|
||||
( RasterUniform<Points64Handle, Points64ConstPortal>(vertices,
|
||||
frameBuffer,
|
||||
ViewMatrix,
|
||||
RasterView.Width,
|
||||
RasterView.Height,
|
||||
ColorMap,
|
||||
scalarBounds,
|
||||
zBuffer,
|
||||
RasterView.Position)
|
||||
)
|
||||
.Invoke(visibleTriangles,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Vec<vtkm::Id,4> >(indices),
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float32>(scalars) );
|
||||
}
|
||||
|
||||
}
|
||||
else throw vtkm::cont::ErrorControlBadValue("Point data type not supported by the rasterizer.");
|
||||
std::cout<<"Writing files\n";
|
||||
writer::WriteDepthBufferUnPack(packedBuffer,RasterView.Width,RasterView.Height);
|
||||
writer::RasterWriteColorBufferUnPack(packedBuffer,RasterView.Width,RasterView.Height);
|
||||
|
||||
}
|
||||
VTKM_CONT_EXPORT
|
||||
void SetColorMap(const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > &colorMap)
|
||||
{
|
||||
ColorMap = colorMap;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}} // namespace vtkm::rendering
|
||||
#endif //vtk_m_rendering_Rasterizer_h
|
75
vtkm/rendering/SceneRenderer.h
Normal file
75
vtkm/rendering/SceneRenderer.h
Normal file
@ -0,0 +1,75 @@
|
||||
//============================================================================
|
||||
// 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_SceneRenderer_h
|
||||
#define vtk_m_rendering_SceneRenderer_h
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/rendering/ColorTable.h>
|
||||
#include <vtkm/rendering/View.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
|
||||
class SceneRenderer
|
||||
{
|
||||
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 vtkm::rendering::View3D& GetView()
|
||||
{
|
||||
return View;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
virtual void RenderCells(const vtkm::cont::DynamicCellSet &cellset,
|
||||
const vtkm::cont::CoordinateSystem &coords,
|
||||
vtkm::cont::Field &scalarField) = 0;
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
virtual void SetActiveColorTable(const ColorTable &colorTable)
|
||||
{
|
||||
colorTable.Sample(1024, ColorMap);
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
virtual void SetBackgroundColor(const vtkm::Vec<vtkm::Float32,4> &backgroundColor)
|
||||
{
|
||||
BackgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
protected:
|
||||
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
|
84
vtkm/rendering/SceneRendererVolume.h
Normal file
84
vtkm/rendering/SceneRendererVolume.h
Normal file
@ -0,0 +1,84 @@
|
||||
//============================================================================
|
||||
// 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_SceneRendererVolume_h
|
||||
#define vtk_m_rendering_SceneRendererVolume_h
|
||||
#include <vtkm/rendering/ColorTable.h>
|
||||
#include <vtkm/rendering/Triangulator.h>
|
||||
#include <vtkm/rendering/SceneRenderer.h>
|
||||
#include <vtkm/rendering/raytracing/VolumeRendererUniform.h>
|
||||
#include <vtkm/rendering/raytracing/Camera.h>
|
||||
#include <vtkm/rendering/View.h>
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
template<typename DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
||||
class SceneRendererVolume : public SceneRenderer
|
||||
{
|
||||
protected:
|
||||
vtkm::rendering::raytracing::VolumeRendererUniform<DeviceAdapter> Tracer;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
SceneRendererVolume()
|
||||
{}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetNumberOfSamples(const vtkm::Int32 &numSamples)
|
||||
{
|
||||
Tracer.SetNumberOfSamples(numSamples);
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
virtual void RenderCells(const vtkm::cont::DynamicCellSet &cellset,
|
||||
const vtkm::cont::CoordinateSystem &coords,
|
||||
vtkm::cont::Field &scalarField)
|
||||
{
|
||||
vtkm::cont::DynamicArrayHandleCoordinateSystem dynamicCoordsHandle = coords.GetData();
|
||||
vtkm::Float64 coordsBounds[6]; // Xmin,Xmax,Ymin..
|
||||
coords.GetBounds(coordsBounds,DeviceAdapter());
|
||||
|
||||
bool isExplicit = false;
|
||||
bool isUniform = false;
|
||||
if(!cellset.IsType(vtkm::cont::CellSetStructured<3>()))
|
||||
{
|
||||
std::cerr<<"ERROR cell set type not currently supported\n";
|
||||
std::string theType = typeid(cellset).name();
|
||||
std::cerr<<"Type : "<<theType<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::CellSetStructured<3> cellSetStructured3D;
|
||||
cellSetStructured3D = cellset.CastTo(vtkm::cont::CellSetStructured<3>());
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates vertices;
|
||||
dynamicCoordsHandle.CastToArrayHandle(vertices);
|
||||
vtkm::rendering::raytracing::Camera<DeviceAdapter> &camera = Tracer.GetCamera();
|
||||
camera.SetParameters(View);
|
||||
Tracer.SetData(vertices, scalarField, coordsBounds, cellSetStructured3D);
|
||||
Tracer.SetColorMap(ColorMap);
|
||||
std::cout<<"Structured Rendering"<<std::endl;
|
||||
Tracer.SetBackgroundColor(this->BackgroundColor);
|
||||
Tracer.Render();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}} //namespace vtkm::rendering
|
||||
#endif //vtk_m_rendering_SceneRendererVolume_h
|
527
vtkm/rendering/Triangulator.h
Normal file
527
vtkm/rendering/Triangulator.h
Normal file
@ -0,0 +1,527 @@
|
||||
//============================================================================
|
||||
// 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_Triangulator_h
|
||||
#define vtk_m_rendering_Triangulator_h
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/exec/ExecutionWholeArray.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapTopology.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapTopology.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
/// \brief Triangulator creates a minimal set of triangles from a cell set.
|
||||
///
|
||||
/// This class creates a array of triangle indices from both 3D and 2D
|
||||
/// explicit cell sets. This list can serve as input to opengl and the
|
||||
/// ray tracer scene renderers. TODO: Add regular grid support
|
||||
///
|
||||
template<typename DeviceAdapter>
|
||||
class Triangulator
|
||||
{
|
||||
private:
|
||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Id> IdArrayHandle;
|
||||
typedef typename vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id,4> > Vec4ArrayHandle;
|
||||
typedef typename Vec4ArrayHandle::ExecutionTypes<DeviceAdapter>::Portal Vec4ArrayPortalType;
|
||||
typedef typename IdArrayHandle::ExecutionTypes<DeviceAdapter>::PortalConst IdPortalConstType;
|
||||
public:
|
||||
template<class T>
|
||||
class MemSet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
T Value;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
MemSet(T value)
|
||||
: Value(value)
|
||||
{}
|
||||
typedef void ControlSignature(FieldOut<>);
|
||||
typedef void ExecutionSignature(_1);
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(T &outValue) const
|
||||
{
|
||||
outValue = Value;
|
||||
}
|
||||
}; //class MemSet
|
||||
class CountTriangles : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
CountTriangles(){}
|
||||
typedef void ControlSignature(FieldIn<>,
|
||||
FieldOut<>);
|
||||
typedef void ExecutionSignature(_1,
|
||||
_2);
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const vtkm::Id &shapeType,
|
||||
vtkm::Id &triangles) const
|
||||
{
|
||||
if( shapeType == vtkm::CELL_SHAPE_TRIANGLE ) triangles = 1;
|
||||
else if( shapeType == vtkm::CELL_SHAPE_QUAD ) triangles = 2;
|
||||
else if( shapeType == vtkm::CELL_SHAPE_TETRA ) triangles = 4;
|
||||
else if( shapeType == vtkm::CELL_SHAPE_HEXAHEDRON ) triangles = 12;
|
||||
else if( shapeType == vtkm::CELL_SHAPE_WEDGE ) triangles = 8;
|
||||
else if( shapeType == vtkm::CELL_SHAPE_PYRAMID ) triangles = 6;
|
||||
else triangles = 0;
|
||||
}
|
||||
}; //class CountTriangles
|
||||
|
||||
class TrianglulateStructured :
|
||||
public vtkm::worklet::WorkletMapPointToCell
|
||||
{
|
||||
private:
|
||||
Vec4ArrayPortalType OutputIndices;
|
||||
public:
|
||||
typedef void ControlSignature(TopologyIn topology,
|
||||
FieldInTo<>);
|
||||
typedef void ExecutionSignature(FromIndices, _2);
|
||||
//typedef _1 InputDomain;
|
||||
VTKM_CONT_EXPORT
|
||||
TrianglulateStructured(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id,4> > &outputIndices)
|
||||
{
|
||||
this->OutputIndices = outputIndices.PrepareForOutput(outputIndices.GetNumberOfValues(), DeviceAdapter() );
|
||||
}
|
||||
template<typename CellNodeVecType>
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const CellNodeVecType &cellIndices,
|
||||
const vtkm::Id &cellIndex) const
|
||||
{
|
||||
const vtkm::Id triangleOffset = cellIndex * 12;
|
||||
vtkm::Vec<vtkm::Id,4> triangle;
|
||||
// 0-1-2
|
||||
triangle[1] = cellIndices[0];
|
||||
triangle[2] = cellIndices[1];
|
||||
triangle[3] = cellIndices[2];
|
||||
triangle[0] = cellIndex;
|
||||
OutputIndices.Set(triangleOffset, triangle);
|
||||
// 0-3-2
|
||||
triangle[2] = cellIndices[3];
|
||||
OutputIndices.Set(triangleOffset+1, triangle);
|
||||
// 0-3-7
|
||||
triangle[3] = cellIndices[7];
|
||||
OutputIndices.Set(triangleOffset+2, triangle);
|
||||
// 0-4-7
|
||||
triangle[2] = cellIndices[4];
|
||||
OutputIndices.Set(triangleOffset+3, triangle);
|
||||
// 5-4-7
|
||||
triangle[1] = cellIndices[5];
|
||||
OutputIndices.Set(triangleOffset+4, triangle);
|
||||
// 5-6-7
|
||||
triangle[2] = cellIndices[6];
|
||||
OutputIndices.Set(triangleOffset+5, triangle);
|
||||
// 3-6-7
|
||||
triangle[1] = cellIndices[3];
|
||||
OutputIndices.Set(triangleOffset+6, triangle);
|
||||
// 3-6-2
|
||||
triangle[3] = cellIndices[2];
|
||||
OutputIndices.Set(triangleOffset+7, triangle);
|
||||
// 1-6-2
|
||||
triangle[1] = cellIndices[1];
|
||||
OutputIndices.Set(triangleOffset+8, triangle);
|
||||
// 1-6-5
|
||||
triangle[3] = cellIndices[5];
|
||||
OutputIndices.Set(triangleOffset+9, triangle);
|
||||
// 1-4-5
|
||||
triangle[2] = cellIndices[4];
|
||||
OutputIndices.Set(triangleOffset+10, triangle);
|
||||
// 1-4-0
|
||||
triangle[3] = cellIndices[0];
|
||||
OutputIndices.Set(triangleOffset+11, triangle);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class IndicesSort : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
IndicesSort(){}
|
||||
typedef void ControlSignature(FieldInOut<>);
|
||||
typedef void ExecutionSignature(_1);
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()( vtkm::Vec<vtkm::Id,4> &triangleIndices) const
|
||||
{
|
||||
// first field contains the id of the cell the
|
||||
// trianlge belongs to
|
||||
vtkm::Id temp;
|
||||
if (triangleIndices[1] > triangleIndices[3])
|
||||
{
|
||||
temp = triangleIndices[1];
|
||||
triangleIndices[1] = triangleIndices[3];
|
||||
triangleIndices[3] = temp;
|
||||
}
|
||||
if (triangleIndices[1] > triangleIndices[2])
|
||||
{
|
||||
temp = triangleIndices[1];
|
||||
triangleIndices[1] = triangleIndices[2];
|
||||
triangleIndices[2] = temp;
|
||||
}
|
||||
if (triangleIndices[2] > triangleIndices[3])
|
||||
{
|
||||
temp = triangleIndices[2];
|
||||
triangleIndices[2] = triangleIndices[3];
|
||||
triangleIndices[3] = temp;
|
||||
}
|
||||
}
|
||||
}; //class IndicesSort
|
||||
|
||||
struct IndicesLessThan
|
||||
{
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
bool operator()(const vtkm::Vec<vtkm::Id,4> &a,
|
||||
const vtkm::Vec<vtkm::Id,4> &b) const
|
||||
{
|
||||
if(a[1] < b[1]) return true;
|
||||
if(a[1] > b[1]) return false;
|
||||
if(a[2] < b[2]) return true;
|
||||
if(a[2] > b[2]) return false;
|
||||
if(a[3] < b[3]) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class UniqueTriangles : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
UniqueTriangles(){}
|
||||
typedef void ControlSignature(ExecObject,
|
||||
ExecObject);
|
||||
typedef void ExecutionSignature(_1,_2,WorkIndex);
|
||||
VTKM_EXEC_EXPORT
|
||||
bool IsTwin(const vtkm::Vec<vtkm::Id,4> &a, const vtkm::Vec<vtkm::Id,4> &b) const
|
||||
{
|
||||
return (a[1] == b[1] && a[2] == b[2] && a[3] == b[3]);
|
||||
}
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(vtkm::exec::ExecutionWholeArrayConst<vtkm::Vec<vtkm::Id,4> > &indices,
|
||||
vtkm::exec::ExecutionWholeArray<vtkm::UInt8> &outputFlags,
|
||||
const vtkm::Id &index) const
|
||||
{
|
||||
if (index == 0) return;
|
||||
//if we are a shared face, mark ourself and neighbor for desctruction
|
||||
if(IsTwin(indices.Get(index), indices.Get(index-1) ))
|
||||
{
|
||||
outputFlags.Set(index, 0);
|
||||
outputFlags.Set(index - 1, 0);
|
||||
}
|
||||
}
|
||||
}; //class UniqueTriangles
|
||||
|
||||
|
||||
class Trianglulate : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
private:
|
||||
IdPortalConstType Indices;
|
||||
Vec4ArrayPortalType OutputIndices;
|
||||
|
||||
vtkm::Int32 TRIANGLE_INDICES;
|
||||
vtkm::Int32 QUAD_INDICES;
|
||||
vtkm::Int32 TETRA_INDICES;
|
||||
vtkm::Int32 HEX_INDICES;
|
||||
vtkm::Int32 WEDGE_INDICES;
|
||||
vtkm::Int32 PYRAMID_INDICES;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
Trianglulate(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id,4> > &outputIndices,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id> &indices,
|
||||
const vtkm::Id &size)
|
||||
: Indices(indices.PrepareForInput(DeviceAdapter()))
|
||||
{
|
||||
this->OutputIndices = outputIndices.PrepareForOutput(size, DeviceAdapter() );
|
||||
TRIANGLE_INDICES = 3;
|
||||
QUAD_INDICES = 4;
|
||||
TETRA_INDICES = 4;
|
||||
HEX_INDICES = 8;
|
||||
WEDGE_INDICES = 6;
|
||||
PYRAMID_INDICES = 5;
|
||||
}
|
||||
typedef void ControlSignature(FieldIn<>,
|
||||
FieldIn<>,
|
||||
FieldIn<>);
|
||||
typedef void ExecutionSignature(_1,
|
||||
_2,
|
||||
_3,
|
||||
WorkIndex);
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const vtkm::Id &shapeType,
|
||||
const vtkm::Id &indexOffset,
|
||||
const vtkm::Id &triangleOffset,
|
||||
const vtkm::Id &cellId) const
|
||||
{
|
||||
vtkm::Vec<vtkm::Id,4> triangle;
|
||||
if( shapeType == vtkm::CELL_SHAPE_TRIANGLE )
|
||||
{
|
||||
|
||||
triangle[1] = Indices.Get(indexOffset+0);
|
||||
triangle[2] = Indices.Get(indexOffset+1);
|
||||
triangle[3] = Indices.Get(indexOffset+2);
|
||||
triangle[0] = cellId;
|
||||
OutputIndices.Set(triangleOffset, triangle);
|
||||
}
|
||||
if( shapeType == vtkm::CELL_SHAPE_QUAD )
|
||||
{
|
||||
|
||||
triangle[1] = Indices.Get(indexOffset+0);
|
||||
triangle[2] = Indices.Get(indexOffset+1);
|
||||
triangle[3] = Indices.Get(indexOffset+2);
|
||||
triangle[0] = cellId;
|
||||
OutputIndices.Set(triangleOffset, triangle);
|
||||
|
||||
triangle[2] = Indices.Get(indexOffset+3);
|
||||
OutputIndices.Set(triangleOffset+1, triangle);
|
||||
}
|
||||
if( shapeType == vtkm::CELL_SHAPE_TETRA )
|
||||
{
|
||||
// 0-1-2
|
||||
triangle[1] = Indices.Get(indexOffset+1);
|
||||
triangle[2] = Indices.Get(indexOffset+0);
|
||||
triangle[3] = Indices.Get(indexOffset+2);
|
||||
triangle[0] = cellId;
|
||||
OutputIndices.Set(triangleOffset, triangle);
|
||||
// 0-1-3
|
||||
triangle[1] = Indices.Get(indexOffset+1);
|
||||
triangle[2] = Indices.Get(indexOffset+0);
|
||||
triangle[3] = Indices.Get(indexOffset+3);
|
||||
|
||||
OutputIndices.Set(triangleOffset+1, triangle);
|
||||
// 2-1-3
|
||||
triangle[1] = Indices.Get(indexOffset+1);
|
||||
triangle[2] = Indices.Get(indexOffset+2);
|
||||
triangle[3] = Indices.Get(indexOffset+3);
|
||||
OutputIndices.Set(triangleOffset+2, triangle);
|
||||
// 2-0-3
|
||||
triangle[1] = Indices.Get(indexOffset+2);
|
||||
triangle[2] = Indices.Get(indexOffset+0);
|
||||
triangle[3] = Indices.Get(indexOffset+3);
|
||||
OutputIndices.Set(triangleOffset+3, triangle);
|
||||
}
|
||||
if( shapeType == vtkm::CELL_SHAPE_HEXAHEDRON )
|
||||
{
|
||||
// 0-1-2
|
||||
triangle[1] = Indices.Get(indexOffset+0);
|
||||
triangle[2] = Indices.Get(indexOffset+1);
|
||||
triangle[3] = Indices.Get(indexOffset+2);
|
||||
triangle[0] = cellId;
|
||||
OutputIndices.Set(triangleOffset, triangle);
|
||||
// 0-3-2
|
||||
triangle[2] = Indices.Get(indexOffset+3);
|
||||
OutputIndices.Set(triangleOffset+1, triangle);
|
||||
// 0-3-7
|
||||
triangle[3] = Indices.Get(indexOffset+7);
|
||||
OutputIndices.Set(triangleOffset+2, triangle);
|
||||
// 0-4-7
|
||||
triangle[2] = Indices.Get(indexOffset+4);
|
||||
OutputIndices.Set(triangleOffset+3, triangle);
|
||||
// 5-4-7
|
||||
triangle[1] = Indices.Get(indexOffset+5);
|
||||
OutputIndices.Set(triangleOffset+4, triangle);
|
||||
// 5-6-7
|
||||
triangle[2] = Indices.Get(indexOffset+6);
|
||||
OutputIndices.Set(triangleOffset+5, triangle);
|
||||
// 3-6-7
|
||||
triangle[1] = Indices.Get(indexOffset+3);
|
||||
OutputIndices.Set(triangleOffset+6, triangle);
|
||||
// 3-6-2
|
||||
triangle[3] = Indices.Get(indexOffset+2);
|
||||
OutputIndices.Set(triangleOffset+7, triangle);
|
||||
// 1-6-2
|
||||
triangle[1] = Indices.Get(indexOffset+1);
|
||||
OutputIndices.Set(triangleOffset+8, triangle);
|
||||
// 1-6-5
|
||||
triangle[3] = Indices.Get(indexOffset+5);
|
||||
OutputIndices.Set(triangleOffset+9, triangle);
|
||||
// 1-4-5
|
||||
triangle[2] = Indices.Get(indexOffset+4);
|
||||
OutputIndices.Set(triangleOffset+10, triangle);
|
||||
// 1-4-0
|
||||
triangle[3] = Indices.Get(indexOffset+0);
|
||||
OutputIndices.Set(triangleOffset+11, triangle);
|
||||
}
|
||||
if( shapeType == vtkm::CELL_SHAPE_WEDGE )
|
||||
{
|
||||
// 0-1-2
|
||||
triangle[1] = Indices.Get(indexOffset+0);
|
||||
triangle[2] = Indices.Get(indexOffset+1);
|
||||
triangle[3] = Indices.Get(indexOffset+2);
|
||||
triangle[0] = cellId;
|
||||
OutputIndices.Set(triangleOffset, triangle);
|
||||
// 0-3-2
|
||||
triangle[2] = Indices.Get(indexOffset+3);
|
||||
OutputIndices.Set(triangleOffset+1, triangle);
|
||||
// 5-3-2
|
||||
triangle[1] = Indices.Get(indexOffset+5);
|
||||
OutputIndices.Set(triangleOffset+2, triangle);
|
||||
// 5-3-4
|
||||
triangle[3] = Indices.Get(indexOffset+4);
|
||||
OutputIndices.Set(triangleOffset+3, triangle);
|
||||
// 5-2-4
|
||||
triangle[2] = Indices.Get(indexOffset+2);
|
||||
OutputIndices.Set(triangleOffset+4, triangle);
|
||||
// 5-1-4
|
||||
triangle[2] = Indices.Get(indexOffset+1);
|
||||
OutputIndices.Set(triangleOffset+5, triangle);
|
||||
}
|
||||
if( shapeType == vtkm::CELL_SHAPE_PYRAMID )
|
||||
{
|
||||
// 0-1-2
|
||||
triangle[1] = Indices.Get(indexOffset+0);
|
||||
triangle[2] = Indices.Get(indexOffset+1);
|
||||
triangle[3] = Indices.Get(indexOffset+2);
|
||||
triangle[0] = cellId;
|
||||
OutputIndices.Set(triangleOffset, triangle);
|
||||
// 0-3-2
|
||||
triangle[2] = Indices.Get(indexOffset+3);
|
||||
OutputIndices.Set(triangleOffset+1, triangle);
|
||||
// 0-3-4
|
||||
triangle[3] = Indices.Get(indexOffset+4);
|
||||
OutputIndices.Set(triangleOffset+2, triangle);
|
||||
// 2-3-4
|
||||
triangle[1] = Indices.Get(indexOffset+2);
|
||||
OutputIndices.Set(triangleOffset+3, triangle);
|
||||
// 2-1-4
|
||||
triangle[2] = Indices.Get(indexOffset+1);
|
||||
OutputIndices.Set(triangleOffset+4, triangle);
|
||||
// 0-3-4
|
||||
triangle[1] = Indices.Get(indexOffset+0);
|
||||
OutputIndices.Set(triangleOffset+5, triangle);
|
||||
}
|
||||
}
|
||||
}; //class Trianglulate
|
||||
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
Triangulator() {}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void ExternalTrianlges(vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id,4> > &outputIndices,
|
||||
vtkm::Id &outputTriangles)
|
||||
{
|
||||
//Eliminate unseen triangles
|
||||
vtkm::worklet::DispatcherMapField<IndicesSort>()
|
||||
.Invoke(outputIndices);
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::Sort(outputIndices, IndicesLessThan());
|
||||
vtkm::cont::ArrayHandle<vtkm::UInt8> flags;
|
||||
flags.Allocate(outputTriangles);
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::UInt8 > >( MemSet< vtkm::UInt8>( 1 ) )
|
||||
.Invoke( flags );
|
||||
|
||||
//Unique triangles will have a flag = 1
|
||||
std::cout<<"Number of tris "<<outputTriangles<<std::endl;
|
||||
vtkm::worklet::DispatcherMapField< UniqueTriangles >()
|
||||
.Invoke( vtkm::exec::ExecutionWholeArrayConst< vtkm::Vec<vtkm::Id,4> >(outputIndices),
|
||||
vtkm::exec::ExecutionWholeArray< vtkm::UInt8 >(flags));
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id,4> > subset;
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::StreamCompact(outputIndices,
|
||||
flags,
|
||||
subset);
|
||||
std::cout<<"Number of tris after"<<subset.GetNumberOfValues()<<std::endl;
|
||||
}
|
||||
VTKM_CONT_EXPORT
|
||||
void run(const vtkm::cont::DynamicCellSet &cellset,
|
||||
vtkm::cont::ArrayHandle< vtkm::Vec<vtkm::Id,4> > &outputIndices,
|
||||
vtkm::Id &outputTriangles)
|
||||
{
|
||||
vtkm::cont::CellSetStructured<3> cellSetStructured3D;
|
||||
vtkm::cont::CellSetExplicit<> cellSetExplicit;
|
||||
bool isExplicitCellSet = false;//cellset.IsTypeAndStorage(vtkm::cont::CellSetStructured());
|
||||
bool isStructuredCellSet = false;
|
||||
try
|
||||
{
|
||||
cellSetStructured3D = cellset.CastTo(vtkm::cont::CellSetStructured<3>());
|
||||
isStructuredCellSet = true;
|
||||
std::cout<<"Is structured"<<std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
//do nothing
|
||||
std::cout<<"Not structured"<<std::endl;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
cellSetExplicit = cellset.CastTo(vtkm::cont::CellSetExplicit<>());
|
||||
isExplicitCellSet = true;
|
||||
std::cout<<"Is explicit"<<std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
//do nothing
|
||||
std::cout<<"Not explicit"<<std::endl;
|
||||
}
|
||||
|
||||
if(isStructuredCellSet)
|
||||
{
|
||||
const vtkm::Id numCells = cellSetStructured3D.GetNumberOfCells();
|
||||
std::cout<<"Number of cells "<<numCells<<std::endl;
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> cellIdxs(0,1,numCells);
|
||||
outputIndices.Allocate(numCells * 12);
|
||||
vtkm::worklet::DispatcherMapTopology<TrianglulateStructured>(TrianglulateStructured(outputIndices))
|
||||
.Invoke(cellSetStructured3D,
|
||||
cellIdxs);
|
||||
printSummary_ArrayHandle(outputIndices, std::cout); std::cout<<"\n";
|
||||
outputTriangles = numCells * 12;
|
||||
}
|
||||
if(isExplicitCellSet)
|
||||
{
|
||||
const vtkm::cont::ArrayHandle<vtkm::UInt8> shapes = cellSetExplicit.GetShapesArray( vtkm::TopologyElementTagPoint(),vtkm::TopologyElementTagCell());
|
||||
const vtkm::cont::ArrayHandle<vtkm::Int32> indices = cellSetExplicit.GetNumIndicesArray( vtkm::TopologyElementTagPoint(),vtkm::TopologyElementTagCell());
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> conn = cellSetExplicit.GetConnectivityArray( vtkm::TopologyElementTagPoint(),vtkm::TopologyElementTagCell());
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> offsets = cellSetExplicit.GetIndexOffsetArray( vtkm::TopologyElementTagPoint(),vtkm::TopologyElementTagCell());
|
||||
|
||||
// We need to somehow force the data set to build the index offsets
|
||||
//vtkm::IdComponent c = indices.GetPortalControl().Get(0);
|
||||
vtkm::Vec< vtkm::Id, 3> forceBuildIndices;
|
||||
cellSetExplicit.GetIndices(0, forceBuildIndices );
|
||||
|
||||
vtkm::Id numberOfShapes = shapes.GetNumberOfValues();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> trianglesPerCell;
|
||||
trianglesPerCell.Allocate(numberOfShapes);
|
||||
vtkm::worklet::DispatcherMapField<CountTriangles>( CountTriangles() )
|
||||
.Invoke(shapes,
|
||||
trianglesPerCell);
|
||||
|
||||
vtkm::Id totalTriangles = 0;
|
||||
totalTriangles = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::Reduce(trianglesPerCell,
|
||||
vtkm::Id(0));
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellOffsets;
|
||||
cellOffsets.Allocate(numberOfShapes);
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::ScanExclusive(trianglesPerCell,
|
||||
cellOffsets);
|
||||
outputIndices.Allocate(totalTriangles);
|
||||
vtkm::worklet::DispatcherMapField<Trianglulate>( Trianglulate(outputIndices,
|
||||
conn,
|
||||
totalTriangles) )
|
||||
.Invoke(shapes,
|
||||
offsets,
|
||||
cellOffsets);
|
||||
|
||||
outputTriangles = totalTriangles;
|
||||
}
|
||||
//get rid of any triagles we cannot see
|
||||
ExternalTrianlges(outputIndices, outputTriangles);
|
||||
}
|
||||
}; // class Triangulator
|
||||
}}//namespace vtkm::rendering
|
||||
#endif //vtk_m_rendering_Triangulator_h
|
121
vtkm/rendering/View.h
Normal file
121
vtkm/rendering/View.h
Normal file
@ -0,0 +1,121 @@
|
||||
#ifndef vtk_m_rendering_View_h
|
||||
#define vtk_m_rendering_View_h
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/Matrix.h>
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
|
||||
class View3D
|
||||
{
|
||||
public:
|
||||
vtkm::Vec<vtkm::Float32,3> Up;
|
||||
vtkm::Vec<vtkm::Float32,3> LookAt;
|
||||
vtkm::Vec<vtkm::Float32,3> Position;
|
||||
vtkm::Float32 NearPlane;
|
||||
vtkm::Float32 FarPlane;
|
||||
vtkm::Float32 FieldOfView;
|
||||
vtkm::Float32 AspectRatio;
|
||||
vtkm::Int32 Height;
|
||||
vtkm::Int32 Width;
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
View3D()
|
||||
{
|
||||
Up[0] = 0.f;
|
||||
Up[1] = 1.f;
|
||||
Up[2] = 0.f;
|
||||
|
||||
Position[0] = 0.f;
|
||||
Position[1] = 0.f;
|
||||
Position[2] = 0.f;
|
||||
|
||||
LookAt[0] = 0.f;
|
||||
LookAt[1] = 0.f;
|
||||
LookAt[2] = 1.f;
|
||||
|
||||
FieldOfView = 60.f;
|
||||
NearPlane = 1.0f;
|
||||
FarPlane = 100.0f;
|
||||
Height = 500;
|
||||
Width = 500;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Matrix<vtkm::Float32,4,4> CreateViewMatrix()
|
||||
{
|
||||
vtkm::Normalize(Up);
|
||||
vtkm::Matrix<vtkm::Float32,4,4> viewMatrix;
|
||||
vtkm::MatrixIdentity(viewMatrix);
|
||||
vtkm::Vec<vtkm::Float32,3> viewDir = Position - LookAt; //looking down the neg z axis
|
||||
vtkm::Normalize(viewDir);
|
||||
vtkm::Vec<vtkm::Float32,3> right = vtkm::Cross(Up,viewDir);
|
||||
vtkm::Vec<vtkm::Float32,3> ru = vtkm::Cross(right,viewDir);
|
||||
vtkm::Normalize(ru);
|
||||
vtkm::Normalize(right);
|
||||
viewMatrix(0,0) = right[0];
|
||||
viewMatrix(0,1) = right[1];
|
||||
viewMatrix(0,2) = right[2];
|
||||
viewMatrix(1,0) = ru[0];
|
||||
viewMatrix(1,1) = ru[1];
|
||||
viewMatrix(1,2) = ru[2];
|
||||
viewMatrix(2,0) = viewDir[0];
|
||||
viewMatrix(2,1) = viewDir[1];
|
||||
viewMatrix(2,2) = viewDir[2];
|
||||
|
||||
viewMatrix(0,3) = -vtkm::dot(right,Position);
|
||||
viewMatrix(1,3) = -vtkm::dot(ru,Position);
|
||||
viewMatrix(2,3) = -vtkm::dot(viewDir,Position);
|
||||
return viewMatrix;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Matrix<vtkm::Float32,4,4> CreateProjectionMatrix()
|
||||
{
|
||||
AspectRatio = vtkm::Float32(Width) / vtkm::Float32(Height);
|
||||
vtkm::Matrix<vtkm::Float32,4,4> projectionMatrix;
|
||||
vtkm::MatrixIdentity(projectionMatrix);
|
||||
vtkm::Float32 fovRad = (FieldOfView * 3.1415926f)/180.f;
|
||||
fovRad = vtkm::Tan( fovRad * 0.5f);
|
||||
std::cout<<"Field of View "<<fovRad<<std::endl;
|
||||
vtkm::Float32 size = NearPlane * fovRad;
|
||||
vtkm::Float32 left = -size * AspectRatio;
|
||||
vtkm::Float32 right = size * AspectRatio;
|
||||
vtkm::Float32 bottom = -size;
|
||||
vtkm::Float32 top = size;
|
||||
|
||||
projectionMatrix(0,0) = 2.f * NearPlane / (right - left);
|
||||
projectionMatrix(1,1) = 2.f * NearPlane / (top - bottom);
|
||||
projectionMatrix(0,2) = (right + left) / (right - left);
|
||||
projectionMatrix(1,2) = (top + bottom) / (top - bottom);
|
||||
projectionMatrix(2,2) = -(FarPlane + NearPlane) / (FarPlane - NearPlane);
|
||||
projectionMatrix(3,2) = -1.f;
|
||||
projectionMatrix(2,3) = -(2.f * FarPlane * NearPlane) / (FarPlane - NearPlane);
|
||||
return projectionMatrix;
|
||||
}
|
||||
|
||||
void operator=(const View3D &other)
|
||||
{
|
||||
this->Up = other.Up;
|
||||
this->LookAt = other.LookAt;
|
||||
this->Position = other.Position;
|
||||
this->NearPlane = other.NearPlane;
|
||||
this->FarPlane = other.FarPlane;
|
||||
this->FieldOfView = other.FieldOfView;
|
||||
this->Height = other.Height;
|
||||
this->Width = other.Width;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
static void PrintMatrix(const vtkm::Matrix<vtkm::Float32,4,4> &mat)
|
||||
{
|
||||
std::cout<<mat(0,0)<<","<<mat(0,1)<<","<<mat(0,2)<<","<<mat(0,3)<<std::endl;
|
||||
std::cout<<mat(1,0)<<","<<mat(1,1)<<","<<mat(1,2)<<","<<mat(1,3)<<std::endl;
|
||||
std::cout<<mat(2,0)<<","<<mat(2,1)<<","<<mat(2,2)<<","<<mat(2,3)<<std::endl;
|
||||
std::cout<<mat(3,0)<<","<<mat(3,1)<<","<<mat(3,2)<<","<<mat(3,3)<<std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace vtkm::rendering
|
||||
#endif // vtk_m_rendering_View_h
|
29
vtkm/rendering/raytracing/CMakeLists.txt
Normal file
29
vtkm/rendering/raytracing/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
||||
##============================================================================
|
||||
## 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 2014 Sandia Corporation.
|
||||
## Copyright 2014 UT-Battelle, LLC.
|
||||
## Copyright 2014 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.
|
||||
##============================================================================
|
||||
|
||||
set(headers
|
||||
Camera.h
|
||||
RayTracingTypeDefs.h
|
||||
Ray.h
|
||||
Worklets.h
|
||||
VolumeRendererUniform.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
366
vtkm/rendering/raytracing/Camera.h
Normal file
366
vtkm/rendering/raytracing/Camera.h
Normal file
@ -0,0 +1,366 @@
|
||||
//============================================================================
|
||||
// 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_raytracing_Camera_h
|
||||
#define vtk_m_rendering_raytracing_Camera_h
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ErrorControlBadValue.h>
|
||||
#include <vtkm/rendering/View.h>
|
||||
#include <vtkm/rendering/raytracing/Ray.h>
|
||||
#include <vtkm/rendering/raytracing/Worklets.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
namespace raytracing {
|
||||
template< typename DeviceAdapter >
|
||||
class Camera
|
||||
{
|
||||
public:
|
||||
class PerspectiveRayGen : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
public:
|
||||
vtkm::Int32 w;
|
||||
vtkm::Int32 h;
|
||||
vtkm::Vec< vtkm::Float32, 3> nlook;// normalized look
|
||||
vtkm::Vec< vtkm::Float32, 3> delta_x;
|
||||
vtkm::Vec< vtkm::Float32, 3> delta_y;
|
||||
VTKM_CONT_EXPORT
|
||||
PerspectiveRayGen(vtkm::Int32 width,
|
||||
vtkm::Int32 height,
|
||||
vtkm::Float32 fovX,
|
||||
vtkm::Float32 fovY,
|
||||
vtkm::Vec< vtkm::Float32, 3> look,
|
||||
vtkm::Vec< vtkm::Float32, 3> up,
|
||||
vtkm::Float32 _zoom)
|
||||
: w(width), h(height)
|
||||
{
|
||||
vtkm::Float32 thx = tanf( (fovX*3.1415926f/180.f) *.5f);
|
||||
vtkm::Float32 thy = tanf( (fovY*3.1415926f/180.f) *.5f);
|
||||
std::cout<<"Tan fovx "<<thx<<std::endl;
|
||||
vtkm::Vec< vtkm::Float32, 3> ru = vtkm::Cross(up,look);
|
||||
vtkm::Normalize(ru);
|
||||
|
||||
vtkm::Vec< vtkm::Float32, 3> rv = vtkm::Cross(ru,look);
|
||||
vtkm::Normalize(rv);
|
||||
|
||||
delta_x = ru*(2*thx/(float)w);
|
||||
delta_y = rv*(2*thy/(float)h);
|
||||
|
||||
if(_zoom > 0)
|
||||
{
|
||||
delta_x[0] = delta_x[0] / _zoom;
|
||||
delta_x[1] = delta_x[1] / _zoom;
|
||||
delta_x[2] = delta_x[2] / _zoom;
|
||||
delta_y[0] = delta_y[0] / _zoom;
|
||||
delta_y[1] = delta_y[1] / _zoom;
|
||||
delta_y[2] = delta_y[2] / _zoom;
|
||||
}
|
||||
nlook = look;
|
||||
vtkm::Normalize(nlook);
|
||||
std::cout<<"Up/look/right "<<ru<<nlook<<rv<<std::endl;
|
||||
|
||||
}
|
||||
|
||||
typedef void ControlSignature(FieldOut<>,
|
||||
FieldOut<>,
|
||||
FieldOut<> );
|
||||
|
||||
typedef void ExecutionSignature(WorkIndex,
|
||||
_1,
|
||||
_2,
|
||||
_3);
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(vtkm::Id idx,
|
||||
vtkm::Float32 &rayDirX,
|
||||
vtkm::Float32 &rayDirY,
|
||||
vtkm::Float32 &rayDirZ) const
|
||||
{
|
||||
vtkm::Vec<vtkm::Float32,3> ray_dir(rayDirX, rayDirY, rayDirZ);
|
||||
int i = vtkm::Int32( idx ) % w;
|
||||
int j = vtkm::Int32( idx ) / w;
|
||||
|
||||
ray_dir = nlook + delta_x * ((2.f * vtkm::Float32(i) - vtkm::Float32(w)) / 2.0f)
|
||||
+ delta_y * ((2.f * vtkm::Float32(j) - vtkm::Float32(h)) / 2.0f);
|
||||
vtkm::Normalize(ray_dir);
|
||||
rayDirX = ray_dir[0];
|
||||
rayDirY = ray_dir[1];
|
||||
rayDirZ = ray_dir[2];
|
||||
}
|
||||
|
||||
};// class perspective ray gen
|
||||
private:
|
||||
vtkm::Int32 Height;
|
||||
vtkm::Int32 Width;
|
||||
vtkm::Float32 FovX;
|
||||
vtkm::Float32 FovY;
|
||||
vtkm::Float32 FOV;
|
||||
vtkm::Float32 Zoom;
|
||||
bool IsViewDirty;
|
||||
bool IsResDirty;
|
||||
bool MortonSort;
|
||||
bool LookAtSet;
|
||||
|
||||
vtkm::Vec< vtkm::Float32, 3> Look;
|
||||
vtkm::Vec< vtkm::Float32, 3> Up;
|
||||
vtkm::Vec< vtkm::Float32, 3> LookAt;
|
||||
vtkm::Vec< vtkm::Float32, 3> Position;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
Camera()
|
||||
{
|
||||
Height = 500;
|
||||
Width = 500;
|
||||
FovY = 30.f;
|
||||
FovX = 30.f;
|
||||
Zoom = 1.f;
|
||||
Look[0] = 0.f;
|
||||
Look[1] = 0.f;
|
||||
Look[2] = -1.f;
|
||||
LookAt[0] = 0.f;
|
||||
LookAt[1] = 0.f;
|
||||
LookAt[2] = -1.f;
|
||||
Up[0] = 0.f;
|
||||
Up[1] = 1.f;
|
||||
Up[2] = 0.f;
|
||||
Position[0] = 0.f;
|
||||
Position[1] = 0.f;
|
||||
Position[2] = 0.f;
|
||||
IsViewDirty = true;
|
||||
IsResDirty = true;
|
||||
MortonSort = false;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetParameters(View3D &view)
|
||||
{
|
||||
this->SetUp(view.Up);
|
||||
this->SetLookAt(view.LookAt);
|
||||
this->SetPosition(view.Position);
|
||||
this->SetFieldOfView(view.FieldOfView);
|
||||
this->SetHeight(view.Height);
|
||||
this->SetWidth(view.Width);
|
||||
}
|
||||
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetHeight(const vtkm::Int32 &height)
|
||||
{
|
||||
if(height <= 0) throw vtkm::cont::ErrorControlBadValue("Camera height must be greater than zero.");
|
||||
if(Height != height)
|
||||
{
|
||||
IsResDirty = true;
|
||||
Height = height;
|
||||
this->SetFieldOfView(FovX);
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Int32 GetHeight() const
|
||||
{
|
||||
return Height;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetWidth(const vtkm::Int32 &width)
|
||||
{
|
||||
if(width <= 0) throw vtkm::cont::ErrorControlBadValue("Camera width must be greater than zero.");
|
||||
if(Width != width)
|
||||
{
|
||||
IsResDirty = true;
|
||||
Width = width;
|
||||
this->SetFieldOfView(FovX);
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Int32 GetWidth() const
|
||||
{
|
||||
return Width;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetZoom(const vtkm::Float32 &zoom)
|
||||
{
|
||||
if(zoom <= 0) throw vtkm::cont::ErrorControlBadValue("Camera zoom must be greater than zero.");
|
||||
if(Zoom != zoom)
|
||||
{
|
||||
IsViewDirty = true;
|
||||
Zoom = zoom;
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Float32 GetZoom() const
|
||||
{
|
||||
return Zoom;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetFieldOfView(const vtkm::Float32 °rees)
|
||||
{
|
||||
if(degrees <= 0) throw vtkm::cont::ErrorControlBadValue("Camera feild of view must be greater than zero.");
|
||||
if(degrees > 180) throw vtkm::cont::ErrorControlBadValue("Camera feild of view must be less than 180.");
|
||||
// fov is stored as a half angle
|
||||
vtkm::Float32 newFOVY = (vtkm::Float32(Height) / vtkm::Float32(Width)) * degrees;
|
||||
vtkm::Float32 newFOVX = degrees;
|
||||
if(newFOVX != FovX) IsViewDirty = true;
|
||||
if(newFOVY != FovY) IsViewDirty = true;
|
||||
FovX = newFOVX;
|
||||
FovY = newFOVY;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Float32 GetFieldOfView() const
|
||||
{
|
||||
return FovX;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetUp(const vtkm::Vec<vtkm::Float32, 3> &up)
|
||||
{
|
||||
if(Up != up)
|
||||
{
|
||||
Up = up;
|
||||
vtkm::Normalize(Up);
|
||||
IsViewDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Vec<vtkm::Float32, 3> GetUp() const
|
||||
{
|
||||
return Up;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetLookAt(const vtkm::Vec<vtkm::Float32, 3> &lookAt)
|
||||
{
|
||||
if(LookAt != lookAt)
|
||||
{
|
||||
LookAt = lookAt;
|
||||
IsViewDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Vec<vtkm::Float32, 3> GetLookAt() const
|
||||
{
|
||||
return LookAt;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetPosition(const vtkm::Vec<vtkm::Float32, 3> &position)
|
||||
{
|
||||
if(LookAt != position)
|
||||
{
|
||||
Position = position;
|
||||
IsViewDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Vec<vtkm::Float32, 3> GetPosition() const
|
||||
{
|
||||
return Position;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void ResetIsViewDirty()
|
||||
{
|
||||
IsViewDirty = false;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
bool GetIsViewDirty() const
|
||||
{
|
||||
return IsViewDirty;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void CreateRays(Ray &rays)
|
||||
{
|
||||
|
||||
if(IsResDirty) rays.resize(Height * Width);
|
||||
IsResDirty = false;
|
||||
//Set the origin of the ray back to the camera position
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::Float32 > >( MemSet< vtkm::Float32>( Position[0] ) )
|
||||
.Invoke( rays.OriginX );
|
||||
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::Float32 > >( MemSet< vtkm::Float32>( Position[1] ) )
|
||||
.Invoke( rays.OriginY );
|
||||
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::Float32 > >( MemSet< vtkm::Float32>( Position[2] ) )
|
||||
.Invoke( rays.OriginZ );
|
||||
|
||||
//Reset the camera look vector
|
||||
Look = LookAt - Position;
|
||||
vtkm::Normalize(Look);
|
||||
std::cout<<"******Loook "<<Look<<std::endl;
|
||||
std::cout<<"******Pos "<<Position<<std::endl;
|
||||
//Create the ray direction
|
||||
vtkm::worklet::DispatcherMapField< PerspectiveRayGen >( PerspectiveRayGen(Width,
|
||||
Height,
|
||||
FovX,
|
||||
FovY,
|
||||
Look,
|
||||
Up,
|
||||
Zoom) )
|
||||
.Invoke(rays.DirX,
|
||||
rays.DirY,
|
||||
rays.DirZ); //X Y Z
|
||||
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::Float32 > >( MemSet< vtkm::Float32 >( 1e12f ) )
|
||||
.Invoke( rays.Distance );
|
||||
|
||||
//Reset the Rays Hit Index to -2
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::Id > >( MemSet< vtkm::Id >( -2 ) )
|
||||
.Invoke( rays.HitIdx );
|
||||
|
||||
} //create rays
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void CreateRays(VolumeRay &rays)
|
||||
{
|
||||
|
||||
if(IsResDirty) rays.resize(Height * Width);
|
||||
IsResDirty = false;
|
||||
|
||||
//Reset the camera look vector
|
||||
Look = LookAt - Position;
|
||||
vtkm::Normalize(Look);
|
||||
std::cout<<"******Loook "<<Look<<std::endl;
|
||||
std::cout<<"******Pos "<<Position<<std::endl;
|
||||
//Create the ray direction
|
||||
vtkm::worklet::DispatcherMapField< PerspectiveRayGen >( PerspectiveRayGen(Width,
|
||||
Height,
|
||||
FovX,
|
||||
FovY,
|
||||
Look,
|
||||
Up,
|
||||
Zoom) )
|
||||
.Invoke(rays.DirX,
|
||||
rays.DirY,
|
||||
rays.DirZ); //X Y Z
|
||||
|
||||
} //create rays
|
||||
}; // class camera
|
||||
}}}//namespace vtkm::rendering::raytracing
|
||||
#endif //vtk_m_rendering_raytracing_Camera_h
|
254
vtkm/rendering/raytracing/Ray.h
Normal file
254
vtkm/rendering/raytracing/Ray.h
Normal file
@ -0,0 +1,254 @@
|
||||
//============================================================================
|
||||
// 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_raytracing_Ray_h
|
||||
#define vtk_m_rendering_raytracing_Ray_h
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
namespace raytracing {
|
||||
|
||||
class Ray
|
||||
{
|
||||
public:
|
||||
|
||||
// composite vectors to hold array handles
|
||||
vtkm::cont::ArrayHandleCompositeVectorType<vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> >::type Intersection;
|
||||
|
||||
vtkm::cont::ArrayHandleCompositeVectorType<vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> >::type Normal;
|
||||
|
||||
vtkm::cont::ArrayHandleCompositeVectorType<vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> >::type Origin;
|
||||
|
||||
vtkm::cont::ArrayHandleCompositeVectorType<vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> >::type Dir;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> IntersectionX; //ray Normal
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> IntersectionY;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> IntersectionZ;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> NormalX; //ray Normal
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> NormalY;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> NormalZ;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> OriginX; //ray Origin
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> OriginY;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> OriginZ;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> DirX; //ray Dir
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> DirY;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> DirZ;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> U; //barycentric coordinates
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> V;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> Distance; //distance to hit
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> Scalar; //scalar
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> HitIdx;
|
||||
|
||||
vtkm::Int32 NumRays;
|
||||
VTKM_CONT_EXPORT
|
||||
Ray()
|
||||
{
|
||||
NumRays = 0;
|
||||
vtkm::IdComponent inComp[3];
|
||||
inComp[0] = 0;
|
||||
inComp[1] = 1;
|
||||
inComp[2] = 2;
|
||||
Intersection = vtkm::cont::make_ArrayHandleCompositeVector( IntersectionX, inComp[0],
|
||||
IntersectionY, inComp[1],
|
||||
IntersectionZ, inComp[2]);
|
||||
|
||||
Normal = vtkm::cont::make_ArrayHandleCompositeVector( NormalX, inComp[0],
|
||||
NormalY, inComp[1],
|
||||
NormalZ, inComp[2]);
|
||||
|
||||
Origin = vtkm::cont::make_ArrayHandleCompositeVector( OriginX, inComp[0],
|
||||
OriginY, inComp[1],
|
||||
OriginZ, inComp[2]);
|
||||
|
||||
Dir = vtkm::cont::make_ArrayHandleCompositeVector( DirX, inComp[0],
|
||||
DirY, inComp[1],
|
||||
DirZ, inComp[2]);
|
||||
}
|
||||
VTKM_CONT_EXPORT
|
||||
Ray( const vtkm::Int32 size )
|
||||
{
|
||||
NumRays = size;
|
||||
|
||||
IntersectionX.Allocate( NumRays );
|
||||
IntersectionY.Allocate( NumRays );
|
||||
IntersectionZ.Allocate( NumRays );
|
||||
|
||||
NormalX.Allocate( NumRays );
|
||||
NormalY.Allocate( NumRays );
|
||||
NormalZ.Allocate( NumRays );
|
||||
|
||||
OriginX.Allocate( NumRays );
|
||||
OriginY.Allocate( NumRays );
|
||||
OriginZ.Allocate( NumRays );
|
||||
|
||||
DirX.Allocate( NumRays );
|
||||
DirY.Allocate( NumRays );
|
||||
DirZ.Allocate( NumRays );
|
||||
|
||||
U.Allocate( NumRays );
|
||||
V.Allocate( NumRays );
|
||||
Distance.Allocate( NumRays );
|
||||
Scalar.Allocate( NumRays );
|
||||
|
||||
HitIdx.Allocate( NumRays );
|
||||
|
||||
vtkm::IdComponent inComp[3];
|
||||
inComp[0] = 0;
|
||||
inComp[1] = 1;
|
||||
inComp[2] = 2;
|
||||
|
||||
Intersection = vtkm::cont::make_ArrayHandleCompositeVector( IntersectionX, inComp[0],
|
||||
IntersectionY, inComp[1],
|
||||
IntersectionZ, inComp[2]);
|
||||
|
||||
Normal = vtkm::cont::make_ArrayHandleCompositeVector( NormalX, inComp[0],
|
||||
NormalY, inComp[1],
|
||||
NormalZ, inComp[2]);
|
||||
|
||||
Origin = vtkm::cont::make_ArrayHandleCompositeVector( OriginX, inComp[0],
|
||||
OriginY, inComp[1],
|
||||
OriginZ, inComp[2]);
|
||||
|
||||
Dir = vtkm::cont::make_ArrayHandleCompositeVector( DirX, inComp[0],
|
||||
DirY, inComp[1],
|
||||
DirZ, inComp[2]);
|
||||
}
|
||||
VTKM_CONT_EXPORT
|
||||
void resize( const vtkm::Int32 newSize )
|
||||
{
|
||||
if(newSize == NumRays) return; //nothing to do
|
||||
|
||||
NumRays = newSize;
|
||||
|
||||
IntersectionX.Allocate( NumRays );
|
||||
IntersectionY.Allocate( NumRays );
|
||||
IntersectionZ.Allocate( NumRays );
|
||||
|
||||
NormalX.Allocate( NumRays );
|
||||
NormalY.Allocate( NumRays );
|
||||
NormalZ.Allocate( NumRays );
|
||||
|
||||
OriginX.Allocate( NumRays );
|
||||
OriginY.Allocate( NumRays );
|
||||
OriginZ.Allocate( NumRays );
|
||||
|
||||
DirX.Allocate( NumRays );
|
||||
DirY.Allocate( NumRays );
|
||||
DirZ.Allocate( NumRays );
|
||||
|
||||
U.Allocate( NumRays );
|
||||
V.Allocate( NumRays );
|
||||
Distance.Allocate( NumRays );
|
||||
Scalar.Allocate( NumRays );
|
||||
|
||||
HitIdx.Allocate( NumRays );
|
||||
}
|
||||
|
||||
};// class ray
|
||||
|
||||
class VolumeRay
|
||||
{
|
||||
public:
|
||||
|
||||
vtkm::cont::ArrayHandleCompositeVectorType<vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> >::type Dir;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> DirX; //ray Dir
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> DirY;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> DirZ;
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> MinDistance; //distance to hit
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> MaxDistance; //distance to hit
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> HitIndex;
|
||||
vtkm::Int32 NumRays;
|
||||
VTKM_CONT_EXPORT
|
||||
VolumeRay()
|
||||
{
|
||||
NumRays = 0;
|
||||
vtkm::IdComponent inComp[3];
|
||||
inComp[0] = 0;
|
||||
inComp[1] = 1;
|
||||
inComp[2] = 2;
|
||||
|
||||
Dir = vtkm::cont::make_ArrayHandleCompositeVector( DirX, inComp[0],
|
||||
DirY, inComp[1],
|
||||
DirZ, inComp[2]);
|
||||
}
|
||||
VTKM_CONT_EXPORT
|
||||
VolumeRay( const vtkm::Int32 size )
|
||||
{
|
||||
NumRays = size;
|
||||
|
||||
DirX.Allocate( NumRays );
|
||||
DirY.Allocate( NumRays );
|
||||
DirZ.Allocate( NumRays );
|
||||
|
||||
MinDistance.Allocate( NumRays );
|
||||
MaxDistance.Allocate( NumRays );
|
||||
HitIndex.Allocate( NumRays );
|
||||
|
||||
vtkm::IdComponent inComp[3];
|
||||
inComp[0] = 0;
|
||||
inComp[1] = 1;
|
||||
inComp[2] = 2;
|
||||
|
||||
|
||||
Dir = vtkm::cont::make_ArrayHandleCompositeVector( DirX, inComp[0],
|
||||
DirY, inComp[1],
|
||||
DirZ, inComp[2]);
|
||||
}
|
||||
VTKM_CONT_EXPORT
|
||||
void resize( const vtkm::Int32 newSize )
|
||||
{
|
||||
if(newSize == NumRays) return; //nothing to do
|
||||
|
||||
NumRays = newSize;
|
||||
|
||||
DirX.Allocate( NumRays );
|
||||
DirY.Allocate( NumRays );
|
||||
DirZ.Allocate( NumRays );
|
||||
|
||||
MinDistance.Allocate( NumRays );
|
||||
MaxDistance.Allocate( NumRays );
|
||||
HitIndex.Allocate( NumRays );
|
||||
|
||||
}
|
||||
|
||||
};// class ray
|
||||
|
||||
}}}//namespace vtkm::rendering::raytracing
|
||||
#endif //vtk_m_rendering_raytracing_Ray_h
|
32
vtkm/rendering/raytracing/RayTracingTypeDefs.h
Normal file
32
vtkm/rendering/raytracing/RayTracingTypeDefs.h
Normal file
@ -0,0 +1,32 @@
|
||||
//============================================================================
|
||||
// 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_raytracing_RayTracingTypeDefs_h
|
||||
#define vtk_m_rendering_raytracing_RayTracingTypeDefs_h
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
namespace raytracing {
|
||||
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > ColorBuffer4f;
|
||||
typedef vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8,4> > ColorBuffer4b;
|
||||
|
||||
|
||||
}}}//namespace vtkm::rendering::raytracing
|
||||
#endif //vtk_m_rendering_raytracing_RayTracingTypeDefs_h
|
725
vtkm/rendering/raytracing/VolumeRendererUniform.h
Normal file
725
vtkm/rendering/raytracing/VolumeRendererUniform.h
Normal file
@ -0,0 +1,725 @@
|
||||
#ifndef vtk_m_rendering_raytracing_VolumeRendererUniform_h
|
||||
#define vtk_m_rendering_raytracing_VolumeRendererUniform_h
|
||||
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/ErrorControlBadValue.h>
|
||||
#include <vtkm/rendering/ColorTable.h>
|
||||
#include <vtkm/rendering/raytracing/Ray.h>
|
||||
#include <vtkm/rendering/raytracing/Camera.h>
|
||||
#include <vtkm/rendering/raytracing/RayTracingTypeDefs.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
|
||||
namespace vtkm {
|
||||
namespace rendering{
|
||||
namespace raytracing{
|
||||
class VUniWriter
|
||||
{
|
||||
public:
|
||||
static void WriteDepthBufferVR(vtkm::rendering::raytracing::VolumeRay &rays, vtkm::Int32 width, vtkm::Int32 height)
|
||||
{
|
||||
for(vtkm::Int32 i = 0; i < height* width; i++)
|
||||
{
|
||||
if(rays.MinDistance.GetPortalControl().Get(i) < 0)
|
||||
{
|
||||
rays.MinDistance.GetPortalControl().Set(i,0);
|
||||
}
|
||||
}
|
||||
vtkm::Float32 maxVal= vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
||||
::Reduce(rays.MinDistance,
|
||||
0.f,
|
||||
vtkm::rendering::raytracing::MaxValue());
|
||||
|
||||
vtkm::Float32 minVal= vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
||||
::Reduce(rays.MinDistance,
|
||||
1e12f,
|
||||
vtkm::rendering::raytracing::MinValue());
|
||||
|
||||
FILE *pnm;
|
||||
pnm = fopen("VRDepth.pnm", "w");
|
||||
if( !pnm ) std::cout<<"Could not open pnm file\n";
|
||||
fprintf(pnm, "P%c %d %d 255\n",'6', width, height);
|
||||
vtkm::Int32 size = height * width;
|
||||
unsigned char pixel[3];
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
vtkm::Float32 d = rays.MinDistance.GetPortalControl().Get(i);
|
||||
d = (d - minVal) / (maxVal);
|
||||
pixel[0] = (unsigned char) (d*255.f);
|
||||
pixel[1] = pixel[0];
|
||||
pixel[2] = pixel[0];
|
||||
fwrite(pixel, sizeof(unsigned char), 3, pnm);
|
||||
}
|
||||
fclose(pnm);
|
||||
}
|
||||
|
||||
static void WriteColorBufferVR(vtkm::rendering::raytracing::ColorBuffer4f &rgba,
|
||||
vtkm::Int32 width,
|
||||
vtkm::Int32 height)
|
||||
{
|
||||
FILE *pnm;
|
||||
pnm = fopen("VRColor.pnm", "w");
|
||||
if( !pnm ) std::cout<<"Could not open pnm file\n";
|
||||
fprintf(pnm, "P%c %d %d 255\n",'6', width, height);
|
||||
vtkm::Int32 size = height * width;
|
||||
unsigned char pixel[3];
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
vtkm::Vec<vtkm::Float32,4> color = rgba.GetPortalControl().Get(i);
|
||||
pixel[0] = (unsigned char) (color[3] * color[0]*255.f);
|
||||
pixel[1] = (unsigned char) (color[3] * color[1]*255.f);
|
||||
pixel[2] = (unsigned char) (color[3] * color[2]*255.f);
|
||||
fwrite(pixel, sizeof(unsigned char), 3, pnm);
|
||||
}
|
||||
fclose(pnm);
|
||||
}
|
||||
};
|
||||
template< typename DeviceAdapter>
|
||||
class VolumeRendererUniform
|
||||
{
|
||||
public:
|
||||
|
||||
class Sampler : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
private:
|
||||
typedef typename vtkm::cont::ArrayHandleUniformPointCoordinates UniformArrayHandle;
|
||||
typedef typename UniformArrayHandle::ExecutionTypes<DeviceAdapter>::PortalConst UniformConstPortal;
|
||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > ColorArrayHandle;
|
||||
typedef typename ColorArrayHandle::ExecutionTypes<DeviceAdapter>::PortalConst ColorArrayPortal;
|
||||
//vtkm::Float32 BoundingBox[6];
|
||||
vtkm::Float32 SampleDistance;
|
||||
vtkm::Vec<vtkm::Float32,3> CameraPosition;
|
||||
vtkm::Vec<vtkm::Float32,3> Origin;
|
||||
vtkm::Vec<vtkm::Float32,3> InvSpacing;
|
||||
vtkm::Id3 PointDimensions;
|
||||
vtkm::Float32 MinScalar;
|
||||
vtkm::Float32 InverseDeltaScalar;
|
||||
ColorArrayPortal ColorMap;
|
||||
vtkm::Id ColorMapSize;
|
||||
UniformConstPortal Coordinates;
|
||||
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell,3> Conn;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
Sampler(vtkm::Vec<vtkm::Float32,3> cameraPosition,
|
||||
const ColorArrayHandle &colorMap,
|
||||
const UniformArrayHandle &coordinates,
|
||||
vtkm::cont::CellSetStructured<3> &cellset,
|
||||
const vtkm::Float32 &minScalar,
|
||||
const vtkm::Float32 &maxScalar,
|
||||
const vtkm::Float32 &sampleDistance)
|
||||
: CameraPosition(cameraPosition),
|
||||
ColorMap( colorMap.PrepareForInput( DeviceAdapter() )),
|
||||
Coordinates(coordinates.PrepareForInput( DeviceAdapter() )),
|
||||
Conn( cellset.PrepareForInput( DeviceAdapter(),
|
||||
vtkm::TopologyElementTagPoint(),
|
||||
vtkm::TopologyElementTagCell() )),
|
||||
MinScalar(minScalar),
|
||||
SampleDistance(sampleDistance)
|
||||
{
|
||||
ColorMapSize = colorMap.GetNumberOfValues() - 1;
|
||||
|
||||
Origin = Coordinates.GetOrigin();
|
||||
PointDimensions = Conn.GetPointDimensions();
|
||||
vtkm::Vec<vtkm::Float32,3> spacing = Coordinates.GetSpacing();
|
||||
std::cout<<"Spacing "<<spacing<<std::endl;
|
||||
InvSpacing[0] = 1.f / spacing[0];
|
||||
InvSpacing[1] = 1.f / spacing[1];
|
||||
InvSpacing[2] = 1.f / spacing[2];
|
||||
std::cout<<"Max s "<<maxScalar<<" min s "<<minScalar<<std::endl;
|
||||
if((maxScalar - minScalar) != 0.f) InverseDeltaScalar = 1.f / (maxScalar - minScalar);
|
||||
else InverseDeltaScalar = minScalar;
|
||||
}
|
||||
typedef void ControlSignature(FieldIn<>,
|
||||
FieldIn<>,
|
||||
FieldIn<>,
|
||||
FieldOut<>,
|
||||
ExecObject);
|
||||
typedef void ExecutionSignature(_1,
|
||||
_2,
|
||||
_3,
|
||||
_4,
|
||||
_5);
|
||||
VTKM_EXEC_EXPORT
|
||||
void
|
||||
LocateCell(const vtkm::Vec<vtkm::Float32,3> &point,
|
||||
vtkm::Vec<vtkm::Id,8> &cellIndices) const
|
||||
{
|
||||
vtkm::Vec<vtkm::Float32,3> temp = point;
|
||||
//make sure that if we border the upper edge, we sample the correct cell
|
||||
if(temp[0] == vtkm::Float32(PointDimensions[0] - 1)) temp[0] = vtkm::Float32(PointDimensions[0] - 2);
|
||||
if(temp[1] == vtkm::Float32(PointDimensions[1] - 1)) temp[0] = vtkm::Float32(PointDimensions[1] - 2);
|
||||
if(temp[2] == vtkm::Float32(PointDimensions[2] - 1)) temp[0] = vtkm::Float32(PointDimensions[2] - 2);
|
||||
temp = temp - Origin;
|
||||
temp = temp * InvSpacing;
|
||||
vtkm::Vec<vtkm::Id,3> cell = temp;
|
||||
//TODO: Just do this manually, this just does unneeded calcs
|
||||
//cellId = Conn.LogicalToFlatCellIndex(cell);
|
||||
//cellIndices = Conn.GetIndices(cellId);
|
||||
cellIndices[0] = (cell[2] * PointDimensions[1] + cell[1]) * PointDimensions[0] + cell[0];
|
||||
cellIndices[1] = cellIndices[0] + 1;
|
||||
cellIndices[2] = cellIndices[1] + PointDimensions[0];
|
||||
cellIndices[3] = cellIndices[2] - 1;
|
||||
cellIndices[4] = cellIndices[0] + PointDimensions[0]*PointDimensions[1];
|
||||
cellIndices[5] = cellIndices[4] + 1;
|
||||
cellIndices[6] = cellIndices[5] + PointDimensions[0];
|
||||
cellIndices[7] = cellIndices[6] - 1;
|
||||
}
|
||||
|
||||
template<typename ScalarType, typename ScalarStorageTag>
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const vtkm::Vec<vtkm::Float32,3> &rayDir,
|
||||
const vtkm::Float32 &minDistance,
|
||||
const vtkm::Float32 &maxDistance,
|
||||
vtkm::Vec<vtkm::Float32,4> &color,
|
||||
vtkm::exec::ExecutionWholeArrayConst<ScalarType, ScalarStorageTag> &scalars) const
|
||||
{
|
||||
color[0] = 0.f;
|
||||
color[1] = 0.f;
|
||||
color[2] = 0.f;
|
||||
color[3] = 0.f;
|
||||
if(minDistance == -1.f) return; //TODO: Compact? or just image subset...
|
||||
//get the initial sample position;
|
||||
vtkm::Float32 currentDistance = minDistance + SampleDistance; //Move the ray forward some epsilon
|
||||
vtkm::Float32 lastSample = maxDistance - SampleDistance;
|
||||
vtkm::Vec<vtkm::Float32,3> sampleLocation = CameraPosition + currentDistance * rayDir;
|
||||
/*
|
||||
7----------6
|
||||
/| /|
|
||||
4----------5 |
|
||||
| | | |
|
||||
| 3--------|-2 z y
|
||||
|/ |/ |/
|
||||
0----------1 |__ x
|
||||
*/
|
||||
vtkm::Vec<vtkm::Float32,3> bottomLeft;
|
||||
bool newCell = true;
|
||||
//check to see if we left the cell
|
||||
//vtkm::Float32 deltaTx = SampleDistance * rayDir[0];
|
||||
//vtkm::Float32 deltaTx = SampleDistance * rayDir[0];
|
||||
//vtkm::Float32 deltaTx = SampleDistance * rayDir[0];
|
||||
vtkm::Float32 tx = 0.f;
|
||||
vtkm::Float32 ty = 0.f;
|
||||
vtkm::Float32 tz = 0.f;
|
||||
vtkm::Float32 scalar0 = 0.f;
|
||||
vtkm::Float32 scalar1minus0 = 0.f;
|
||||
vtkm::Float32 scalar2minus3 = 0.f;
|
||||
vtkm::Float32 scalar3 = 0.f;
|
||||
vtkm::Float32 scalar4 = 0.f;
|
||||
vtkm::Float32 scalar5minus4 = 0.f;
|
||||
vtkm::Float32 scalar6minus7 = 0.f;
|
||||
vtkm::Float32 scalar7 = 0.f;
|
||||
while(currentDistance < lastSample)
|
||||
{
|
||||
std::cout.precision(10);
|
||||
|
||||
//std::cout<<sampleLocation<<" current dist "<<currentDistance<<" max "<<lastSample<<" "<<vtkm::Float32(PointDimensions[0] - 1)<<std::endl;
|
||||
if(sampleLocation[0] < Origin[0] || sampleLocation[0] >= vtkm::Float32(PointDimensions[0] - 1)) return;
|
||||
if(sampleLocation[1] < Origin[1] || sampleLocation[1] >= vtkm::Float32(PointDimensions[1] - 1)) return;
|
||||
if(sampleLocation[2] < Origin[2] || sampleLocation[2] >= vtkm::Float32(PointDimensions[2] - 1)) return;
|
||||
if( tx > 1.f || tx < 0.f) newCell = true;
|
||||
if( ty > 1.f || ty < 0.f) newCell = true;
|
||||
if( tz > 1.f || tz < 0.f) newCell = true;
|
||||
|
||||
if(newCell)
|
||||
{
|
||||
vtkm::Vec<vtkm::Id,8> cellIndices;
|
||||
LocateCell(sampleLocation, cellIndices);
|
||||
|
||||
bottomLeft = Coordinates.Get(cellIndices[0]);
|
||||
|
||||
scalar0 = vtkm::Float32(scalars.Get(cellIndices[0]));
|
||||
vtkm::Float32 scalar1 = vtkm::Float32(scalars.Get(cellIndices[1]));
|
||||
vtkm::Float32 scalar2 = vtkm::Float32(scalars.Get(cellIndices[2]));
|
||||
scalar3 = vtkm::Float32(scalars.Get(cellIndices[3]));
|
||||
scalar4 = vtkm::Float32(scalars.Get(cellIndices[4]));
|
||||
vtkm::Float32 scalar5 = vtkm::Float32(scalars.Get(cellIndices[5]));
|
||||
vtkm::Float32 scalar6 = vtkm::Float32(scalars.Get(cellIndices[6]));
|
||||
scalar7 = vtkm::Float32(scalars.Get(cellIndices[7]));
|
||||
|
||||
// save ourselves a couple extra instructions
|
||||
scalar6minus7 = scalar6 - scalar7;
|
||||
scalar5minus4 = scalar5 - scalar4;
|
||||
scalar1minus0 = scalar1 - scalar0;
|
||||
scalar2minus3 = scalar2 - scalar3;
|
||||
|
||||
tx = (sampleLocation[0] - bottomLeft[0]) * InvSpacing[0];
|
||||
ty = (sampleLocation[1] - bottomLeft[1]) * InvSpacing[1];
|
||||
tz = (sampleLocation[2] - bottomLeft[2]) * InvSpacing[2];
|
||||
|
||||
newCell = false;
|
||||
}
|
||||
|
||||
vtkm::Float32 lerped76 = scalar7 + tx * scalar6minus7;
|
||||
vtkm::Float32 lerped45 = scalar4 + tx * scalar5minus4;
|
||||
vtkm::Float32 lerpedTop = lerped45 + ty * (lerped76 - lerped45);
|
||||
|
||||
vtkm::Float32 lerped01 = scalar0 + tx * scalar1minus0;
|
||||
vtkm::Float32 lerped32 = scalar3 + tx * scalar2minus3;
|
||||
vtkm::Float32 lerpedBottom = lerped01 + ty * (lerped32 - lerped01);
|
||||
|
||||
vtkm::Float32 finalScalar = lerpedBottom + tz *(lerpedTop - lerpedBottom);
|
||||
//normalize scalar
|
||||
finalScalar = (finalScalar - MinScalar) * InverseDeltaScalar;
|
||||
|
||||
vtkm::Id colorIndex = vtkm::Id(finalScalar * ColorMapSize);
|
||||
//colorIndex = vtkm::Min(ColorMapSize, vtkm::Max(0,colorIndex));
|
||||
vtkm::Vec<vtkm::Float32,4> sampleColor = ColorMap.Get(colorIndex);
|
||||
//sampleColor[3] = .05f;
|
||||
|
||||
//composite
|
||||
sampleColor[3] *= (1.f - color[3]);
|
||||
color[0] = color[0] + sampleColor[0] * sampleColor[3];
|
||||
color[1] = color[1] + sampleColor[1] * sampleColor[3];
|
||||
color[2] = color[2] + sampleColor[2] * sampleColor[3];
|
||||
color[3] = sampleColor[3] + color[3];
|
||||
//advance
|
||||
currentDistance += SampleDistance;
|
||||
sampleLocation = sampleLocation + SampleDistance * rayDir;
|
||||
|
||||
//this is linear could just do an addition
|
||||
tx = (sampleLocation[0] - bottomLeft[0]) * InvSpacing[0];
|
||||
ty = (sampleLocation[1] - bottomLeft[1]) * InvSpacing[1];
|
||||
tz = (sampleLocation[2] - bottomLeft[2]) * InvSpacing[2];
|
||||
if(color[3] >= 1.f) break;
|
||||
}
|
||||
//color[0] = vtkm::Min(color[0],1.f);
|
||||
//color[1] = vtkm::Min(color[1],1.f);
|
||||
//color[2] = vtkm::Min(color[2],1.f);
|
||||
}
|
||||
}; //Sampler
|
||||
|
||||
class SamplerCellAssoc : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
private:
|
||||
typedef typename vtkm::cont::ArrayHandleUniformPointCoordinates UniformArrayHandle;
|
||||
typedef typename UniformArrayHandle::ExecutionTypes<DeviceAdapter>::PortalConst UniformConstPortal;
|
||||
typedef typename vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > ColorArrayHandle;
|
||||
typedef typename ColorArrayHandle::ExecutionTypes<DeviceAdapter>::PortalConst ColorArrayPortal;
|
||||
//vtkm::Float32 BoundingBox[6];
|
||||
vtkm::Float32 SampleDistance;
|
||||
vtkm::Vec<vtkm::Float32,3> CameraPosition;
|
||||
vtkm::Vec<vtkm::Float32,3> Origin;
|
||||
vtkm::Vec<vtkm::Float32,3> InvSpacing;
|
||||
vtkm::Id3 CellDimensions;
|
||||
vtkm::Float32 MinScalar;
|
||||
vtkm::Float32 InverseDeltaScalar;
|
||||
ColorArrayPortal ColorMap;
|
||||
vtkm::Id ColorMapSize;
|
||||
UniformConstPortal Coordinates;
|
||||
vtkm::exec::ConnectivityStructured<vtkm::TopologyElementTagPoint,vtkm::TopologyElementTagCell,3> Conn;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
SamplerCellAssoc(vtkm::Vec<vtkm::Float32,3> cameraPosition,
|
||||
const ColorArrayHandle &colorMap,
|
||||
const UniformArrayHandle &coordinates,
|
||||
vtkm::cont::CellSetStructured<3> &cellset,
|
||||
const vtkm::Float32 &minScalar,
|
||||
const vtkm::Float32 &maxScalar,
|
||||
const vtkm::Float32 &sampleDistance)
|
||||
: CameraPosition(cameraPosition),
|
||||
ColorMap( colorMap.PrepareForInput( DeviceAdapter() )),
|
||||
Coordinates(coordinates.PrepareForInput( DeviceAdapter() )),
|
||||
Conn( cellset.PrepareForInput( DeviceAdapter(),
|
||||
vtkm::TopologyElementTagPoint(),
|
||||
vtkm::TopologyElementTagCell() )),
|
||||
MinScalar(minScalar),
|
||||
SampleDistance(sampleDistance)
|
||||
{
|
||||
ColorMapSize = colorMap.GetNumberOfValues() - 1;
|
||||
|
||||
Origin = Coordinates.GetOrigin();
|
||||
CellDimensions = Conn.GetPointDimensions();
|
||||
CellDimensions[0] -= 1;
|
||||
CellDimensions[1] -= 1;
|
||||
CellDimensions[2] -= 1;
|
||||
vtkm::Vec<vtkm::Float32,3> spacing = Coordinates.GetSpacing();
|
||||
InvSpacing[0] = 1.f / spacing[0];
|
||||
InvSpacing[1] = 1.f / spacing[1];
|
||||
InvSpacing[2] = 1.f / spacing[2];
|
||||
if((maxScalar - minScalar) != 0.f) InverseDeltaScalar = 1.f / (maxScalar - minScalar);
|
||||
else InverseDeltaScalar = minScalar;
|
||||
}
|
||||
typedef void ControlSignature(FieldIn<>,
|
||||
FieldIn<>,
|
||||
FieldIn<>,
|
||||
FieldOut<>,
|
||||
ExecObject);
|
||||
typedef void ExecutionSignature(_1,
|
||||
_2,
|
||||
_3,
|
||||
_4,
|
||||
_5);
|
||||
VTKM_EXEC_EXPORT
|
||||
void
|
||||
LocateCellId(const vtkm::Vec<vtkm::Float32,3> &point,
|
||||
vtkm::Id &cellId) const
|
||||
{
|
||||
vtkm::Vec<vtkm::Float32,3> temp = point;
|
||||
temp = temp - Origin;
|
||||
temp = temp * InvSpacing;
|
||||
if(temp[0] == vtkm::Float32(CellDimensions[0])) temp[0] = vtkm::Float32(CellDimensions[0] - 1);
|
||||
if(temp[1] == vtkm::Float32(CellDimensions[1])) temp[0] = vtkm::Float32(CellDimensions[1] - 1);
|
||||
if(temp[2] == vtkm::Float32(CellDimensions[2])) temp[0] = vtkm::Float32(CellDimensions[2] - 1);
|
||||
vtkm::Vec<vtkm::Id,3> cell = temp;
|
||||
cellId = (cell[2] * CellDimensions[1] + cell[1]) * CellDimensions[0] + cell[0];
|
||||
}
|
||||
|
||||
template<typename ScalarType, typename ScalarStorageTag>
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const vtkm::Vec<vtkm::Float32,3> &rayDir,
|
||||
const vtkm::Float32 &minDistance,
|
||||
const vtkm::Float32 &maxDistance,
|
||||
vtkm::Vec<vtkm::Float32,4> &color,
|
||||
vtkm::exec::ExecutionWholeArrayConst<ScalarType, ScalarStorageTag> &scalars) const
|
||||
{
|
||||
color[0] = 0.f;
|
||||
color[1] = 0.f;
|
||||
color[2] = 0.f;
|
||||
color[3] = 0.f;
|
||||
if(minDistance == -1.f) return; //TODO: Compact? or just image subset...
|
||||
//get the initial sample position;
|
||||
vtkm::Float32 currentDistance = minDistance + 0.001f; //Move the ray forward some epsilon
|
||||
vtkm::Float32 lastSample = maxDistance - 0.001f;
|
||||
vtkm::Vec<vtkm::Float32,3> sampleLocation = CameraPosition + currentDistance * rayDir;
|
||||
|
||||
/*
|
||||
7----------6
|
||||
/| /|
|
||||
4----------5 |
|
||||
| | | |
|
||||
| 3--------|-2 z y
|
||||
|/ |/ |/
|
||||
0----------1 |__ x
|
||||
*/
|
||||
bool newCell = true;
|
||||
//check to see if we left the cell
|
||||
vtkm::Float32 deltaTx = SampleDistance * rayDir[0];
|
||||
vtkm::Float32 deltaTy = SampleDistance * rayDir[1];
|
||||
vtkm::Float32 deltaTz = SampleDistance * rayDir[2];
|
||||
vtkm::Float32 tx = 2.f;
|
||||
vtkm::Float32 ty = 2.f;
|
||||
vtkm::Float32 tz = 2.f;
|
||||
vtkm::Float32 scalar0 = 0.f;
|
||||
vtkm::Vec<vtkm::Float32,4> sampleColor;
|
||||
while(currentDistance < lastSample)
|
||||
{
|
||||
if( tx > 1.f ) newCell = true;
|
||||
if( ty > 1.f ) newCell = true;
|
||||
if( tz > 1.f ) newCell = true;
|
||||
|
||||
if(newCell)
|
||||
{
|
||||
vtkm::Id cellId;
|
||||
LocateCellId(sampleLocation, cellId);
|
||||
scalar0 = vtkm::Float32(scalars.Get(cellId));
|
||||
scalar0 = (scalar0 - MinScalar) * InverseDeltaScalar;
|
||||
sampleColor = ColorMap.Get(vtkm::Id(scalar0 * ColorMapSize));
|
||||
sampleColor[3] = .05f;
|
||||
vtkm::Vec<vtkm::Float32,3> bottomLeft = Coordinates.Get(cellId);
|
||||
tx = (sampleLocation[0] - bottomLeft[0]) * InvSpacing[0];
|
||||
ty = (sampleLocation[1] - bottomLeft[1]) * InvSpacing[1];
|
||||
tz = (sampleLocation[2] - bottomLeft[2]) * InvSpacing[2];
|
||||
newCell = false;
|
||||
}
|
||||
|
||||
// just repeatably composite
|
||||
vtkm::Float32 alpha = sampleColor[3] * (1.f - color[3]);
|
||||
color[0] = color[0] + sampleColor[0] * alpha;
|
||||
color[1] = color[1] + sampleColor[1] * alpha;
|
||||
color[2] = color[2] + sampleColor[2] * alpha;
|
||||
color[3] = alpha + color[3];
|
||||
//advance
|
||||
currentDistance += SampleDistance;
|
||||
|
||||
//std::cout<<" current color "<<color;
|
||||
if(color[3] >= 1.f) break;
|
||||
|
||||
|
||||
tx += deltaTx;
|
||||
ty += deltaTy;
|
||||
tz += deltaTz;
|
||||
}
|
||||
//color[0] = vtkm::Min(color[0],1.f);
|
||||
//color[1] = vtkm::Min(color[1],1.f);
|
||||
//color[2] = vtkm::Min(color[2],1.f);
|
||||
}
|
||||
}; //SamplerCell
|
||||
|
||||
class CalcRayStart : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
vtkm::Float32 Xmin;
|
||||
vtkm::Float32 Ymin;
|
||||
vtkm::Float32 Zmin;
|
||||
vtkm::Float32 Xmax;
|
||||
vtkm::Float32 Ymax;
|
||||
vtkm::Float32 Zmax;
|
||||
vtkm::Vec<vtkm::Float32,3> CameraPosition;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
CalcRayStart(vtkm::Vec<vtkm::Float32,3> cameraPosition,
|
||||
vtkm::Float32 boundingBox[6])
|
||||
: CameraPosition(cameraPosition)
|
||||
{
|
||||
Xmin = boundingBox[0];
|
||||
Xmax = boundingBox[1];
|
||||
Ymin = boundingBox[2];
|
||||
Ymax = boundingBox[3];
|
||||
Zmin = boundingBox[4];
|
||||
Zmax = boundingBox[5];
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Float32 rcp(vtkm::Float32 f) const { return 1.0f/f;}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Float32 rcp_safe(vtkm::Float32 f) const { return rcp((fabs(f) < 1e-8f) ? 1e-8f : f); }
|
||||
|
||||
typedef void ControlSignature(FieldIn<>,
|
||||
FieldOut<>,
|
||||
FieldOut<>);
|
||||
typedef void ExecutionSignature(_1,
|
||||
_2,
|
||||
_3);
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(const vtkm::Vec<vtkm::Float32,3> &rayDir,
|
||||
vtkm::Float32 &minDistance,
|
||||
vtkm::Float32 &maxDistance) const
|
||||
{
|
||||
vtkm::Float32 dirx = rayDir[0];
|
||||
vtkm::Float32 diry = rayDir[1];
|
||||
vtkm::Float32 dirz = rayDir[2];
|
||||
|
||||
vtkm::Float32 invDirx = rcp_safe(dirx);
|
||||
vtkm::Float32 invDiry = rcp_safe(diry);
|
||||
vtkm::Float32 invDirz = rcp_safe(dirz);
|
||||
|
||||
vtkm::Float32 odirx = CameraPosition[0] * invDirx;
|
||||
vtkm::Float32 odiry = CameraPosition[1] * invDiry;
|
||||
vtkm::Float32 odirz = CameraPosition[2] * invDirz;
|
||||
|
||||
vtkm::Float32 xmin = Xmin * invDirx - odirx;
|
||||
vtkm::Float32 ymin = Ymin * invDiry - odiry;
|
||||
vtkm::Float32 zmin = Zmin * invDirz - odirz;
|
||||
vtkm::Float32 xmax = Xmax * invDirx - odirx;
|
||||
vtkm::Float32 ymax = Ymax * invDiry - odiry;
|
||||
vtkm::Float32 zmax = Zmax * invDirz - odirz;
|
||||
|
||||
|
||||
minDistance = fmaxf(fmaxf(fmaxf(fminf(ymin,ymax),fminf(xmin,xmax)),fminf(zmin,zmax)), 0.f);
|
||||
maxDistance = fminf(fminf(fmaxf(ymin,ymax),fmaxf(xmin,xmax)),fmaxf(zmin,zmax));
|
||||
if(maxDistance < minDistance)
|
||||
{
|
||||
minDistance = -1.f; //flag for miss
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}; //class CalcRayStart
|
||||
|
||||
class CompositeBackground : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
vtkm::Vec<vtkm::Float32,4> BackgroundColor;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
CompositeBackground(const vtkm::Vec<vtkm::Float32,4> &backgroundColor)
|
||||
: BackgroundColor(backgroundColor)
|
||||
{}
|
||||
|
||||
typedef void ControlSignature(FieldInOut<>);
|
||||
typedef void ExecutionSignature(_1);
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(vtkm::Vec<vtkm::Float32,4> &color) const
|
||||
{
|
||||
|
||||
if(color[3] >= 1.f) return;
|
||||
vtkm::Float32 alpha = BackgroundColor[3] * (1.f - color[3]);
|
||||
color[0] = color[0] + BackgroundColor[0] * alpha;
|
||||
color[1] = color[1] + BackgroundColor[1] * alpha;
|
||||
color[2] = color[2] + BackgroundColor[2] * alpha;
|
||||
color[3] = alpha + color[3];
|
||||
}
|
||||
}; //class CompositeBackground
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
VolumeRendererUniform()
|
||||
{
|
||||
IsSceneDirty = false;
|
||||
IsUniformDataSet = true;
|
||||
NumberOfSamples = 300;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
Camera<DeviceAdapter>& GetCamera()
|
||||
{
|
||||
return camera;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetColorMap(const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > &colorMap)
|
||||
{
|
||||
ColorMap = colorMap;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void Init()
|
||||
{
|
||||
camera.CreateRays(Rays);
|
||||
IsSceneDirty = true;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetData(const vtkm::cont::ArrayHandleUniformPointCoordinates &coordinates,
|
||||
vtkm::cont::Field &scalarField,
|
||||
vtkm::Float64 coordsBounds[6],
|
||||
const vtkm::cont::CellSetStructured<3> &cellset)
|
||||
{
|
||||
IsSceneDirty = true;
|
||||
Coordinates = coordinates;
|
||||
ScalarField = &scalarField;
|
||||
Cellset = cellset;
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
BoundingBox[i] = vtkm::Float32(coordsBounds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void Render()
|
||||
{
|
||||
if(IsSceneDirty)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
vtkm::Float32 sampleDistance = 1.f;
|
||||
vtkm::Vec<vtkm::Float32,3> extent;
|
||||
extent[0] = BoundingBox[1] - BoundingBox[0];
|
||||
extent[1] = BoundingBox[3] - BoundingBox[2];
|
||||
extent[2] = BoundingBox[5] - BoundingBox[4];
|
||||
sampleDistance = vtkm::Magnitude(extent) / vtkm::Float32(NumberOfSamples);
|
||||
std::cout<<"SampleDistance "<<sampleDistance<<std::endl;
|
||||
//Clear the framebuffer
|
||||
RGBA.Allocate(camera.GetWidth() * camera.GetHeight());
|
||||
vtkm::worklet::DispatcherMapField< MemSet< vtkm::Vec<vtkm::Float32,4> > >( MemSet< vtkm::Vec<vtkm::Float32,4> >( BackgroundColor ) )
|
||||
.Invoke( RGBA );
|
||||
|
||||
vtkm::worklet::DispatcherMapField< CalcRayStart >( CalcRayStart( camera.GetPosition(), BoundingBox ))
|
||||
.Invoke( Rays.Dir,
|
||||
Rays.MinDistance,
|
||||
Rays.MaxDistance);
|
||||
|
||||
vtkm::Float64 scalarBounds[2];
|
||||
ScalarField->GetBounds(scalarBounds, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
|
||||
bool isAssocPoints = ScalarField->GetAssociation() == vtkm::cont::Field::ASSOC_POINTS;
|
||||
|
||||
if(ScalarField->GetData().IsArrayHandleType( vtkm::cont::ArrayHandle<vtkm::Float32>() ))
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> scalarsHandle;
|
||||
ScalarField->GetData().CastToArrayHandle(scalarsHandle);
|
||||
|
||||
if(isAssocPoints)
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField< Sampler >( Sampler( camera.GetPosition(),
|
||||
ColorMap,
|
||||
Coordinates,
|
||||
Cellset,
|
||||
vtkm::Float32(scalarBounds[0]),
|
||||
vtkm::Float32(scalarBounds[1]),
|
||||
sampleDistance ))
|
||||
.Invoke( Rays.Dir,
|
||||
Rays.MinDistance,
|
||||
Rays.MaxDistance,
|
||||
RGBA,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float32>(scalarsHandle));
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField< SamplerCellAssoc >( SamplerCellAssoc( camera.GetPosition(),
|
||||
ColorMap,
|
||||
Coordinates,
|
||||
Cellset,
|
||||
vtkm::Float32(scalarBounds[0]),
|
||||
vtkm::Float32(scalarBounds[1]),
|
||||
sampleDistance ))
|
||||
.Invoke( Rays.Dir,
|
||||
Rays.MinDistance,
|
||||
Rays.MaxDistance,
|
||||
RGBA,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float32>(scalarsHandle));
|
||||
}
|
||||
|
||||
}
|
||||
else if(ScalarField->GetData().IsArrayHandleType( vtkm::cont::ArrayHandle<vtkm::Float64>() ))
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> scalarsHandle;
|
||||
ScalarField->GetData().CastToArrayHandle(scalarsHandle);
|
||||
if(isAssocPoints)
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField< Sampler >( Sampler( camera.GetPosition(),
|
||||
ColorMap,
|
||||
Coordinates,
|
||||
Cellset,
|
||||
vtkm::Float32(scalarBounds[0]),
|
||||
vtkm::Float32(scalarBounds[1]),
|
||||
sampleDistance ))
|
||||
.Invoke( Rays.Dir,
|
||||
Rays.MinDistance,
|
||||
Rays.MaxDistance,
|
||||
RGBA,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float64>(scalarsHandle));
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField< SamplerCellAssoc >( SamplerCellAssoc( camera.GetPosition(),
|
||||
ColorMap,
|
||||
Coordinates,
|
||||
Cellset,
|
||||
vtkm::Float32(scalarBounds[0]),
|
||||
vtkm::Float32(scalarBounds[1]),
|
||||
sampleDistance ))
|
||||
.Invoke( Rays.Dir,
|
||||
Rays.MinDistance,
|
||||
Rays.MaxDistance,
|
||||
RGBA,
|
||||
vtkm::exec::ExecutionWholeArrayConst<vtkm::Float64>(scalarsHandle));
|
||||
}
|
||||
}
|
||||
vtkm::worklet::DispatcherMapField< CompositeBackground >( CompositeBackground( BackgroundColor ) )
|
||||
.Invoke( RGBA );
|
||||
VUniWriter::WriteColorBufferVR(RGBA, camera.GetWidth(), camera.GetHeight());
|
||||
VUniWriter::WriteDepthBufferVR(Rays, camera.GetWidth(), camera.GetHeight());
|
||||
} //Render
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetNumberOfSamples(vtkm::Int32 numSamples)
|
||||
{
|
||||
if(numSamples > 0) NumberOfSamples = numSamples;
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
void SetBackgroundColor(const vtkm::Vec<vtkm::Float32,4> &backgroundColor)
|
||||
{
|
||||
BackgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool IsSceneDirty;
|
||||
bool IsUniformDataSet;
|
||||
VolumeRay Rays;
|
||||
Camera<DeviceAdapter> camera;
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates Coordinates;
|
||||
vtkm::cont::CellSetStructured<3> Cellset;
|
||||
vtkm::cont::Field *ScalarField;
|
||||
ColorBuffer4f RGBA;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32,4> > ColorMap;
|
||||
vtkm::Float32 BoundingBox[6];
|
||||
vtkm::Float32 NumberOfSamples;
|
||||
vtkm::Vec<vtkm::Float32,4> BackgroundColor;
|
||||
|
||||
};
|
||||
}}} //namespace vtkm::rendering::raytracing
|
||||
#endif
|
68
vtkm/rendering/raytracing/Worklets.h
Normal file
68
vtkm/rendering/raytracing/Worklets.h
Normal file
@ -0,0 +1,68 @@
|
||||
//============================================================================
|
||||
// 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_raytracing_Worklets_h
|
||||
#define vtk_m_rendering_raytracing_Worklets_h
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
namespace raytracing {
|
||||
//
|
||||
// Utility memory set functor
|
||||
//
|
||||
template<class T>
|
||||
class MemSet : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
T Value;
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
MemSet(T value)
|
||||
: Value(value)
|
||||
{}
|
||||
typedef void ControlSignature(FieldOut<>);
|
||||
typedef void ExecutionSignature(_1);
|
||||
VTKM_EXEC_EXPORT
|
||||
void operator()(T &outValue) const
|
||||
{
|
||||
outValue = Value;
|
||||
}
|
||||
}; //class MemSet
|
||||
|
||||
struct MaxValue
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT T operator()(const T& a,const T& b) const
|
||||
{
|
||||
return (a > b) ? a : b;
|
||||
}
|
||||
|
||||
}; //struct MaxValue
|
||||
|
||||
struct MinValue
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT T operator()(const T& a,const T& b) const
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
}; //struct MinValue
|
||||
|
||||
}}}//namespace vtkm::rendering::raytracing
|
||||
#endif //vtk_m_rendering_raytracing_Worklets_h
|
26
vtkm/rendering/testing/CMakeLists.txt
Normal file
26
vtkm/rendering/testing/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
#============================================================================
|
||||
## 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 2014 Sandia Corporation.
|
||||
## Copyright 2014 UT-Battelle, LLC.
|
||||
## Copyright 2014 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.
|
||||
##============================================================================
|
||||
|
||||
set(unit_tests
|
||||
UnitTestSceneRendererVolume.cxx
|
||||
)
|
||||
|
||||
VTKM_unit_tests(SOURCES ${unit_tests})
|
||||
|
273
vtkm/rendering/testing/Makefile
Normal file
273
vtkm/rendering/testing/Makefile
Normal file
@ -0,0 +1,273 @@
|
||||
# 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
|
||||
|
74
vtkm/rendering/testing/UnitTestSceneRendererVolume.cxx
Normal file
74
vtkm/rendering/testing/UnitTestSceneRendererVolume.cxx
Normal file
@ -0,0 +1,74 @@
|
||||
//============================================================================
|
||||
// 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/SceneRendererVolume.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
namespace {
|
||||
|
||||
void TestSceneRendererVolume()
|
||||
{
|
||||
|
||||
// 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("cellvar");
|
||||
const vtkm::cont::CoordinateSystem coords = regularGrid.GetCoordinateSystem();
|
||||
|
||||
vtkm::rendering::SceneRendererVolume<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);
|
||||
sceneRenderer.RenderCells(regularGrid.GetCellSet(), coords, scalarField);
|
||||
}
|
||||
|
||||
}//TestMortonCodes
|
||||
|
||||
} //namespace
|
||||
int UnitTestSceneRendererVolume(int, char *[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestSceneRendererVolume);
|
||||
}
|
Loading…
Reference in New Issue
Block a user