1 /*=========================================================================
4 Module: $RCSfile: vtkGdcmWriter.h,v $
6 Date: $Date: 2007/06/21 14:47:16 $
7 Version: $Revision: 1.12 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #ifndef __vtkGdcmWriter_h
20 #define __vtkGdcmWriter_h
22 #include "gdcmCommon.h" // To avoid warnings concerning the std
23 #include "gdcmFile.h" // for GDCM_NAME_SPACE::File
25 #include <vtkImageWriter.h>
26 #include <vtkLookupTable.h>
29 //-----------------------------------------------------------------------------
31 #define VTK_GDCM_WRITE_TYPE_EXPLICIT_VR 1
32 #define VTK_GDCM_WRITE_TYPE_IMPLICIT_VR 2
33 #define VTK_GDCM_WRITE_TYPE_ACR 3
34 #define VTK_GDCM_WRITE_TYPE_ACR_LIBIDO 4
36 #define VTK_GDCM_WRITE_TYPE_USER_OWN_IMAGE 1
37 #define VTK_GDCM_WRITE_TYPE_FILTERED_IMAGE 2
38 #define VTK_GDCM_WRITE_TYPE_CREATED_IMAGE 3
39 #define VTK_GDCM_WRITE_TYPE_UNMODIFIED_PIXELS_IMAGE 4
41 //-----------------------------------------------------------------------------
43 class vtkMedicalImageProperties;
45 class VTK_EXPORT vtkGdcmWriter : public vtkImageWriter
48 static vtkGdcmWriter *New();
49 vtkTypeRevisionMacro(vtkGdcmWriter, vtkImageWriter);
51 void PrintSelf(ostream &os, vtkIndent indent);
53 //vtkSetObjectMacro(LookupTable, vtkLookupTable);
54 virtual void SetLookupTable(vtkLookupTable*);
55 vtkGetObjectMacro(LookupTable, vtkLookupTable);
57 void SetWriteTypeToDcmImplVR(){SetWriteType(VTK_GDCM_WRITE_TYPE_EXPLICIT_VR);}
58 void SetWriteTypeToDcmExplVR(){SetWriteType(VTK_GDCM_WRITE_TYPE_IMPLICIT_VR);}
59 void SetWriteTypeToAcr() {SetWriteType(VTK_GDCM_WRITE_TYPE_ACR); }
60 void SetWriteTypeToAcrLibido(){SetWriteType(VTK_GDCM_WRITE_TYPE_ACR_LIBIDO); }
63 // gdcm cannot guess how user built his image (and therefore cannot be clever about some Dicom fields)
64 // It's up to the user to tell gdcm what he did.
65 // -1) user created ex nihilo his own image and wants to write it as a Dicom image.
67 // -2) user modified the pixels of an existing image.
69 // -3) user created a new image, using existing a set of images (eg MIP, MPR, cartography image)
71 // -4) user modified/added some tags *without processing* the pixels (anonymization..
72 // UNMODIFIED_PIXELS_IMAGE
73 // -Probabely some more to be added
74 //(see gdcmFileHelper.h for more explanations)
76 void SetContentTypeToUserOwnImage() {SetContentType(VTK_GDCM_WRITE_TYPE_USER_OWN_IMAGE);}
77 void SetContentTypeToFilteredImage() {SetContentType(VTK_GDCM_WRITE_TYPE_FILTERED_IMAGE);}
78 void SetContentTypeToUserCreatedImage() {SetContentType(VTK_GDCM_WRITE_TYPE_CREATED_IMAGE);}
79 void SetContentTypeToUnmodifiedPixelsImage(){SetContentType(VTK_GDCM_WRITE_TYPE_UNMODIFIED_PIXELS_IMAGE);}
81 vtkSetMacro(WriteType, int);
82 vtkGetMacro(WriteType, int);
83 const char *GetWriteTypeAsString();
88 // Aware user is allowed to pass his own GDCM_NAME_SPACE::File *, so he may set *any Dicom field* he wants.
89 // (including his own Shadow Elements, or any GDCM_NAME_SPACE::SeqEntry)
90 // GDCM_NAME_SPACE::FileHelper::CheckMandatoryElements() will check inconsistencies, as far as it knows how.
91 // Sorry, not yet available under Python.
92 vtkSetMacro(GdcmFile, GDCM_NAME_SPACE::File *);
93 vtkGetMacro(GdcmFile, GDCM_NAME_SPACE::File *);
96 vtkSetMacro(ContentType, int);
97 vtkGetMacro(ContentType, int);
100 // To pass in some extra information from a VTK context a user can pass a
101 // vtkMedicalImageProperties object
102 #if (VTK_MAJOR_VERSION >= 5)
103 void SetMedicalImageProperties(vtkMedicalImageProperties*);
105 void SetMedicalImageProperties(vtkMedicalImageProperties*) {}
112 virtual void RecursiveWrite(int axis, vtkImageData *image, ofstream *file);
113 virtual void RecursiveWrite(int axis, vtkImageData *image,
114 vtkImageData *cache, ofstream *file);
115 void WriteDcmFile(char *fileName, vtkImageData *image);
119 vtkLookupTable *LookupTable;
120 vtkMedicalImageProperties *MedicalImageProperties;
123 GDCM_NAME_SPACE::File *GdcmFile;
129 //-----------------------------------------------------------------------------