| 767 | } |
| 768 | |
| 769 | bool 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 | //---------------------------------------------------------------------------- |
| 818 | bool FillFields(vtkDataSet* data_set, vtkFieldData* field_data, const std::string& association, |
no test coverage detected