45 {
"none",
"polyhedra",
"all"};
58 polyhedra_(polyhedra),
61 addPointCellLabels_(),
64 const cellModel& tet = *(cellModeller::lookup(
"tet"));
65 const cellModel& pyr = *(cellModeller::lookup(
"pyr"));
66 const cellModel& prism = *(cellModeller::lookup(
"prism"));
67 const cellModel& wedge = *(cellModeller::lookup(
"wedge"));
68 const cellModel& tetWedge = *(cellModeller::lookup(
"tetWedge"));
69 const cellModel&
hex = *(cellModeller::lookup(
"hex"));
75 label nAddPoints = 0, nAddCells = 0;
79 if (polyhedra_ == vtkPolyhedra::none)
83 const cellModel& model =
cellShapes[celli].model();
95 const cell& cFaces = mesh_.cells()[celli];
99 const face&
f = mesh_.faces()[cFaces[cFacei]];
103 nAddCells +=
f.nTriangles();
119 addPointCellLabels_.setSize(nAddPoints);
123 superCells_.setSize(nAddCells);
126 vertLabels_.setSize(
cellShapes.size() + nAddCells);
129 cellTypes_.setSize(
cellShapes.size() + nAddCells);
132 polygonTriangulate triEngine;
135 label addPointi = 0, addCelli = 0;
136 const labelList& faceOwner = mesh.faceOwner();
139 const cellShape& cellShape =
cellShapes[celli];
140 const cellModel& cellModel = cellShape.model();
142 labelList& vtkVerts = vertLabels_[celli];
144 if (polyhedra_ != vtkPolyhedra::all && cellModel == tet)
146 vtkVerts = cellShape;
148 cellTypes_[celli] = VTK_TETRA;
150 else if (polyhedra_ != vtkPolyhedra::all && cellModel == pyr)
152 vtkVerts = cellShape;
154 cellTypes_[celli] = VTK_PYRAMID;
156 else if (polyhedra_ != vtkPolyhedra::all && cellModel == prism)
160 vtkVerts = cellShape;
165 cellTypes_[celli] = VTK_WEDGE;
167 else if (polyhedra_ == vtkPolyhedra::none && cellModel == tetWedge)
171 vtkVerts[0] = cellShape[0];
172 vtkVerts[1] = cellShape[2];
173 vtkVerts[2] = cellShape[1];
174 vtkVerts[3] = cellShape[3];
175 vtkVerts[4] = cellShape[4];
176 vtkVerts[5] = cellShape[3];
178 cellTypes_[celli] = VTK_WEDGE;
180 else if (polyhedra_ != vtkPolyhedra::all && cellModel == wedge)
184 vtkVerts[0] = cellShape[0];
185 vtkVerts[1] = cellShape[1];
186 vtkVerts[2] = cellShape[2];
187 vtkVerts[3] = cellShape[2];
188 vtkVerts[4] = cellShape[3];
189 vtkVerts[5] = cellShape[4];
190 vtkVerts[6] = cellShape[5];
191 vtkVerts[7] = cellShape[6];
193 cellTypes_[celli] = VTK_HEXAHEDRON;
195 else if (polyhedra_ != vtkPolyhedra::all && cellModel ==
hex)
197 vtkVerts = cellShape;
199 cellTypes_[celli] = VTK_HEXAHEDRON;
201 else if (polyhedra_ == vtkPolyhedra::none)
206 addPointCellLabels_[addPointi] = celli;
209 const label newVertexLabel = mesh_.nPoints() + addPointi;
212 bool substituteCell =
true;
214 const labelList& cFaces = mesh_.cells()[celli];
217 const face&
f = mesh_.faces()[cFaces[cFacei]];
218 const bool isOwner = faceOwner[cFaces[cFacei]] == celli;
221 faceList triFcs(
f.size() == 4 ? 0 :
f.nTriangles());
225 triEngine.triangulate
227 UIndirectList<point>(mesh.points(),
f)
229 forAll(triEngine.triPoints(), trii)
231 triFcs[trii] = triEngine.triPoints(trii,
f);
246 substituteCell =
false;
250 thisCelli = mesh_.nCells() + addCelli;
251 superCells_[addCelli++] = celli;
254 labelList& addVtkVerts = vertLabels_[thisCelli];
258 const face& quad = quadFcs[quadI];
269 addVtkVerts[0] = quad[3];
270 addVtkVerts[1] = quad[2];
271 addVtkVerts[2] = quad[1];
272 addVtkVerts[3] = quad[0];
276 addVtkVerts[0] = quad[0];
277 addVtkVerts[1] = quad[1];
278 addVtkVerts[2] = quad[2];
279 addVtkVerts[3] = quad[3];
281 addVtkVerts[4] = newVertexLabel;
283 cellTypes_[thisCelli] = VTK_PYRAMID;
293 substituteCell =
false;
297 thisCelli = mesh_.nCells() + addCelli;
298 superCells_[addCelli++] = celli;
302 labelList& addVtkVerts = vertLabels_[thisCelli];
304 const face& tri = triFcs[triI];
311 addVtkVerts[0] = tri[2];
312 addVtkVerts[1] = tri[1];
313 addVtkVerts[2] = tri[0];
317 addVtkVerts[0] = tri[0];
318 addVtkVerts[1] = tri[1];
319 addVtkVerts[2] = tri[2];
321 addVtkVerts[3] = newVertexLabel;
323 cellTypes_[thisCelli] = VTK_TETRA;
332 cellTypes_[celli] = VTK_POLYHEDRON;
334 const labelList& cFaces = mesh_.cells()[celli];
337 label nData = 1 + cFaces.size();
342 const face&
f = mesh.faces()[cFaces[cFacei]];
346 vtkVerts.setSize(nData);
349 vtkVerts[nData++] = cFaces.size();
354 const face&
f = mesh.faces()[cFaces[cFacei]];
355 const bool isOwner = faceOwner[cFaces[cFacei]] == celli;
358 vtkVerts[nData++] =
f.size();
364 vtkVerts[nData++] =
f[fp];
373 vtkVerts[nData++] =
f[fp];
380 if (polyhedra_ == vtkPolyhedra::none)
382 Pout<<
" Original cells:" << mesh_.nCells()
383 <<
" points:" << mesh_.nPoints()
384 <<
" Additional cells:" << superCells_.size()
385 <<
" additional points:" << addPointCellLabels_.size()
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
void setSize(const label)
Reset size of List.
Initialise the NamedEnum HashTable from the static list of names.
static const char * names[nEnum]
The set of names corresponding to the enumeration Enum.
vtkTopo(const polyMesh &mesh, const vtkPolyhedra &polyhedra)
Construct from components.
static const NamedEnum< vtkPolyhedra, 3 > vtkPolyhedraNames_
Names of groups of cell types retain as polyhedra.
const cellShapeList & cellShapes
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOstream & hex(IOstream &io)
prefixOSstream Pout(cout, "Pout")