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

Function FillFieldArrayValues

IO/CatalystConduit/vtkDataObjectToConduit.cxx:769–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767}
768
769bool FillFieldArrayValues(vtkDataSet* data_set, conduit_cpp::Node& values_node,
770 const std::string& association, vtkDataArray* data_array)
771{
772 bool is_success = true;
773 auto pointSet = vtkPointSet::SafeDownCast(data_set);
774
775 // Conversion may fail for cell types TRIANGLE_STRIP, POLY_LINE, POLY_VERTEX
776 // Where we create more than 1 conduit cell for each VTK cell. We need to insert values to
777 // handle this case And avoid having less cell field values than cells in the Conduit node.
778 if (association == "element" && pointSet && HasMultiCells(pointSet))
779 {
780 const std::map<int, int> topo_num_vertices{ { VTK_POLY_VERTEX, 1 }, { VTK_POLY_LINE, 2 },
781 { VTK_TRIANGLE_STRIP, 3 } };
782
783 auto newArray = vtkSmartPointer<vtkDataArray>::NewInstance(data_array);
784 newArray->Allocate(data_array->GetNumberOfTuples());
785 newArray->SetNumberOfComponents(data_array->GetNumberOfComponents());
786 for (vtkIdType i = 0; i < pointSet->GetNumberOfCells(); i++)
787 {
788 auto type = pointSet->GetCellType(i);
789
790 if (topo_num_vertices.find(type) != topo_num_vertices.end())
791 {
792 // triangle strip with 5 points has 3 triangles
793 auto numCells = pointSet->GetCellSize(i) - topo_num_vertices.at(type) + 1;
794 for (vtkIdType j = 0; j < numCells; j++)
795 {
796 newArray->InsertNextTuple(data_array->GetTuple(i));
797 }
798 }
799 else
800 {
801 newArray->InsertNextTuple(data_array->GetTuple(i));
802 }
803 }
804
805 // Array is not owned in this case, hard copy it
806 is_success =
807 ::ConvertDataArrayToMCArray(newArray, values_node, std::vector<std::string>(), false);
808 }
809 else
810 {
811 is_success = ::ConvertDataArrayToMCArray(data_array, values_node);
812 }
813
814 return is_success;
815}
816
817//----------------------------------------------------------------------------
818bool FillFields(vtkDataSet* data_set, vtkFieldData* field_data, const std::string& association,

Callers 1

FillFieldsFunction · 0.85

Calls 15

HasMultiCellsFunction · 0.85
NewInstanceFunction · 0.50
AllocateMethod · 0.45
GetNumberOfTuplesMethod · 0.45
SetNumberOfComponentsMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetNumberOfCellsMethod · 0.45
GetCellTypeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
GetCellSizeMethod · 0.45

Tested by

no test coverage detected