+2004-12-07 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+ * Test/TestUtil.cxx : reformat the source code
+ * vtk/vtkGdcmReader.cxx : remove and change prints
+ * src/gdcmValEntry.[cxx|h] : now set the length of the value when calling
+ SetValue
+ * src/gdcmBinEntry.[cxx|h] : SetValue method don't set the length
+ * src/*.cxx : remove all useless call to SetLength of a ValEntry object
+
2004-12-07 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
* src/gdcmPixelWriteConvert.[h|cxx] : ficnished this class
* src/gdcmFile.cxx : finished the correctly use of PixelWriteConvert
Program: gdcm
Module: $RCSfile: TestUtil.cxx,v $
Language: C++
- Date: $Date: 2004/12/03 20:16:56 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2004/12/07 13:39:32 $
+ 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
int TestUtil(int , char * [])
{
+ // Unique UID test
std::cout << gdcm::Util::CreateUniqueUID("") << std::endl;
+ // DicomString test
const char ref[] = "MONOCHROME1";
std::string a = "MONOCHROME1";
a += '\0';
std::string c = gdcm::Util::DicomString("MONOCHROME1");
std::string d = "MONOCHROME1";
- if( !gdcm::Util::DicomStringEqual(a,ref) ) return 1;
- if( !gdcm::Util::DicomStringEqual(b,ref) ) return 1;
- if( !gdcm::Util::DicomStringEqual(c,ref) ) return 1;
- if( gdcm::Util::DicomStringEqual(d,ref) ) return 1;
+ if( !gdcm::Util::DicomStringEqual(a,ref) )
+ return 1;
+ if( !gdcm::Util::DicomStringEqual(b,ref) )
+ return 1;
+ if( !gdcm::Util::DicomStringEqual(c,ref) )
+ return 1;
+ if( gdcm::Util::DicomStringEqual(d,ref) )
+ return 1;
return 0;
}
Program: gdcm
Module: $RCSfile: gdcmBinEntry.h,v $
Language: C++
- Date: $Date: 2004/12/03 20:16:57 $
- Version: $Revision: 1.27 $
+ Date: $Date: 2004/12/07 13:39:32 $
+ Version: $Revision: 1.28 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
uint8_t* GetBinArea() { return BinArea; }
void SetBinArea( uint8_t* area, bool self = true );
+ /// Sets the value (string) of the current Dicom Document Entry
+ virtual void SetValue(std::string const & val) {SetValueOnly(val);};
private:
/// \brief unsecure memory area to hold 'non string' values
/// (ie : Lookup Tables, overlays, icons)
Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2004/12/06 11:37:38 $
- Version: $Revision: 1.87 $
+ Date: $Date: 2004/12/07 13:39:33 $
+ Version: $Revision: 1.88 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
entry->SetOffset(0); // just to avoid further missprinting
entry->SetValue( it->Value );
- // dealing with value length ...
-
- if( dictEntry->GetGroup() == 0xfffe)
- {
- entry->SetLength(entry->GetValue().length());
- }
- else if( dictEntry->GetVR() == "UL" || dictEntry->GetVR() == "SL" )
- {
- entry->SetLength( 4 );
- }
- else if( dictEntry->GetVR() == "US" || dictEntry->GetVR() == "SS" )
- {
- entry->SetLength(2);
- }
- else if( dictEntry->GetVR() == "SQ" )
- {
- entry->SetLength( 0xffffffff );
- }
- else
- {
- entry->SetLength( entry->GetValue().length() );
- }
p->AddEntry( entry );
}
entry = new ValEntry( dictEntry ); // Be sure it's never a BinEntry !
entry->SetOffset(0); // just to avoid further missprinting
- entry->SetLength(0); // just to avoid further missprinting
if( header )
{
val = it->Value;
}
- // GDCM_UNFOUND or not !
-
entry->SetValue( val ); // troubles expected when vr=SQ ...
- if( dictEntry )
- {
- if( dictEntry->GetGroup() == 0xfffe )
- {
- entry->SetLength( entry->GetValue().length() ); // FIXME
- }
- else if( dictEntry->GetVR() == "UL" || dictEntry->GetVR() == "SL" )
- {
- entry->SetLength(4);
- }
- else if( dictEntry->GetVR() == "US" || dictEntry->GetVR() == "SS" )
- {
- entry->SetLength(2);
- }
- else if( dictEntry->GetVR() == "SQ" )
- {
- entry->SetLength( 0xffffffff );
- }
- else
- {
- entry->SetLength( entry->GetValue().length() );
- }
- }
-
if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
{
std::cout << "GDCM_DICOMDIR_META ?!? should never print that"
Program: gdcm
Module: $RCSfile: gdcmDicomDirObject.cxx,v $
Language: C++
- Date: $Date: 2004/12/07 09:32:24 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2004/12/07 13:39:33 $
+ Version: $Revision: 1.12 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
entry->SetOffset(0); // just to avoid further missprinting
entry->SetValue(it->Value);
- // dealing with value length ...
-
- if(dictEntry->GetGroup()==0xfffe)
- {
- entry->SetLength(entry->GetValue().length());
- }
- else if( dictEntry->GetVR() == "UL" || dictEntry->GetVR() == "SL" )
- {
- entry->SetLength(4);
- }
- else if( dictEntry->GetVR() == "US" || dictEntry->GetVR() == "SS" )
- {
- entry->SetLength(2);
- }
- else if( dictEntry->GetVR() == "SQ" )
- {
- entry->SetLength(0xffffffff);
- }
- else
- {
- entry->SetLength(entry->GetValue().length());
- }
AddEntry(entry);
}
}
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2004/12/06 12:54:40 $
- Version: $Revision: 1.148 $
+ Date: $Date: 2004/12/07 13:39:33 $
+ Version: $Revision: 1.149 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
std::string Document::GetEntryByNumber(uint16_t group, uint16_t element)
{
TagKey key = DictEntry::TranslateToKey(group, element);
- /// \todo use map methods, instead of multimap JPR
if ( !TagHT.count(key))
{
return GDCM_UNFOUND;
bool Document::SetEntryByNumber(std::string const& content,
uint16_t group, uint16_t element)
{
- int c;
- int l;
-
ValEntry* valEntry = GetValEntryByNumber(group, element);
if (!valEntry )
{
return false;
}
// Non even content must be padded with a space (020H)...
- std::string finalContent = Util::DicomString( content.c_str() );
- assert( !(finalContent.size() % 2) );
- valEntry->SetValue(finalContent);
-
- // Integers have a special treatement for their length:
- l = finalContent.length();
- if ( l != 0) // To avoid to be cheated by 'zero length' integers
- {
- VRKey vr = valEntry->GetVR();
- if( vr == "US" || vr == "SS" )
- {
- // for multivaluated items
- c = Util::CountSubstring(content, "\\") + 1;
- l = c*2;
- }
- else if( vr == "UL" || vr == "SL" )
- {
- // for multivaluated items
- c = Util::CountSubstring(content, "\\") + 1;
- l = c*4;;
- }
- }
- valEntry->SetLength(l);
+ valEntry->SetValue(content);
return true;
}
return true;
}
-/**
- * \brief Accesses an existing DocEntry (i.e. a Dicom Element)
- * in the PubDocEntrySet of this instance
- * through it's (group, element) and modifies it's length with
- * the given value.
- * \warning Use with extreme caution.
- * @param l new length to substitute with
- * @param group group number of the Entry to modify
- * @param element element number of the Entry to modify
- * @return true on success, false otherwise.
- */
-/*bool Document::SetEntryLengthByNumber(uint32_t l,
- uint16_t group, uint16_t element)
-{
- /// \todo use map methods, instead of multimap JPR
- TagKey key = DictEntry::TranslateToKey(group, element);
- if ( !TagHT.count(key) )
- {
- return false;
- }
- if ( l % 2 )
- {
- l++; // length must be even
- }
- ( ((TagHT.equal_range(key)).first)->second )->SetLength(l);
-
- return true ;
-}*/
-
-/**
- * \brief Gets (from Header) the offset of a 'non string' element value
- * (LoadElementValues has already be executed)
- * @param group group number of the Entry
- * @param elem element number of the Entry
- * @return File Offset of the Element Value
- */
-/*size_t Document::GetEntryOffsetByNumber(uint16_t group, uint16_t elem)
-{
- DocEntry* entry = GetDocEntryByNumber(group, elem);
- if (!entry)
- {
- dbg.Verbose(1, "Document::GetDocEntryByNumber: no entry present.");
- return 0;
- }
- return entry->GetOffset();
-}*/
-
/**
* \brief Gets (from Header) a 'non string' element value
* (LoadElementValues has already be executed)
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2004/12/03 20:16:58 $
- Version: $Revision: 1.67 $
+ Date: $Date: 2004/12/07 13:39:33 $
+ Version: $Revision: 1.68 $
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 element);
virtual bool SetEntryByNumber(uint8_t* content, int lgth,
uint16_t group, uint16_t element);
- // FIXME
- // Verify the usefull of this method... otherwise remove it
- // It's body is commented in the .xx
- //virtual bool SetEntryLengthByNumber(uint32_t length,
- // uint16_t group, uint16_t element);
-
- // FIXME
- // Verify the usefull of this method... otherwise remove it
- // It's body is commented in the .xx
- // virtual size_t GetEntryOffsetByNumber(uint16_t group, uint16_t elem);
virtual void* GetEntryBinAreaByNumber(uint16_t group, uint16_t elem);
// FIXME
// Verify the usefull of this method... otherwise remove it
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2004/12/07 09:32:24 $
- Version: $Revision: 1.172 $
+ Date: $Date: 2004/12/07 13:39:33 $
+ Version: $Revision: 1.173 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
if(HeaderInternal->HasLUT())
{
photInt->SetValue("PALETTE COLOR ");
- photInt->SetLength(14);
}
else
{
photInt->SetValue("MONOCHROME1 ");
- photInt->SetLength(12);
}
PixelWriteConverter->SetReadData(PixelReadConverter->GetDecompressed(),
ValEntry* spp = CopyValEntry(0x0028,0x0002);
spp->SetValue("3 ");
- spp->SetLength(2);
ValEntry* planConfig = CopyValEntry(0x0028,0x0006);
planConfig->SetValue("0 ");
- planConfig->SetLength(2);
ValEntry* photInt = CopyValEntry(0x0028,0x0004);
photInt->SetValue("RGB ");
- photInt->SetLength(4);
if(PixelReadConverter->GetRGB())
{
{
ValEntry* bitsAlloc = CopyValEntry(0x0028,0x0100);
bitsAlloc->SetValue("8 ");
- bitsAlloc->SetLength(2);
ValEntry* bitsStored = CopyValEntry(0x0028,0x0101);
bitsStored->SetValue("8 ");
- bitsStored->SetLength(2);
ValEntry* highBit = CopyValEntry(0x0028,0x0102);
highBit->SetValue("7 ");
- highBit->SetLength(2);
Archive->Push(bitsAlloc);
Archive->Push(bitsStored);
ValEntry* tss = CopyValEntry(0x0002,0x0010);
tss->SetValue(ts);
- tss->SetLength(ts.length());
Archive->Push(tss);
}
ValEntry* tss = CopyValEntry(0x0002,0x0010);
tss->SetValue(ts);
- tss->SetLength(ts.length());
}
void File::RestoreWriteFileType()
ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
libidoCode->SetValue("ACRNEMA_LIBIDO_1.1");
- libidoCode->SetLength(10);
Archive->Push(libidoCode);
}
{
ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
libidoCode->SetValue("");
- libidoCode->SetLength(0);
Archive->Push(libidoCode);
}
}
Program: gdcm
Module: $RCSfile: gdcmHeader.cxx,v $
Language: C++
- Date: $Date: 2004/12/07 02:36:21 $
- Version: $Revision: 1.212 $
+ Date: $Date: 2004/12/07 13:39:33 $
+ Version: $Revision: 1.213 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
return "FD";
}
- if ( bitsAlloc == "12" )
+ else if ( bitsAlloc == "12" )
{
// It will be unpacked
bitsAlloc = "16";
dbg.Verbose(0, "Header::GetPixelType: unfound Pixel Representation");
bitsAlloc = "0";
}
- if ( sign == "0" )
+ else if ( sign == "0" )
{
sign = "U";
}
Program: gdcm
Module: $RCSfile: gdcmSQItem.cxx,v $
Language: C++
- Date: $Date: 2004/12/06 11:37:38 $
- Version: $Revision: 1.41 $
+ Date: $Date: 2004/12/07 13:39:33 $
+ Version: $Revision: 1.42 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
// we assume the constructor didn't fail
entry = new ValEntry(dictEntry);
-
if (entry)
{
entry->SetValue(val);
}
- entry->SetLength(val.length());
DocEntries.insert(i,entry);
return true;
{
entry->SetValue(val);
}
- (*i)->SetLength(val.length());
return true;
}
}
Program: gdcm
Module: $RCSfile: gdcmValEntry.cxx,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:12 $
- Version: $Revision: 1.38 $
+ Date: $Date: 2004/12/07 13:39:33 $
+ Version: $Revision: 1.39 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
=========================================================================*/
#include "gdcmValEntry.h"
+#include "gdcmVR.h"
#include "gdcmTS.h"
#include "gdcmGlobal.h"
#include "gdcmUtil.h"
os << s.str();
}
+//-----------------------------------------------------------------------------
+// Public
+void ValEntry::SetValue(std::string const & val)
+{
+ // Integers have a special treatement for their length:
+ int l = val.length();
+ if ( l != 0) // To avoid to be cheated by 'zero length' integers
+ {
+ VRKey vr = GetVR();
+ if( vr == "US" || vr == "SS" )
+ {
+ // for multivaluated items
+ l = (Util::CountSubstring(val, "\\") + 1) * 2;
+ }
+ else if( vr == "UL" || vr == "SL" )
+ {
+ // for multivaluated items
+ l = (Util::CountSubstring(val, "\\") + 1) * 4;;
+ }
+ SetValueOnly(val);
+ }
+ else
+ {
+ std::string finalVal = Util::DicomString( val.c_str() );
+ assert( !(finalVal.size() % 2) );
+
+ l = finalVal.length();
+ SetValueOnly(finalVal);
+ }
+
+ SetLength(l);
+}
+
/*
* \brief canonical Writer
*/
{
DocEntry::WriteContent(fp, filetype);
- //std::cout << "=====================================" << GetVR() << std::endl;
-
if ( GetGroup() == 0xfffe )
{
return; //delimitors have NO value
return;
}
- assert( lgr == GetValue().size() );
+ assert( lgr == GetValue().length() );
binary_write(*fp, GetValue());
}
-//-----------------------------------------------------------------------------
-// Public
-
//-----------------------------------------------------------------------------
// Protected
Program: gdcm
Module: $RCSfile: gdcmValEntry.h,v $
Language: C++
- Date: $Date: 2004/12/03 20:16:58 $
- Version: $Revision: 1.32 $
+ Date: $Date: 2004/12/07 13:39:33 $
+ Version: $Revision: 1.33 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// current Dicom Document Entry
std::string const & GetValue() const { return Value; };
- /// Sets the value (string) of the current Dicom Document Entry
- void SetValue(std::string const & val) { Value = val; };
+ /// Sets the value (string) of the current Dicom Document Entry.
+ /// The size is updated
+ virtual void SetValue(std::string const & val);
virtual void Print(std::ostream &os = std::cout);
+
virtual void WriteContent(std::ofstream *fp, FileType filetype);
protected:
+ /// Sets the value (string) of the current Dicom Document Entry
+ void SetValueOnly(std::string const & val) { Value = val; };
private:
// Members :
#include <vtkPointData.h>
#include <vtkLookupTable.h>
-vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.60 $");
+vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.61 $");
vtkStandardNewMacro(vtkGdcmReader);
//-----------------------------------------------------------------------------
&& (type != "16U") && (type != "16S")
&& (type != "32U") && (type != "32S") )
{
- vtkErrorMacro(<< "Bad File Type for file" << filename->c_str());
- vtkErrorMacro(<< " " << type.c_str());
- vtkErrorMacro(<< "Removing this file from readed files "
- << filename->c_str());
+ vtkErrorMacro(<< "Bad File Type for file " << filename->c_str() << "\n"
+ << " File type found : " << type.c_str()
+ << " (might be 8U, 8S, 16U, 16S, 32U, 32S) \n"
+ << " Removing this file from readed files");
*filename = "GDCM_UNREADABLE";
continue;
}
{
for (int line = 0; line < numLines; line++)
{
- cerr << line << endl;
// Copy one line at proper destination:
memcpy((void*)destination, (void*)source, lineSize);
source += lineSize;