258 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
259 vtkInformation *outInfo = outputVector->GetInformationObject(0);
263 vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
265 vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
267 if (input->CheckAttributes()) {
271 const vtkIdType numCells = input->GetNumberOfCells();
273 vtkDebugMacro(<<
"Number of cells is zero, no data to process.");
276 vtkNew<vtkCellArray> newCells{};
278 newCells->Allocate(numCells);
281 auto regionArr = vtkArrayDownCast<vtkIntArray>(
283 for (vtkIdType i = 0; i < numCells; ++i) {
284 auto cell = input->GetCell(i);
285 auto region = regionArr->GetTypedComponent(i, 0);
287 if (cell->GetCellDimension() != this->GetDimension()) {
291 if (this->GetDimension() == 2) {
292 for (
int j = 0; j < cell->GetNumberOfEdges(); ++j) {
293 auto edge = cell->GetEdge(j);
294 boundaryCellSet.insert(i, j, edge->GetPointIds(), 2, region);
297 switch (static_cast<VTKCellType>(cell->GetCellType())) {
299 case VTK_QUADRATIC_TETRA:
300 case VTK_HIGHER_ORDER_TETRAHEDRON:
301 case VTK_LAGRANGE_TETRAHEDRON: {
302 auto points = cell->GetPointIds()->GetPointer(0);
303 boundaryCellSet.insertTetFaces(i,
points, region);
307 case VTK_QUADRATIC_HEXAHEDRON:
308 case VTK_TRIQUADRATIC_HEXAHEDRON:
309 case VTK_BIQUADRATIC_QUADRATIC_HEXAHEDRON:
310 case VTK_HIGHER_ORDER_HEXAHEDRON:
311 case VTK_LAGRANGE_HEXAHEDRON: {
312 auto points = cell->GetPointIds()->GetPointer(0);
313 boundaryCellSet.insertHexFaces(i,
points, region);
317 case VTK_QUADRATIC_WEDGE:
318 case VTK_QUADRATIC_LINEAR_WEDGE:
319 case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
320 case VTK_HIGHER_ORDER_WEDGE:
321 case VTK_LAGRANGE_WEDGE: {
322 auto points = cell->GetPointIds()->GetPointer(0);
323 boundaryCellSet.insertWedgeFaces(i,
points, region);
327 for (
int j = 0; j < cell->GetNumberOfFaces(); ++j) {
328 auto face = cell->GetFace(j);
332 boundaryCellSet.insert(i, j, face->GetPointIds(),
333 face->GetNumberOfEdges(), region);
341 vtkSmartPointer<vtkIdTypeArray> origCellId{};
342 vtkSmartPointer<vtkIntArray> cellSideId{}, surfRegionId{};
343 if (!this->GetOrigCellArrayName().empty()) {
345 origCellId->SetName(this->GetOrigCellArrayName().c_str());
346 origCellId->SetNumberOfComponents(2);
347 origCellId->SetNumberOfTuples(boundaryCellSet.size());
349 if (!this->GetCellSideArrayName().empty()) {
351 cellSideId->SetName(this->GetCellSideArrayName().c_str());
352 cellSideId->SetNumberOfComponents(2);
353 cellSideId->SetNumberOfTuples(boundaryCellSet.size());
355 if (!this->GetBoundaryRegionArrayName().empty()) {
357 surfRegionId->SetName(this->GetBoundaryRegionArrayName().c_str());
358 surfRegionId->SetNumberOfTuples(boundaryCellSet.size());
362 std::map<std::array<int, 2>,
int> oldRegions2SurfRegions{};
363 for (
const auto &boundaryCell : boundaryCellSet) {
364 auto origCellToInsert = input->GetCell(boundaryCell.sources[0]);
365 auto sideToInsert = this->GetDimension() == 2
366 ? origCellToInsert->GetEdge(boundaryCell.sides[0])
367 : origCellToInsert->GetFace(boundaryCell.sides[0]);
368 auto sideIdx = newCells->InsertNextCell(
369 this->GetDimension() == 2 ? 2 : sideToInsert->GetNumberOfEdges(),
370 sideToInsert->GetPointIds()->GetPointer(0));
372 origCellId->SetTypedTuple(sideIdx, boundaryCell.sources.data());
375 cellSideId->SetTypedTuple(sideIdx, boundaryCell.sides.data());
377 auto surfRegionIter = oldRegions2SurfRegions.emplace(
378 boundaryCell.regions, oldRegions2SurfRegions.size());
380 surfRegionId->SetTypedComponent(sideIdx, 0, surfRegionIter.first->second);
385 if (!this->GetRegionToMaterialArrayName().empty()) {
386 vtkNew<vtkIntArray> region2MaterialId;
387 region2MaterialId->SetName(this->GetRegionToMaterialArrayName().c_str());
388 region2MaterialId->SetNumberOfComponents(2);
389 region2MaterialId->SetNumberOfTuples(oldRegions2SurfRegions.size());
390 for (
const auto &old2newRegion : oldRegions2SurfRegions) {
391 auto newRegion = old2newRegion.second;
392 region2MaterialId->SetComponent(newRegion, 0, old2newRegion.first[0]);
393 region2MaterialId->SetComponent(newRegion, 1, old2newRegion.first[1]);
395 output->GetFieldData()->AddArray(region2MaterialId);
398 if (
auto pointSet = vtkPointSet::SafeDownCast(input)) {
399 output->SetPoints(pointSet->GetPoints());
400 }
else if (
auto rectGrid = vtkRectilinearGrid::SafeDownCast(input)) {
401 rectGrid->GetPoints(output->GetPoints());
403 auto outPoints = output->GetPoints();
404 outPoints->Initialize();
405 outPoints->SetNumberOfPoints(input->GetNumberOfPoints());
406 for (vtkIdType i = 0; i < input->GetNumberOfPoints(); ++i) {
407 outPoints->SetPoint(i, input->GetPoint(i));
410 output->GetPointData()->ShallowCopy(input->GetPointData());
412 if (this->GetDimension() == 2) {
413 output->SetLines(newCells);
415 output->SetPolys(newCells);
418 vtkCellData *outputCD = output->GetCellData();
419 outputCD->AddArray(origCellId);
420 outputCD->AddArray(cellSideId);
421 outputCD->AddArray(surfRegionId);
423 if (output->CheckAttributes()) {
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
std::vector< vtkIdType > points
points given by id in .inp file
std::string MaterialArrayName