+/**
+ * Copy the image and reverse the Y axis
+ */
+// The output data must be deleted by the user of the method !!!
+size_t ReverseData(vtkImageData *image,unsigned char **data)
+{
+#if (VTK_MAJOR_VERSION >= 5)
+ vtkIdType inc[3];
+#else
+ int inc[3];
+#endif
+ int *extent = image->GetUpdateExtent();
+ int dim[3] = {extent[1]-extent[0]+1,
+ extent[3]-extent[2]+1,
+ extent[5]-extent[4]+1};
+
+ size_t lineSize = dim[0] * image->GetScalarSize()
+ * image->GetNumberOfScalarComponents();
+ size_t planeSize = dim[1] * lineSize;
+ size_t size = dim[2] * planeSize;
+
+ if( size>0 )
+ {
+ *data = new unsigned char[size];
+
+ image->GetIncrements(inc);
+ unsigned char *src = (unsigned char *)image->GetScalarPointerForExtent(extent);
+ unsigned char *dst = *data + planeSize - lineSize;
+ for (int plane = extent[4]; plane <= extent[5]; plane++)
+ {
+ for (int line = extent[2]; line <= extent[3]; line++)
+ {
+ // Copy one line at proper destination:
+ memcpy((void*)dst, (void*)src, lineSize);
+
+ src += inc[1] * image->GetScalarSize();
+ dst -= lineSize;
+ }
+ dst += 2 * planeSize;
+ }
+ }
+ else
+ {
+ *data = NULL;
+ }
+
+ return size;
+}
+
+/**
+ * Set the medical informations in the file, based on the user passed
+ * vtkMedicalImageProperties
+ */
+#if (VTK_MAJOR_VERSION >= 5)
+void SetMedicalImageInformation(GDCM_NAME_SPACE::FileHelper *file, vtkMedicalImageProperties *medprop)
+{
+ // For now only do:
+ // PatientName, PatientID, PatientAge, PatientSex, PatientBirthDate, StudyID
+ std::ostringstream str;
+ if( medprop )
+ {
+ if (medprop->GetPatientName())
+ {
+ str.str("");
+ str << medprop->GetPatientName();
+ file->InsertEntryString(str.str(),0x0010,0x0010,"PN"); // PN 1 Patient's Name
+ }
+
+ if (medprop->GetPatientID())
+ {
+ str.str("");
+ str << medprop->GetPatientID();
+ file->InsertEntryString(str.str(),0x0010,0x0020,"LO"); // LO 1 Patient ID
+ }
+
+ if (medprop->GetPatientAge())
+ {
+ str.str("");
+ str << medprop->GetPatientAge();
+ file->InsertEntryString(str.str(),0x0010,0x1010,"AS"); // AS 1 Patient's Age
+ }
+
+ if (medprop->GetPatientSex())
+ {
+ str.str("");
+ str << medprop->GetPatientSex();
+ file->InsertEntryString(str.str(),0x0010,0x0040,"CS"); // CS 1 Patient's Sex
+ }
+
+ if (medprop->GetPatientBirthDate())
+ {
+ str.str("");
+ str << medprop->GetPatientBirthDate();
+ file->InsertEntryString(str.str(),0x0010,0x0030,"DA"); // DA 1 Patient's Birth Date
+ }
+
+ if (medprop->GetStudyID())
+ {
+ str.str("");
+ str << medprop->GetStudyID();
+ file->InsertEntryString(str.str(),0x0020,0x0010,"SH"); // SH 1 Study ID
+ }
+ }
+}
+#endif
+
+/**
+ * Set the data informations in the file
+ */
+void SetImageInformation(GDCM_NAME_SPACE::FileHelper *file, vtkImageData *image)