| 367 | } |
| 368 | |
| 369 | bool GetShape(Ioss::Region* region, const Ioss::GroupingEntity* group_entity, |
| 370 | vtkCellAttribute::CellTypeInfo& cellShapeInfo, int timestep, vtkDGCell* meta, vtkCellGrid* grid, |
| 371 | vtkIOSSUtilities::Cache* cache) |
| 372 | { |
| 373 | (void)timestep; |
| 374 | (void)group_entity; // TODO: If we ever squeeze points on a per-block basis, we must cache |
| 375 | // the nodal coords on group_entity (not nodeblock_entity) and |
| 376 | // use the vtkDGCell's cellSpec.Connectivity to subset points when |
| 377 | // generating the cache entry. |
| 378 | |
| 379 | auto nodeblock_entity = region->get_entity("nodeblock_1", Ioss::EntityType::NODEBLOCK); |
| 380 | if (!nodeblock_entity) |
| 381 | { |
| 382 | return false; |
| 383 | } |
| 384 | vtkSmartPointer<vtkDataArray> cached = (cache |
| 385 | ? vtkDataArray::SafeDownCast(cache->Find(nodeblock_entity, "__vtk_mesh_model_coordinates__")) |
| 386 | : nullptr); |
| 387 | if (cached) |
| 388 | { |
| 389 | vtkLogF(TRACE, "using cached mesh_model_coordinates"); |
| 390 | } |
| 391 | else |
| 392 | { |
| 393 | cached = vtkIOSSUtilities::GetData(nodeblock_entity, "mesh_model_coordinates"); |
| 394 | cached = ChangeComponents(cached, 3); |
| 395 | |
| 396 | if (cache) |
| 397 | { |
| 398 | cache->Insert(group_entity, "__vtk_mesh_model_coordinates__", cached.GetPointer()); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | grid->GetAttributes("coordinates")->AddArray(cached); |
| 403 | |
| 404 | vtkNew<vtkCellAttribute> attribute; |
| 405 | attribute->Initialize("shape", "ℝ³", 3); |
| 406 | cellShapeInfo.DOFSharing = "coordinates"_token; // Required for the shape attribute. |
| 407 | cellShapeInfo.FunctionSpace = meta->GetCellSpec().SourceShape == vtkDGCell::Shape::Vertex |
| 408 | ? "constant"_token |
| 409 | : "HGRAD"_token; // Required for the shape attribute. |
| 410 | cellShapeInfo.ArraysByRole["connectivity"] = meta->GetCellSpec().Connectivity; |
| 411 | cellShapeInfo.ArraysByRole["values"] = cached; |
| 412 | attribute->SetCellTypeInfo(meta->GetClassName(), cellShapeInfo); |
| 413 | grid->AddCellAttribute(attribute); |
| 414 | grid->SetShapeAttribute(attribute); |
| 415 | return true; |
| 416 | } |
| 417 | |
| 418 | VTK_ABI_NAMESPACE_END |
| 419 | } // namespace vtkIOSSCellGridUtilities |
no test coverage detected