MCPcopy Create free account
hub / github.com/Kitware/VTK / CreateMixedUnstructuredGrid

Function CreateMixedUnstructuredGrid

IO/CatalystConduit/vtkConduitToDataObject.cxx:970–1043  ·  view source on GitHub ↗

----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

968
969//----------------------------------------------------------------------------
970vtkSmartPointer<vtkDataSet> CreateMixedUnstructuredGrid(
971 const conduit_cpp::Node& topologyNode, const conduit_cpp::Node& coords)
972{
973 auto unstructured = vtkSmartPointer<vtkUnstructuredGrid>::New();
974 // mixed shapes definition
975 conduit_cpp::Node shape_map = topologyNode["elements/shape_map"];
976 auto connectivity = topologyNode["elements/connectivity"];
977 int8_t id;
978 bool working;
979 bool isDevicePointer =
980 vtkConduitArrayUtilities::IsDevicePointer(connectivity.element_ptr(0), id, working);
981 if (isDevicePointer && !working)
982 {
983 throw std::runtime_error("Viskores does not support device" + vtk::to_string(id));
984 }
985
986 // check presence of polyhedra
987 bool hasPolyhedra(false);
988 conduit_index_t nCells = shape_map.number_of_children();
989 for (conduit_index_t i = 0; i < nCells && !hasPolyhedra; ++i)
990 {
991 auto child = shape_map.child(i);
992 int cellType = child.to_int32();
993 hasPolyhedra |= (cellType == VTK_POLYHEDRON);
994 }
995 if (isDevicePointer && hasPolyhedra)
996 {
997 throw std::runtime_error("Viskores does not support VTK_POLYHEDRON cell type");
998 }
999
1000 // if polyhedra are present, the subelements should be present as well.
1001 if (hasPolyhedra &&
1002 !(topologyNode.has_path("subelements/shape") &&
1003 topologyNode.has_path("subelements/shape_map") &&
1004 topologyNode.has_path("subelements/shapes")))
1005 {
1006 throw std::runtime_error("no subelements found for polyhedral cell definition.");
1007 }
1008 if (nCells > 0)
1009 {
1010 unstructured->SetPoints(CreatePoints(coords));
1011 auto numberOfPoints = unstructured->GetNumberOfPoints();
1012
1013 conduit_cpp::Node t_elements = topologyNode["elements"];
1014 conduit_cpp::Node t_elementShapes = topologyNode["elements/shapes"];
1015
1016 auto shapes =
1017 vtkConduitArrayUtilities::MCArrayToVTKArray(conduit_cpp::c_node(&t_elementShapes));
1018 auto elements = vtkConduitArrayUtilities::O2MRelationToVTKCellArray(
1019 numberOfPoints, conduit_cpp::c_node(&t_elements));
1020 if (!elements || !shapes)
1021 {
1022 throw std::runtime_error("elements or elements/shapes not available (nullptr)");
1023 }
1024
1025 if (hasPolyhedra)
1026 {
1027 conduit_cpp::Node t_subelements = topologyNode["subelements"];

Callers 1

CreateMeshFunction · 0.85

Calls 7

SetMixedPolyhedralCellsFunction · 0.85
childMethod · 0.80
CreatePointsFunction · 0.70
NewFunction · 0.50
to_stringFunction · 0.50
SetPointsMethod · 0.45
GetNumberOfPointsMethod · 0.45

Tested by

no test coverage detected