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

Function CreateImageData

IO/CatalystConduit/vtkConduitToDataObject.cxx:731–760  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

729
730//----------------------------------------------------------------------------
731vtkSmartPointer<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/**

Callers 1

CreateMeshFunction · 0.70

Calls 4

NewFunction · 0.50
SetOriginMethod · 0.45
SetSpacingMethod · 0.45
SetDimensionsMethod · 0.45

Tested by

no test coverage detected