37#ifndef vtk3DLinearGridInternal_h
38#define vtk3DLinearGridInternal_h
60#define MAX_CELL_VERTS 8
65 unsigned char CellType;
66 unsigned char NumVerts;
67 unsigned char NumEdges;
68 unsigned short* Cases;
71 BaseCell(
int cellType)
78 virtual ~BaseCell() =
default;
88 virtual void BuildCases() = 0;
89 void BuildCases(
int numCases,
const vtkIdType**
edges,
int** cases,
unsigned short* caseArray);
92unsigned char BaseCell::Mask[
MAX_CELL_VERTS] = { 1, 2, 4, 8, 16, 32, 64, 128 };
94void BaseCell::BuildCases(
95 int numCases,
const vtkIdType**
edges,
int** cases,
unsigned short* caseArray)
97 int caseOffset = numCases;
98 for (
int caseNum = 0; caseNum < numCases; ++caseNum)
100 caseArray[caseNum] = caseOffset;
101 int* triCases = cases[caseNum];
104 const int count = std::find(triCases, triCases + numCases, -1) - triCases;
105 caseArray[caseOffset++] = count;
109 for (
int i = 0; triCases[i] != -1; ++i)
111 edge =
edges[triCases[i]];
112 caseArray[caseOffset++] = edge[0];
113 caseArray[caseOffset++] = edge[1];
120struct TetraCell :
public BaseCell
122 static unsigned short TetraCases[152];
130 this->Cases = this->TetraCases;
132 ~TetraCell()
override =
default;
133 void BuildCases()
override;
137unsigned short TetraCell::TetraCases[152] = { 0 };
140void TetraCell::BuildCases()
143 int numCases = std::pow(2, this->NumVerts);
144 int** cases =
new int*[numCases];
145 for (
int i = 0; i < this->NumEdges; ++i)
149 for (
int i = 0; i < numCases; ++i)
154 BaseCell::BuildCases(numCases,
edges, cases, this->TetraCases);
161struct HexahedronCell :
public BaseCell
163 static unsigned short HexahedronCases[5432];
171 this->Cases = this->HexahedronCases;
173 ~HexahedronCell()
override =
default;
174 void BuildCases()
override;
177unsigned short HexahedronCell::HexahedronCases[5432] = { 0 };
180void HexahedronCell::BuildCases()
183 int numCases = std::pow(2, this->NumVerts);
184 int** cases =
new int*[numCases];
185 for (
int i = 0; i < this->NumEdges; ++i)
189 for (
int i = 0; i < numCases; ++i)
194 BaseCell::BuildCases(numCases,
edges, cases, this->HexahedronCases);
201struct WedgeCell :
public BaseCell
203 static unsigned short WedgeCases[968];
211 this->Cases = this->WedgeCases;
213 ~WedgeCell()
override =
default;
214 void BuildCases()
override;
217unsigned short WedgeCell::WedgeCases[968] = { 0 };
220void WedgeCell::BuildCases()
223 int numCases = std::pow(2, this->NumVerts);
224 int** cases =
new int*[numCases];
225 for (
int i = 0; i < this->NumEdges; ++i)
229 for (
int i = 0; i < numCases; ++i)
234 BaseCell::BuildCases(numCases,
edges, cases, this->WedgeCases);
241struct PyramidCell :
public BaseCell
243 static unsigned short PyramidCases[448];
251 this->Cases = this->PyramidCases;
253 ~PyramidCell()
override =
default;
254 void BuildCases()
override;
257unsigned short PyramidCell::PyramidCases[448] = { 0 };
260void PyramidCell::BuildCases()
263 int numCases = std::pow(2, this->NumVerts);
264 int** cases =
new int*[numCases];
265 for (
int i = 0; i < this->NumEdges; ++i)
269 for (
int i = 0; i < numCases; ++i)
274 BaseCell::BuildCases(numCases,
edges, cases, this->PyramidCases);
281struct VoxelCell :
public BaseCell
283 static unsigned short VoxCases[5432];
291 this->Cases = this->VoxCases;
293 ~VoxelCell()
override =
default;
294 void BuildCases()
override;
297unsigned short VoxelCell::VoxCases[5432] = { 0 };
302void VoxelCell::BuildCases()
307 constexpr vtkIdType voxEdges[12][2] = { { 0, 1 }, { 1, 3 }, { 2, 3 }, { 0, 2 }, { 4, 5 },
308 { 5, 7 }, { 6, 7 }, { 4, 6 }, { 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 } };
310 for (
int i = 0; i < this->NumEdges; ++i)
312 edges[i] = voxEdges[i];
317 unsigned int numCases = std::pow(2, this->NumVerts);
318 int** cases =
new int*[numCases];
319 unsigned int hexCase, voxCase;
320 for (hexCase = 0; hexCase < numCases; ++hexCase)
322 voxCase = ((hexCase & BaseCell::Mask[0]) ? 1 : 0) << 0;
323 voxCase |= ((hexCase & BaseCell::Mask[1]) ? 1 : 0) << 1;
324 voxCase |= ((hexCase & BaseCell::Mask[2]) ? 1 : 0) << 3;
325 voxCase |= ((hexCase & BaseCell::Mask[3]) ? 1 : 0) << 2;
326 voxCase |= ((hexCase & BaseCell::Mask[4]) ? 1 : 0) << 4;
327 voxCase |= ((hexCase & BaseCell::Mask[5]) ? 1 : 0) << 5;
328 voxCase |= ((hexCase & BaseCell::Mask[6]) ? 1 : 0) << 7;
329 voxCase |= ((hexCase & BaseCell::Mask[7]) ? 1 : 0) << 6;
333 BaseCell::BuildCases(numCases,
edges, cases, this->VoxCases);
340struct EmptyCell :
public BaseCell
342 static unsigned short EmptyCases[2];
349 this->Cases = this->EmptyCases;
351 ~EmptyCell()
override =
default;
352 void BuildCases()
override {}
355unsigned short EmptyCell::EmptyCases[2] = { 0, 0 };
368 unsigned char NumVerts;
369 const unsigned short* Cases;
373 const unsigned char* Types;
380 HexahedronCell* Hexahedron;
381 PyramidCell* Pyramid;
394 , Hexahedron(nullptr)
409 , CellArray(cellArray)
412 this->Tetra =
new TetraCell;
413 this->Hexahedron =
new HexahedronCell;
414 this->Pyramid =
new PyramidCell;
415 this->Wedge =
new WedgeCell;
416 this->Voxel =
new VoxelCell;
417 this->Empty =
new EmptyCell;
425 delete this->Hexahedron;
426 delete this->Pyramid;
433 CellIter(
const CellIter&) =
default;
436 CellIter& operator=(
const CellIter& cellIter)
439 this->Cell =
nullptr;
441 this->NumVerts = cellIter.NumVerts;
442 this->Cases = cellIter.Cases;
444 this->NumCells = cellIter.NumCells;
445 this->Types = cellIter.Types;
446 this->CellArray = cellIter.CellArray;
451 if (cellIter.ConnIter)
454 this->ConnIter->GoToCell(cellIter.ConnIter->GetCurrentCellId());
458 this->ConnIter =
nullptr;
461 this->Tetra = cellIter.Tetra;
462 this->Hexahedron = cellIter.Hexahedron;
463 this->Pyramid = cellIter.Pyramid;
464 this->Wedge = cellIter.Wedge;
465 this->Voxel = cellIter.Voxel;
466 this->Empty = cellIter.Empty;
474 const unsigned short* GetCase(
unsigned char caseNum)
476 return (this->Cases + this->Cases[caseNum]);
485 this->Cell = this->GetCell(this->Types[cellId]);
486 this->NumVerts = this->Cell->NumVerts;
487 this->Cases = this->Cell->Cases;
488 this->ConnIter->GoToCell(cellId);
492 this->ConnIter->GetCurrentCell(dummy, conn);
498 this->ConnIter->GoToNextCell();
500 if (this->ConnIter->IsDoneWithTraversal())
505 const vtkIdType currentCellId = this->ConnIter->GetCurrentCellId();
510 this->Cell->CellType != this->Types[currentCellId])
512 this->Cell = this->GetCell(this->Types[currentCellId]);
513 this->NumVerts = this->Cell->NumVerts;
514 this->Cases = this->Cell->Cases;
519 this->ConnIter->GetCurrentCell(dummy, conn);
529 this->Cell = this->GetCell(this->Types[cellId]);
530 this->NumVerts = this->Cell->NumVerts;
531 this->Cases = this->Cell->Cases;
532 this->ConnIter->GoToCell(cellId);
536 this->ConnIter->GetCurrentCell(dummy, conn);
541 BaseCell* GetCell(
int cellType)
548 return this->Hexahedron;
552 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’).
int GetCellType(const Ioss::ElementTopology *topology)
Returns VTK celltype for a Ioss topology element.
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)