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

Method MCGhostArrayToVTKGhostArray

IO/CatalystConduit/vtkConduitArrayUtilities.cxx:273–306  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

271
272//----------------------------------------------------------------------------
273vtkSmartPointer<vtkDataArray> vtkConduitArrayUtilities::MCGhostArrayToVTKGhostArray(
274 const conduit_node* c_mcarray, bool is_cell_data)
275{
276 vtkSmartPointer<vtkUnsignedCharArray> array = vtkSmartPointer<vtkUnsignedCharArray>::New();
277 array->SetName(vtkDataSetAttributes::GhostArrayName());
278
279 const conduit_cpp::Node mcarray = conduit_cpp::cpp_node(const_cast<conduit_node*>(c_mcarray));
280
281 const int num_components = static_cast<int>(mcarray.number_of_children());
282 if (num_components != 0)
283 {
284 vtkLogF(ERROR, "number of components for ascent_ghost should be 1 but is %d", num_components);
285 return nullptr;
286 }
287 const conduit_cpp::DataType dtype0 = mcarray.dtype();
288 const vtkIdType num_tuples = static_cast<vtkIdType>(dtype0.number_of_elements());
289 array->SetNumberOfTuples(num_tuples);
290 const int* vals = mcarray.as_int_ptr();
291 unsigned char ghost_type = is_cell_data
292 ? static_cast<unsigned char>(vtkDataSetAttributes::HIDDENCELL)
293 : static_cast<unsigned char>(vtkDataSetAttributes::HIDDENPOINT);
294 for (vtkIdType i = 0; i < num_tuples; i++)
295 {
296 if (vals[i] == 0)
297 {
298 array->SetTypedComponent(i, 0, 0);
299 }
300 else
301 {
302 array->SetTypedComponent(i, 0, ghost_type);
303 }
304 }
305 return array;
306}
307
308//----------------------------------------------------------------------------
309vtkSmartPointer<vtkDataArray> vtkConduitArrayUtilities::MCArrayToVTKArray(

Callers

nothing calls this directly

Calls 5

GhostArrayNameFunction · 0.85
NewFunction · 0.50
SetNameMethod · 0.45
SetNumberOfTuplesMethod · 0.45
SetTypedComponentMethod · 0.45

Tested by

no test coverage detected