Program: gdcm
Module: $RCSfile: gdcmBase.h,v $
Language: C++
- Date: $Date: 2005/10/21 07:40:13 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2005/10/23 15:32:30 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
//-----------------------------------------------------------------------------
/**
- * \brief Base class of all gdcm classes
+ * \brief Base class of all gdcm classes.
* Contains the Print related methods :
* - Print
* - SetPrintLevel / GetPrintLevel
class GDCM_EXPORT Base
{
public:
+ /// \brief Constructor
Base( ) {PrintLevel = 0;}
+ /// \brief Canonical Destructor
virtual ~Base() {}
-
+ /// \brief Printer
virtual void Print(std::ostream & = std::cout,
std::string const & = "" ) {};
Program: gdcm
Module: $RCSfile: gdcmCommon.h,v $
Language: C++
- Date: $Date: 2005/10/20 15:24:08 $
- Version: $Revision: 1.100 $
+ Date: $Date: 2005/10/23 15:32:30 $
+ Version: $Revision: 1.101 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
struct DicomElement
{
- /// DicomGroup number
+ /// Dicom Group number
unsigned short int Group;
- /// DicomElement number
+ /// Dicom Element number
unsigned short int Elem;
/// value (coded as a std::string) of the Element
std::string Value;
Program: gdcm
Module: $RCSfile: gdcmDataEntry.cxx,v $
Language: C++
- Date: $Date: 2005/10/21 15:52:13 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2005/10/23 15:32:30 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
State = STATE_LOADED;
}
-
+/**
+ * \brief Inserts the value (non string) into the current Dicom Header Entry
+ */
void DataEntry::CopyBinArea( uint8_t *area, uint32_t length )
{
DeleteBinArea();
}
}
-void DataEntry::SetValue(const uint32_t &id,const double &val)
+void DataEntry::SetValue(const uint32_t &id, const double &val)
{
if( !BinArea )
NewBinArea();
BinArea[id] = (uint8_t)val;
}
}
-
+/**
+ * \brief returns, as a double (?!?) one of the values
+ // (when entry is multivaluated), identified by its index.
+ // Returns 0.0 if index is wrong
+ // FIXME : warn the user there was a problem !
+ */
double DataEntry::GetValue(const uint32_t &id) const
{
if( !BinArea )
{
gdcmErrorMacro("BinArea not set. Can't get the value");
- return 0;
+ return 0.0;
}
uint32_t count = GetValueCount();
if( id > count )
{
gdcmErrorMacro("Index (" << id << ")is greater than the data size");
- return 0;
+ return 0.0;
}
+ // FIX the API : user *knows* that entry contains a US
+ // and he receives a double ?!?
+
const VRKey &vr = GetVR();
if( vr == "US" || vr == "SS" )
return ((uint16_t *)BinArea)[id];
return BinArea[id];
}
+/**
+ * \brief Checks if the multiplicity of the value follows Dictionary VM
+ */
bool DataEntry::IsValueCountValid() const
{
bool valid = false;
uint32_t vm;
const std::string &strVM = GetVM();
uint32_t vc = GetValueCount();
+
+ // FIXME : what shall we do with VM = "2-n", "3-n", etc
+
if( strVM == "1-n" )
- {
+ {
// make sure it is at least one ??? FIXME
valid = vc >= 1 || vc == 0;
- }
+ }
else
- {
+ {
std::istringstream os;
os.str( strVM );
os >> vm;
// Two cases:
// vm respect the one from the dict
- // vm is 0 (we need to check is this element is allowed to be empty) FIXME
+ // vm is 0 (we need to check if this element is allowed to be empty) FIXME
+
+ // note (JPR)
+ // ----
+ // Entries whose type is 1 are mandatory, with a mandatory value.
+ // Entries whose type is 1c are mandatory-inside-a-Sequence,
+ // with a mandatory value.
+ // Entries whose type is 2 are mandatory, with an optional value.
+ // Entries whose type is 2c are mandatory-inside-a-Sequence,
+ // with an optional value.
+ // Entries whose type is 3 are optional.
+
+ // case vc == 0 is only applicable for 'type 2' entries.
+ // Problem : entry type may depend on the modality and/or the Sequence
+ // it's embedded in !
+ // (Get the information in the 'Conformance Statements' ...)
valid = vc == vm || vc == 0;
- }
+ }
return valid;
}
-uint32_t DataEntry::GetValueCount(void) const
+/**
+ * \brief returns the number of elementary values
+ */
+uint32_t DataEntry::GetValueCount( ) const
{
const VRKey &vr = GetVR();
if( vr == "US" || vr == "SS" )
return GetLength();
}
-
+/**
+ * \brief Sets the 'value' of an Entry, passed as a std::string
+ * @param value string representation of the value to be set
+ */
void DataEntry::SetString(std::string const &value)
{
DeleteBinArea();
{
if( value.size() > 0 )
{
+ // FIXME : should be quicker if we don't create one more std::string
+ // just to make even the length of a char array ...
+
+ /*
std::string finalVal = Util::DicomString( value.c_str() );
SetLength(finalVal.size());
NewBinArea();
memcpy(BinArea, &(finalVal[0]), finalVal.size());
+ */
+
+ size_t l = value.size();
+ SetLength(l + l%2);
+ NewBinArea();
+ memcpy(BinArea, &(value[0]), l);
+ if (l%2)
+ BinArea[l] = '\0';
}
}
State = STATE_LOADED;
}
-
+/**
+ * \brief returns as a string (when possible) the value of the DataEntry
+ */
std::string const &DataEntry::GetString() const
{
static std::ostringstream s;
if( !BinArea )
return StrArea;
+
+ // When short integer(s) are stored, convert the following (n * 2) characters
+ // as a displayable string, the values being separated by a back-slash
if( vr == "US" || vr == "SS" )
{
}
StrArea=s.str();
}
- // See above comment on multiple integers (mutatis mutandis).
+ // See above comment on multiple short integers (mutatis mutandis).
else if( vr == "UL" || vr == "SL" )
{
uint32_t *data=(uint32_t *)BinArea;
return StrArea;
}
-
+/**
+ * \brief Copies all the attributes from an other DocEntry
+ * @param doc entry to copy from
+ */
void DataEntry::Copy(DocEntry *doc)
{
DocEntry::Copy(doc);
CopyBinArea(entry->BinArea,entry->GetLength());
}
}
-
+/**
+ * \brief Writes the value of a DataEntry
+ * @param fp already open ofstream pointer
+ * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
+ */
void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
{
DocEntry::WriteContent(fp, filetype);
{
if(Global::GetVR()->IsVROfStringRepresentable(vr))
{
- std::string cleanString = Util::CreateCleanString(v); // replace non printable characters by '.'
+ // replace non printable characters by '.'
+ std::string cleanString = Util::CreateCleanString(v);
if ( cleanString.length() <= GetMaxSizePrintEntry()
- || PrintLevel >= 3
- || IsNotLoaded() )
+ || PrintLevel >= 3
+ || IsNotLoaded() )
+ // FIXME : when IsNotLoaded(), you create a Clean String ?!?
+ // FIXME : PrintLevel<2 *does* print the values
+ // (3 is only for extra offsets printing)
+ // What do you wanted to do ? JPR
{
s << " [" << cleanString << "]";
}
}
else
{
- if ( Util::IsCleanArea( GetBinArea(),GetLength() ) )
+ // A lot of Private elements (with no VR) contain actually
+ // only printable characters;
+ // Let's deal with them as is they were VR std::string representable
+
+ if ( Util::IsCleanArea( GetBinArea(), GetLength() ) )
{
+ // FIXME : since the 'Area' *is* clean, just use
+ // a 'CreateString' method, to save CPU time.
std::string cleanString =
Util::CreateCleanString( BinArea,GetLength() );
s << " [" << cleanString << "]";
Program: gdcm
Module: $RCSfile: gdcmDataEntry.h,v $
Language: C++
- Date: $Date: 2005/10/21 14:09:41 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2005/10/23 15:32:30 $
+ Version: $Revision: 1.4 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
//-----------------------------------------------------------------------------
/**
- * \brief Any Dicom Document (File or DicomDir) contains
+ * \brief Any Dicom Document (File or DicomDir, or ...) contains
* a set of DocEntry - Dicom entries -
* (when successfuly parsed against a given Dicom dictionary)
* DataEntry is an elementary DocEntry (as opposed to SeqEntry).
// Write
virtual void WriteContent(std::ofstream *fp, FileType filetype);
-// Set/Get datas
+// Set/Get data
/// Sets the value (string) of the current Dicom entry
//virtual void SetValue(std::string const &val);
/// \brief Returns the 'Value' (e.g. "Dupond^Marcel") converted
/// \brief Sets SelfArea
void SetSelfArea(bool area) { SelfArea = area; }
- /// \brief Returns SelfArea
+ /// \brief True if Entry owns its BinArea
bool IsSelfArea() { return SelfArea; }
// State
void SetState(const char &state) { State = state; }
const char &GetState() const { return State; }
+ /// \brief true when value Entry not loaded
bool IsNotLoaded() { return State == STATE_NOTLOADED; }
+ /// \brief true if Entry not found
bool IsUnfound() { return State == STATE_UNFOUND; }
+ /// \brief true if Entry not read
bool IsUnread() { return State == STATE_UNREAD; }
+ /// \brief true if Entry value properly loaded
bool IsGoodValue() { return State == 0; }
// Flags
+ /// \brief sets the 'pixel data flag'
void SetFlag(const char &flag) { Flag = flag; }
+ /// \brief returns the 'pixel data flag'
const char &GetFlag() const { return Flag; }
+ /// \brief true id Entry is a Pixel Data entry
bool IsPixelData() { return (Flag & FLAG_PIXELDATA) != 0; }
void Copy(DocEntry *doc);
/// \brief Header Elements too long will not be printed
static void SetMaxSizePrintEntry(const uint32_t &size) { MaxSizePrintEntry = size; }
+ ///\brief values for current state of a DataEntry (internal use only)
typedef enum
{
STATE_LOADED = 0x00,
STATE_UNFOUND = 0x02,
STATE_UNREAD = 0x03
} TValueState;
-
+
+ ///\brief values for current pixel status of a DataEntry (internal use only)
typedef enum
{
FLAG_NONE = 0x00,
uint8_t *BinArea;
/// \brief Whether DataEntry has its own BinArea or not
bool SelfArea;
-
+ /// \brief std::string representable value of the Entry.
+ /// Parts of a multivaluated data are separated by back-slash
mutable std::string StrArea;
private:
+ /// \brief 0 for straight entries, FLAG_PIXELDATA for Pixel Data entries
char Flag;
+ /// \brief Entry status : STATE_NOTLOADED,STATE_UNFOUND, STATE_UNREAD, 0
char State;
/// \brief Size threshold above which an element val
Program: gdcm
Module: $RCSfile: gdcmDicomEntry.h,v $
Language: C++
- Date: $Date: 2005/10/21 15:34:56 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2005/10/23 15:32:30 $
+ Version: $Revision: 1.7 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
/**
* \brief
- * the DicomEntry in an element contained by the Dict.
+ * a DicomEntry is an element contained by the Dict.
* It contains :
- * - the key referenced by the DICOM norm or the constructor (for private keys)
- * i.e. the Group number
- * the Element number
+ * - the key referenced by the DICOM norm or the manufacturer(for private keys)
+ * i.e.
+ * - - the Group number
+ * - - the Element number
* - the VR (Value Representation)
* - the VM (Value Multiplicity)
* - the corresponding name in english
~DicomEntry();
private:
- /// Dicom \ref TagKey. Contains DicomGroup number and DicomElement number
+ /// Dicom \ref TagKey. Contains Dicom Group number and Dicom Element number
TagKey Tag;
/// \brief Value Representation i.e. some clue about the nature
/// of the data represented e.g.
- /// "FD" short for "Floating Point Double"(see \ref VR)
- /// "PN" short for "Person Name"
+ /// - "FD" short for "Floating Point Double"(see \ref VR)
+ /// - "PN" short for "Person Name"
VRKey VR;
};
} // end namespace gdcm
Program: gdcm
Module: $RCSfile: gdcmDict.cxx,v $
Language: C++
- Date: $Date: 2005/10/20 15:24:08 $
- Version: $Revision: 1.81 $
+ Date: $Date: 2005/10/23 15:32:30 $
+ Version: $Revision: 1.82 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Public
/**
- * \brief Add a all the entries held in a source dictionary
+ * \brief Add all the entries held in a source dictionary
* \note it concerns only Private Dictionnary
* @param filename from which to build the dictionary.
*/
/**
* \brief Get the dictionary entry identified by a given tag ("group|element")
- * @param key tag of the entry to be found
+ * @param key tag of the searched entry
* @return the corresponding dictionary entry when existing, NULL otherwise
*/
DictEntry *Dict::GetEntry(TagKey const &key)
}
return it->second;
}
-
+/**
+ * \brief Get the dictionary entry identified by it's "group" and "element")
+ * @param group Group number of the searched entry.
+ * @param elem Element number of the searched entry.
+ * @return the corresponding dictionary entry when existing, NULL otherwise
+ */
DictEntry *Dict::GetEntry(uint16_t group, uint16_t elem)
{
TagKey key = DictEntry::TranslateToKey(group, elem);
Program: gdcm
Module: $RCSfile: gdcmDict.h,v $
Language: C++
- Date: $Date: 2005/10/20 15:24:08 $
- Version: $Revision: 1.43 $
+ Date: $Date: 2005/10/23 15:32:30 $
+ Version: $Revision: 1.44 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// Access through TagKey
TagKeyHT KeyHt;
+ /// Iterator for the entries
TagKeyHT::iterator ItKeyHt;
};
} // end namespace gdcm
Program: gdcm
Module: $RCSfile: gdcmDictGroupName.cxx,v $
Language: C++
- Date: $Date: 2005/06/24 10:55:58 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2005/10/23 15:32:30 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
+/// \returns the formerly NIH defined ACR-NEMA group name
const TagName &DictGroupName::GetName(uint16_t group)
{
DictGroupNameHT::const_iterator it = groupName.find(group);
Program: gdcm
Module: $RCSfile: gdcmDictGroupName.h,v $
Language: C++
- Date: $Date: 2005/04/06 12:49:27 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2005/10/23 15:32:31 $
+ Version: $Revision: 1.3 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
/**
- * \brief Container for dicom Value Representation Hash Table
- * \note This is a singleton
+ * \brief Container for dicom 'Value Representation' Hash Table.
+ * \note This is a singleton.
*/
class GDCM_EXPORT DictGroupName
{
Program: gdcm
Module: $RCSfile: gdcmDictSet.h,v $
Language: C++
- Date: $Date: 2005/10/20 15:24:09 $
- Version: $Revision: 1.47 $
+ Date: $Date: 2005/10/23 15:32:31 $
+ Version: $Revision: 1.48 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
private:
/// Hash table of all dictionaries contained in this DictSet
DictSetHT Dicts;
+ /// Iterator to visit the Dictionaries of a given DictSet
DictSetHT::iterator ItDictHt;
/// Directory path to dictionaries
Program: gdcm
Module: $RCSfile: gdcmDirList.h,v $
Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- Version: $Revision: 1.25 $
+ Date: $Date: 2005/10/23 15:32:31 $
+ Version: $Revision: 1.26 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// so GDCM_EXPORT keyword was removed for this class only
/**
- * \brief List containing the file headers of all the gdcm readable files
- * found by exploring recursively a root directory.
+ * \brief List containing the file headers of all the 'gdcm readable' files
+ * found by exploring (possibely recursively) a root directory.
*/
class GDCM_EXPORT DirList
{
Program: gdcm
Module: $RCSfile: gdcmDocEntry.h,v $
Language: C++
- Date: $Date: 2005/10/20 15:24:09 $
- Version: $Revision: 1.53 $
+ Date: $Date: 2005/10/23 15:32:31 $
+ Version: $Revision: 1.54 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// Dictionnary, of the current Dicom entry
VRKey const &GetVR() const { return DicomDict->GetVR(); }
- /// \brief Returns the 'Value Multiplicity' (e.g. "1", "1-n", "6"),
+ /// \brief Returns the 'Value Multiplicity' (e.g. "1", 6", "1-n", "3-n"),
/// found in the Dicom entry or in the Dicom Dictionnary
/// of the current Dicom entry
std::string const &GetVM() const { return DicomDict->GetVM(); }