----------------------------------------------------------------------------
| 729 | |
| 730 | //---------------------------------------------------------------------------- |
| 731 | vtkSmartPointer<vtkImageData> CreateImageData(const conduit_cpp::Node& coordset) |
| 732 | { |
| 733 | auto image = vtkSmartPointer<vtkImageData>::New(); |
| 734 | int dims[3] = { 1, 1, 1 }; |
| 735 | const char* dims_paths[] = { "dims/i", "dims/j", "dims/k" }; |
| 736 | double origin[3] = { 0, 0, 0 }; |
| 737 | const char* origin_paths[] = { "origin/x", "origin/y", "origin/z" }; |
| 738 | double spacing[3] = { 1, 1, 1 }; |
| 739 | const char* spacing_paths[] = { "spacing/dx", "spacing/dy", "spacing/dz" }; |
| 740 | for (int cc = 0; cc < 3; ++cc) |
| 741 | { |
| 742 | if (coordset.has_path(dims_paths[cc])) |
| 743 | { |
| 744 | dims[cc] = coordset[dims_paths[cc]].to_int32(); |
| 745 | } |
| 746 | if (coordset.has_path(origin_paths[cc])) |
| 747 | { |
| 748 | origin[cc] = coordset[origin_paths[cc]].to_double(); |
| 749 | } |
| 750 | if (coordset.has_path(spacing_paths[cc])) |
| 751 | { |
| 752 | spacing[cc] = coordset[spacing_paths[cc]].to_double(); |
| 753 | } |
| 754 | } |
| 755 | image->SetOrigin(origin); |
| 756 | image->SetSpacing(spacing); |
| 757 | image->SetDimensions(dims); |
| 758 | |
| 759 | return image; |
| 760 | } |
| 761 | |
| 762 | //---------------------------------------------------------------------------- |
| 763 | /** |
no test coverage detected