X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vtk%2FvtkGdcmReader.cxx;h=91556c82e9803f3999f1f3decf2ee05f470c3d8e;hb=f04d4a677f3a7738f3d03e0783d7a38b84983a33;hp=580379cb96e92140cb0a862e1603948a3d90e0d7;hpb=ba78e6c6d47d6db1528e8e88e5ebde7296a26692;p=gdcm.git diff --git a/vtk/vtkGdcmReader.cxx b/vtk/vtkGdcmReader.cxx index 580379cb..91556c82 100644 --- a/vtk/vtkGdcmReader.cxx +++ b/vtk/vtkGdcmReader.cxx @@ -1,4 +1,21 @@ -// vtkGdcmReader.cxx +/*========================================================================= + + Program: gdcm + Module: $RCSfile: vtkGdcmReader.cxx,v $ + Language: C++ + Date: $Date: 2004/12/09 10:59:59 $ + Version: $Revision: 1.64 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + //----------------------------------------------------------------------------- // ////////////////////////////////////////////////////////////// // WARNING TODO CLEANME @@ -58,7 +75,7 @@ #include #include -vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.60 $"); +vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.64 $"); vtkStandardNewMacro(vtkGdcmReader); //----------------------------------------------------------------------------- @@ -460,10 +477,10 @@ int vtkGdcmReader::CheckFileCoherence() && (type != "16U") && (type != "16S") && (type != "32U") && (type != "32S") ) { - vtkErrorMacro(<< "Bad File Type for file" << filename->c_str()); - vtkErrorMacro(<< " " << type.c_str()); - vtkErrorMacro(<< "Removing this file from readed files " - << filename->c_str()); + vtkErrorMacro(<< "Bad File Type for file " << filename->c_str() << "\n" + << " File type found : " << type.c_str() + << " (might be 8U, 8S, 16U, 16S, 32U, 32S) \n" + << " Removing this file from readed files"); *filename = "GDCM_UNREADABLE"; continue; } @@ -548,9 +565,9 @@ int vtkGdcmReader::CheckFileCoherence() this->DataSpacing[2] = GdcmHeader.GetZSpacing(); //Set image origin - this->DataOrigin[0] = GdcmHeader.GetXOrigin(); - this->DataOrigin[1] = GdcmHeader.GetYOrigin(); - this->DataOrigin[2] = GdcmHeader.GetZOrigin(); + //this->DataOrigin[0] = GdcmHeader.GetXOrigin(); + //this->DataOrigin[1] = GdcmHeader.GetYOrigin(); + //this->DataOrigin[2] = GdcmHeader.GetZOrigin(); } } // End of loop on filename @@ -607,7 +624,7 @@ void vtkGdcmReader::AddInternalFileName(const char* name) */ size_t vtkGdcmReader::LoadImageInMemory( std::string fileName, - unsigned char * dest, + unsigned char *dest, const unsigned long updateProgressTarget, unsigned long & updateProgressCount) { @@ -626,13 +643,14 @@ size_t vtkGdcmReader::LoadImageInMemory( int numLines = file.GetHeader()->GetYSize(); int numPlanes = file.GetHeader()->GetZSize(); int lineSize = NumComponents * numColumns * file.GetHeader()->GetPixelSize(); + int planeSize = lineSize * numLines; - unsigned char * source; + unsigned char *src; if( file.GetHeader()->HasLUT() && AllowLookupTable ) { size = file.GetImageDataSize(); - source = (unsigned char*) file.GetImageDataRaw(); + src = (unsigned char*) file.GetImageDataRaw(); unsigned char *lut = (unsigned char*) file.GetLutRGBA(); if(!this->LookupTable) @@ -656,21 +674,19 @@ size_t vtkGdcmReader::LoadImageInMemory( } else { - size = file.GetImageDataSize(); - source = (unsigned char*)file.GetImageData(); + size = file.GetImageDataSize(); + src = (unsigned char*)file.GetImageData(); } - - unsigned char * destination = dest + size - lineSize; + unsigned char *dst = dest + planeSize - lineSize; for (int plane = 0; plane < numPlanes; plane++) { for (int line = 0; line < numLines; line++) { - cerr << line << endl; // Copy one line at proper destination: - memcpy((void*)destination, (void*)source, lineSize); - source += lineSize; - destination -= lineSize; + memcpy((void*)dst, (void*)src, lineSize); + src += lineSize; + dst -= lineSize; // Update progress related: if (!(updateProgressCount%updateProgressTarget)) { @@ -678,17 +694,9 @@ size_t vtkGdcmReader::LoadImageInMemory( } updateProgressCount++; } + dst += 2 * planeSize; } -// DO NOT remove this commented out code . -// Nobody knows what's expecting you ... -// Just to 'see' what was actually read on disk :-( - -// FILE * f2; -// f2 = fopen("SpuriousFile.RAW","wb"); -// fwrite(Dest,size,1,f2); -// fclose(f2); - return size; }