From: Frederic Cervenansky Date: Fri, 21 May 2010 14:49:23 +0000 (+0000) Subject: improvement in use of gdcm2 and speed database X-Git-Tag: CREATOOLS.2-0-3~26 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=creaImageIO.git;a=commitdiff_plain;h=80dc7421c0a44fa7f37d19c7c5752ff6d0c0d38c improvement in use of gdcm2 and speed database --- diff --git a/src/creaImageIODicomImageReader2.cpp b/src/creaImageIODicomImageReader2.cpp index 713655b..7ae643b 100644 --- a/src/creaImageIODicomImageReader2.cpp +++ b/src/creaImageIODicomImageReader2.cpp @@ -1,5 +1,5 @@ #include - +#include "gdcmStringFilter.h" #include @@ -126,40 +126,45 @@ namespace creaImageIO reader.SetFileName( filename.c_str() ); if (reader.Read()) { - std::map::iterator i; - for (i=attr.begin();i!=attr.end();++i) - { - if ( i->first == "D0004_1500" ) - { - boost::filesystem::path full_path(filename); - std::string f = full_path.leaf(); - i->second = f; - } - else if ( i->first == "FullFileName" ) - { - i->second = filename; - } - else if ( i->first == "FullFileDirectory" ) - { - std::string::size_type last_pos = filename.find_last_of("//"); - //find first separator - i->second = filename.substr(0, last_pos); - } - else + gdcm::StringFilter sf; + sf.SetFile(reader.GetFile()); + std::map::iterator i; + for (i=attr.begin();i!=attr.end();++i) { - uint16_t el; - uint16_t gr; - - tree::AttributeDescriptor::GetDicomGroupElementFromKey(i->first,gr,el); - if ( ( gr!=0 ) && ( el!=0 ) ) - { - - std::string val = GetStringValueFromTag(reader.GetFile().GetDataSet().GetDataElement(gdcm::Tag(gr,el))); - i->second = irclean(val); + if ( i->first == "D0004_1500" ) + { + boost::filesystem::path full_path(filename); + std::string f = full_path.leaf(); + i->second = f; + } + else if ( i->first == "FullFileName" ) + { + i->second = filename; + } + else if ( i->first == "FullFileDirectory" ) + { + std::string::size_type last_pos = filename.find_last_of("//"); + //find first separator + i->second = filename.substr(0, last_pos); + } + else + { + uint16_t el; + uint16_t gr; + tree::AttributeDescriptor::GetDicomGroupElementFromKey(i->first,gr,el); + //if ( ( gr!=0 ) && ( el!=0 ) ) + const gdcm::Tag tag(gr, el); + if( reader.GetFile().GetDataSet().FindDataElement( tag ) ) + { + i->second = irclean(sf.ToString(tag)); + } + else + { + i->second = ""; + } + } } - } } - } } void DicomImageReader::ReadAttributes2(const std::string& filename, diff --git a/src/creaImageIODicomImageReader2.h b/src/creaImageIODicomImageReader2.h index 0cd9056..a267b29 100644 --- a/src/creaImageIODicomImageReader2.h +++ b/src/creaImageIODicomImageReader2.h @@ -7,6 +7,7 @@ #include #include #include +#include #endif class vtkGDCMImageReader; diff --git a/src/creaImageIOGimmickView.cpp b/src/creaImageIOGimmickView.cpp index 2b7c85b..2fbc258 100644 --- a/src/creaImageIOGimmickView.cpp +++ b/src/creaImageIOGimmickView.cpp @@ -218,30 +218,11 @@ namespace creaImageIO } else { - std::string extentx = (*sel).GetAttribute("D0028_0010"); - std::string extenty = (*sel).GetAttribute("D0028_0011"); - std::string extentz = (*sel).GetAttribute("D0028_0012"); - std::string extentt = (*sel).GetAttribute("D0028_0010"); - if( extentx == "" && extenty == "" && extentz == "") - { - // we try to create a vtkImageData just to get dim informations - // Long method need to improve it! - std::string name = (*sel).GetAttribute("FullFileName"); - if (name != "") - { - int dim[3]; - char c[5]; - mReader.GetImage(name)->GetDimensions(dim); - sprintf(c,"%d", dim[0]); - extentx = c; - sprintf(c,"%d", dim[1]); - extenty = c; - sprintf(c,"%d", dim[2]); - extentz = c; - } - } + boost::shared_ptr ie=boost::shared_ptr(new ImageExtent((*sel).GetAttribute("D0028_0010"), + (*sel).GetAttribute("D0028_0011"), + (*sel).GetAttribute("D0028_0012"), + "")); - boost::shared_ptr ie=boost::shared_ptr(new ImageExtent(extentx, extenty, extentz,extentt)); if(mImageExtent==0) { mImageExtent=ie; diff --git a/src/creaImageIOSQLiteTreeHandler.cpp b/src/creaImageIOSQLiteTreeHandler.cpp index 7a296e6..478a4be 100644 --- a/src/creaImageIOSQLiteTreeHandler.cpp +++ b/src/creaImageIOSQLiteTreeHandler.cpp @@ -43,7 +43,8 @@ namespace creaImageIO //===================================================================== bool SQLiteTreeHandler::Open(bool writable) { - // std::cout << "***> SQLiteTreeHandler::Open('"<execDML("PRAGMA synchronous=ON "); if (parent==0) parent = GetTree().GetTree(); return DBLoadChildren(parent,maxlevel); } @@ -238,6 +240,7 @@ namespace creaImageIO try { mDB->open(GetFileName().c_str()); + mDB->execDML("pragma synchronous=off;"); } catch (CppSQLite3Exception& e) { @@ -282,7 +285,7 @@ namespace creaImageIO << e.errorMessage() <execDML("pragma synchronous=off;"); // CREATING TABLES diff --git a/src/creaImageIOWxGimmickView.cpp b/src/creaImageIOWxGimmickView.cpp index f13c5e0..d9f727c 100644 --- a/src/creaImageIOWxGimmickView.cpp +++ b/src/creaImageIOWxGimmickView.cpp @@ -113,6 +113,7 @@ namespace creaImageIO // Sets the current directory to the home dir mCurrentDirectory = std2wx(gimmick->GetHomeDirectory()); + // Connect the AddProgress callback gimmick->ConnectAddProgressObserver ( boost::bind( &WxGimmickView::OnAddProgress , this, _1 ) ); @@ -535,6 +536,7 @@ namespace creaImageIO if (FD->ShowModal()==wxID_OK) { + time(&mstart); std::string dirname = wx2std (FD->GetPath()); bool recurse = isNeedRecursive(dirname); if (recurse) @@ -1208,6 +1210,9 @@ namespace creaImageIO mess << "Files\tscanned\t: " << p.GetNumberScannedFiles() << "\n"; mess << "Files\thandled\t: " << p.GetNumberHandledFiles() << "\n\n"; mess << "Files\tadded \t: " << p.GetNumberAddedFiles() << "\n\n"; + time_t end; + time(&end); + mess << "time to scan :" << difftime(end,mstart) << "sec"; wxMessageBox(std2wx(mess.str()),_T("Addition result"),wxOK,this); } diff --git a/src/creaImageIOWxGimmickView.h b/src/creaImageIOWxGimmickView.h index 63cddad..ad66923 100644 --- a/src/creaImageIOWxGimmickView.h +++ b/src/creaImageIOWxGimmickView.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "wx/progdlg.h" @@ -182,7 +183,7 @@ namespace creaImageIO /// Display a message box with the last addition statistics void DisplayAddSummary(); - + time_t mstart; /// Test a directory to know if contains sub-directory to analyze bool isNeedRecursive(std::string i_name);