25#ifndef vtk3DLinearGridInternal_h
26#define vtk3DLinearGridInternal_h
48#define MAX_CELL_VERTS 8
53 unsigned char CellType;
54 unsigned char NumVerts;
55 unsigned char NumEdges;
56 unsigned short* Cases;
59 BaseCell(
int cellType)
66 virtual ~BaseCell() =
default;
76 virtual void BuildCases() = 0;
77 void BuildCases(
int numCases,
const vtkIdType**
edges,
int** cases,
unsigned short* caseArray);
81unsigned char BaseCell::Mask[
MAX_CELL_VERTS] = { 1, 2, 4, 8, 16, 32, 64, 128 };
83inline void BaseCell::BuildCases(
84 int numCases,
const vtkIdType**
edges,
int** cases,
unsigned short* caseArray)
86 int caseOffset = numCases;
87 for (
int caseNum = 0; caseNum < numCases; ++caseNum)
89 caseArray[caseNum] = caseOffset;
90 int* triCases = cases[caseNum];
93 const int count = std::find(triCases, triCases + numCases, -1) - triCases;
94 caseArray[caseOffset++] = count;
98 for (
int i = 0; triCases[i] != -1; ++i)
100 edge =
edges[triCases[i]];
101 caseArray[caseOffset++] = edge[0];
102 caseArray[caseOffset++] = edge[1];
109struct TetraCell :
public BaseCell
111 static unsigned short TetraCases[152];
119 this->Cases = TetraCell::TetraCases;
121 ~TetraCell()
override =
default;
122 void BuildCases()
override;
127unsigned short TetraCell::TetraCases[152] = { 0 };
130inline void TetraCell::BuildCases()
133 int numCases = std::pow(2, this->NumVerts);
134 int** cases =
new int*[numCases];
135 for (
int i = 0; i < this->NumEdges; ++i)
139 for (
int i = 0; i < numCases; ++i)
144 BaseCell::BuildCases(numCases,
edges, cases, TetraCell::TetraCases);
151struct HexahedronCell :
public BaseCell
153 static unsigned short HexahedronCases[5432];
161 this->Cases = HexahedronCell::HexahedronCases;
163 ~HexahedronCell()
override =
default;
164 void BuildCases()
override;
168unsigned short HexahedronCell::HexahedronCases[5432] = { 0 };
171inline void HexahedronCell::BuildCases()
174 int numCases = std::pow(2, this->NumVerts);
175 int** cases =
new int*[numCases];
176 for (
int i = 0; i < this->NumEdges; ++i)
180 for (
int i = 0; i < numCases; ++i)
185 BaseCell::BuildCases(numCases,
edges, cases, HexahedronCell::HexahedronCases);
192struct WedgeCell :
public BaseCell
194 static unsigned short WedgeCases[968];
202 this->Cases = WedgeCell::WedgeCases;
204 ~WedgeCell()
override =
default;
205 void BuildCases()
override;
209unsigned short WedgeCell::WedgeCases[968] = { 0 };
212inline void WedgeCell::BuildCases()
215 int numCases = std::pow(2, this->NumVerts);
216 int** cases =
new int*[numCases];
217 for (
int i = 0; i < this->NumEdges; ++i)
221 for (
int i = 0; i < numCases; ++i)
226 BaseCell::BuildCases(numCases,
edges, cases, WedgeCell::WedgeCases);
233struct PyramidCell :
public BaseCell
235 static unsigned short PyramidCases[448];
243 this->Cases = PyramidCell::PyramidCases;
245 ~PyramidCell()
override =
default;
246 void BuildCases()
override;
250unsigned short PyramidCell::PyramidCases[448] = { 0 };
253inline void PyramidCell::BuildCases()
256 int numCases = std::pow(2, this->NumVerts);
257 int** cases =
new int*[numCases];
258 for (
int i = 0; i < this->NumEdges; ++i)
262 for (
int i = 0; i < numCases; ++i)
267 BaseCell::BuildCases(numCases,
edges, cases, PyramidCell::PyramidCases);
274struct VoxelCell :
public BaseCell
276 static unsigned short VoxCases[5432];
284 this->Cases = VoxelCell::VoxCases;
286 ~VoxelCell()
override =
default;
287 void BuildCases()
override;
291unsigned short VoxelCell::VoxCases[5432] = { 0 };
296inline void VoxelCell::BuildCases()
301 constexpr vtkIdType voxEdges[12][2] = { { 0, 1 }, { 1, 3 }, { 2, 3 }, { 0, 2 }, { 4, 5 },
302 { 5, 7 }, { 6, 7 }, { 4, 6 }, { 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 } };
304 for (
int i = 0; i < this->NumEdges; ++i)
306 edges[i] = voxEdges[i];
311 unsigned int numCases = std::pow(2, this->NumVerts);
312 int** cases =
new int*[numCases];
313 unsigned int hexCase, voxCase;
314 for (hexCase = 0; hexCase < numCases; ++hexCase)
316 voxCase = ((hexCase & BaseCell::Mask[0]) ? 1 : 0) << 0;
317 voxCase |= ((hexCase & BaseCell::Mask[1]) ? 1 : 0) << 1;
318 voxCase |= ((hexCase & BaseCell::Mask[2]) ? 1 : 0) << 3;
319 voxCase |= ((hexCase & BaseCell::Mask[3]) ? 1 : 0) << 2;
320 voxCase |= ((hexCase & BaseCell::Mask[4]) ? 1 : 0) << 4;
321 voxCase |= ((hexCase & BaseCell::Mask[5]) ? 1 : 0) << 5;
322 voxCase |= ((hexCase & BaseCell::Mask[6]) ? 1 : 0) << 7;
323 voxCase |= ((hexCase & BaseCell::Mask[7]) ? 1 : 0) << 6;
327 BaseCell::BuildCases(numCases,
edges, cases, VoxelCell::VoxCases);
334struct EmptyCell :
public BaseCell
336 static unsigned short EmptyCases[2];
343 this->Cases = EmptyCell::EmptyCases;
345 ~EmptyCell()
override =
default;
346 void BuildCases()
override {}
350unsigned short EmptyCell::EmptyCases[2] = { 0, 0 };
363 unsigned char NumVerts;
364 const unsigned short* Cases;
368 const unsigned char* Types;
375 HexahedronCell* Hexahedron;
376 PyramidCell* Pyramid;
389 , Hexahedron(nullptr)
404 , CellArray(cellArray)
407 this->Tetra =
new TetraCell;
408 this->Hexahedron =
new HexahedronCell;
409 this->Pyramid =
new PyramidCell;
410 this->Wedge =
new WedgeCell;
411 this->Voxel =
new VoxelCell;
412 this->Empty =
new EmptyCell;
420 delete this->Hexahedron;
421 delete this->Pyramid;
428 CellIter(
const CellIter&) =
default;
431 CellIter& operator=(
const CellIter& cellIter)
434 this->Cell =
nullptr;
436 this->NumVerts = cellIter.NumVerts;
437 this->Cases = cellIter.Cases;
439 this->NumCells = cellIter.NumCells;
440 this->Types = cellIter.Types;
441 this->CellArray = cellIter.CellArray;
446 if (cellIter.ConnIter)
449 this->ConnIter->GoToCell(cellIter.ConnIter->GetCurrentCellId());
453 this->ConnIter =
nullptr;
456 this->Tetra = cellIter.Tetra;
457 this->Hexahedron = cellIter.Hexahedron;
458 this->Pyramid = cellIter.Pyramid;
459 this->Wedge = cellIter.Wedge;
460 this->Voxel = cellIter.Voxel;
461 this->Empty = cellIter.Empty;
469 const unsigned short* GetCase(
unsigned char caseNum)
471 return (this->Cases + this->Cases[caseNum]);
480 this->Cell = this->GetCell(this->Types[cellId]);
481 this->NumVerts = this->Cell->NumVerts;
482 this->Cases = this->Cell->Cases;
483 this->ConnIter->GoToCell(cellId);
487 this->ConnIter->GetCurrentCell(dummy, conn);
493 this->ConnIter->GoToNextCell();
495 if (this->ConnIter->IsDoneWithTraversal())
500 const vtkIdType currentCellId = this->ConnIter->GetCurrentCellId();
505 this->Cell->CellType != this->Types[currentCellId])
507 this->Cell = this->GetCell(this->Types[currentCellId]);
508 this->NumVerts = this->Cell->NumVerts;
509 this->Cases = this->Cell->Cases;
514 this->ConnIter->GetCurrentCell(dummy, conn);
524 this->Cell = this->GetCell(this->Types[cellId]);
525 this->NumVerts = this->Cell->NumVerts;
526 this->Cases = this->Cell->Cases;
527 this->ConnIter->GoToCell(cellId);
531 this->ConnIter->GetCurrentCell(dummy, conn);
536 BaseCell* GetCell(
int cellType)
543 return this->Hexahedron;
547 return this->Pyramid;
object to represent cell connectivity
static int * GetTriangleCases(int caseId)
Return the case table for table-based isocontouring (aka marching cubes style implementations).
static const vtkIdType * GetEdgeArray(vtkIdType edgeId)
Return the ids of the vertices defining edge/face (edgeId/‘faceId’).
static const vtkIdType * GetEdgeArray(vtkIdType edgeId)
Return the ids of the vertices defining edge/face (edgeId/‘faceId’).
static int * GetTriangleCases(int caseId)
Return the case table for table-based isocontouring (aka marching cubes style implementations).
Hold a reference to a vtkObjectBase instance.
static int * GetTriangleCases(int caseId)
Return the case table for table-based isocontouring (aka marching cubes style implementations).
static const vtkIdType * GetEdgeArray(vtkIdType edgeId)
Return the ids of the vertices defining edge/face (edgeId/‘faceId’).
static int * GetTriangleCases(int caseId)
Return the case table for table-based isocontouring (aka marching cubes style implementations).
static const vtkIdType * GetEdgeArray(vtkIdType edgeId)
Return the ids of the vertices defining edge/face (edgeId/‘faceId’).
VTKIOCATALYSTCONDUIT_EXPORT int GetCellType(const std::string &shape)
Get vtk cell type from conduit shape name throw a runtime_error on unsupported type.
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.
vtkSmartPointer< T > TakeSmartPointer(T *obj)
Construct a vtkSmartPointer<T> containing obj.
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)