Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vtkGdcmReader Class Reference

#include <vtkGdcmReader.h>

List of all members.

Public Member Functions

 vtkTypeRevisionMacro (vtkGdcmReader, vtkImageReader)
void PrintSelf (ostream &os, vtkIndent indent)
virtual void RemoveAllFileName (void)
virtual void AddFileName (const char *name)
virtual void SetFileName (const char *name)
void SetCoherentFileList (std::vector< gdcm::File * > *cfl)
 vtkSetMacro (AllowLightChecking, bool)
 vtkGetMacro (AllowLightChecking, bool)
 vtkBooleanMacro (AllowLightChecking, bool)
void SetUserFunction (VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc)
 vtkSetMacro (AllowLookupTable, bool)
 vtkGetMacro (AllowLookupTable, bool)
 vtkBooleanMacro (AllowLookupTable, bool)
 vtkGetObjectMacro (LookupTable, vtkLookupTable)
 vtkSetMacro (LoadMode, int)
 vtkGetMacro (LoadMode, int)
 vtkBooleanMacro (LoadMode, int)

Static Public Member Functions

static vtkGdcmReaderNew ()

Protected Member Functions

 vtkGdcmReader ()
 ~vtkGdcmReader ()
virtual void ExecuteInformation ()
virtual void ExecuteData (vtkDataObject *output)
virtual void BuildData (vtkDataObject *output)
virtual void BuildFileListFromPattern ()
virtual void LoadFileInformation ()
virtual void UpdateFileInformation ()
virtual void GetFileInformation (gdcm::File *file)
virtual bool TestFileInformation (gdcm::File *file)

Private Types

typedef std::vector< gdcm::File * > gdcmFileList

Private Member Functions

void RemoveAllInternalFileName (void)
void AddInternalFileName (const char *name)
void RemoveAllInternalFile (void)
void IncrementProgress (const unsigned long updateProgressTarget, unsigned long &updateProgressCount)
void LoadImageInMemory (gdcm::File *f, unsigned char *dest, const unsigned long updateProgressTarget, unsigned long &updateProgressCount)

Private Attributes

vtkLookupTable * LookupTable
vtkTimeStamp fileTime
bool AllowLookupTable
bool AllowLightChecking
int NumColumns
int NumLines
int NumPlanes
int TotalNumberOfPlanes
int NumComponents
std::string ImageType
size_t PixelSize
std::list< std::string > FileNameList
gdcmFileListCoherentFileList
bool OwnFile
std::list< std::string > InternalFileNameList
gdcmFileList InternalFileList
bool Execution
int LoadMode
 Bit string integer (each one considered as a boolean) Bit 0 : Skip Sequences, if possible Bit 1 : Skip Shadow Groups if possible Bit 2 : Skip Sequences inside a Shadow Group, if possible Probabely (?), some more to add.
VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction
 Pointer to a user suplied function to allow modification of pixel order.


Detailed Description

Definition at line 36 of file vtkGdcmReader.h.


Member Typedef Documentation

typedef std::vector<gdcm::File *> vtkGdcmReader::gdcmFileList [private]
 

Definition at line 120 of file vtkGdcmReader.h.


Constructor & Destructor Documentation

vtkGdcmReader::vtkGdcmReader  )  [protected]
 

vtkGdcmReader::~vtkGdcmReader  )  [protected]
 

Definition at line 93 of file vtkGdcmReader.cxx.

References InternalFileNameList, LookupTable, and RemoveAllFileName().

00094 {
00095    this->RemoveAllFileName();
00096    this->InternalFileNameList.clear();
00097    if(this->LookupTable) 
00098       this->LookupTable->Delete();
00099 }


Member Function Documentation

void vtkGdcmReader::AddFileName const char *  name  )  [virtual]
 

Definition at line 130 of file vtkGdcmReader.cxx.

References FileNameList.

Referenced by main().

00131 {
00132    // We need to bypass the const pointer [since list<>.push_bash() only
00133    // takes a char* (but not a const char*)] by making a local copy:
00134    this->FileNameList.push_back(name);
00135    this->Modified();
00136 }

void vtkGdcmReader::AddInternalFileName const char *  name  )  [private]
 

Definition at line 665 of file vtkGdcmReader.cxx.

References InternalFileNameList.

Referenced by BuildFileListFromPattern().

00666 {
00667    char *LocalName = new char[strlen(name) + 1];
00668    strcpy(LocalName, name);
00669    this->InternalFileNameList.push_back(LocalName);
00670    delete[] LocalName;
00671 }

void vtkGdcmReader::BuildData vtkDataObject *  output  )  [protected, virtual]
 

Definition at line 306 of file vtkGdcmReader.cxx.

References InternalFileList, LoadImageInMemory(), NumColumns, NumComponents, NumLines, and NumPlanes.

Referenced by ExecuteInformation().

00307 {
00308    vtkImageData *data = this->AllocateOutputData(output);
00309 
00310    data->GetPointData()->GetScalars()->SetName("DicomImage-Volume");
00311 
00312    // Test if output has valid extent
00313    // Prevent memory errors
00314    if((this->DataExtent[1]-this->DataExtent[0]>=0) &&
00315       (this->DataExtent[3]-this->DataExtent[2]>=0) &&
00316       (this->DataExtent[5]-this->DataExtent[4]>=0))
00317    {
00318       // The memory size for a full stack of images of course depends
00319       // on the number of planes and the size of each image:
00320       //size_t StackNumPixels = this->NumColumns * this->NumLines
00321       //                      * this->TotalNumberOfPlanes * this->NumComponents;
00322       //size_t stack_size = StackNumPixels * this->PixelSize; //not used
00323       // Allocate pixel data space itself.
00324 
00325       // Variables for the UpdateProgress. We shall use 50 steps to signify
00326       // the advance of the process:
00327       unsigned long UpdateProgressTarget = (unsigned long) ceil (this->NumLines
00328                                          * this->TotalNumberOfPlanes
00329                                          / 50.0);
00330       // The actual advance measure:
00331       unsigned long UpdateProgressCount = 0;
00332 
00333       // Filling the allocated memory space with each image/volume:
00334 
00335       size_t size = this->NumColumns * this->NumLines * this->NumPlanes
00336                   * data->GetScalarSize() * this->NumComponents;
00337       unsigned char *Dest = (unsigned char *)data->GetScalarPointer();
00338       for (std::vector<gdcm::File* >::iterator it =  InternalFileList.begin();
00339                                                it != InternalFileList.end();
00340                                              ++it)
00341       {
00342          this->LoadImageInMemory(*it, Dest,
00343                                  UpdateProgressTarget,
00344                                  UpdateProgressCount); 
00345          Dest += size;
00346       }
00347    }
00348 }

void vtkGdcmReader::BuildFileListFromPattern  )  [protected, virtual]
 

Definition at line 358 of file vtkGdcmReader.cxx.

References AddInternalFileName(), FileNameList, InternalFileNameList, and RemoveAllInternalFileName().

Referenced by ExecuteInformation().

00359 {
00360    this->RemoveAllInternalFileName();
00361 
00362    // Test miscellanous cases
00363    if ((! this->FileNameList.empty()) && this->FileName )
00364    {
00365       vtkErrorMacro(<< "Both AddFileName and SetFileName schemes were used");
00366       vtkErrorMacro(<< "No images loaded ! ");
00367       return;
00368    }
00369 
00370    if ((! this->FileNameList.empty()) && this->FilePrefix )
00371    {
00372       vtkErrorMacro(<< "Both AddFileName and SetFilePrefix schemes were used");
00373       vtkErrorMacro(<< "No images loaded ! ");
00374       return;
00375    }
00376 
00377    if (this->FileName && this->FilePrefix)
00378    {
00379       vtkErrorMacro(<< "Both SetFileName and SetFilePrefix schemes were used");
00380       vtkErrorMacro(<< "No images loaded ! ");
00381       return;
00382    }
00383 
00384    // Create the InternalFileNameList
00385    if (! this->FileNameList.empty()  )
00386    {
00387       vtkDebugMacro(<< "Using the AddFileName specified files");
00388       this->InternalFileNameList=this->FileNameList;
00389       return;
00390    }
00391 
00392    if (!this->FileName && !this->FilePrefix)
00393    {
00394       vtkErrorMacro(<< "FileNames are not set. Either use AddFileName() or");
00395       vtkErrorMacro(<< "specify a FileName or FilePrefix.");
00396       return;
00397    }
00398 
00399    if( this->FileName )
00400    {
00401       // Single file loading (as given with ::SetFileName()):
00402       // Case of multi-frame file considered here
00403       this->ComputeInternalFileName(this->DataExtent[4]);
00404       vtkDebugMacro(<< "Adding file " << this->InternalFileName);
00405       this->AddInternalFileName(this->InternalFileName);
00406    }
00407    else
00408    {
00409       // Multi file loading (as given with ::SetFilePattern()):
00410       for (int idx = this->DataExtent[4]; idx <= this->DataExtent[5]; ++idx)
00411       {
00412          this->ComputeInternalFileName(idx);
00413          vtkDebugMacro(<< "Adding file " << this->InternalFileName);
00414          this->AddInternalFileName(this->InternalFileName);
00415       }
00416    }
00417 }

void vtkGdcmReader::ExecuteData vtkDataObject *  output  )  [protected, virtual]
 

Definition at line 285 of file vtkGdcmReader.cxx.

00286 {
00287    vtkImageData *data=vtkImageData::SafeDownCast(output);
00288    data->SetExtent(this->DataExtent);
00289 
00290 /*   if ( CoherentFileList != 0 )   // When a list of names is passed
00291    {
00292       if (this->CoherentFileList->empty())
00293       {
00294          vtkErrorMacro(<< "Coherent File List must have at least a valid File*.");
00295          return;
00296       }
00297    }
00298    else if (this->InternalFileNameList.empty())
00299    {
00300       vtkErrorMacro(<< "A least a valid FileName must be specified.");
00301       return;
00302    }
00303 */
00304 }

void vtkGdcmReader::ExecuteInformation  )  [protected, virtual]
 

Definition at line 157 of file vtkGdcmReader.cxx.

References BuildData(), BuildFileListFromPattern(), Execution, fileTime, ImageType, LoadFileInformation(), NumColumns, NumLines, RemoveAllInternalFile(), TotalNumberOfPlanes, and UpdateFileInformation().

00158 {
00159    if(this->Execution)
00160       return;
00161 
00162    this->Execution=true;
00163    this->RemoveAllInternalFile();
00164    if(this->MTime>this->fileTime)
00165    {
00166       this->TotalNumberOfPlanes = 0;
00167 
00168       if ( this->CoherentFileList != 0 )
00169       {
00170          this->UpdateFileInformation();
00171       }
00172       else
00173       {
00174          this->BuildFileListFromPattern();
00175          this->LoadFileInformation();
00176       }
00177 
00178       if ( this->TotalNumberOfPlanes == 0)
00179       {
00180          vtkErrorMacro(<< "File set is not coherent. Exiting...");
00181          return;
00182       }
00183 
00184       // if the user has not set the extent, but has set the VOI
00185       // set the z axis extent to the VOI z axis
00186       if (this->DataExtent[4]==0 && this->DataExtent[5] == 0 &&
00187          (this->DataVOI[4] || this->DataVOI[5]))
00188       {
00189          this->DataExtent[4] = this->DataVOI[4];
00190          this->DataExtent[5] = this->DataVOI[5];
00191       }
00192 
00193       // When the user has set the VOI, check it's coherence with the file content.
00194       if (this->DataVOI[0] || this->DataVOI[1] || 
00195       this->DataVOI[2] || this->DataVOI[3] ||
00196       this->DataVOI[4] || this->DataVOI[5])
00197       { 
00198          if ((this->DataVOI[0] < 0) ||
00199              (this->DataVOI[1] >= this->NumColumns) ||
00200              (this->DataVOI[2] < 0) ||
00201              (this->DataVOI[3] >= this->NumLines) ||
00202              (this->DataVOI[4] < 0) ||
00203              (this->DataVOI[5] >= this->TotalNumberOfPlanes ))
00204          {
00205             vtkWarningMacro(<< "The requested VOI is larger than expected extent.");
00206             this->DataVOI[0] = 0;
00207             this->DataVOI[1] = this->NumColumns - 1;
00208             this->DataVOI[2] = 0;
00209             this->DataVOI[3] = this->NumLines - 1;
00210             this->DataVOI[4] = 0;
00211             this->DataVOI[5] = this->TotalNumberOfPlanes - 1;
00212          }
00213       }
00214 
00215       // Set the Extents.
00216       this->DataExtent[0] = 0;
00217       this->DataExtent[1] = this->NumColumns - 1;
00218       this->DataExtent[2] = 0;
00219       this->DataExtent[3] = this->NumLines - 1;
00220       this->DataExtent[4] = 0;
00221       this->DataExtent[5] = this->TotalNumberOfPlanes - 1;
00222   
00223       // We don't need to set the Endian related stuff (by using
00224       // this->SetDataByteOrderToBigEndian() or SetDataByteOrderToLittleEndian()
00225       // since the reading of the file is done by gdcm.
00226       // But we do need to set up the data type for downstream filters:
00227       if      ( ImageType == "8U" )
00228       {
00229          vtkDebugMacro(<< "8 bits unsigned image");
00230          this->SetDataScalarTypeToUnsignedChar(); 
00231       }
00232       else if ( ImageType == "8S" )
00233       {
00234          vtkErrorMacro(<< "Cannot handle 8 bit signed files");
00235          return;
00236       }
00237       else if ( ImageType == "16U" )
00238       {
00239          vtkDebugMacro(<< "16 bits unsigned image");
00240          this->SetDataScalarTypeToUnsignedShort();
00241       }
00242       else if ( ImageType == "16S" )
00243       {
00244          vtkDebugMacro(<< "16 bits signed image");
00245          this->SetDataScalarTypeToShort();
00246       }
00247       else if ( ImageType == "32U" )
00248       {
00249          vtkDebugMacro(<< "32 bits unsigned image");
00250          vtkDebugMacro(<< "WARNING: forced to signed int !");
00251          this->SetDataScalarTypeToInt();
00252       }
00253       else if ( ImageType == "32S" )
00254       {
00255          vtkDebugMacro(<< "32 bits signed image");
00256          this->SetDataScalarTypeToInt();
00257       }
00258       else if ( ImageType == "FD" )
00259       {
00260          vtkDebugMacro(<< "64 bits Double image");
00261          this->SetDataScalarTypeToDouble();
00262       }
00263       //Set number of scalar components:
00264       this->SetNumberOfScalarComponents(this->NumComponents);
00265 
00266       this->fileTime=this->MTime;
00267    }
00268 
00269    this->Superclass::ExecuteInformation();
00270 
00271    this->GetOutput()->SetUpdateExtentToWholeExtent();
00272    this->BuildData(this->GetOutput());
00273 
00274    this->Execution=false;
00275    this->RemoveAllInternalFile();
00276 }

void vtkGdcmReader::GetFileInformation gdcm::File file  )  [protected, virtual]
 

Get the informations from a file. These informations are required to specify the output image caracteristics

Definition at line 537 of file vtkGdcmReader.cxx.

References AllowLookupTable, CoherentFileList, gdcm::File::GetNumberOfScalarComponents(), gdcm::File::GetNumberOfScalarComponentsRaw(), gdcm::File::GetPixelSize(), gdcm::File::GetPixelType(), gdcm::File::GetXSize(), gdcm::File::GetXSpacing(), gdcm::File::GetYSize(), gdcm::File::GetYSpacing(), gdcm::File::GetZSize(), gdcm::File::GetZSpacing(), gdcm::File::HasLUT(), ImageType, InternalFileNameList, NumColumns, NumComponents, NumLines, NumPlanes, PixelSize, and TotalNumberOfPlanes.

Referenced by LoadFileInformation(), and UpdateFileInformation().

00538 {
00539    // Get the image caracteristics
00540    this->NumColumns = file->GetXSize();
00541    this->NumLines   = file->GetYSize();
00542    this->NumPlanes  = file->GetZSize();
00543 
00544    if (CoherentFileList == 0)
00545       this->TotalNumberOfPlanes = this->NumPlanes*InternalFileNameList.size();
00546    else
00547       this->TotalNumberOfPlanes = this->NumPlanes*CoherentFileList->size();
00548 
00549    this->ImageType = file->GetPixelType();
00550    this->PixelSize = file->GetPixelSize();
00551 
00552    this->DataSpacing[0] = file->GetXSpacing();
00553    this->DataSpacing[1] = file->GetYSpacing();
00554    this->DataSpacing[2] = file->GetZSpacing();
00555 
00556    // Get the image data caracteristics
00557    if( file->HasLUT() && this->AllowLookupTable )
00558    {
00559       // I could raise an error is AllowLookupTable is on and HasLUT() off
00560       this->NumComponents = file->GetNumberOfScalarComponentsRaw();
00561    }
00562    else
00563    {
00564       this->NumComponents = file->GetNumberOfScalarComponents(); //rgb or mono
00565    }
00566 }

void vtkGdcmReader::IncrementProgress const unsigned long  updateProgressTarget,
unsigned long &  updateProgressCount
[private]
 

Definition at line 690 of file vtkGdcmReader.cxx.

References NumLines.

00692 {
00693    // Update progress related for bad files:
00694    updateProgressCount += this->NumLines;
00695    if (updateProgressTarget > 0)
00696    {
00697       if (!(updateProgressCount%updateProgressTarget))
00698       {
00699          this->UpdateProgress(updateProgressCount/(50.0*updateProgressTarget));
00700       }
00701    }
00702 }

void vtkGdcmReader::LoadFileInformation  )  [protected, virtual]
 

Load all the files and set it in the InternalFileList For each file, the readability and the coherence of image caracteristics are tested. If an image doesn't agree the required specifications, it isn't considered and no data will be set for the planes corresponding to this image

The source of this work is the list of file name generated by the BuildFileListFromPattern method

Definition at line 429 of file vtkGdcmReader.cxx.

References gdcm::RefCounter::Delete(), GetFileInformation(), gdcm::File::GetPixelType(), InternalFileList, InternalFileNameList, gdcm::File::IsReadable(), gdcm::File::Load(), LoadMode, gdcm::File::New(), OwnFile, gdcm::Document::SetFileName(), gdcm::Document::SetLoadMode(), and TestFileInformation().

Referenced by ExecuteInformation().

00430 {
00431    gdcm::File *file;
00432    bool foundReference=false;
00433    std::string type;
00434 
00435    this->OwnFile=true;
00436    for (std::list<std::string>::iterator filename = InternalFileNameList.begin();
00437         filename != InternalFileNameList.end();
00438         ++filename)
00439    {
00440       // check for file readability
00441       FILE *fp;
00442       fp = fopen(filename->c_str(),"rb");
00443       if (!fp)
00444       {
00445          vtkErrorMacro(<< "Unable to open file " << filename->c_str());
00446          vtkErrorMacro(<< "Removing this file from read files: "
00447                        << filename->c_str());
00448          file = NULL;
00449          InternalFileList.push_back(file);
00450          continue;
00451       }
00452       fclose(fp);
00453 
00454       // Read the file
00455       file=gdcm::File::New();
00456       file->SetLoadMode( LoadMode );
00457       file->SetFileName(filename->c_str() );
00458       file->Load();
00459 
00460       // Test the Dicom file readability
00461       if(!file->IsReadable())
00462       {
00463          vtkErrorMacro(<< "Gdcm cannot parse file " << filename->c_str());
00464          vtkErrorMacro(<< "Removing this file from read files: "
00465                         << filename->c_str());
00466          file->Delete();
00467          file=NULL;
00468          InternalFileList.push_back(file);
00469          continue;
00470       }
00471 
00472       // Test the Pixel Type recognition
00473       type = file->GetPixelType();
00474       if (   (type !=  "8U") && (type !=  "8S")
00475           && (type != "16U") && (type != "16S")
00476           && (type != "32U") && (type != "32S") )
00477       {
00478          vtkErrorMacro(<< "Bad File Type for file " << filename->c_str() << "\n"
00479                        << "   File type found : " << type.c_str() 
00480                        << " (might be 8U, 8S, 16U, 16S, 32U, 32S) \n"
00481                        << "   Removing this file from read files");
00482          file->Delete();
00483          file=NULL;
00484          InternalFileList.push_back(file);
00485          continue;
00486       }
00487 
00488       // Test the image informations
00489       if(!foundReference)
00490       {
00491          foundReference = true;
00492          GetFileInformation(file);
00493 
00494          vtkDebugMacro(<< "This file taken as coherence reference:"
00495                         << filename->c_str());
00496          vtkDebugMacro(<< "Image dimensions of reference file as read from Gdcm:" 
00497                         << this->NumColumns << " " << this->NumLines << " " 
00498                         << this->NumPlanes);
00499       }
00500       else if(!TestFileInformation(file))
00501       {
00502          file->Delete();
00503          file=NULL;
00504       }
00505 
00506       InternalFileList.push_back(file);
00507    }
00508 }

void vtkGdcmReader::LoadImageInMemory gdcm::File f,
unsigned char *  dest,
const unsigned long  updateProgressTarget,
unsigned long &  updateProgressCount
[private]
 

Definition at line 735 of file vtkGdcmReader.cxx.

References AllowLookupTable, gdcm::RefCounter::Delete(), gdcm::FileHelper::GetFile(), gdcm::Document::GetFileName(), gdcm::FileHelper::GetImageData(), gdcm::FileHelper::GetImageDataRaw(), gdcm::FileHelper::GetImageDataSize(), gdcm::FileHelper::GetLutRGBA(), gdcm::File::GetNumberOfScalarComponents(), gdcm::File::GetNumberOfScalarComponentsRaw(), gdcm::File::GetPixelSize(), gdcm::File::GetXSize(), gdcm::File::GetYSize(), gdcm::File::GetZSize(), gdcm::File::HasLUT(), LookupTable, gdcm::FileHelper::New(), NumComponents, gdcm::FileHelper::SetUserFunction(), and UserFunction.

Referenced by BuildData().

00740 {
00741    if(!f)
00742       return;
00743 
00744    gdcm::FileHelper *fileH = gdcm::FileHelper::New( f );
00745    fileH->SetUserFunction( UserFunction );
00746 
00747    int numColumns = f->GetXSize();
00748    int numLines   = f->GetYSize();
00749    int numPlanes  = f->GetZSize();
00750    int numComponents;
00751 
00752    if( f->HasLUT() && this->AllowLookupTable )
00753       numComponents = f->GetNumberOfScalarComponentsRaw();
00754    else
00755       numComponents = f->GetNumberOfScalarComponents(); //rgb or mono
00756    vtkDebugMacro(<< "numComponents:" << numComponents);
00757    vtkDebugMacro(<< "Copying to memory image [" << f->GetFileName().c_str() << "]");
00758    //size_t size;
00759 
00760    // If the data structure of vtk for image/volume representation
00761    // were straigthforwards the following would be enough:
00762    //    GdcmFile.GetImageDataIntoVector((void*)Dest, size);
00763    // But vtk chooses to invert the lines of an image, that is the last
00764    // line comes first (for some axis related reasons?). Hence we need
00765    // to load the image line by line, starting from the end.
00766 
00767    int lineSize   = NumComponents * numColumns * f->GetPixelSize();
00768    int planeSize  = lineSize * numLines;
00769 
00770    unsigned char *src;
00771    
00772    if( fileH->GetFile()->HasLUT() && AllowLookupTable )
00773    {
00774       // to avoid bcc 5.5 w
00775       /*size               = */ fileH->GetImageDataSize(); 
00776       src                = (unsigned char*) fileH->GetImageDataRaw();
00777       unsigned char *lut = (unsigned char*) fileH->GetLutRGBA();
00778 
00779       if(!this->LookupTable)
00780       {
00781          this->LookupTable = vtkLookupTable::New();
00782       }
00783 
00784       this->LookupTable->SetNumberOfTableValues(256);
00785       for (int tmp=0; tmp<256; tmp++)
00786       {
00787          this->LookupTable->SetTableValue(tmp,
00788          (float)lut[4*tmp+0]/255.0,
00789          (float)lut[4*tmp+1]/255.0,
00790          (float)lut[4*tmp+2]/255.0,
00791          1);
00792       }
00793       this->LookupTable->SetRange(0,255);
00794       vtkDataSetAttributes *a = this->GetOutput()->GetPointData();
00795       a->GetScalars()->SetLookupTable(this->LookupTable);
00796       free(lut);
00797    }
00798    else
00799    {
00800       //size = fileH->GetImageDataSize(); 
00801       // useless - just an accessor;  'size' unused
00802       src  = (unsigned char*)fileH->GetImageData();  
00803    } 
00804 
00805    unsigned char *dst = dest + planeSize - lineSize;
00806    for (int plane = 0; plane < numPlanes; plane++)
00807    {
00808       for (int line = 0; line < numLines; line++)
00809       {
00810          // Copy one line at proper destination:
00811          memcpy((void*)dst, (void*)src, lineSize);
00812          src += lineSize;
00813          dst -= lineSize;
00814          // Update progress related:
00815          if (!(updateProgressCount%updateProgressTarget))
00816          {
00817             this->UpdateProgress(updateProgressCount/(50.0*updateProgressTarget));
00818          }
00819          updateProgressCount++;
00820       }
00821       dst += 2 * planeSize;
00822    }
00823 
00824    fileH->Delete();
00825 }

static vtkGdcmReader* vtkGdcmReader::New  )  [static]
 

Referenced by main().

void vtkGdcmReader::PrintSelf ostream &  os,
vtkIndent  indent
 

Definition at line 103 of file vtkGdcmReader.cxx.

References FileNameList.

00104 {
00105    this->Superclass::PrintSelf(os,indent);
00106    os << indent << "Filenames  : " << endl;
00107    vtkIndent nextIndent = indent.GetNextIndent();
00108    for (std::list<std::string>::iterator it = FileNameList.begin();
00109         it != FileNameList.end();
00110         ++it)
00111    {
00112       os << nextIndent << it->c_str() << endl ;
00113    }
00114 }

void vtkGdcmReader::RemoveAllFileName void   )  [virtual]
 

Definition at line 121 of file vtkGdcmReader.cxx.

References FileNameList.

Referenced by ~vtkGdcmReader().

00122 {
00123    this->FileNameList.clear();
00124    this->Modified();
00125 }

void vtkGdcmReader::RemoveAllInternalFile void   )  [private]
 

Definition at line 676 of file vtkGdcmReader.cxx.

References InternalFileList, and OwnFile.

Referenced by ExecuteInformation().

00677 {
00678    if(this->OwnFile)
00679    {
00680       for(gdcmFileList::iterator it=InternalFileList.begin();
00681                                  it!=InternalFileList.end();
00682                                  ++it)
00683       {
00684          (*it)->Delete();
00685       }
00686    }
00687    this->InternalFileList.clear();
00688 }

void vtkGdcmReader::RemoveAllInternalFileName void   )  [private]
 

Definition at line 657 of file vtkGdcmReader.cxx.

References InternalFileNameList.

Referenced by BuildFileListFromPattern().

00658 {
00659    this->InternalFileNameList.clear();
00660 }

void vtkGdcmReader::SetCoherentFileList std::vector< gdcm::File * > *  cfl  )  [inline]
 

Definition at line 48 of file vtkGdcmReader.h.

Referenced by main().

00048                                                          {
00049                                                       CoherentFileList = cfl; }    

void vtkGdcmReader::SetFileName const char *  name  )  [virtual]
 

Definition at line 141 of file vtkGdcmReader.cxx.

References FileNameList.

Referenced by main().

00142 {
00143    vtkImageReader2::SetFileName(name);
00144    // Since we maintain a list of filenames, when building a volume,
00145    // (see vtkGdcmReader::AddFileName), we additionaly need to purge
00146    // this list when we manually positionate the filename.
00147    vtkDebugMacro(<< "Clearing all files given with AddFileName");
00148    this->FileNameList.clear();
00149    this->Modified();
00150 }

void vtkGdcmReader::SetUserFunction VOID_FUNCTION_PUINT8_PFILE_POINTER  userFunc  )  [inline]
 

Definition at line 57 of file vtkGdcmReader.h.

Referenced by main().

00058                         { UserFunction = userFunc; } 

bool vtkGdcmReader::TestFileInformation gdcm::File file  )  [protected, virtual]
 

Test the coherent informations of the file with the reference informations used as image caracteristics. The tested informations are :

  • they all share the same X dimensions
  • they all share the same Y dimensions
  • they all share the same Z dimensions
  • they all share the same number of components
  • they all share the same ImageType ( 8 bit signed, or unsigned...)

Returns:
True if the file match, False otherwise

Definition at line 595 of file vtkGdcmReader.cxx.

References AllowLookupTable, gdcm::Document::GetFileName(), gdcm::File::GetNumberOfScalarComponents(), gdcm::File::GetNumberOfScalarComponentsRaw(), gdcm::File::GetPixelSize(), gdcm::File::GetXSize(), gdcm::File::GetYSize(), gdcm::File::GetZSize(), gdcm::File::HasLUT(), NumColumns, NumComponents, NumLines, NumPlanes, and PixelSize.

Referenced by LoadFileInformation().

00596 {
00597    int numColumns = file->GetXSize();
00598    int numLines   = file->GetYSize();
00599    int numPlanes  = file->GetZSize();
00600    int numComponents;
00601    unsigned int pixelSize  = file->GetPixelSize();
00602 
00603    if( file->HasLUT() && this->AllowLookupTable )
00604       numComponents = file->GetNumberOfScalarComponentsRaw();
00605    else
00606       numComponents = file->GetNumberOfScalarComponents(); //rgb or mono
00607 
00608    if( numColumns != this->NumColumns )
00609    {
00610       vtkErrorMacro(<< "File X value doesn't match with the previous ones: "
00611                     << file->GetFileName().c_str()
00612                     << ". Found " << numColumns << ", must be "
00613                     << this->NumColumns);
00614       return false;
00615    }
00616    if( numLines != this->NumLines )
00617    {
00618       vtkErrorMacro(<< "File Y value doesn't match with the previous ones: "
00619                     << file->GetFileName().c_str()
00620                     << ". Found " << numLines << ", must be "
00621                     << this->NumLines);
00622       return false;
00623    }
00624    if( numPlanes != this->NumPlanes )
00625    {
00626       vtkErrorMacro(<< "File Z value doesn't match with the previous ones: "
00627                     << file->GetFileName().c_str()
00628                     << ". Found " << numPlanes << ", must be "
00629                     << this->NumPlanes);
00630       return false;
00631    }
00632    if( numComponents != this->NumComponents )
00633    {
00634       vtkErrorMacro(<< "File Components count doesn't match with the previous ones: "
00635                     << file->GetFileName().c_str()
00636                     << ". Found " << numComponents << ", must be "
00637                     << this->NumComponents);
00638       return false;
00639    }
00640    if( pixelSize != this->PixelSize )
00641    {
00642       vtkErrorMacro(<< "File pixel size doesn't match with the previous ones: "
00643                     << file->GetFileName().c_str()
00644                     << ". Found " << pixelSize << ", must be "
00645                     << this->PixelSize);
00646       return false;
00647    }
00648 
00649    return true;
00650 }

void vtkGdcmReader::UpdateFileInformation  )  [protected, virtual]
 

Update the file informations. This works exactly like LoadFileInformation, but the source of work is the list of coherent files

Definition at line 515 of file vtkGdcmReader.cxx.

References CoherentFileList, GetFileInformation(), InternalFileList, and OwnFile.

Referenced by ExecuteInformation().

00516 {
00517    this->InternalFileList=*(this->CoherentFileList);
00518    this->OwnFile=false;
00519 
00520    for(gdcmFileList::iterator it=InternalFileList.begin();
00521                               it!=InternalFileList.end();
00522                               ++it)
00523    {
00524       if( *it != NULL)
00525       {
00526          GetFileInformation(*it);
00527          break;
00528       }
00529    }
00530 }

vtkGdcmReader::vtkBooleanMacro LoadMode  ,
int 
 

vtkGdcmReader::vtkBooleanMacro AllowLookupTable  ,
bool 
 

vtkGdcmReader::vtkBooleanMacro AllowLightChecking  ,
bool 
 

vtkGdcmReader::vtkGetMacro LoadMode  ,
int 
 

vtkGdcmReader::vtkGetMacro AllowLookupTable  ,
bool 
 

vtkGdcmReader::vtkGetMacro AllowLightChecking  ,
bool 
 

vtkGdcmReader::vtkGetObjectMacro LookupTable  ,
vtkLookupTable 
 

vtkGdcmReader::vtkSetMacro LoadMode  ,
int 
 

vtkGdcmReader::vtkSetMacro AllowLookupTable  ,
bool 
 

vtkGdcmReader::vtkSetMacro AllowLightChecking  ,
bool 
 

vtkGdcmReader::vtkTypeRevisionMacro vtkGdcmReader  ,
vtkImageReader 
 


Member Data Documentation

bool vtkGdcmReader::AllowLightChecking [private]
 

Definition at line 127 of file vtkGdcmReader.h.

bool vtkGdcmReader::AllowLookupTable [private]
 

Definition at line 126 of file vtkGdcmReader.h.

Referenced by GetFileInformation(), LoadImageInMemory(), and TestFileInformation().

gdcmFileList* vtkGdcmReader::CoherentFileList [private]
 

Definition at line 147 of file vtkGdcmReader.h.

Referenced by GetFileInformation(), and UpdateFileInformation().

bool vtkGdcmReader::Execution [private]
 

Definition at line 158 of file vtkGdcmReader.h.

Referenced by ExecuteInformation().

std::list<std::string> vtkGdcmReader::FileNameList [private]
 

Definition at line 146 of file vtkGdcmReader.h.

Referenced by AddFileName(), BuildFileListFromPattern(), PrintSelf(), RemoveAllFileName(), and SetFileName().

vtkTimeStamp vtkGdcmReader::fileTime [private]
 

Definition at line 124 of file vtkGdcmReader.h.

Referenced by ExecuteInformation().

std::string vtkGdcmReader::ImageType [private]
 

Definition at line 141 of file vtkGdcmReader.h.

Referenced by ExecuteInformation(), and GetFileInformation().

gdcmFileList vtkGdcmReader::InternalFileList [private]
 

Definition at line 157 of file vtkGdcmReader.h.

Referenced by BuildData(), LoadFileInformation(), RemoveAllInternalFile(), and UpdateFileInformation().

std::list<std::string> vtkGdcmReader::InternalFileNameList [private]
 

Definition at line 156 of file vtkGdcmReader.h.

Referenced by AddInternalFileName(), BuildFileListFromPattern(), GetFileInformation(), LoadFileInformation(), RemoveAllInternalFileName(), and ~vtkGdcmReader().

int vtkGdcmReader::LoadMode [private]
 

Bit string integer (each one considered as a boolean) Bit 0 : Skip Sequences, if possible Bit 1 : Skip Shadow Groups if possible Bit 2 : Skip Sequences inside a Shadow Group, if possible Probabely (?), some more to add.

Definition at line 167 of file vtkGdcmReader.h.

Referenced by LoadFileInformation().

vtkLookupTable* vtkGdcmReader::LookupTable [private]
 

Definition at line 123 of file vtkGdcmReader.h.

Referenced by LoadImageInMemory(), and ~vtkGdcmReader().

int vtkGdcmReader::NumColumns [private]
 

Definition at line 131 of file vtkGdcmReader.h.

Referenced by BuildData(), ExecuteInformation(), GetFileInformation(), and TestFileInformation().

int vtkGdcmReader::NumComponents [private]
 

Definition at line 139 of file vtkGdcmReader.h.

Referenced by BuildData(), GetFileInformation(), LoadImageInMemory(), and TestFileInformation().

int vtkGdcmReader::NumLines [private]
 

Definition at line 133 of file vtkGdcmReader.h.

Referenced by BuildData(), ExecuteInformation(), GetFileInformation(), IncrementProgress(), and TestFileInformation().

int vtkGdcmReader::NumPlanes [private]
 

Definition at line 135 of file vtkGdcmReader.h.

Referenced by BuildData(), GetFileInformation(), and TestFileInformation().

bool vtkGdcmReader::OwnFile [private]
 

Definition at line 148 of file vtkGdcmReader.h.

Referenced by LoadFileInformation(), RemoveAllInternalFile(), and UpdateFileInformation().

size_t vtkGdcmReader::PixelSize [private]
 

Definition at line 143 of file vtkGdcmReader.h.

Referenced by GetFileInformation(), and TestFileInformation().

int vtkGdcmReader::TotalNumberOfPlanes [private]
 

Definition at line 137 of file vtkGdcmReader.h.

Referenced by ExecuteInformation(), and GetFileInformation().

VOID_FUNCTION_PUINT8_PFILE_POINTER vtkGdcmReader::UserFunction [private]
 

Pointer to a user suplied function to allow modification of pixel order.

Definition at line 170 of file vtkGdcmReader.h.

Referenced by LoadImageInMemory().


The documentation for this class was generated from the following files:
Generated on Fri Jan 20 10:14:30 2006 for gdcm by  doxygen 1.4.4