Commit 91f26844 authored by Sujin Philip's avatar Sujin Philip Committed by Kitware Robot
Browse files

Merge topic 'remove-VTKM_EXEC_CONSTANT'

e28309f0

 Remove VTKM_EXEC_CONSTANT
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarRobert Maynard <robert.maynard@kitware.com>
Merge-request: !1015
parents e0b1edb4 e28309f0
......@@ -56,12 +56,6 @@ struct VecAxisAlignedPointCoordinatesNumComponents<3>
static const vtkm::IdComponent NUM_COMPONENTS = 8;
};
VTKM_EXEC_CONSTANT
const vtkm::FloatDefault VecAxisAlignedPointCoordinatesOffsetTable[8][3] = {
{ 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f }, { 0.0f, 1.0f, 1.0f }
};
} // namespace detail
/// \brief An implicit vector for point coordinates in axis aligned cells. For
......@@ -110,7 +104,12 @@ public:
VTKM_EXEC_CONT
ComponentType operator[](vtkm::IdComponent index) const
{
const vtkm::FloatDefault* offset = detail::VecAxisAlignedPointCoordinatesOffsetTable[index];
static const vtkm::FloatDefault VecAxisAlignedPointCoordinatesOffsetTable[8][3] = {
{ 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f }, { 1.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 1.0f }, { 0.0f, 1.0f, 1.0f }
};
const auto& offset = VecAxisAlignedPointCoordinatesOffsetTable[index];
return ComponentType(this->Origin[0] + offset[0] * this->Spacing[0],
this->Origin[1] + offset[1] * this->Spacing[1],
this->Origin[2] + offset[2] * this->Spacing[2]);
......
......@@ -17,8 +17,8 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_exec_CellFaces_h
#define vtk_m_exec_CellFaces_h
#ifndef vtk_m_exec_CellEdge_h
#define vtk_m_exec_CellEdge_h
#include <vtkm/Assert.h>
#include <vtkm/CellShape.h>
......@@ -35,224 +35,241 @@ namespace exec
namespace detail
{
static const vtkm::IdComponent MAX_NUM_EDGES = 12;
class CellEdgeTables
{
public:
static const vtkm::IdComponent MAX_NUM_EDGES = 12;
VTKM_EXEC_CONSTANT
static const vtkm::IdComponent NumEdges[vtkm::NUMBER_OF_CELL_SHAPES] = {
0, // 0: CELL_SHAPE_EMPTY
0, // 1: CELL_SHAPE_VERTEX
0, // 2: Unused
0, // 3: CELL_SHAPE_LINE
0, // 4: Unused
3, // 5: CELL_SHAPE_TRIANGLE
0, // 6: Unused
-1, // 7: CELL_SHAPE_POLYGON ---special case---
0, // 8: Unused
4, // 9: CELL_SHAPE_QUAD
6, // 10: CELL_SHAPE_TETRA
0, // 11: Unused
12, // 12: CELL_SHAPE_HEXAHEDRON
9, // 13: CELL_SHAPE_WEDGE
8 // 14: CELL_SHAPE_PYRAMID
};
private:
struct Tables
{
vtkm::IdComponent NumEdges[vtkm::NUMBER_OF_CELL_SHAPES];
vtkm::IdComponent PointsInEdge[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_EDGES][2];
};
VTKM_EXEC_CONSTANT
static const vtkm::IdComponent PointsInEdge[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_EDGES][2] = {
// 0: CELL_SHAPE_EMPTY
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 1: CELL_SHAPE_VERTEX
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 2: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 3: CELL_SHAPE_LINE
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 4: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 5: CELL_SHAPE_TRIANGLE
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 6: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 7: CELL_SHAPE_POLYGON --- special case ---
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 8: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 9: CELL_SHAPE_QUAD
{ { 0, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 0 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 10: CELL_SHAPE_TETRA
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ 0, 3 },
{ 1, 3 },
{ 2, 3 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 11: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 12: CELL_SHAPE_HEXAHEDRON
{ { 0, 1 },
{ 1, 2 },
{ 3, 2 },
{ 0, 3 },
{ 4, 5 },
{ 5, 6 },
{ 7, 6 },
{ 4, 7 },
{ 0, 4 },
{ 1, 5 },
{ 3, 7 },
{ 2, 6 } },
// 13: CELL_SHAPE_WEDGE
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ 3, 4 },
{ 4, 5 },
{ 5, 3 },
{ 0, 3 },
{ 1, 4 },
{ 2, 5 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 14: CELL_SHAPE_PYRAMID
{ { 0, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 0 },
{ 0, 4 },
{ 1, 4 },
{ 2, 4 },
{ 3, 4 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
public:
VTKM_EXEC_CONT static const Tables& Get()
{
static const Tables table = { {
// NumEdges
0, // 0: CELL_SHAPE_EMPTY
0, // 1: CELL_SHAPE_VERTEX
0, // 2: Unused
0, // 3: CELL_SHAPE_LINE
0, // 4: Unused
3, // 5: CELL_SHAPE_TRIANGLE
0, // 6: Unused
-1, // 7: CELL_SHAPE_POLYGON ---special case---
0, // 8: Unused
4, // 9: CELL_SHAPE_QUAD
6, // 10: CELL_SHAPE_TETRA
0, // 11: Unused
12, // 12: CELL_SHAPE_HEXAHEDRON
9, // 13: CELL_SHAPE_WEDGE
8 // 14: CELL_SHAPE_PYRAMID
},
{
// PointsInEdge
// 0: CELL_SHAPE_EMPTY
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 1: CELL_SHAPE_VERTEX
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 2: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 3: CELL_SHAPE_LINE
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 4: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 5: CELL_SHAPE_TRIANGLE
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 6: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 7: CELL_SHAPE_POLYGON --- special case ---
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 8: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 9: CELL_SHAPE_QUAD
{ { 0, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 0 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 10: CELL_SHAPE_TETRA
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ 0, 3 },
{ 1, 3 },
{ 2, 3 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 11: Unused
{ { -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 12: CELL_SHAPE_HEXAHEDRON
{ { 0, 1 },
{ 1, 2 },
{ 3, 2 },
{ 0, 3 },
{ 4, 5 },
{ 5, 6 },
{ 7, 6 },
{ 4, 7 },
{ 0, 4 },
{ 1, 5 },
{ 3, 7 },
{ 2, 6 } },
// 13: CELL_SHAPE_WEDGE
{ { 0, 1 },
{ 1, 2 },
{ 2, 0 },
{ 3, 4 },
{ 4, 5 },
{ 5, 3 },
{ 0, 3 },
{ 1, 4 },
{ 2, 5 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
// 14: CELL_SHAPE_PYRAMID
{ { 0, 1 },
{ 1, 2 },
{ 2, 3 },
{ 3, 0 },
{ 0, 4 },
{ 1, 4 },
{ 2, 4 },
{ 3, 4 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 },
{ -1, -1 } },
} };
return table;
}
};
} // namespace detail
......@@ -264,7 +281,7 @@ static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(vtkm::IdComponen
{
(void)numPoints; // Silence compiler warnings.
VTKM_ASSERT(numPoints == vtkm::CellTraits<CellShapeTag>::NUM_POINTS);
return detail::NumEdges[CellShapeTag::Id];
return detail::CellEdgeTables::Get().NumEdges[CellShapeTag::Id];
}
static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(vtkm::IdComponent numPoints,
......@@ -286,7 +303,7 @@ static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(
}
else
{
return detail::NumEdges[shape.Id];
return detail::CellEdgeTables::Get().NumEdges[shape.Id];
}
}
......@@ -298,15 +315,15 @@ static inline VTKM_EXEC vtkm::Vec<vtkm::IdComponent, 2> CellEdgeLocalIndices(
const vtkm::exec::FunctorBase& worklet)
{
VTKM_ASSUME(edgeIndex >= 0);
VTKM_ASSUME(edgeIndex < detail::MAX_NUM_EDGES);
VTKM_ASSUME(edgeIndex < detail::CellEdgeTables::MAX_NUM_EDGES);
if (edgeIndex >= vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, worklet))
{
worklet.RaiseError("Invalid edge number.");
return vtkm::Vec<vtkm::IdComponent, 2>(0);
}
return vtkm::make_Vec(detail::PointsInEdge[CellShapeTag::Id][edgeIndex][0],
detail::PointsInEdge[CellShapeTag::Id][edgeIndex][1]);
return vtkm::make_Vec(detail::CellEdgeTables::Get().PointsInEdge[CellShapeTag::Id][edgeIndex][0],
detail::CellEdgeTables::Get().PointsInEdge[CellShapeTag::Id][edgeIndex][1]);
}
static inline VTKM_EXEC vtkm::Vec<vtkm::IdComponent, 2> CellEdgeLocalIndices(
......@@ -336,7 +353,7 @@ static inline VTKM_EXEC vtkm::Vec<vtkm::IdComponent, 2> CellEdgeLocalIndices(
const vtkm::exec::FunctorBase& worklet)
{
VTKM_ASSUME(edgeIndex >= 0);
VTKM_ASSUME(edgeIndex < detail::MAX_NUM_EDGES);
VTKM_ASSUME(edgeIndex < detail::CellEdgeTables::MAX_NUM_EDGES);
if (shape.Id == vtkm::CELL_SHAPE_POLYGON)
{
......@@ -344,14 +361,14 @@ static inline VTKM_EXEC vtkm::Vec<vtkm::IdComponent, 2> CellEdgeLocalIndices(
}
else
{
if (edgeIndex >= detail::NumEdges[shape.Id])
if (edgeIndex >= detail::CellEdgeTables::Get().NumEdges[shape.Id])
{
worklet.RaiseError("Invalid edge number.");
return vtkm::Vec<vtkm::IdComponent, 2>(0);
}
return vtkm::make_Vec(detail::PointsInEdge[shape.Id][edgeIndex][0],
detail::PointsInEdge[shape.Id][edgeIndex][1]);
return vtkm::make_Vec(detail::CellEdgeTables::Get().PointsInEdge[shape.Id][edgeIndex][0],
detail::CellEdgeTables::Get().PointsInEdge[shape.Id][edgeIndex][1]);
}
}
......
......@@ -34,156 +34,173 @@ namespace exec
namespace detail
{
static const vtkm::IdComponent MAX_FACE_SIZE = 4;
static const vtkm::IdComponent MAX_NUM_FACES = 6;
class CellFaceTables
{
public:
static const vtkm::IdComponent MAX_FACE_SIZE = 4;
static const vtkm::IdComponent MAX_NUM_FACES = 6;
VTKM_EXEC_CONSTANT
static const vtkm::IdComponent NumFaces[vtkm::NUMBER_OF_CELL_SHAPES] = {
0, // 0: CELL_SHAPE_EMPTY
0, // 1: CELL_SHAPE_VERTEX
0, // 2: Unused
0, // 3: CELL_SHAPE_LINE
0, // 4: Unused
0, // 5: CELL_SHAPE_TRIANGLE
0, // 6: Unused
0, // 7: CELL_SHAPE_POLYGON
0, // 8: Unused
0, // 9: CELL_SHAPE_QUAD
4, // 10: CELL_SHAPE_TETRA
0, // 11: Unused
6, // 12: CELL_SHAPE_HEXAHEDRON
5, // 13: CELL_SHAPE_WEDGE
5 // 14: CELL_SHAPE_PYRAMID
};
private:
struct Tables
{
vtkm::IdComponent NumFaces[vtkm::NUMBER_OF_CELL_SHAPES];
vtkm::IdComponent NumPointsInFace[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_FACES];
vtkm::IdComponent PointsInFace[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_FACES][MAX_FACE_SIZE];
};
VTKM_EXEC_CONSTANT
static const vtkm::IdComponent NumPointsInFace[vtkm::NUMBER_OF_CELL_SHAPES][MAX_NUM_FACES] = {
{ -1, -1, -1, -1, -1, -1 }, // 0: CELL_SHAPE_EMPTY
{ -1, -1, -1, -1, -1, -1 }, // 1: CELL_SHAPE_VERTEX