2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
29 #include <creaImageIOGimmickView.h>
31 #include "boost/filesystem.hpp"
34 #include <gdcmGlobal.h>
35 #include <gdcmSerieHelper.h>
36 #include <gdcmFileHelper.h>
38 #include <vtkGdcmReader.h>
41 /*#if defined(USE_GDCM2)
42 #include <vtkGDCMImageReader.h>
43 #include "gdcmSystem.h"
44 #include "gdcmCryptographicMessageSyntax.h"
45 #include "gdcmUIDGenerator.h"
46 #include "gdcmAnonymizer.h"
47 #include "gdcmGlobal.h"
50 #pragma warning(disable: 4996)
53 namespace fs = boost::filesystem;
57 ///Class used to represent the actual state of the image selected and to perform comparisons on its values
61 ImageExtent(const std::string& x, const std::string& y, const std::string& z, const std::string& t)
63 sscanf(x.c_str(),"%d",&mExtent[0]);
64 sscanf(y.c_str(),"%d",&mExtent[1]);
65 sscanf(z.c_str(),"%d",&mExtent[2]);
66 sscanf(t.c_str(),"%d",&mExtent[3]);
67 if(x==""){mExtent[0]=1;}
68 if(y==""){mExtent[1]=1;}
69 if(z==""){mExtent[2]=1;}
70 if(t==""){mExtent[3]=1;}
72 if (mExtent[3]>1) mDim=4;
73 else if (mExtent[2]>1) mDim=3;
74 else if (mExtent[1]>1) mDim=2;
75 else if (mExtent[0]>1) mDim=1;
81 void Clear() { mExtent[0] = mExtent[1] = mExtent[2] = mExtent[3] = 1; }
83 ///Returns true if the two extents are compatible
84 bool IsCompatible( const ImageExtent& );
86 ///Adds the extent passed as a parameter to the current extent
87 void Add ( const ImageExtent& );
89 ///Returns the ieth position of the extent
90 int Get(int i) { return mExtent[i]; }
92 ///Returns the dimension of the current image
93 void SetDimension(int dim) { mDim=dim; }
95 ///Returns the dimension of the current image
96 int GetDimension() { return mDim; }
103 //======================================================================
105 //======================================================================
107 GimmickView::GimmickView(boost::shared_ptr<Gimmick> gimmick, int threads)
111 GimmickDebugMessage(1,"GimmickView::GimmickView"
113 // Anciently started the threads ...
114 // Threads now automatically start at first image request
118 //======================================================================
120 //======================================================================
122 GimmickView::~GimmickView()
124 GimmickDebugMessage(1,"GimmickView::~GimmickView"
127 //======================================================================
129 //======================================================================
130 /// Initializes the view :
131 /// Creates the TreeViews for all the TreeHandler of the Controller
133 void GimmickView::Initialize()
135 mReaderStarted=false;
137 //======================================================================
139 //======================================================================
141 void GimmickView::Finalize()
145 //======================================================================
147 //======================================================================
148 /// Create the tree views
149 void GimmickView::CreateTreeViews()
151 GimmickMessage(2,"Creating the tree views"<<std::endl);
152 Gimmick::TreeHandlerMapType::const_iterator i;
153 for (i = mGimmick->GetTreeHandlerMap().begin();
154 i!= mGimmick->GetTreeHandlerMap().end();
157 this->CreateTreeView(i->second);
161 /// Create a tree view with a given name
162 void GimmickView::CreateSingleTreeView(std::string &i_name)
164 this->CreateTreeView(mGimmick->GetTreeHandlerMap()[i_name]);
169 //======================================================================
171 //======================================================================
172 /// Updates the TreeView of given name from level l to bottom
173 /// (calls the virtual method TreeView::Update())
174 void GimmickView::UpdateTreeViewLevel(const std::string& t, int l)
176 TreeViewMapType::iterator i;
177 i = GetTreeViewMap().find(t);
178 if ( i == GetTreeViewMap().end() )
180 GimmickError("INTERNAL ERROR : GimmickView::UpdateTreeView : '"
181 <<t<<"' is not in TreeViewMap");
183 i->second->UpdateLevel(l);
186 //======================================================================
187 /// Clears the status and begins a new selection process
188 void GimmickView::ResetExtent()
192 mImageExtent.reset();
197 //======================================================================
199 //======================================================================
200 bool ImageExtent::IsCompatible(const ImageExtent& ie)
202 bool compatible=true;
203 ImageExtent * extent= (ImageExtent*)&ie;
204 if((*extent).Get(0)!=Get(0)
205 || (*extent).Get(1)!=Get(1))
212 //======================================================================
214 //======================================================================
215 void ImageExtent::Add(const ImageExtent& ie)
217 ImageExtent * extent= (ImageExtent*)&ie;
218 mExtent[2]+=(*extent).Get(2);
225 //======================================================================
226 /// No selected image
227 bool GimmickView::NoValidateSelected ()
229 GimmickDebugMessage(2,"Validating selected"<<std::endl);
230 std::string mMessage;
231 mMessage="Cannot have 0 images selected!";
233 modifyValidationSignal(valid);
234 SetMessage(mMessage);
238 //======================================================================
239 ///Validates the dimension compliance of the images with the maximum and
240 ///minimum given, and between their sizes
241 bool GimmickView::ValidateSelected (tree::Node* sel, int min_dim, int max_dim)
243 GimmickDebugMessage(2,"Validating selected"<<std::endl);
244 std::string mMessage;
248 mMessage="Cannot have 0 images selected!";
253 boost::shared_ptr<ImageExtent> ie=boost::shared_ptr<ImageExtent>(new ImageExtent((*sel).GetAttribute("D0028_0010"),
254 (*sel).GetAttribute("D0028_0011"),
255 (*sel).GetAttribute("D0028_0012"),
261 if((mImageExtent->Get(min_dim-1)<2)||(mImageExtent->Get(max_dim)>1))
267 std::stringstream out;
268 out << mImageExtent->GetDimension() << "D image " << mImageExtent->Get(0) << "x"<< mImageExtent->Get(1) << "x"<< mImageExtent->Get(2) <<" selected";
269 mMessage = out.str();
270 mImageExtent->SetDimension(2);
276 if(mImageExtent->IsCompatible(*ie))
278 if(mImageExtent->GetDimension()==max_dim && mImageExtent->Get(max_dim)>2)
280 std::stringstream out;
281 out<<"Cannot add this image to selection : would result in a "<<mImageExtent->GetDimension()+1<<"D image!";
287 std::stringstream out;
288 out<<"Selecting "<<mImageExtent->GetDimension()<<"D images is not allowed !";
292 else if(min_dim==3 && (ie->Get(2)+mImageExtent->Get(2))<2)
294 std::stringstream out;
295 out << "Cannot build the selection as it would result in a ";
296 out << mImageExtent->GetDimension();
297 out << "D image, and the minimum is ";
305 mImageExtent->Add(*ie);
306 std::stringstream out;
307 out << mImageExtent->GetDimension() << "D image " << mImageExtent->Get(0) << "x"<< mImageExtent->Get(1) << "x"<< mImageExtent->Get(2) <<" selected";
308 mMessage = out.str();
313 mMessage="The selected images are not compatible.";
319 modifyValidationSignal(valid);
320 SetMessage(mMessage);
324 //======================================================================
325 void GimmickView::modifyValidationSignal(bool ivalid)
328 mValidationSignal(ivalid);
331 void GimmickView::stopReader()
336 //======================================================================
337 ///Reads Images (Non Threaded)
338 void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vector<std::string> im, int dimension)
343 #define GIMMICK_NO_IMAGE_SELECTION 0
344 #define GIMMICK_2D_IMAGE_SELECTION 2
345 #define GIMMICK_3D_IMAGE_SELECTION 3
346 #define GIMMICK_4D_IMAGE_SELECTION 4
353 // Create the output data
356 vtkImageData * out=vtkImageData::New();
357 out->ShallowCopy(mReader.GetImage(im.front()));
360 else if (im.size()>1) // Test inutile ? JPR
362 vtkImageData* first = mReader.GetImage( im.front());
366 std::vector<std::string>::iterator it;
367 for (it=im.begin(); it!=im.end(); ++it)
369 vtkImageData* out = vtkImageData::New();
370 out->ShallowCopy(mReader.GetImage(*it));
377 vtkImageData* out = vtkImageData::New();
378 // out->CopyStructure(first);
379 out->SetScalarType(first->GetScalarType());
380 out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
382 //first->GetExtent(ext); // JPR
383 first->GetWholeExtent(ext); // renvoie egalement 0,0 en Z // JPR
387 ext[5] = (int)im.size()-1;
391 ext[5] = ext[5] * (int)im.size()-1; // to deal with multiframes - JPR
395 // LG : TODO : Z Spacing ?
398 first->GetDimensions(dim);
400 out->SetDimensions(dim[0], dim[1], (int)im.size() );
401 out->AllocateScalars();
404 unsigned long imsize = dim[0] * dim[1];
405 imsize = imsize * dim[2] ; // deal with multiframes // JPR
409 // differents formats char , short, etc...
410 // differents components 1..3 ex. jpg ->RGB 3
411 imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
414 // Order the file name vector
417 first->GetSpacing(spc);
419 // OrderTheFileNameVector is not here anymore.
420 // Try orderFilesWithZSpacing from OutputModel FCY
421 // spc[2]=OrderTheFileNameVector(im);
424 out->SetSpacing(spc);
427 std::vector<std::string>::iterator it;
429 for (it=im.begin(); it!=im.end(); ++it)
431 vtkImageData* cur = mReader.GetImage( (*it) );
432 memcpy(out->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
442 //======================================================================
446 //////////////////////////////////////////////////////////
447 // Test if the image is a multiple or single frame.
448 // For the moment only with the creation of vtkImageDta.
449 // TO DO with image size and dim!!!
450 //////////////////////////////////////////////////////////
451 bool GimmickView::isSingle(const std::string i_file)
454 vtkImageData* first = mReader.GetImage( i_file);
456 first->GetDimensions(dim);
467 //////////////////////////////////////////////////////////
468 // get Attributes values for a file
469 //////////////////////////////////////////////////////////
471 void GimmickView::getAttributes(const std::string i_file, std::map<std::string, std::string> &o_infos, OutputAttr i_attr)
473 if(i_attr.inside.size() >0)
475 mGimmick->GetAttributes(i_file,o_infos,i_attr);
477 if(i_attr.outside.size()>0)
479 mReader.getAttributes(i_file,o_infos, i_attr.outside);
483 //////////////////////////////////////////////////////////
484 // create an output structure with n entries = n output
485 //////////////////////////////////////////////////////////
486 void GimmickView::readImages1(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
490 i_attr.outside.push_back("D0019_100a"); // simens Number Of Images In Mosaic
492 std::vector<std::string>::iterator it;
493 for (it=im.begin(); it!=im.end(); ++it)
496 out.img = vtkImageData::New();
497 out.img->ShallowCopy(mReader.GetImage(*it));
500 getAttributes((*it),out.infos,i_attr);
502 o_output.push_back(out);
504 // If we want only one output information structure, we set it outside the loop
507 getAttributes(im.front(), o_output.front().infos, i_attr);
512 //////////////////////////////////////////////////////////
513 // create an output structure with n entries = 1 output
514 //////////////////////////////////////////////////////////
515 void GimmickView::readImages3(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
516 OutputAttr i_attr, double i_zspc)
519 vtkImageData* first = mReader.GetImage( im.front());
520 out.img = vtkImageData::New();
521 out.img->SetScalarType(first->GetScalarType());
522 out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
524 first->GetWholeExtent(ext); // send also 0,0 in Z
527 ext[5] = (int)im.size()-1;
529 ext[5] = ext[5] * (int)im.size()-1; // to deal with multiframes
531 out.img->SetExtent(ext);
534 first->GetDimensions(dim);
535 first->GetSpacing(spac);
536 out.img->SetSpacing(spac);
537 out.img->SetDimensions(dim[0], dim[1], (int)im.size() );
538 out.img->AllocateScalars();
540 unsigned long imsize = dim[0] * dim[1];
541 imsize = imsize * dim[2] ; // deal with multiframes here
542 // differents formats char , short, etc...
543 // differents components 1..3 ex. jpg ->RGB 3
544 imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
545 // Order the file name vector already did with the OutputModel!!!
546 //!!!!out.img->SetSpacing(i_zspc);
548 std::vector<std::string>::iterator it;
549 for (it=im.begin(); it!=im.end(); ++it)
551 vtkImageData* cur = mReader.GetImage( (*it) );
552 memcpy(out.img->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
555 getAttributes(im.front(),out.infos, i_attr);
556 o_output.push_back(out);
560 // TO DO NO VERY SURE : NEED TO BE TESTED
561 //////////////////////////////////////////////////////////
562 // create an output structure with n entries (T size) = T output (n size)
563 //////////////////////////////////////////////////////////
564 void GimmickView::readImages2(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
565 OutputAttr i_attr, double i_zspc)
567 vtkImageData* first = mReader.GetImage( im.front());
570 first->GetDimensions(dim);
571 first->GetSpacing(spac);
572 // differents formats char , short, etc...
573 // differents components 1..3 ex. jpg ->RGB 3
574 unsigned long imsize = dim[0] * dim[1];
575 imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
577 // Order the file name vector already did with the OutputModel!!!
578 std::vector<std::string>::iterator it;
579 std::vector<OutStrGimmick>::iterator it_out = o_output.begin();
581 for (it=im.begin(); it!=im.end(); ++it)//, it_out ++)
583 vtkImageData* cur = mReader.GetImage( (*it) );
584 for (int slice= 0 ; slice <dim[2]; slice++)
587 out.img = vtkImageData::New();
588 out.img->SetScalarType(first->GetScalarType());
589 out.img->SetSpacing(spac);
590 out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
592 first->GetWholeExtent(ext); // send also 0,0 in Z
594 out.img->SetExtent(ext);
596 out.img->SetDimensions(dim[0], dim[1], 1 );
597 out.img->AllocateScalars();
599 memcpy(out.img->GetScalarPointer(0,0,0), cur->GetScalarPointer(0,0,slice), imsize);
600 o_output.push_back(out);
603 // getAttributes((*it),(*it_out).infos,i_attr);
607 getAttributes(im.front(), o_output.front().infos,i_attr);
612 //////////////////////////////////////////////////////////
613 // create an output structure with n entries (T size) = T + n output
614 //////////////////////////////////////////////////////////
615 void GimmickView::readImages4(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
618 std::vector<std::string>::iterator it;
619 std::vector<OutStrGimmick>::iterator it_out = o_output.begin();
620 vtkImageData* first = mReader.GetImage( im.front());
622 first->GetDimensions(dim);
624 for (int slice= 0 ; slice <dim[2]; slice++)
627 out.img = vtkImageData::New();
628 out.img->SetScalarType(first->GetScalarType());
629 out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
633 first->GetWholeExtent(ext); // send also 0,0 in Z
635 out.img->SetExtent(ext);
636 first->GetSpacing(spac);
637 out.img->SetSpacing(spac);
638 out.img->SetDimensions(dim[0], dim[1], (int)im.size() );
639 out.img->AllocateScalars();
641 unsigned long imsize = dim[0] * dim[1];
642 imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
645 for (it=im.begin(); it!=im.end(); ++it, index ++)
647 vtkImageData* cur = mReader.GetImage( (*it) );
648 memcpy(out.img->GetScalarPointer(0,0,index), cur->GetScalarPointer(0,0,slice), imsize);
649 o_output.push_back(out);
652 if(!i_attr.mult) // No sense to take informations in all images
654 getAttributes(im.front(), o_output.front().infos,i_attr);
660 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
661 // Global function to read Images and create wished output (informations, multiple, type and size of output...)
662 // In function of type (file, vector) and size, the correct readImages function is selected
663 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
664 void GimmickView::readImages(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
665 OutputAttr i_attr, int i_dim, double i_zspc)
667 int size = (int)im.size();
671 } else if (size == 1) {
673 // Only one image : give it
674 // But take in count multiframe possibility
675 if ( isSingle(im.front()) || i_dim != 1)
677 readImages1(o_output,im, i_attr);
679 readImages2(o_output,im, i_attr,i_zspc);
682 // multiple or single frame
683 if ( isSingle(im.front()) )
685 //we deal with 2D images
689 readImages3(o_output,im, i_attr,i_zspc);
691 readImages1(o_output,im, i_attr);
694 // we deal with multiple frames n x (2D x T)
695 // Differents outputs are avaialable
698 // put all in one output
699 readImages3(o_output,im, i_attr,i_zspc);
700 } else if( i_dim == 2) {
701 // put in a vector of n x T (2D)
702 readImages2(o_output,im, i_attr,i_zspc);
703 } else if( i_dim == 3) {
704 // put in a vector of n (2D x T)
705 // No transformations.
706 readImages1(o_output,im, i_attr);
708 // put in a vector of T (2D x n)
709 readImages4(o_output,im, i_attr);
711 } //isSingle(im.front())
714 //EED UnMosaic step...
715 //How to verifie if is a mosaic file , with how many images inside??
721 void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, std::vector<std::string> im, int dimension)
723 // Create the output data
726 // Only one image : give it
727 vtkImageData* out = vtkImageData::New();
728 GimmickDebugMessage(3, "State Check: Full Filename: "
731 out->ShallowCopy(mReader.GetImage(im.front()));
734 else if (im.size()>1) // Test inutile ? JPR
736 /// \TODO fix unused variable 'first'
737 // vtkImageData* first = mReader.GetImage( im.front());
741 std::vector<std::string>::iterator it;
742 for (it=im.begin(); it!=im.end(); ++it)
744 vtkImageData* out = vtkImageData::New();
745 out->ShallowCopy(mReader.GetImage(*it));
750 // n *2D + T in a vector :
752 std::vector<std::string>::iterator it;
753 for (it=im.begin(); it!=im.end(); ++it)
755 vtkImageData* out = mReader.GetImage( (*it));
761 //======================================================================
763 //======================================================================
764 ///Requests the reading of an image
765 void GimmickView::RequestReading(tree::Node* n,
766 int prio, int selection_index, boost::shared_ptr<ImagePointerHolder> p)
773 ImageEventType t(n,selection_index);
775 mImageEventMap[n->GetAttribute("FullFileName")] = t;
776 mReader.Request(this,n->GetAttribute("FullFileName"),prio);
778 //======================================================================
780 //======================================================================
782 OnMultiThreadImageReaderEvent(const std::string& filename,
783 MultiThreadImageReaderUser::EventType e,
786 GimmickDebugMessage(7,
787 "MultiThreadImageReader event : "<<e<<std::endl);
790 if (filename.size()==0)
792 //What to do in this case?
794 GimmickDebugMessage(5,
795 "Pushing unknown image in queue"
797 mImageEventQueue.push_back(ImageEventType(image));*/
800 ImageEventTypeMap::iterator i;
801 //JCP 22-06-2009, test mImageEventMap.size() > 0
802 if(mImageEventMap.size()>0){
803 i = mImageEventMap.find(filename);
804 if (i!=mImageEventMap.end())
806 GimmickDebugMessage(5,
807 "Putting image of file '"<<filename<<"' on pointer"
809 ImageEventType ie(i->second);
811 ie.pointerHolder->Set(ie.image);
812 //mImageEventMap.erase(i);
818 std::string mess="ERROR: MultiThreadImageReader: Cannot read image in file ";
821 GimmickMessage(1,mess);
822 ImageEventTypeMap::iterator i;
823 i = mImageEventMap.find(filename);
824 if (i!=mImageEventMap.end())
826 ImageEventType ie(i->second);
828 ie.pointerHolder->Set(GetDefaultImage());
829 //mImageEventMap.erase(i);
833 else if (e==ImageUnloaded)
835 std::string mess="Unloaded image in file ";
838 GimmickMessage(1,mess);
839 ImageEventTypeMap::iterator i;
840 i = mImageEventMap.find(filename);
841 if (i!=mImageEventMap.end())
843 ImageEventType ie(i->second);
845 ie.pointerHolder->Set(GetDefaultImage());
846 //mImageEventMap.erase(i);
851 //====================================================================
853 //====================================================================
854 void GimmickView::ConnectValidationObserver(ValidationCallbackType callback)
856 mValidationSignal.connect(callback);
860 #if defined(USE_GDCM)
861 ////////////////////////////////////////////////////////////////////////
862 void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
865 std::vector<GDCM_NAME_SPACE::FileHelper *> filesH;
866 std::vector<std::string> suid;
867 std::map<std::string, std::string> msuid;
868 std::string tempuid = GDCM_NAME_SPACE::Util::CreateUniqueUID();
870 std::vector<std::string>::iterator it = i_filenames.begin();
871 for(; it != i_filenames.end(); it++)
874 GDCM_NAME_SPACE::File *file;
875 file = GDCM_NAME_SPACE::File::New( );
876 file->SetLoadMode( GDCM_NAME_SPACE::LD_ALL );
877 file->SetFileName( (*it).c_str() );
881 std::cerr << "Sorry, " << (*it).c_str() <<" not a gdcm-readable "
882 << "DICOM / ACR File" <<std::endl;
886 std::cout << " ... is readable " << std::endl;
888 // We need a gdcm::FileHelper, since we want to load the pixels
889 GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(file);
892 //EED uint8_t *imageData = fh->GetImageData();
895 file->AddAnonymizeElement(0x0008, 0x0080, "*");
897 file->AddAnonymizeElement(0x0010, 0x0010, "*");
899 file->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
900 // Study Instance UID
901 file->AddAnonymizeElement(0x0020, 0x000d, tempuid );
903 file->AddAnonymizeElement(0x0010, 0x2154, "3615" );
905 // Aware user will add here more fields to anonymize here
907 // The gdcm::File is modified in memory
909 file->AnonymizeFile();
913 fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
915 fh->WriteDcmExplVR(file->GetFileName() +".ano1" );
916 std::cout << i <<" End Anonymize" << std::endl;
917 file->ClearAnonymizeList();
923 #if defined(USE_GDCM2)
924 void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
928 ////////////////////////////////////////////////////////////////////////
929 //void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
932 // gdcm::FileMetaInformation::SetSourceApplicationEntityTitle( "gdcmanon" );
933 // gdcm::Global& g = gdcm::Global::GetInstance();
934 // //if( !resourcespath )
936 // // const char *xmlpathenv = getenv("GDCM_RESOURCES_PATH");
937 // // if( xmlpathenv )
939 // // // Make sure to look for XML dict in user explicitly specified dir first:
940 // // xmlpath = xmlpathenv;
941 // // resourcespath = 1;
944 // // if( resourcespath )
946 // // // xmlpath is set either by the cmd line option or the env var
947 // // if( !g.Prepend( xmlpath.c_str() ) )
949 // // std::cerr << "Specified Resources Path is not valid: " << xmlpath << std::endl;
953 // // All set, then load the XML files:
954 // if( !g.LoadResourcesFiles() )
958 // const gdcm::Defs &defs = g.GetDefs(); (void)defs;
961 // // only read the env var if no explicit cmd line option
962 // // maybe there is an env var defined... let's check
963 // const char *rootuid_env = getenv("GDCM_ROOT_UID");
967 // root = rootuid_env;
972 // // root is set either by the cmd line option or the env var
973 // if( !gdcm::UIDGenerator::IsValid( root.c_str() ) )
975 // std::cerr << "specified Root UID is not valid: " << root << std::endl;
978 // gdcm::UIDGenerator::SetRoot( root.c_str() );
983 // // Get private key/certificate
984 // gdcm::CryptographicMessageSyntax cms;
987 // if( !GetRSAKeys(cms, rsa_path.c_str(), cert_path.c_str() ) )
991 // cms.SetCipherType( ciphertype );
994 // // Setup gdcm::Anonymizer
995 // gdcm::Anonymizer anon;
997 // anon.SetCryptographicMessageSyntax( &cms );
1001 // for(unsigned int i = 0; i < nfiles; ++i)
1003 // const char *in = filenames[i].c_str();
1004 // const char *out = outfilenames[i].c_str();
1005 // if( !AnonymizeOneFileDumb(anon, in, out, empty_tags, remove_tags, replace_tags_value) )
1007 // //std::cerr << "Could not anonymize: " << in << std::endl;
1014 // // for(unsigned int i = 0; i < nfiles; ++i)
1016 // // const char *in = filenames[i].c_str();
1017 // // const char *out = outfilenames[i].c_str();
1018 // // if( !AnonymizeOneFile(anon, in, out) )
1020 // // //std::cerr << "Could not anonymize: " << in << std::endl;
1028 } // EO namespace creaImageIO