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

Function vtkMINCImageReaderExecuteChunk

IO/MINC/vtkMINCImageReader.cxx:928–1024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

926//------------------------------------------------------------------------------
927template <class T1, class T2>
928void vtkMINCImageReaderExecuteChunk(T1* outPtr, T2* buffer, double slope, double intercept,
929 int ncid, int varid, int ndims, size_t* start, size_t* count, vtkIdType* permutedInc)
930{
931 // Read the chunk of data from the MINC file.
932 vtkMINCImageReaderReadChunk(ncid, varid, start, count, buffer);
933
934 // Create space to save values during the copy loop.
935 T1* saveOutPtr[VTK_MINC_MAX_DIMS];
936 size_t index[VTK_MINC_MAX_DIMS];
937 int idim = 0;
938 for (idim = 0; idim < ndims; idim++)
939 {
940 index[idim] = 0;
941 saveOutPtr[idim] = outPtr;
942 }
943
944 // See if there is a range of dimensions over which the
945 // the MINC data and VTK data will be contiguous. The
946 // lastdim is the dimension after which all dimensions
947 // are contiguous between the MINC file and the output.
948 int lastdim = ndims - 1;
949 int ncontiguous = 1;
950 vtkIdType dimprod = 1;
951 for (idim = ndims; idim > 0;)
952 {
953 idim--;
954
955 lastdim = idim;
956 ncontiguous = dimprod;
957
958 if (dimprod != permutedInc[idim])
959 {
960 break;
961 }
962
963 dimprod *= static_cast<vtkIdType>(count[idim]);
964 }
965
966 // Save the count and permuted increment of this dimension.
967 size_t lastdimcount = count[lastdim];
968 size_t lastdimindex = 0;
969 vtkIdType lastdimInc = permutedInc[lastdim];
970 T1* lastdimOutPtr = saveOutPtr[lastdim];
971
972 // Loop over all contiguous sections of the image.
973 for (;;)
974 {
975 // Loop through one contiguous section
976 vtkIdType k = ncontiguous;
977 do
978 {
979 // Use special function for type conversion.
980 vtkMINCImageReaderConvert((*buffer++) * slope + intercept, *outPtr++);
981 } while (--k);
982
983 lastdimindex++;
984 lastdimOutPtr += lastdimInc;
985 outPtr = lastdimOutPtr;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected