vtkGdcmWriter Class Reference

#include <vtkGdcmWriter.h>

Collaboration diagram for vtkGdcmWriter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 vtkTypeRevisionMacro (vtkGdcmWriter, vtkImageWriter)
void PrintSelf (ostream &os, vtkIndent indent)
virtual void SetLookupTable (vtkLookupTable *)
 vtkGetObjectMacro (LookupTable, vtkLookupTable)
void SetWriteTypeToDcmImplVR ()
void SetWriteTypeToDcmExplVR ()
void SetWriteTypeToAcr ()
void SetWriteTypeToAcrLibido ()
void SetContentTypeToUserOwnImage ()
void SetContentTypeToFilteredImage ()
void SetContentTypeToUserCreatedImage ()
void SetContentTypeToUnmodifiedPixelsImage ()
 vtkSetMacro (WriteType, int)
 vtkGetMacro (WriteType, int)
const char * GetWriteTypeAsString ()
 vtkSetMacro (GdcmFile, GDCM_NAME_SPACE::File *)
 vtkGetMacro (GdcmFile, GDCM_NAME_SPACE::File *)
 vtkSetMacro (ContentType, int)
 vtkGetMacro (ContentType, int)
void SetMedicalImageProperties (vtkMedicalImageProperties *)

Static Public Member Functions

static vtkGdcmWriterNew ()

Protected Member Functions

 vtkGdcmWriter ()
 ~vtkGdcmWriter ()
virtual void RecursiveWrite (int axis, vtkImageData *image, ofstream *file)
virtual void RecursiveWrite (int axis, vtkImageData *image, vtkImageData *cache, ofstream *file)
void WriteDcmFile (char *fileName, vtkImageData *image)

Private Attributes

vtkLookupTableLookupTable
vtkMedicalImageProperties * MedicalImageProperties
int WriteType
GDCM_NAME_SPACE::FileGdcmFile
int ContentType

Detailed Description

Definition at line 45 of file vtkGdcmWriter.h.


Constructor & Destructor Documentation

vtkGdcmWriter::vtkGdcmWriter  )  [protected]
 

Definition at line 45 of file vtkGdcmWriter.cxx.

References ContentType, GdcmFile, MedicalImageProperties, VTK_GDCM_WRITE_TYPE_EXPLICIT_VR, VTK_GDCM_WRITE_TYPE_USER_OWN_IMAGE, and WriteType.

00046 {
00047    this->LookupTable = NULL;
00048    this->MedicalImageProperties = NULL;
00049    this->FileDimensionality = 3;
00050    this->WriteType = VTK_GDCM_WRITE_TYPE_EXPLICIT_VR;
00051    this->GdcmFile = 0;
00052    this->ContentType = VTK_GDCM_WRITE_TYPE_USER_OWN_IMAGE;
00053 }

vtkGdcmWriter::~vtkGdcmWriter  )  [protected]
 

Definition at line 55 of file vtkGdcmWriter.cxx.

References SetLookupTable(), and SetMedicalImageProperties().

00056 {
00057    this->SetMedicalImageProperties(NULL);
00058    this->SetLookupTable(NULL);
00059 }


Member Function Documentation

const char * vtkGdcmWriter::GetWriteTypeAsString  ) 
 

Definition at line 72 of file vtkGdcmWriter.cxx.

References VTK_GDCM_WRITE_TYPE_ACR, VTK_GDCM_WRITE_TYPE_ACR_LIBIDO, VTK_GDCM_WRITE_TYPE_EXPLICIT_VR, VTK_GDCM_WRITE_TYPE_IMPLICIT_VR, and WriteType.

Referenced by PrintSelf().

00073 {
00074    switch(WriteType)
00075    {
00076       case VTK_GDCM_WRITE_TYPE_EXPLICIT_VR :
00077          return "Explicit VR";
00078       case VTK_GDCM_WRITE_TYPE_IMPLICIT_VR :
00079          return "Implicit VR";
00080       case VTK_GDCM_WRITE_TYPE_ACR :
00081          return "ACR";
00082       case VTK_GDCM_WRITE_TYPE_ACR_LIBIDO :
00083          return "ACR Libido";
00084       default :
00085          return "Unknow type";
00086    }
00087 }

static vtkGdcmWriter* vtkGdcmWriter::New  )  [static]
 

void vtkGdcmWriter::PrintSelf ostream &  os,
vtkIndent  indent
 

Definition at line 63 of file vtkGdcmWriter.cxx.

References GetWriteTypeAsString().

00064 {
00065    this->Superclass::PrintSelf(os, indent);
00066 
00067    os << indent << "Write type : " << this->GetWriteTypeAsString();
00068 }

void vtkGdcmWriter::RecursiveWrite int  axis,
vtkImageData *  image,
vtkImageData *  cache,
ofstream *  file
[protected, virtual]
 

Definition at line 328 of file vtkGdcmWriter.cxx.

References RecursiveWrite(), and WriteDcmFile().

00330 {
00331    int idx, min, max;
00332 
00333    // if the file is already open then just write to it
00334    if( file )
00335    {
00336       vtkErrorMacro( <<  "File musn't be open");
00337       return;
00338    }
00339 
00340    // if we need to open another slice, do it
00341    if( (axis + 1) == this->FileDimensionality )
00342    {
00343       // determine the name
00344       if (this->FileName)
00345       {
00346          sprintf(this->InternalFileName, "%s", this->FileName);
00347       }
00348       else 
00349       {
00350          if (this->FilePrefix)
00351          {
00352             sprintf(this->InternalFileName, this->FilePattern, 
00353             this->FilePrefix, this->FileNumber);
00354          }
00355          else
00356          {
00357             sprintf(this->InternalFileName, this->FilePattern,this->FileNumber);
00358          }
00359 // Remove this code in case user is using VTK 4.2...
00360 #if !(VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION == 2)
00361          if (this->FileNumber < this->MinimumFileNumber)
00362          {
00363             this->MinimumFileNumber = this->FileNumber;
00364          }
00365          else if (this->FileNumber > this->MaximumFileNumber)
00366          {
00367             this->MaximumFileNumber = this->FileNumber;
00368          }
00369 #endif
00370       }
00371 
00372       // Write the file
00373       WriteDcmFile(this->InternalFileName,image);
00374       ++this->FileNumber;
00375       return;
00376    }
00377 
00378    // if the current region is too high a dimension for the file
00379    // the we will split the current axis
00380    cache->GetAxisUpdateExtent(axis, min, max);
00381 
00382    // if it is the y axis then flip by default
00383    if (axis == 1 && !this->FileLowerLeft)
00384    {
00385       for(idx = max; idx >= min; idx--)
00386       {
00387          cache->SetAxisUpdateExtent(axis, idx, idx);
00388          this->RecursiveWrite(axis - 1, cache, image, file);
00389       }
00390    }
00391    else
00392    {
00393       for(idx = min; idx <= max; idx++)
00394       {
00395          cache->SetAxisUpdateExtent(axis, idx, idx);
00396          this->RecursiveWrite(axis - 1, cache, image, file);
00397       }
00398    }
00399 
00400    // restore original extent
00401    cache->SetAxisUpdateExtent(axis, min, max);
00402 }

void vtkGdcmWriter::RecursiveWrite int  axis,
vtkImageData *  image,
ofstream *  file
[protected, virtual]
 

Write of the files The call to this method is recursive if there is some files to write

Definition at line 306 of file vtkGdcmWriter.cxx.

Referenced by RecursiveWrite().

00308 {
00309    if(file)
00310    {
00311       vtkErrorMacro( <<  "File must not be open");
00312       return;
00313    }
00314 
00315    if( image->GetScalarType() == VTK_FLOAT || 
00316        image->GetScalarType() == VTK_DOUBLE )
00317    {
00318       vtkErrorMacro(<< "Bad input type. Scalar type must not be of type "
00319                     << "VTK_FLOAT or VTK_DOUBLE (found:"
00320                     << image->GetScalarTypeAsString() << ")" );
00321       return;
00322    }
00323 
00324    RecursiveWrite(axis,image, image, file);
00325    //WriteDcmFile(this->FileName,image);
00326 }

void vtkGdcmWriter::SetContentTypeToFilteredImage  )  [inline]
 

Definition at line 77 of file vtkGdcmWriter.h.

References VTK_GDCM_WRITE_TYPE_FILTERED_IMAGE.

00077 {SetContentType(VTK_GDCM_WRITE_TYPE_FILTERED_IMAGE);}   

void vtkGdcmWriter::SetContentTypeToUnmodifiedPixelsImage  )  [inline]
 

Definition at line 79 of file vtkGdcmWriter.h.

References VTK_GDCM_WRITE_TYPE_UNMODIFIED_PIXELS_IMAGE.

void vtkGdcmWriter::SetContentTypeToUserCreatedImage  )  [inline]
 

Definition at line 78 of file vtkGdcmWriter.h.

References VTK_GDCM_WRITE_TYPE_CREATED_IMAGE.

00078 {SetContentType(VTK_GDCM_WRITE_TYPE_CREATED_IMAGE);}   

void vtkGdcmWriter::SetContentTypeToUserOwnImage  )  [inline]
 

Definition at line 76 of file vtkGdcmWriter.h.

References VTK_GDCM_WRITE_TYPE_USER_OWN_IMAGE.

00076 {SetContentType(VTK_GDCM_WRITE_TYPE_USER_OWN_IMAGE);}   

virtual void vtkGdcmWriter::SetLookupTable vtkLookupTable  )  [virtual]
 

Referenced by ~vtkGdcmWriter().

void vtkGdcmWriter::SetMedicalImageProperties vtkMedicalImageProperties *   )  [inline]
 

Definition at line 105 of file vtkGdcmWriter.h.

Referenced by ~vtkGdcmWriter().

00105 {}

void vtkGdcmWriter::SetWriteTypeToAcr  )  [inline]
 

Definition at line 59 of file vtkGdcmWriter.h.

References VTK_GDCM_WRITE_TYPE_ACR.

00059 {SetWriteType(VTK_GDCM_WRITE_TYPE_ACR);        }

void vtkGdcmWriter::SetWriteTypeToAcrLibido  )  [inline]
 

Definition at line 60 of file vtkGdcmWriter.h.

References VTK_GDCM_WRITE_TYPE_ACR_LIBIDO.

00060 {SetWriteType(VTK_GDCM_WRITE_TYPE_ACR_LIBIDO); }

void vtkGdcmWriter::SetWriteTypeToDcmExplVR  )  [inline]
 

Definition at line 58 of file vtkGdcmWriter.h.

References VTK_GDCM_WRITE_TYPE_IMPLICIT_VR.

00058 {SetWriteType(VTK_GDCM_WRITE_TYPE_IMPLICIT_VR);}

void vtkGdcmWriter::SetWriteTypeToDcmImplVR  )  [inline]
 

Definition at line 57 of file vtkGdcmWriter.h.

References VTK_GDCM_WRITE_TYPE_EXPLICIT_VR.

00057 {SetWriteType(VTK_GDCM_WRITE_TYPE_EXPLICIT_VR);}

vtkGdcmWriter::vtkGetMacro ContentType  ,
int 
 

vtkGdcmWriter::vtkGetMacro GdcmFile  ,
GDCM_NAME_SPACE::File
 

vtkGdcmWriter::vtkGetMacro WriteType  ,
int 
 

vtkGdcmWriter::vtkGetObjectMacro LookupTable  ,
vtkLookupTable 
 

vtkGdcmWriter::vtkSetMacro ContentType  ,
int 
 

vtkGdcmWriter::vtkSetMacro GdcmFile  ,
GDCM_NAME_SPACE::File
 

vtkGdcmWriter::vtkSetMacro WriteType  ,
int 
 

vtkGdcmWriter::vtkTypeRevisionMacro vtkGdcmWriter  ,
vtkImageWriter 
 

void vtkGdcmWriter::WriteDcmFile char *  fileName,
vtkImageData *  image
[protected]
 

Definition at line 404 of file vtkGdcmWriter.cxx.

References ContentType, GdcmFile, GDCM_NAME_SPACE::FileHelper::New(), GDCM_NAME_SPACE::FileHelper::SetContentType(), SetImageInformation(), GDCM_NAME_SPACE::FileHelper::SetWriteTypeToAcr(), GDCM_NAME_SPACE::FileHelper::SetWriteTypeToAcrLibido(), GDCM_NAME_SPACE::FileHelper::SetWriteTypeToDcmExplVR(), GDCM_NAME_SPACE::FileHelper::SetWriteTypeToDcmImplVR(), VTK_GDCM_WRITE_TYPE_ACR, VTK_GDCM_WRITE_TYPE_ACR_LIBIDO, VTK_GDCM_WRITE_TYPE_EXPLICIT_VR, VTK_GDCM_WRITE_TYPE_IMPLICIT_VR, and GDCM_NAME_SPACE::FileHelper::Write().

Referenced by RecursiveWrite().

00405 {
00406    GDCM_NAME_SPACE::FileHelper *dcmFile;
00407    if ( GdcmFile != 0)
00408       dcmFile = GDCM_NAME_SPACE::FileHelper::New(GdcmFile);
00409    else
00410       dcmFile = GDCM_NAME_SPACE::FileHelper::New();
00411    
00412    // From here, the write of the file begins
00413 
00414    // Set the medical informations:
00415 #if (VTK_MAJOR_VERSION >= 5)  
00416    SetMedicalImageInformation(dcmFile, this->MedicalImageProperties);
00417 #endif
00418       
00419    // Set the image informations
00420    SetImageInformation(dcmFile, image);
00421 
00422    // Write the image
00423    switch(this->WriteType)
00424    {
00425       case VTK_GDCM_WRITE_TYPE_EXPLICIT_VR :
00426          dcmFile->SetWriteTypeToDcmExplVR();
00427          break;
00428       case VTK_GDCM_WRITE_TYPE_IMPLICIT_VR :
00429          dcmFile->SetWriteTypeToDcmImplVR();
00430          break;
00431       case VTK_GDCM_WRITE_TYPE_ACR :
00432          dcmFile->SetWriteTypeToAcr();
00433          break;
00434       case VTK_GDCM_WRITE_TYPE_ACR_LIBIDO :
00435          dcmFile->SetWriteTypeToAcrLibido();
00436          break;
00437       default :
00438          dcmFile->SetWriteTypeToDcmExplVR();
00439    }
00440   
00441    dcmFile->SetContentType((GDCM_NAME_SPACE::ImageContentType)ContentType);
00442  
00443    if(!dcmFile->Write(fileName))
00444    {
00445       vtkErrorMacro( << "File "  <<  this->FileName  <<  "cannot be written by "
00446                      << " the gdcm library");
00447    }
00448    // Clean up
00449    if( dcmFile->GetUserData() && dcmFile->GetUserDataSize()>0 )
00450    {
00451       delete[] dcmFile->GetUserData();
00452    }
00453    dcmFile->Delete();
00454 }


Member Data Documentation

int vtkGdcmWriter::ContentType [private]
 

Definition at line 125 of file vtkGdcmWriter.h.

Referenced by vtkGdcmWriter(), and WriteDcmFile().

GDCM_NAME_SPACE::File* vtkGdcmWriter::GdcmFile [private]
 

Definition at line 123 of file vtkGdcmWriter.h.

Referenced by vtkGdcmWriter(), and WriteDcmFile().

vtkLookupTable* vtkGdcmWriter::LookupTable [private]
 

Definition at line 119 of file vtkGdcmWriter.h.

vtkMedicalImageProperties* vtkGdcmWriter::MedicalImageProperties [private]
 

Definition at line 120 of file vtkGdcmWriter.h.

Referenced by vtkGdcmWriter().

int vtkGdcmWriter::WriteType [private]
 

Definition at line 121 of file vtkGdcmWriter.h.

Referenced by GetWriteTypeAsString(), and vtkGdcmWriter().


The documentation for this class was generated from the following files:
Generated on Fri Aug 24 13:01:20 2007 for gdcm by  doxygen 1.4.6