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>
30 #include <creaImageIOSystem.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"
51 namespace fs = boost::filesystem;
55 ///Class used to represent the actual state of the image selected and to perform comparisons on its values
59 ImageExtent(const std::string& x, const std::string& y, const std::string& z, const std::string& t)
61 sscanf(x.c_str(),"%d",&mExtent[0]);
62 sscanf(y.c_str(),"%d",&mExtent[1]);
63 sscanf(z.c_str(),"%d",&mExtent[2]);
64 sscanf(t.c_str(),"%d",&mExtent[3]);
65 if(x==""){mExtent[0]=1;}
66 if(y==""){mExtent[1]=1;}
67 if(z==""){mExtent[2]=1;}
68 if(t==""){mExtent[3]=1;}
70 if (mExtent[3]>1) mDim=4;
71 else if (mExtent[2]>1) mDim=3;
72 else if (mExtent[1]>1) mDim=2;
73 else if (mExtent[0]>1) mDim=1;
79 void Clear() { mExtent[0] = mExtent[1] = mExtent[2] = mExtent[3] = 1; }
81 ///Returns true if the two extents are compatible
82 bool IsCompatible( const ImageExtent& );
84 ///Adds the extent passed as a parameter to the current extent
85 void Add ( const ImageExtent& );
87 ///Returns the ieth position of the extent
88 int Get(int i) { return mExtent[i]; }
90 ///Returns the dimension of the current image
91 void SetDimension(int dim) { mDim=dim; }
93 ///Returns the dimension of the current image
94 int GetDimension() { return mDim; }
101 //======================================================================
103 //======================================================================
105 GimmickView::GimmickView(boost::shared_ptr<Gimmick> gimmick, int threads)
109 GimmickDebugMessage(1,"GimmickView::GimmickView"
111 // Anciently started the threads ...
112 // Threads now automatically start at first image request
116 //======================================================================
118 //======================================================================
120 GimmickView::~GimmickView()
122 GimmickDebugMessage(1,"GimmickView::~GimmickView"
125 //======================================================================
127 //======================================================================
128 /// Initializes the view :
129 /// Creates the TreeViews for all the TreeHandler of the Controller
131 void GimmickView::Initialize()
133 mReaderStarted=false;
135 //======================================================================
137 //======================================================================
139 void GimmickView::Finalize()
143 //======================================================================
145 //======================================================================
146 /// Create the tree views
147 void GimmickView::CreateTreeViews()
149 GimmickMessage(2,"Creating the tree views"<<std::endl);
150 Gimmick::TreeHandlerMapType::const_iterator i;
151 for (i = mGimmick->GetTreeHandlerMap().begin();
152 i!= mGimmick->GetTreeHandlerMap().end();
155 this->CreateTreeView(i->second);
159 /// Create a tree view with a given name
160 void GimmickView::CreateSingleTreeView(std::string &i_name)
162 this->CreateTreeView(mGimmick->GetTreeHandlerMap()[i_name]);
167 //======================================================================
169 //======================================================================
170 /// Updates the TreeView of given name from level l to bottom
171 /// (calls the virtual method TreeView::Update())
172 void GimmickView::UpdateTreeViewLevel(const std::string& t, int l)
174 TreeViewMapType::iterator i;
175 i = GetTreeViewMap().find(t);
176 if ( i == GetTreeViewMap().end() )
178 GimmickError("INTERNAL ERROR : GimmickView::UpdateTreeView : '"
179 <<t<<"' is not in TreeViewMap");
181 i->second->UpdateLevel(l);
184 //======================================================================
185 /// Clears the status and begins a new selection process
186 void GimmickView::ResetExtent()
190 mImageExtent.reset();
195 //======================================================================
197 //======================================================================
198 bool ImageExtent::IsCompatible(const ImageExtent& ie)
200 bool compatible=true;
201 ImageExtent * extent= (ImageExtent*)&ie;
202 if((*extent).Get(0)!=Get(0)
203 || (*extent).Get(1)!=Get(1))
210 //======================================================================
212 //======================================================================
213 void ImageExtent::Add(const ImageExtent& ie)
215 ImageExtent * extent= (ImageExtent*)&ie;
216 mExtent[2]+=(*extent).Get(2);
223 //======================================================================
224 /// No selected image
225 bool GimmickView::NoValidateSelected ()
227 GimmickDebugMessage(2,"Validating selected"<<std::endl);
228 std::string mMessage;
229 mMessage="Cannot have 0 images selected!";
231 modifyValidationSignal(valid);
232 SetMessage(mMessage);
236 //======================================================================
237 ///Validates the dimension compliance of the images with the maximum and
238 ///minimum given, and between their sizes
239 bool GimmickView::ValidateSelected (tree::Node* sel, int min_dim, int max_dim)
241 GimmickDebugMessage(2,"Validating selected"<<std::endl);
242 std::string mMessage;
246 mMessage="Cannot have 0 images selected!";
251 boost::shared_ptr<ImageExtent> ie=boost::shared_ptr<ImageExtent>(new ImageExtent((*sel).GetAttribute("D0028_0010"),
252 (*sel).GetAttribute("D0028_0011"),
253 (*sel).GetAttribute("D0028_0012"),
259 if((mImageExtent->Get(min_dim-1)<2)||(mImageExtent->Get(max_dim)>1))
265 std::stringstream out;
266 out << mImageExtent->GetDimension() << "D image " << mImageExtent->Get(0) << "x"<< mImageExtent->Get(1) << "x"<< mImageExtent->Get(2) <<" selected";
267 mMessage = out.str();
268 mImageExtent->SetDimension(2);
274 if(mImageExtent->IsCompatible(*ie))
276 if(mImageExtent->GetDimension()==max_dim && mImageExtent->Get(max_dim)>2)
278 std::stringstream out;
279 out<<"Cannot add this image to selection : would result in a "<<mImageExtent->GetDimension()+1<<"D image!";
285 std::stringstream out;
286 out<<"Selecting "<<mImageExtent->GetDimension()<<"D images is not allowed !";
290 else if(min_dim==3 && (ie->Get(2)+mImageExtent->Get(2))<2)
292 std::stringstream out;
293 out << "Cannot build the selection as it would result in a ";
294 out << mImageExtent->GetDimension();
295 out << "D image, and the minimum is ";
303 mImageExtent->Add(*ie);
304 std::stringstream out;
305 out << mImageExtent->GetDimension() << "D image " << mImageExtent->Get(0) << "x"<< mImageExtent->Get(1) << "x"<< mImageExtent->Get(2) <<" selected";
306 mMessage = out.str();
311 mMessage="The selected images are not compatible.";
317 modifyValidationSignal(valid);
318 SetMessage(mMessage);
322 //======================================================================
323 void GimmickView::modifyValidationSignal(bool ivalid)
326 mValidationSignal(ivalid);
329 void GimmickView::stopReader()
334 //======================================================================
335 ///Reads Images (Non Threaded)
336 void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s, std::vector<std::string> im, int dimension)
341 #define GIMMICK_NO_IMAGE_SELECTION 0
342 #define GIMMICK_2D_IMAGE_SELECTION 2
343 #define GIMMICK_3D_IMAGE_SELECTION 3
344 #define GIMMICK_4D_IMAGE_SELECTION 4
351 // Create the output data
354 vtkImageData * out=vtkImageData::New();
355 out->ShallowCopy(mReader.GetImage(im.front()));
358 else if (im.size()>1) // Test inutile ? JPR
360 vtkImageData* first = mReader.GetImage( im.front());
364 std::vector<std::string>::iterator it;
365 for (it=im.begin(); it!=im.end(); ++it)
367 vtkImageData* out = vtkImageData::New();
368 out->ShallowCopy(mReader.GetImage(*it));
375 vtkImageData* out = vtkImageData::New();
376 // out->CopyStructure(first);
377 out->SetScalarType(first->GetScalarType());
378 out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
380 //first->GetExtent(ext); // JPR
381 first->GetWholeExtent(ext); // renvoie egalement 0,0 en Z // JPR
385 ext[5] = im.size()-1;
389 ext[5] = ext[5] * im.size()-1; // to deal with multiframes - JPR
393 // LG : TODO : Z Spacing ?
396 first->GetDimensions(dim);
398 out->SetDimensions(dim[0], dim[1], im.size() );
399 out->AllocateScalars();
402 unsigned long imsize = dim[0] * dim[1];
403 imsize = imsize * dim[2] ; // deal with multiframes // JPR
407 // differents formats char , short, etc...
408 // differents components 1..3 ex. jpg ->RGB 3
409 imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
412 // Order the file name vector
415 first->GetSpacing(spc);
417 // OrderTheFileNameVector is not here anymore.
418 // Try orderFilesWithZSpacing from OutputModel FCY
419 // spc[2]=OrderTheFileNameVector(im);
422 out->SetSpacing(spc);
425 std::vector<std::string>::iterator it;
427 for (it=im.begin(); it!=im.end(); ++it)
429 vtkImageData* cur = mReader.GetImage( (*it) );
430 memcpy(out->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
440 //======================================================================
444 //////////////////////////////////////////////////////////
445 // Test if the image is a multiple or single frame.
446 // For the moment only with the creation of vtkImageDta.
447 // TO DO with image size and dim!!!
448 //////////////////////////////////////////////////////////
449 bool GimmickView::isSingle(const std::string i_file)
452 vtkImageData* first = mReader.GetImage( i_file);
454 first->GetDimensions(dim);
465 //////////////////////////////////////////////////////////
466 // get Attributes values for a file
467 //////////////////////////////////////////////////////////
469 void GimmickView::getAttributes(const std::string i_file, std::map<std::string, std::string> &o_infos, OutputAttr i_attr)
471 if(i_attr.inside.size() >0)
473 mGimmick->GetAttributes(i_file,o_infos,i_attr);
475 if(i_attr.outside.size()>0)
477 mReader.getAttributes(i_file,o_infos, i_attr.outside);
481 //////////////////////////////////////////////////////////
482 // create an output structure with n entries = n output
483 //////////////////////////////////////////////////////////
484 void GimmickView::readImages1(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
487 std::vector<std::string>::iterator it;
488 for (it=im.begin(); it!=im.end(); ++it)
491 out.img = vtkImageData::New();
492 out.img->ShallowCopy(mReader.GetImage(*it));
494 getAttributes((*it),out.infos,i_attr);
495 o_output.push_back(out);
497 // If we want only one output information structure, we set it outside the loop
500 getAttributes(im.front(), o_output.front().infos, i_attr);
505 //////////////////////////////////////////////////////////
506 // create an output structure with n entries = 1 output
507 //////////////////////////////////////////////////////////
508 void GimmickView::readImages3(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
509 OutputAttr i_attr, double i_zspc)
512 vtkImageData* first = mReader.GetImage( im.front());
513 out.img = vtkImageData::New();
514 out.img->SetScalarType(first->GetScalarType());
515 out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
517 first->GetWholeExtent(ext); // send also 0,0 in Z
520 ext[5] = im.size()-1;
524 ext[5] = ext[5] * im.size()-1; // to deal with multiframes
526 out.img->SetExtent(ext);
529 first->GetDimensions(dim);
530 first->GetSpacing(spac);
531 out.img->SetSpacing(spac);
532 out.img->SetDimensions(dim[0], dim[1], im.size() );
533 out.img->AllocateScalars();
535 unsigned long imsize = dim[0] * dim[1];
536 imsize = imsize * dim[2] ; // deal with multiframes here
537 // differents formats char , short, etc...
538 // differents components 1..3 ex. jpg ->RGB 3
539 imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
540 // Order the file name vector already did with the OutputModel!!!
541 //!!!!out.img->SetSpacing(i_zspc);
543 std::vector<std::string>::iterator it;
544 for (it=im.begin(); it!=im.end(); ++it)
546 vtkImageData* cur = mReader.GetImage( (*it) );
547 memcpy(out.img->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
550 getAttributes(im.front(),out.infos, i_attr);
551 o_output.push_back(out);
555 // TO DO NO VERY SURE : NEED TO BE TESTED
556 //////////////////////////////////////////////////////////
557 // create an output structure with n entries (T size) = T output (n size)
558 //////////////////////////////////////////////////////////
559 void GimmickView::readImages2(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
560 OutputAttr i_attr, double i_zspc)
562 vtkImageData* first = mReader.GetImage( im.front());
565 first->GetDimensions(dim);
566 first->GetSpacing(spac);
567 // differents formats char , short, etc...
568 // differents components 1..3 ex. jpg ->RGB 3
569 unsigned long imsize = dim[0] * dim[1];
570 imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
572 // Order the file name vector already did with the OutputModel!!!
573 std::vector<std::string>::iterator it;
574 std::vector<OutStrGimmick>::iterator it_out = o_output.begin();
576 for (it=im.begin(); it!=im.end(); ++it, it_out += dim[2])
578 vtkImageData* cur = mReader.GetImage( (*it) );
579 for (int slice= 0 ; slice <dim[2]; slice++)
582 out.img = vtkImageData::New();
583 out.img->SetScalarType(first->GetScalarType());
584 out.img->SetSpacing(spac);
585 out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
587 first->GetWholeExtent(ext); // send also 0,0 in Z
589 out.img->SetExtent(ext);
591 out.img->SetDimensions(dim[0], dim[1], 1 );
592 out.img->AllocateScalars();
594 memcpy(out.img->GetScalarPointer(0,0,0), cur->GetScalarPointer(0,0,slice), imsize);
595 o_output.push_back(out);
598 getAttributes((*it),(*it_out).infos,i_attr);
602 getAttributes(im.front(), o_output.front().infos,i_attr);
607 //////////////////////////////////////////////////////////
608 // create an output structure with n entries (T size) = T + n output
609 //////////////////////////////////////////////////////////
610 void GimmickView::readImages4(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
613 std::vector<std::string>::iterator it;
614 std::vector<OutStrGimmick>::iterator it_out = o_output.begin();
615 vtkImageData* first = mReader.GetImage( im.front());
617 first->GetDimensions(dim);
619 for (int slice= 0 ; slice <dim[2]; slice++)
622 out.img = vtkImageData::New();
623 out.img->SetScalarType(first->GetScalarType());
624 out.img->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
628 first->GetWholeExtent(ext); // send also 0,0 in Z
630 out.img->SetExtent(ext);
631 first->GetSpacing(spac);
632 out.img->SetSpacing(spac);
633 out.img->SetDimensions(dim[0], dim[1], im.size() );
634 out.img->AllocateScalars();
636 unsigned long imsize = dim[0] * dim[1];
637 imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
640 for (it=im.begin(); it!=im.end(); ++it, index ++)
642 vtkImageData* cur = mReader.GetImage( (*it) );
643 memcpy(out.img->GetScalarPointer(0,0,index), cur->GetScalarPointer(0,0,slice), imsize);
644 o_output.push_back(out);
647 if(!i_attr.mult) // No sense to take informations in all images
649 getAttributes(im.front(), o_output.front().infos,i_attr);
655 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
656 // Global function to read Images and create wished output (informations, multiple, type and size of output...)
657 // In function of type (file, vector) and size, the correct readImages function is selected
658 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
659 void GimmickView::readImages(std::vector<OutStrGimmick>& o_output, std::vector<std::string> im,
660 OutputAttr i_attr, int i_dim, double i_zspc)
662 int size = im.size();
670 // Only one image : give it
671 // But take in count multiframe possibility
672 if ( isSingle(im.front()) || i_dim != 1)
674 readImages1(o_output,im, i_attr);
678 readImages2(o_output,im, i_attr,i_zspc);
684 // multiple or single frame
685 if ( isSingle(im.front()) )
687 //we deal with 2D images
691 readImages3(o_output,im, i_attr,i_zspc);
695 readImages1(o_output,im, i_attr);
700 // we deal with multiple frames n x (2D x T)
701 // Differents outputs are avaialable
704 // put all in one output
705 readImages3(o_output,im, i_attr,i_zspc);
710 // put in a vector of n x T (2D)
711 readImages2(o_output,im, i_attr,i_zspc);
715 // put in a vector of n (2D x T)
716 // No transformations.
717 readImages1(o_output,im, i_attr);
721 // put in a vector of T (2D x n)
722 readImages4(o_output,im, i_attr);
730 void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, std::vector<std::string> im, int dimension)
732 // Create the output data
735 // Only one image : give it
736 vtkImageData* out = vtkImageData::New();
737 GimmickDebugMessage(3, "State Check: Full Filename: "
740 out->ShallowCopy(mReader.GetImage(im.front()));
743 else if (im.size()>1) // Test inutile ? JPR
745 /// \TODO fix unused variable 'first'
746 vtkImageData* first = mReader.GetImage( im.front());
750 std::vector<std::string>::iterator it;
751 for (it=im.begin(); it!=im.end(); ++it)
753 vtkImageData* out = vtkImageData::New();
754 out->ShallowCopy(mReader.GetImage(*it));
761 // n *2D + T in a vector :
763 std::vector<std::string>::iterator it;
764 for (it=im.begin(); it!=im.end(); ++it)
766 vtkImageData* out = mReader.GetImage( (*it));
772 //======================================================================
774 //======================================================================
775 ///Requests the reading of an image
776 void GimmickView::RequestReading(tree::Node* n,
777 int prio, int selection_index, boost::shared_ptr<ImagePointerHolder> p)
784 ImageEventType t(n,selection_index);
786 mImageEventMap[n->GetAttribute("FullFileName")] = t;
787 mReader.Request(this,n->GetAttribute("FullFileName"),prio);
789 //======================================================================
791 //======================================================================
793 OnMultiThreadImageReaderEvent(const std::string& filename,
794 MultiThreadImageReaderUser::EventType e,
797 GimmickDebugMessage(7,
798 "MultiThreadImageReader event : "<<e<<std::endl);
801 if (filename.size()==0)
803 //What to do in this case?
805 GimmickDebugMessage(5,
806 "Pushing unknown image in queue"
808 mImageEventQueue.push_back(ImageEventType(image));*/
811 ImageEventTypeMap::iterator i;
812 //JCP 22-06-2009, test mImageEventMap.size() > 0
813 if(mImageEventMap.size()>0){
814 i = mImageEventMap.find(filename);
815 if (i!=mImageEventMap.end())
817 GimmickDebugMessage(5,
818 "Putting image of file '"<<filename<<"' on pointer"
820 ImageEventType ie(i->second);
822 ie.pointerHolder->Set(ie.image);
823 //mImageEventMap.erase(i);
829 std::string mess="ERROR: MultiThreadImageReader: Cannot read image in file ";
832 GimmickMessage(1,mess);
833 ImageEventTypeMap::iterator i;
834 i = mImageEventMap.find(filename);
835 if (i!=mImageEventMap.end())
837 ImageEventType ie(i->second);
839 ie.pointerHolder->Set(GetDefaultImage());
840 //mImageEventMap.erase(i);
844 else if (e==ImageUnloaded)
846 std::string mess="Unloaded image in file ";
849 GimmickMessage(1,mess);
850 ImageEventTypeMap::iterator i;
851 i = mImageEventMap.find(filename);
852 if (i!=mImageEventMap.end())
854 ImageEventType ie(i->second);
856 ie.pointerHolder->Set(GetDefaultImage());
857 //mImageEventMap.erase(i);
862 //====================================================================
864 //====================================================================
865 void GimmickView::ConnectValidationObserver(ValidationCallbackType callback)
867 mValidationSignal.connect(callback);
871 #if defined(USE_GDCM)
872 ////////////////////////////////////////////////////////////////////////
873 void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
876 std::vector<GDCM_NAME_SPACE::FileHelper *> filesH;
877 std::vector<std::string> suid;
878 std::map<std::string, std::string> msuid;
879 std::string tempuid = GDCM_NAME_SPACE::Util::CreateUniqueUID();
881 std::vector<std::string>::iterator it = i_filenames.begin();
882 for(; it != i_filenames.end(); it++)
885 GDCM_NAME_SPACE::File *file;
886 file = GDCM_NAME_SPACE::File::New( );
887 file->SetLoadMode( GDCM_NAME_SPACE::LD_ALL );
888 file->SetFileName( (*it).c_str() );
892 std::cerr << "Sorry, " << (*it).c_str() <<" not a gdcm-readable "
893 << "DICOM / ACR File" <<std::endl;
897 std::cout << " ... is readable " << std::endl;
899 // We need a gdcm::FileHelper, since we want to load the pixels
900 GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(file);
902 uint8_t *imageData = fh->GetImageData();
905 file->AddAnonymizeElement(0x0008, 0x0080, "*");
907 file->AddAnonymizeElement(0x0010, 0x0010, "*");
909 file->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
910 // Study Instance UID
911 file->AddAnonymizeElement(0x0020, 0x000d, tempuid );
913 file->AddAnonymizeElement(0x0010, 0x2154, "3615" );
915 // Aware user will add here more fields to anonymize here
917 // The gdcm::File is modified in memory
919 file->AnonymizeFile();
923 fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
925 fh->WriteDcmExplVR(file->GetFileName() +".ano1" );
926 std::cout << i <<" End Anonymize" << std::cout;
927 file->ClearAnonymizeList();
933 #if defined(USE_GDCM2)
934 void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
938 ////////////////////////////////////////////////////////////////////////
939 //void GimmickView::Anonymize(std::vector<std::string> i_filenames, int type)
942 // gdcm::FileMetaInformation::SetSourceApplicationEntityTitle( "gdcmanon" );
943 // gdcm::Global& g = gdcm::Global::GetInstance();
944 // //if( !resourcespath )
946 // // const char *xmlpathenv = getenv("GDCM_RESOURCES_PATH");
947 // // if( xmlpathenv )
949 // // // Make sure to look for XML dict in user explicitly specified dir first:
950 // // xmlpath = xmlpathenv;
951 // // resourcespath = 1;
954 // // if( resourcespath )
956 // // // xmlpath is set either by the cmd line option or the env var
957 // // if( !g.Prepend( xmlpath.c_str() ) )
959 // // std::cerr << "Specified Resources Path is not valid: " << xmlpath << std::endl;
963 // // All set, then load the XML files:
964 // if( !g.LoadResourcesFiles() )
968 // const gdcm::Defs &defs = g.GetDefs(); (void)defs;
971 // // only read the env var if no explicit cmd line option
972 // // maybe there is an env var defined... let's check
973 // const char *rootuid_env = getenv("GDCM_ROOT_UID");
977 // root = rootuid_env;
982 // // root is set either by the cmd line option or the env var
983 // if( !gdcm::UIDGenerator::IsValid( root.c_str() ) )
985 // std::cerr << "specified Root UID is not valid: " << root << std::endl;
988 // gdcm::UIDGenerator::SetRoot( root.c_str() );
993 // // Get private key/certificate
994 // gdcm::CryptographicMessageSyntax cms;
997 // if( !GetRSAKeys(cms, rsa_path.c_str(), cert_path.c_str() ) )
1001 // cms.SetCipherType( ciphertype );
1004 // // Setup gdcm::Anonymizer
1005 // gdcm::Anonymizer anon;
1007 // anon.SetCryptographicMessageSyntax( &cms );
1011 // for(unsigned int i = 0; i < nfiles; ++i)
1013 // const char *in = filenames[i].c_str();
1014 // const char *out = outfilenames[i].c_str();
1015 // if( !AnonymizeOneFileDumb(anon, in, out, empty_tags, remove_tags, replace_tags_value) )
1017 // //std::cerr << "Could not anonymize: " << in << std::endl;
1024 // // for(unsigned int i = 0; i < nfiles; ++i)
1026 // // const char *in = filenames[i].c_str();
1027 // // const char *out = outfilenames[i].c_str();
1028 // // if( !AnonymizeOneFile(anon, in, out) )
1030 // // //std::cerr << "Could not anonymize: " << in << std::endl;
1038 } // EO namespace creaImageIO