+
+
+// --------------------------------------------------------
+// This is just a *very* simple example of user supplied function
+// to mirror (why not ?) the image
+// It's *not* part of gdcm.
+// --------------------------------------------------------
+
+#define UF(ty) \
+ int i, j; \
+ ty *imj; \
+ ty tamp; \
+ for (j=0;j<ny;j++) \
+ { \
+ imj = (ty *)im +j*nx; \
+ for (i=0;i<nx/2;i++) \
+ { \
+ tamp =imj[i]; \
+ imj[i] =imj[nx-1-i]; \
+ imj[nx-1-i]=tamp; \
+ } \
+ } \
+ if (nx%2 != 0) \
+ { \
+ i = nx / 2; \
+ for (j=0;j<ny;j++) \
+ { \
+ imj = (ty *)im +j*nx; \
+ tamp =imj[i]; \
+ imj[i] =imj[nx/2+1]; \
+ imj[nx/2+1]=tamp; \
+ } \
+ }
+
+void userSuppliedMirrorFunction(uint8_t *im, GDCM_NAME_SPACE::File *f)
+{
+ if (f->GetZSize() != 1)
+ {
+ std::cout << "mirror : Multiframe images not yet dealt with" << std::endl;
+ return;
+ }
+
+ if (f->GetSamplesPerPixel() != 1 || f->GetBitsAllocated() == 24)
+ {
+ std::cout << "mirror : RGB / YBR not yet dealt with" << std::endl;
+ return;
+ }
+ int nx = f->GetXSize();
+ int ny = f->GetYSize();
+
+ std::string pixelType = f->GetPixelType();
+ if ( pixelType == "8U" || pixelType == "8S" )
+ {
+ UF(uint8_t)
+ return;
+ }
+ if ( pixelType == "16U" || pixelType == "16S")
+ {
+ UF(uint16_t)
+ return;
+ }
+ std::cout << "mirror : Pixel Size (!=8, !=16) not yet dealt with"
+ << std::endl;
+ return;
+}
+
+
+// --------------------------------------------------------
+// This is just a *very* simple example of user supplied function
+// to topdown (why not ?) the image
+// It's *not* part of gdcm.
+// --------------------------------------------------------
+
+#define UF2(ty) \
+ int i, j; \
+ ty *imj, *imJ; \
+ ty tamp; \
+ for (j=0;j<ny/2;j++) \
+ { \
+ imj = (ty *)im +j*nx; \
+ imJ = (ty *)im +(ny-1-j)*nx; \
+ for (i=0;i<nx;i++) \
+ { \
+ tamp =imj[i]; \
+ imj[i] =imJ[i]; \
+ imJ[i] =tamp; \
+ } \
+ }
+
+void userSuppliedTopDownFunction(uint8_t *im, GDCM_NAME_SPACE::File *f)
+{
+ if (f->GetZSize() != 1)
+ {
+ std::cout << "mirror : Multiframe images not yet dealt with" << std::endl;
+ return;
+ }
+
+ if (f->GetSamplesPerPixel() != 1 || f->GetBitsAllocated() == 24)
+ {
+ std::cout << "mirror : RGB / YBR not yet dealt with" << std::endl;
+ return;
+ }
+ int nx = f->GetXSize();
+ int ny = f->GetYSize();
+
+ std::string pixelType = f->GetPixelType();
+ if ( pixelType == "8U" || pixelType == "8S" )
+ {
+ UF2(uint8_t)
+ return;
+ }
+ if ( pixelType == "16U" || pixelType == "16S")
+ {
+ UF2(uint16_t)
+ return;
+ }
+ std::cout << "topdown : Pixel Size (!=8, !=16) not yet dealt with"
+ << std::endl;
+ return;
+}
+
+// --------------------------------------------------------
+// This is just a *very* simple example of user supplied 'LessThan' function
+// It's *not* part of gdcm.
+//
+// Note : orderNb and elemsToOrderOn are here global variables.
+// Within a 'normal' function they would't be any orderNb and elemsToOrderOn var
+// User *knows* on what field(s) he wants to compare;
+// He just writes a decent function.
+// Here, we want to get info from the command line Argument Manager.
+//
+// Warning : it's up to 'vtkgdcmSerieViewer' user to find a suitable data set !
+// --------------------------------------------------------
+
+
+bool userSuppliedLessThanFunction(GDCM_NAME_SPACE::File *f1, GDCM_NAME_SPACE::File *f2)
+{
+ // for *this* user supplied function, I supposed only ValEntries are checked.
+//
+ std::string s1, s2;
+ GDCM_NAME_SPACE::DataEntry *e1,*e2;
+ for (int ri=0; ri<orderNb; ri++)
+ {
+ std::cout << std::hex << elemsToOrderOn[2*ri] << "|"
+ << elemsToOrderOn[2*ri+1]
+ << std::endl;
+
+ e1= f1->GetDataEntry( elemsToOrderOn[2*ri],
+ elemsToOrderOn[2*ri+1]);
+
+ e2= f2->GetDataEntry( elemsToOrderOn[2*ri],
+ elemsToOrderOn[2*ri+1]);
+ if(!e2 || !e2)
+ {
+ std::cout << std::hex << elemsToOrderOn[2*ri] << "|"
+ << elemsToOrderOn[2*ri+1]
+ << " not found" << std::endl;
+ continue;
+ }
+ s1 = e1->GetString();
+ s2 = e2->GetString();
+ std::cout << "[" << s1 << "] vs [" << s2 << "]" << std::endl;
+ if ( s1 < s2 )
+ return true;
+ else if (s1 == s2 )
+ continue;
+ else
+ return false;
+ }
+ return false; // all fields equal
+}
+
+// --------------------------------------------------------
+// This is just an other *very* simple example of user supplied 'LessThan'
+// function
+// It's *not* part of gdcm.
+//
+// Warning : it's up to 'vtkgdcmSerieViewer' user to find a suitable data set !
+// --------------------------------------------------------
+
+bool userSuppliedLessThanFunction2(GDCM_NAME_SPACE::File *f1, GDCM_NAME_SPACE::File *f2)
+{
+ std::cout << "[" << f1->GetFileName() << "] vs ["
+ << f2->GetFileName() << "]" << std::endl;
+ return f1->GetFileName() < f2->GetFileName();
+}