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

Function vtkMINCImageWriterExecuteChunk

IO/MINC/vtkMINCImageWriter.cxx:1284–1449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1282//------------------------------------------------------------------------------
1283template <class T1, class T2>
1284void vtkMINCImageWriterExecuteChunk(T1* inPtr, T2* buffer, double chunkRange[2],
1285 double validRange[2], int ncid, int varid, int ndims, size_t* start, size_t* count,
1286 vtkIdType* permutedInc, int rescale)
1287{
1288 // See if there is a range of dimensions over which the
1289 // the MINC data and VTK data will be contiguous. The
1290 // lastdim is the dimension after which all dimensions
1291 // are contiguous between the MINC file and the output.
1292 int lastdim = ndims - 1;
1293 int idim = 0;
1294 int ncontiguous = 1;
1295 vtkIdType dimprod = 1;
1296 for (idim = ndims; idim > 0;)
1297 {
1298 idim--;
1299
1300 lastdim = idim;
1301 ncontiguous = dimprod;
1302
1303 if (dimprod != permutedInc[idim])
1304 {
1305 break;
1306 }
1307
1308 // Also need to break if the spatial dimension
1309 // corresponding to idim has flipped.
1310
1311 dimprod *= static_cast<vtkIdType>(count[idim]);
1312 }
1313
1314 T2* outPtr = buffer;
1315
1316 // Initialize min and max values.
1317 T1 minval = *inPtr;
1318 T1 maxval = *inPtr;
1319
1320 // Initialize shift and scale values
1321 double shift = 0.0;
1322 double scale = 1.0;
1323
1324 // Need to do everything from here down _twice_: stage 0 is to
1325 // calculate the range, and stage 1 is to rescale the values
1326 // and write them out to disk.
1327 for (int stage = 0; stage < 2; stage++)
1328 {
1329 // Create space to save values during the copy loop.
1330 T1* tmpInPtr = inPtr;
1331 T1* saveInPtr[VTK_MINC_MAX_DIMS];
1332 size_t index[VTK_MINC_MAX_DIMS];
1333 for (idim = 0; idim < ndims; idim++)
1334 {
1335 index[idim] = 0;
1336 saveInPtr[idim] = tmpInPtr;
1337 }
1338
1339 // Save the count and permuted increment of this dimension.
1340 size_t lastdimcount = count[lastdim];
1341 size_t lastdimindex = 0;

Callers 1

WriteMINCDataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected