@@ -373,39 +373,52 @@ int main(int argc, char** argv)
373
373
return EXIT_FAILURE;
374
374
}
375
375
376
+ std::string fileExtension = vtksys::SystemTools::GetFilenameLastExtension (inputFileName);
377
+ bool headerOnlyUpdatePossible = (inputFileName == outputFileName) // file overwrite requested
378
+ && (igsioCommon::IsEqualInsensitive (fileExtension, " .mhd" ) || igsioCommon::IsEqualInsensitive (fileExtension, " .nhdr" ));
379
+ bool headerOnlyOperation = false ; // false by default
380
+
376
381
// Set operation
377
382
if (strOperation.empty ())
378
383
{
379
384
operation = NO_OPERATION;
380
385
LOG_INFO (" No modification operation has been specified (specify --operation parameter to change the input sequence)." );
386
+ headerOnlyOperation = true ;
381
387
}
382
388
else if (igsioCommon::IsEqualInsensitive (strOperation, " UPDATE_FRAME_FIELD_NAME" ))
383
389
{
384
390
operation = UPDATE_FRAME_FIELD_NAME;
391
+ headerOnlyOperation = true ;
385
392
}
386
393
else if (igsioCommon::IsEqualInsensitive (strOperation, " UPDATE_FRAME_FIELD_VALUE" ))
387
394
{
388
395
operation = UPDATE_FRAME_FIELD_VALUE;
396
+ headerOnlyOperation = true ;
389
397
}
390
398
else if (igsioCommon::IsEqualInsensitive (strOperation, " DELETE_FRAME_FIELD" ))
391
399
{
392
400
operation = DELETE_FRAME_FIELD;
401
+ headerOnlyOperation = true ;
393
402
}
394
403
else if (igsioCommon::IsEqualInsensitive (strOperation, " UPDATE_FIELD_NAME" ))
395
404
{
396
405
operation = UPDATE_FIELD_NAME;
406
+ headerOnlyOperation = true ;
397
407
}
398
408
else if (igsioCommon::IsEqualInsensitive (strOperation, " UPDATE_FIELD_VALUE" ))
399
409
{
400
410
operation = UPDATE_FIELD_VALUE;
411
+ headerOnlyOperation = true ;
401
412
}
402
413
else if (igsioCommon::IsEqualInsensitive (strOperation, " DELETE_FIELD" ))
403
414
{
404
415
operation = DELETE_FIELD;
416
+ headerOnlyOperation = true ;
405
417
}
406
418
else if (igsioCommon::IsEqualInsensitive (strOperation, " ADD_TRANSFORM" ))
407
419
{
408
420
operation = ADD_TRANSFORM;
421
+ headerOnlyOperation = true ;
409
422
}
410
423
else if (igsioCommon::IsEqualInsensitive (strOperation, " TRIM" ))
411
424
{
@@ -780,7 +793,8 @@ int main(int argc, char** argv)
780
793
// Save output file to file
781
794
782
795
LOG_INFO (" Save output sequence file to: " << outputFileName);
783
- if (vtkPlusSequenceIO::Write (outputFileName, trackedFrameList, trackedFrameList->GetImageOrientation (), useCompression, operation != REMOVE_IMAGE_DATA) != PLUS_SUCCESS)
796
+ if (vtkPlusSequenceIO::Write (outputFileName, trackedFrameList, trackedFrameList->GetImageOrientation (),
797
+ useCompression, operation != REMOVE_IMAGE_DATA, headerOnlyUpdatePossible && headerOnlyOperation) != PLUS_SUCCESS)
784
798
{
785
799
LOG_ERROR (" Couldn't write sequence file: " << outputFileName);
786
800
return EXIT_FAILURE;
0 commit comments