#endif
# include <iomanip>
+#define UI1_2_840_10008_1_2 "1.2.840.10008.1.2"
+#define UI1_2_840_10008_1_2_1 "1.2.840.10008.1.2.1"
+#define UI1_2_840_10008_1_2_2 "1.2.840.10008.1.2.2"
+#define UI1_2_840_10008_1_2_1_99 "1.2.840.10008.1.2.1.99"
+
//-----------------------------------------------------------------------------
// Refer to gdcmParser::CheckSwap()
const unsigned int gdcmParser::HEADER_LENGTH_TO_READ = 256;
if ( !OpenFile(exception_on_error))
return;
-
Parse();
LoadHeaderEntries();
-
CloseFile();
wasUpdated = 0; // will be set to 1 if user adds an entry
- printLevel = 1; // 'Medium' header print by default
+ printLevel = 1; // 'Heavy' header print by default
}
/**
*/
gdcmParser::gdcmParser(bool exception_on_error)
{
- //enableSequences=0;
+ enableSequences=0;
SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE);
Initialise();
{
std::ostringstream s;
- s << "------------ gdcmParser::Print, using listEntries ----------------" << std::endl;
+ s << "------------ using listEntries ----------------" << std::endl;
for (ListTag::iterator i = listEntries.begin();
i != listEntries.end();
++i)
/**
* \ingroup gdcmParser
- * \brief Prints The Dict Entries of the current shadow Dicom Dictionnry
+ * \brief Prints The Dict Entries of THE shadow Dicom Dictionnry
* @return
*/
void gdcmParser::PrintShaDict(std::ostream & os)
// Public
/**
* \ingroup gdcmParser
- * \brief Get THE public dictionary used
+ * \brief Get the public dictionary used
*/
gdcmDict *gdcmParser::GetPubDict(void)
{
/**
* \ingroup gdcmParser
- * \brief Get the current shadow dictionary
+ * \brief Get the shadow dictionary used
*/
gdcmDict *gdcmParser::GetShaDict(void)
{
* \brief Set the shadow dictionary used
* \param dictName name of the dictionary to use in shadow
*/
-bool gdcmParser::SetShaDict(DictKey dictName) {
+bool gdcmParser::SetShaDict(DictKey dictName)
+{
RefShaDict=gdcmGlobal::GetDicts()->GetDict(dictName);
return(!RefShaDict);
}
bool gdcmParser::IsReadable(void)
{
std::string res = GetEntryByNumber(0x0028, 0x0005);
- if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) {
- //std::cout << "error on : 28 5" << std::endl;
+ if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 )
return false; // Image Dimensions
- }
- if ( !GetHeaderEntryByNumber(0x0028, 0x0100) ) {
- //std::cout << "error on : 28 100" << std::endl;
+ if ( !GetHeaderEntryByNumber(0x0028, 0x0100) )
return false; // "Bits Allocated"
- }
- if ( !GetHeaderEntryByNumber(0x0028, 0x0101) ){
- // std::cout << "error on : 28 101" << std::endl;
+ if ( !GetHeaderEntryByNumber(0x0028, 0x0101) )
return false; // "Bits Stored"
- }
- if ( !GetHeaderEntryByNumber(0x0028, 0x0102) ) {
- //std::cout << "error on : 28 102" << std::endl;
+ if ( !GetHeaderEntryByNumber(0x0028, 0x0102) )
return false; // "High Bit"
- }
- if ( !GetHeaderEntryByNumber(0x0028, 0x0103) ) {
- //std::cout << "error on : 28 103" << std::endl;
+ if ( !GetHeaderEntryByNumber(0x0028, 0x0103) )
return false; // "Pixel Representation"
- }
return true;
}
*
* @return True when ImplicitVRLittleEndian found. False in all other cases.
*/
-bool gdcmParser::IsImplicitVRLittleEndianTransferSyntax(void) {
+bool gdcmParser::IsImplicitVRLittleEndianTransferSyntax(void)
+{
gdcmHeaderEntry *Element = GetHeaderEntryByNumber(0x0002, 0x0010);
if ( !Element )
return false;
LoadHeaderEntrySafe(Element);
std::string Transfer = Element->GetValue();
- if ( Transfer == "1.2.840.10008.1.2" )
+ if ( Transfer == UI1_2_840_10008_1_2 )
return true;
return false;
}
LoadHeaderEntrySafe(Element);
std::string Transfer = Element->GetValue();
- if ( Transfer == "1.2.840.10008.1.2.1" )
+ if ( Transfer == UI1_2_840_10008_1_2_1 )
return true;
return false;
}
LoadHeaderEntrySafe(Element);
std::string Transfer = Element->GetValue();
- if ( Transfer == "1.2.840.10008.1.2.1.99" )
+ if ( Transfer == UI1_2_840_10008_1_2_1_99 )
return true;
return false;
}
LoadHeaderEntrySafe(Element);
std::string Transfer = Element->GetValue();
- if ( Transfer == "1.2.840.10008.1.2.2" ) //1.2.2 ??? A verifier !
+ if ( Transfer == UI1_2_840_10008_1_2_2 ) //1.2.2 ??? A verifier !
return true;
return false;
}
if (type == ImplicitVR)
{
- std::string implicitVRTransfertSyntax = "1.2.840.10008.1.2";
+ std::string implicitVRTransfertSyntax = UI1_2_840_10008_1_2;
ReplaceOrCreateByNumber(implicitVRTransfertSyntax,0x0002, 0x0010);
//FIXME Refer to standards on page 21, chapter 6.2 "Value representation":
if (type == ExplicitVR)
{
- std::string explicitVRTransfertSyntax = "1.2.840.10008.1.2.1";
+ std::string explicitVRTransfertSyntax = UI1_2_840_10008_1_2_1;
ReplaceOrCreateByNumber(explicitVRTransfertSyntax,0x0002, 0x0010);
//FIXME Refer to standards on page 21, chapter 6.2 "Value representation":
* \brief Searches within Header Entries (Dicom Elements) parsed with
* the public and private dictionaries
* for the element value of a given tag.
+ * \warning Don't use any longer : use GetPubEntryByName
* @param tagName name of the searched element.
* @return Corresponding element value when it exists,
* and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
Entry->SetValue("gdcm::UnRead");
return;
}
- Entry->SetValue(NewValue);
+
+ if( (vr == "UI") ) // Because of correspondance with the VR dic
+ Entry->SetValue(NewValue.c_str());
+ else
+ Entry->SetValue(NewValue);
}
/**
{
if(i!=0)
s << '\\';
- NewInt32=(val[4*i+0]&0xFF)+((val[4*i+1]&0xFF)<<8)+((val[4*i+2]&0xFF)<<16)+((val[4*i+3]&0xFF)<<24);
+ NewInt32= (val[4*i+0]&0xFF)+((val[4*i+1]&0xFF)<<8)+
+ ((val[4*i+2]&0xFF)<<16)+((val[4*i+3]&0xFF)<<24);
NewInt32=SwapLong(NewInt32);
s << NewInt32;
}
std::string vr=Entry->GetVR();
std::ostringstream s;
std::vector<std::string> tokens;
- unsigned char *ptr;
if (vr == "US" || vr == "SS")
{
/**
* \ingroup gdcmParser
* \brief Request a new virtual dict entry to the dict set
- * @param group group of the underlying DictEntry
- * @param element element of the underlying DictEntry
- * @param vr VR of the underlying DictEntry
- * @param fourth owner group
- * @param name english name
+ * @param group group of the underlying DictEntry
+ * @param elem element of the underlying DictEntry
+ * @param vr VR of the underlying DictEntry
+ * @param fourth owner group
+ * @param name english name
*/
gdcmDictEntry *gdcmParser::NewVirtualDictEntry(guint16 group, guint16 element,
std::string vr,