Program: gdcm
Module: $RCSfile: gdcmSerieHelper.cxx,v $
Language: C++
- Date: $Date: 2007/06/04 08:51:24 $
- Version: $Revision: 1.56 $
+ Date: $Date: 2007/09/20 12:44:16 $
+ Version: $Revision: 1.60 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
ClearAll();
UserLessThanFunction = 0;
DirectOrder = true;
+
}
/**
/**
* \brief add an extra 'SerieDetail' for building a 'Serie Identifier'
- * that ensures (hope so) File constistency (Series Instance UID doesn't.
+ * that ensures (hope so) File consistency (Series Instance UID doesn't)
* @param group tag group number we want restrict on a given value
* @param elem tag element number we want restrict on a given value
* @param convert wether we want 'convertion', to allow further ordering
* e.g : 100 would be *before* 20; 000020.00 vs 00100.00 : OK
*/
void SerieHelper::AddSeriesDetail(uint16_t group, uint16_t elem, bool convert)
-{
-
+{
ExDetail d;
d.group = group;
d.elem = elem;
}
}
+/**
+ * \brief Sets the DicomDirSerie
+ * @param se DicomDirSerie to deal with
+ */
+void SerieHelper::SetDicomDirSerie(DicomDirSerie *se)
+{
+ DirList dirList(se);
+
+ DirListType filenames_list = dirList.GetFilenames();
+ for( DirListType::const_iterator it = filenames_list.begin();
+ it != filenames_list.end(); ++it)
+ {
+ AddFileName( *it );
+ }
+}
+
/**
* \brief Sorts the given Fileset
* \warning This could be implemented in a 'Strategy Pattern' approach
std::ostringstream ossOrient;
FileList::const_iterator it = fileSet->begin();
- it ++;
+ //it ++;
for ( ;
it != fileSet->end();
++it)
std::ostringstream ossPosition;
std::string strPosition; // re computed
FileList::const_iterator it = fileSet->begin();
- it ++;
+ //it ++;
for ( ;
it != fileSet->end();
++it)
std::string strTagValue; // read on disc
FileList::const_iterator it = fileSet->begin();
- it ++;
+ //it ++;
for ( ;
it != fileSet->end();
++it)
}
if (!ok)
{
- return false;
+ if (! DropDuplicatePositions)
+ return false;
}
// Now, we could calculate Z Spacing as the difference
++it3)
{
fileList->push_back( (*it3).second );
+ if (DropDuplicatePositions)
+ {
+ it3 = distmultimap.upper_bound((*it3).first); // skip all duplicates
+ if (it3 == distmultimap.end() ) // if last image, stop iterate
+ break;
+ }
}
}
else // user asked for reverse order
{
it4--;
fileList->push_back( (*it4).second );
+ if (DropDuplicatePositions) // skip all duplicates
+ {
+ it4 = distmultimap.upper_bound((*it4).first);
+ if (it4 == distmultimap.begin() ) // if first image, stop iterate
+ break;
+ }
} while (it4 != distmultimap.begin() );
}
* then additional identifying information is used.
* We allow user to add his own critierions, using AddSeriesDetail
* (he knows more than we do about his images!)
- * ex : in tagging series, the only pertnent tag is
+ * ex : in tagging series, the only pertinent tag is
* 0018|1312 [In-plane Phase Encoding Direction] value : ROW/COLUMN
* @param inFile GDCM_NAME_SPACE::File we want to build a Serie Identifier for.
* @return the SeriesIdentifier
* -File class? FileHelper class?-
* @return FileIdentifier (Tokenizable on '%%%'. Hope it's enough !)
*/
-std::string SerieHelper::CreateUserDefinedFileIdentifier( File * inFile )
+std::string SerieHelper::CreateUserDefinedFileIdentifier( File *inFile )
{
// Deal with all user supplied tags.
// (user knows more than we do about his images!)
for(unsigned int i=0; i<s.size(); i++)
{
while(i<s.size()
- && !( s[i] == '.' || s[i] == '%'
+ && !( s[i] == '.' || s[i] == '%' || s[i] == '_'
+ || (s[i] >= '+' && s[i] <= '-')
|| (s[i] >= 'a' && s[i] <= 'z')
|| (s[i] >= '0' && s[i] <= '9')
|| (s[i] >= 'A' && s[i] <= 'Z')))
{
- s.erase(i, 1);
+ //s.erase(i, 1);
+ s.replace(i, 1, "_"); // ImagePositionPatient related stuff will be more human readable
}
}
id += s.c_str();
id += "%%%"; // make the FileIdentifier Tokenizable
}
-
+ id += inFile->GetFileName();
+ id += "%%%";
return id;
}