+ return SingleSerieUIDFileSetHT[SerieUID];
+}
+*/
+//#endif
+
+
+/**
+ * \brief Get the first Fileset while visiting the SingleSerieUIDFileSetmap
+ * @return The first FileList (SingleSerieUIDFileSet) if found, otherwhise 0
+ */
+FileList *SerieHelper::GetFirstSingleSerieUIDFileSet()
+{
+ ItFileSetHt = SingleSerieUIDFileSetHT.begin();
+ if ( ItFileSetHt != SingleSerieUIDFileSetHT.end() )
+ return ItFileSetHt->second;
+ return NULL;
+}
+
+/**
+ * \brief Get the next Fileset while visiting the SingleSerieUIDFileSetmap
+ * \note : meaningfull only if GetNextSingleSerieUIDFileSet() already called
+ * @return The next FileList (SingleSerieUIDFileSet) if found, otherwhise 0
+ */
+FileList *SerieHelper::GetNextSingleSerieUIDFileSet()
+{
+ gdcmAssertMacro (ItFileSetHt != SingleSerieUIDFileSetHT.end());
+
+ ++ItFileSetHt;
+ if ( ItFileSetHt != SingleSerieUIDFileSetHT.end() )
+ return ItFileSetHt->second;
+ return NULL;
+}
+
+/**
+ * \brief Get the SingleSerieUIDFileSet according to its Serie UID
+ * @param SerieUID SerieUID to retrieve
+ * \return pointer to the FileList (SingleSerieUIDFileSet) if found, otherwhise 0
+ */
+FileList *SerieHelper::GetSingleSerieUIDFileSet(std::string SerieUID)
+{
+ if ( SingleSerieUIDFileSetHT.count(SerieUID) == 0 )
+ return 0;
+ return SingleSerieUIDFileSetHT[SerieUID];
+}
+
+/**
+ * \brief Splits a Single SerieUID Fileset according to the Orientations
+ * @param fileSet File Set to be splitted
+ * \return std::map of 'Xcoherent' File sets
+ */
+
+XCoherentFileSetmap SerieHelper::SplitOnOrientation(FileList *fileSet)
+{
+ XCoherentFileSetmap CoherentFileSet;
+
+ int nb = fileSet->size();
+ if (nb == 0 )
+ return CoherentFileSet;
+ float iop[6];
+ std::string strOrient;
+ std::ostringstream ossOrient;
+
+ FileList::const_iterator it = fileSet->begin();
+ //it ++;
+ for ( ;
+ it != fileSet->end();
+ ++it)
+ {
+ // Information is in :
+ // 0020 0037 : Image Orientation (Patient) or
+ // 0020 0035 : Image Orientation (RET)
+
+ // Let's build again the 'cosines' string, to be sure of it's format
+ (*it)->GetImageOrientationPatient(iop);
+
+ ossOrient << iop[0];
+ for (int i = 1; i < 6; i++)
+ {
+ ossOrient << "\\";
+ ossOrient << iop[i];
+ }
+ strOrient = ossOrient.str();
+ ossOrient.str("");
+ if ( CoherentFileSet.count(strOrient) == 0 )
+ {
+ gdcmDebugMacro(" New Orientation :[" << strOrient << "]");
+ // create a File set in 'orientation' position
+ CoherentFileSet[strOrient] = new FileList;
+ }
+ // Current Orientation and DICOM header match; add the file:
+ CoherentFileSet[strOrient]->push_back( (*it) );
+ }
+ return CoherentFileSet;
+}
+
+/**
+ * \brief Splits a 'Single SerieUID' Fileset according to the Positions
+ * @param fileSet File Set to be splitted
+ * \return std::map of 'Xcoherent' File sets
+ */
+
+XCoherentFileSetmap SerieHelper::SplitOnPosition(FileList *fileSet)
+{
+ XCoherentFileSetmap CoherentFileSet;
+
+ int nb = fileSet->size();
+ if (nb == 0 )
+ return CoherentFileSet;
+ float pos[3];
+ std::string strImPos; // read on disc
+ std::ostringstream ossPosition;
+ std::string strPosition; // re computed
+ FileList::const_iterator it = fileSet->begin();
+ //it ++;
+ for ( ;
+ it != fileSet->end();
+ ++it)
+ {
+ // Information is in :
+ // 0020,0032 : Image Position Patient
+ // 0020,0030 : Image Position (RET)
+
+ strImPos = (*it)->GetEntryString(0x0020,0x0032);
+ if ( strImPos == GDCM_UNFOUND)
+ {
+ gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
+ strImPos = (*it)->GetEntryString(0x0020,0x0030); // For ACR-NEMA images
+ if ( strImPos == GDCM_UNFOUND )
+ {
+ gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
+ // User wants to split on the 'Position'
+ // No 'Position' info found.
+ // We return an empty Htable !
+ return CoherentFileSet;
+ }
+ }
+
+ if ( sscanf( strImPos.c_str(), "%f \\%f \\%f ",
+ &pos[0], &pos[1], &pos[2]) != 3 )
+ {
+ gdcmWarningMacro( "Wrong number for Position : ["
+ << strImPos << "]" );
+ return CoherentFileSet;
+ }
+
+ // Let's build again the 'position' string, to be sure of it's format
+
+ ossPosition << pos[0];
+ for (int i = 1; i < 3; i++)
+ {
+ ossPosition << "\\";
+ ossPosition << pos[i];
+ }
+ strPosition = ossPosition.str();
+ ossPosition.str("");
+
+ if ( CoherentFileSet.count(strPosition) == 0 )
+ {
+ gdcmDebugMacro(" New Position :[" << strPosition << "]");
+ // create a File set in 'position' position
+ CoherentFileSet[strPosition] = new FileList;
+ }
+ // Current Position and DICOM header match; add the file:
+ CoherentFileSet[strPosition]->push_back( (*it) );
+ }
+ return CoherentFileSet;
+}
+
+/**
+ * \brief Splits a 'Single SerieUID' File set Coherent according to the
+ * value of a given Tag
+ * @param fileSet File Set to be splitted
+ * @param group group number of the target Element
+ * @param element element number of the target Element
+ * \return std::map of 'Xcoherent' File sets
+ */
+
+XCoherentFileSetmap SerieHelper::SplitOnTagValue(FileList *fileSet,
+ uint16_t group, uint16_t element)
+{
+ XCoherentFileSetmap CoherentFileSet;
+
+ int nb = fileSet->size();
+ if (nb == 0 )
+ return CoherentFileSet;
+
+ std::string strTagValue; // read on disc
+
+ FileList::const_iterator it = fileSet->begin();
+ //it ++;
+ for ( ;
+ it != fileSet->end();
+ ++it)
+ {
+ // Information is in :
+ // 0020,0032 : Image Position Patient
+ // 0020,0030 : Image Position (RET)
+
+ strTagValue = (*it)->GetEntryString(group,element);
+
+ if ( CoherentFileSet.count(strTagValue) == 0 )
+ {
+ gdcmDebugMacro(" New Tag Value :[" << strTagValue << "]");
+ // create a File set in 'position' position
+ CoherentFileSet[strTagValue] = new FileList;
+ }
+ // Current Tag value and DICOM header match; add the file:
+ CoherentFileSet[strTagValue]->push_back( (*it) );
+ }
+ return CoherentFileSet;