Program: gdcm
Module: $RCSfile: vtkGdcmReader.cxx,v $
Language: C++
- Date: $Date: 2006/03/29 11:23:43 $
- Version: $Revision: 1.86 $
+ Date: $Date: 2007/06/21 14:47:16 $
+ Version: $Revision: 1.91 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// //////////////////////////////////////////////////////////////
//
//===> Many users expect from vtkGdcmReader it 'orders' the images
-// (that's the job of gdcm::SerieHelper ...)
+// (that's the job of GDCM_NAME_SPACE::SerieHelper ...)
// When user *knows* the files with same Serie UID
// have same sizes, same 'pixel' type, same color convention, ...
// the right way to proceed is as follow :
//
-// gdcm::SerieHelper *sh= new gdcm::SerieHelper();
+// GDCM_NAME_SPACE::SerieHelper *sh= new GDCM_NAME_SPACE::SerieHelper();
// // if user wants *not* to load some parts of the file headers
// sh->SetLoadMode(loadMode);
+//
// // if user wants *not* to load some files
// sh->AddRestriction(group, element, value, operator);
// sh->AddRestriction( ...
//
// // if user wants to sort reverse order
// sh->SetSortOrderToReverse();
-// // here, we suppose only the first Coherent File List is of interest
-// gdcm::FileList *l = sh->GetFirstCoherentFileList();
+//
+// // here, we suppose only the first 'Serie' is of interest
+// // it's up to the user to decide !
+// GDCM_NAME_SPACE::FileList *l = sh->GetFirstSingleSerieUIDFileSet();
+//
// // if user is doesn't trust too much the files with same Serie UID
// if ( !sh->IsCoherent(l) )
// return; // not same sizes, same 'pixel' type -> stop
+//
+// // WARNING : all that follows works only with 'bona fide' Series
+// // (In some Series; there are more than one 'orientation'
+// // Don't expected to build a 'volume' with that!
+// //
+// // -> use sh->SplitOnOrientation(l)
+// // - or sh->SplitOnPosition(l), or SplitOnTagValue(l, gr, el) -
+// // depending on what you want to do
+// // and iterate on the various 'X Coherent File Sets'
+//
+// // if user *knows* he has to drop the 'duplicates' images
+// // (same Position)
+// sh->SetDropDuplicatePositions(true);
+//
+// // Sorting the list is mandatory
+// // a side effect is to compute ZSpacing for the fle set
// sh->OrderFileList(l); // sort the list
//
// vtkGdcmReader *reader = vtkGdcmReader::New();
+//
// // if user wants to modify pixel order (Mirror, TopDown, 90°Rotate, ...)
// // he has to supply the function that does the job
// // (a *very* simple example is given in vtkgdcmSerieViewer.cxx)
// reader->SetUserFunction (userSuppliedFunction);
-// // to pass a 'Coherent File List' as produced by gdcm::SerieHelper
+//
+// // to pass a 'Coherent File List' as produced by GDCM_NAME_SPACE::SerieHelper
// reader->SetCoherentFileList(l);
// reader->Update();
//
#include "gdcmFileHelper.h"
#include "gdcmFile.h"
+#include "gdcmSerieHelper.h" // for ImagePositionPatientOrdering()
#include "vtkGdcmReader.h"
#include "gdcmDebug.h"
#include <vtkPointData.h>
#include <vtkLookupTable.h>
-vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.86 $")
+vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.91 $")
vtkStandardNewMacro(vtkGdcmReader)
//-----------------------------------------------------------------------------
{
this->LookupTable = NULL;
this->AllowLookupTable = false;
- this->AllowLightChecking = false;
- this->LoadMode = gdcm::LD_ALL; // Load everything (possible values :
- // - LD_NOSEQ,
- // - LD_NOSHADOW,
- // - LD_NOSHADOWSEQ)
+ //this->AllowLightChecking = false;
+ this->LoadMode = GDCM_NAME_SPACE::LD_ALL; // Load everything (possible values :
+ // - LD_NOSEQ,
+ // - LD_NOSHADOW,
+ // - LD_NOSHADOWSEQ)
this->CoherentFileList = 0;
this->UserFunction = 0;
size_t size = this->NumColumns * this->NumLines * this->NumPlanes
* data->GetScalarSize() * this->NumComponents;
unsigned char *Dest = (unsigned char *)data->GetScalarPointer();
- for (std::vector<gdcm::File* >::iterator it = InternalFileList.begin();
+ for (std::vector<GDCM_NAME_SPACE::File* >::iterator it = InternalFileList.begin();
it != InternalFileList.end();
++it)
{
*/
void vtkGdcmReader::LoadFileInformation()
{
- gdcm::File *file;
+ GDCM_NAME_SPACE::File *file;
bool foundReference=false;
std::string type;
fclose(fp);
// Read the file
- file=gdcm::File::New();
+ file=GDCM_NAME_SPACE::File::New();
file->SetLoadMode( LoadMode );
file->SetFileName(filename->c_str() );
file->Load();
* These informations are required to specify the output image
* caracteristics
*/
-void vtkGdcmReader::GetFileInformation(gdcm::File *file)
+void vtkGdcmReader::GetFileInformation(GDCM_NAME_SPACE::File *file)
{
// Get the image caracteristics
this->NumColumns = file->GetXSize();
this->DataSpacing[0] = file->GetXSpacing();
this->DataSpacing[1] = file->GetYSpacing();
- this->DataSpacing[2] = file->GetZSpacing();
+
+ // Most of the file headers have NO z spacing
+ // It must be calculated from the whole GDCM_NAME_SPACE::Serie (if any)
+ // using Jolinda Smith's algoritm.
+ // see GDCM_NAME_SPACE::SerieHelper::ImagePositionPatientOrdering()
+ if (CoherentFileList == 0)
+ this->DataSpacing[2] = file->GetZSpacing();
+ else
+ {
+ // Just because OrderFileList() is a member of GDCM_NAME_SPACE::SerieHelper
+ // we need to instanciate sh.
+ GDCM_NAME_SPACE::SerieHelper *sh = GDCM_NAME_SPACE::SerieHelper::New();
+ sh->OrderFileList(CoherentFileList); // calls ImagePositionPatientOrdering()
+ this->DataSpacing[2] = sh->GetZSpacing();
+ sh->Delete();
+ }
// Get the image data caracteristics
if( file->HasLUT() && this->AllowLookupTable )
*
* \return True if the file match, False otherwise
*/
-bool vtkGdcmReader::TestFileInformation(gdcm::File *file)
+bool vtkGdcmReader::TestFileInformation(GDCM_NAME_SPACE::File *file)
{
int numColumns = file->GetXSize();
int numLines = file->GetYSize();
{
vtkDebugMacro(<< "Copying to memory image [" << fileName.c_str() << "]");
- gdcm::File *f;
- f = new gdcm::File();
+ GDCM_NAME_SPACE::File *f;
+ f = new GDCM_NAME_SPACE::File();
f->SetLoadMode( LoadMode );
f->SetFileName( fileName.c_str() );
f->Load( );
}*/
/*
- * Loads the contents of the image/volume contained by gdcm::File* f at
+ * Loads the contents of the image/volume contained by GDCM_NAME_SPACE::File* f at
* the Dest memory address. Returns the size of the data loaded.
* \ param f File to consider. NULL if the file must be skiped
* \remarks Assume that if (f != NULL) then its caracteristics match
* with the previous ones
*/
void vtkGdcmReader::LoadImageInMemory(
- gdcm::File *f,
+ GDCM_NAME_SPACE::File *f,
unsigned char *dest,
const unsigned long updateProgressTarget,
unsigned long &updateProgressCount)
if(!f)
return;
- gdcm::FileHelper *fileH = gdcm::FileHelper::New( f );
+ GDCM_NAME_SPACE::FileHelper *fileH = GDCM_NAME_SPACE::FileHelper::New( f );
fileH->SetUserFunction( UserFunction );
int numColumns = f->GetXSize();