]> Creatis software - gdcm.git/blobdiff - vtk/vtkGdcmReader.cxx
Add vtkGdcmReader::SetFlipY(bool) (default : true, to keep old behaviour)
[gdcm.git] / vtk / vtkGdcmReader.cxx
index 30d0ccf84335b34436cc0da75cc26a224a699893..91bc6b408223892c69e9df85c0e08e09c271f82f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmReader.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/09/04 16:21:50 $
-  Version:   $Revision: 1.92 $
+  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 <vtkPointData.h>
 #include <vtkLookupTable.h>
 
-vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.92 $")
+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()
@@ -335,14 +337,14 @@ void vtkGdcmReader::ExecuteData(vtkDataObject *output)
 //}                           // end For VTK5.0
 
    data->AllocateScalars();  // For VTK5.0
+   
+#if (VTK_MAJOR_VERSION >= 5) || ( VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 2 )
+//#if (VTK_MAJOR_VERSION >= 5)
    if (this->UpdateExtentIsEmpty(output))
    {
       return;
    }
-   
-//void vtkGdcmReader::BuildData(vtkDataObject *output)  // For VTK5.0
-//{
-//   vtkImageData *data = this->AllocateOutputData(output);  // end For VTK5.0
+#endif
 
    data->GetPointData()->GetScalars()->SetName("DicomImage-Volume");
 
@@ -849,15 +851,20 @@ void vtkGdcmReader::LoadImageInMemory(
       this->LookupTable->SetRange(0,255);
       vtkDataSetAttributes *a = this->GetOutput()->GetPointData();
       a->GetScalars()->SetLookupTable(this->LookupTable);
-      free(lut);
+      delete[] lut;
    }
    else
    {
       //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();
 }