+Mon Oct 18 10:27:49 2005 by regrain
+ * Correctly use the VRKey for all vr variables... instead of TagName
+ or std::string
+ * Replace the definition of VRKey from std::string to a class
+ containing a char[2]. All methods are inline to have no speed low
+ * Create the GDCM_VRUNKNOWN = " " for the VR values
+
Mon Oct 18 10:27:49 2005 by regrain
* Remove useless constructor of gdcm::Document
* Remove useless parameter in the constructor of gdcm::ElementSet
Program: gdcm
Module: $RCSfile: exReadWriteFile.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:44 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2005/10/18 12:58:24 $
+ Version: $Revision: 1.8 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
gdcm::DataEntry *dataEntry;
std::string value;
- std::string vr; // value representation
+ gdcm::VRKey vr; // value representation
std::string vm; // value multiplicity
std::string name; // held in the Dicom Dictionary
Program: gdcm
Module: $RCSfile: TestVR.cxx,v $
Language: C++
- Date: $Date: 2005/02/02 10:05:26 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2005/10/18 12:58:25 $
+ Version: $Revision: 1.8 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
int TestVR(int , char *[])
{
- gdcm::VR *tempVrDict=0;
- std::cout << "------ Test Default VR Dictionary : ----------" << std::endl;
- // Just to improve test coverage:
- // tempVrDict = new gdcm::Dict("dummyFileNameThatDoesntExist");
- // tempVrDict->Print();
- // std::cout << "----- end Test Default VR Dictionary : -----" << std::endl;
-
- // Lets delete it.
- delete tempVrDict;
-
+ int error = 0;
gdcm::VR *vr = new gdcm::VR();
// There should be 16 entries ...
vr->Print( std::cout );
- vr->IsVROfStringRepresentable( "PN" );
- vr->IsVROfStringRepresentable( "FD" );
+ // Valid VR
+ if( !vr->IsValidVR( "PN" ) )
+ {
+ std::cerr << "'PN' is not a valid VR" << std::endl;
+ error++;
+ }
+ if( !vr->IsValidVR( "FD" ) )
+ {
+ std::cerr << "'FD' is not a valid VR" << std::endl;
+ error++;
+ }
+ if( vr->IsValidVR( "" ) )
+ {
+ std::cerr << "'' is a valid VR" << std::endl;
+ error++;
+ }
+ if( vr->IsValidVR( " " ) )
+ {
+ std::cerr << "' ' is a valid VR" << std::endl;
+ error++;
+ }
+ if( vr->IsValidVR( gdcm::GDCM_VRUNKNOWN ) )
+ {
+ std::cerr << "' ' is a valid VR" << std::endl;
+ error++;
+ }
+
+ // String representable
+ if( !vr->IsVROfStringRepresentable( "PN" ) )
+ {
+ std::cerr << "'PN' is not a string representable" << std::endl;
+ error++;
+ }
+ if( vr->IsVROfStringRepresentable( "FD" ) )
+ {
+ std::cerr << "'FD' is a string representable" << std::endl;
+ error++;
+ }
+
+ // Binary representable
+ if( !vr->IsVROfBinaryRepresentable( "FD" ) )
+ {
+ std::cerr << "FD is not a binary representable" << std::endl;
+ error++;
+ }
+ if( vr->IsVROfBinaryRepresentable( "PN" ) )
+ {
+ std::cerr << "'PN' is a binary representable" << std::endl;
+ error++;
+ }
- vr->IsVROfBinaryRepresentable( "FD" );
- vr->IsVROfBinaryRepresentable( "PN" );
+ // Sequence
+ if( vr->IsVROfSequence( "" ) )
+ {
+ std::cerr << "'' is a sequence" << std::endl;
+ error++;
+ }
+ if( !vr->IsVROfSequence( "SQ" ) )
+ {
+ std::cerr << "'SQ' is not a sequence" << std::endl;
+ error++;
+ }
- vr->IsVROfSequence( "" );
- vr->IsVROfSequence( "SQ" );
delete vr;
- return 0;
+ return error;
}
%ignore GDCM_NOTASCII;
%ignore GDCM_PIXELDATA;
%ignore GDCM_LEGACY;
+%ignore GDCM_VRUNKNOWN;
-%constant const char *UNKNOWN = "gdcm::Unknown";
-%constant const char *UNFOUND = "gdcm::Unfound";
-%constant const char *BINLOADED = "gdcm::Binary data loaded";
-%constant const char *NOTLOADED = "gdcm::NotLoaded";
-%constant const char *UNREAD = "gdcm::UnRead";
-%constant const char *GDCM_NOTASCII = "gdcm::NotAscii";
+%constant const char *UNKNOWN = "gdcm::Unknown";
+%constant const char *UNFOUND = "gdcm::Unfound";
+%constant const char *BINLOADED = "gdcm::Binary data loaded";
+%constant const char *NOTLOADED = "gdcm::NotLoaded";
+%constant const char *UNREAD = "gdcm::UnRead";
+%constant const char *GDCM_NOTASCII = "gdcm::NotAscii";
%constant const char *GDCM_PIXELDATA = "gdcm::Pixel Data to be loaded";
+%constant const char *VRUNKNOWN = " ";
+
////////////////////////////////////////////////////////////////////////////
// Warning: Order matters !
%include "gdcmCommon.h"
Program: gdcm
Module: $RCSfile: gdcmCommon.h,v $
Language: C++
- Date: $Date: 2005/10/18 09:17:08 $
- Version: $Revision: 1.94 $
+ Date: $Date: 2005/10/18 12:58:27 $
+ Version: $Revision: 1.95 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmConfigure.h"
#include "gdcmSystem.h"
+#define FASTTAGKEY 0
+
+// FIXME: Should rewrite this:
+#if FASTTAGKEY
+ #include <iostream>
+ #include <iomanip>
+#endif
+ #if defined(_MSC_VER) && (_MSC_VER == 1200)
+ /* ostream operator for std::string since VS6 does not provide it*/
+ #include <iostream>
+#endif
+
//-----------------------------------------------------------------------------
/// \brief namespace for Grass root DiCoM
namespace gdcm
GDCM_EXPORT extern const std::string GDCM_UNREAD;
GDCM_EXPORT extern const std::string GDCM_NOTASCII;
GDCM_EXPORT extern const std::string GDCM_PIXELDATA;
+
+GDCM_EXPORT extern const std::string GDCM_VRUNKNOWN;
+
/// \brief TagKey is made to hold the standard Dicom Tag
/// (Group number, Element number)
/// Instead of using the two '16 bits integers' as the Hask Table key, we
/* ostream operator for TagKey */
inline std::ostream& operator<<(std::ostream& _O, TagKey _val)
{
- _O.setf( std::ios::right);
- return (_O << std::hex << std::setw( 4 ) << std::setfill( '0' )
- << _val.tab[0] << '|' << std::setw( 4 ) << std::setfill( '0' )
- << _val.tab[1] << std::setfill( ' ' ) << std::dec);
+ _O.setf( std::ios::right);
+ return (_O << std::hex << std::setw( 4 ) << std::setfill( '0' )
+ << _val.tab[0] << '|' << std::setw( 4 ) << std::setfill( '0' )
+ << _val.tab[1] << std::setfill( ' ' ) << std::dec);
}
inline bool operator==(TagKey _self, TagKey _val)
{
- return _self.tagkey == _val.tagkey;
+ return _self.tagkey == _val.tagkey;
}
inline bool operator<(TagKey _self, TagKey _val)
{
- // This expression is a tad faster but PrintFile output
- // is more difficult to read
- //return _self.tagkey < _val.tagkey;
-
- // More usal order of dicom tags:
- if( _self.tab[0] == _val.tab[0] )
- return _self.tab[1] < _val.tab[1];
- return _self.tab[0] < _val.tab[0];
+ // This expression is a tad faster but PrintFile output
+ // is more difficult to read
+ //return _self.tagkey < _val.tagkey;
+
+ // More usal order of dicom tags:
+ if( _self.tab[0] == _val.tab[0] )
+ return _self.tab[1] < _val.tab[1];
+ return _self.tab[0] < _val.tab[0];
}
#else
typedef std::string TagKey;
Program: gdcm
Module: $RCSfile: gdcmDebug.h,v $
Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- Version: $Revision: 1.42 $
+ Date: $Date: 2005/10/18 12:58:27 $
+ Version: $Revision: 1.43 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmCommon.h"
+#include <iostream>
#include <sstream>
#include <fstream>
#include <assert.h>
Program: gdcm
Module: $RCSfile: gdcmDict.cxx,v $
Language: C++
- Date: $Date: 2005/09/02 07:00:04 $
- Version: $Revision: 1.79 $
+ Date: $Date: 2005/10/18 12:58:27 $
+ Version: $Revision: 1.80 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
uint16_t group;
uint16_t elem;
- TagName vr;
+ VRKey vr;
TagName vm;
TagName name;
from >> std::ws; //remove white space
std::getline(from, name);
- const DictEntry newEntry(group, elem, vr, vm, name);
+ DictEntry newEntry(group, elem, vr, vm, name);
AddEntry(newEntry);
}
from.close();
Program: gdcm
Module: $RCSfile: gdcmDictEntry.cxx,v $
Language: C++
- Date: $Date: 2005/07/11 15:20:46 $
- Version: $Revision: 1.51 $
+ Date: $Date: 2005/10/18 12:58:27 $
+ Version: $Revision: 1.52 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
DictEntry::DictEntry(uint16_t group, uint16_t elem,
- TagName const &vr,
+ VRKey const &vr,
TagName const &vm,
TagName const &name)
{
* \ is unset then overwrite it.
* @param vr New V(alue) R(epresentation) to be set.
*/
-void DictEntry::SetVR(TagName const &vr)
+void DictEntry::SetVR(VRKey const &vr)
{
if ( IsVRUnknown() )
{
*/
void DictEntry::Print(std::ostream &os, std::string const & )
{
- std::string vr;
+ VRKey vr;
std::ostringstream s;
vr = GetVR();
- if ( vr==GDCM_UNKNOWN )
+ if ( IsVRUnknown() )
vr=" ";
s << DictEntry::TranslateToKey(GetGroup(),GetElement());
Program: gdcm
Module: $RCSfile: gdcmDictEntry.h,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:49 $
- Version: $Revision: 1.36 $
+ Date: $Date: 2005/10/18 12:58:27 $
+ Version: $Revision: 1.37 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#define GDCMDICTENTRY_H
#include "gdcmBase.h"
+#include "gdcmVRKey.h"
namespace gdcm
{
-
//-----------------------------------------------------------------------------
/**
* \brief
public:
DictEntry(uint16_t group,
uint16_t elem,
- TagName const &vr = GDCM_UNKNOWN,
+ VRKey const &vr = GDCM_VRUNKNOWN,
TagName const &vm = GDCM_UNKNOWN,
TagName const &name = GDCM_UNKNOWN);
void Print(std::ostream &os = std::cout, std::string const &indent = "");
// Content of DictEntry
- void SetVR(TagName const &vr);
+ void SetVR(VRKey const &vr);
void SetVM(TagName const &vm);
/// \brief tells if the V(alue) R(epresentation) is known (?!)
/// @return
- bool IsVRUnknown() const { return VR == GDCM_UNKNOWN; }
+ bool IsVRUnknown() const { return VR == GDCM_VRUNKNOWN; }
/// \brief tells if the V(alue) M(ultiplicity) is known (?!)
/// @return
/// \brief Returns the Dicom Value Representation of the current
/// DictEntry
/// @return the Dicom Value Representation
- const TagName &GetVR() const { return VR; }
+ const VRKey &GetVR() const { return VR; }
/// \brief sets the key of the current DictEntry
/// @param k New key to be set.
/// of the data represented e.g.
/// "FD" short for "Floating Point Double"(see \ref VR)
/// "PN" short for "Person Name"
- TagName VR;
+ VRKey VR;
/*
* .
Program: gdcm
Module: $RCSfile: gdcmDictSet.cxx,v $
Language: C++
- Date: $Date: 2005/07/11 20:44:52 $
- Version: $Revision: 1.68 $
+ Date: $Date: 2005/10/18 12:58:27 $
+ Version: $Revision: 1.69 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
DictEntry *DictSet::NewVirtualDictEntry( uint16_t group,
uint16_t elem,
- TagName vr,
- TagName vm,
- TagName name)
+ const VRKey &vr,
+ const TagName &vm,
+ const TagName &name)
{
DictEntry *entry;
char res[10];
sprintf(res,"%04x|%04x", group, elem);
ExtendedTagKey tag = res;
- tag += "#" + vr + "#" + vm + "#" + name;
+ tag += "#" + vr.str() + "#" + vm + "#" + name;
#endif
-
+
ExtendedTagKeyHT::iterator it;
it = VirtualEntries.find(tag);
Program: gdcm
Module: $RCSfile: gdcmDictSet.h,v $
Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- Version: $Revision: 1.45 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.46 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Dict *GetVirtualDict() { return &VirtualEntries; }
DictEntry *NewVirtualDictEntry(uint16_t group, uint16_t elem,
- TagName vr = GDCM_UNKNOWN,
- TagName vm = GDCM_UNKNOWN,
- TagName name = GDCM_UNKNOWN);
+ const VRKey &vr = GDCM_VRUNKNOWN,
+ const TagName &vm = GDCM_UNKNOWN,
+ const TagName &name = GDCM_UNKNOWN);
Dict *GetFirstEntry();
Dict *GetNextEntry();
Program: gdcm
Module: $RCSfile: gdcmDocEntry.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:49 $
- Version: $Revision: 1.70 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.71 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
uint16_t zero = 0;
uint16_t shortLgr = (uint16_t)lgth;
- if (vr == GDCM_UNKNOWN)
+ if( IsVRUnknown() )
{
- // GDCM_UNKNOWN was stored in the Entry VR;
+ // GDCM_VRUNKNOWN was stored in the Entry VR;
// deal with Entry as if TS were Implicit VR
// FIXME : troubles expected on big endian processors :
}
else
{
- binary_write(*fp, vr);
- gdcmAssertMacro( vr.size() == 2 );
+ binary_write(*fp, vr.str());
if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") /*|| (vr == "UN")*/ )
{
size_t o;
std::string st;
TSKey v;
- std::string d2, vr;
+ std::string d2;
+ VRKey vr;
std::ostringstream s;
uint32_t lgth;
o = GetOffset();
vr = GetVR();
- if ( vr==GDCM_UNKNOWN )
+ if ( vr == GDCM_VRUNKNOWN )
vr=" ";
s << DictEntry::TranslateToKey(GetGroup(),GetElement());
Program: gdcm
Module: $RCSfile: gdcmDocEntry.h,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:49 $
- Version: $Revision: 1.50 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.51 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// \brief Returns the 'Value Representation' (e.g. "PN" : Person Name,
/// "SL" : Signed Long), found in the Dicom header or in the Dicom
/// Dictionnary, of the current Dicom entry
- std::string const &GetVR() const { return DicomDict->GetVR(); }
+ VRKey const &GetVR() const { return DicomDict->GetVR(); }
/// \brief Returns the 'Value Multiplicity' (e.g. "1", "1-n", "6"),
/// found in the Dicom entry or in the Dicom Dictionnary
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:49 $
- Version: $Revision: 1.60 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ 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
return -1;
}
-/**
- * \brief Searches within Header Entries (Dicom Elements) parsed with
- * the public [and private dictionaries]
- * for the element value representation of a given tag..
- * Obtaining the VR (Value Representation) might be needed by caller
- * to convert the string typed content to caller's native type
- * (think of C++ vs Python). The VR is actually of a higher level
- * of semantics than just the native C++ type.
- * @param group Group number of the searched tag.
- * @param elem Element number of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string DocEntrySet::GetEntryVR(uint16_t group, uint16_t elem)
-{
- DocEntry *entry = GetDocEntry(group, elem);
- if ( entry )
- return entry->GetVR();
- return GDCM_UNFOUND;
-}
-
/**
* \brief Same as \ref Document::GetDocEntry except it only
* returns a result when the corresponding entry is of type
*/
DataEntry *DocEntrySet::InsertEntryString(std::string const &value,
uint16_t group, uint16_t elem,
- TagName const &vr )
+ VRKey const &vr )
{
DataEntry *dataEntry = 0;
DocEntry *currentEntry = GetDocEntry( group, elem );
*/
DataEntry *DocEntrySet::InsertEntryBinArea(uint8_t *binArea, int lgth,
uint16_t group, uint16_t elem,
- TagName const &vr )
+ VRKey const &vr )
{
DataEntry *dataEntry = 0;
DocEntry *currentEntry = GetDocEntry( group, elem );
* @param vr V(alue) R(epresentation) of the new Entry
*/
DataEntry *DocEntrySet::NewDataEntry(uint16_t group,uint16_t elem,
- TagName const &vr)
+ VRKey const &vr)
{
DictEntry *dictEntry = GetDictEntry(group, elem, vr);
gdcmAssertMacro(dictEntry);
* @param name english name
*/
DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group, uint16_t elem,
- TagName const &vr,
+ VRKey const &vr,
TagName const &vm,
TagName const &name )
{
* @return Corresponding DictEntry when it exists, NULL otherwise.
*/
DictEntry *DocEntrySet::GetDictEntry(uint16_t group, uint16_t elem,
- TagName const &vr)
+ VRKey const &vr)
{
DictEntry *dictEntry = GetDictEntry(group,elem);
DictEntry *goodEntry = dictEntry;
- std::string goodVR = vr;
+ VRKey goodVR = vr;
if (elem == 0x0000) goodVR="UL";
if ( goodEntry )
{
if ( goodVR != goodEntry->GetVR()
- && goodVR != GDCM_UNKNOWN )
+ && goodVR != GDCM_VRUNKNOWN )
{
goodEntry = NULL;
}
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.h,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:49 $
- Version: $Revision: 1.57 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.58 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#define GDCMDOCENTRYSET_H
#include "gdcmBase.h"
+#include "gdcmVRKey.h"
+
#include <fstream>
namespace gdcm
virtual std::string GetEntryString(uint16_t group, uint16_t elem);
virtual void *GetEntryBinArea(uint16_t group, uint16_t elem);
virtual int GetEntryLength(uint16_t group, uint16_t elem);
- virtual std::string GetEntryVR(uint16_t group, uint16_t elem);
virtual std::string GetEntryForcedAsciiValue(uint16_t group, uint16_t elem);
/// \brief Gets any type of DocEntry, identified by its (group,elem)
DataEntry *InsertEntryString(std::string const &value,
uint16_t group, uint16_t elem,
- TagName const &vr = GDCM_UNKNOWN);
+ VRKey const &vr = GDCM_VRUNKNOWN);
DataEntry *InsertEntryBinArea(uint8_t *binArea, int lgth,
uint16_t group, uint16_t elem,
- TagName const &vr = GDCM_UNKNOWN);
+ VRKey const &vr = GDCM_VRUNKNOWN);
SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
/// tells us if the set contains no entry
virtual bool IsEmpty() = 0;
// DocEntry related utilities
DataEntry *NewDataEntry(uint16_t group,uint16_t elem,
- TagName const &vr = GDCM_UNKNOWN);
+ VRKey const &vr = GDCM_VRUNKNOWN);
SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem);
// DictEntry related utilities
DictEntry *NewVirtualDictEntry(uint16_t group,uint16_t elem,
- TagName const &vr = GDCM_UNKNOWN,
+ VRKey const &vr = GDCM_VRUNKNOWN,
TagName const &vm = GDCM_UNKNOWN,
TagName const &name = GDCM_UNKNOWN );
// DictEntry related utilities
DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
- TagName const &vr);
+ VRKey const &vr);
/// To be able to backtrack (Private Sequence, Implicit VR related pb)
DocEntry *PreviousDocEntry;
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 11:35:31 $
- Version: $Revision: 1.293 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.294 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
int Document::ComputeGroup0002Length( )
{
uint16_t gr;
- std::string vr;
+ VRKey vr;
int groupLength = 0;
bool found0002 = false;
{
uint16_t group = entry->GetGroup();
uint16_t elem = entry->GetElement();
- std::string vr = entry->GetVR();
+ const VRKey &vr = entry->GetVR();
uint32_t length = entry->GetLength();
Fp->seekg((long)entry->GetOffset(), std::ios::beg);
void Document::FindDocEntryLength( DocEntry *entry )
throw ( FormatError )
{
- std::string vr = entry->GetVR();
+ const VRKey &vr = entry->GetVR();
uint16_t length16;
if ( Filetype == ExplicitVR && !entry->IsImplicitVR() )
* \brief Find the Value Representation of the current Dicom Element.
* @return Value Representation of the current Entry
*/
-std::string Document::FindDocEntryVR()
+VRKey Document::FindDocEntryVR()
{
if ( Filetype != ExplicitVR )
- return GDCM_UNKNOWN;
+ return GDCM_VRUNKNOWN;
long positionOnEntry = Fp->tellg();
// Warning: we believe this is explicit VR (Value Representation) because
// is in explicit VR and try to fix things if it happens not to be
// the case.
- char vr[3];
- Fp->read (vr, (size_t)2);
- vr[2] = 0;
+ VRKey vr;
+ Fp->read(&(vr[0]),(size_t)2);
+ gdcmWarningMacro( "--> VR: " << vr )
if ( !CheckDocEntryVR(vr) )
{
+ Global::GetVR()->Print(std::cerr);
+ gdcmWarningMacro( "Unknown VR '" << vr << "'" )
Fp->seekg(positionOnEntry, std::ios::beg);
- return GDCM_UNKNOWN;
+ return GDCM_VRUNKNOWN;
}
return vr;
}
* @return false if the VR is incorrect or if the VR isn't referenced
* otherwise, it returns true
*/
-bool Document::CheckDocEntryVR(VRKey vr)
+bool Document::CheckDocEntryVR(const VRKey &vr)
{
- if ( !Global::GetVR()->IsValidVR(vr) )
- return false;
-
- return true;
+ return Global::GetVR()->IsValidVR(vr);
}
/**
{
uint16_t elem = entry->GetElement();
uint16_t group = entry->GetGroup();
- const std::string &vr = entry->GetVR();
+ const VRKey &vr = entry->GetVR();
uint32_t length = entry->GetLength();
// When we have some semantics on the element we just read, and if we
if ( HasDCMPreamble )
HandleOutOfGroup0002(group, elem);
- std::string vr = FindDocEntryVR();
- std::string realVR = vr;
+ VRKey vr = FindDocEntryVR();
+
+ VRKey realVR = vr;
- if ( vr == GDCM_UNKNOWN )
+ if ( vr == GDCM_VRUNKNOWN )
{
if ( elem == 0x0000 ) // Group Length
{
}
}
}
+ gdcmWarningMacro( "Found VR: " << vr << " / Real VR: " << realVR );
DocEntry *newEntry;
if ( Global::GetVR()->IsVROfSequence(realVR) )
static_cast<DataEntry *>(newEntry)->SetState(DataEntry::STATE_NOTLOADED);
}
- if ( vr == GDCM_UNKNOWN )
+ if ( vr == GDCM_VRUNKNOWN )
{
if ( Filetype == ExplicitVR )
{
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2005/10/18 09:17:08 $
- Version: $Revision: 1.124 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.125 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void LoadDocEntry (DocEntry *e, bool forceLoad = false);
void FindDocEntryLength (DocEntry *e) throw ( FormatError );
uint32_t FindDocEntryLengthOBOrOW() throw( FormatUnexpected );
- std::string FindDocEntryVR();
- bool CheckDocEntryVR (VRKey k);
+ VRKey FindDocEntryVR();
+ bool CheckDocEntryVR (const VRKey &k);
void SkipDocEntry (DocEntry *entry);
void SkipToNextDocEntry (DocEntry *entry);
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:50 $
- Version: $Revision: 1.276 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.277 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
DataEntry *oldEntry = dynamic_cast<DataEntry *>(entry);
if (oldEntry)
{
- std::string PixelVR;
+ VRKey PixelVR;
// 8 bits allocated is a 'O Bytes' , as well as 24 (old ACR-NEMA RGB)
// more than 8 (i.e 12, 16) is a 'O Words'
if ( GetBitsAllocated() == 8 || GetBitsAllocated() == 24 )
Module: $RCSfile: gdcmFileHelper.cxx,v $
Language: C++
- Date: $Date: 2005/10/18 12:49:55 $
- Version: $Revision: 1.61 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.62 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
DataEntry *newE;
- if ( oldE && vr != GDCM_UNKNOWN )
- if ( oldE->GetVR()!=vr )
+ if ( oldE && vr != GDCM_VRUNKNOWN )
+ if ( oldE->GetVR() != vr )
oldE = NULL;
if ( oldE )
Program: gdcm
Module: $RCSfile: gdcmFileHelper.h,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:50 $
- Version: $Revision: 1.23 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.24 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void RestoreWriteOfLibido();
DataEntry *CopyDataEntry(uint16_t group, uint16_t elem,
- const TagName &vr = GDCM_UNKNOWN);
+ const TagName &vr = GDCM_VRUNKNOWN);
void CheckMandatoryElements();
void CheckMandatoryEntry(uint16_t group,uint16_t elem,std::string value);
void SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value);
Program: gdcm
Module: $RCSfile: gdcmGlobal.cxx,v $
Language: C++
- Date: $Date: 2005/10/11 08:24:10 $
- Version: $Revision: 1.26 $
+ Date: $Date: 2005/10/18 12:58:28 $
+ Version: $Revision: 1.27 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
const std::string GDCM_UNREAD = "gdcm::UnRead";
const std::string GDCM_NOTASCII = "gdcm::NotAscii";
const std::string GDCM_PIXELDATA = "gdcm::Pixel Data to be loaded";
+
+const std::string GDCM_VRUNKNOWN = " ";
+
//-----------------------------------------------------------------------------
DictSet *Global::Dicts = (DictSet *)0;
VR *Global::ValRes = (VR *)0;
Program: gdcm
Module: $RCSfile: gdcmSystem.h,v $
Language: C++
- Date: $Date: 2005/10/18 09:17:08 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2005/10/18 12:58:29 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#endif
#include <string>
-#define FASTTAGKEY 0
-
-// FIXME: Should rewrite this:
-#if FASTTAGKEY
-#include <iostream>
-#include <iomanip>
-#endif
-#if defined(_MSC_VER) && (_MSC_VER == 1200)
-/* ostream operator for std::string since VS6 does not provide it*/
-#include <iostream>
-#endif
//-----------------------------------------------------------------------------
#endif
Program: gdcm
Module: $RCSfile: gdcmVR.h,v $
Language: C++
- Date: $Date: 2005/10/18 08:35:51 $
- Version: $Revision: 1.20 $
+ Date: $Date: 2005/10/18 12:58:29 $
+ Version: $Revision: 1.21 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#define GDCMVR_H
#include "gdcmCommon.h"
+#include "gdcmVRKey.h"
+
#include <map>
#include <string>
#include <iostream>
{
//-----------------------------------------------------------------------------
-typedef std::string VRKey;
typedef std::string VRAtr;
/// Value Representation Hash Table
typedef std::map<VRKey, VRAtr> VRHT;
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmVRKey.h,v $
+ Language: C++
+ Date: $Date: 2005/10/18 12:58:29 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef GDCMVRKEY_H
+#define GDCMVRKEY_H
+
+#include "gdcmCommon.h"
+#include "gdcmDebug.h"
+
+#include <assert.h>
+
+namespace gdcm
+{
+//-----------------------------------------------------------------------------
+class VRKey
+{
+public :
+ inline VRKey() { key[0] = key[1] = ' ';}
+ inline VRKey(const char *_key) { key[0] = _key[0]; key[1] = _key[1];}
+ inline VRKey(const std::string &_key) { key[0] = _key[0]; key[1] = _key[1];}
+
+ inline std::string str() const { return std::string(key,2); }
+
+ friend std::ostream& operator<<(std::ostream& _os, const VRKey &_val);
+ friend std::istream& operator>>(std::istream& _is, VRKey &_val);
+
+ inline VRKey &operator=(const VRKey &_val)
+ {
+ key[0] = _val.key[0];
+ key[1] = _val.key[1];
+ return *this;
+ }
+ inline VRKey &operator=(const std::string &_val)
+ {
+ key[0] = _val[0];
+ key[1] = _val[1];
+ return *this;
+ }
+ inline VRKey &operator=(const char *_val)
+ {
+ key[0] = _val[0];
+ key[1] = _val[1];
+ return *this;
+ }
+
+ inline const char &operator[](const unsigned int &_id) const
+ {
+ assert(_id<2);
+ return key[_id];
+ }
+ inline char &operator[](const unsigned int &_id)
+ {
+ assert(_id<2);
+ return key[_id];
+ }
+
+ inline bool operator==(const VRKey &_val) const
+ {
+ return key[0] == _val.key[0] && key[1] == _val.key[1];
+ }
+ inline bool operator==(const std::string &_val) const
+ {
+ return key[0] == _val[0] && key[1] == _val[1];
+ }
+ inline bool operator==(const char *_val) const
+ {
+ return key[0] == _val[0] && key[1] == _val[1];
+ }
+
+ inline bool operator!=(const VRKey &_val) const
+ {
+ return key[0] != _val.key[0] || key[1] != _val.key[1];
+ }
+ inline bool operator!=(const std::string &_val) const
+ {
+ return key[0] != _val[0] || key[1] != _val[1];
+ }
+ inline bool operator!=(const char *_val) const
+ {
+ return key[0] != _val[0] || key[1] != _val[1];
+ }
+
+ inline bool operator<(const VRKey &_val) const
+ {
+ return key[0] < _val[0] || (key[0] == _val[0] && key[1] < _val[1]);
+ }
+
+private :
+ char key[2];
+};
+
+//-----------------------------------------------------------------------------
+inline std::ostream& operator<<(std::ostream& _os, const VRKey &_val)
+{
+ _os << _val.key[0] << _val[1];
+ return _os;
+}
+
+inline std::istream& operator>>(std::istream& _is, VRKey &_val)
+{
+ _is >> _val.key[0] >> _val[1];
+ return _is;
+}
+
+//-----------------------------------------------------------------------------
+
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+#endif