Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/07/03 12:45:53 $
- Version: $Revision: 1.143 $
+ Date: $Date: 2005/07/07 16:37:40 $
+ Version: $Revision: 1.144 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
+/**
+ * \brief Loader. use SetLoadMode(), SetFileName() before !
+ * @return false if file cannot be open or no swap info was found,
+ * or no tag was found.
+ */
+bool DicomDir::Load( )
+{
+ // We should clean out anything that already exists.
+ Initialize(); // sets all private fields to NULL
+
+ if (!ParseDir)
+ {
+ if ( ! this->Document::Load( ) )
+ return false;
+ }
+ return DoTheLoadingJob( );
+}
+
+/**
+ * \brief Loader. (DEPRECATED : not to break the API)
+ * @param fileName file to be open for parsing
+ * @return false if file cannot be open or no swap info was found,
+ * or no tag was found.
+ */
bool DicomDir::Load(std::string const &fileName )
{
- Filename = fileName;
// We should clean out anything that already exists.
+ Initialize(); // sets all private fields to NULL
+ SetFileName( fileName );
+ if (!ParseDir)
+ {
+ if ( ! this->Document::Load( ) )
+ return false;
+ }
+ return DoTheLoadingJob( );
+}
+
+/**
+ * \brief Does the Loading Job (internal use only)
+ * @return false if file cannot be open or no swap info was found,
+ * or no tag was found.
+ */
+bool DicomDir::DoTheLoadingJob( )
+{
+ // We should clean out anything that already exists.
Initialize(); // sets all private fields to NULL
if (!ParseDir)
{
return false;
}
- Document::Load(fileName);
+ if (!Document::Load() )
+ {
+ return false;
+ }
+
if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
{
- gdcmWarningMacro( "Entry HT empty for file: "<< fileName);
+ gdcmWarningMacro( "Entry HT empty for file: "<< GetFileName());
return false;
}
// Directory record sequence
if ( !e )
{
gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
- << " in file " << fileName);
+ << " in file " << GetFileName());
return false;
}
else
{
// Only if user passed a root directory
// ------------------------------------
- if ( fileName == "." )
+ if ( GetFileName() == "." )
{
// user passed '.' as Name
// we get current directory name
SetFileName( dummy ); // will be converted into a string
}
NewMeta();
- gdcmWarningMacro( "Parse directory and create the DicomDir : " << Filename );
-
+ gdcmWarningMacro( "Parse directory and create the DicomDir : "
+ << GetFileName() );
ParseDirectory();
}
return true;
Program: gdcm
Module: $RCSfile: gdcmDicomDir.h,v $
Language: C++
- Date: $Date: 2005/05/03 09:43:04 $
- Version: $Revision: 1.60 $
+ Date: $Date: 2005/07/07 16:37:41 $
+ Version: $Revision: 1.61 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
~DicomDir();
bool Load( std::string const &filename );
+ bool Load( );
void Print(std::ostream &os = std::cout, std::string const &indent = "" );
void SetParseDir(bool parseDir) { ParseDir = parseDir; };
private:
void Initialize();
void CreateDicomDir();
-
+ bool DoTheLoadingJob();
bool AddPatientToEnd(DicomDirPatient *dd);
bool AddStudyToEnd (DicomDirStudy *dd);
bool AddSerieToEnd (DicomDirSerie *dd);
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/07/07 13:55:39 $
- Version: $Revision: 1.261 $
+ Date: $Date: 2005/07/07 16:37:40 $
+ Version: $Revision: 1.262 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Load will set it to true if sucessfull
Group0002Parsed = false;
IsDocumentAlreadyLoaded = false;
+ IsDocumentModified = true;
LoadMode = 0x00000000; // default : load everything, later
+ SetFileName("");
}
/**
- * \brief Constructor (not to break the API)
+ * \brief Constructor (DEPRECATED : not to break the API)
* @param fileName 'Document' (File or DicomDir) to be open for parsing
*/
Document::Document( std::string const &fileName )
// Load will set it to true if sucessfull
IsDocumentAlreadyLoaded = false;
+ IsDocumentModified = true;
- Load(fileName);
+ SetFileName(fileName);
+ Load( );
}
/**
* \brief Canonical destructor.
// Public
/**
- * \brief Loader
+ * \brief Loader. use SetLoadMode(), SetFileName() before !
+ * @return false if file cannot be open or no swap info was found,
+ * or no tag was found.
+ */
+bool Document::Load( )
+{
+ if ( GetFileName() == "" )
+ {
+ gdcmWarningMacro( "Use SetFileName, before !" );
+ return false;
+ }
+ return DoTheLoadingDocumentJob( );
+}
+/**
+ * \brief Loader. (DEPRECATED : not to break the API)
* @param fileName 'Document' (File or DicomDir) to be open for parsing
* @return false if file cannot be open or no swap info was found,
* or no tag was found.
*/
bool Document::Load( std::string const &fileName )
{
- if ( IsDocumentAlreadyLoaded )
- {
- // time waste hunting
+ Filename = fileName;
+ return DoTheLoadingDocumentJob( );
+}
+
+/**
+ * \brief Performs the Loading Job (internal use only)
+ * @return false if file cannot be open or no swap info was found,
+ * or no tag was found.
+ */
+bool Document::DoTheLoadingDocumentJob( )
+{
+ if ( ! IsDocumentModified ) // Nothing to do !
+ return true;
+
// if ( Filename == fileName )
// {
// gdcmWarningMacro( "The file was already parsed inside this "
// return true;
// }
- gdcmWarningMacro( "A file was already parsed inside this "
- << "gdcm::Document (previous name was: "
- << Filename.c_str() << ". New name is :"
- << fileName );
+ //gdcmWarningMacro( "A file was already parsed inside this "
+ // << "gdcm::Document (previous name was: "
+ // << Filename.c_str() << ". New name is :"
+ // << fileName );
// clean out the Entries, if already parsed
// (probabely a mistake from the user)
- ClearEntry();
- }
-
- Filename = fileName;
+ ClearEntry();
Fp = 0;
if ( !OpenFile() )
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2005/06/29 15:58:33 $
- Version: $Revision: 1.113 $
+ Date: $Date: 2005/07/07 16:37:41 $
+ Version: $Revision: 1.114 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
typedef std::list<Element> ListElements;
// Loading
- virtual bool Load( std::string const &filename );
+ virtual bool Load( std::string const &filename );
+ virtual bool Load( );
// Dictionaries
Dict *GetPubDict();
/// Accessor to \ref Filename
const std::string &GetFileName() const { return Filename; }
/// Accessor to \ref Filename
- void SetFileName(std::string const &fileName) { Filename = fileName; }
+ void SetFileName(std::string const &fileName) { if (Filename != fileName)
+ Filename = fileName, IsDocumentModified = true; }
std::ifstream *OpenFile();
bool CloseFile();
* of *each* Shadow Group. The parser will fail if the size is wrong !
* @param mode Load mode to be used
*/
- void SetLoadMode (int mode) { LoadMode = mode; }
+ void SetLoadMode (int mode) { if (LoadMode != mode)
+ LoadMode = mode, IsDocumentModified = true; }
protected:
// Methods
/// Whether the gdcm::Document is already parsed/loaded
/// - False from the creation of the gdcm::Document untill
/// gdcm::Document:Load()
- bool IsDocumentAlreadyLoaded;
+ bool IsDocumentAlreadyLoaded; // FIXME : probabely useless now
+
+ bool IsDocumentModified;
private:
// Methods
void Initialize();
-
+ bool DoTheLoadingDocumentJob();
// Read
void ParseDES(DocEntrySet *set, long offset, long l_max, bool delim_mode);
void ParseSQ (SeqEntry *seq, long offset, long l_max, bool delim_mode);
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2005/07/07 10:12:32 $
- Version: $Revision: 1.248 $
+ Date: $Date: 2005/07/07 16:37:40 $
+ Version: $Revision: 1.249 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
-
/**
* \brief Loader
+ * @return false if file cannot be open or no swap info was found,
+ * or no tag was found.
+ */
+bool File::Load( )
+{
+ if ( ! this->Document::Load( ) )
+ return false;
+
+ return DoTheLoadingJob( );
+}
+/**
+ * \brief Loader. (DEPRECATED : not to break the API)
* @param fileName file to be open for parsing
* @return false if file cannot be open or no swap info was found,
* or no tag was found.
*/
bool File::Load( std::string const &fileName )
{
- if ( ! this->Document::Load( fileName ) )
+ SetFileName( fileName );
+ if ( ! this->Document::Load( ) )
return false;
+ return DoTheLoadingJob( );
+}
+
+/**
+ * \brief Does the Loading Job (internal use only)
+ * @return false if file cannot be open or no swap info was found,
+ * or no tag was found.
+ */
+bool File::DoTheLoadingJob( )
+{
+
// for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010
// We may encounter the 'RETired' (0x0028, 0x0200) tag
// (Image Location") . This entry contains the number of
Program: gdcm
Module: $RCSfile: gdcmFile.h,v $
Language: C++
- Date: $Date: 2005/06/10 14:05:38 $
- Version: $Revision: 1.107 $
+ Date: $Date: 2005/07/07 16:37:41 $
+ Version: $Revision: 1.108 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Loading
bool Load( std::string const &filename );
-
+ bool Load();
// Standard values and informations contained in the header
bool IsReadable();
uint16_t GrPixel;
private:
+ bool DoTheLoadingJob();
void ComputeRLEInfo();
void ComputeJPEGFragmentInfo();
bool ReadTag(uint16_t, uint16_t);