VTK-m  2.0
CellTables.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_rendering_raytracing_CellTables_h
11 #define vtk_m_rendering_raytracing_CellTables_h
12 
13 #include <vtkm/Types.h>
15 
16 namespace vtkm
17 {
18 namespace rendering
19 {
20 namespace raytracing
21 {
22 struct CellTables
23 {
24  // CellTypeLookUp: LookUp of Shapes to FaceLookUp
26  {
28  4, // 0 Nothing
29  4, // 1 Vertex
30  4, // 2 (Not Used) Poly Vertex
31  4, // 3 Line
32  4, // 4 (Not Used) Poly Line
33  4, // 5 Triangle
34  4, // 6 (not used) triangle strip
35  4, // 7 Polygon
36  4, // 8 (Not used)Pixel
37  4, // 9 Quad
38  1, // 10 Tetra
39  4, // 11 (Not used) Voxel
40  0, // 12 Hex
41  2, // 13 Wedge
42  3 // 14 Pyramid
43  };
44  return lookup[x];
45  }
46 
47  // FaceLookUp
49  {
51  { 0, 6, 8 }, //hex offset into shapes face list, num faces and number of Indices
52  { 6, 4, 4 }, //tet
53  { 10, 5, 6 }, //wedge
54  { 15, 5, 5 }, //pyramid
55  { -1, 0, 0 } //unsupported shape
56  };
57  return faces[x][y];
58  }
59 
60  // ShapesFaceList:
61  // The convention for the faces is that looking from the outside of
62  // the shape at a face, triangles should wind CCW.
63  // Quads are broken up by {4=quad,a,b,c,d}:
64  // t1 = abc and t2 = acd. Indices of the face are ordered CW, and the mapping
65  // of t1 and t2 become CCW.
66  // Since we know the triangle winding, we could tell
67  // if we hit an inside face or outside face.
69  {
70  VTKM_STATIC_CONSTEXPR_ARRAY vtkm::Int32 shapes[20][5] = { //hex
71  { 4, 0, 1, 5, 4 }, //face 0
72  { 4, 1, 2, 6, 5 },
73  { 4, 3, 7, 6, 2 },
74  { 4, 0, 4, 7, 3 },
75  { 4, 0, 3, 2, 1 },
76  { 4, 4, 5, 6, 7 }, //face 5
77 
78  //tet
79  { 3, 0, 3, 1, -1 },
80  { 3, 1, 2, 3, -1 },
81  { 3, 0, 2, 3, -1 },
82  { 3, 0, 2, 1, -1 },
83 
84  //wedge
85  { 3, 0, 1, 2, -1 },
86  { 3, 3, 5, 4, -1 },
87  { 4, 3, 0, 2, 5 },
88  { 4, 1, 4, 5, 2 },
89  { 4, 0, 3, 4, 1 },
90 
91  //pyramid
92  { 3, 0, 4, 1, -1 },
93  { 3, 1, 2, 4, -1 },
94  { 3, 2, 3, 4, -1 },
95  { 3, 0, 4, 3, -1 },
96  { 4, 3, 2, 1, 0 }
97  };
98  return shapes[x][y];
99  }
100 
101  // ZooTable:
102  // Test of zoo table.
103  // Format (faceNumber, triangle)
105  {
107  { 0, 0, 1, 5 }, // hex
108  { 0, 0, 5, 4 }, { 1, 1, 2, 6 }, { 1, 1, 6, 5 }, { 2, 3, 7, 6 }, { 2, 3, 6, 2 },
109  { 3, 0, 4, 7 }, { 3, 0, 7, 3 }, { 4, 0, 3, 2 }, { 4, 0, 2, 1 }, { 5, 4, 5, 6 },
110  { 5, 4, 6, 7 }, { 0, 0, 3, 1 }, // Tet
111  { 1, 1, 2, 3 }, { 2, 0, 2, 3 }, { 3, 0, 2, 1 }, { 0, 0, 1, 2 }, // Wedge
112  { 1, 3, 5, 4 }, { 2, 3, 0, 2 }, { 2, 3, 2, 5 }, { 3, 1, 4, 5 }, { 3, 1, 5, 2 },
113  { 4, 0, 3, 4 }, { 4, 0, 4, 1 }, { 0, 0, 4, 1 }, // Pyramid
114  { 1, 1, 2, 4 }, { 2, 2, 3, 4 }, { 3, 0, 4, 3 }, { 4, 3, 2, 1 }, { 4, 3, 1, 0 }
115  };
116  return zoo[x][y];
117  }
118 
119  // ZooLookUp:
120  // Offset into zoo table and the
121  // number of triangles for the shape
122  //
124  {
126  { 0, 12 }, //hex offset into shapes face list, num faces and number of Indices
127  { 12, 4 }, //tet
128  { 16, 8 }, //wedge
129  { 24, 6 }, //pyramid
130  { -1, 0 } //unsupported shape
131  };
132  return zoo[x][y];
133  }
134 };
135 
136 } // namespace raytracing
137 } // namespace rendering
138 } // namespace vtkm
139 #endif
vtkm::rendering::raytracing::CellTables::FaceLookUp
VTKM_EXEC vtkm::Int32 FaceLookUp(vtkm::Int32 x, vtkm::Int32 y) const
Definition: CellTables.h:48
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
VTKM_STATIC_CONSTEXPR_ARRAY
#define VTKM_STATIC_CONSTEXPR_ARRAY
Definition: ExportMacros.h:107
vtkm::rendering::raytracing::CellTables::CellTypeLookUp
VTKM_EXEC vtkm::Int32 CellTypeLookUp(vtkm::Int32 x) const
Definition: CellTables.h:25
vtkm::rendering::raytracing::CellTables
Definition: CellTables.h:22
ExportMacros.h
vtkm::rendering::raytracing::CellTables::ZooTable
VTKM_EXEC vtkm::Int32 ZooTable(vtkm::Int32 x, vtkm::Int32 y) const
Definition: CellTables.h:104
vtkm::rendering::raytracing::CellTables::ShapesFaceList
VTKM_EXEC vtkm::Int32 ShapesFaceList(vtkm::Int32 x, vtkm::Int32 y) const
Definition: CellTables.h:68
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::rendering::raytracing::CellTables::ZooLookUp
VTKM_EXEC vtkm::Int32 ZooLookUp(vtkm::Int32 x, vtkm::Int32 y) const
Definition: CellTables.h:123