ExplicitVR,
ImplicitVR,
ACR,
- ACR_LIBIDO
+ ACR_LIBIDO,
+ DICOMDIR
};
//For now gdcm is not willing cmake, try to be more quiet
{
dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir entry list empty");
}
-
CreateDicomDir();
}
* \brief
* @param exception_on_error
*/
-gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
+gdcmDicomDir::gdcmDicomDir(ListTag *l,
+ bool exception_on_error):
gdcmParser(exception_on_error )
{
-
+ listEntries=*l;
+ CreateDicomDir();
}
-
-
+/*
+ * \ingroup gdcmDicomDir
+ * \brief Canonical destructor
+ */
gdcmDicomDir::~gdcmDicomDir()
{
for(ListPatient::iterator cc = patients.begin();cc!=patients.end();++cc)
}
}
+
+
//-----------------------------------------------------------------------------
// Print
void gdcmDicomDir::Print(std::ostream &os)
//-----------------------------------------------------------------------------
// Public
+
+/**
+ * \ingroup gdcmDicomDir
+ * \brief writes on disc a DICOMDIR
+ * \ warning does NOT add the missing elements in the header :
+ * \ it's up to the user doing it !
+ * @param fileName file to be written to
+ * @return
+ */
+bool gdcmDicomDir::Write(std::string fileName) {
+
+ FILE * fp1;
+ fp1 = fopen(fileName.c_str(),"wb");
+ if (fp1 == NULL) {
+ printf("Failed to open (write) File [%s] \n",fileName.c_str());
+ return (false);
+ }
+ char * filePreamble;
+ filePreamble=(char*)calloc(128,1);
+ fwrite(filePreamble,128,1,fp1);
+ fwrite("DICM",4,1,fp1);
+ free (filePreamble);
+ WriteEntries(DICOMDIR,fp1);
+
+ return true;
+
+}
+
//-----------------------------------------------------------------------------
// Protected
//-----------------------------------------------------------------------------
// Private
-void gdcmDicomDir::CreateDicomDir(void)
+/*
+ * \ingroup gdcmDicomDir
+ * \brief
+ * @param
+ */
+void gdcmDicomDir::CreateDicomDir()
{
// The list is parsed. When a tag is found :
// 1 - we save the beginning iterator
ListTag::iterator begin;
ListTag::iterator end;
- begin=GetListEntry().begin();
+ begin=listEntries.begin();
end=begin;
- for(ListTag::iterator i=GetListEntry().begin();i != GetListEntry().end();++i)
+ for(ListTag::iterator i=listEntries.begin();i != listEntries.end();++i)
{
// std::cout << std::hex << (*i)->GetGroup() <<
// " " << (*i)->GetElement() << endl;
std::string v = (*i)->GetValue();
if (v == "PATIENT ")
{
-// std::cout<<"PATIENT"<<std::endl;
+ // std::cout<<"PATIENT"<<std::endl;
end=i;
AddObjectToEnd(type,begin,end);
if (v == "STUDY ")
{
-// std::cout<<"STUDY"<<std::endl;
+ // std::cout<<"STUDY"<<std::endl;
end=i;
AddObjectToEnd(type,begin,end);
if (v == "SERIES")
{
-// std::cout<<"SERIES"<<std::endl;
+ // std::cout<<"SERIES"<<std::endl;
end=i;
AddObjectToEnd(type,begin,end);
if (v == "IMAGE ")
{
-// std::cout<<"IMAGE"<<std::endl;
+ // std::cout<<"IMAGE"<<std::endl;
end=i;
AddObjectToEnd(type,begin,end);
end=GetListEntry().end();
AddObjectToEnd(type,begin,end);
}
-
+/*
+ * \ingroup gdcmDicomDir
+ * \brief
+ * @param
+ */
void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,ListTag::iterator end)
{
if(begin==end)
}
}
+/*
+ * \ingroup gdcmDicomDir
+ * \brief
+ * @param
+ */
void gdcmDicomDir::AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end)
{
patients.push_back(new gdcmPatient(begin,end));
}
-void gdcmDicomDir::AddStudyToEnd(ListTag::iterator begin,ListTag::iterator end)
+/*
+ * \ingroup gdcmDicomDir
+ * \brief
+ * @param
+ */
+ void gdcmDicomDir::AddStudyToEnd(ListTag::iterator begin,ListTag::iterator end)
{
if(patients.size()>0)
{
(*itp)->AddStudy(new gdcmStudy(begin,end));
}
}
-
+/*
+ * \ingroup gdcmDicomDir
+ * \brief
+ * @param
+ */
void gdcmDicomDir::AddSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
{
if(patients.size()>0)
}
}
-void gdcmDicomDir::AddImageToEnd(ListTag::iterator begin,ListTag::iterator end)
+/*
+ * \ingroup gdcmDicomDir
+ * \brief
+ * @param
+ */
+ void gdcmDicomDir::AddImageToEnd(ListTag::iterator begin,ListTag::iterator end)
{
if(patients.size()>0)
{
class GDCM_EXPORT gdcmDicomDir: public gdcmParser
{
public:
- gdcmDicomDir(bool exception_on_error = false);
- gdcmDicomDir(std::string &FileName,bool exception_on_error = false );
+ gdcmDicomDir(ListTag *l, bool exception_on_error = false);
+ gdcmDicomDir(std::string &FileName,bool exception_on_error = false);
~gdcmDicomDir(void);
virtual void Print(std::ostream &os = std::cout);
inline ListPatient &GetPatients() {return patients;};
+ bool Write(std::string fileName);
+
typedef enum
{
/**
* \ingroup gdcmFile
- * \brief Ecrit sur disque les pixels d'UNE image
- * Aucun test n'est fait sur l'"Endiannerie" du processeur.
+ * \brief Writes on disk A SINGLE Dicom file
+ * NO test is performed on processor "Endiannity".
* Ca sera à l'utilisateur d'appeler son Reader correctement
* (Equivalent a IdImaWriteRawFile)
*
/**
* \ingroup gdcmFile
- * \brief Ecrit sur disque UNE image Dicom
- * Aucun test n'est fait sur l'"Endiannerie" du processeur.
- * Ca fonctionnera correctement (?) sur processeur Intel
- * (Equivalent a IdDcmWrite)
+ * \brief Writes on disk A SINGLE Dicom file
+ * NO test is performed on processor "Endiannity".
*
* @param fileName name of the file to be created
* (any already existing file is overwritten)
FILE * fp1;
fp1 = fopen(fileName.c_str(),"wb");
if (fp1 == NULL) {
- printf("Echec ouverture (ecriture) Fichier [%s] \n",fileName.c_str());
+ printf("Failed to open (write) File [%s] \n",fileName.c_str());
return (false);
}
filePreamble=(char*)calloc(128,1);
fwrite(filePreamble,128,1,fp1);
fwrite("DICM",4,1,fp1);
+ free (filePreamble);
}
// --------------------------------------------------------------
#include "gdcmUtil.h"
#include "gdcmTS.h"
-//-----------------------------------------------------------------------------
-// Refer to gdcmHeader::CheckSwap()
-//const unsigned int gdcmHeader::HEADER_LENGTH_TO_READ = 256;
-
-// Refer to gdcmHeader::SetMaxSizeLoadEntry()
-//const unsigned int gdcmHeader::MAX_SIZE_LOAD_ELEMENT_VALUE = 4096;
//-----------------------------------------------------------------------------
// Constructor / Destructor
//-----------------------------------------------------------------------------
// Print
+// see gdcmParser.cxx
//-----------------------------------------------------------------------------
// Public
/**
#endif
#include <iomanip> // for std::ios::left, ...
+
+#define MAX_SIZE_PRINT_ELEMENT_VALUE 64
+
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
if (printLevel>=1) {
s.setf(std::ios::left);
s << std::setw(66-GetName().length()) << " ";
- }
+ }
+
+ s << "[" << GetName()<< "]";
+
- s << "[" << GetName()<< "]";
- if( (GetLength()<64) || (printLevel>=3) )
+
+ if( (GetLength()<MAX_SIZE_PRINT_ELEMENT_VALUE) ||
+ (printLevel>=3) ||
+ (d2.find("gdcm::NotLoaded.") < d2.length()) )
s << " [" << d2 << "]";
- else
+ else
s << " [ gdcm::too long for print (" << GetLength() << ") ]";
// Display the UID value (instead of displaying the rough code)
// Refer to gdcmParser::CheckSwap()
const unsigned int gdcmParser::HEADER_LENGTH_TO_READ = 256;
-// Refer to gdcmParser::SetMaxSizeLoadElementValue()
+// Refer to gdcmParser::SetMaxSizeLoadEntry()
const unsigned int gdcmParser::MAX_SIZE_LOAD_ELEMENT_VALUE = 4096;
+// Refer to gdcmParser::SetMaxSizePrintEntry()
+// TODO : Right now, better see "define, in gdcmHederEntry.cxx
+const unsigned int gdcmParser::MAX_SIZE_PRINT_ELEMENT_VALUE = 64;
+
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
// === Deal with the value
// -------------------
- if (vr == "SQ") continue; // vo "value" to write for the SEQuences
+ if (vr == "SQ") continue; // no "value" to write for the SEQuences
if (gr == 0xfffe)continue;
if (vr == "US" || vr == "SS")
* \ingroup gdcmParser
* \brief
* @param NewSize
- * @return
*/
void gdcmParser::SetMaxSizeLoadEntry(long NewSize)
{
MaxSizeLoadEntry = NewSize;
}
+
+/**
+ * \ingroup gdcmParser
+ * \brief
+ * \warning TODO : not yet usable
+ * (see MAX_SIZE_PRINT_ELEMENT_VALUE
+ * in gdcmHeaderEntry gdcmLoadEntry)
+ *
+ * @param NewSize
+ */
+void gdcmParser::SetMaxSizePrintEntry(long NewSize)
+{
+ if (NewSize < 0)
+ return;
+ if ((guint32)NewSize >= (guint32)0xffffffff)
+ {
+ MaxSizePrintEntry = 0xffffffff;
+ return;
+ }
+ MaxSizePrintEntry = NewSize;
+}
+
/**
* \ingroup gdcmParser
* \brief Searches both the public and the shadow dictionary (when they
static const unsigned int HEADER_LENGTH_TO_READ;
static const unsigned int MAX_SIZE_LOAD_ELEMENT_VALUE;
+ static const unsigned int MAX_SIZE_PRINT_ELEMENT_VALUE;
protected:
int enableSequences;
void CheckSwap(void);
void SwitchSwapToBigEndian(void);
void SetMaxSizeLoadEntry(long);
+ void SetMaxSizePrintEntry(long);
// DictEntry related utilities
gdcmDictEntry *GetDictEntryByName (std::string Name);
// this upper bound is fixed to 1024 bytes (which might look reasonable
// when one considers the definition of the various VR contents).
guint32 MaxSizeLoadEntry;
+ // Size treshold above which an element value will NOT be *printed* in
+ // order no to polute the screen output. By default,
+ // this upper bound is fixed to 64 bytes.
+ guint32 MaxSizePrintEntry;
+
};
//-----------------------------------------------------------------------------