From 50600b72b592a13f87f549aa370137b3e994f015 Mon Sep 17 00:00:00 2001 From: jpr Date: Sat, 18 Apr 2009 14:42:51 +0000 Subject: [PATCH] Add vtkGdcmReader::SetFlipY(bool) (default : true, to keep old behaviour) false DOESN'T flip the image. To be used by aware people only! --- vtk/vtkGdcmReader.cxx | 23 +++++++++++++++++------ vtk/vtkGdcmReader.h | 14 ++++++++++---- vtk/vtkgdcmViewer2.cxx | 12 ++++++++++-- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/vtk/vtkGdcmReader.cxx b/vtk/vtkGdcmReader.cxx index a387d611..91bc6b40 100644 --- a/vtk/vtkGdcmReader.cxx +++ b/vtk/vtkGdcmReader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: vtkGdcmReader.cxx,v $ Language: C++ - Date: $Date: 2007/12/13 16:18:13 $ - Version: $Revision: 1.94 $ + Date: $Date: 2009/04/18 14:42:51 $ + Version: $Revision: 1.95 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -59,7 +59,7 @@ // sh->SetDropDuplicatePositions(true); // // // Sorting the list is mandatory -// // a side effect is to compute ZSpacing for the fle set +// // a side effect is to compute ZSpacing for the file set // sh->OrderFileList(l); // sort the list // // vtkGdcmReader *reader = vtkGdcmReader::New(); @@ -92,7 +92,7 @@ #include #include -vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.94 $") +vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.95 $") vtkStandardNewMacro(vtkGdcmReader) //----------------------------------------------------------------------------- @@ -113,6 +113,8 @@ vtkGdcmReader::vtkGdcmReader() // this->Execution=false; // For VTK5.0 this->KeepOverlays = false; + + this->FlipY = true; // to keep old behaviour } vtkGdcmReader::~vtkGdcmReader() @@ -855,9 +857,14 @@ void vtkGdcmReader::LoadImageInMemory( { //size = fileH->GetImageDataSize(); // useless - just an accessor; 'size' unused - src = (unsigned char*)fileH->GetImageData(); + //if (this->GetFlipY()) + src = (unsigned char*)fileH->GetImageData(); + //else + // dest = (unsigned char*)fileH->GetImageData(); } + +if (this->GetFlipY()) { unsigned char *dst = dest + planeSize - lineSize; for (int plane = 0; plane < numPlanes; plane++) { @@ -877,7 +884,11 @@ void vtkGdcmReader::LoadImageInMemory( } dst += 2 * planeSize; } - +} +else +{ + memcpy((void*)dest, (void*)src, numPlanes * numLines * lineSize); +} fileH->Delete(); } diff --git a/vtk/vtkGdcmReader.h b/vtk/vtkGdcmReader.h index 9250b7f3..928013a7 100644 --- a/vtk/vtkGdcmReader.h +++ b/vtk/vtkGdcmReader.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: vtkGdcmReader.h,v $ Language: C++ - Date: $Date: 2007/09/04 16:21:50 $ - Version: $Revision: 1.35 $ + Date: $Date: 2009/04/18 14:42:51 $ + Version: $Revision: 1.36 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -64,15 +64,19 @@ public: // Description: // If this flag is set and the DICOM reader encounters a dicom file with // lookup table the data will be kept as unsigned chars and a lookuptable - // will be exported and accessible through GetLookupTable() + // will be exported and accessible through GetLookupTable() + vtkSetMacro(AllowLookupTable, bool); vtkGetMacro(AllowLookupTable, bool); vtkBooleanMacro(AllowLookupTable, bool); - vtkSetMacro(KeepOverlays, bool); vtkGetMacro(KeepOverlays, bool); vtkBooleanMacro(KeepOverlays, bool); + + vtkSetMacro(FlipY, bool); + vtkGetMacro(FlipY, bool); + vtkBooleanMacro(FlipY, bool); vtkGetObjectMacro(LookupTable, vtkLookupTable); @@ -187,6 +191,8 @@ private: bool KeepOverlays; + bool FlipY; + /// Pointer to a user suplied function to allow modification of pixel order VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction; diff --git a/vtk/vtkgdcmViewer2.cxx b/vtk/vtkgdcmViewer2.cxx index 72dd2379..b840ea1c 100644 --- a/vtk/vtkgdcmViewer2.cxx +++ b/vtk/vtkgdcmViewer2.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: vtkgdcmViewer2.cxx,v $ Language: C++ - Date: $Date: 2007/10/03 15:50:13 $ - Version: $Revision: 1.15 $ + Date: $Date: 2009/04/18 14:42:51 $ + Version: $Revision: 1.16 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -129,6 +129,14 @@ int main(int argc, char *argv[]) reader->SetKeepOverlays(true); } +// not a very clever way to pass several params +// but it's just for checking + if (strcmp (argv[argc-1], "n") == 0) + { + argc--; // Is it allowed?!? + reader->SetFlipY(false); + } + if( argc == 2 ) reader->SetFileName( argv[1] ); else -- 2.45.0