vtkGdcmWriter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002                                                                                 
00003   Program:   gdcm
00004   Module:    $RCSfile: vtkGdcmWriter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/06/21 14:47:16 $
00007   Version:   $Revision: 1.12 $
00008                                                                                 
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012                                                                                 
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
00016                                                                                 
00017 =========================================================================*/
00018                                                                                 
00019 #ifndef __vtkGdcmWriter_h
00020 #define __vtkGdcmWriter_h
00021 
00022 #include "gdcmCommon.h" // To avoid warnings concerning the std
00023 #include "gdcmFile.h"   // for GDCM_NAME_SPACE::File
00024 
00025 #include <vtkImageWriter.h>
00026 #include <vtkLookupTable.h>
00027 #include <string>
00028 
00029 //-----------------------------------------------------------------------------
00030 
00031 #define VTK_GDCM_WRITE_TYPE_EXPLICIT_VR 1
00032 #define VTK_GDCM_WRITE_TYPE_IMPLICIT_VR 2
00033 #define VTK_GDCM_WRITE_TYPE_ACR         3
00034 #define VTK_GDCM_WRITE_TYPE_ACR_LIBIDO  4
00035 
00036 #define VTK_GDCM_WRITE_TYPE_USER_OWN_IMAGE          1
00037 #define VTK_GDCM_WRITE_TYPE_FILTERED_IMAGE          2
00038 #define VTK_GDCM_WRITE_TYPE_CREATED_IMAGE           3
00039 #define VTK_GDCM_WRITE_TYPE_UNMODIFIED_PIXELS_IMAGE 4
00040 
00041 //-----------------------------------------------------------------------------
00042 class vtkLookupTable;
00043 class vtkMedicalImageProperties;
00044 
00045 class VTK_EXPORT vtkGdcmWriter : public vtkImageWriter
00046 {
00047 public:
00048    static vtkGdcmWriter *New();
00049    vtkTypeRevisionMacro(vtkGdcmWriter, vtkImageWriter);
00050 
00051    void PrintSelf(ostream &os, vtkIndent indent);
00052 
00053    //vtkSetObjectMacro(LookupTable, vtkLookupTable);
00054    virtual void SetLookupTable(vtkLookupTable*);
00055    vtkGetObjectMacro(LookupTable, vtkLookupTable);
00056 
00057    void SetWriteTypeToDcmImplVR(){SetWriteType(VTK_GDCM_WRITE_TYPE_EXPLICIT_VR);}
00058    void SetWriteTypeToDcmExplVR(){SetWriteType(VTK_GDCM_WRITE_TYPE_IMPLICIT_VR);}
00059    void SetWriteTypeToAcr()      {SetWriteType(VTK_GDCM_WRITE_TYPE_ACR);        }
00060    void SetWriteTypeToAcrLibido(){SetWriteType(VTK_GDCM_WRITE_TYPE_ACR_LIBIDO); }
00061    
00062 
00063    // gdcm cannot guess how user built his image (and therefore cannot be clever about some Dicom fields)
00064    // It's up to the user to tell gdcm what he did. 
00065    // -1) user created ex nihilo his own image and wants to write it as a Dicom image.
00066    // USER_OWN_IMAGE
00067    // -2) user modified the pixels of an existing image.
00068    // FILTERED_IMAGE
00069    // -3) user created a new image, using existing a set of images (eg MIP, MPR, cartography image)
00070    //  CREATED_IMAGE
00071    // -4) user modified/added some tags *without processing* the pixels (anonymization..
00072    //  UNMODIFIED_PIXELS_IMAGE 
00073    // -Probabely some more to be added 
00074    //(see gdcmFileHelper.h for more explanations)
00075    
00076    void SetContentTypeToUserOwnImage()         {SetContentType(VTK_GDCM_WRITE_TYPE_USER_OWN_IMAGE);}   
00077    void SetContentTypeToFilteredImage()        {SetContentType(VTK_GDCM_WRITE_TYPE_FILTERED_IMAGE);}   
00078    void SetContentTypeToUserCreatedImage()     {SetContentType(VTK_GDCM_WRITE_TYPE_CREATED_IMAGE);}   
00079    void SetContentTypeToUnmodifiedPixelsImage(){SetContentType(VTK_GDCM_WRITE_TYPE_UNMODIFIED_PIXELS_IMAGE);}   
00080    
00081    vtkSetMacro(WriteType, int);
00082    vtkGetMacro(WriteType, int);
00083    const char *GetWriteTypeAsString();
00084 
00085 
00086 //BTX
00087    // Description:
00088    // Aware user is allowed to pass his own GDCM_NAME_SPACE::File *, so he may set *any Dicom field* he wants.
00089    // (including his own Shadow Elements, or any GDCM_NAME_SPACE::SeqEntry)
00090    // GDCM_NAME_SPACE::FileHelper::CheckMandatoryElements() will check inconsistencies, as far as it knows how.
00091    // Sorry, not yet available under Python.
00092    vtkSetMacro(GdcmFile, GDCM_NAME_SPACE::File *);
00093    vtkGetMacro(GdcmFile, GDCM_NAME_SPACE::File *);
00094 //ETX
00095 
00096    vtkSetMacro(ContentType, int);
00097    vtkGetMacro(ContentType, int);
00098 
00099    // Description:
00100    // To pass in some extra information from a VTK context a user can pass a
00101    // vtkMedicalImageProperties object
00102 #if (VTK_MAJOR_VERSION >= 5)   
00103    void SetMedicalImageProperties(vtkMedicalImageProperties*);
00104 #else
00105    void SetMedicalImageProperties(vtkMedicalImageProperties*) {}
00106 #endif
00107         
00108 protected:
00109    vtkGdcmWriter();
00110    ~vtkGdcmWriter();
00111 
00112   virtual void RecursiveWrite(int axis, vtkImageData *image, ofstream *file);
00113   virtual void RecursiveWrite(int axis, vtkImageData *image, 
00114                               vtkImageData *cache, ofstream *file);
00115   void WriteDcmFile(char *fileName, vtkImageData *image);
00116 
00117 private:
00118 // Variables
00119    vtkLookupTable *LookupTable;
00120    vtkMedicalImageProperties *MedicalImageProperties;   
00121    int WriteType;
00122 //BTX
00123    GDCM_NAME_SPACE::File *GdcmFile;
00124 //ETX
00125    int ContentType;
00126    
00127 };
00128 
00129 //-----------------------------------------------------------------------------
00130 #endif

Generated on Fri Aug 24 12:59:32 2007 for gdcm by  doxygen 1.4.6