12 const std::string fname =
13 "chi_mesh::UnpartitionedMesh::CreateCellFromVTKPolyhedron";
16 switch (vtk_cell->GetCellType())
18 case VTK_HEXAGONAL_PRISM:
19 case VTK_PENTAGONAL_PRISM:
37 throw std::logic_error(fname +
": Unsupported 3D cell type encountered.");
41 auto num_cpoints = vtk_cell->GetNumberOfPoints();
42 auto num_cfaces = vtk_cell->GetNumberOfFaces();
44 polyh_cell->vertex_ids.reserve(num_cpoints);
45 auto point_ids = vtk_cell->GetPointIds();
46 for (
int p = 0; p < num_cpoints; ++p)
48 uint64_t point_id = point_ids->GetId(p);
49 polyh_cell->vertex_ids.push_back(point_id);
58 std::vector<std::vector<uint64_t>> face_vids = {{1, 2, 6, 5},
64 for (
int f = 0; f < 6; ++f)
69 for (
int p = 0; p < 4; ++p)
70 face.
vertex_ids.push_back(polyh_cell->vertex_ids[face_vids[f][p]]);
72 polyh_cell->faces.push_back(face);
79 std::vector<uint64_t> remapping = {0, 2, 1, 3, 5, 4};
80 std::vector<uint64_t> remapped(6, 0);
81 for (
int i = 0; i < 6; ++i)
82 remapped[i] = polyh_cell->vertex_ids[remapping[i]];
83 polyh_cell->vertex_ids = remapped;
85 std::vector<std::vector<uint64_t>> face_vids = {
86 {0, 1, 4, 3}, {1, 2, 5, 4}, {2, 0, 3, 5}, {3, 4, 5}, {0, 2, 1}};
87 for (
int f = 0; f < 6; ++f)
92 for (
int p = 0; p < face_vids[f].size(); ++p)
93 face.
vertex_ids.push_back(polyh_cell->vertex_ids[face_vids[f][p]]);
95 polyh_cell->faces.push_back(face);
103 std::vector<std::vector<uint64_t>> face_vids = {{0, 2, 1},
107 for (
int f = 0; f < 4; ++f)
109 LightWeightFace face;
111 face.vertex_ids.reserve(3);
112 for (
int p = 0; p < 3; ++p)
113 face.vertex_ids.push_back(polyh_cell->vertex_ids[face_vids[f][p]]);
115 polyh_cell->faces.push_back(face);
121 polyh_cell->faces.reserve(num_cfaces);
122 for (
int f = 0; f < num_cfaces; ++f)
124 LightWeightFace face;
125 auto vtk_face = vtk_cell->GetFace(f);
126 auto num_face_points = vtk_face->GetNumberOfPoints();
128 face.vertex_ids.reserve(num_face_points);
129 auto face_point_ids = vtk_face->GetPointIds();
130 for (
int p = 0; p < num_face_points; ++p)
132 uint64_t point_id = face_point_ids->GetId(p);
133 face.vertex_ids.push_back(point_id);
136 polyh_cell->faces.push_back(face);
150 const std::string fname =
151 "chi_mesh::UnpartitionedMesh::CreateCellFromVTKPolygon";
154 switch (vtk_cell->GetCellType())
167 throw std::logic_error(fname +
": Unsupported 2D cell type encountered.");
172 auto num_cpoints = vtk_cell->GetNumberOfPoints();
173 auto num_cfaces = num_cpoints;
175 poly_cell->vertex_ids.reserve(num_cpoints);
176 auto point_ids = vtk_cell->GetPointIds();
177 for (
int p = 0; p < num_cpoints; ++p)
179 uint64_t point_id = point_ids->GetId(p);
180 poly_cell->vertex_ids.push_back(point_id);
183 poly_cell->faces.reserve(num_cfaces);
184 for (
int f = 0; f < num_cfaces; ++f)
189 auto v1_id = (f < (num_cfaces - 1)) ? poly_cell->vertex_ids[f + 1]
190 : poly_cell->vertex_ids[0];
196 poly_cell->faces.push_back(face);
207 const std::string fname =
208 "chi_mesh::UnpartitionedMesh::CreateCellFromVTKPolygon";
211 switch (vtk_cell->GetCellType())
217 throw std::logic_error(fname +
": Unsupported 1D cell type encountered.");
222 auto vtk_line = vtkLine::SafeDownCast(vtk_cell);
223 auto num_cpoints = vtk_line->GetNumberOfPoints();
224 auto num_cfaces = num_cpoints;
226 slab_cell->vertex_ids.reserve(num_cpoints);
227 auto point_ids = vtk_line->GetPointIds();
228 for (
int p = 0; p < num_cpoints; ++p)
230 uint64_t point_id = point_ids->GetId(p);
231 slab_cell->vertex_ids.push_back(point_id);
234 slab_cell->faces.reserve(num_cfaces);
235 for (
int f = 0; f < num_cfaces; ++f)
244 slab_cell->faces.push_back(face);
257 auto vtk_vertex = vtkVertex::SafeDownCast(vtk_cell);
258 auto num_cpoints = vtk_vertex->GetNumberOfPoints();
260 point_cell->vertex_ids.reserve(num_cpoints);
261 auto point_ids = vtk_vertex->GetPointIds();
262 for (
int p = 0; p < num_cpoints; ++p)
264 uint64_t point_id = point_ids->GetId(p);
265 point_cell->vertex_ids.push_back(point_id);
static LightWeightCell * CreateCellFromVTKLine(vtkCell *vtk_cell)
static LightWeightCell * CreateCellFromVTKVertex(vtkCell *vtk_cell)
static LightWeightCell * CreateCellFromVTKPolygon(vtkCell *vtk_cell)
static LightWeightCell * CreateCellFromVTKPolyhedron(vtkCell *vtk_cell)
std::vector< uint64_t > vertex_ids