+Mon Oct 18 10:27:49 2005 by regrain
+ * Minor coding-style clean up
+ * Replace the ContentEntry and its derived classes (BinEntry and ValEntry)
+ by the DataEntry. This unique entry considers all datas like binary datas.
+ Some methods are added to interpret - at fly - the binary datas.
+ Due to this important change, some methods of the DocEntrySet, concerning
+ the BinEntry and ValEntry classes, are erased ; and new methods for the
+ DataEntry class are created.
+ Some methods to set the ValEntry or the BinEntry are renamed to
+ correspond to the new DataEntry, like for example :
+ - SetValEntry -> SetEntryString
+ - SetBinEntry -> SetEntryBinArea
+ This change will remove all useless creation of the string when working
+ directly on values.
+
Thu Aug 25 16:59:49 2005 by jpr
gdcmBinEntry.cxx
Now Print displays the BinEntry Content (if it's printable, and loaded)
Program: gdcm
Module: $RCSfile: AnonymizeDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/07/21 04:55:50 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ 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
#include "gdcmSQItem.h"
#include "gdcmSeqEntry.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmDocument.h"
#include "gdcmFile.h"
if ( d == NULL)
return;
- if ( ! dynamic_cast<gdcm::ValEntry *>(d) )
+ if ( ! dynamic_cast<gdcm::DataEntry *>(d) )
return;
offset = d->GetOffset();
while(tmpSI)
{
d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
- if ( gdcm::ValEntry* valEntry = dynamic_cast<gdcm::ValEntry *>(d) )
+ if ( gdcm::DataEntry *dataEntry = dynamic_cast<gdcm::DataEntry *>(d) )
{
- v = valEntry->GetValue();
+ v = dataEntry->GetString();
}
else
{
- std::cout << "(0004,1430) not a ValEntry ?!?" << std::endl;
+ std::cout << "(0004,1430) not a DataEntry ?!?" << std::endl;
continue;
}
Program: gdcm
Module: $RCSfile: FindTags.cxx,v $
Language: C++
- Date: $Date: 2005/07/08 12:02:02 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ Version: $Revision: 1.15 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
int dataSize = h->GetImageDataSize();
std::cout << "---> pourFindTaggs : dataSize " << dataSize << std::endl;
- h->SetValEntry(RecCode ,0x0008,0x0010);
- h->SetValEntry(ManufacturerName ,0x0008,0x0070);
+ h->SetEntryString(RecCode ,0x0008,0x0010);
+ h->SetEntryString(ManufacturerName ,0x0008,0x0070);
// ImagePositionPatient
- ImagePositionPatient = h->GetFile()->GetEntryValue(0x0020,0x0032);
+ ImagePositionPatient = h->GetFile()->GetEntryString(0x0020,0x0032);
// Image Position (RET)
- h->SetValEntry(ImagePositionPatient, 0x0020,0x0030);
+ h->SetEntryString(ImagePositionPatient, 0x0020,0x0030);
sscanf(ImagePositionPatient.c_str(), "%f%c%f%c%f", &x,&c,&y,&c,&z);
// Location
std::string zizi = gdcm::Util::Format("%f",l);
Location = gdcm::Util::DicomString(zizi.c_str());
- h->SetValEntry(Location, 0x0020,0x0050);
+ h->SetEntryString(Location, 0x0020,0x0050);
// sinon, la longueur du champ est erronée (?!?)
// Probable sac de noeud entre strlen(xxx.c_str()) et xxx.length()
zizi = gdcm::Util::Format("%d",0x7FE0);
ImageLocation = gdcm::Util::DicomString(zizi.c_str());
-//h->SetValEntry(Location, 0x0028,0x0200);
+//h->SetEntryString(Location, 0x0028,0x0200);
//h->GetFile()->SetEntryLength(strlen(ImageLocation.c_str())-1, 0x0020,0x0050); // prudence !
// void *imageData= h->GetImageData();
Program: gdcm
Module: $RCSfile: PrintDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/07/21 04:55:50 $
- Version: $Revision: 1.28 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ Version: $Revision: 1.29 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
=========================================================================*/
#include "gdcmDocument.h"
#include "gdcmDicomDir.h"
-#include "gdcmValEntry.h"
#include "gdcmDicomDirPatient.h"
#include "gdcmDicomDirStudy.h"
#include "gdcmDicomDirVisit.h"
pa = f->GetFirstPatient();
while (pa)
{
- std::cout << "Pat.Name:[" << pa->GetEntryValue(0x0010, 0x0010) <<"]"; // Patient's Name
+ std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
std::cout << " Pat.ID:[";
- std::cout << pa->GetEntryValue(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+ std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
pa = f->GetNextPatient();
}
break;
pa = f->GetFirstPatient();
while ( pa ) // on degouline les PATIENT de ce DICOMDIR
{
- std::cout << "Pat.Name:[" << pa->GetEntryValue(0x0010, 0x0010) <<"]"; // Patient's Name
+ std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
std::cout << " Pat.ID:[";
- std::cout << pa->GetEntryValue(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+ std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
st = pa->GetFirstStudy();
while ( st ) { // on degouline les STUDY de ce patient
- std::cout << "--- Stud.descr:[" << st->GetEntryValue(0x0008, 0x1030) << "]"; // Study Description
- std::cout << " Stud.ID:[" << st->GetEntryValue(0x0020, 0x0010) << "]"; // Study ID
+ std::cout << "--- Stud.descr:[" << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description
+ std::cout << " Stud.ID:[" << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
std::cout << std::endl;
st = pa->GetNextStudy();
}
while ( pa ) // on degouline les PATIENT de ce DICOMDIR
{
// Patient's Name, Patient ID
- std::cout << "Pat.Name:[" << pa->GetEntryValue(0x0010, 0x0010) <<"]"; // Patient's Name
+ std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
std::cout << " Pat.ID:[";
- std::cout << pa->GetEntryValue(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+ std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
st = pa->GetFirstStudy();
while ( st ) { // on degouline les STUDY de ce patient
- std::cout << "--- Stud.descr:[" << st->GetEntryValue(0x0008, 0x1030) << "]"; // Study Description
- std::cout << " Stud.ID:[" << st->GetEntryValue(0x0020, 0x0010) << "]"; // Study ID
+ std::cout << "--- Stud.descr:[" << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description
+ std::cout << " Stud.ID:[" << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
std::cout << std::endl;
se = st->GetFirstSerie();
while ( se ) { // on degouline les SERIES de cette study
- std::cout << "--- --- Ser.Descr:["<< se->GetEntryValue(0x0008, 0x103e)<< "]"; // Series Description
- std::cout << " Ser.nb:[" << se->GetEntryValue(0x0020, 0x0011); // Series number
- std::cout << "] Mod.:[" << se->GetEntryValue(0x0008, 0x0060) << "]"; // Modality
+ std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]"; // Series Description
+ std::cout << " Ser.nb:[" << se->GetEntryString(0x0020, 0x0011); // Series number
+ std::cout << "] Mod.:[" << se->GetEntryString(0x0008, 0x0060) << "]"; // Modality
std::cout << std::endl;
se = st->GetNextSerie();
}
vs = st->GetFirstVisit();
while ( vs ) { // on degouline les VISIT de cette study
std::cout << "--- --- VISIT: ";
- std::cout << " Ref. File ID :[" << vs->GetEntryValue(0x0004, 0x1500) << "]"; // Referenced File ID
- std::cout << " Inst.Name:[" << vs->GetEntryValue(0x0008,0x0080) << "]"; // Institution Name
- std::cout << " Adm.ID:[" << vs->GetEntryValue(0x0038, 0x0010) << "]"; // Admission ID
- std::cout << " Adm. date:[" << vs->GetEntryValue(0x0038, 0x0020) << "]"; // Admitting Date
+ std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID
+ std::cout << " Inst.Name:[" << vs->GetEntryString(0x0008,0x0080) << "]"; // Institution Name
+ std::cout << " Adm.ID:[" << vs->GetEntryString(0x0038, 0x0010) << "]"; // Admission ID
+ std::cout << " Adm. date:[" << vs->GetEntryString(0x0038, 0x0020) << "]"; // Admitting Date
std::cout << std::endl;
vs = st->GetNextVisit();
}
pa = f->GetFirstPatient();
while ( pa ) { // les PATIENT de ce DICOMDIR
// Patient's Name, Patient ID
- std::cout << "Pat.Name:[" << pa->GetEntryValue(0x0010, 0x0010) <<"]"; // Patient's Name
+ std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
std::cout << " Pat.ID:[";
- std::cout << pa->GetEntryValue(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+ std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
st = pa->GetFirstStudy();
while ( st ) { // on degouline les STUDY de ce patient
- std::cout << "--- Stud.descr:[" << st->GetEntryValue(0x0008, 0x1030) << "]"; // Study Description
- std::cout << " Stud.ID:[" << st->GetEntryValue(0x0020, 0x0010) << "]"; // Study ID
+ std::cout << "--- Stud.descr:[" << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description
+ std::cout << " Stud.ID:[" << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
std::cout << std::endl;
vs = st->GetFirstVisit();
while ( vs ) { // on degouline les VISIT de cette study
std::cout << "--- --- VISIT: ";
- std::cout << " Ref. File ID :[" << vs->GetEntryValue(0x0004, 0x1500) << "]"; // Referenced File ID
- std::cout << " Inst.Name:[" << vs->GetEntryValue(0x0008,0x0080) << "]"; // Institution Name
- std::cout << " Adm.ID:[" << vs->GetEntryValue(0x0038, 0x0010) << "]"; // Admission ID
- std::cout << " Adm. date:[" << vs->GetEntryValue(0x0038, 0x0020) << "]"; // Admitting Date
+ std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID
+ std::cout << " Inst.Name:[" << vs->GetEntryString(0x0008,0x0080) << "]"; // Institution Name
+ std::cout << " Adm.ID:[" << vs->GetEntryString(0x0038, 0x0010) << "]"; // Admission ID
+ std::cout << " Adm. date:[" << vs->GetEntryString(0x0038, 0x0020) << "]"; // Admitting Date
std::cout << std::endl;
vs = st->GetNextVisit();
}
se = st->GetFirstSerie();
while ( se ) { // on degouline les SERIES de cette study
- std::cout << "--- --- Ser.Descr:["<< se->GetEntryValue(0x0008, 0x103e)<< "]"; // Series Description
- std::cout << " Ser.nb:[" << se->GetEntryValue(0x0020, 0x0011); // Series number
- std::cout << "] Mod.:[" << se->GetEntryValue(0x0008, 0x0060) << "]"; // Modality
+ std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]"; // Series Description
+ std::cout << " Ser.nb:[" << se->GetEntryString(0x0020, 0x0011); // Series number
+ std::cout << "] Mod.:[" << se->GetEntryString(0x0008, 0x0060) << "]"; // Modality
std::cout << std::endl;
im = se->GetFirstImage();
while ( im ) { // on degouline les Images de cette serie
- std::cout << "--- --- --- "<< " IMAGE Ref. File ID :[" << im->GetEntryValue(0x0004, 0x1500)
+ std::cout << "--- --- --- "<< " IMAGE Ref. File ID :[" << im->GetEntryString(0x0004, 0x1500)
<< "]" << std::endl; // File name (Referenced File ID)
im = se->GetNextImage();
}
itPatient = f->GetDicomDirPatients().begin();
while ( itPatient != f->GetDicomDirPatients().end() ) { // on degouline les PATIENT de ce DICOMDIR
- std::cout << (*itPatient)->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name
+ std::cout << (*itPatient)->GetEntryString(0x0010, 0x0010) << std::endl; // Patient's Name
itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
- std::cout << "--- "<< (*itStudy)->GetEntryValue(0x0008, 0x1030) << std::endl; // Study Description
+ std::cout << "--- "<< (*itStudy)->GetEntryString(0x0008, 0x1030) << std::endl; // Study Description
itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
- std::cout << "--- --- "<< (*itSerie)->GetEntryValue(0x0008, 0x103e) << std::endl; // Serie Description
+ std::cout << "--- --- "<< (*itSerie)->GetEntryString(0x0008, 0x103e) << std::endl; // Serie Description
itImage = ((*itSerie)->GetDicomDirImages()).begin();
while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les IMAGES de cette serie
- std::cout << "--- --- --- "<< (*itImage)->GetEntryValue(0x0004, 0x1500) << std::endl; // File name
+ std::cout << "--- --- --- "<< (*itImage)->GetEntryString(0x0004, 0x1500) << std::endl; // File name
++itImage;
}
++itSerie;
Program: gdcm
Module: $RCSfile: PrintFile.cxx,v $
Language: C++
- Date: $Date: 2005/10/13 09:18:34 $
- Version: $Revision: 1.62 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ Version: $Revision: 1.63 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmDocument.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmFileHelper.h"
#include "gdcmDebug.h"
gdcm::SQItem *sqi= modLutSeq->GetFirstSQItem();
if ( sqi != 0 )
{
- std::string lutDescriptor = sqi->GetEntryValue(0x0028,0x3002);
+ std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
if ( /*lutDescriptor == GDCM_UNFOUND*/ 0 )
{
//gdcmWarningMacro( "LUT Descriptor is missing" );
std::cout << "Wrong LUT descriptor" << std::endl;
}
//LUT Data (CTX dependent)
- gdcm::BinEntry *b = sqi->GetBinEntry(0x0028,0x3006);
+ gdcm::DataEntry *b = sqi->GetDataEntry(0x0028,0x3006);
if ( b != 0 )
{
int BitsAllocated = f->GetBitsAllocated();
}
}
else
- std::cout << "No LUT Data BinEntry (0x0028,0x3006) found?!? "
+ std::cout << "No LUT Data DataEntry (0x0028,0x3006) found?!? "
<< std::endl;
}
else
<< "] PlanarConfiguration= [" << planarConfig
<< "] "<< std::endl
<< " PhotometricInterpretation= ["
- << f->GetEntryValue(0x0028,0x0004)
+ << f->GetEntryString(0x0028,0x0004)
<< "] "<< std::endl;
int numberOfScalarComponents=f->GetNumberOfScalarComponents();
<< " LUT = " << (f->HasLUT() ? "TRUE" : "FALSE")
<< std::endl;
- if ( f->GetEntryValue(0x0002,0x0010) == gdcm::GDCM_NOTLOADED )
- {
- std::cout << "Transfer Syntax not loaded. " << std::endl
- << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
- << std::endl;
- return 0;
- }
+ if ( f->GetDataEntry(0x0002,0x0010) )
+ if ( f->GetDataEntry(0x0002,0x0010)->IsNotLoaded() )
+ {
+ std::cout << "Transfer Syntax not loaded. " << std::endl
+ << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
+ << std::endl;
+ return 0;
+ }
std::string transferSyntaxName = f->GetTransferSyntaxName();
std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]"
<< std::endl;
std::cout << " SwapCode= " << f->GetSwapCode() << std::endl;
std::cout << " ------" << std::endl;
+
//std::cout << "\n\n" << std::endl;
//std::cout << "X spacing " << f->GetXSpacing() << std::endl;
//std::cout << "Y spacing " << f->GetYSpacing() << std::endl;
// ------------------------------------------------------------
std::string strPatientPosition =
- f->GetEntryValue(0x0018,0x5100);
+ f->GetEntryString(0x0018,0x5100);
if ( strPatientPosition != gdcm::GDCM_UNFOUND
&& strPatientPosition != "" )
std::cout << "PatientPosition (0x0010,0x5100)= ["
<< strPatientPosition << "]" << std::endl;
std::string strViewPosition =
- f->GetEntryValue(0x0018,0x5101);
+ f->GetEntryString(0x0018,0x5101);
if ( strViewPosition != gdcm::GDCM_UNFOUND
&& strViewPosition != "" )
std::cout << "strViewPosition (0x0010,0x5101)= ["
<< strViewPosition << "]" << std::endl;
std::string strPatientOrientation =
- f->GetEntryValue(0x0020,0x0020);
+ f->GetEntryString(0x0020,0x0020);
if ( strPatientOrientation != gdcm::GDCM_UNFOUND
&& strPatientOrientation != "")
std::cout << "PatientOrientation (0x0020,0x0020)= ["
<< strPatientOrientation << "]" << std::endl;
std::string strImageOrientationPatient =
- f->GetEntryValue(0x0020,0x0037);
+ f->GetEntryString(0x0020,0x0037);
if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND
&& strImageOrientationPatient != "" )
std::cout << "ImageOrientationPatient (0x0020,0x0037)= ["
<< strImageOrientationPatient << "]" << std::endl;
std::string strImageOrientationRET =
- f->GetEntryValue(0x0020,0x0035);
+ f->GetEntryString(0x0020,0x0035);
if ( strImageOrientationRET != gdcm::GDCM_UNFOUND
&& strImageOrientationRET != "" )
std::cout << "ImageOrientationRET (0x0020,0x0035)= ["
gdcm::SQItem *sqi= modLutSeq->GetFirstSQItem();
if ( !sqi )
{
- std::string lutDescriptor = sqi->GetEntryValue(0x0028,0x3002);
+ std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
int length; // LUT length in Bytes
int deb; // Subscript of the first Lut Value
int nbits; // Lut item size (in Bits)
//gdcmWarningMacro( "Wrong LUT descriptor" );
std::cout << "Wrong LUT descriptor" << std::endl;
}
- gdcm::BinEntry *b = sqi->GetBinEntry(0x0028,0x3006);
+ gdcm::DataEntry *b = sqi->GetDataEntry(0x0028,0x3006);
if ( b != 0 )
{
if ( b->GetLength() != 0 )
// ------------------------------------------------------------
std::string strPatientPosition =
- f->GetEntryValue(0x0018,0x5100);
+ f->GetEntryString(0x0018,0x5100);
if ( strPatientPosition != gdcm::GDCM_UNFOUND
&& strPatientPosition != "" )
std::cout << "PatientPosition (0x0010,0x5100)= ["
<< strPatientPosition << "]" << std::endl;
std::string strViewPosition =
- f->GetEntryValue(0x0018,0x5101);
+ f->GetEntryString(0x0018,0x5101);
if ( strViewPosition != gdcm::GDCM_UNFOUND
&& strViewPosition != "" )
std::cout << "strViewPosition (0x0010,0x5101)= ["
<< strViewPosition << "]" << std::endl;
std::string strPatientOrientation =
- f->GetEntryValue(0x0020,0x0020);
+ f->GetEntryString(0x0020,0x0020);
if ( strPatientOrientation != gdcm::GDCM_UNFOUND
&& strPatientOrientation != "")
std::cout << "PatientOrientation (0x0020,0x0020)= ["
<< strPatientOrientation << "]" << std::endl;
std::string strImageOrientationPatient =
- f->GetEntryValue(0x0020,0x0037);
+ f->GetEntryString(0x0020,0x0037);
if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND
&& strImageOrientationPatient != "" )
std::cout << "ImageOrientationPatient (0x0020,0x0037)= ["
<< strImageOrientationPatient << "]" << std::endl;
std::string strImageOrientationRET =
- f->GetEntryValue(0x0020,0x0035);
+ f->GetEntryString(0x0020,0x0035);
if ( strImageOrientationRET != gdcm::GDCM_UNFOUND
&& strImageOrientationRET != "" )
std::cout << "ImageOrientationRET (0x0020,0x0035)= ["
Program: gdcm
Module: $RCSfile: ReWrite.cxx,v $
Language: C++
- Date: $Date: 2005/10/17 10:29:32 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ Version: $Revision: 1.13 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
<< " SampleserPixel=" << sPP
<< " PlanarConfiguration=" << planarConfig
<< " PhotometricInterpretation="
- << f->GetEntryValue(0x0028,0x0004)
+ << f->GetEntryString(0x0028,0x0004)
<< std::endl;
int numberOfScalarComponents=f->GetNumberOfScalarComponents();
Program: gdcm
Module: $RCSfile: TestChangeHeader.cxx,v $
Language: C++
- Date: $Date: 2005/07/08 12:02:02 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ Version: $Revision: 1.16 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
f2->GetFile()->GetPubDict()->GetEntry( 0x0018, 1310 );
std::cerr << std::hex << dictEntry->GetGroup() << "," << dictEntry->GetElement() << std::endl;
- std::string matrix = f2->GetFile()->GetEntryValue(0x0018, 0x1310);
+ std::string matrix = f2->GetFile()->GetEntryString(0x0018, 0x1310);
if(matrix != "gdcm::Unfound")
{
std::cerr << "Aquisition Matrix:" << matrix << std::endl;
- f1->GetFile()->InsertValEntry( matrix, 0x0018, 0x1310);
+ f1->GetFile()->InsertEntryString( matrix, 0x0018, 0x1310);
}
f1->GetImageData();
Program: gdcm
Module: $RCSfile: TestCopyDicom.cxx,v $
Language: C++
- Date: $Date: 2005/10/17 10:41:59 $
- Version: $Revision: 1.30 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ Version: $Revision: 1.31 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
#include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#ifndef _WIN32
#include <unistd.h> //for access, unlink
gdcm::DocEntry *d = original->GetFile()->GetFirstEntry();
while(d)
{
- if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+ if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
{
- copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
- b->GetGroup(),b->GetElement(),
- b->GetVR() );
- }
- else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
- {
- copy->GetFile()->InsertValEntry( v->GetValue(),
- v->GetGroup(),v->GetElement(),
- v->GetVR() );
+ copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+ de->GetGroup(),de->GetElement(),
+ de->GetVR() );
}
else
{
Program: gdcm
Module: $RCSfile: Volume2Dicom.cxx,v $
Language: C++
- Date: $Date: 2005/09/07 08:35:20 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmFile.h"
#include "gdcmDocEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmFileHelper.h"
#include "gdcmUtil.h"
Program: gdcm
Module: $RCSfile: WriteDicomSimple.cxx,v $
Language: C++
- Date: $Date: 2005/07/08 12:02:02 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ Version: $Revision: 1.14 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Set the image size
str.str("");
str << SIZE_X;
- header->InsertValEntry(str.str(),0x0028,0x0011); // Columns
+ header->InsertEntryString(str.str(),0x0028,0x0011); // Columns
str.str("");
str << SIZE_Y;
- header->InsertValEntry(str.str(),0x0028,0x0010); // Rows
+ header->InsertEntryString(str.str(),0x0028,0x0010); // Rows
// Set the pixel type
str.str("");
str << COMPONENT_SIZE * 8;
- header->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
- header->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
+ header->InsertEntryString(str.str(),0x0028,0x0100); // Bits Allocated
+ header->InsertEntryString(str.str(),0x0028,0x0101); // Bits Stored
str.str("");
str << ( COMPONENT_SIZE * 8 ) - 1;
- header->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
+ header->InsertEntryString(str.str(),0x0028,0x0102); // High Bit
// Set the pixel representation
str.str("");
str << "0"; // Unsigned
- header->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
+ header->InsertEntryString(str.str(),0x0028,0x0103); // Pixel Representation
// Set the samples per pixel
str.str("");
str << COMPONENT;
- header->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
+ header->InsertEntryString(str.str(),0x0028,0x0002); // Samples per Pixel
// Set the Window / Level
str.str("");
str << COLOR_WINDOW;
- header->InsertValEntry(str.str(),0x0028,0x1051); // Window Width
+ header->InsertEntryString(str.str(),0x0028,0x1051); // Window Width
str.str("");
str << COLOR_LEVEL;
- header->InsertValEntry(str.str(),0x0028,0x1050); // Window Center
+ header->InsertEntryString(str.str(),0x0028,0x1050); // Window Center
if( !header->IsReadable() )
{
Program: gdcm
Module: $RCSfile: exColorToRGB.cxx,v $
Language: C++
- Date: $Date: 2005/09/06 11:10:03 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ 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
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
#include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmSeqEntry.h"
#include <stdlib.h> // for exit
&& !( d->GetGroup()%2 ) )
{
- if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+ if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
{
- copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
- b->GetGroup(),b->GetElement(),
- b->GetVR() );
- }
- else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
- {
- copy->GetFile()->InsertValEntry( v->GetValue(),
- v->GetGroup(),v->GetElement(),
- v->GetVR() );
+ copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+ de->GetGroup(),de->GetElement(),
+ de->GetVR() );
}
else
{
Program: gdcm
Module: $RCSfile: exCurveData.cxx,v $
Language: C++
- Date: $Date: 2005/10/16 17:07:05 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2005/10/18 08:35:43 $
+ 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
#include "gdcmCommon.h"
#include "gdcmDebug.h"
#include "gdcmDocEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
static const char* TypeOfDataArrays[13][2] = {
{ "TAC" , "time activity curve" },
// ============================================================
//* B 5004|3000 [OW] [Curve Data] [gdcm::Binary data loaded;length = 1938]
- std::string curve_data_str = f->GetEntryValue(0x5004, 0x3000);
+ std::string curve_data_str = f->GetEntryString(0x5004, 0x3000);
if (curve_data_str == gdcm::GDCM_UNFOUND)
{
std::cout << " Image doesn't contain any Curve Data" << std::endl;
// ============================================================
std::istringstream convert;
//* V 5004|0005 [US] [Curve Dimensions] [1] x(1)
- std::string curve_dim_str = f->GetEntryValue(0x5004,0x0005);
+ std::string curve_dim_str = f->GetEntryString(0x5004,0x0005);
unsigned short curve_dim;
convert.str(curve_dim_str);
convert >> curve_dim;
std::cout << "Curve Dimensions: " << curve_dim << std::endl;
//* V 5004|0010 [US] [Number of Points] [969] x(3c9)
- std::string num_points_str = f->GetEntryValue(0x5004,0x0010);
+ std::string num_points_str = f->GetEntryString(0x5004,0x0010);
unsigned short num_points;
convert.clear(); //important
convert.str(num_points_str);
convert >> num_points;
std::cout << "Number of Points: " << num_points << std::endl;
//* V 5004|0020 [CS] [Type of Data] [PHYSIO]
- std::string data_type = f->GetEntryValue(0x5004,0x0020);
+ std::string data_type = f->GetEntryString(0x5004,0x0020);
std::cout << "Type of Data: " << data_type << std::endl;
std::cout << " this is thus a : " << ConvertTypeOfData(data_type) << std::endl;
//* V 5004|0022 [LO] [Curve Description] []
- std::string curve_desc = f->GetEntryValue(0x5004,0x0022);
+ std::string curve_desc = f->GetEntryString(0x5004,0x0022);
std::cout << "Curve Description: " << curve_desc << std::endl;
//* V 5004|0103 [US] [Data Value Representation] [0] x(0)
- std::string data_rep_str = f->GetEntryValue(0x5004,0x0103);
+ std::string data_rep_str = f->GetEntryString(0x5004,0x0103);
unsigned short data_rep;
convert.clear(); //important
convert.str(data_rep_str);
gdcm::DocEntry *pCurveDataDoc = f->GetDocEntry(0x5004, 0x3000);
- gdcm::BinEntry *pCurveData = dynamic_cast<gdcm::BinEntry*>(pCurveDataDoc);
+ gdcm::DataEntry *pCurveData = dynamic_cast<gdcm::DataEntry *>(pCurveDataDoc);
uint8_t *curve_data = pCurveData->GetBinArea();
// From Part3, C.10.2.1.2 Data value representation (p668)
size_t sz;
switch( data_rep)
- {
- case 0:
- sz = PrintCurveData((unsigned short*)(curve_data), num_points);
- break;
- case 1:
- sz = PrintCurveData((signed short*)(curve_data), num_points);
- break;
- case 2:
- sz = PrintCurveData((float*)(curve_data), num_points);
- break;
- case 3:
- sz = PrintCurveData((double*)(curve_data), num_points);
- break;
- case 4:
- sz = PrintCurveData((signed long*)(curve_data), num_points);
- break;
- default:
- std::cerr << "Error don't know the type: " << data_rep_str << std::endl;
- delete f;
- return 1;
- }
+ {
+ case 0:
+ sz = PrintCurveData((unsigned short*)(curve_data), num_points);
+ break;
+ case 1:
+ sz = PrintCurveData((signed short*)(curve_data), num_points);
+ break;
+ case 2:
+ sz = PrintCurveData((float*)(curve_data), num_points);
+ break;
+ case 3:
+ sz = PrintCurveData((double*)(curve_data), num_points);
+ break;
+ case 4:
+ sz = PrintCurveData((signed long*)(curve_data), num_points);
+ break;
+ default:
+ std::cerr << "Error don't know the type: " << data_rep_str << std::endl;
+ delete f;
+ return 1;
+ }
// Just to make sure that values read are consistant and we won't read out of bound data:
assert( sz*num_points == pCurveData->GetLength());
Program: gdcm
Module: $RCSfile: exExtractDicomTags.cxx,v $
Language: C++
- Date: $Date: 2005/09/29 08:49:27 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2005/10/18 08:35:44 $
+ 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
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
#include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
#include "gdcmDebug.h"
// Modality, Transfer Syntax, Study Date, Study Time
// Patient Name, Media Storage SOP Instance UID, etc
- MediaStSOPinstUID = f->GetEntryValue(0x0002,0x0002);
- TransferSyntax = f->GetEntryValue(0x0002,0x0010);
- StudyDate = f->GetEntryValue(0x0008,0x0020);
- StudyTime = f->GetEntryValue(0x0008,0x0030);
- PatientName = f->GetEntryValue(0x0010,0x0010);
- PatientID = f->GetEntryValue(0x0010,0x0020); //patientid
- PatientSex = f->GetEntryValue(0x0010,0x0040); //sexe
- SOPInstanceUID = f->GetEntryValue(0x0008,0x0018); //imageid = SOPinsUID
- StudyInstanceUID = f->GetEntryValue(0x0020,0x000d); //STUInsUID [Study Instance UID] [1.2.840.113680.1.103.56887.1017329008.714317]
- SeriesInstanceUID = f->GetEntryValue(0x0020,0x000e); //SerInsUID
- AcquistionDate = f->GetEntryValue(0x0008,0x0022);
- AcquisitionTime = f->GetEntryValue(0x0008,0x0032);
- AcquisitionDateTime = f->GetEntryValue(0x0008,0x002a);
-
-
- Modality = f->GetEntryValue(0x0008,0x0060); //modality
- InstitutionName = f->GetEntryValue(0x0008,0x0080); //hospital
+ MediaStSOPinstUID = f->GetEntryString(0x0002,0x0002);
+ TransferSyntax = f->GetEntryString(0x0002,0x0010);
+ StudyDate = f->GetEntryString(0x0008,0x0020);
+ StudyTime = f->GetEntryString(0x0008,0x0030);
+ PatientName = f->GetEntryString(0x0010,0x0010);
+ PatientID = f->GetEntryString(0x0010,0x0020); //patientid
+ PatientSex = f->GetEntryString(0x0010,0x0040); //sexe
+ SOPInstanceUID = f->GetEntryString(0x0008,0x0018); //imageid = SOPinsUID
+ StudyInstanceUID = f->GetEntryString(0x0020,0x000d); //STUInsUID [Study Instance UID] [1.2.840.113680.1.103.56887.1017329008.714317]
+ SeriesInstanceUID = f->GetEntryString(0x0020,0x000e); //SerInsUID
+ AcquistionDate = f->GetEntryString(0x0008,0x0022);
+ AcquisitionTime = f->GetEntryString(0x0008,0x0032);
+ AcquisitionDateTime = f->GetEntryString(0x0008,0x002a);
+
+
+ Modality = f->GetEntryString(0x0008,0x0060); //modality
+ InstitutionName = f->GetEntryString(0x0008,0x0080); //hospital
// always empty :-(
InstitutionalDepartmentName
- = f->GetEntryValue(0x0008,0x1040); //departement
+ = f->GetEntryString(0x0008,0x1040); //departement
// Radiologist :
// 0008|0090 [Referring Physician's Name]
// --> I'll have to ask people working on PACS which one they use. JPRx
- ProtocolName = f->GetEntryValue(0x0018,0x1030);
+ ProtocolName = f->GetEntryString(0x0018,0x1030);
// --> Big trouble with nz (mb of planes) and nt (number of 'times')
// --> that belong to LibIDO, not to DICOM.
std::string PixelRepresentation;
std::string PixelType;
- SamplesPerPixel = f->GetEntryValue(0x0028,0x0002); // 3 -> RGB
- Rows = f->GetEntryValue(0x0028,0x0010); //ny
- Columns = f->GetEntryValue(0x0028,0x0011); //nx
- Planes = f->GetEntryValue(0x0028,0x0012); //nz
-
- BitsAllocated = f->GetEntryValue(0x0028,0x0100);
- BitsStored = f->GetEntryValue(0x0028,0x0101);
- HighBit = f->GetEntryValue(0x0028,0x0102);
- PixelRepresentation = f->GetEntryValue(0x0028,0x0103);
+ SamplesPerPixel = f->GetEntryString(0x0028,0x0002); // 3 -> RGB
+ Rows = f->GetEntryString(0x0028,0x0010); //ny
+ Columns = f->GetEntryString(0x0028,0x0011); //nx
+ Planes = f->GetEntryString(0x0028,0x0012); //nz
+
+ BitsAllocated = f->GetEntryString(0x0028,0x0100);
+ BitsStored = f->GetEntryString(0x0028,0x0101);
+ HighBit = f->GetEntryString(0x0028,0x0102);
+ PixelRepresentation = f->GetEntryString(0x0028,0x0103);
PixelType = f->GetPixelType(); //type
/*
Program: gdcm
Module: $RCSfile: exExtractTag.cxx,v $
Language: C++
- Date: $Date: 2005/10/10 21:57:57 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2005/10/18 08:35:44 $
+ 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
#include "gdcmCommon.h"
#include "gdcmDebug.h"
#include "gdcmDocEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#include <iomanip>
gdcm::File *f;
if( argc < 5 )
- {
- std::cerr << "Usage :" << argv[0] << " input.dcm group element outputfile" << std::endl;
- std::cerr << " Ex: " << argv[0] << " /tmp/bla.dcm 0029 2110 /tmp/out.raw" << std::endl;
- return 1;
- }
+ {
+ std::cerr << "Usage :" << argv[0] << " input.dcm group element outputfile" << std::endl;
+ std::cerr << " Ex: " << argv[0] << " /tmp/bla.dcm 0029 2110 /tmp/out.raw" << std::endl;
+ return 1;
+ }
std::string fileName = argv[1];
std::cout << fileName << std::endl;
convert >> std::hex >> elem;
std::cout << "Extracting tag: (0x" << std::hex << std::setw(4) << std::setfill('0')
<< group << ",0x" << std::setw(4) << std::setfill('0') << elem << ")" << std::endl;
- std::string dicom_tag_value = f->GetEntryValue(group, elem);
+ std::string dicom_tag_value = f->GetEntryString(group, elem);
if (dicom_tag_value == gdcm::GDCM_UNFOUND)
{
gdcm::DictEntry *dictEntry = f->GetPubDict()->GetEntry( group, elem);
}
gdcm::DocEntry *dicom_tag_doc = f->GetDocEntry(group, elem);
- gdcm::BinEntry *dicom_tag = dynamic_cast<gdcm::BinEntry*>(dicom_tag_doc);
+ gdcm::DataEntry *dicom_tag = dynamic_cast<gdcm::DataEntry *>(dicom_tag_doc);
if( !dicom_tag )
- {
- std::cerr << "Sorry BinEntry only please" << std::endl; //TODO support ValEntry
- delete f;
- return 1;
- }
+ {
+ std::cerr << "Sorry DataEntry only please" << std::endl;
+ delete f;
+ return 1;
+ }
// Write out the data as a file:
std::ofstream o(argv[4]);
if( !o )
- {
- std::cerr << "Problem opening file: " << argv[4] << std::endl;
- delete f;
- return 1;
- }
+ {
+ std::cerr << "Problem opening file: " << argv[4] << std::endl;
+ delete f;
+ return 1;
+ }
o.write((char*)dicom_tag->GetBinArea(), dicom_tag->GetLength());
o.close();
Program: gdcm
Module: $RCSfile: exGC.cxx,v $
Language: C++
- Date: $Date: 2005/08/30 15:13:06 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2005/10/18 08:35:44 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
#include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmSeqEntry.h"
#include <stdlib.h> // for exit
&& !( d->GetGroup()%2 ) )
{
- if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+ if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
{
- copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
- b->GetGroup(),b->GetElement(),
- b->GetVR() );
- }
- else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
- {
- copy->GetFile()->InsertValEntry( v->GetValue(),
- v->GetGroup(),v->GetElement(),
- v->GetVR() );
+ copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+ de->GetGroup(),de->GetElement(),
+ de->GetVR() );
}
else
{
Program: gdcm
Module: $RCSfile: exGrey2RGB.cxx,v $
Language: C++
- Date: $Date: 2005/07/19 15:19:25 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2005/10/18 08:35:44 $
+ 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
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
#include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmDebug.h"
#ifndef _WIN32
uint8_t *imageDataRGB = new uint8_t[dataSize*3];
- if (fh->GetFile()->GetEntryValue(0x0028,0x0100) == "8" )
+ if (fh->GetFile()->GetEntryString(0x0028,0x0100) == "8" )
{
for (unsigned int i=0;i<dataSize;i++)
{
}
}
// Samples Per Pixel
- fh->GetFile()->InsertValEntry( "3 " ,0x0028,0x0002);
+ fh->GetFile()->InsertEntryString( "3 " ,0x0028,0x0002);
// Photometric Interpretation
- fh->GetFile()->InsertValEntry( "RGB ",0x0028,0x0004 );
+ fh->GetFile()->InsertEntryString( "RGB ",0x0028,0x0004 );
// Planar Configuration
- fh->GetFile()->InsertValEntry( "1 ",0x0028,0x0006 );
+ fh->GetFile()->InsertEntryString( "1 ",0x0028,0x0006 );
// TODO : free existing PixelData first !
Program: gdcm
Module: $RCSfile: exImageLighten.cxx,v $
Language: C++
- Date: $Date: 2005/09/08 14:33:50 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2005/10/18 08:35:44 $
+ 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
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
#include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmSeqEntry.h"
#include <stdlib.h> // for exit
&& !( d->GetGroup()%2 ) )
{
- if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+ if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
{
- copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
- b->GetGroup(),b->GetElement(),
- b->GetVR() );
- }
- else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
- {
- copy->GetFile()->InsertValEntry( v->GetValue(),
- v->GetGroup(),v->GetElement(),
- v->GetVR() );
+ copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+ de->GetGroup(),de->GetElement(),
+ de->GetVR() );
}
else
{
Program: gdcm
Module: $RCSfile: exOverlaysACR.cxx,v $
Language: C++
- Date: $Date: 2005/08/30 15:13:06 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2005/10/18 08:35:44 $
+ 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
delete f;
return 0;
}
- std::string s1 = f->GetEntryValue(0x6000, 0x0102);
+ std::string s1 = f->GetEntryString(0x6000, 0x0102);
if (s1 == gdcm::GDCM_UNFOUND)
{
std::cout << " Image doesn't contain any Overlay " << std::endl;
gdcm::FileHelper *fh = 0;
-while ( (strOvlBitPosition = f->GetEntryValue(currentOvlGroup, 0x0102))
+while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102))
!= gdcm::GDCM_UNFOUND )
{
- strOverlayLocation = f->GetEntryValue(currentOvlGroup, 0x0200);
+ strOverlayLocation = f->GetEntryString(currentOvlGroup, 0x0200);
if ( strOverlayLocation != gdcm::GDCM_UNFOUND )
{
overlayLocation = atoi(strOverlayLocation.c_str());
str.str("");
str << nx;
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0011); // Columns
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0011); // Columns
str.str("");
str << ny;
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0010); // Rows
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0010); // Rows
- fileToBuild->InsertValEntry("8",0x0028,0x0100); // Bits Allocated
- fileToBuild->InsertValEntry("8",0x0028,0x0101); // Bits Stored
- fileToBuild->InsertValEntry("7",0x0028,0x0102); // High Bit
- fileToBuild->InsertValEntry("0",0x0028,0x0103); // Pixel Representation
- fileToBuild->InsertValEntry("1",0x0028,0x0002); // Samples per Pixel
+ fileToBuild->InsertEntryString("8",0x0028,0x0100); // Bits Allocated
+ fileToBuild->InsertEntryString("8",0x0028,0x0101); // Bits Stored
+ fileToBuild->InsertEntryString("7",0x0028,0x0102); // High Bit
+ fileToBuild->InsertEntryString("0",0x0028,0x0103); // Pixel Representation
+ fileToBuild->InsertEntryString("1",0x0028,0x0002); // Samples per Pixel
- fileToBuild->InsertValEntry("MONOCHROME2 ",0x0028,0x0004);
+ fileToBuild->InsertEntryString("MONOCHROME2 ",0x0028,0x0004);
// Other mandatory fields will be set automatically,
// just before Write(), by FileHelper::CheckMandatoryElements()
Program: gdcm
Module: $RCSfile: exPrintWritePrint.cxx,v $
Language: C++
- Date: $Date: 2005/08/30 15:13:06 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2005/10/18 08:35:44 $
+ 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
=========================================================================*/
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
-
int main(int argc, char *argv[])
{
Program: gdcm
Module: $RCSfile: exReadPapyrus.cxx,v $
Language: C++
- Date: $Date: 2005/07/07 17:31:54 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2005/10/18 08:35:44 $
+ 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
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
#include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
#include "gdcmDebug.h"
// Modality, Transfer Syntax, Study Date, Study Time
// Patient Name, Media Storage SOP Instance UID, etc
- MediaStSOPinstUID = f->GetEntryValue(0x0002,0x0002);
- TransferSyntax = f->GetEntryValue(0x0002,0x0010);
- StudyDate = sqi->GetEntryValue(0x0008,0x0020);
- StudyTime = sqi->GetEntryValue(0x0008,0x0030);
- Modality = sqi->GetEntryValue(0x0008,0x0060);
- PatientName = sqi->GetEntryValue(0x0010,0x0010);
+ MediaStSOPinstUID = f->GetEntryString(0x0002,0x0002);
+ TransferSyntax = f->GetEntryString(0x0002,0x0010);
+ StudyDate = sqi->GetEntryString(0x0008,0x0020);
+ StudyTime = sqi->GetEntryString(0x0008,0x0030);
+ Modality = sqi->GetEntryString(0x0008,0x0060);
+ PatientName = sqi->GetEntryString(0x0010,0x0010);
std::cout << "TransferSyntax " << TransferSyntax << std::endl;
// we brutally suppose all the images within a Papyrus file
// have the same caracteristics.
- // if you're aware they have not, just move the GetEntryValue
+ // if you're aware they have not, just move the GetEntryString
// inside the loop
// Get caracteristics of the first image
- SamplesPerPixel = sqi->GetEntryValue(0x0028,0x0002);
- Rows = sqi->GetEntryValue(0x0028,0x0010);
- Columns = sqi->GetEntryValue(0x0028,0x0011);
- BitsAllocated = sqi->GetEntryValue(0x0028,0x0100);
- BitsStored = sqi->GetEntryValue(0x0028,0x0101);
- HighBit = sqi->GetEntryValue(0x0028,0x0102);
- PixelRepresentation = sqi->GetEntryValue(0x0028,0x0103);
+ SamplesPerPixel = sqi->GetEntryString(0x0028,0x0002);
+ Rows = sqi->GetEntryString(0x0028,0x0010);
+ Columns = sqi->GetEntryString(0x0028,0x0011);
+ BitsAllocated = sqi->GetEntryString(0x0028,0x0100);
+ BitsStored = sqi->GetEntryString(0x0028,0x0101);
+ HighBit = sqi->GetEntryString(0x0028,0x0102);
+ PixelRepresentation = sqi->GetEntryString(0x0028,0x0103);
// just convert those needed to compute PixelArea length
int iRows = (uint32_t) atoi( Rows.c_str() );
// allocate enough room to get the pixels of all images.
uint8_t *PixelArea = new uint8_t[lgrImage*nbImages];
uint8_t *currentPosition = PixelArea;
- gdcm::BinEntry *pixels;
+ gdcm::DataEntry *pixels;
// declare and open the file
std::ifstream *Fp;
while (sqi)
{
std::cout << "One more image read. Keep waiting" << std::endl;
- Rows = sqi->GetEntryValue(0x0028,0x0010);
+ Rows = sqi->GetEntryString(0x0028,0x0010);
// minimum integrity check
if (Rows != previousRows)
{
return 1;
}
// get the images pixels
- pixels = sqi->GetBinEntry(0x7fe0,0x0010);
+ pixels = sqi->GetDataEntry(0x7fe0,0x0010);
offset = pixels->GetOffset();
// perform a fseek, on offset length on the 'right' length
Fp->seekg(offset, std::ios::beg);
gdcm::File *n = new gdcm::File();
- n->InsertValEntry(MediaStSOPinstUID, 0x0002,0x0002);
+ n->InsertEntryString(MediaStSOPinstUID, 0x0002,0x0002);
// Whe keep default gdcm Transfer Syntax (Explicit VR Little Endian)
// since using Papyrus one (Implicit VR Little Endian) is a mess
- //n->InsertValEntry(TransferSyntax, 0x0002,0x0010);
- n->InsertValEntry(StudyDate, 0x0008,0x0020);
- n->InsertValEntry(StudyTime, 0x0008,0x0030);
- n->InsertValEntry(Modality, 0x0008,0x0060);
- n->InsertValEntry(PatientName, 0x0010,0x0010);
-
- n->InsertValEntry(SamplesPerPixel, 0x0028,0x0002);
- n->InsertValEntry(NumberOfFrames, 0x0028,0x0008);
- n->InsertValEntry(Rows, 0x0028,0x0010);
- n->InsertValEntry(Columns, 0x0028,0x0011);
- n->InsertValEntry(BitsAllocated, 0x0028,0x0100);
- n->InsertValEntry(BitsStored, 0x0028,0x0101);
- n->InsertValEntry(HighBit, 0x0028,0x0102);
- n->InsertValEntry(PixelRepresentation,0x0028,0x0103);
+ //n->InsertEntryString(TransferSyntax, 0x0002,0x0010);
+ n->InsertEntryString(StudyDate, 0x0008,0x0020);
+ n->InsertEntryString(StudyTime, 0x0008,0x0030);
+ n->InsertEntryString(Modality, 0x0008,0x0060);
+ n->InsertEntryString(PatientName, 0x0010,0x0010);
+
+ n->InsertEntryString(SamplesPerPixel, 0x0028,0x0002);
+ n->InsertEntryString(NumberOfFrames, 0x0028,0x0008);
+ n->InsertEntryString(Rows, 0x0028,0x0010);
+ n->InsertEntryString(Columns, 0x0028,0x0011);
+ n->InsertEntryString(BitsAllocated, 0x0028,0x0100);
+ n->InsertEntryString(BitsStored, 0x0028,0x0101);
+ n->InsertEntryString(HighBit, 0x0028,0x0102);
+ n->InsertEntryString(PixelRepresentation,0x0028,0x0103);
// create the file
gdcm::FileHelper *file = new gdcm::FileHelper(n);
Program: gdcm
Module: $RCSfile: exReadWriteFile.cxx,v $
Language: C++
- Date: $Date: 2005/07/19 15:19:25 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2005/10/18 08:35:44 $
+ 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
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
#include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmSeqEntry.h"
#include <stdlib.h> // for exit
<< "--- Display only human readable values -----------------------"
<< std::endl;
- gdcm::ValEntry *valEntry;
+ gdcm::DataEntry *dataEntry;
std::string value;
std::string vr; // value representation
std::string vm; // value multiplicity
// We skip SeqEntries, since user cannot do much with them
if ( !(dynamic_cast<gdcm::SeqEntry*>(d))
// We skip Shadow Groups, since nobody knows what they mean
- && !( d->GetGroup()%2 )
- // we skip BinEntries, since their content is not human-readable
- && !dynamic_cast<gdcm::BinEntry*>(d) )
+ && !( d->GetGroup()%2 ) )
{
// If user just 'wants to see'
//d->Print();
//std::cout << std::endl;
// If user wants to get info about the entry
- // (he is sure, here that DocEntry is a ValEntry)
- valEntry = dynamic_cast<gdcm::ValEntry*>(d);
+ // (he is sure, here that DocEntry is a DataEntry)
+ dataEntry = dynamic_cast<gdcm::DataEntry *>(d);
// Let's be carefull -maybe he commented out some previous line-
- if (!valEntry)
+ if (!dataEntry)
continue;
- value = valEntry->GetValue();
- vr = valEntry->GetVR();
+ value = dataEntry->GetString();
+ vr = dataEntry->GetVR();
// user wants really to know everything about entry!
- vm = valEntry->GetVM();
- name = valEntry->GetName();
+ vm = dataEntry->GetVM();
+ name = dataEntry->GetName();
std::cout //<< std::hex << group << "," << elem
- << valEntry->GetKey()
- << " VR :[" << vr << "] VM : [" << vm
+ << dataEntry->GetKey()
+ << " VR :[" << vr << "] VM : [" << vm
<< "] name : [" << name << "]"
<< " value : [" << value << "]"
-
- << std::endl;
+ << std::endl;
}
d = f1->GetNextEntry();
}
<< std::endl;
// ------ User is aware, and wants to get fields with no accesor --------
- std::cout << "Manufacturer :[" << f1->GetEntryValue(0x0008,0x0070)
+ std::cout << "Manufacturer :[" << f1->GetEntryString(0x0008,0x0070)
<< "]" << std::endl;
- std::cout << "Institution :[" << f1->GetEntryValue(0x0008,0x0080)
+ std::cout << "Institution :[" << f1->GetEntryString(0x0008,0x0080)
<< "]" << std::endl;
- std::cout << "Patient's name :[" << f1->GetEntryValue(0x0010,0x0010)
+ std::cout << "Patient's name :[" << f1->GetEntryString(0x0010,0x0010)
<< "]" << std::endl;
- std::cout << "Physician's name :[" << f1->GetEntryValue(0x0008,0x0090)
+ std::cout << "Physician's name :[" << f1->GetEntryString(0x0008,0x0090)
<< "]" << std::endl;
- std::cout << "Study Date :[" << f1->GetEntryValue(0x0008,0x0020)
+ std::cout << "Study Date :[" << f1->GetEntryString(0x0008,0x0020)
<< "]" << std::endl;
- std::cout << "Study inst UID :[" << f1->GetEntryValue(0x0020,0x000d)
+ std::cout << "Study inst UID :[" << f1->GetEntryString(0x0020,0x000d)
<< "]" << std::endl;
- std::cout << "Serie inst UID :[" << f1->GetEntryValue(0x0020,0x000e)
+ std::cout << "Serie inst UID :[" << f1->GetEntryString(0x0020,0x000e)
<< "]" << std::endl;
- std::cout << "Frame ref UID :[" << f1->GetEntryValue(0x0020,0x0052)
+ std::cout << "Frame ref UID :[" << f1->GetEntryString(0x0020,0x0052)
<< "]" << std::endl;
// User wants to get info about the 'real world' vs image
&& !( d->GetGroup()%2 ) )
{
- if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+ if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
{
- copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
- b->GetGroup(),b->GetElement(),
- b->GetVR() );
- }
- else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
- {
- copy->GetFile()->InsertValEntry( v->GetValue(),
- v->GetGroup(),v->GetElement(),
- v->GetVR() );
+ copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+ de->GetGroup(),de->GetElement(),
+ de->GetVR() );
}
else
{
TestVR.cxx
TestDictGroupName.cxx
TestDict.cxx
+ TestDataEntry.cxx
TestWriteSimple.cxx
TestImageSet.cxx
TestDicomDirElement.cxx
"MR_Philips_Intera_No_PrivateSequenceImplicitVR.dcm"
"MR_Philips_Intera_PrivateSequenceImplicitVR.dcm"
"MR_SIEMENS_forceLoad29-1010_29-1020.dcm"
+ # An element contains a value of 4, but no data follows
+ # So, the next (group, elem) is not correctly read
+ "gdcm-MR-PHILIPS-16-Multi-Seq.dcm"
)
# Create a specific list of dicom files that we know are part of a sequence
Program: gdcm
Module: $RCSfile: TestAllEntryVerify.cxx,v $
Language: C++
- Date: $Date: 2005/07/11 14:47:19 $
- Version: $Revision: 1.28 $
+ Date: $Date: 2005/10/18 08:35:45 $
+ Version: $Revision: 1.29 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include <iostream>
#include <sstream>
-typedef std::string EntryValueType; // same type as ValEntry::value
+typedef std::string EntryValueType; // same type as DataEntry::value
typedef std::map< gdcm::TagKey, EntryValueType > MapEntryValues;
typedef MapEntryValues *MapEntryValuesPtr;
typedef std::string FileNameType;
Program: gdcm
Module: $RCSfile: TestAllPrint.cxx,v $
Language: C++
- Date: $Date: 2005/08/30 15:13:07 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
#include "gdcmFileHelper.h"
#include "gdcmUtil.h"
#include "gdcmCommon.h"
-#include "gdcmBinEntry.h"
#include "gdcmDocEntry.h"
#include "gdcmDocEntrySet.h"
#include "gdcmDocument.h"
#include "gdcmElementSet.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
#include <iostream>
Program: gdcm
Module: $RCSfile: TestAllReadCompareDicom.cxx,v $
Language: C++
- Date: $Date: 2005/08/30 15:13:07 $
- Version: $Revision: 1.47 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
<< " Scalar size: " << tested->GetFile()->GetPixelSize() << " # "
<< reference->GetScalarSize() << std::endl
<< " Number of scalar: " << tested->GetFile()->GetNumberOfScalarComponents() << " # "
- << reference->GetNumberOfComponents() << std::endl;
+ << reference->GetNumberOfComponents() << std::endl
+ << " Pixel type: " << tested->GetFile()->GetPixelType() << std::endl;
delete reference;
delete tested;
delete f;
+ return 1;
}
// Test the data size
Program: gdcm
Module: $RCSfile: TestAnonymize.cxx,v $
Language: C++
- Date: $Date: 2005/07/08 13:39:56 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
=========================================================================*/
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmGlobal.h"
#include "gdcmDebug.h"
Program: gdcm
Module: $RCSfile: TestBuildUpDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/08/31 09:29:11 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
// Create patient ONE
// ------------------
p1 = dcmdir->NewPatient();
- p1->SetValEntry("patientONE",0x0010, 0x0010);
+ p1->SetEntryString("patientONE",0x0010, 0x0010);
// fill here other patient characteristics
gdcm::DicomDirStudy *s11;
// Let's create and add a Study for this Patient
s11 = p1->NewStudy();
- s11->SetValEntry("StudyDescrOne.One_",0x0008, 0x1030);
+ s11->SetEntryString("StudyDescrOne.One_",0x0008, 0x1030);
// we know entry (0008,1060) is not yet created
- s11->InsertValEntry("Dr Mabuse", 0x0008, 0x1060);
+ s11->InsertEntryString("Dr Mabuse", 0x0008, 0x1060);
// fill here other Study characteristics
gdcm::DicomDirStudy *s12 = p1->NewStudy();
- s12->SetValEntry("StudyDescrOne.Two",0x0008, 0x1030);
- s12->InsertValEntry("Dr Zorglub", 0x0008, 0x1060);
+ s12->SetEntryString("StudyDescrOne.Two",0x0008, 0x1030);
+ s12->InsertEntryString("Dr Zorglub", 0x0008, 0x1060);
// fill here other Study characteristics
gdcm::DicomDirStudy *s13 = p1->NewStudy();
- s13->SetValEntry("StudyDescrOne.Tree",0x0008, 0x1030);
- s13->InsertValEntry("Dr Follamour", 0x0008, 0x1060);
+ s13->SetEntryString("StudyDescrOne.Tree",0x0008, 0x1030);
+ s13->InsertEntryString("Dr Follamour", 0x0008, 0x1060);
// fill here other Study characteristics
gdcm::DicomDirSerie *s111;
// Let's create and add a Serie for this Study
s111 = s11->NewSerie();
- s111->SetValEntry("01-01-111", 0x0008, 0x0021);
+ s111->SetEntryString("01-01-111", 0x0008, 0x0021);
// fill here other Serie characteristics
gdcm::DicomDirImage *s1111;
// Let's create and add a Image for this Serie
s1111 = s111->NewImage();
- s1111->SetValEntry("imageFileName1111",0x0004,0x1500);
+ s1111->SetEntryString("imageFileName1111",0x0004,0x1500);
gdcm::DicomDirImage *s1112 = s111->NewImage();
- s1112->SetValEntry("imageFileName1112",0x0004,0x1500);
+ s1112->SetEntryString("imageFileName1112",0x0004,0x1500);
// Create patient TWO
// ------------------
gdcm::DicomDirPatient *p2 = dcmdir->NewPatient();
- p2->SetValEntry("patientTWO",0x0010, 0x0010);
+ p2->SetEntryString("patientTWO",0x0010, 0x0010);
// fill here other patient characteristics
gdcm::DicomDirStudy *s21 = p2->NewStudy();
- s21->SetValEntry("StudyDescrTwo.One",0x0008, 0x1030);
+ s21->SetEntryString("StudyDescrTwo.One",0x0008, 0x1030);
// fill here other Study characteristics
gdcm::DicomDirSerie *s211 = s21->NewSerie();
- s111->SetValEntry("01-01-211", 0x0008, 0x0021);
+ s111->SetEntryString("01-01-211", 0x0008, 0x0021);
// fill here other Serie characteristics
gdcm::DicomDirImage *s2111 = s211->NewImage();
- s2111->SetValEntry("imageFileName2111",0x0004,0x1500);
+ s2111->SetEntryString("imageFileName2111",0x0004,0x1500);
// fill here other Image characteristics
gdcm::DicomDirImage *s2112 = s211->NewImage();
- s2112->SetValEntry("imageFileName1122",0x0004,0x1500);
+ s2112->SetEntryString("imageFileName1122",0x0004,0x1500);
// fill here other Image characteristics
// Create patient TREE
// -------------------
gdcm::DicomDirPatient *p3 = dcmdir->NewPatient();
- p3->SetValEntry("patientTHREE",0x0010, 0x0010);
+ p3->SetEntryString("patientTHREE",0x0010, 0x0010);
// fill here other Patient characteristics
// Add a new Serie/Image for a Patient's Study created a long time ago
// -------------------------------------------------------------------
gdcm::DicomDirSerie *s131 = s13->NewSerie();
- s111->SetValEntry("01-01-131", 0x0008, 0x0021);
+ s111->SetEntryString("01-01-131", 0x0008, 0x0021);
// fill here other Serie characteristics
gdcm::DicomDirImage *s1311 = s131->NewImage();
- s1311->SetValEntry("imageFileName1311",0x0004,0x1500);
+ s1311->SetEntryString("imageFileName1311",0x0004,0x1500);
// fill here other Image characteristics
// Print
std::string valueStuff;
for (;;) // exit on 'break'
{
- if ( p1->GetEntryValue(0x0010, 0x0010) != "patientONE" )
+ if ( p1->GetEntryString(0x0010, 0x0010) != "patientONE" )
{
std::cout << "0x0010,0x0010 ["
- << p1->GetEntryValue(0x0010, 0x0010)
+ << p1->GetEntryString(0x0010, 0x0010)
<< "]" << std::endl;
errorFound = true;
break;
}
std::cout << "Patient : ["
- << p1->GetEntryValue(0x0010, 0x0010)
+ << p1->GetEntryString(0x0010, 0x0010)
<< "]" << std::endl;
if ( !(s11 = p1->GetFirstStudy()) )
errorFound = true;
break;
}
- valueStuff = s11->GetEntryValue(0x0008, 0x1030);
+ valueStuff = s11->GetEntryString(0x0008, 0x1030);
if ( valueStuff.find("StudyDescrOne.One_") >= valueStuff.length() )
{
std::cout << "1 : 0x0008,0x1030 ["
<< valueStuff
<< "]" << std::endl;
- valueStuff = s11->GetEntryValue(0x0008, 0x1060);
+ valueStuff = s11->GetEntryString(0x0008, 0x1060);
if (!gdcm::Util::DicomStringEqual(valueStuff, "Dr Mabuse") )
{
std::cout << "2 : 0x0008,0x1060 ["
- << s11->GetEntryValue(0x0008,0x1060)
+ << s11->GetEntryString(0x0008,0x1060)
<< "]" << std::endl;
errorFound = true;
break;
errorFound = true;
break;
}
- if ( gdcm::Util::DicomStringEqual(s12->GetEntryValue(0x0008,
+ if ( gdcm::Util::DicomStringEqual(s12->GetEntryString(0x0008,
0x1030),"StudyDescrOne.Two " ))
{
std::cout << "3 0x0008,0x1030 ["
- << s12->GetEntryValue(0x0008,0x1030)
+ << s12->GetEntryString(0x0008,0x1030)
<< "]" << std::endl;
errorFound = true;
break;
}
std::cout << "Study Descr : ["
- << s12->GetEntryValue(0x0008,0x1030)
+ << s12->GetEntryString(0x0008,0x1030)
<< "]" << std::endl;
- if ( gdcm::Util::DicomStringEqual(s12->GetEntryValue(0x0008,
+ if ( gdcm::Util::DicomStringEqual(s12->GetEntryString(0x0008,
0x1060),"Dr Zorglub " ))
{
std::cout << "4 0x0008,0x1060 ["
- << s12->GetEntryValue(0x0008,0x1060)
+ << s12->GetEntryString(0x0008,0x1060)
<< "]" << std::endl;
errorFound = true;
break;
}
std::cout << "Pysician : ["
- << s12->GetEntryValue(0x0008,0x1060)
+ << s12->GetEntryString(0x0008,0x1060)
<< "]" << std::endl;
if ( (s13 = p1->GetNextStudy()) == 0 )
std::cout << "Study StudyDescrOne.Tree missing" << std::endl;
break;
}
- if ( s13->GetEntryValue(0x0008, 0x1030) != "StudyDescrOne.Tree" )
+ if ( s13->GetEntryString(0x0008, 0x1030) != "StudyDescrOne.Tree" )
{
errorFound = true;
break;
<< valueStuff
<< "]" << std::endl;
- valueStuff = s13->GetEntryValue(0x0008, 0x1060);
+ valueStuff = s13->GetEntryString(0x0008, 0x1060);
if (!gdcm::Util::DicomStringEqual(valueStuff, "Dr Follamour") )
{
std::cout << "5 0x0008,0x1060 ["
break;
}
- valueStuff = s111->GetEntryValue(0x0008, 0x0021);
+ valueStuff = s111->GetEntryString(0x0008, 0x0021);
if (!gdcm::Util::DicomStringEqual(valueStuff, "01-01-131") )
{
std::cout << "6 0x0008,0x0021 ["
break;
}
/*
- if ( s1111->GetEntryValue(0x0004,0x1500) != "imageFileName1111 " )
+ if ( s1111->GetEntryString(0x0004,0x1500) != "imageFileName1111 " )
{
errorFound = true;
break;
break;
}
/*
- if ( s1112->GetEntryValue(0x0004,0x1500) != "imageFileName1112 " )
+ if ( s1112->GetEntryString(0x0004,0x1500) != "imageFileName1112 " )
{
errorFound = true;
break;
Program: gdcm
Module: $RCSfile: TestCopyDicom.cxx,v $
Language: C++
- Date: $Date: 2005/07/08 13:39:57 $
- Version: $Revision: 1.41 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
=========================================================================*/
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
//Generated file:
#include "gdcmDataImages.h"
gdcm::DocEntry *d=originalH->GetFirstEntry();
while(d)
{
- if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
- {
- copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(),
- b->GetGroup(),b->GetElement(),
- b->GetVR() );
- }
- else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
- {
- copyH->InsertValEntry( v->GetValue(),
- v->GetGroup(),v->GetElement(),
- v->GetVR() );
+ if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
+ {
+ copyH->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+ de->GetGroup(),de->GetElement(),
+ de->GetVR() );
}
else
{
uint8_t *imageData = original->GetImageData();
// Useless to set the image data, because it's already made when
- // copying the corresponding BinEntry that contains the pixel data
+ // copying the corresponding DataEntry that contains the pixel data
copy->SetImageData(imageData, dataSize);
//////////////// Step 3:
Program: gdcm
Module: $RCSfile: TestCopyRescaleDicom.cxx,v $
Language: C++
- Date: $Date: 2005/07/08 13:39:57 $
- Version: $Revision: 1.20 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
=========================================================================*/
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#include <time.h>
#include <sys/times.h>
gdcm::DocEntry *d = originalF.GetFirstEntry();
while(d)
{
- if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
- {
- copyF.InsertBinEntry( b->GetBinArea(),b->GetLength(),
- b->GetGroup(),b->GetElement(),
- b->GetVR() );
- }
- else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
- {
- copyF.InsertValEntry( v->GetValue(),
- v->GetGroup(),v->GetElement(),
- v->GetVR() );
+ if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
+ {
+ copyF.InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+ de->GetGroup(),de->GetElement(),
+ de->GetVR() );
}
else
{
if( bitsStored == "16" )
{
std::cout << "Rescale...";
- copyF.InsertValEntry( "8", 0x0028, 0x0100); // Bits Allocated
- copyF.InsertValEntry( "8", 0x0028, 0x0101); // Bits Stored
- copyF.InsertValEntry( "7", 0x0028, 0x0102); // High Bit
- copyF.InsertValEntry( "0", 0x0028, 0x0103); // Pixel Representation
+ copyF.InsertEntryString( "8", 0x0028, 0x0100); // Bits Allocated
+ copyF.InsertEntryString( "8", 0x0028, 0x0101); // Bits Stored
+ copyF.InsertEntryString( "7", 0x0028, 0x0102); // High Bit
+ copyF.InsertEntryString( "0", 0x0028, 0x0103); // Pixel Representation
// We assume the value were from 0 to uint16_t max
rescaleSize = dataSize / 2;
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: TestDataEntry.cxx,v $
+ Language: C++
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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.
+
+=========================================================================*/
+#include "gdcmDictEntry.h"
+#include "gdcmDataEntry.h"
+
+// ===============================================================
+
+char data[]="1\\2\\3\\4\\5";
+char fdata[]="1.1\\2.2\\3.3\\4.4\\5.5";
+
+short svalue[]={1,2,3,4,5};
+long lvalue[]={1,2,3,4,5};
+float fvalue[]={1.1f,2.2f,3.3f,4.4f,5.5f};
+double dvalue[]={1.1,2.2,3.3,4.4,5.5};
+
+unsigned long nbvalue = 5;
+
+/**
+ * \brief Test the DataEntry object
+ */
+int TestDataEntry(int argc, char *argv[])
+{
+ unsigned int error = 0;
+ gdcm::DictEntry *dict;
+ gdcm::DataEntry *entry;
+
+ //------------------------------------------------------------------
+ dict = new gdcm::DictEntry(0x0000,0x0000);
+ entry = new gdcm::DataEntry(dict);
+ dict->SetVR("US");
+
+ std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+
+ entry->SetString("1");
+ std::cout << "1: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+ if( entry->GetValueCount() != 1 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+
+ entry->SetString("1\\2");
+ std::cout << "2: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+ if( entry->GetValueCount() != 2 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+
+ entry->SetString("");
+ std::cout << "3: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+ if( entry->GetValueCount() != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+
+ std::cout << std::endl;
+ delete dict;
+ delete entry;
+
+ //------------------------------------------------------------------
+ dict = new gdcm::DictEntry(0x0000,0x0000);
+ entry = new gdcm::DataEntry(dict);
+ dict->SetVR("LT");
+
+ std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+ entry->SetString(data);
+ entry->Print(std::cout);
+ std::cout << std::endl;
+
+ if( entry->GetLength() != strlen(data) + strlen(data)%2 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Size of string is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( entry->GetValueCount() != nbvalue )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( memcmp(entry->GetBinArea(),data,entry->GetLength()) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of bin area is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( memcmp(entry->GetString().c_str(),data,entry->GetLength()) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of string is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ for(unsigned int i=0;i<entry->GetValueCount();i++)
+ {
+ if( entry->GetValue(i) != svalue[i] )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of entry's values is incorrect : id " << i << std::endl
+ << " Found " << entry->GetValue(i) << " - Must be " << svalue[i] << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ }
+
+ std::cout << std::endl;
+ delete dict;
+ delete entry;
+
+ //------------------------------------------------------------------
+ dict = new gdcm::DictEntry(0x0000,0x0000);
+ entry = new gdcm::DataEntry(dict);
+ dict->SetVR("US");
+
+ std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+ entry->SetString(data);
+ std::cout << "1: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+
+ if( entry->GetLength() != nbvalue*sizeof(uint16_t) )
+ {
+ std::cout << " Failed" << std::endl
+ << " BinArea length is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of string is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( entry->GetValueCount() != nbvalue )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ for(unsigned int i=0;i<entry->GetValueCount();i++)
+ {
+ if( entry->GetValue(i) != svalue[i] )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of entry's values is incorrect : id " << i << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ }
+
+ entry->SetLength(nbvalue*sizeof(uint16_t));
+ entry->SetBinArea((uint8_t *)svalue,false);
+ std::cout << "2: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+
+ if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of string is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( entry->GetValueCount() != nbvalue )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ for(unsigned int i=0;i<entry->GetValueCount();i++)
+ {
+ if( entry->GetValue(i) != svalue[i] )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of entry's values is incorrect : id " << i << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ }
+
+ std::cout << std::endl;
+ delete dict;
+ delete entry;
+
+ //------------------------------------------------------------------
+ dict = new gdcm::DictEntry(0x0000,0x0000);
+ entry = new gdcm::DataEntry(dict);
+ dict->SetVR("UL");
+
+ std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+ entry->SetString(data);
+ std::cout << "1: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+
+ if( entry->GetLength() != nbvalue*sizeof(uint32_t) )
+ {
+ std::cout << " Failed" << std::endl
+ << " BinArea length is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of string is incorrect" << std::endl;
+ std::cout<<"#"<<entry->GetString()<<"#"<<" / "<<"#"<<data<<"#"<<std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( entry->GetValueCount() != nbvalue )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ for(unsigned int i=0;i<entry->GetValueCount();i++)
+ {
+ if( entry->GetValue(i) != lvalue[i] )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of entry's values is incorrect : id " << i << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ }
+
+ entry->SetLength(nbvalue*sizeof(uint32_t));
+ entry->SetBinArea((uint8_t *)lvalue,false);
+ std::cout << "2: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+
+ if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of string is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( entry->GetValueCount() != nbvalue )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ for(unsigned int i=0;i<entry->GetValueCount();i++)
+ {
+ if( entry->GetValue(i) != lvalue[i] )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of entry's values is incorrect : id " << i << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ }
+
+ std::cout << std::endl;
+ delete dict;
+ delete entry;
+
+ //------------------------------------------------------------------
+ dict = new gdcm::DictEntry(0x0000,0x0000);
+ entry = new gdcm::DataEntry(dict);
+ dict->SetVR("FL");
+
+ std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+ entry->SetString(fdata);
+ std::cout << "1: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+
+ if( entry->GetLength() != nbvalue*sizeof(float) )
+ {
+ std::cout << " Failed" << std::endl
+ << " BinArea length is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of string is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( entry->GetValueCount() != nbvalue )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ for(unsigned int i=0;i<entry->GetValueCount();i++)
+ {
+ if( entry->GetValue(i) != fvalue[i] )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of entry's values is incorrect : id " << i << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ }
+
+ entry->SetLength(nbvalue*sizeof(float));
+ entry->SetBinArea((uint8_t *)fvalue,false);
+ std::cout << "2: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+
+ if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of string is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( entry->GetValueCount() != nbvalue )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ for(unsigned int i=0;i<entry->GetValueCount();i++)
+ {
+ if( entry->GetValue(i) != fvalue[i] )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of entry's values is incorrect : id " << i << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ }
+
+ std::cout << std::endl;
+ delete dict;
+ delete entry;
+
+ //------------------------------------------------------------------
+ dict = new gdcm::DictEntry(0x0000,0x0000);
+ entry = new gdcm::DataEntry(dict);
+ dict->SetVR("FD");
+
+ std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+ entry->SetString(fdata);
+ std::cout << "1: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+
+ if( entry->GetLength() != nbvalue*sizeof(double) )
+ {
+ std::cout << " Failed" << std::endl
+ << " BinArea length is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of string is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( entry->GetValueCount() != nbvalue )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ for(unsigned int i=0;i<entry->GetValueCount();i++)
+ {
+ if( entry->GetValue(i) != dvalue[i] )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of entry's values is incorrect : id " << i << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ }
+
+ entry->SetLength(nbvalue*sizeof(double));
+ entry->SetBinArea((uint8_t *)dvalue,false);
+ std::cout << "2: ";
+ entry->Print(std::cout);
+ std::cout << std::endl;
+
+ if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of string is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ if( entry->GetValueCount() != nbvalue )
+ {
+ std::cout << " Failed" << std::endl
+ << " Number of content values is incorrect" << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ for(unsigned int i=0;i<entry->GetValueCount();i++)
+ {
+ if( entry->GetValue(i) != dvalue[i] )
+ {
+ std::cout << " Failed" << std::endl
+ << " Content of entry's values is incorrect : id " << i << std::endl;
+ delete dict;
+ delete entry;
+ return(1);
+ }
+ }
+
+ std::cout << std::endl;
+ delete dict;
+ delete entry;
+
+ //------------------------------------------------------------------
+ std::cout<<std::flush;
+ return 0;
+}
Program: gdcm
Module: $RCSfile: TestDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/08/31 09:29:11 $
- Version: $Revision: 1.40 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ Version: $Revision: 1.41 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
=========================================================================*/
#include "gdcmDocEntry.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmDicomDir.h"
#include "gdcmDicomDirPatient.h"
#include "gdcmDicomDirStudy.h"
return 1;
}
// skip SeqEntries (I don't want to deal with 'recursion pbs' here)
- if ( !dynamic_cast<gdcm::ValEntry*>(e1) ||
- !dynamic_cast<gdcm::ValEntry*>(e2) )
+ if ( !dynamic_cast<gdcm::DataEntry *>(e1) ||
+ !dynamic_cast<gdcm::DataEntry *>(e2) )
continue;
// a value is read as GDCM_UNFOUND
- if ( ((gdcm::ValEntry*)e1)->GetValue() == gdcm::GDCM_UNFOUND )
+ if ( ((gdcm::DataEntry *)e1)->GetString() == gdcm::GDCM_UNFOUND )
{
std::cout << "for gdcm source DicomDir : element (" << std::hex
<< e1->GetGroup() << "," <<e1->GetElement()
}
// values differ in source file and destination file
- if ( ((gdcm::ValEntry*)e1)->GetValue() !=
- ((gdcm::ValEntry*)e2)->GetValue() )
+ if ( ((gdcm::DataEntry *)e1)->GetString() !=
+ ((gdcm::DataEntry *)e2)->GetString() )
{
// serious trouble : values differ in source and destination file
std::cout << "for gdcm DicomDir element (" << std::hex
<< e2->GetGroup() << "," <<e2->GetElement()
<< ") values differ ["
- << ((gdcm::ValEntry*)e1)->GetValue() << "] != ["
- << ((gdcm::ValEntry*)e2)->GetValue() << "]"
+ << ((gdcm::DataEntry *)e1)->GetString() << "] != ["
+ << ((gdcm::DataEntry *)e2)->GetString() << "]"
<< std::endl;
return 1;
}
pa1 = dicomdir->GetFirstPatient();
while ( pa1 )
{ // we process all the PATIENT of this DICOMDIR
- std::cout << pa1->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name
+ std::cout << pa1->GetEntryString(0x0010, 0x0010) << std::endl; // Patient's Name
st1 = pa1->GetFirstStudy();
while ( st1 )
{ // we process all the STUDY of this patient
- std::cout << "--- "<< st1->GetEntryValue(0x0008, 0x1030) // Study Description
+ std::cout << "--- "<< st1->GetEntryString(0x0008, 0x1030) // Study Description
<< std::endl;
- std::cout << " Stud.ID:[" << st1->GetEntryValue(0x0020, 0x0010) // Study ID
+ std::cout << " Stud.ID:[" << st1->GetEntryString(0x0020, 0x0010) // Study ID
<< "]";
se1 = st1->GetFirstSerie();
while ( se1 )
{ // we process all the SERIES of this study
- std::cout << "--- --- "<< se1->GetEntryValue(0x0008, 0x103e) << std::endl; // Serie Description
- std::cout << " Ser.nb:[" << se1->GetEntryValue(0x0020, 0x0011); // Series number
- std::cout << "] Mod.:[" << se1->GetEntryValue(0x0008, 0x0060) << "]"; // Modality
+ std::cout << "--- --- "<< se1->GetEntryString(0x0008, 0x103e) << std::endl; // Serie Description
+ std::cout << " Ser.nb:[" << se1->GetEntryString(0x0020, 0x0011); // Series number
+ std::cout << "] Mod.:[" << se1->GetEntryString(0x0008, 0x0060) << "]"; // Modality
im1 = se1->GetFirstImage();
while ( im1 ) { // we process all the IMAGE of this serie
- std::cout << "--- --- --- "<< im1->GetEntryValue(0x0004, 0x1500) << std::endl; // File name
+ std::cout << "--- --- --- "<< im1->GetEntryString(0x0004, 0x1500) << std::endl; // File name
im1 = se1->GetNextImage();
}
se1 = st1->GetNextSerie();
}
// just to allow human reader to be sure ...
- std::cout << pa2->GetEntryValue(0x0010, 0x0010)
+ std::cout << pa2->GetEntryString(0x0010, 0x0010)
<< std::endl; // Patient's Name
st1 = pa1->GetFirstStudy();
}
// just to allow human reader to be sure ...
- std::cout << "--- "<< st2->GetEntryValue(0x0008, 0x1030);
+ std::cout << "--- "<< st2->GetEntryString(0x0008, 0x1030);
// << std::endl; // Study Description
std::cout << " Stud.ID:["
- << st2->GetEntryValue(0x0020, 0x0010)
+ << st2->GetEntryString(0x0020, 0x0010)
<< "]" << std::endl; // Study ID
se1 = st1->GetFirstSerie();
{ // we process all the SERIE of this study
if ( CompareSQItem(se2,se1) == 1 )
return 1;
- std::cout << "--- --- " << se2->GetEntryValue(0x0008, 0x103e); // Serie Description
- std::cout << " Ser.nb:["<< se2->GetEntryValue(0x0020, 0x0011); // Series number
- std::cout << "] Mod.:[" << se2->GetEntryValue(0x0008, 0x0060) << "]" << std::endl; // Modality
+ std::cout << "--- --- " << se2->GetEntryString(0x0008, 0x103e); // Serie Description
+ std::cout << " Ser.nb:["<< se2->GetEntryString(0x0020, 0x0011); // Series number
+ std::cout << "] Mod.:[" << se2->GetEntryString(0x0008, 0x0060) << "]" << std::endl; // Modality
im1 = se1->GetFirstImage();
im2 = se2->GetFirstImage();
Program: gdcm
Module: $RCSfile: TestFileAccessors.cxx,v $
Language: C++
- Date: $Date: 2005/07/08 13:39:57 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
#include "gdcmFileHelper.h"
#include "gdcmUtil.h"
#include "gdcmCommon.h"
-#include "gdcmBinEntry.h"
#include "gdcmDocEntry.h"
#include "gdcmDocEntrySet.h"
#include "gdcmDocument.h"
#include "gdcmElementSet.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
#include <iostream>
//Generated file:
#include "gdcmDataImages.h"
+#define TestMethodMacro(mode,obj,name) \
+ try \
+ { \
+ std::cout << " " << #name << "() : " << mode << obj->name() << std::endl; \
+ } \
+ catch(...) \
+ { \
+ std::cout << " --> Can't access to the '" << #name << "' method !" << std::endl; \
+ delete f; \
+ return 1; \
+ }
+
+
int TestFileAccessors(int, char *[])
{
int i = 0;
filename += "/"; //doh!
filename += gdcmDataImages[i];
+ std::cout << "Begin with " << filename << std::endl;
gdcm::File *f= new gdcm::File( );
f->SetFileName( filename );
f->Load( );
// We just want to be sure no accessor seg faults on any image ...
// And this will improve test coverage ;-)
- std::cout << "GetSwapCode()" << f->GetSwapCode() << std::endl;
- std::cout << "GetImageNumber()" << f->GetImageNumber() << std::endl;
- std::cout << "GetModality()" << f->GetModality() << std::endl;
- std::cout << "GetXSize()" << f->GetXSize() << std::endl;
- std::cout << "GetYSize()" << f->GetYSize() << std::endl;
- std::cout << "GetZSize()" << f->GetZSize() << std::endl;
- std::cout << "GetXSpacing()" << f->GetXSpacing() << std::endl;
- std::cout << "GetYSpacing()" << f->GetYSpacing() << std::endl;
- std::cout << "GetZSpacing()" << f->GetZSpacing() << std::endl;
- std::cout << "GetXOrigin()" << f->GetXOrigin() << std::endl;
- std::cout << "GetYOrigin()" << f->GetYOrigin() << std::endl;
- std::cout << "GetZOrigin()" << f->GetZOrigin() << std::endl;
- std::cout << "GetBitsStored()" << f->GetBitsStored() << std::endl;
- std::cout << "GetBitsAllocated()" << f->GetBitsAllocated() << std::endl;
- std::cout << "GetHighBitPosition()" << f->GetHighBitPosition() << std::endl;
- std::cout << "GetSamplesPerPixel()" << f->GetSamplesPerPixel() << std::endl;
- std::cout << "GetPlanarConfiguration()" << f->GetPlanarConfiguration() << std::endl;
- std::cout << "GetPixelSize()" << f->GetPixelSize() << std::endl;
- std::cout << "GetPixelType()" << f->GetPixelType() << std::endl;
- std::cout << "GetLUTNbits()" << f->GetLUTNbits() << std::endl;
- std::cout << "GetRescaleIntercept()" << f->GetRescaleIntercept() << std::endl;
- std::cout << "GetRescaleSlope()" << f->GetRescaleSlope() << std::endl;
- std::cout << "GetGrPixel()" << std::hex << f->GetGrPixel() << std::endl;
- std::cout << "GetNumPixel()" << std::hex << f->GetNumPixel() << std::endl;
- std::cout << "GetPixelOffset()" << f->GetPixelOffset() << std::endl;
-
- std::cout << "GetPixelAreaLength()" << f->GetPixelAreaLength()<< std::endl;
- std::cout << "GetNumberOfScalarComponents()" << f->GetNumberOfScalarComponents()<< std::endl;
- std::cout << "GetNumberOfScalarComponentsRaw()" << f->GetNumberOfScalarComponentsRaw()<< std::endl;
- std::cout << "IsSignedPixelData()" << f->IsSignedPixelData()<< std::endl;
- std::cout << "IsMonochrome()" << f->IsMonochrome() << std::endl;
- std::cout << "IsPaletteColor()" << f->IsPaletteColor() << std::endl;
- std::cout << "IsYBRFull()" << f->IsYBRFull() << std::endl;
- std::cout << "HasLut() " << f->HasLUT() << std::endl;
- std::cout << "GetTransferSyntax()" << f->GetTransferSyntax() << std::endl;
- std::cout << "GetTransferSyntaxName()" << f->GetTransferSyntaxName() << std::endl;
- std::cout << "GetFileType()" << f->GetFileType() << std::endl;
- std::cout << "GetFileName()" << f->GetFileName() << std::endl;
+ TestMethodMacro(std::dec,f,GetSwapCode)
+ TestMethodMacro(std::dec,f,GetImageNumber)
+ TestMethodMacro(std::dec,f,GetModality)
+ TestMethodMacro(std::dec,f,GetXSize)
+ TestMethodMacro(std::dec,f,GetYSize)
+ TestMethodMacro(std::dec,f,GetZSize)
+ TestMethodMacro(std::dec,f,GetXSpacing)
+ TestMethodMacro(std::dec,f,GetYSpacing)
+ TestMethodMacro(std::dec,f,GetZSpacing)
+ TestMethodMacro(std::dec,f,GetXOrigin)
+ TestMethodMacro(std::dec,f,GetYOrigin)
+ TestMethodMacro(std::dec,f,GetZOrigin)
+ TestMethodMacro(std::dec,f,GetBitsStored)
+ TestMethodMacro(std::dec,f,GetBitsAllocated)
+ TestMethodMacro(std::dec,f,GetHighBitPosition)
+ TestMethodMacro(std::dec,f,GetSamplesPerPixel)
+ TestMethodMacro(std::dec,f,GetPlanarConfiguration)
+ TestMethodMacro(std::dec,f,GetPixelSize)
+ TestMethodMacro(std::dec,f,GetPixelType)
+ TestMethodMacro(std::dec,f,GetLUTNbits)
+ TestMethodMacro(std::dec,f,GetRescaleIntercept)
+ TestMethodMacro(std::dec,f,GetRescaleSlope)
+ TestMethodMacro(std::hex,f,GetGrPixel)
+ TestMethodMacro(std::hex,f,GetNumPixel)
+ TestMethodMacro(std::dec,f,GetPixelOffset)
+
+ TestMethodMacro(std::dec,f,GetPixelAreaLength)
+ TestMethodMacro(std::dec,f,GetNumberOfScalarComponents)
+ TestMethodMacro(std::dec,f,GetNumberOfScalarComponentsRaw)
+ TestMethodMacro(std::dec,f,IsSignedPixelData)
+ TestMethodMacro(std::dec,f,IsMonochrome)
+ TestMethodMacro(std::dec,f,IsPaletteColor)
+ TestMethodMacro(std::dec,f,IsYBRFull)
+ TestMethodMacro(std::dec,f,HasLUT)
+ TestMethodMacro(std::dec,f,GetTransferSyntax)
+ TestMethodMacro(std::dec,f,GetTransferSyntaxName)
+ TestMethodMacro(std::dec,f,GetFileType)
+ TestMethodMacro(std::dec,f,GetFileName)
f->GetImageOrientationPatient( iop );
for (int j=0; j<6; j++)
gdcm::FileHelper *fh= new gdcm::FileHelper( f );
- // TODO : Newbe user would appreciate any comment !
-
- std::cout << "GetImageDataSize()" << fh->GetImageDataSize() << std::endl;
- std::cout << "GetImageDataRawSize()" << fh->GetImageDataRawSize() << std::endl;
- // User Data
- std::cout << "GetRGBDataSize()" << fh->GetRGBDataSize() << std::endl;
- std::cout << "GetRawDataSize()" << fh->GetRawDataSize() << std::endl;
- std::cout << "GetUserDataSize()" << fh->GetUserDataSize() << std::endl;
-
- std::cout << "GetWriteType()" << fh->GetWriteType() << std::endl;
+ TestMethodMacro(std::dec,fh,GetImageDataSize)
+ TestMethodMacro(std::dec,fh,GetImageDataRawSize)
+ TestMethodMacro(std::dec,fh,GetRGBDataSize)
+ TestMethodMacro(std::dec,fh,GetRawDataSize)
+ TestMethodMacro(std::dec,fh,GetUserDataSize)
+ TestMethodMacro(std::dec,fh,GetWriteType)
delete fh;
}
}
delete f;
+ std::cout << "End with " << filename << std::endl;
i++;
}
return 0;
Program: gdcm
Module: $RCSfile: TestImageSet.cxx,v $
Language: C++
- Date: $Date: 2005/07/08 13:39:57 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
*/
#include "gdcmFile.h"
#include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmUtil.h"
#include "gdcmDebug.h"
if( sameSerie )
sameStudy = true;
- gdcm::ValEntry *entry;
+ gdcm::DataEntry *entry;
std::map<std::string, int> instUID;
std::map<std::string, int> mediaUID;
std::map<std::string, int> serieUID;
for(it=list.begin();it!=list.end();++it)
{
// SOP Instance UID
- entry=(*it)->GetValEntry(0x0008, 0x0018);
+ entry=(*it)->GetDataEntry(0x0008, 0x0018);
if( entry )
- if( instUID.find(entry->GetValue())!=instUID.end() )
- instUID[entry->GetValue()]++;
+ if( instUID.find(entry->GetString())!=instUID.end() )
+ instUID[entry->GetString()]++;
else
- instUID[entry->GetValue()]=1;
+ instUID[entry->GetString()]=1;
// Media Storage SOP Instance UID
- entry=(*it)->GetValEntry(0x0002,0x0003);
+ entry=(*it)->GetDataEntry(0x0002,0x0003);
if( entry )
- if( mediaUID.find(entry->GetValue())!=mediaUID.end() )
- mediaUID[entry->GetValue()]++;
+ if( mediaUID.find(entry->GetString())!=mediaUID.end() )
+ mediaUID[entry->GetString()]++;
else
- mediaUID[entry->GetValue()]=1;
+ mediaUID[entry->GetString()]=1;
// Series Instance UID
- entry=(*it)->GetValEntry(0x0020,0x000e);
+ entry=(*it)->GetDataEntry(0x0020,0x000e);
if( entry )
- if( serieUID.find(entry->GetValue())!=serieUID.end() )
- serieUID[entry->GetValue()]++;
+ if( serieUID.find(entry->GetString())!=serieUID.end() )
+ serieUID[entry->GetString()]++;
else
- serieUID[entry->GetValue()]=1;
+ serieUID[entry->GetString()]=1;
// Study Instance UID
- entry=(*it)->GetValEntry(0x0020,0x000d);
+ entry=(*it)->GetDataEntry(0x0020,0x000d);
if( entry )
- if( studyUID.find(entry->GetValue())!=studyUID.end() )
- studyUID[entry->GetValue()]++;
+ if( studyUID.find(entry->GetString())!=studyUID.end() )
+ studyUID[entry->GetString()]++;
else
- studyUID[entry->GetValue()]=1;
+ studyUID[entry->GetString()]=1;
}
if( sameSerie )
std::ostringstream str;
// Set the image size
- file->InsertValEntry("256",0x0028,0x0011); // Columns
- file->InsertValEntry("256",0x0028,0x0010); // Rows
+ file->InsertEntryString("256",0x0028,0x0011); // Columns
+ file->InsertEntryString("256",0x0028,0x0010); // Rows
// Set the pixel type
- file->InsertValEntry("8",0x0028,0x0100); // Bits Allocated
- file->InsertValEntry("8",0x0028,0x0101); // Bits Stored
- file->InsertValEntry("7",0x0028,0x0102); // High Bit
+ file->InsertEntryString("8",0x0028,0x0100); // Bits Allocated
+ file->InsertEntryString("8",0x0028,0x0101); // Bits Stored
+ file->InsertEntryString("7",0x0028,0x0102); // High Bit
// Set the pixel representation
- file->InsertValEntry("0",0x0028,0x0103); // Pixel Representation
+ file->InsertEntryString("0",0x0028,0x0103); // Pixel Representation
// Set the samples per pixel
- file->InsertValEntry("1",0x0028,0x0002); // Samples per Pixel
+ file->InsertEntryString("1",0x0028,0x0002); // Samples per Pixel
// The so called 'prepared image', built ex nihilo just before,
// has NO Pixel Element yet.
// It's up to the user to initialize Serie UID and Study UID
// Study Instance UID
studyUID = gdcm::Util::CreateUniqueUID();
- file->InsertValEntry(studyUID, 0x0020, 0x000d);
+ file->InsertEntryString(studyUID, 0x0020, 0x000d);
// Series Instance UID
serieUID = gdcm::Util::CreateUniqueUID();
- file->InsertValEntry(serieUID, 0x0020, 0x000e);
+ file->InsertEntryString(serieUID, 0x0020, 0x000e);
newFile = WriteImage(file, fileName.str());
if( !newFile )
std::ostringstream fileName;
fileName << "FileSeq" << i << ".dcm";
file = new gdcm::File();
- file->InsertValEntry(studyUID, 0x0020, 0x000d);
- file->InsertValEntry(serieUID, 0x0020, 0x000e);
+ file->InsertEntryString(studyUID, 0x0020, 0x000d);
+ file->InsertEntryString(serieUID, 0x0020, 0x000e);
newFile = WriteImage(file, fileName.str());
if( !newFile )
std::ostringstream fileName;
fileName << "FileSeq" << i << ".dcm";
file = new gdcm::File();
- file->InsertValEntry(studyUID, 0x0020, 0x000d);
+ file->InsertEntryString(studyUID, 0x0020, 0x000d);
serieUID = gdcm::Util::CreateUniqueUID();
- file->InsertValEntry(serieUID, 0x0020, 0x000e);
+ file->InsertEntryString(serieUID, 0x0020, 0x000e);
newFile = WriteImage(file, fileName.str());
if( !newFile )
{
Program: gdcm
Module: $RCSfile: TestLoadAllDocumentsNoPrivNoSeq.cxx,v $
Language: C++
- Date: $Date: 2005/09/22 14:42:37 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
#include "gdcmFile.h"
#include "gdcmUtil.h"
#include "gdcmCommon.h"
-#include "gdcmBinEntry.h"
#include "gdcmDocEntry.h"
#include "gdcmDocEntrySet.h"
#include "gdcmDocument.h"
#include "gdcmElementSet.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
#include "gdcmOrientation.h"
+
#include <fstream>
#include <iostream>
#include <iomanip> // for std::ios::left, ...
Program: gdcm
Module: $RCSfile: TestMakeIcon.cxx,v $
Language: C++
- Date: $Date: 2005/07/21 14:05:09 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ Version: $Revision: 1.9 $
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 "gdcmFile.h"
#include "gdcmFileHelper.h"
+#include "gdcmDataEntry.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
// 0088 0200 SQ 1 Icon Image Sequence
uint16_t binVal[3]={0x52f7,0xf358,0xad9b};
- sqi->InsertValEntry( "MONOCHROME2", 0x0028,0x0004);
- sqi->InsertValEntry( "128", 0x0028,0x0010);
- sqi->InsertValEntry( "8", 0x0028,0x0100);
- sqi->InsertValEntry( "8", 0x0028,0x0101);
- sqi->InsertValEntry( "7", 0x0028,0x0102);
- sqi->InsertValEntry( "0", 0x0028,0x0103);
- sqi->InsertBinEntry( (uint8_t *)binVal, 3*2, 0x0005,0x0010,"OW");
- sqi->InsertBinEntry( pixels, lgth, 0x7fe0,0x0010);
+ sqi->InsertEntryString( "MONOCHROME2", 0x0028,0x0004);
+ sqi->InsertEntryString( "128", 0x0028,0x0010);
+ sqi->InsertEntryString( "8", 0x0028,0x0100);
+ sqi->InsertEntryString( "8", 0x0028,0x0101);
+ sqi->InsertEntryString( "7", 0x0028,0x0102);
+ sqi->InsertEntryString( "0", 0x0028,0x0103);
+ sqi->InsertEntryBinArea( (uint8_t *)binVal, 3*2, 0x0005,0x0010,"OW");
+ sqi->InsertEntryBinArea( pixels, lgth, 0x7fe0,0x0010);
// just to see if it's stored a the right place
- sqi->InsertValEntry( "128", 0x0028,0x0011);
+ sqi->InsertEntryString( "128", 0x0028,0x0011);
fh->WriteDcmExplVR(output);
std::cout << "First Item found" << std::endl;
// Test for entry 0028|0010
- if ( !sqi->GetValEntry(0x0028,0x0010) )
+ if ( !sqi->GetDataEntry(0x0028,0x0010) )
{
- std::cout << "ValEntry 0028|0010 not found" << std::endl
+ std::cout << "GetDataEntry 0028|0010 not found" << std::endl
<< " ... Failed" << std::endl;
delete fh;
delete f;
return 1;
}
- std::cout << "First Item ->ValEntry 0028|0010 found" << std::endl;
- if ( sqi->GetValEntry(0x0028,0x0010)->GetValue() != "128" )
+ std::cout << "First Item ->DataEntry 0028|0010 found" << std::endl;
+ if ( sqi->GetDataEntry(0x0028,0x0010)->GetString() != "128" )
{
std::cout << "Value 0028|0010 don't match" << std::endl
- << "Read : " << sqi->GetValEntry(0x0028,0x0010)->GetValue()
+ << "Read : " << sqi->GetDataEntry(0x0028,0x0010)->GetString()
<< " - Expected : 128" << std::endl
<< " ... Failed" << std::endl;
delete fh;
}
// Test for entry 0028|0011
- if ( !sqi->GetValEntry(0x0028,0x0011) )
+ if ( !sqi->GetDataEntry(0x0028,0x0011) )
{
- std::cout << "ValEntry 0028|0011 not found" << std::endl
+ std::cout << "GetDataEntry 0028|0011 not found" << std::endl
<< " ... Failed" << std::endl;
delete fh;
delete f;
return 1;
}
- std::cout << "First Item ->ValEntry 0028|0011 found" << std::endl;
- if ( sqi->GetValEntry(0x0028,0x0011)->GetValue() != "128" )
+ std::cout << "First Item ->DataEntry 0028|0011 found" << std::endl;
+ if ( sqi->GetDataEntry(0x0028,0x0011)->GetString() != "128" )
{
std::cout << "Value 0028|0011 don't match" << std::endl
- << "Read : " << sqi->GetValEntry(0x0028,0x0011)->GetValue()
+ << "Read : " << sqi->GetDataEntry(0x0028,0x0011)->GetString()
<< " - Expected : 128" << std::endl
<< " ... Failed" << std::endl;
delete fh;
}
// Test for entry 0028|0100
- if ( !sqi->GetValEntry(0x0028,0x0100) )
+ if ( !sqi->GetDataEntry(0x0028,0x0100) )
{
- std::cout << "ValEntry 0028|0100 not found" << std::endl
+ std::cout << "GetDataEntry 0028|0100 not found" << std::endl
<< " ... Failed" << std::endl;
delete fh;
delete f;
return 1;
}
- std::cout << "First Item ->ValEntry 0028|0100 found" << std::endl;
- if ( sqi->GetValEntry(0x0028,0x0100)->GetValue() != "8" )
+ std::cout << "First Item ->DataEntry 0028|0100 found" << std::endl;
+ if ( sqi->GetDataEntry(0x0028,0x0100)->GetString() != "8" )
{
std::cout << "Value 0028|0100 don't match" << std::endl
- << "Read : " << sqi->GetValEntry(0x0028,0x0100)->GetValue()
+ << "Read : " << sqi->GetDataEntry(0x0028,0x0100)->GetString()
<< " - Expected : 8" << std::endl
<< " ... Failed" << std::endl;
delete fh;
}
// Test for entry 0028|0101
- if ( !sqi->GetValEntry(0x0028,0x0101) )
+ if ( !sqi->GetDataEntry(0x0028,0x0101) )
{
- std::cout << "ValEntry 0028|0101 not found" << std::endl
+ std::cout << "GetDataEntry 0028|0101 not found" << std::endl
<< " ... Failed" << std::endl;
delete fh;
delete f;
return 1;
}
- std::cout << "First Item ->ValEntry 0028|0101 found" << std::endl;
- if ( sqi->GetValEntry(0x0028,0x0101)->GetValue() != "8" )
+ std::cout << "First Item ->DataEntry 0028|0101 found" << std::endl;
+ if ( sqi->GetDataEntry(0x0028,0x0101)->GetString() != "8" )
{
std::cout << "Value 0028|0101 don't match" << std::endl
- << "Read : " << sqi->GetValEntry(0x0028,0x0101)->GetValue()
+ << "Read : " << sqi->GetDataEntry(0x0028,0x0101)->GetString()
<< " - Expected : 8" << std::endl
<< " ... Failed" << std::endl;
delete fh;
}
// Test for entry 0028|0102
- if ( !sqi->GetValEntry(0x0028,0x0102) )
+ if ( !sqi->GetDataEntry(0x0028,0x0102) )
{
- std::cout << "ValEntry 0028|0102 not found" << std::endl
+ std::cout << "DataEntry 0028|0102 not found" << std::endl
<< " ... Failed" << std::endl;
delete fh;
delete f;
return 1;
}
- std::cout << "First Item ->ValEntry 0028|0102 found" << std::endl;
- if ( sqi->GetValEntry(0x0028,0x0102)->GetValue() != "7" )
+ std::cout << "First Item ->DataEntry 0028|0102 found" << std::endl;
+ if ( sqi->GetDataEntry(0x0028,0x0102)->GetString() != "7" )
{
std::cout << "Value 0028|0102 don't match" << std::endl
- << "Read : " << sqi->GetValEntry(0x0028,0x0102)->GetValue()
+ << "Read : " << sqi->GetDataEntry(0x0028,0x0102)->GetString()
<< " - Expected : 7" << std::endl
<< " ... Failed" << std::endl;
delete fh;
}
// Test for entry 0028|0103
- if ( !sqi->GetValEntry(0x0028,0x0103) )
+ if ( !sqi->GetDataEntry(0x0028,0x0103) )
{
- std::cout << "ValEntry 0028|0010 not found" << std::endl
+ std::cout << "GetDataEntry 0028|0010 not found" << std::endl
<< " ... Failed" << std::endl;
delete fh;
delete f;
return 1;
}
- std::cout << "First Item ->ValEntry 0028|0103 found" << std::endl;
- if ( sqi->GetValEntry(0x0028,0x0103)->GetValue() != "0" )
+ std::cout << "First Item ->DataEntry 0028|0103 found" << std::endl;
+ if ( sqi->GetDataEntry(0x0028,0x0103)->GetString() != "0" )
{
std::cout << "Value 0028|0103 don't match" << std::endl
- << "Read : " << sqi->GetValEntry(0x0028,0x0103)->GetValue()
+ << "Read : " << sqi->GetDataEntry(0x0028,0x0103)->GetString()
<< " - Expected : 0" << std::endl
<< " ... Failed" << std::endl;
delete fh;
}
// Test for entry 0005|0010
- if ( !sqi->GetBinEntry(0x0005,0x0010) )
+ if ( !sqi->GetDataEntry(0x0005,0x0010) )
{
- std::cout << "BinEntry 0005|0010 not found" << std::endl
+ std::cout << "GetDataEntry 0005|0010 not found" << std::endl
<< " ... Failed" << std::endl;
delete fh;
delete f;
return 1;
}
- std::cout << "First Item ->BinEntry 0005|0010 found" << std::endl;
- if( sqi->GetBinEntry(0x0005,0x0010)->GetLength() != 6 )
+ std::cout << "First Item ->GetDataEntry 0005|0010 found" << std::endl;
+ if( sqi->GetDataEntry(0x0005,0x0010)->GetLength() != 6 )
{
- std::cout << "BinEntry size 0005|0010 don't match" << std::endl
- << "Read : " << sqi->GetValEntry(0x0005,0x0010)->GetLength()
+ std::cout << "GetDataEntry size 0005|0010 don't match" << std::endl
+ << "Read : " << sqi->GetDataEntry(0x0005,0x0010)->GetLength()
<< " - Expected : 6" << std::endl
<< " ... Failed" << std::endl;
delete fh;
return 1;
}
- std::cout << "Length BinEntry 0005|0010 OK" << std::endl;
+ std::cout << "Length GetDataEntry 0005|0010 OK" << std::endl;
- if( memcmp(sqi->GetBinEntry(0x0005,0x0010)->GetBinArea(),binVal,6)!=0 )
+ if( memcmp(sqi->GetDataEntry(0x0005,0x0010)->GetBinArea(),binVal,6)!=0 )
{
- std::cout << "Value 0005|0010 don't match (BinEntry)" << std::endl
+ std::cout << "Value 0005|0010 don't match (DataEntry)" << std::endl
<< " ... Failed" << std::endl;
delete fh;
delete f;
return 1;
}
- std::cout << "Value BinEntry 0005|0010 OK" << std::endl;
+ std::cout << "Value DataEntry 0005|0010 OK" << std::endl;
delete fh;
delete f;
Program: gdcm
Module: $RCSfile: TestPrintAllDocument.cxx,v $
Language: C++
- Date: $Date: 2005/10/01 19:39:15 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmFile.h"
#include "gdcmUtil.h"
#include "gdcmCommon.h"
-#include "gdcmBinEntry.h"
#include "gdcmDocEntry.h"
#include "gdcmDocEntrySet.h"
#include "gdcmDocument.h"
#include "gdcmElementSet.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
#include "gdcmOrientation.h"
#include <fstream>
#include <iostream>
std::cout << " Smpl.P.Pix.=" << f->GetSamplesPerPixel()
<< " Plan.Config.=" << f->GetPlanarConfiguration();
- photomInterp = f->GetEntryValue(0x0028,0x0004);
+ photomInterp = f->GetEntryString(0x0028,0x0004);
std::cout << " Photom.Interp.=" << photomInterp;
for (j=0; j<l-photomInterp.length(); j++)
std::cout << " ";
std::cout << std::endl;
std::string strImageOrientationPatient =
- f->GetEntryValue(0x0020,0x0037);
+ f->GetEntryString(0x0020,0x0037);
if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND )
{
gdcm::Orientation o;
Program: gdcm
Module: $RCSfile: TestReadWriteReadCompare.cxx,v $
Language: C++
- Date: $Date: 2005/07/21 04:51:26 $
- Version: $Revision: 1.24 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ Version: $Revision: 1.25 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
file->Load ();
if( !file->IsReadable() )
{
- std::cerr << "Test::TestReadWriteReadCompare: Image not gdcm compatible:"
+ std::cout << "Failed" << std::endl
+ << "Test::TestReadWriteReadCompare: Image not gdcm compatible:"
<< filename << std::endl;
delete file;
return 1;
fileout->SetFileName( output );
fileout->Load();
// gdcm::FileHelper *reread = new gdcm::FileHelper( output ); // deprecated
-
+
if( !fileout->IsReadable() )
{
- std::cerr << "Failed" << std::endl
+ std::cout << "Failed" << std::endl
<< "Test::TestReadWriteReadCompare: Could not parse the newly "
<< "written image:" << filename << std::endl;
delete file;
}
else if( argc > 4 || argc == 2 )
{
- std::cerr << "Please read the manual" << std::endl;
+ std::cout << "Please read the manual" << std::endl;
}
else
{
Program: gdcm
Module: $RCSfile: TestWriteSimple.cxx,v $
Language: C++
- Date: $Date: 2005/10/11 14:24:29 $
- Version: $Revision: 1.38 $
+ Date: $Date: 2005/10/18 08:35:46 $
+ 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
{0, 0, 1, 1, 8, 8, 0, 'i'} // to find the end
};
+const unsigned int MAX_NUMBER_OF_DIFFERENCE = 10;
+
int WriteSimple(Image &img)
{
std::ostringstream fileName;
// Set the image size
str.str("");
str << img.sizeX;
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0011); // Columns
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0011); // Columns
str.str("");
str << img.sizeY;
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0010); // Rows
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0010); // Rows
if(img.sizeZ>1)
{
str.str("");
str << img.sizeZ;
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0008); // Number of Frames
}
fileName << "-" << img.sizeX << "-" << img.sizeY << "-" << img.sizeZ;
// Set the pixel type
str.str("");
str << img.componentSize;
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0100); // Bits Allocated
str.str("");
str << img.componentUse;
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0101); // Bits Stored
str.str("");
str << ( img.componentSize - 1 );
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0102); // High Bit
// Set the pixel representation
str.str("");
str << img.sign;
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0103); // Pixel Representation
fileName << "-" << img.componentSize;
if(img.sign == 0)
// Set the samples per pixel
str.str("");
str << img.components;
- fileToBuild->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
+ fileToBuild->InsertEntryString(str.str(),0x0028,0x0002); // Samples per Pixel
// Step 2 : Create the output image
std::cout << "2...";
if( !fileH->Write(fileName.str()) )
{
std::cout << "Failed for [" << fileName.str() << "]\n"
- << " File in unwrittable\n";
+ << " File is unwrittable\n";
delete fileH;
delete fileToBuild;
{
std::cout << "Failed" << std::endl
<< " Pixel differ (as expanded in memory)." << std::endl;
+ std::cout << " list of the first " << MAX_NUMBER_OF_DIFFERENCE
+ << " pixels differing (pos : test - ref) :"
+ << std::endl;
+ int i;
+ unsigned int j;
+ for(i=0, j=0;i<dataSizeWritten && j<MAX_NUMBER_OF_DIFFERENCE;i++)
+ {
+ if(imageDataWritten[i]!=imageData[i])
+ {
+ std::cout << std::hex << "(" << i << " : "
+ << std::hex << (int)(imageDataWritten[i]) << " - "
+ << std::hex << (int)(imageData[i]) << ") "
+ << std::dec;
+ ++j;
+ }
+ }
+ std::cout << std::endl;
delete fileToBuild;
delete fileH;
delete reread;
return 1;
}
- // gdcm::Debug::DebugOn();
+ //gdcm::Debug::DebugOn();
int ret=0;
int i=0;
image=serie.GetFirstImage()
while(image):
print " Image"
- print " ---",image.GetValEntry(0x0004,0x1500).GetValue()
+ print " ---",image.GetDataEntry(0x0004,0x1500).GetValue()
image=serie.GetNextImage()
serie=study.GetNextSerie()
study=patient.GetNextStudy()
SET(libgdcm_la_SOURCES
gdcmArgMgr.cxx
gdcmBase.cxx
- gdcmBinEntry.cxx
- gdcmContentEntry.cxx
+ gdcmDataEntry.cxx
gdcmDebug.cxx
gdcmDicomDir.cxx
gdcmDicomDirElement.cxx
gdcmSQItem.cxx
gdcmTS.cxx
gdcmUtil.cxx
- gdcmValEntry.cxx
gdcmValidator.cxx
gdcmVR.cxx
${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx
Program: gdcm
Module: $RCSfile: gdcm.h,v $
Language: C++
- Date: $Date: 2005/03/09 11:16:11 $
- Version: $Revision: 1.54 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ Version: $Revision: 1.55 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmFileHelper.h"
#include "gdcmSerieHelper.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmSeqEntry.h"
#include "gdcmUtil.h"
+++ /dev/null
-/*=========================================================================
-
- Program: gdcm
- Module: $RCSfile: gdcmBinEntry.cxx,v $
- Language: C++
- Date: $Date: 2005/10/11 14:48:19 $
- 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
- 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.
-
-=========================================================================*/
-
-#include "gdcmBinEntry.h"
-#include "gdcmContentEntry.h"
-#include "gdcmUtil.h"
-
-#include <fstream>
-#include <sstream>
-#include <iostream> // for std::ios_base, since <ios> does not exist on gcc/Solaris
-
-namespace gdcm
-{
-//-----------------------------------------------------------------------------
-// Constructor / Destructor
-/**
- * \brief Constructor from a given BinEntry
- */
-BinEntry::BinEntry(DictEntry *e)
- :ContentEntry(e)
-{
- BinArea = 0;
- SelfArea = true;
-}
-
-/**
- * \brief Constructor from a given BinEntry
- * @param e Pointer to existing Doc entry
- */
-BinEntry::BinEntry(DocEntry *e)
- : ContentEntry(e->GetDictEntry())
-{
- Copy(e);
-
- BinArea = 0;
- SelfArea = true;
-}
-
-/**
- * \brief Canonical destructor.
- */
-BinEntry::~BinEntry()
-{
- if (BinArea && SelfArea)
- {
- delete[] BinArea;
- BinArea = 0; // let's be carefull !
- }
-}
-
-//-----------------------------------------------------------------------------
-// Public
-/**
- * \brief canonical Writer
- * @param fp already open file pointer
- * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
-*/
-void BinEntry::WriteContent(std::ofstream *fp, FileType filetype)
-{
- DocEntry::WriteContent(fp, filetype);
- uint8_t *binArea8 = BinArea; //safe notation
- size_t lgr = GetLength();
- if (BinArea) // the binArea was *actually* loaded
- {
-
- // The same operation should be done if we wanted
- // to write image with Big Endian Transfer Syntax,
- // while working on Little Endian Processor
- // --> forget Big Endian Transfer Syntax writting!
- // Next DICOM version will give it up ...
-
- // -->
- // --> FIXME
- // -->
- // The stuff looks nice, but it's probably bugged,
- // since troubles occur on big endian processors (SunSparc, Motorola)
- // while reading the pixels of a
- // gdcm-written Little-Endian 16 bits per pixel image
-
-#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
-
- /// \todo FIXME : Right now, we only care of Pixels element
- /// we should deal with *all* the BinEntries
- /// Well, not really since we are not interpreting values read...
-
- // 8 Bits Pixels *are* OB, 16 Bits Pixels *are* OW
- // -value forced while Reading process-
-
- //-->
- // -->
- // --> WARNING
- // --> the following lines *looked* very clever,
- // --> but they don't work on big endian processors.
- // --> since I've no access for the moment to a big endian proc :-(
- // --> I comment them out, to see the result on the dash board
- // -->
-
- // --> Revert to initial code : TestWriteSimple hangs on Darwin :-(
- if (GetGroup() == 0x7fe0 && GetVR() == "OW")
- {
- uint16_t *binArea16 = (uint16_t*)binArea8;
- binary_write (*fp, binArea16, lgr );
- }
- else
- {
- // For any other VR, BinEntry is re-written as-is
- binary_write (*fp, binArea8, lgr );
- }
-
- //-->
- // -->
- // --> WARNING
- // --> remove the following line, an uncomment the previous ones,
- // --> if it doesn't work better
- // -->
- /*binary_write ( *fp, binArea8, lgr ); // Elem value*/
-
-#else
- binary_write ( *fp, binArea8, lgr ); // Elem value
-#endif //GDCM_WORDS_BIGENDIAN
-
- }
- else
- {
- // nothing was loaded, but we need to skip space on disc
-
- // --> WARNING : nothing is written;
- // --> the initial data (on the the source image) is lost
- // --> user is *not* informed !
-
- fp->seekp(lgr, std::ios::cur);
- }
-}
-
-/**
- * \brief Sets the value (non string) of the current Dicom Header Entry
- */
-void BinEntry::SetBinArea( uint8_t *area, bool self )
-{
- if (BinArea && SelfArea)
- delete[] BinArea;
-
- BinArea = area;
- SelfArea=self;
-}
-
-//-----------------------------------------------------------------------------
-// Protected
-
-//-----------------------------------------------------------------------------
-// Private
-
-//-----------------------------------------------------------------------------
-// Print
-/**
- * \brief Prints a BinEntry (Dicom entry)
- * @param os ostream we want to print in
- * @param indent Indentation string to be prepended during printing
- */
-void BinEntry::Print(std::ostream &os, std::string const & )
-{
- os << "B ";
- DocEntry::Print(os);
- std::ostringstream s;
- void* binArea = GetBinArea();
- if (binArea)
- {
- if ( GetVR() == "FL" )
- {
- int l = GetReadLength()/4 - 1;
- float *beg = (float *)GetBinArea();
- s << " [" << *beg;
- if ( l!= 0)
- for (int i=0;i<l;i++)
- {
- beg++;
- s << "\\" << *beg;
- }
- s << "]";
- }
- else if ( GetVR() == "FD" )
- {
- int l = GetReadLength()/8 - 1;
- double *beg = (double *)GetBinArea();
- s << " [" << *beg;
- if ( l!= 0)
- for (int i=0;i<l;i++)
- {
- beg++;
- s << "\\" << *beg;
- }
- s << "]";
- }
- else
- {
- if ( Util::IsCleanArea( GetBinArea(),GetLength() ) )
- {
- std::string cleanString =
- Util::CreateCleanString( GetBinArea(),GetLength() );
- s << " [" << cleanString << "]";
- }
- else
- {
- //s << " [" << GetValue()
- s << " [" << GDCM_BINLOADED << ";"
- << "length = " << GetLength() << "]";
- }
- }
- }
- else
- {
- if ( GetLength() == 0 )
- {
- s << " []";
- }
- else
- {
- s << " [" <<GetValue() << "]";
- }
- }
- os << s.str();
-}
-
-//-----------------------------------------------------------------------------
-} // end namespace gdcm
+++ /dev/null
-/*=========================================================================
-
- Program: gdcm
- Module: $RCSfile: gdcmBinEntry.h,v $
- Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- Version: $Revision: 1.38 $
-
- 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 GDCMBINENTRY_H
-#define GDCMBINENTRY_H
-
-#include "gdcmContentEntry.h"
-#include <iostream>
-
-namespace gdcm
-{
-
-//-----------------------------------------------------------------------------
-/**
- * \brief Any Dicom Document (File or DicomDir) contains
- * a set of DocEntry - Dicom entries -
- * BinEntry is an elementary DocEntry (i.e. a ContentEntry,
- * as opposed to SeqEntry) whose content is non std::string
- * representable
- * BinEntry is a specialisation of ContentEntry
- */
-
-class GDCM_EXPORT BinEntry : public ContentEntry
-{
-public:
- BinEntry( DictEntry *e );
- BinEntry( DocEntry *d );
-
- ~BinEntry();
-
- void Print( std::ostream &os = std::cout, std::string const &indent = "" );
-
- void WriteContent( std::ofstream *fp, FileType ft);
-
- /// \brief Returns the area value of the current Dicom Entry
- /// when it's not string-translatable (e.g : LUT table, overlay, icon)
- uint8_t *GetBinArea() { return BinArea; }
- void SetBinArea( uint8_t *area, bool self = true );
-
- /// \brief Sets SelfArea
- void SetSelfArea(bool area) { SelfArea = area; }
- /// \brief Returns SelfArea
- bool IsSelfArea() { return SelfArea; }
-
-private:
- /// \brief memory area to hold 'non std::string' representable values
- /// (ie : Lookup Tables, overlays, icons)
- uint8_t *BinArea;
- /// \brief Whether BinEntry has its own BinArea or not
- bool SelfArea;
-};
-
-} // end namespace gdcm
-//-----------------------------------------------------------------------------
-#endif
-
+++ /dev/null
-/*=========================================================================
-
- Program: gdcm
- Module: $RCSfile: gdcmContentEntry.cxx,v $
- Language: C++
- Date: $Date: 2005/06/24 10:55:58 $
- 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
- 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.
-
-=========================================================================*/
-
-#include "gdcmContentEntry.h"
-#include "gdcmVR.h"
-#include "gdcmTS.h"
-#include "gdcmGlobal.h"
-#include "gdcmUtil.h"
-#include "gdcmDebug.h"
-
-#include <fstream>
-
-namespace gdcm
-{
-
-//-----------------------------------------------------------------------------
-// Constructor / Destructor
-/**
- * \brief Constructor for a given DictEntry
- * @param e Pointer to existing dictionary entry
- */
-ContentEntry::ContentEntry(DictEntry *e)
- : DocEntry(e)
-{
- Value = GDCM_UNFOUND;
-}
-
-/**
- * \brief Constructor for a given DocEntry
- * @param e Pointer to existing Doc entry
- */
-ContentEntry::ContentEntry(DocEntry *e)
- : DocEntry(e->GetDictEntry())
-{
- Copy(e);
-}
-
-/**
- * \brief Canonical destructor.
- */
-ContentEntry::~ContentEntry ()
-{
-}
-
-//-----------------------------------------------------------------------------
-// Print
-
-//-----------------------------------------------------------------------------
-// Public
-void ContentEntry::Copy(DocEntry *doc)
-{
- DocEntry::Copy(doc);
-
- ContentEntry *entry = dynamic_cast<ContentEntry *>(doc);
- if ( entry )
- Value = entry->Value;
-}
-
-//-----------------------------------------------------------------------------
-// Protected
-
-//-----------------------------------------------------------------------------
-// Private
-
-//-----------------------------------------------------------------------------
-} // end namespace gdcm
-
+++ /dev/null
-/*=========================================================================
-
- Program: gdcm
- Module: $RCSfile: gdcmContentEntry.h,v $
- Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- Version: $Revision: 1.6 $
-
- 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 GDCMCONTENTENTRY_H
-#define GDCMCONTENTENTRY_H
-
-#include "gdcmDocEntry.h"
-
-#include <iostream>
-
-namespace gdcm
-{
-//-----------------------------------------------------------------------------
-/**
- * \brief Any Dicom Document (File or DicomDir) contains
- * a set of DocEntry - Dicom entries -
- * (when successfuly parsed against a given Dicom dictionary)
- * ContentEntry is an elementary DocEntry (as opposed to SeqEntry).
- * Depending on the type of its content,
- * ContentEntry is specialized as a ValEntry or a BinEntry
- */
-class GDCM_EXPORT ContentEntry : public DocEntry
-{
-public:
- virtual void WriteContent(std::ofstream *fp, FileType filetype) = 0;
-
- /// Sets the value (string) of the current Dicom entry
- virtual void SetValue(std::string const &val) { Value = val; }
- /// \brief Returns the 'Value' (e.g. "Dupond^Marcel") converted
- /// into a 'string', event if it's physically stored on disk as an integer
- /// (e.g. : 0x000c returned as "12")
- std::string const &GetValue() const { return Value; }
-
- void Copy(DocEntry *doc);
-
-protected:
- // Contructors are protected, not to be invoked by end user.
- ContentEntry(DictEntry *e);
- ContentEntry(DocEntry *d);
- // Destructor is protected, not to be invoked by end user.
- ~ContentEntry();
-
-private:
-// Members :
- /// \brief Dicom entry value, internaly represented as a std::string.
- /// The Value Representation (\ref VR) is independently used
- /// in order to interpret (decode) this field.
- std::string Value;
-};
-
-} // end namespace gdcm
-
-//-----------------------------------------------------------------------------
-#endif
-
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmDataEntry.cxx,v $
+ Language: C++
+ Date: $Date: 2005/10/18 08:35:51 $
+ 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.
+
+=========================================================================*/
+
+#include "gdcmDataEntry.h"
+#include "gdcmVR.h"
+#include "gdcmTS.h"
+#include "gdcmGlobal.h"
+#include "gdcmUtil.h"
+#include "gdcmDebug.h"
+
+#include <fstream>
+
+namespace gdcm
+{
+//-----------------------------------------------------------------------------
+#define MAX_SIZE_PRINT_ELEMENT_VALUE 0x7fffffff
+uint32_t DataEntry::MaxSizePrintEntry = MAX_SIZE_PRINT_ELEMENT_VALUE;
+
+//-----------------------------------------------------------------------------
+// Constructor / Destructor
+/**
+ * \brief Constructor for a given DictEntry
+ * @param e Pointer to existing dictionary entry
+ */
+DataEntry::DataEntry(DictEntry *e)
+ : DocEntry(e)
+{
+ State = STATE_LOADED;
+ Flag = FLAG_NONE;
+
+ BinArea = 0;
+ SelfArea = true;
+}
+
+/**
+ * \brief Constructor for a given DocEntry
+ * @param e Pointer to existing Doc entry
+ */
+DataEntry::DataEntry(DocEntry *e)
+ : DocEntry(e->GetDictEntry())
+{
+ Flag = 0;
+ BinArea = 0;
+ SelfArea = true;
+
+ Copy(e);
+}
+
+/**
+ * \brief Canonical destructor.
+ */
+DataEntry::~DataEntry ()
+{
+ DeleteBinArea();
+}
+
+//-----------------------------------------------------------------------------
+// Print
+
+//-----------------------------------------------------------------------------
+// Public
+/**
+ * \brief Sets the value (non string) of the current Dicom Header Entry
+ */
+void DataEntry::SetBinArea( uint8_t *area, bool self )
+{
+ DeleteBinArea();
+
+ BinArea = area;
+ SelfArea = self;
+
+ State = STATE_LOADED;
+}
+
+void DataEntry::CopyBinArea( uint8_t *area, uint32_t length )
+{
+ DeleteBinArea();
+
+ uint32_t lgh = length + length%2;
+ SetLength(lgh);
+
+ if( area && length > 0 )
+ {
+ NewBinArea();
+ memcpy(BinArea,area,length);
+ if( length!=lgh )
+ BinArea[length]=0;
+
+ State = STATE_LOADED;
+ }
+}
+
+void DataEntry::SetValue(const uint32_t &id,const double &val)
+{
+ if( !BinArea )
+ NewBinArea();
+ State = STATE_LOADED;
+
+ if( id > GetValueCount() )
+ {
+ gdcmErrorMacro("Index (" << id << ")is greater than the data size");
+ return;
+ }
+
+ const VRKey &vr = GetVR();
+ if( vr == "US" || vr == "SS" )
+ {
+ uint16_t *data = (uint16_t *)BinArea;
+ data[id] = (uint16_t)val;
+ }
+ else if( vr == "UL" || vr == "SL" )
+ {
+ uint32_t *data = (uint32_t *)BinArea;
+ data[id] = (uint32_t)val;
+ }
+ else if( vr == "FL" )
+ {
+ float *data = (float *)BinArea;
+ data[id] = (float)val;
+ }
+ else if( vr == "FD" )
+ {
+ double *data = (double *)BinArea;
+ data[id] = (double)val;
+ }
+ else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
+ {
+ gdcmErrorMacro("SetValue on String representable not implemented yet");
+ }
+ else
+ {
+ BinArea[id] = (uint8_t)val;
+ }
+}
+
+double DataEntry::GetValue(const uint32_t &id) const
+{
+ if( !BinArea )
+ {
+ gdcmErrorMacro("BinArea not set. Can't get the value");
+ return 0;
+ }
+
+ uint32_t count = GetValueCount();
+ if( id > count )
+ {
+ gdcmErrorMacro("Index (" << id << ")is greater than the data size");
+ return 0;
+ }
+
+ const VRKey &vr = GetVR();
+ if( vr == "US" || vr == "SS" )
+ return ((uint16_t *)BinArea)[id];
+ else if( vr == "UL" || vr == "SL" )
+ return ((uint32_t *)BinArea)[id];
+ else if( vr == "FL" )
+ return ((float *)BinArea)[id];
+ else if( vr == "FD" )
+ return ((double *)BinArea)[id];
+ else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
+ {
+ if( GetLength() )
+ {
+ // Don't use std::string to accelerate processing
+ double val = 0.0;
+ char *tmp = new char[GetLength()+1];
+ memcpy(tmp,BinArea,GetLength());
+ tmp[GetLength()]=0;
+
+ if( count == 0 )
+ {
+ val = atof(tmp);
+ }
+ else
+ {
+ count = id;
+ char *beg = tmp;
+ for(uint32_t i=0;i<GetLength();i++)
+ {
+ if( tmp[i] == '\\' )
+ {
+ if( count == 0 )
+ {
+ tmp[i] = NULL;
+ break;
+ }
+ else
+ {
+ count--;
+ beg = &(tmp[i+1]);
+ }
+ }
+ }
+ val = atof(beg);
+ }
+
+ delete[] tmp;
+ return val;
+ }
+ else
+ return 0.0;
+ }
+ else
+ return BinArea[id];
+}
+
+uint32_t DataEntry::GetValueCount(void) const
+{
+ const VRKey &vr = GetVR();
+ if( vr == "US" || vr == "SS" )
+ return GetLength()/sizeof(uint16_t);
+ else if( vr == "UL" || vr == "SL" )
+ return GetLength()/sizeof(uint32_t);
+ else if( vr == "FL" )
+ return GetLength()/sizeof(float);
+ else if( vr == "FD" )
+ return GetLength()/sizeof(double);
+ else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
+ {
+ // Don't use std::string to accelerate processing
+ uint32_t count = 1;
+ for(uint32_t i=0;i<GetLength();i++)
+ {
+ if( BinArea[i] == '\\')
+ count++;
+ }
+ return count;
+ }
+ else
+ return GetLength();
+}
+
+void DataEntry::SetString(std::string const &value)
+{
+ DeleteBinArea();
+
+ const VRKey &vr = GetVR();
+ if ( vr == "US" || vr == "SS" )
+ {
+ std::vector<std::string> tokens;
+ Util::Tokenize (value, tokens, "\\");
+ SetLength(tokens.size()*sizeof(uint16_t));
+ NewBinArea();
+
+ uint16_t *data = (uint16_t *)BinArea;
+ for (unsigned int i=0; i<tokens.size();i++)
+ data[i] = atoi(tokens[i].c_str());
+ tokens.clear();
+ }
+ else if ( vr == "UL" || vr == "SL" )
+ {
+ std::vector<std::string> tokens;
+ Util::Tokenize (value, tokens, "\\");
+ SetLength(tokens.size()*sizeof(uint32_t));
+ NewBinArea();
+
+ uint32_t *data = (uint32_t *)BinArea;
+ for (unsigned int i=0; i<tokens.size();i++)
+ data[i] = atoi(tokens[i].c_str());
+ tokens.clear();
+ }
+ else if ( vr == "FL" )
+ {
+ std::vector<std::string> tokens;
+ Util::Tokenize (value, tokens, "\\");
+ SetLength(tokens.size()*sizeof(float));
+ NewBinArea();
+
+ float *data = (float *)BinArea;
+ for (unsigned int i=0; i<tokens.size();i++)
+ data[i] = (float)atof(tokens[i].c_str());
+ tokens.clear();
+ }
+ else if ( vr == "FD" )
+ {
+ std::vector<std::string> tokens;
+ Util::Tokenize (value, tokens, "\\");
+ SetLength(tokens.size()*sizeof(double));
+ NewBinArea();
+
+ double *data = (double *)BinArea;
+ for (unsigned int i=0; i<tokens.size();i++)
+ data[i] = atof(tokens[i].c_str());
+ tokens.clear();
+ }
+ else
+ {
+ if( value.size() > 0 )
+ {
+ std::string finalVal = Util::DicomString( value.c_str() );
+ SetLength(finalVal.size());
+ NewBinArea();
+
+ memcpy(BinArea, &(finalVal[0]), finalVal.size());
+ }
+ }
+ State = STATE_LOADED;
+}
+
+std::string const &DataEntry::GetString() const
+{
+ static std::ostringstream s;
+ const VRKey &vr = GetVR();
+
+ s.str("");
+ StrArea="";
+
+ if( !BinArea )
+ return StrArea;
+
+ if( vr == "US" || vr == "SS" )
+ {
+ uint16_t *data=(uint16_t *)BinArea;
+
+ for (int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ StrArea=s.str();
+ }
+ // See above comment on multiple integers (mutatis mutandis).
+ else if( vr == "UL" || vr == "SL" )
+ {
+ uint32_t *data=(uint32_t *)BinArea;
+
+ for (int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ StrArea=s.str();
+ }
+ else if( vr == "FL" )
+ {
+ float *data=(float *)BinArea;
+
+ for (int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ StrArea=s.str();
+ }
+ else if( vr == "FD" )
+ {
+ double *data=(double *)BinArea;
+
+ for (int i=0; i < GetValueCount(); i++)
+ {
+ if( i!=0 )
+ s << '\\';
+ s << data[i];
+ }
+ StrArea=s.str();
+ }
+ else
+ StrArea.append((const char *)BinArea,GetLength());
+
+ return StrArea;
+}
+
+void DataEntry::Copy(DocEntry *doc)
+{
+ DocEntry::Copy(doc);
+
+ DataEntry *entry = dynamic_cast<DataEntry *>(doc);
+ if ( entry )
+ {
+ State = entry->State;
+ Flag = entry->Flag;
+ CopyBinArea(entry->BinArea,entry->GetLength());
+ }
+}
+
+void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
+{
+ DocEntry::WriteContent(fp, filetype);
+
+ if ( GetGroup() == 0xfffe )
+ {
+ return; //delimitors have NO value
+ }
+
+ uint8_t *binArea8 = BinArea; //safe notation
+ size_t lgr = GetLength();
+ if (BinArea) // the binArea was *actually* loaded
+ {
+
+ // The same operation should be done if we wanted
+ // to write image with Big Endian Transfer Syntax,
+ // while working on Little Endian Processor
+ // --> forget Big Endian Transfer Syntax writting!
+ // Next DICOM version will give it up ...
+
+ // --> FIXME
+ // The stuff looks nice, but it's probably bugged,
+ // since troubles occur on big endian processors (SunSparc, Motorola)
+ // while reading the pixels of a
+ // gdcm-written Little-Endian 16 bits per pixel image
+
+#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
+
+ /// \todo FIXME : Right now, we only care of Pixels element
+ /// we should deal with *all* the BinEntries
+ /// Well, not really since we are not interpreting values read...
+
+ // 8 Bits Pixels *are* OB, 16 Bits Pixels *are* OW
+ // -value forced while Reading process-
+
+ // --> WARNING
+ // --> the following lines *looked* very clever,
+ // --> but they don't work on big endian processors.
+ // --> since I've no access for the moment to a big endian proc :-(
+ // --> I comment them out, to see the result on the dash board
+ // -->
+
+ // --> Revert to initial code : TestWriteSimple hangs on Darwin :-(
+ if (GetGroup() == 0x7fe0 && GetVR() == "OW")
+ {
+ uint16_t *binArea16 = (uint16_t*)binArea8;
+ binary_write (*fp, binArea16, lgr );
+ }
+ else
+ {
+ // For any other VR, DataEntry is re-written as-is
+ binary_write (*fp, binArea8, lgr );
+ }
+
+ // --> WARNING
+ // --> remove the following line, an uncomment the previous ones,
+ // --> if it doesn't work better
+ // -->
+ /*binary_write ( *fp, binArea8, lgr ); // Elem value*/
+
+#else
+ binary_write ( *fp, binArea8, lgr ); // Elem value
+#endif //GDCM_WORDS_BIGENDIAN
+ }
+ else
+ {
+ // nothing was loaded, but we need to skip space on disc
+
+ // --> WARNING : nothing is written;
+ // --> the initial data (on the the source image) is lost
+ // --> user is *not* informed !
+
+ fp->seekp(lgr, std::ios::cur);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Protected
+void DataEntry::NewBinArea(void)
+{
+ DeleteBinArea();
+ if( GetLength() > 0 )
+ BinArea = new uint8_t[GetLength()];
+ SelfArea = true;
+}
+
+void DataEntry::DeleteBinArea(void)
+{
+ if (BinArea && SelfArea)
+ {
+ delete[] BinArea;
+ BinArea = NULL;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Private
+
+//-----------------------------------------------------------------------------
+// Print
+/**
+ * \brief Prints a DataEntry (Dicom entry)
+ * @param os ostream we want to print in
+ * @param indent Indentation string to be prepended during printing
+ */
+void DataEntry::Print(std::ostream &os, std::string const & )
+{
+ os << "D ";
+ DocEntry::Print(os);
+
+ std::ostringstream s;
+ TSAtr v;
+
+ if( BinArea )
+ {
+ v = GetString();
+ const VRKey &vr = GetVR();
+
+ if( vr == "US" || vr == "SS" )
+ s << " [" << GetString() << "]";
+ else if( vr == "UL" || vr == "SL" )
+ s << " [" << GetString() << "]";
+ else if ( vr == "FL" )
+ s << " [" << GetString() << "]";
+ else if ( vr == "FD" )
+ s << " [" << GetString() << "]";
+ else
+ {
+ if(Global::GetVR()->IsVROfStringRepresentable(vr))
+ {
+ std::string cleanString = Util::CreateCleanString(v); // replace non printable characters by '.'
+ if ( cleanString.length() <= GetMaxSizePrintEntry()
+ || PrintLevel >= 3
+ || IsNotLoaded() )
+ {
+ s << " [" << cleanString << "]";
+ }
+ else
+ {
+ s << " [gdcm::too long for print (" << cleanString.length() << ") ]";
+ }
+ }
+ else
+ {
+ if ( Util::IsCleanArea( GetBinArea(),GetLength() ) )
+ {
+ std::string cleanString =
+ Util::CreateCleanString( BinArea,GetLength() );
+ s << " [" << cleanString << "]";
+ }
+ else
+ {
+ s << " [" << GDCM_BINLOADED << ";"
+ << "length = " << GetLength() << "]";
+ }
+ }
+ }
+ }
+ else
+ {
+ if( IsNotLoaded() )
+ s << " [" << GDCM_NOTLOADED << "]";
+ else if( IsUnfound() )
+ s << " [" << GDCM_UNFOUND << "]";
+ else if( IsUnread() )
+ s << " [" << GDCM_UNREAD << "]";
+ else if ( GetLength() == 0 )
+ s << " []";
+ }
+
+ if( IsPixelData() )
+ s << " (" << GDCM_PIXELDATA << ")";
+
+ // Display the UID value (instead of displaying only the rough code)
+ // First 'clean' trailing character (space or zero)
+ if(BinArea)
+ {
+ const uint16_t &gr = GetGroup();
+ const uint16_t &elt = GetElement();
+ TS *ts = Global::GetTS();
+
+ if (gr == 0x0002)
+ {
+ // Any more to be displayed ?
+ if ( elt == 0x0010 || elt == 0x0002 )
+ {
+ if ( v.length() != 0 ) // for brain damaged headers
+ {
+ if ( ! isdigit((unsigned char)v[v.length()-1]) )
+ {
+ v.erase(v.length()-1, 1);
+ }
+ }
+ s << " ==>\t[" << ts->GetValue(v) << "]";
+ }
+ }
+ else if (gr == 0x0008)
+ {
+ if ( elt == 0x0016 || elt == 0x1150 )
+ {
+ if ( v.length() != 0 ) // for brain damaged headers
+ {
+ if ( ! isdigit((unsigned char)v[v.length()-1]) )
+ {
+ v.erase(v.length()-1, 1);
+ }
+ }
+ s << " ==>\t[" << ts->GetValue(v) << "]";
+ }
+ }
+ else if (gr == 0x0004)
+ {
+ if ( elt == 0x1510 || elt == 0x1512 )
+ {
+ if ( v.length() != 0 ) // for brain damaged headers
+ {
+ if ( ! isdigit((unsigned char)v[v.length()-1]) )
+ {
+ v.erase(v.length()-1, 1);
+ }
+ }
+ s << " ==>\t[" << ts->GetValue(v) << "]";
+ }
+ }
+ }
+
+ os << s.str();
+}
+
+//-----------------------------------------------------------------------------
+} // end namespace gdcm
+
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmDataEntry.h,v $
+ Language: C++
+ Date: $Date: 2005/10/18 08:35:51 $
+ 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 GDCMDATAENTRY_H
+#define GDCMDATAENTRY_H
+
+#include "gdcmDocEntry.h"
+
+#include <iostream>
+
+namespace gdcm
+{
+//-----------------------------------------------------------------------------
+/**
+ * \brief Any Dicom Document (File or DicomDir) contains
+ * a set of DocEntry - Dicom entries -
+ * (when successfuly parsed against a given Dicom dictionary)
+ * DataEntry is an elementary DocEntry (as opposed to SeqEntry).
+ * Depending on the type of its content,
+ */
+class GDCM_EXPORT DataEntry : public DocEntry
+{
+public:
+ DataEntry(DictEntry *e);
+ DataEntry(DocEntry *d);
+ ~DataEntry();
+
+// Print
+ void Print(std::ostream &os = std::cout, std::string const &indent = "");
+
+// Write
+ virtual void WriteContent(std::ofstream *fp, FileType filetype);
+
+// Set/Get datas
+ /// 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
+ /// into a 'string', event if it's physically stored on disk as an integer
+ /// (e.g. : 0x000c returned as "12")
+ //virtual std::string const &GetValue() const { return Value; }
+
+ /// \brief Returns the area value of the current Dicom Entry
+ /// when it's not string-translatable (e.g : LUT table, overlay, icon)
+ uint8_t *GetBinArea() { return BinArea; }
+ void SetBinArea( uint8_t *area, bool self = true );
+ void CopyBinArea( uint8_t *area, uint32_t length );
+
+ void SetValue(const uint32_t &id,const double &val);
+ double GetValue(const uint32_t &id) const;
+ uint32_t GetValueCount(void) const;
+
+ void SetString(std::string const &value);
+ std::string const &GetString() const;
+
+ /// \brief Sets SelfArea
+ void SetSelfArea(bool area) { SelfArea = area; }
+ /// \brief Returns SelfArea
+ bool IsSelfArea() { return SelfArea; }
+
+ // State
+ void SetState(const char &state) { State = state; }
+ const char &GetState() const { return State; }
+ bool IsNotLoaded() { return State == STATE_NOTLOADED; }
+ bool IsUnfound() { return State == STATE_UNFOUND; }
+ bool IsUnread() { return State == STATE_UNREAD; }
+ bool IsGoodValue() { return State == 0; }
+
+ // Flags
+ void SetFlag(const char &flag) { Flag = flag; }
+ const char &GetFlag() const { return Flag; }
+ bool IsPixelData() { return (Flag & FLAG_PIXELDATA) != 0; }
+
+ void Copy(DocEntry *doc);
+
+ /// \brief returns the size threshold above which an element value
+ /// will NOT be *printed* in order no to polute the screen output
+ static const uint32_t &GetMaxSizePrintEntry() { return MaxSizePrintEntry; }
+ /// \brief Header Elements too long will not be printed
+ static void SetMaxSizePrintEntry(const uint32_t &size) { MaxSizePrintEntry = size; }
+
+ typedef enum
+ {
+ STATE_LOADED = 0x00,
+ STATE_NOTLOADED = 0x01,
+ STATE_UNFOUND = 0x02,
+ STATE_UNREAD = 0x03,
+ } TValueState;
+
+ typedef enum
+ {
+ FLAG_NONE = 0x00,
+ FLAG_PIXELDATA = 0x01,
+ } TValueFlag;
+
+protected:
+// Methods :
+ void NewBinArea(void);
+ void DeleteBinArea(void);
+
+// Members :
+ /// \brief memory area to hold 'non std::string' representable values
+ /// (ie : Lookup Tables, overlays, icons)
+ uint8_t *BinArea;
+ /// \brief Whether DataEntry has its own BinArea or not
+ bool SelfArea;
+
+ mutable std::string StrArea;
+
+private:
+ char Flag;
+ char State;
+
+ /// \brief Size threshold above which an element val
+ /// By default, this upper bound is fixed to 64 bytes.
+ static uint32_t MaxSizePrintEntry;
+};
+
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+#endif
+
Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/08/31 16:24:19 $
- Version: $Revision: 1.159 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ Version: $Revision: 1.160 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmFile.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
#include <fstream>
#include <string>
bool DicomDir::Anonymize()
{
- ValEntry *v;
+ DataEntry *v;
// Something clever to be found to forge the Patient names
std::ostringstream s;
int i = 1;
++cc)
{
s << i;
- v = (*cc)->GetValEntry(0x0010, 0x0010) ; // Patient's Name
+ v = (*cc)->GetDataEntry(0x0010, 0x0010) ; // Patient's Name
if (v)
{
- v->SetValue(s.str());
+ v->SetString(s.str());
}
- v = (*cc)->GetValEntry(0x0010, 0x0020) ; // Patient ID
+ v = (*cc)->GetDataEntry(0x0010, 0x0020) ; // Patient ID
if (v)
{
- v->SetValue(" ");
+ v->SetString(" ");
}
- v = (*cc)->GetValEntry(0x0010, 0x0030) ; // Patient's BirthDate
+ v = (*cc)->GetDataEntry(0x0010, 0x0030) ; // Patient's BirthDate
if (v)
{
- v->SetValue(" ");
+ v->SetString(" ");
}
s << "";
i++;
while(tmpSI)
{
d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
- if ( ValEntry* valEntry = dynamic_cast<ValEntry *>(d) )
+ if ( DataEntry *dataEntry = dynamic_cast<DataEntry *>(d) )
{
- v = valEntry->GetValue();
+ v = dataEntry->GetString();
}
else
{
- gdcmWarningMacro( "(0004,1430) not a ValEntry ?!?");
+ gdcmWarningMacro( "(0004,1430) not a DataEntry ?!?");
continue;
}
++it )
{
// get the current file characteristics
- patCurName = (*it)->GetEntryValue(0x0010,0x0010);
- patCurID = (*it)->GetEntryValue(0x0010,0x0011);
- studCurInstanceUID = (*it)->GetEntryValue(0x0020,0x000d);
- studCurID = (*it)->GetEntryValue(0x0020,0x0010);
- serCurInstanceUID = (*it)->GetEntryValue(0x0020,0x000e);
- serCurID = (*it)->GetEntryValue(0x0020,0x0011);
+ patCurName = (*it)->GetEntryString(0x0010,0x0010);
+ patCurID = (*it)->GetEntryString(0x0010,0x0011);
+ studCurInstanceUID = (*it)->GetEntryString(0x0020,0x000d);
+ studCurID = (*it)->GetEntryString(0x0020,0x0010);
+ serCurInstanceUID = (*it)->GetEntryString(0x0020,0x000e);
+ serCurID = (*it)->GetEntryString(0x0020,0x0011);
if ( patCurName != patPrevName || patCurID != patPrevID || first )
{
ListDicomDirElem::const_iterator it;
uint16_t tmpGr, tmpEl;
DictEntry *dictEntry;
- ValEntry *entry;
+ DataEntry *entry;
std::string val;
SQItem *si;
tmpEl = it->Elem;
dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
- entry = new ValEntry( dictEntry ); // Be sure it's never a BinEntry !
+ entry = new DataEntry( dictEntry ); // Be sure it's never a DataEntry !
entry->SetOffset(0); // just to avoid further missprinting
{
// NULL when we Build Up (ex nihilo) a DICOMDIR
// or when we add the META elems
- val = header->GetEntryValue(tmpGr, tmpEl);
+ val = header->GetEntryString(tmpGr, tmpEl);
}
else
{
val = it->Value;
}
- entry->SetValue( val ); // troubles expected when vr=SQ ...
+ entry->SetString( val ); // troubles expected when vr=SQ ...
if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
{
Program: gdcm
Module: $RCSfile: gdcmDicomDirImage.cxx,v $
Language: C++
- Date: $Date: 2005/06/24 10:55:58 $
- Version: $Revision: 1.23 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ 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
=========================================================================*/
#include "gdcmDicomDirImage.h"
-#include "gdcmValEntry.h"
#include "gdcmGlobal.h"
+#include "gdcmDataEntry.h"
namespace gdcm
{
{
if ( (*i)->GetGroup() == 0x0004 && (*i)->GetElement() == 0x1500 )
{
- os << (dynamic_cast<ValEntry *>(*i))->GetValue(); //FIXME
+ if( dynamic_cast<DataEntry *>(*i) )
+ os << (dynamic_cast<DataEntry *>(*i))->GetString();
}
}
os << std::endl;
Program: gdcm
Module: $RCSfile: gdcmDicomDirObject.cxx,v $
Language: C++
- Date: $Date: 2005/07/12 17:08:12 $
- Version: $Revision: 1.20 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ 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
#include "gdcmDicomDirObject.h"
#include "gdcmGlobal.h"
#include "gdcmDebug.h"
-#include "gdcmValEntry.h"
#include "gdcmDictSet.h"
+#include "gdcmDataEntry.h"
namespace gdcm
{
ListDicomDirMetaElem::const_iterator it;
uint16_t tmpGr,tmpEl;
DictEntry *dictEntry;
- ValEntry *entry;
+ DataEntry *entry;
// for all the Elements found in they own part of the DicomDir dict.
for(it = elemList.begin(); it != elemList.end(); ++it)
tmpGr = it->Group;
tmpEl = it->Elem;
dictEntry = Global::GetDicts()->GetDefaultPubDict()->GetEntry(tmpGr,tmpEl);
- entry = new ValEntry(dictEntry);
+ entry = new DataEntry(dictEntry);
entry->SetOffset(0); // just to avoid further missprinting
- entry->SetValue(it->Value);
+ entry->SetString(it->Value);
AddEntry(entry);
}
Program: gdcm
Module: $RCSfile: gdcmDicomDirVisit.cxx,v $
Language: C++
- Date: $Date: 2005/07/08 19:07:12 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ 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
=========================================================================*/
#include "gdcmDicomDirVisit.h"
-#include "gdcmValEntry.h"
#include "gdcmGlobal.h"
+#include "gdcmDataEntry.h"
namespace gdcm
{
{
if ( (*i)->GetGroup() == 0x0004 && (*i)->GetElement() == 0x1500 )
{
- os << (dynamic_cast<ValEntry *>(*i))->GetValue(); //FIXME // ????
+ if( dynamic_cast<DataEntry *>(*i) )
+ os << (dynamic_cast<DataEntry *>(*i))->GetString();
}
}
os << std::endl;
Program: gdcm
Module: $RCSfile: gdcmDictEntry.h,v $
Language: C++
- Date: $Date: 2005/07/11 14:40:40 $
- Version: $Revision: 1.35 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ Version: $Revision: 1.36 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// \brief tells if the V(alue) R(epresentation) is known (?!)
/// @return
- bool IsVRUnknown() { return VR == GDCM_UNKNOWN; }
+ bool IsVRUnknown() const { return VR == GDCM_UNKNOWN; }
/// \brief tells if the V(alue) M(ultiplicity) is known (?!)
/// @return
- bool IsVMUnknown() { return VM == GDCM_UNKNOWN; }
+ bool IsVMUnknown() const { return VM == GDCM_UNKNOWN; }
/// \brief Returns the Dicom Group Number of the current DictEntry
/// @return the Dicom Group Number
- uint16_t GetGroup() { return Group; }
+ const uint16_t &GetGroup() const { return Group; }
/// \brief Returns the Dicom Element Number of the current DictEntry
/// @return the Dicom Element Number
- uint16_t GetElement() { return Element; }
+ const uint16_t &GetElement() const { return Element; }
/// \brief Returns the Dicom Value Representation of the current
/// DictEntry
Program: gdcm
Module: $RCSfile: gdcmDocEntry.cxx,v $
Language: C++
- Date: $Date: 2005/09/21 09:44:59 $
- Version: $Revision: 1.69 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ Version: $Revision: 1.70 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
/**
- * \brief Writes the common part of any ValEntry, BinEntry, SeqEntry
+ * \brief Writes the common part of any DataEntry, SeqEntry
* @param fp already open ofstream pointer
* @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
*/
//-----------------------------------------------------------------------------
// Print
/**
- * \brief Prints the common part of ValEntry, BinEntry, SeqEntry
+ * \brief Prints the common part of DataEntry, SeqEntry
* @param os ostream we want to print in
* @param indent Indentation string to be prepended during printing
*/
Program: gdcm
Module: $RCSfile: gdcmDocEntry.h,v $
Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- Version: $Revision: 1.49 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ Version: $Revision: 1.50 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
class File;
-class ValEntry;
-class BinEntry;
class SeqEntry;
//-----------------------------------------------------------------------------
DictEntry * GetDictEntry() { return DicomDict; }
/// Returns the Dicom Group number of the current Dicom entry
- uint16_t GetGroup() { return DicomDict->GetGroup(); }
+ const uint16_t &GetGroup() const { return DicomDict->GetGroup(); }
/// Returns the Dicom Element number of the current Dicom entry
- uint16_t GetElement() { return DicomDict->GetElement();}
+ const uint16_t &GetElement() const { return DicomDict->GetElement();}
/// Set the 'key' of the current Dicom entry
void SetKey( TagKey const &key ) { Key = key; }
/// \brief Returns offset (since the beginning of the file, including
/// the File Preamble, if any) of the value of the current Dicom entry
/// \warning offset of the *value*, not of the Dicom entry
- size_t GetOffset() { return Offset; }
+ const size_t &GetOffset() const { return Offset; }
/// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
/// Dicom entry
/// \warning this value is the one stored in the Dicom header but not
/// mandatoryly the one thats's used (in case on SQ, or delimiters,
/// the usable length is set to zero)
- uint32_t GetReadLength() { return ReadLength; }
+ const uint32_t &GetReadLength() const { return ReadLength; }
/// \brief Sets both 'Read Length' and 'Usable Length' of the current
/// Dicom entry
- void SetLength(uint32_t l) { Length = l; }
+ virtual void SetLength(uint32_t l) { Length = l; }
/// \brief Returns the actual value length of the current Dicom entry
/// \warning this value is not *always* the one stored in the Dicom header
/// in case of well knowned bugs
- uint32_t GetLength() { return Length; }
+ const uint32_t &GetLength() const { return Length; }
uint32_t GetFullLength();
/// \brief Tells us if the current Dicom entry was checked as ImplicitVr
/// @return true if the current Dicom entry was checked as ImplicitVr
- bool IsImplicitVR() { return ImplicitVR; }
+ bool IsImplicitVR() const { return ImplicitVR; }
/// \brief Tells us if the VR of the current Dicom entry is Unknown
/// @return true if the VR is unknown
- bool IsVRUnknown() { return DicomDict->IsVRUnknown(); }
+ bool IsVRUnknown() const { return DicomDict->IsVRUnknown(); }
/// \brief Tells us if the VM of the current Dicom entry is Unknown
/// @return true if the VM is unknown
- bool IsVMUnknown() { return DicomDict->IsVMUnknown(); }
+ bool IsVMUnknown() const { return DicomDict->IsVMUnknown(); }
bool IsItemDelimitor();
bool IsItemStarter();
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.cxx,v $
Language: C++
- Date: $Date: 2005/09/06 15:28:49 $
- Version: $Revision: 1.59 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ Version: $Revision: 1.60 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmGlobal.h"
#include "gdcmDocEntry.h"
#include "gdcmSeqEntry.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmUtil.h"
+#include "gdcmDataEntry.h"
+#include "gdcmVR.h"
namespace gdcm
{
* @return Corresponding element value when it exists,
* and the string GDCM_UNFOUND otherwise.
*/
-std::string DocEntrySet::GetEntryValue(uint16_t group, uint16_t elem)
+std::string DocEntrySet::GetEntryString(uint16_t group, uint16_t elem)
{
- ContentEntry *entry = dynamic_cast<ContentEntry *>(GetDocEntry(group,elem));
+ DataEntry *entry = dynamic_cast<DataEntry *>(GetDocEntry(group,elem));
if ( entry )
- return entry->GetValue();
+ {
+ if( entry->IsNotLoaded() )
+ return GDCM_NOTLOADED;
+ if( entry->IsUnfound() )
+ return GDCM_UNFOUND;
+ if( entry->IsUnread() )
+ return GDCM_UNREAD;
+ return entry->GetString();
+ }
return GDCM_UNFOUND;
}
*/
void *DocEntrySet::GetEntryBinArea(uint16_t group, uint16_t elem)
{
- BinEntry *entry = GetBinEntry(group, elem);
+ DataEntry *entry = GetDataEntry(group, elem);
if ( entry )
return entry->GetBinArea();
return 0;
}
/**
- * \brief Return the value of the BinEntry if it's "std::string representable"
+ * \brief Return the value of the DataEntry if it's "std::string representable"
* @param group Group number of the searched tag.
* @param elem Element number of the searched tag.
* @return Corresponding element value when it's "std::string representable"
if ( !d )
return GDCM_UNFOUND;
- if (ValEntry *v = dynamic_cast<ValEntry *>(d))
- return v->GetValue();
-
- if (BinEntry *b = dynamic_cast<BinEntry *>(d))
+ DataEntry *de = dynamic_cast<DataEntry *>(d);
+ if ( de )
{
- uint8_t *a = b->GetBinArea();
- if (!b)
+ if( de->IsNotLoaded() )
return GDCM_NOTLOADED;
- // TODO : unify those two methods.
- if (Util::IsCleanArea(a, b->GetLength()) )
- return Util::CreateCleanString(a, b->GetLength());
+ if( de->IsUnfound() )
+ return GDCM_UNFOUND;
+ if( de->IsUnread() )
+ return GDCM_UNREAD;
+ }
+
+ if( Global::GetVR()->IsVROfStringRepresentable( de->GetVR() ) )
+ return de->GetString();
+ else
+ {
+ uint8_t *a = de->GetBinArea();
+ if( Util::IsCleanArea(a, de->GetLength()) )
+ return Util::CreateCleanString(a, de->GetLength());
}
return GDCM_NOTASCII;
}
/**
* \brief Same as \ref Document::GetDocEntry except it only
* returns a result when the corresponding entry is of type
- * ValEntry.
+ * DataEntry.
* @param group Group number of the searched Dicom Element
* @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding ValEntry.
+ * @return When present, the corresponding DataEntry.
*/
-ValEntry *DocEntrySet::GetValEntry(uint16_t group, uint16_t elem)
+DataEntry *DocEntrySet::GetDataEntry(uint16_t group, uint16_t elem)
{
DocEntry *currentEntry = GetDocEntry(group, elem);
if ( !currentEntry )
return NULL;
- return dynamic_cast<ValEntry*>(currentEntry);
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * BinEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding BinEntry.
- */
-BinEntry *DocEntrySet::GetBinEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- gdcmWarningMacro( "No corresponding BinEntry " << std::hex << group <<
- "," << elem);
- return NULL;
- }
-
- return dynamic_cast<BinEntry*>(currentEntry);
+ return dynamic_cast<DataEntry*>(currentEntry);
}
/**
* @param group group number of the Dicom Element to modify
* @param elem element number of the Dicom Element to modify
*/
-bool DocEntrySet::SetValEntry(std::string const &content,
- uint16_t group, uint16_t elem)
+bool DocEntrySet::SetEntryString(std::string const &content,
+ uint16_t group, uint16_t elem)
{
- ValEntry *entry = GetValEntry(group, elem);
+ DataEntry *entry = GetDataEntry(group, elem);
if (!entry )
{
- gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group <<
+ gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
"," << elem << " element (try promotion first).");
return false;
}
- return SetValEntry(content,entry);
+ return SetEntryString(content,entry);
}
/**
* @param group group number of the Dicom Element to modify
* @param elem element number of the Dicom Element to modify
*/
-bool DocEntrySet::SetBinEntry(uint8_t *content, int lgth,
- uint16_t group, uint16_t elem)
+bool DocEntrySet::SetEntryBinArea(uint8_t *content, int lgth,
+ uint16_t group, uint16_t elem)
{
- BinEntry *entry = GetBinEntry(group, elem);
+ DataEntry *entry = GetDataEntry(group, elem);
if (!entry )
{
- gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group <<
+ gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
"," << elem << " element (try promotion first).");
return false;
}
- return SetBinEntry(content,lgth,entry);
+ return SetEntryBinArea(content,lgth,entry);
}
/**
* @param content new value (string) to substitute with
* @param entry Entry to be modified
*/
-bool DocEntrySet::SetValEntry(std::string const &content, ValEntry *entry)
+bool DocEntrySet::SetEntryString(std::string const &content, DataEntry *entry)
{
if (entry)
{
- entry->SetValue(content);
+ entry->SetString(content);
return true;
}
return false;
}
/**
- * \brief Accesses an existing BinEntry (i.e. a Dicom Element)
+ * \brief Accesses an existing DataEntry (i.e. a Dicom Element)
* and modifies it's content with the given value.
* @param content new value (void* -> uint8_t*) to substitute with
* @param entry Entry to be modified
* @param lgth new value length
*/
-bool DocEntrySet::SetBinEntry(uint8_t *content, int lgth, BinEntry *entry)
+bool DocEntrySet::SetEntryBinArea(uint8_t *content, int lgth, DataEntry *entry)
{
if (entry)
{
- entry->SetBinArea(content);
entry->SetLength(lgth);
- entry->SetValue(GDCM_BINLOADED);
+ entry->SetBinArea(content);
return true;
}
return false;
* \return pointer to the modified/created Header Entry (NULL when creation
* failed).
*/
-ValEntry *DocEntrySet::InsertValEntry(std::string const &value,
- uint16_t group, uint16_t elem,
- TagName const &vr )
+DataEntry *DocEntrySet::InsertEntryString(std::string const &value,
+ uint16_t group, uint16_t elem,
+ TagName const &vr )
{
- ValEntry *valEntry = 0;
+ DataEntry *dataEntry = 0;
DocEntry *currentEntry = GetDocEntry( group, elem );
if (currentEntry)
{
- valEntry = dynamic_cast<ValEntry *>(currentEntry);
+ dataEntry = dynamic_cast<DataEntry *>(currentEntry);
// Verify the VR
- if ( valEntry )
- if ( valEntry->GetVR()!=vr )
- valEntry = NULL;
+ if ( dataEntry )
+ if ( dataEntry->GetVR()!=vr )
+ dataEntry = NULL;
- // if currentEntry doesn't correspond to the requested valEntry
- if ( !valEntry)
+ // if currentEntry doesn't correspond to the requested dataEntry
+ if ( !dataEntry)
{
if ( !RemoveEntry(currentEntry) )
{
gdcmWarningMacro( "Removal of previous DocEntry failed.");
-
return NULL;
}
}
}
- // Create a new valEntry if necessary
- if ( !valEntry )
+ // Create a new dataEntry if necessary
+ if ( !dataEntry )
{
- valEntry = NewValEntry( group, elem, vr );
+ dataEntry = NewDataEntry( group, elem, vr );
- if ( !AddEntry(valEntry) )
+ if ( !AddEntry(dataEntry) )
{
gdcmWarningMacro("AddEntry failed although this is a creation.");
- delete valEntry;
+ delete dataEntry;
return NULL;
}
}
- // Set the binEntry value
- SetValEntry(value, valEntry); // The std::string value
- return valEntry;
+ // Set the dataEntry value
+ SetEntryString(value, dataEntry); // The std::string value
+ return dataEntry;
}
/**
* \return pointer to the modified/created Header Entry (NULL when creation
* failed).
*/
-BinEntry *DocEntrySet::InsertBinEntry(uint8_t *binArea, int lgth,
- uint16_t group, uint16_t elem,
- TagName const &vr )
+DataEntry *DocEntrySet::InsertEntryBinArea(uint8_t *binArea, int lgth,
+ uint16_t group, uint16_t elem,
+ TagName const &vr )
{
- BinEntry *binEntry = 0;
+ DataEntry *dataEntry = 0;
DocEntry *currentEntry = GetDocEntry( group, elem );
// Verify the currentEntry
if (currentEntry)
{
- binEntry = dynamic_cast<BinEntry *>(currentEntry);
+ dataEntry = dynamic_cast<DataEntry *>(currentEntry);
// Verify the VR
- if ( binEntry )
- if ( binEntry->GetVR()!=vr )
- binEntry = NULL;
+ if ( dataEntry )
+ if ( dataEntry->GetVR()!=vr )
+ dataEntry = NULL;
- // if currentEntry doesn't correspond to the requested valEntry
- if ( !binEntry)
+ // if currentEntry doesn't correspond to the requested dataEntry
+ if ( !dataEntry)
{
if ( !RemoveEntry(currentEntry) )
{
gdcmWarningMacro( "Removal of previous DocEntry failed.");
-
return NULL;
}
}
}
- // Create a new binEntry if necessary
- if ( !binEntry)
+ // Create a new dataEntry if necessary
+ if ( !dataEntry)
{
- binEntry = NewBinEntry(group, elem, vr);
+ dataEntry = NewDataEntry(group, elem, vr);
- if ( !AddEntry(binEntry) )
+ if ( !AddEntry(dataEntry) )
{
gdcmWarningMacro( "AddEntry failed although this is a creation.");
- delete binEntry;
+ delete dataEntry;
return NULL;
}
}
- // Set the binEntry value
+ // Set the dataEntry value
uint8_t *tmpArea;
if ( lgth>0 && binArea )
{
{
tmpArea = 0;
}
- if ( !SetBinEntry(tmpArea,lgth,binEntry) )
+ if ( !SetEntryBinArea(tmpArea,lgth,dataEntry) )
{
if ( tmpArea )
{
}
}
- return binEntry;
+ return dataEntry;
}
/**
* @param elem Element number of the new Entry
* @param vr V(alue) R(epresentation) of the new Entry
*/
-ValEntry *DocEntrySet::NewValEntry(uint16_t group,uint16_t elem,
- TagName const &vr)
-{
- DictEntry *dictEntry = GetDictEntry(group, elem, vr);
- gdcmAssertMacro(dictEntry);
-
- ValEntry *newEntry = new ValEntry(dictEntry);
- if (!newEntry)
- {
- gdcmWarningMacro( "Failed to allocate ValEntry");
- return 0;
- }
- return newEntry;
-}
-
-
-/**
- * \brief Build a new Bin Entry from all the low level arguments.
- * Check for existence of dictionary entry, and build
- * a default one when absent.
- * @param group Group number of the new Entry
- * @param elem Element number of the new Entry
- * @param vr V(alue) R(epresentation) of the new Entry
- */
-BinEntry *DocEntrySet::NewBinEntry(uint16_t group, uint16_t elem,
+DataEntry *DocEntrySet::NewDataEntry(uint16_t group,uint16_t elem,
TagName const &vr)
{
DictEntry *dictEntry = GetDictEntry(group, elem, vr);
gdcmAssertMacro(dictEntry);
- BinEntry *newEntry = new BinEntry(dictEntry);
+ DataEntry *newEntry = new DataEntry(dictEntry);
if (!newEntry)
{
- gdcmWarningMacro( "Failed to allocate BinEntry");
+ gdcmWarningMacro( "Failed to allocate DataEntry");
return 0;
}
return newEntry;
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.h,v $
Language: C++
- Date: $Date: 2005/09/06 15:28:49 $
- Version: $Revision: 1.56 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ Version: $Revision: 1.57 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
//-----------------------------------------------------------------------------
class DocEntry;
-class ValEntry;
-class BinEntry;
+class DataEntry;
class SeqEntry;
class DictEntry;
/// Gets the next entry of any type of set
virtual DocEntry *GetNextEntry()=0;
- virtual std::string GetEntryValue(uint16_t group, uint16_t elem);
+ 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)
virtual DocEntry *GetDocEntry(uint16_t group, uint16_t elem) = 0;
- /// \brief Gets a ValEntry, identified by its (group, elem)
- ValEntry *GetValEntry(uint16_t group, uint16_t elem);
- /// \brief Gets a BinEntry, identified by its (group,elem)
- BinEntry *GetBinEntry(uint16_t group, uint16_t elem);
+ /// \brief Gets a DataEntry, identified by its (group, elem)
+ DataEntry *GetDataEntry(uint16_t group, uint16_t elem);
/// \brief Gets a SeqEntry, identified by its (group,elem)
SeqEntry *GetSeqEntry(uint16_t group, uint16_t elem);
- bool SetValEntry(std::string const &content,
- uint16_t group, uint16_t elem);
- bool SetBinEntry(uint8_t *content, int lgth,
- uint16_t group, uint16_t elem);
- bool SetValEntry(std::string const &content, ValEntry *entry);
- bool SetBinEntry(uint8_t *content, int lgth, BinEntry *entry);
-
- ValEntry *InsertValEntry(std::string const &value,
- uint16_t group, uint16_t elem,
- TagName const &vr = GDCM_UNKNOWN);
- BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
+ bool SetEntryString(std::string const &content,
+ uint16_t group, uint16_t elem);
+ bool SetEntryBinArea(uint8_t *content, int lgth,
+ uint16_t group, uint16_t elem);
+ bool SetEntryString(std::string const &content, DataEntry *entry);
+ bool SetEntryBinArea(uint8_t *content, int lgth, DataEntry *entry);
+
+ DataEntry *InsertEntryString(std::string const &value,
+ uint16_t group, uint16_t elem,
+ TagName const &vr = GDCM_UNKNOWN);
+ DataEntry *InsertEntryBinArea(uint8_t *binArea, int lgth,
uint16_t group, uint16_t elem,
TagName const &vr = GDCM_UNKNOWN);
SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
virtual bool CheckIfEntryExist(uint16_t group, uint16_t elem);
// DocEntry related utilities
- ValEntry *NewValEntry(uint16_t group,uint16_t elem,
- TagName const &vr = GDCM_UNKNOWN);
- BinEntry *NewBinEntry(uint16_t group, uint16_t elem,
+ DataEntry *NewDataEntry(uint16_t group,uint16_t elem,
TagName const &vr = GDCM_UNKNOWN);
SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem);
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/10/17 14:55:01 $
- Version: $Revision: 1.288 $
+ Date: $Date: 2005/10/18 08:35:49 $
+ Version: $Revision: 1.289 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
=========================================================================*/
#include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmSeqEntry.h"
#include "gdcmGlobal.h"
#include "gdcmUtil.h"
#include "gdcmDictSet.h"
#include "gdcmDocEntrySet.h"
#include "gdcmSQItem.h"
+#include "gdcmDataEntry.h"
#include <vector>
#include <iomanip>
if ( ! IsDocumentModified ) // Nothing to do !
return true;
- // if ( Filename == fileName )
- // {
- // gdcmWarningMacro( "The file was already parsed inside this "
- // << "gdcm::Document (its name is: "
- // << Filename.c_str() );
- // return true;
- // }
-
- //gdcmWarningMacro( "A file was already parsed inside this "
- // << "gdcm::Document (previous name was: "
- // << Filename.c_str() << ". New name is :"
- // << fileName );
- // clean out the Entries, if already parsed
- // (probabely a mistake from the user)
-
ClearEntry();
Fp = 0;
// Load 'non string' values
- std::string PhotometricInterpretation = GetEntryValue(0x0028,0x0004);
+ std::string PhotometricInterpretation = GetEntryString(0x0028,0x0004);
if ( PhotometricInterpretation == "PALETTE COLOR " )
{
// FIXME
/// defined as having an US Value Representation in the public
/// dictionary. BUT the semantics implied by the three following
/// lines state that the corresponding tag contents are in fact
- /// the ones of a BinEntry.
+ /// the ones of a DataEntry.
/// In order to fix things "Quick and Dirty" the dictionary was
/// altered on PURPOSE but now contains a WRONG value.
/// In order to fix things and restore the dictionary to its
/// correct value, one needs to decided of the semantics by deciding
/// whether the following tags are either :
- /// - multivaluated US, and hence loaded as ValEntry, but afterwards
- /// also used as BinEntry, which requires the proper conversion,
- /// - OW, and hence loaded as BinEntry, but afterwards also used
- /// as ValEntry, which requires the proper conversion.
+ /// - multivaluated US, and hence loaded as DataEntry, but afterwards
+ /// also used as DataEntry, which requires the proper conversion,
+ /// - OW, and hence loaded as DataEntry, but afterwards also used
+ /// as DataEntry, which requires the proper conversion.
LoadEntryBinArea(0x0028,0x1201); // R LUT
LoadEntryBinArea(0x0028,0x1202); // G LUT
LoadEntryBinArea(0x0028,0x1203); // B LUT
SQItem *sqi= modLutSeq->GetFirstSQItem();
if ( sqi != 0 )
{
- BinEntry *b = sqi->GetBinEntry(0x0028,0x3006);
- if ( b != 0 )
+ DataEntry *dataEntry = sqi->GetDataEntry(0x0028,0x3006);
+ if ( dataEntry != 0 )
{
- if ( b->GetLength() != 0 )
+ if ( dataEntry->GetLength() != 0 )
{
- LoadEntryBinArea(b); //LUT Data (CTX dependent)
+ LoadEntryBinArea(dataEntry); //LUT Data (CTX dependent)
}
}
}
continue;
}
- if ( dynamic_cast<ValEntry *>(d) )
- {
- LoadDocEntry(d, true);
- continue;
- }
-
- BinEntry *b = dynamic_cast<BinEntry *>(d);
- if ( b )
- {
- LoadEntryBinArea(b);
- b->SetValue(GDCM_BINLOADED);
- continue;
- }
-
- if ( dynamic_cast<SeqEntry *>(d) )
- {
- gdcmWarningMacro( "You cannot 'ForceLoad' a SeqEntry :" << std::hex
- << (*it).Group <<"|"<< (*it).Elem );
- continue;
- }
+ LoadDocEntry(d, true);
}
CloseFile();
// we switch lineNumber and columnNumber
//
std::string RecCode;
- RecCode = GetEntryValue(0x0008, 0x0010); // recognition code (RET)
+ RecCode = GetEntryString(0x0008, 0x0010); // recognition code (RET)
if (RecCode == "ACRNEMA_LIBIDO_1.1" ||
RecCode == "CANRME_AILIBOD1_1." ) // for brain-damaged softwares
// with "little-endian strings"
{
Filetype = ACR_LIBIDO;
- std::string rows = GetEntryValue(0x0028, 0x0010);
- std::string columns = GetEntryValue(0x0028, 0x0011);
- SetValEntry(columns, 0x0028, 0x0010);
- SetValEntry(rows , 0x0028, 0x0011);
+ std::string rows = GetEntryString(0x0028, 0x0010);
+ std::string columns = GetEntryString(0x0028, 0x0011);
+ SetEntryString(columns, 0x0028, 0x0010);
+ SetEntryString(rows , 0x0028, 0x0011);
}
// --- End of ACR-LibIDO kludge ---
return true;
// The entry might be present but not loaded (parsing and loading
// happen at different stages): try loading and proceed with check...
LoadDocEntrySafe(entry);
- if (ValEntry *valEntry = dynamic_cast< ValEntry* >(entry) )
+ if (DataEntry *dataEntry = dynamic_cast<DataEntry *>(entry) )
{
- std::string transfer = valEntry->GetValue();
+ std::string transfer = dataEntry->GetString();
// The actual transfer (as read from disk) might be padded. We
// first need to remove the potential padding. We can make the
// weak assumption that padding was not executed with digits...
while ( !isdigit((unsigned char)transfer[transfer.length()-1]) )
{
transfer.erase(transfer.length()-1, 1);
+ if ( transfer.length() == 0 )
+ {
+ // for brain damaged headers
+ return GDCM_UNKNOWN;
+ }
}
return transfer;
}
std::string Document::GetTransferSyntaxName()
{
// use the TS (TS : Transfer Syntax)
- std::string transferSyntax = GetEntryValue(0x0002,0x0010);
+ std::string transferSyntax = GetEntryString(0x0002,0x0010);
if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) )
{
void Document::LoadEntryBinArea(uint16_t group, uint16_t elem)
{
// Search the corresponding DocEntry
- DocEntry *docElement = GetDocEntry(group, elem);
- if ( !docElement )
+ DocEntry *docEntry = GetDocEntry(group, elem);
+ if ( !docEntry )
{
gdcmWarningMacro(std::hex << group << "|" << elem
<< "doesn't exist" );
return;
}
- BinEntry *binElement = dynamic_cast<BinEntry *>(docElement);
- if ( !binElement )
+ DataEntry *dataEntry = dynamic_cast<DataEntry *>(docEntry);
+ if ( !dataEntry )
{
gdcmWarningMacro(std::hex << group << "|" << elem
- << "is NOT a BinEntry");
+ << "is NOT a DataEntry");
return;
}
- LoadEntryBinArea(binElement);
+ LoadEntryBinArea(dataEntry);
}
/**
* when a string is not suitable
* @param elem Entry whose binArea is going to be loaded
*/
-void Document::LoadEntryBinArea(BinEntry *elem)
+void Document::LoadEntryBinArea(DataEntry *entry)
{
- if (elem->GetBinArea() )
+ if( entry->GetBinArea() )
return;
bool openFile = !Fp;
if ( openFile )
OpenFile();
- size_t o =(size_t)elem->GetOffset();
+ size_t o =(size_t)entry->GetOffset();
Fp->seekg(o, std::ios::beg);
- size_t l = elem->GetLength();
- uint8_t *a = new uint8_t[l];
- if ( !a )
+ size_t l = entry->GetLength();
+ uint8_t *data = new uint8_t[l];
+ if ( !data )
{
- gdcmWarningMacro( "Cannot allocate BinEntry content for : "
- << std::hex << elem->GetGroup()
- << "|" << elem->GetElement() );
+ gdcmWarningMacro( "Cannot allocate DataEntry content for : "
+ << std::hex << entry->GetGroup()
+ << "|" << entry->GetElement() );
return;
}
- Fp->read((char*)a, l);
+ // Read the datas
+ Fp->read((char*)data, l);
if ( Fp->fail() || Fp->eof() )
{
- delete[] a;
+ delete[] data;
+ entry->SetState(DataEntry::STATE_UNREAD);
return;
}
- elem->SetBinArea(a);
+ // Swap the data content if necessary
+ uint32_t i;
+ unsigned short vrLgth = Global::GetVR()->GetAtomicElementLength(entry->GetVR());
+ if( entry->GetVR() == "OW" )
+ vrLgth = 1;
+
+ switch(vrLgth)
+ {
+ case 2:
+ {
+ uint16_t *data16 = (uint16_t *)data;
+ for(i=0;i<l/vrLgth;i++)
+ data16[i] = SwapShort(data16[i]);
+ break;
+ }
+ case 4:
+ {
+ uint32_t *data32 = (uint32_t *)data;
+ for(i=0;i<l/vrLgth;i++)
+ data32[i] = SwapLong(data32[i]);
+ break;
+ }
+ case 8:
+ {
+ gdcmWarningMacro("Can't swap 64 bits datas");
+/* uint64_t *data64 = (uint64_t *)data;
+ for(i=0;i<l/vrLgth;i++)
+ data64[i] = SwapLongLong(data64[i]);*/
+ break;
+ }
+ }
+
+ entry->SetBinArea(data);
if ( openFile )
CloseFile();
bool Document::operator<(Document &document)
{
// Patient Name
- std::string s1 = GetEntryValue(0x0010,0x0010);
- std::string s2 = document.GetEntryValue(0x0010,0x0010);
+ std::string s1 = GetEntryString(0x0010,0x0010);
+ std::string s2 = document.GetEntryString(0x0010,0x0010);
if (s1 < s2)
{
return true;
else
{
// Patient ID
- s1 = GetEntryValue(0x0010,0x0020);
- s2 = document.GetEntryValue(0x0010,0x0020);
+ s1 = GetEntryString(0x0010,0x0020);
+ s2 = document.GetEntryString(0x0010,0x0020);
if ( s1 < s2 )
{
return true;
else
{
// Study Instance UID
- s1 = GetEntryValue(0x0020,0x000d);
- s2 = document.GetEntryValue(0x0020,0x000d);
+ s1 = GetEntryString(0x0020,0x000d);
+ s2 = document.GetEntryString(0x0020,0x000d);
if ( s1 < s2 )
{
return true;
else
{
// Serie Instance UID
- s1 = GetEntryValue(0x0020,0x000e);
- s2 = document.GetEntryValue(0x0020,0x000e);
+ s1 = GetEntryString(0x0020,0x000e);
+ s2 = document.GetEntryString(0x0020,0x000e);
if ( s1 < s2 )
{
return true;
long l_max, bool delim_mode)
{
DocEntry *newDocEntry;
- ValEntry *newValEntry;
- BinEntry *newBinEntry;
+ DataEntry *newDataEntry;
SeqEntry *newSeqEntry;
VRKey vr;
bool used; // will be set to false when something wrong happens to an Entry.
newDocEntry = ReadNextDocEntry( );
// FIXME :
- // Private tag, in IMplicit VR are defaulted as a BinEntry,
+ // Private tag, in IMplicit VR are defaulted as a DataEntry,
// Very often they are only composed of Printable characters,
- // and could be defaulted as a ValEntry.
+ // and could be defaulted as a DataEntry.
// It's too late to do the Job
// (we should check the value, but we know it after LoadDocEntry ...)
- // --> in next gdcm major release let's unify ValEntry and BinEntry !
// Uncoment this printf line to be able to 'follow' the DocEntries
// when something *very* strange happens
}
used = true;
- newValEntry = dynamic_cast<ValEntry*>(newDocEntry);
- newBinEntry = dynamic_cast<BinEntry*>(newDocEntry);
+ newDataEntry = dynamic_cast<DataEntry*>(newDocEntry);
- if ( newValEntry || newBinEntry )
+ if ( newDataEntry )
{
- //////////////////////////// ContentEntry
- if ( newBinEntry )
- {
- vr = newDocEntry->GetVR();
- if ( Filetype == ExplicitVR &&
- !Global::GetVR()->IsVROfBinaryRepresentable(vr) )
- {
- ////// Neither ValEntry NOR BinEntry: should mean UNKOWN VR
- gdcmWarningMacro( std::hex << newDocEntry->GetGroup()
- << "|" << newDocEntry->GetElement()
- << " : Neither Valentry, nor BinEntry."
- "Probably unknown VR.");
- }
-
- //////////////////// BinEntry or UNKOWN VR:
-
- // When "this" is a Document the Key is simply of the
- // form ( group, elem )...
- //if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
- //{
- // newBinEntry->SetKey( newBinEntry->GetKey() );
- //}
- // but when "this" is a SQItem, we are inserting this new
- // valEntry in a sequence item, and the key has the
- // generalized form (refer to \ref BaseTagKey):
+ //////////////////////////// DataEntry
+ vr = newDocEntry->GetVR();
+ if ( Filetype == ExplicitVR &&
+ !Global::GetVR()->IsVROfBinaryRepresentable(vr) )
+ {
+ ////// No DataEntry: should mean UNKOWN VR
+ gdcmWarningMacro( std::hex << newDocEntry->GetGroup()
+ << "|" << newDocEntry->GetElement()
+ << " : No DataEntry."
+ "Probably unknown VR.");
+ }
- // time waste hunting
- //if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) )
- //{
- // newBinEntry->SetKey( parentSQItem->GetBaseTagKey()
- // + newBinEntry->GetKey() );
- //}
-
- if ( !set->AddEntry( newBinEntry ) )
- {
- gdcmWarningMacro( "in ParseDES : cannot add a BinEntry "
- << newBinEntry->GetKey()
- << " (at offset : "
- << newBinEntry->GetOffset() << " )" );
- used=false;
- }
- else
- {
- // Load only if we can add (not a duplicate key)
- LoadDocEntry( newBinEntry );
- }
- } // end BinEntry
+ if ( !set->AddEntry( newDataEntry ) )
+ {
+ gdcmWarningMacro( "in ParseDES : cannot add a DataEntry "
+ << newDataEntry->GetKey()
+ << " (at offset : "
+ << newDataEntry->GetOffset() << " )" );
+ used=false;
+ }
else
{
- /////////////////////// ValEntry
-
- // When "set" is a Document, then we are at the top of the
- // hierarchy and the Key is simply of the form ( group, elem )...
- //if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
- //{
- // newValEntry->SetKey( newValEntry->GetKey() );
- //}
- // ...but when "set" is a SQItem, we are inserting this new
- // valEntry in a sequence item. Hence the key has the
- // generalized form (refer to \ref BaseTagKey):
-
- // time waste hunting
- //if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) )
- //{
- // newValEntry->SetKey( parentSQItem->GetBaseTagKey()
- // + newValEntry->GetKey() );
- //}
-
- if ( !set->AddEntry( newValEntry ) )
- {
- gdcmWarningMacro( "in ParseDES : cannot add a ValEntry "
- << newValEntry->GetKey()
- << " (at offset : "
- << newValEntry->GetOffset() << " )" );
- used=false;
- }
- else
- {
- // Load only if we can add (not a duplicate key)
- LoadDocEntry( newValEntry );
- }
+ // Load only if we can add (not a duplicate key)
+ LoadDocEntry( newDataEntry );
+ }
- if ( newValEntry->GetElement() == 0x0000 ) // if on group length
+ if ( newDataEntry->GetElement() == 0x0000 ) // if on group length
+ {
+ if ( newDataEntry->GetGroup()%2 != 0 ) // if Shadow Group
{
- if ( newValEntry->GetGroup()%2 != 0 ) // if Shadow Group
+ if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr
{
- if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr
+ std::string strLgrGroup = newDataEntry->GetString();
+ int lgrGroup;
+ if ( newDataEntry->IsUnfound() )
{
- std::string strLgrGroup = newValEntry->GetValue();
- int lgrGroup;
- if ( strLgrGroup != GDCM_UNFOUND)
- {
- lgrGroup = atoi(strLgrGroup.c_str());
- Fp->seekg(lgrGroup, std::ios::cur);
- //used = false; // never used
- RemoveEntry( newDocEntry ); // Remove and delete
- // bcc 5.5 is right "assigned a value that's never used"
- // newDocEntry = 0;
- continue;
- }
+ lgrGroup = atoi(strLgrGroup.c_str());
+ Fp->seekg(lgrGroup, std::ios::cur);
+ //used = false; // never used
+ RemoveEntry( newDocEntry ); // Remove and delete
+ // bcc 5.5 is right "assigned a value that's never used"
+ // newDocEntry = 0;
+ continue;
}
}
}
+ }
- bool delimitor = newValEntry->IsItemDelimitor();
+ bool delimitor = newDataEntry->IsItemDelimitor();
- if ( (delimitor) ||
- (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) )
- {
- if ( !used )
- delete newDocEntry;
- break;
- }
+ if ( (delimitor) ||
+ (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) )
+ {
+ if ( !used )
+ delete newDocEntry;
+ break;
}
// Just to make sure we are at the beginning of next entry.
}
// create the current SQItem
SQItem *itemSQ = new SQItem( seqEntry->GetDepthLevel() );
-/*
- std::ostringstream newBase;
- newBase << seqEntry->GetKey()
- << "/"
- << SQItemNumber
- << "#";
- itemSQ->SetBaseTagKey( newBase.str() );
-*/
unsigned int l = newDocEntry->GetReadLength();
if ( l == 0xffffffff )
Fp->seekg( 0, std::ios::beg);
Fp->seekg(offset, std::ios::cur);
-return newEntry;
+ return newEntry;
}
/**
// (fffe e000) tells us an Element is beginning
// (fffe e00d) tells us an Element just ended
// (fffe e0dd) tells us the current SeQuence just ended
- if ( group == 0xfffe )
+ if ( group == 0xfffe || vr == "SQ" )
{
// NO more value field for SQ !
return;
}
+ DataEntry *dataEntryPtr = dynamic_cast< DataEntry* >(entry);
+ if( !dataEntryPtr )
+ {
+ return;
+ }
+
// When the length is zero things are easy:
if ( length == 0 )
{
- ((ValEntry *)entry)->SetValue("");
+ dataEntryPtr->SetBinArea(NULL,true);
return;
}
{
if (length > MaxSizeLoadEntry)
{
- if (BinEntry *binEntryPtr = dynamic_cast< BinEntry* >(entry) )
- {
- s << GDCM_NOTLOADED;
- s << " Ad.:" << (long)entry->GetOffset();
- s << " x(" << std::hex << entry->GetOffset() << ")";
- s << std::dec;
- s << " Lgt:" << entry->GetLength();
- s << " x(" << std::hex << entry->GetLength() << ")";
- binEntryPtr->SetValue(s.str());
- }
- else if (ValEntry *valEntryPtr = dynamic_cast< ValEntry* >(entry) )
- {
- s << GDCM_NOTLOADED;
- s << " Address:" << (long)entry->GetOffset();
- s << " Length:" << entry->GetLength();
- s << " x(" << std::hex << entry->GetLength() << ")";
- valEntryPtr->SetValue(s.str());
- }
- else
- {
- // fusible
- gdcmErrorMacro( "MaxSizeLoadEntry exceeded, neither a BinEntry "
- << "nor a ValEntry ?! Should never print that !" );
- }
+ dataEntryPtr->SetBinArea(NULL,true);
+ dataEntryPtr->SetState(DataEntry::STATE_NOTLOADED);
// to be sure we are at the end of the value ...
Fp->seekg((long)entry->GetOffset()+(long)entry->GetLength(),
}
}
- // When we find a BinEntry not very much can be done :
- if (BinEntry *binEntryPtr = dynamic_cast< BinEntry* >(entry) )
- {
- s << GDCM_BINLOADED;
- binEntryPtr->SetValue(s.str());
- LoadEntryBinArea(binEntryPtr); // last one, not to erase length !
- return;
- }
-
- if ( IsDocEntryAnInteger(entry) )
- {
- uint32_t NewInt;
- int nbInt;
- // When short integer(s) are expected, read and convert the following
- // (n * 2) characters properly i.e. consider them as short integers as
- // opposed to strings.
- // Elements with Value Multiplicity > 1
- // contain a set of integers (not a single one)
- if (vr == "US" || vr == "SS")
- {
- nbInt = length / 2;
- NewInt = ReadInt16();
- s << NewInt;
- if (nbInt > 1)
- {
- for (int i=1; i < nbInt; i++)
- {
- s << '\\';
- NewInt = ReadInt16();
- s << NewInt;
- }
- }
- }
- // See above comment on multiple integers (mutatis mutandis).
- else if (vr == "UL" || vr == "SL")
- {
- nbInt = length / 4;
- NewInt = ReadInt32();
- s << NewInt;
- if (nbInt > 1)
- {
- for (int i=1; i < nbInt; i++)
- {
- s << '\\';
- NewInt = ReadInt32();
- s << NewInt;
- }
- }
- }
-#ifdef GDCM_NO_ANSI_STRING_STREAM
- s << std::ends; // to avoid oddities on Solaris
-#endif //GDCM_NO_ANSI_STRING_STREAM
-
- ((ValEntry *)entry)->SetValue(s.str());
- return;
- }
-
- // FIXME: We need an additional byte for storing \0 that is not on disk
- char *str = new char[length+1];
- Fp->read(str, (size_t)length);
- str[length] = '\0'; //this is only useful when length is odd
- // Special DicomString call to properly handle \0 and even length
- std::string newValue;
- if ( length % 2 )
- {
- newValue = Util::DicomString(str, length+1);
- gdcmWarningMacro("Warning: bad length: " << length <<
- " For string :" << newValue.c_str());
- // Since we change the length of string update it length
- //entry->SetReadLength(length+1);
- }
- else
- {
- newValue = Util::DicomString(str, length);
- }
- delete[] str;
-
- if ( ValEntry *valEntry = dynamic_cast<ValEntry* >(entry) )
- {
- if ( Fp->fail() || Fp->eof())
- {
- if ( Fp->fail() )
- gdcmWarningMacro("--> fail");
-
- gdcmWarningMacro("Unread element value " << valEntry->GetKey()
- << " lgt : " << valEntry->GetReadLength()
- << " at " << std::hex << valEntry->GetOffset());
- valEntry->SetValue(GDCM_UNREAD);
- return;
- }
-
-// if ( vr == "UI" )
-// {
-// // Because of correspondance with the VR dic
-// valEntry->SetValue(newValue);
-// }
-// else
-// {
-// valEntry->SetValue(newValue);
-// }
-
-// Anybody remembers the genesis of strange previous (commented out) code?
- valEntry->SetValue(newValue);
-
- }
- else
- {
- gdcmWarningMacro("Should have a ValEntry, here ! " << valEntry->GetKey()
- << " lgt : " << valEntry->GetReadLength()
- << " at " << std::hex << valEntry->GetOffset());
- }
+ LoadEntryBinArea(dataEntryPtr); // last one, not to erase length !
}
/**
return true;
}
-/**
- * \brief Get the transformed value of the header entry. The VR value
- * is used to define the transformation to operate on the value
- * \warning NOT end user intended method !
- * @param entry entry to tranform
- * @return Transformed entry value
- */
-std::string Document::GetDocEntryValue(DocEntry *entry)
-{
- if ( IsDocEntryAnInteger(entry) && entry->IsImplicitVR() )
- {
- std::string val = ((ValEntry *)entry)->GetValue();
- std::string vr = entry->GetVR();
- uint32_t length = entry->GetLength();
- std::ostringstream s;
- int nbInt;
-
- // When short integer(s) are expected, read and convert the following
- // n * 2 bytes properly i.e. as a multivaluated strings
- // (each single value is separated fromthe next one by '\'
- // as usual for standard multivaluated filels
- // Elements with Value Multiplicity > 1
- // contain a set of short integers (not a single one)
-
- if ( vr == "US" || vr == "SS" )
- {
- uint16_t newInt16;
-
- nbInt = length / 2;
- for (int i=0; i < nbInt; i++)
- {
- if ( i != 0 )
- {
- s << '\\';
- }
- newInt16 = ( val[2*i+0] & 0xFF ) + ( ( val[2*i+1] & 0xFF ) << 8);
- newInt16 = SwapShort( newInt16 );
- s << newInt16;
- }
- }
-
- // When integer(s) are expected, read and convert the following
- // n * 4 bytes properly i.e. as a multivaluated strings
- // (each single value is separated fromthe next one by '\'
- // as usual for standard multivaluated filels
- // Elements with Value Multiplicity > 1
- // contain a set of integers (not a single one)
- else if ( vr == "UL" || vr == "SL" )
- {
- uint32_t newInt32;
-
- nbInt = length / 4;
- for (int i=0; i < nbInt; i++)
- {
- 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 = SwapLong( newInt32 );
- s << newInt32;
- }
- }
-#ifdef GDCM_NO_ANSI_STRING_STREAM
- s << std::ends; // to avoid oddities on Solaris
-#endif //GDCM_NO_ANSI_STRING_STREAM
- return s.str();
- }
- return ((ValEntry *)entry)->GetValue();
-}
-
-/**
- * \brief Get the reverse transformed value of the header entry. The VR
- * value is used to define the reverse transformation to operate on
- * the value
- * \warning NOT end user intended method !
- * @param entry Entry to reverse transform
- * @return Reverse transformed entry value
- */
-std::string Document::GetDocEntryUnvalue(DocEntry *entry)
-{
- if ( IsDocEntryAnInteger(entry) && entry->IsImplicitVR() )
- {
- std::string vr = entry->GetVR();
- std::vector<std::string> tokens;
- std::ostringstream s;
-
- if ( vr == "US" || vr == "SS" )
- {
- uint16_t newInt16;
-
- tokens.erase( tokens.begin(), tokens.end()); // clean any previous value
- Util::Tokenize (((ValEntry *)entry)->GetValue(), tokens, "\\");
- for (unsigned int i=0; i<tokens.size(); i++)
- {
- newInt16 = atoi(tokens[i].c_str());
- s << ( newInt16 & 0xFF )
- << (( newInt16 >> 8 ) & 0xFF );
- }
- tokens.clear();
- }
- if ( vr == "UL" || vr == "SL")
- {
- uint32_t newInt32;
-
- tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
- Util::Tokenize (((ValEntry *)entry)->GetValue(), tokens, "\\");
- for (unsigned int i=0; i<tokens.size();i++)
- {
- newInt32 = atoi(tokens[i].c_str());
- s << (char)( newInt32 & 0xFF )
- << (char)(( newInt32 >> 8 ) & 0xFF )
- << (char)(( newInt32 >> 16 ) & 0xFF )
- << (char)(( newInt32 >> 24 ) & 0xFF );
- }
- tokens.clear();
- }
-
-#ifdef GDCM_NO_ANSI_STRING_STREAM
- s << std::ends; // to avoid oddities on Solaris
-#endif //GDCM_NO_ANSI_STRING_STREAM
- return s.str();
- }
-
- return ((ValEntry *)entry)->GetValue();
-}
-
/**
* \brief Skip a given Header Entry
* \warning NOT end user intended method !
DocEntry *newEntry;
if ( Global::GetVR()->IsVROfSequence(realVR) )
newEntry = NewSeqEntry(group, elem);
- else if ( Global::GetVR()->IsVROfStringRepresentable(realVR) )
- newEntry = NewValEntry(group, elem, realVR);
- else
- newEntry = NewBinEntry(group, elem, realVR);
+ else
+ {
+ newEntry = NewDataEntry(group, elem, realVR);
+ static_cast<DataEntry *>(newEntry)->SetState(DataEntry::STATE_NOTLOADED);
+ }
if ( vr == GDCM_UNKNOWN )
{
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2005/09/07 08:55:23 $
- Version: $Revision: 1.122 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.123 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
-class ValEntry;
-class BinEntry;
class SeqEntry;
class Dict;
// Content entries
virtual void LoadEntryBinArea(uint16_t group, uint16_t elem);
- virtual void LoadEntryBinArea(BinEntry *entry);
+ virtual void LoadEntryBinArea(DataEntry *entry);
void LoadDocEntrySafe(DocEntry *entry);
void AddForceLoadElement(uint16_t group, uint16_t elem);
std::string FindDocEntryVR();
bool CheckDocEntryVR (VRKey k);
- std::string GetDocEntryValue (DocEntry *entry);
- std::string GetDocEntryUnvalue(DocEntry *entry);
-
void SkipDocEntry (DocEntry *entry);
void SkipToNextDocEntry (DocEntry *entry);
Program: gdcm
Module: $RCSfile: gdcmElementSet.cxx,v $
Language: C++
- Date: $Date: 2005/10/11 08:24:10 $
- Version: $Revision: 1.64 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.65 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmElementSet.h"
#include "gdcmDebug.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmSeqEntry.h"
+#include "gdcmDataEntry.h"
namespace gdcm
{
{
// Let's change the 'warning value' for Pixel Data,
// to avoid human reader to be confused by 'gdcm::NotLoaded'.
- gdcm::BinEntry *pixelElement = GetBinEntry(0x7fe0,0x0010);
+ DataEntry *pixelElement = GetDataEntry(0x7fe0,0x0010);
if ( pixelElement != 0 )
{
- pixelElement->SetValue( gdcm::GDCM_PIXELDATA);
- }
+ pixelElement->SetFlag( DataEntry::FLAG_PIXELDATA );
+ }
for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
{
entry->SetPrintLevel(PrintLevel);
entry->Print(os);
- if ( dynamic_cast<SeqEntry*>(entry) )
+ if ( dynamic_cast<SeqEntry *>(entry) )
{
// Avoid the newline for a sequence:
continue;
Program: gdcm
Module: $RCSfile: gdcmElementSet.h,v $
Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- Version: $Revision: 1.45 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ 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
namespace gdcm
{
-class ValEntry;
-class BinEntry;
class SeqEntry;
typedef std::map<TagKey, DocEntry *> TagDocEntryHT;
TagDocEntryHT TagHT;
/// iterator, used to visit the TagHT variable
TagDocEntryHT::iterator ItTagHT;
- /// iterator, used to visit the TagHT variable, seeking only for ValEntries
- TagDocEntryHT::iterator ItValEntryTagHT;
};
} // end namespace gdcm
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2005/10/17 14:26:44 $
- Version: $Revision: 1.275 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.276 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmUtil.h"
#include "gdcmDebug.h"
#include "gdcmTS.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmSeqEntry.h"
#include "gdcmRLEFramesInfo.h"
#include "gdcmJPEGFragmentsInfo.h"
+#include "gdcmDataEntry.h"
#include <vector>
#include <stdio.h> //sscanf
// Note: this IS the right place for the code
// Image Location
- const std::string &imgLocation = GetEntryValue(0x0028, 0x0200);
+ const std::string &imgLocation = GetEntryString(0x0028, 0x0200);
if ( imgLocation == GDCM_UNFOUND )
{
// default value
ComputeJPEGFragmentInfo();
CloseFile();
- // Create a new BinEntry to change the DictEntry
+ // Create a new DataEntry to change the DictEntry
// The changed DictEntry will have
// - a correct PixelVR OB or OW)
// - the name to "Pixel Data"
- BinEntry *oldEntry = dynamic_cast<BinEntry *>(entry);
+ DataEntry *oldEntry = dynamic_cast<DataEntry *>(entry);
if (oldEntry)
{
std::string PixelVR;
DictEntry* newDict = NewVirtualDictEntry(GrPixel,NumPixel,
PixelVR,"1","Pixel Data");
- BinEntry *newEntry = new BinEntry(newDict);
+ DataEntry *newEntry = new DataEntry(newDict);
newEntry->Copy(entry);
newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea());
oldEntry->SetSelfArea(false);
return false;
}
- const std::string &res = GetEntryValue(0x0028, 0x0005);
+ const std::string &res = GetEntryString(0x0028, 0x0005);
if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 )
{
gdcmWarningMacro("Wrong Image Dimensions" << res);
int File::GetImageNumber()
{
//0020 0013 : Image Number
- std::string strImNumber = GetEntryValue(0x0020,0x0013);
+ std::string strImNumber = GetEntryString(0x0020,0x0013);
if ( strImNumber != GDCM_UNFOUND )
{
return atoi( strImNumber.c_str() );
ModalityType File::GetModality()
{
// 0008 0060 : Modality
- std::string strModality = GetEntryValue(0x0008,0x0060);
+ std::string strModality = GetEntryString(0x0008,0x0060);
if ( strModality != GDCM_UNFOUND )
{
if ( strModality.find("AU") < strModality.length()) return AU;
*/
int File::GetXSize()
{
- const std::string &strSize = GetEntryValue(0x0028,0x0011);
- if ( strSize == GDCM_UNFOUND )
- {
- return 0;
- }
- return atoi( strSize.c_str() );
+ DataEntry *entry = GetDataEntry(0x0028,0x0011);
+ if( entry )
+ return (int)entry->GetValue(0);
+ return 0;
}
/**
*/
int File::GetYSize()
{
- const std::string &strSize = GetEntryValue(0x0028,0x0010);
- if ( strSize != GDCM_UNFOUND )
- {
- return atoi( strSize.c_str() );
- }
+ DataEntry *entry = GetDataEntry(0x0028,0x0010);
+ if( entry )
+ return (int)entry->GetValue(0);
+
if ( IsDicomV3() )
{
return 0;
{
// Both DicomV3 and ACR/Nema consider the "Number of Frames"
// as the third dimension.
- const std::string &strSize = GetEntryValue(0x0028,0x0008);
- if ( strSize != GDCM_UNFOUND )
- {
- return atoi( strSize.c_str() );
- }
+ DataEntry *entry = GetDataEntry(0x0028,0x0008);
+ if( entry )
+ return (int)entry->GetValue(0);
// We then consider the "Planes" entry as the third dimension
- const std::string &strSize2 = GetEntryValue(0x0028,0x0012);
- if ( strSize2 != GDCM_UNFOUND )
- {
- return atoi( strSize2.c_str() );
- }
+ entry = GetDataEntry(0x0028,0x0012);
+ if( entry )
+ return (int)entry->GetValue(0);
return 1;
}
float File::GetXSpacing()
{
float xspacing = 1.0;
- float yspacing = 1.0;
- int nbValues;
+ uint32_t nbValue;
// To follow David Clunie's advice, we first check ImagerPixelSpacing
- const std::string &strImagerPixelSpacing = GetEntryValue(0x0018,0x1164);
+ DataEntry *entry = GetDataEntry(0x0018,0x1164);
+ if( entry )
+ {
+ nbValue = entry->GetValueCount();
+ if( nbValue >= 3 )
+ xspacing = (float)entry->GetValue(2);
+ if( nbValue >= 2 )
+ xspacing = (float)entry->GetValue(1);
+ else
+ xspacing = (float)entry->GetValue(0);
+
+ if ( xspacing == 0.0 )
+ xspacing = 1.0;
+ return xspacing;
+ }
+ else
+ {
+ gdcmWarningMacro( "Unfound Pixel Spacing (0018,1164)" );
+ }
+
+/* const std::string &strImagerPixelSpacing = GetEntryString(0x0018,0x1164);
if ( strImagerPixelSpacing != GDCM_UNFOUND )
{
if ( ( nbValues = sscanf( strImagerPixelSpacing.c_str(),
xspacing = 1.0;
}
return xspacing;
- }
+ }*/
+
+ entry = GetDataEntry(0x0028,0x0030);
+ if( entry )
+ {
+ nbValue = entry->GetValueCount();
+ if( nbValue >= 3 )
+ xspacing = (float)entry->GetValue(2);
+ if( nbValue >= 2 )
+ xspacing = (float)entry->GetValue(1);
+ else
+ xspacing = (float)entry->GetValue(0);
- const std::string &strSpacing = GetEntryValue(0x0028,0x0030);
+ if ( xspacing == 0.0 )
+ xspacing = 1.0;
+ return xspacing;
+ }
+ else
+ {
+ gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" );
+ }
+/* const std::string &strSpacing = GetEntryString(0x0028,0x0030);
if ( strSpacing == GDCM_UNFOUND )
{
gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" );
if ( xspacing == 0.0 )
xspacing = 1.0;
- }
return xspacing;
+ }*/
+
// to avoid troubles with David Clunie's-like images (at least one)
- if ( xspacing == 0.0 && yspacing == 0.0)
+/* if ( xspacing == 0.0 && yspacing == 0.0)
return 1.0;
if ( xspacing == 0.0)
nbValues = sscanf( strSpacing.c_str(), "%f \\0\\%f ", &yspacing, &xspacing);
gdcmAssertMacro( nbValues == 2 );
}
-
+*/
return xspacing;
}
float File::GetYSpacing()
{
float yspacing = 1.0;
- int nbValues;
// To follow David Clunie's advice, we first check ImagerPixelSpacing
- const std::string &strImagerPixelSpacing = GetEntryValue(0x0018,0x1164);
+ DataEntry *entry = GetDataEntry(0x0018,0x1164);
+ if( entry )
+ {
+ yspacing = (float)entry->GetValue(0);
+
+ if ( yspacing == 0.0 )
+ yspacing = 1.0;
+ return yspacing;
+ }
+ else
+ {
+ gdcmWarningMacro( "Unfound Pixel Spacing (0018,1164)" );
+ }
+/* const std::string &strImagerPixelSpacing = GetEntryString(0x0018,0x1164);
if ( strImagerPixelSpacing != GDCM_UNFOUND )
{
nbValues = sscanf( strImagerPixelSpacing.c_str(), "%f", &yspacing);
yspacing = 1.0;
return yspacing;
- }
+ }*/
- std::string strSpacing = GetEntryValue(0x0028,0x0030);
+ entry = GetDataEntry(0x0028,0x0030);
+ if( entry )
+ {
+ yspacing = (float)entry->GetValue(0);
+
+ if ( yspacing == 0.0 )
+ yspacing = 1.0;
+ return yspacing;
+ }
+ else
+ {
+ gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" );
+ }
+/* std::string strSpacing = GetEntryString(0x0028,0x0030);
if ( strSpacing == GDCM_UNFOUND )
{
gdcmWarningMacro("Unfound Pixel Spacing (0028,0030)");
yspacing = 1.0;
if ( yspacing == 0.0 )
- yspacing = 1.0;
+ yspacing = 1.0;*/
return yspacing;
}
*/
float File::GetZSpacing()
{
+ // --->
+ // ---> Warning :
+ // --->
+ // For *Dicom* images, ZSpacing should be calculated using
+ // XOrigin, YOrigin, ZOrigin (of the top left image corner)
+ // of 2 consecutive images, and the Orientation
+ //
+ // Computing ZSpacing on a single image is not really meaningfull !
+
+ float zspacing = 1.0f;
+
// Spacing Between Slices : distance between the middle of 2 slices
// Slices may be :
// jointives (Spacing between Slices = Slice Thickness)
// It only concerns the MRI guys, not people wanting to visualize volumes
// If Spacing Between Slices is missing,
// we suppose slices joint together
+ DataEntry *entry = GetDataEntry(0x0018,0x0088);
+ if( entry )
+ {
+ zspacing = (float)entry->GetValue(0);
- // --->
- // ---> Warning :
- // --->
-
- //
- // For *Dicom* images, ZSpacing should be calculated using
- // XOrigin, YOrigin, ZOrigin (of the top left image corner)
- // of 2 consecutive images, and the Orientation
- //
- // Computing ZSpacing on a single image is not really meaningfull !
-
- const std::string &strSpacingBSlices = GetEntryValue(0x0018,0x0088);
+ if ( zspacing == 0.0 )
+ zspacing = 1.0;
+ return zspacing;
+ }
+ else
+ gdcmWarningMacro("Unfound Spacing Between Slices (0018,0088)");
+ // if no 'Spacing Between Slices' is found,
+ // we assume slices join together
+ // (no overlapping, no interslice gap)
+ // if they don't, we're fucked up
+ entry = GetDataEntry(0x0018,0x0050);
+ if( entry )
+ {
+ zspacing = (float)entry->GetValue(0);
+
+ if ( zspacing == 0.0 )
+ zspacing = 1.0;
+ return zspacing;
+ }
+ else
+ gdcmWarningMacro("Unfound Slice Thickness (0018,0050)");
+
+ return zspacing;
+
+/* const std::string &strSpacingBSlices = GetEntryString(0x0018,0x0088);
if ( strSpacingBSlices == GDCM_UNFOUND )
{
gdcmWarningMacro("Unfound Spacing Between Slices (0018,0088)");
- const std::string &strSliceThickness = GetEntryValue(0x0018,0x0050);
+ const std::string &strSliceThickness = GetEntryString(0x0018,0x0050);
if ( strSliceThickness == GDCM_UNFOUND )
{
gdcmWarningMacro("Unfound Slice Thickness (0018,0050)");
return (float)atof( strSliceThickness.c_str() );
}
}
- //else
float zsp = (float)atof( strSpacingBSlices.c_str());
if (zsp == 0.0) // last change not to break further computations ...
zsp = 1.0;
- return zsp;
+ return zsp;*/
}
/**
*/
float File::GetXOrigin()
{
- float xImPos, yImPos, zImPos;
- std::string strImPos = GetEntryValue(0x0020,0x0032);
+ DataEntry *entry = GetDataEntry(0x0020,0x0032);
+ if( !entry )
+ {
+ gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
+ entry = GetDataEntry(0x0020,0x0030);
+ if( !entry )
+ {
+ gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
+ return 0.0f;
+ }
+ }
+
+ if( entry->GetValueCount() == 3 )
+ return (float)entry->GetValue(0);
+ return 0.0f;
+/* std::string strImPos = GetEntryString(0x0020,0x0032);
if ( strImPos == GDCM_UNFOUND )
{
gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
- strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
+ strImPos = GetEntryString(0x0020,0x0030); // For ACR-NEMA images
if ( strImPos == GDCM_UNFOUND )
{
gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
return 0.0;
}
- return xImPos;
+ return xImPos;*/
}
/**
*/
float File::GetYOrigin()
{
- float xImPos, yImPos, zImPos;
- std::string strImPos = GetEntryValue(0x0020,0x0032);
+ DataEntry *entry = GetDataEntry(0x0020,0x0032);
+ if( !entry )
+ {
+ gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
+ entry = GetDataEntry(0x0020,0x0030);
+ if( !entry )
+ {
+ gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
+ return 0.0f;
+ }
+ }
+
+ if( entry->GetValueCount() == 3 )
+ return (float)entry->GetValue(1);
+ return 0.0f;
+/* float xImPos, yImPos, zImPos;
+ std::string strImPos = GetEntryString(0x0020,0x0032);
if ( strImPos == GDCM_UNFOUND)
{
gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
- strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
+ strImPos = GetEntryString(0x0020,0x0030); // For ACR-NEMA images
if ( strImPos == GDCM_UNFOUND )
{
gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
return 0.;
}
- return yImPos;
+ return yImPos;*/
}
/**
*/
float File::GetZOrigin()
{
- float xImPos, yImPos, zImPos;
- std::string strImPos = GetEntryValue(0x0020,0x0032);
+ DataEntry *entry = GetDataEntry(0x0020,0x0032);
+ if( entry )
+ {
+ if( entry->GetValueCount() == 3 )
+ return (float)entry->GetValue(0);
+ gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)");
+ return 0.0f;
+ }
+/* float xImPos, yImPos, zImPos;
+ std::string strImPos = GetEntryString(0x0020,0x0032);
if ( strImPos != GDCM_UNFOUND )
{
{
return zImPos;
}
- }
+ }*/
- strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
+ entry = GetDataEntry(0x0020,0x0030);
+ if( entry )
+ {
+ if( entry->GetValueCount() == 3 )
+ return (float)entry->GetValue(0);
+ gdcmWarningMacro( "Wrong Image Position (RET) (0020,0030)");
+ return 0.0f;
+ }
+/* strImPos = GetEntryString(0x0020,0x0030); // For ACR-NEMA images
if ( strImPos != GDCM_UNFOUND )
{
if ( sscanf( strImPos.c_str(),
{
return zImPos;
}
- }
+ }*/
// for *very* old ACR-NEMA images
- std::string strSliceLocation = GetEntryValue(0x0020,0x1041);
+ entry = GetDataEntry(0x0020,0x1041);
+ if( entry )
+ {
+ if( entry->GetValueCount() == 1 )
+ return (float)entry->GetValue(0);
+ gdcmWarningMacro( "Wrong Slice Location (0020,1041)");
+ return 0.0f;
+ }
+/* std::string strSliceLocation = GetEntryString(0x0020,0x1041);
if ( strSliceLocation != GDCM_UNFOUND )
{
if ( sscanf( strSliceLocation.c_str(), "%f ", &zImPos) != 1)
return zImPos;
}
}
- gdcmWarningMacro( "Unfound Slice Location (0020,1041)");
+ gdcmWarningMacro( "Unfound Slice Location (0020,1041)");*/
- std::string strLocation = GetEntryValue(0x0020,0x0050);
+ entry = GetDataEntry(0x0020,0x0050);
+ if( entry )
+ {
+ gdcmWarningMacro( "Unfound Location (0020,0050)");
+ if( entry->GetValueCount() == 1 )
+ return (float)entry->GetValue(0);
+ gdcmWarningMacro( "Wrong Location (0020,0050)");
+ return 0.0f;
+ }
+/* std::string strLocation = GetEntryString(0x0020,0x0050);
if ( strLocation != GDCM_UNFOUND )
{
if ( sscanf( strLocation.c_str(), "%f ", &zImPos) != 1 )
return zImPos;
}
}
- gdcmWarningMacro( "Unfound Location (0020,0050)");
+ gdcmWarningMacro( "Unfound Location (0020,0050)");*/
return 0.; // Hopeless
}
iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0.;
// 0020 0037 DS REL Image Orientation (Patient)
- if ( (strImOriPat = GetEntryValue(0x0020,0x0037)) != GDCM_UNFOUND )
+ if ( (strImOriPat = GetEntryString(0x0020,0x0037)) != GDCM_UNFOUND )
{
if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ",
&iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
}
//For ACR-NEMA
// 0020 0035 DS REL Image Orientation (RET)
- else if ( (strImOriPat = GetEntryValue(0x0020,0x0035)) != GDCM_UNFOUND )
+ else if ( (strImOriPat = GetEntryString(0x0020,0x0035)) != GDCM_UNFOUND )
{
if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ",
&iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
*/
int File::GetBitsStored()
{
- std::string strSize = GetEntryValue( 0x0028, 0x0101 );
+ DataEntry *entry = GetDataEntry(0x0028,0x0101);
+ if( !entry )
+ {
+ gdcmWarningMacro("(0028,0101) is supposed to be mandatory");
+ return 0;
+ }
+ return (int)entry->GetValue(0);
+
+/* std::string strSize = GetEntryString( 0x0028, 0x0101 );
if ( strSize == GDCM_UNFOUND )
{
gdcmWarningMacro("(0028,0101) is supposed to be mandatory");
return 0; // It's supposed to be mandatory
// the caller will have to check
}
- return atoi( strSize.c_str() );
+ return atoi( strSize.c_str() );*/
}
/**
*/
int File::GetBitsAllocated()
{
- std::string strSize = GetEntryValue(0x0028,0x0100);
+ DataEntry *entry = GetDataEntry(0x0028,0x0100);
+ if( !entry )
+ {
+ gdcmWarningMacro("(0028,0100) is supposed to be mandatory");
+ return 0;
+ }
+ return (int)entry->GetValue(0);
+
+/* std::string strSize = GetEntryString(0x0028,0x0100);
if ( strSize == GDCM_UNFOUND )
{
gdcmWarningMacro( "(0028,0100) is supposed to be mandatory");
return 0; // It's supposed to be mandatory
// the caller will have to check
}
- return atoi( strSize.c_str() );
+ return atoi( strSize.c_str() );*/
}
/**
*/
int File::GetHighBitPosition()
{
- std::string strSize = GetEntryValue( 0x0028, 0x0102 );
+ DataEntry *entry = GetDataEntry(0x0028,0x0102);
+ if( !entry )
+ {
+ gdcmWarningMacro("(0028,0102) is supposed to be mandatory");
+ return 0;
+ }
+ return (int)entry->GetValue(0);
+
+/* std::string strSize = GetEntryString( 0x0028, 0x0102 );
if ( strSize == GDCM_UNFOUND )
{
gdcmWarningMacro( "(0028,0102) is supposed to be mandatory");
return 0;
}
- return atoi( strSize.c_str() );
+ return atoi( strSize.c_str() );*/
}
/**
*/
int File::GetSamplesPerPixel()
{
- const std::string &strSize = GetEntryValue(0x0028,0x0002);
+ DataEntry *entry = GetDataEntry(0x0028,0x0002);
+ if( !entry )
+ {
+ gdcmWarningMacro("(0028,0002) is supposed to be mandatory");
+ return 1; // Well, it's supposed to be mandatory ...
+ // but sometimes it's missing : *we* assume Gray pixels
+ }
+ return (int)entry->GetValue(0);
+
+/* const std::string &strSize = GetEntryString(0x0028,0x0002);
if ( strSize == GDCM_UNFOUND )
{
gdcmWarningMacro( "(0028,0002) is supposed to be mandatory");
return 1; // Well, it's supposed to be mandatory ...
// but sometimes it's missing : *we* assume Gray pixels
}
- return atoi( strSize.c_str() );
+ return atoi( strSize.c_str() );*/
}
/**
*/
int File::GetPlanarConfiguration()
{
- std::string strSize = GetEntryValue(0x0028,0x0006);
+ DataEntry *entry = GetDataEntry(0x0028,0x0006);
+ if( !entry )
+ {
+ gdcmWarningMacro( "Not found : Planar Configuration (0028,0006)");
+ return 0;
+ }
+ return (int)entry->GetValue(0);
+
+/* std::string strSize = GetEntryString(0x0028,0x0006);
if ( strSize == GDCM_UNFOUND )
{
gdcmWarningMacro( "Not found : Planar Configuration (0028,0006)");
return 0;
}
- return atoi( strSize.c_str() );
+ return atoi( strSize.c_str() );*/
}
/**
{
// 0028 0100 US IMG Bits Allocated
// (in order no to be messed up by old ACR-NEMA RGB images)
- // if (File::GetEntryValue(0x0028,0x0100) == "24")
- // return 3;
- assert( !(GetEntryValue(0x0028,0x0100) == "24") );
+ assert( !(GetEntryString(0x0028,0x0100) == "24") );
std::string pixelType = GetPixelType();
if ( pixelType == "8U" || pixelType == "8S" )
{
return 8;
}
- gdcmWarningMacro( "Unknown pixel type");
+ gdcmWarningMacro( "Unknown pixel type: " << pixelType);
return 0;
}
*/
std::string File::GetPixelType()
{
- std::string bitsAlloc = GetEntryValue(0x0028, 0x0100); // Bits Allocated
+ std::string bitsAlloc = GetEntryString(0x0028, 0x0100); // Bits Allocated
if ( bitsAlloc == GDCM_UNFOUND )
{
gdcmWarningMacro( "Missing Bits Allocated (0028,0100)");
bitsAlloc = "8";
}
- std::string sign = GetEntryValue(0x0028, 0x0103);//"Pixel Representation"
+ std::string sign;
+ if( IsSignedPixelData() )
+ {
+ sign = "S";
+ }
+ else
+ {
+ sign = "U";
+ }
+
+/* std::string bitsAlloc = GetEntryString(0x0028, 0x0100); // Bits Allocated
+ if ( bitsAlloc == GDCM_UNFOUND )
+ {
+ gdcmWarningMacro( "Missing Bits Allocated (0028,0100)");
+ bitsAlloc = "16"; // default and arbitrary value, not to polute the output
+ }
+
+ if ( bitsAlloc == "64" )
+ {
+ return "FD";
+ }
+ else if ( bitsAlloc == "12" )
+ {
+ // It will be unpacked
+ bitsAlloc = "16";
+ }
+ else if ( bitsAlloc == "24" )
+ {
+ // (in order no to be messed up by old RGB images)
+ bitsAlloc = "8";
+ }
+
+ std::string sign = GetEntryString(0x0028, 0x0103);//"Pixel Representation"
if (sign == GDCM_UNFOUND )
{
else
{
sign = "S";
- }
+ }*/
return bitsAlloc + sign;
}
*/
bool File::IsSignedPixelData()
{
- std::string strSign = GetEntryValue( 0x0028, 0x0103 );
+ DataEntry *entry = GetDataEntry(0x0028, 0x0103);//"Pixel Representation"
+ if( !entry )
+ {
+ gdcmWarningMacro( "Missing Pixel Representation (0028,0103)");
+ return false;
+ }
+ return entry->GetValue(0) != 0;
+/* std::string strSign = GetEntryString( 0x0028, 0x0103 );
if ( strSign == GDCM_UNFOUND )
{
gdcmWarningMacro( "(0028,0103) is supposed to be mandatory");
{
return false;
}
- return true;
+ return true;*/
}
/**
*/
bool File::IsMonochrome()
{
- const std::string &PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
+ const std::string &PhotometricInterp = GetEntryString( 0x0028, 0x0004 );
if ( Util::DicomStringEqual(PhotometricInterp, "MONOCHROME1")
|| Util::DicomStringEqual(PhotometricInterp, "MONOCHROME2") )
{
*/
bool File::IsMonochrome1()
{
- const std::string &PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
+ const std::string &PhotometricInterp = GetEntryString( 0x0028, 0x0004 );
if ( Util::DicomStringEqual(PhotometricInterp, "MONOCHROME1") )
{
return true;
*/
bool File::IsPaletteColor()
{
- std::string PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
+ std::string PhotometricInterp = GetEntryString( 0x0028, 0x0004 );
if ( PhotometricInterp == "PALETTE COLOR " )
{
return true;
*/
bool File::IsYBRFull()
{
- std::string PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
+ std::string PhotometricInterp = GetEntryString( 0x0028, 0x0004 );
if ( PhotometricInterp == "YBR_FULL" )
{
return true;
//Just hope Lookup Table Desc-Red = Lookup Table Desc-Red
// = Lookup Table Desc-Blue
// Consistency already checked in GetLUTLength
- std::string lutDescription = GetEntryValue(0x0028,0x1101);
+ std::string lutDescription = GetEntryString(0x0028,0x1101);
if ( lutDescription == GDCM_UNFOUND )
{
return 0;
*/
float File::GetRescaleIntercept()
{
- float resInter = 0.;
+ // 0028 1052 DS IMG Rescale Intercept
+ DataEntry *entry = GetDataEntry(0x0028, 0x1052);
+ if( !entry )
+ {
+ gdcmWarningMacro( "Missing Rescale Intercept (0028,1052)");
+ return 0.0f;
+ }
+ return (float)entry->GetValue(0);
+
+/* float resInter = 0.;
/// 0028 1052 DS IMG Rescale Intercept
- const std::string &strRescInter = GetEntryValue(0x0028,0x1052);
+ const std::string &strRescInter = GetEntryString(0x0028,0x1052);
if ( strRescInter != GDCM_UNFOUND )
{
if ( sscanf( strRescInter.c_str(), "%f ", &resInter) != 1 )
}
}
- return resInter;
+ return resInter;*/
}
/**
*/
float File::GetRescaleSlope()
{
- float resSlope = 1.;
+ // 0028 1053 DS IMG Rescale Slope
+ DataEntry *entry = GetDataEntry(0x0028, 0x1053);
+ if( !entry )
+ {
+ gdcmWarningMacro( "Missing Rescale Slope (0028,1053)");
+ return 1.0f;
+ }
+ return (float)entry->GetValue(0);
+/* float resSlope = 1.;
//0028 1053 DS IMG Rescale Slope
- std::string strRescSlope = GetEntryValue(0x0028,0x1053);
+ std::string strRescSlope = GetEntryString(0x0028,0x1053);
if ( strRescSlope != GDCM_UNFOUND )
{
if ( sscanf( strRescSlope.c_str(), "%f ", &resSlope) != 1 )
}
}
- return resSlope;
+ return resSlope;*/
}
/**
{
return 3;
}
-
+
// 0028 0100 US IMG Bits Allocated
// (in order no to be messed up by old RGB images)
- if ( GetEntryValue(0x0028,0x0100) == "24" )
+ if ( GetEntryString(0x0028,0x0100) == "24" )
{
return 3;
}
-
- std::string strPhotometricInterpretation = GetEntryValue(0x0028,0x0004);
+
+ std::string strPhotometricInterpretation = GetEntryString(0x0028,0x0004);
if ( ( strPhotometricInterpretation == "PALETTE COLOR ") )
{
{
// 0028 0100 US IMG Bits Allocated
// (in order no to be messed up by old RGB images)
- if ( File::GetEntryValue(0x0028,0x0100) == "24" )
+ if ( File::GetEntryString(0x0028,0x0100) == "24" )
{
return 3;
}
/**
* \brief anonymize a File (remove Patient's personal info passed with
* AddAnonymizeElement()
- * \note You cannot Anonymize a BinEntry (to be fixed)
+ * \note You cannot Anonymize a DataEntry (to be fixed)
*/
bool File::AnonymizeFile()
{
if ( UserAnonymizeList.begin() == UserAnonymizeList.end() )
{
// If exist, replace by spaces
- SetValEntry (" ",0x0010, 0x2154); // Telephone
- SetValEntry (" ",0x0010, 0x1040); // Adress
- SetValEntry (" ",0x0010, 0x0020); // Patient ID
+ SetEntryString(" ",0x0010, 0x2154); // Telephone
+ SetEntryString(" ",0x0010, 0x1040); // Adress
+ SetEntryString(" ",0x0010, 0x0020); // Patient ID
- DocEntry* patientNameHE = GetDocEntry (0x0010, 0x0010);
+ DocEntry *patientNameHE = GetDocEntry (0x0010, 0x0010);
if ( patientNameHE ) // we replace it by Study Instance UID (why not ?)
{
- std::string studyInstanceUID = GetEntryValue (0x0020, 0x000d);
+ std::string studyInstanceUID = GetEntryString (0x0020, 0x000d);
if ( studyInstanceUID != GDCM_UNFOUND )
{
- SetValEntry(studyInstanceUID, 0x0010, 0x0010);
+ SetEntryString(studyInstanceUID, 0x0010, 0x0010);
}
else
{
- SetValEntry("anonymized", 0x0010, 0x0010);
+ SetEntryString("anonymized", 0x0010, 0x0010);
}
}
}
continue;
}
- if ( dynamic_cast<BinEntry *>(d) )
+ if ( dynamic_cast<DataEntry *>(d) )
{
- gdcmWarningMacro( "To 'Anonymize' a BinEntry, better use AnonymizeNoLoad (FIXME) ");
+ gdcmWarningMacro( "To 'Anonymize' a DataEntry, better use AnonymizeNoLoad (FIXME) ");
continue;
}
else
- SetValEntry ((*it).Value, (*it).Group, (*it).Elem);
+ SetEntryString ((*it).Value, (*it).Group, (*it).Elem);
}
}
}
// Entry : 0002|0000 = group length -> recalculated
- ValEntry*e0000 = GetValEntry(0x0002,0x0000);
+ DataEntry *e0000 = GetDataEntry(0x0002,0x0000);
if ( e0000 )
{
std::ostringstream sLen;
sLen << ComputeGroup0002Length( );
- e0000->SetValue(sLen.str());
+ e0000->SetString(sLen.str());
}
int i_lgPix = GetEntryLength(GrPixel, NumPixel);
// no (GrPixel, NumPixel) element
std::string s_lgPix = Util::Format("%d", i_lgPix+12);
s_lgPix = Util::DicomString( s_lgPix.c_str() );
- InsertValEntry(s_lgPix,GrPixel, 0x0000);
+ InsertEntryString(s_lgPix,GrPixel, 0x0000);
}
Document::WriteContent(fp, writetype);
Module: $RCSfile: gdcmFileHelper.cxx,v $
Language: C++
- Date: $Date: 2005/10/07 09:54:53 $
- Version: $Revision: 1.59 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.60 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmDocument.h"
#include "gdcmDebug.h"
#include "gdcmUtil.h"
-#include "gdcmBinEntry.h"
-#include "gdcmValEntry.h"
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
-#include "gdcmContentEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmFile.h"
#include "gdcmPixelReadConvert.h"
#include "gdcmPixelWriteConvert.h"
* @param elem element number of the Dicom Element to modify
* \return false if DocEntry not found
*/
-bool FileHelper::SetValEntry(std::string const &content,
- uint16_t group, uint16_t elem)
+bool FileHelper::SetEntryString(std::string const &content,
+ uint16_t group, uint16_t elem)
{
- return FileInternal->SetValEntry(content, group, elem);
+ return FileInternal->SetEntryString(content, group, elem);
}
* @param elem element number of the Dicom Element to modify
* \return false if DocEntry not found
*/
-bool FileHelper::SetBinEntry(uint8_t *content, int lgth,
- uint16_t group, uint16_t elem)
+bool FileHelper::SetEntryBinArea(uint8_t *content, int lgth,
+ uint16_t group, uint16_t elem)
{
- return FileInternal->SetBinEntry(content, lgth, group, elem);
+ return FileInternal->SetEntryBinArea(content, lgth, group, elem);
}
/**
* \return pointer to the modified/created Dicom entry (NULL when creation
* failed).
*/
-ValEntry *FileHelper::InsertValEntry(std::string const &content,
- uint16_t group, uint16_t elem)
+DataEntry *FileHelper::InsertEntryString(std::string const &content,
+ uint16_t group, uint16_t elem)
{
- return FileInternal->InsertValEntry(content, group, elem);
+ return FileInternal->InsertEntryString(content, group, elem);
}
/**
* \return pointer to the modified/created Dicom entry (NULL when creation
* failed).
*/
-BinEntry *FileHelper::InsertBinEntry(uint8_t *binArea, int lgth,
- uint16_t group, uint16_t elem)
+DataEntry *FileHelper::InsertEntryBinArea(uint8_t *binArea, int lgth,
+ uint16_t group, uint16_t elem)
{
- return FileInternal->InsertBinEntry(binArea, lgth, group, elem);
+ return FileInternal->InsertEntryBinArea(binArea, lgth, group, elem);
}
/**
// and forgets to create any Entry belonging to group 0008
// (shame on him !)
// We add Recognition Code (RET)
- if ( ! FileInternal->GetValEntry(0x0008, 0x0010) )
- FileInternal->InsertValEntry("", 0x0008, 0x0010);
+ if ( ! FileInternal->GetDataEntry(0x0008, 0x0010) )
+ FileInternal->InsertEntryString("", 0x0008, 0x0010);
SetWriteFileTypeToACR();
// SetWriteFileTypeToImplicitVR(); // ACR IS implicit VR !
break;
}
break;
}
- }
+ }
+
return true;
}
}
else
{
- ValEntry *photInt = CopyValEntry(0x0028,0x0004);
+ DataEntry *photInt = CopyDataEntry(0x0028,0x0004);
if (FileInternal->HasLUT() )
{
- photInt->SetValue("PALETTE COLOR ");
+ photInt->SetString("PALETTE COLOR ");
}
else
{
- photInt->SetValue("MONOCHROME2 ");
+ photInt->SetString("MONOCHROME2 ");
}
PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
vr = "OW";
if ( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files
vr = "OB";
- BinEntry *pixel =
- CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
- pixel->SetValue(GDCM_BINLOADED);
+ DataEntry *pixel =
+ CopyDataEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
+ pixel->SetFlag(DataEntry::FLAG_PIXELDATA);
pixel->SetBinArea(PixelWriteConverter->GetData(),false);
pixel->SetLength(PixelWriteConverter->GetDataSize());
{
PixelReadConverter->BuildRGBImage();
- ValEntry *spp = CopyValEntry(0x0028,0x0002);
- spp->SetValue("3 ");
+ DataEntry *spp = CopyDataEntry(0x0028,0x0002);
+ spp->SetString("3 ");
- ValEntry *planConfig = CopyValEntry(0x0028,0x0006);
- planConfig->SetValue("0 ");
+ DataEntry *planConfig = CopyDataEntry(0x0028,0x0006);
+ planConfig->SetString("0 ");
- ValEntry *photInt = CopyValEntry(0x0028,0x0004);
- photInt->SetValue("RGB ");
+ DataEntry *photInt = CopyDataEntry(0x0028,0x0004);
+ photInt->SetString("RGB ");
if ( PixelReadConverter->GetRGB() )
{
vr = "OW";
if ( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files
vr = "OB";
- BinEntry *pixel =
- CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
- pixel->SetValue(GDCM_BINLOADED);
+ DataEntry *pixel =
+ CopyDataEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
+ pixel->SetFlag(DataEntry::FLAG_PIXELDATA);
pixel->SetBinArea(PixelWriteConverter->GetData(),false);
pixel->SetLength(PixelWriteConverter->GetDataSize());
// samples per pixels = 1 (in the read file)
if ( FileInternal->GetBitsAllocated()==24 )
{
- ValEntry *bitsAlloc = CopyValEntry(0x0028,0x0100);
- bitsAlloc->SetValue("8 ");
+ DataEntry *bitsAlloc = CopyDataEntry(0x0028,0x0100);
+ bitsAlloc->SetString("8 ");
- ValEntry *bitsStored = CopyValEntry(0x0028,0x0101);
- bitsStored->SetValue("8 ");
+ DataEntry *bitsStored = CopyDataEntry(0x0028,0x0101);
+ bitsStored->SetString("8 ");
- ValEntry *highBit = CopyValEntry(0x0028,0x0102);
- highBit->SetValue("7 ");
+ DataEntry *highBit = CopyDataEntry(0x0028,0x0102);
+ highBit->SetString("7 ");
Archive->Push(bitsAlloc);
Archive->Push(bitsStored);
std::string ts = Util::DicomString(
Global::GetTS()->GetSpecialTransferSyntax(TS::ExplicitVRLittleEndian) );
- ValEntry *tss = CopyValEntry(0x0002,0x0010);
- tss->SetValue(ts);
+ DataEntry *tss = CopyDataEntry(0x0002,0x0010);
+ tss->SetString(ts);
Archive->Push(tss);
}
std::string ts = Util::DicomString(
Global::GetTS()->GetSpecialTransferSyntax(TS::ImplicitVRLittleEndian) );
- ValEntry *tss = CopyValEntry(0x0002,0x0010);
- tss->SetValue(ts);
+ DataEntry *tss = CopyDataEntry(0x0002,0x0010);
+ tss->SetString(ts);
Archive->Push(tss);
}
*/
void FileHelper::SetWriteToLibido()
{
- ValEntry *oldRow = dynamic_cast<ValEntry *>
- (FileInternal->GetDocEntry(0x0028, 0x0010));
- ValEntry *oldCol = dynamic_cast<ValEntry *>
- (FileInternal->GetDocEntry(0x0028, 0x0011));
+ DataEntry *oldRow = FileInternal->GetDataEntry(0x0028, 0x0010);
+ DataEntry *oldCol = FileInternal->GetDataEntry(0x0028, 0x0011);
if ( oldRow && oldCol )
{
std::string rows, columns;
- ValEntry *newRow=new ValEntry(oldRow->GetDictEntry());
- ValEntry *newCol=new ValEntry(oldCol->GetDictEntry());
+ DataEntry *newRow=new DataEntry(oldRow->GetDictEntry());
+ DataEntry *newCol=new DataEntry(oldCol->GetDictEntry());
newRow->Copy(oldCol);
newCol->Copy(oldRow);
- newRow->SetValue(oldCol->GetValue());
- newCol->SetValue(oldRow->GetValue());
+ newRow->SetString(oldCol->GetString());
+ newCol->SetString(oldRow->GetString());
Archive->Push(newRow);
Archive->Push(newCol);
}
- ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
- libidoCode->SetValue("ACRNEMA_LIBIDO_1.1");
+ DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010);
+ libidoCode->SetString("ACRNEMA_LIBIDO_1.1");
Archive->Push(libidoCode);
}
*/
void FileHelper::SetWriteToNoLibido()
{
- ValEntry *recCode = dynamic_cast<ValEntry *>
- (FileInternal->GetDocEntry(0x0008,0x0010));
+ DataEntry *recCode = FileInternal->GetDataEntry(0x0008,0x0010);
if ( recCode )
{
- if ( recCode->GetValue() == "ACRNEMA_LIBIDO_1.1" )
+ if ( recCode->GetString() == "ACRNEMA_LIBIDO_1.1" )
{
- ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
- libidoCode->SetValue("");
+ DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010);
+ libidoCode->SetString("");
Archive->Push(libidoCode);
}
}
}
/**
- * \brief Duplicates a ValEntry or creates it.
- * @param group Group number of the Entry
- * @param elem Element number of the Entry
- * \return pointer to the new Val Entry (NULL when creation failed).
- */
-ValEntry *FileHelper::CopyValEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
- ValEntry *newE;
-
- if ( oldE )
- {
- newE = new ValEntry(oldE->GetDictEntry());
- newE->Copy(oldE);
- }
- else
- {
- newE = GetFile()->NewValEntry(group, elem);
- }
-
- return newE;
-}
-
-/**
- * \brief Duplicates a BinEntry or creates it.
+ * \brief Duplicates a DataEntry or creates it.
* @param group Group number of the Entry
* @param elem Element number of the Entry
* @param vr Value Representation of the Entry
* FIXME : what is it used for?
* \return pointer to the new Bin Entry (NULL when creation failed).
*/
-BinEntry *FileHelper::CopyBinEntry(uint16_t group, uint16_t elem,
- const std::string &vr)
+DataEntry *FileHelper::CopyDataEntry(uint16_t group, uint16_t elem,
+ const TagName &vr)
{
DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
- BinEntry *newE;
+ DataEntry *newE;
- if ( oldE )
+ if ( oldE && vr != GDCM_UNKNOWN )
if ( oldE->GetVR()!=vr )
oldE = NULL;
if ( oldE )
{
- newE = new BinEntry(oldE->GetDictEntry());
+ newE = new DataEntry(oldE->GetDictEntry());
newE->Copy(oldE);
}
else
{
- newE = GetFile()->NewBinEntry(group, elem, vr);
+ newE = GetFile()->NewDataEntry(group, elem, vr);
}
return newE;
// Create them if not found
// Always modify the value
// Push the entries to the archive.
- ValEntry *e_0002_0000 = CopyValEntry(0x0002,0x0000);
- e_0002_0000->SetValue("0"); // for the moment
- Archive->Push(e_0002_0000);
+ CopyMandatoryEntry(0x0002,0x0000,"0");
- BinEntry *e_0002_0001 = CopyBinEntry(0x0002,0x0001, "OB");
+ DataEntry *e_0002_0001 = CopyDataEntry(0x0002,0x0001, "OB");
e_0002_0001->SetBinArea((uint8_t*)Util::GetFileMetaInformationVersion(),
false);
e_0002_0001->SetLength(2);
Archive->Push(e_0002_0001);
// 'Media Stored SOP Class UID'
- ValEntry *e_0002_0002 = CopyValEntry(0x0002,0x0002);
// [Secondary Capture Image Storage]
- e_0002_0002->SetValue("1.2.840.10008.5.1.4.1.1.7");
- Archive->Push(e_0002_0002);
+ CopyMandatoryEntry(0x0002,0x0002,"1.2.840.10008.5.1.4.1.1.7");
// 'Media Stored SOP Instance UID'
- ValEntry *e_0002_0003 = CopyValEntry(0x0002,0x0003);
- e_0002_0003->SetValue(Util::CreateUniqueUID());
- Archive->Push(e_0002_0003);
+ CopyMandatoryEntry(0x0002,0x0003,Util::CreateUniqueUID());
// 'Implementation Class UID'
- ValEntry *e_0002_0012 = CopyValEntry(0x0002,0x0012);
- e_0002_0012->SetValue(Util::CreateUniqueUID());
- Archive->Push(e_0002_0012);
+ CopyMandatoryEntry(0x0002,0x0012,Util::CreateUniqueUID());
// 'Implementation Version Name'
- ValEntry *e_0002_0013 = CopyValEntry(0x0002,0x0013);
std::string version = "GDCM ";
version += Util::GetVersion();
- e_0002_0013->SetValue(version);
- Archive->Push(e_0002_0013);
-
- //'Source Application Entity Title' Not Mandatory
- //ValEntry *e_0002_0016 = CopyValEntry(0x0002,0x0016);
- // e_0002_0016->SetValue("1.2.840.10008.5.1.4.1.1.7");
- // Archive->Push(e_0002_0016);
+ CopyMandatoryEntry(0x0002,0x0013,version);
}
// Push out 'LibIDO-special' entries, if any
// Deal with the pb of (Bits Stored = 12)
// - we're gonna write the image as Bits Stored = 16
- if ( FileInternal->GetEntryValue(0x0028,0x0100) == "12")
+ if ( FileInternal->GetEntryString(0x0028,0x0100) == "12")
{
- ValEntry *e_0028_0100 = CopyValEntry(0x0028,0x0100);
- e_0028_0100->SetValue("16");
- Archive->Push(e_0028_0100);
+ CopyMandatoryEntry(0x0028,0x0100,"16");
}
// Check if user wasn't drunk ;-)
int nbBitsAllocated = FileInternal->GetBitsAllocated();
if ( nbBitsAllocated == 0 || nbBitsAllocated > 32)
{
- ValEntry *e_0028_0100 = CopyValEntry(0x0028,0x0100);
- e_0028_0100->SetValue("16");
- Archive->Push(e_0028_0100);
+ CopyMandatoryEntry(0x0028,0x0100,"16");
gdcmWarningMacro("(0028,0100) changed from "
<< nbBitsAllocated << " to 16 for consistency purpose");
nbBitsAllocated = 16;
int nbBitsStored = FileInternal->GetBitsStored();
if ( nbBitsStored == 0 || nbBitsStored > nbBitsAllocated )
{
+ s.str("");
s << nbBitsAllocated;
- ValEntry *e_0028_0101 = CopyValEntry(0x0028,0x0101);
- e_0028_0101->SetValue( s.str() );
- Archive->Push(e_0028_0101);
+ CopyMandatoryEntry(0x0028,0x0101,s.str());
gdcmWarningMacro("(0028,0101) changed from "
<< nbBitsStored << " to " << nbBitsAllocated
<< " for consistency purpose" );
highBitPosition > nbBitsAllocated-1 ||
highBitPosition < nbBitsStored-1 )
{
- ValEntry *e_0028_0102 = CopyValEntry(0x0028,0x0102);
-
+ s.str("");
s << nbBitsStored - 1;
- e_0028_0102->SetValue( s.str() );
- Archive->Push(e_0028_0102);
+ CopyMandatoryEntry(0x0028,0x0102,s.str());
gdcmWarningMacro("(0028,0102) changed from "
<< highBitPosition << " to " << nbBitsAllocated-1
<< " for consistency purpose");
// we create the 'Source Image Sequence' SeqEntry
// to hold informations about the Source Image
- ValEntry *e_0008_0016 = FileInternal->GetValEntry(0x0008, 0x0016);
- if ( e_0008_0016 != 0 )
+ DataEntry *e_0008_0016 = FileInternal->GetDataEntry(0x0008, 0x0016);
+ if ( e_0008_0016 )
{
// Create 'Source Image Sequence' SeqEntry
SeqEntry *sis = new SeqEntry (
SQItem *sqi = new SQItem(1);
// (we assume 'SOP Instance UID' exists too)
// create 'Referenced SOP Class UID'
- ValEntry *e_0008_1150 = new ValEntry(
+ DataEntry *e_0008_1150 = new DataEntry(
Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1150) );
- e_0008_1150->SetValue( e_0008_0016->GetValue());
+ e_0008_1150->SetString( e_0008_0016->GetString());
sqi->AddEntry(e_0008_1150);
// create 'Referenced SOP Instance UID'
- ValEntry *e_0008_0018 = FileInternal->GetValEntry(0x0008, 0x0018);
- ValEntry *e_0008_1155 = new ValEntry(
+ DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018);
+ DataEntry *e_0008_1155 = new DataEntry(
Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1155) );
- e_0008_1155->SetValue( e_0008_0018->GetValue());
+ e_0008_1155->SetString( e_0008_0018->GetString());
sqi->AddEntry(e_0008_1155);
sis->AddSQItem(sqi,1);
Archive->Push(sis);
// 'Image Type' (The written image is no longer an 'ORIGINAL' one)
- ValEntry *e_0008_0008 = CopyValEntry(0x0008,0x0008);
- e_0008_0008->SetValue("DERIVED\\PRIMARY");
- Archive->Push(e_0008_0008);
+ CopyMandatoryEntry(0x0008,0x0008,"DERIVED\\PRIMARY");
}
else
{
// the source image was NOT a true Dicom one.
// We consider the image is a 'Secondary Capture' one
// SOP Class UID
- e_0008_0016 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0016) );
// [Secondary Capture Image Storage]
- e_0008_0016 ->SetValue("1.2.840.10008.5.1.4.1.1.7");
- Archive->Push(e_0008_0016);
+ SetMandatoryEntry(0x0008,0x0016,"1.2.840.10008.5.1.4.1.1.7");
}
// ---- The user will never have to take any action on the following ----.
-
// new value for 'SOP Instance UID'
- ValEntry *e_0008_0018 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0018) );
- e_0008_0018->SetValue( Util::CreateUniqueUID() );
- Archive->Push(e_0008_0018);
+ SetMandatoryEntry(0x0008,0x0018,Util::CreateUniqueUID());
// Instance Creation Date
- ValEntry *e_0008_0012 = CopyValEntry(0x0008,0x0012);
- std::string date = Util::GetCurrentDate();
- e_0008_0012->SetValue(date.c_str());
- Archive->Push(e_0008_0012);
+ CopyMandatoryEntry(0x0008,0x0012,Util::GetCurrentDate().c_str());
// Instance Creation Time
- ValEntry *e_0008_0013 = CopyValEntry(0x0008,0x0013);
- std::string time = Util::GetCurrentTime();
- e_0008_0013->SetValue(time.c_str());
- Archive->Push(e_0008_0013);
+ CopyMandatoryEntry(0x0008,0x0013,Util::GetCurrentTime().c_str());
// ----- Add Mandatory Entries if missing ---
-
// Entries whose type is 1 are mandatory, with a mandatory value
// Entries whose type is 1c are mandatory-inside-a-Sequence
// Entries whose type is 2 are mandatory, with a optional value
// keeping the same 'Serie Instance UID' for various images
// The user shouldn't add any image to a 'Manufacturer Serie'
// but there is no way no to allowed him to do that
- ValEntry *e_0020_000e = FileInternal->GetValEntry(0x0020, 0x000e);
- if ( !e_0020_000e )
- {
- e_0020_000e = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0020, 0x000e) );
- e_0020_000e->SetValue(Util::CreateUniqueUID() );
- Archive->Push(e_0020_000e);
- }
+ CheckMandatoryEntry(0x0020,0x000e,Util::CreateUniqueUID());
// 'Study Instance UID'
// Keep the value if exists
// keeping the same 'Study Instance UID' for various images
// The user may add images to a 'Manufacturer Study',
// adding new series to an already existing Study
- ValEntry *e_0020_000d = FileInternal->GetValEntry(0x0020, 0x000d);
- if ( !e_0020_000d )
- {
- e_0020_000d = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0020, 0x000d) );
- e_0020_000d->SetValue(Util::CreateUniqueUID() );
- Archive->Push(e_0020_000d);
- }
+ CheckMandatoryEntry(0x0020,0x000d,Util::CreateUniqueUID());
// Modality : if missing we set it to 'OTher'
- ValEntry *e_0008_0060 = FileInternal->GetValEntry(0x0008, 0x0060);
- if ( !e_0008_0060 )
- {
- e_0008_0060 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0060) );
- e_0008_0060->SetValue("OT");
- Archive->Push(e_0008_0060);
- }
+ CheckMandatoryEntry(0x0008,0x0060,"OT");
// Manufacturer : if missing we set it to 'GDCM Factory'
- ValEntry *e_0008_0070 = FileInternal->GetValEntry(0x0008, 0x0070);
- if ( !e_0008_0070 )
- {
- e_0008_0070 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0070) );
- e_0008_0070->SetValue("GDCM Factory");
- Archive->Push(e_0008_0070);
- }
+ CheckMandatoryEntry(0x0008,0x0070,"GDCM Factory");
// Institution Name : if missing we set it to 'GDCM Hospital'
- ValEntry *e_0008_0080 = FileInternal->GetValEntry(0x0008, 0x0080);
- if ( !e_0008_0080 )
- {
- e_0008_0080 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0080) );
- e_0008_0080->SetValue("GDCM Hospital");
- Archive->Push(e_0008_0080);
- }
+ CheckMandatoryEntry(0x0008,0x0080,"GDCM Hospital");
// Patient's Name : if missing, we set it to 'GDCM^Patient'
- ValEntry *e_0010_0010 = FileInternal->GetValEntry(0x0010, 0x0010);
- if ( !e_0010_0010 )
- {
- e_0010_0010 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0010, 0x0010) );
- e_0010_0010->SetValue("GDCM^Patient");
- Archive->Push(e_0010_0010);
- }
+ CheckMandatoryEntry(0x0010,0x0010,"GDCM^Patient");
// Patient's Birth Date : 'type 2' entry -> must exist, value not mandatory
- ValEntry *e_0010_0030 = FileInternal->GetValEntry(0x0010, 0x0030);
- if ( !e_0010_0030 )
- {
- e_0010_0030 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0010, 0x0030) );
- e_0010_0030->SetValue("");
- Archive->Push(e_0010_0030);
- }
+ CheckMandatoryEntry(0x0010,0x0030,"");
// Patient's Sex :'type 2' entry -> must exist, value not mandatory
- ValEntry *e_0010_0040 = FileInternal->GetValEntry(0x0010, 0x0040);
- if ( !e_0010_0040 )
- {
- e_0010_0040 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0010, 0x0040) );
- e_0010_0040->SetValue("");
- Archive->Push(e_0010_0040);
- }
+ CheckMandatoryEntry(0x0010,0x0040,"");
// Referring Physician's Name :'type 2' entry -> must exist, value not mandatory
- ValEntry *e_0008_0090 = FileInternal->GetValEntry(0x0008, 0x0090);
- if ( !e_0008_0090 )
- {
- e_0008_0090 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0090) );
- e_0008_0090->SetValue("");
- Archive->Push(e_0008_0090);
- }
+ CheckMandatoryEntry(0x0008,0x0090,"");
// Pixel Spacing : defaulted to 1.0\1.0
- ValEntry *e_0028_0030 = FileInternal->GetValEntry(0x0028, 0x0030);
- if ( !e_0028_0030 )
- {
- e_0028_0030 = new ValEntry(
- Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0028, 0x0030) );
- e_0028_0030->SetValue("1.0\\1.0");
- Archive->Push(e_0028_0030);
- }
+ CheckMandatoryEntry(0x0028,0x0030,"1.0\\1.0");
// Remove some inconstencies (probably some more will be added)
// if (0028 0008)Number of Frames exists
// Push out (0020 0052),Frame of Reference UID
// (only meaningfull within a Serie)
- ValEntry *e_0028_0008 = FileInternal->GetValEntry(0x0028, 0x0008);
+ DataEntry *e_0028_0008 = FileInternal->GetDataEntry(0x0028, 0x0008);
if ( !e_0028_0008 )
{
Archive->Push(0x0020, 0X0052);
}
}
-
+
+void FileHelper::CheckMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+{
+ DataEntry *entry = FileInternal->GetDataEntry(group,elem);
+ if ( !entry )
+ {
+ entry = new DataEntry(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+ entry->SetString(value);
+ Archive->Push(entry);
+ }
+}
+
+void FileHelper::SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+{
+ DataEntry *entry = new DataEntry(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+ entry->SetString(value);
+ Archive->Push(entry);
+}
+
+void FileHelper::CopyMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+{
+ DataEntry *entry = CopyDataEntry(group,elem);
+ entry->SetString(value);
+ Archive->Push(entry);
+}
+
/**
* \brief Restore in the File the initial group 0002
*/
//-----------------------------------------------------------------------------
/**
- * \brief Prints the common part of ValEntry, BinEntry, SeqEntry
+ * \brief Prints the common part of DataEntry, SeqEntry
* @param os ostream we want to print in
* @param indent (unused)
*/
Program: gdcm
Module: $RCSfile: gdcmFileHelper.h,v $
Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- Version: $Revision: 1.22 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.23 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
class File;
-class ValEntry;
-class BinEntry;
+class DataEntry;
class SeqEntry;
class PixelReadConvert;
class PixelWriteConvert;
void SetUserFunction( VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc )
{ UserFunction = userFunc; }
// File methods
- bool SetValEntry(std::string const &content,
- uint16_t group, uint16_t elem);
- bool SetBinEntry(uint8_t *content, int lgth,
- uint16_t group, uint16_t elem);
-
- ValEntry *InsertValEntry(std::string const &content,
- uint16_t group, uint16_t elem);
- BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
+ bool SetEntryString(std::string const &content,
+ uint16_t group, uint16_t elem);
+ bool SetEntryBinArea(uint8_t *content, int lgth,
uint16_t group, uint16_t elem);
+
+ DataEntry *InsertEntryString(std::string const &content,
+ uint16_t group, uint16_t elem);
+ DataEntry *InsertEntryBinArea(uint8_t *binArea, int lgth,
+ uint16_t group, uint16_t elem);
SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
// File helpers
void SetWriteToNoLibido();
void RestoreWriteOfLibido();
- ValEntry *CopyValEntry(uint16_t group, uint16_t elem);
- BinEntry *CopyBinEntry(uint16_t group, uint16_t elem,
- const std::string &vr);
+ DataEntry *CopyDataEntry(uint16_t group, uint16_t elem,
+ const TagName &vr = GDCM_UNKNOWN);
void CheckMandatoryElements();
+ void CheckMandatoryEntry(uint16_t group,uint16_t elem,std::string value);
+ void SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value);
+ void CopyMandatoryEntry(uint16_t group,uint16_t elem,std::string value);
void RestoreWriteMandatory();
private:
Program: gdcm
Module: $RCSfile: gdcmOrientation.cxx,v $
Language: C++
- Date: $Date: 2005/10/03 14:54:16 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.17 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
val=image.GetFirstEntry()
dic={}
while(val):
- if isinstance(val,gdcm.ValEntryPtr):
+ if isinstance(val,gdcm.DataEntryPtr):
dic[val.GetName()]=val.GetValue()
val=image.GetNextEntry()
return dic
Program: gdcm
Module: $RCSfile: gdcmPixelReadConvert.cxx,v $
Language: C++
- Date: $Date: 2005/10/13 07:14:45 $
- Version: $Revision: 1.78 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.79 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
if ( HasLUT )
{
// Just in case some access to a File element requires disk access.
- LutRedDescriptor = file->GetEntryValue( 0x0028, 0x1101 );
- LutGreenDescriptor = file->GetEntryValue( 0x0028, 0x1102 );
- LutBlueDescriptor = file->GetEntryValue( 0x0028, 0x1103 );
+ LutRedDescriptor = file->GetEntryString( 0x0028, 0x1101 );
+ LutGreenDescriptor = file->GetEntryString( 0x0028, 0x1102 );
+ LutBlueDescriptor = file->GetEntryString( 0x0028, 0x1103 );
// The following comment is probabely meaningless, since LUT are *always*
// loaded at parsing time, whatever their length is.
// \TODO Reading a [Bin|Val]Entry directly from disk is a kludge.
// We should NOT bypass the [Bin|Val]Entry class. Instead
// an access to an UNLOADED content of a [Bin|Val]Entry occurence
- // (e.g. BinEntry::GetBinArea()) should force disk access from
+ // (e.g. DataEntry::GetBinArea()) should force disk access from
// within the [Bin|Val]Entry class itself. The only problem
// is that the [Bin|Val]Entry is unaware of the FILE* is was
// parsed from. Fix that. FIXME.
Program: gdcm
Module: $RCSfile: gdcmSQItem.cxx,v $
Language: C++
- Date: $Date: 2005/09/06 17:15:25 $
- Version: $Revision: 1.75 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.76 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmSQItem.h"
#include "gdcmSeqEntry.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmGlobal.h"
#include "gdcmDictSet.h"
#include "gdcmUtil.h"
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.cxx,v $
Language: C++
- Date: $Date: 2005/08/24 03:42:40 $
- Version: $Revision: 1.57 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ 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
#include "gdcmSeqEntry.h"
#include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
#include "gdcmTS.h"
#include "gdcmGlobal.h"
#include "gdcmUtil.h"
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.h,v $
Language: C++
- Date: $Date: 2005/02/11 15:22:18 $
- Version: $Revision: 1.34 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.35 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
/**
- * \brief a SeqEntry (as opposed to a ValEntry) is a non elementary DocEntry.
+ * \brief a SeqEntry (as opposed to a DataEntry) is a non elementary DocEntry.
* It is composed by a set of SQItems.
* Each SQItem is composed by a set of DocEntry
* A DocEntry may be a SeqEntry
Program: gdcm
Module: $RCSfile: gdcmSerieHelper.cxx,v $
Language: C++
- Date: $Date: 2005/10/17 15:45:38 $
- Version: $Revision: 1.23 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ 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
++it2)
{
const ExRule &r = *it2;
- s = header->GetEntryValue( r.group, r.elem );
+ s = header->GetEntryString( r.group, r.elem );
if ( !Util::CompareDicomString(s, r.value.c_str(), r.op) )
{
// Argh ! This rule is unmatched; let's just quit
// Let's add it!
// 0020 000e UI REL Series Instance UID
- const std::string &uid = header->GetEntryValue (0x0020, 0x000e);
+ const std::string &uid = header->GetEntryString(0x0020, 0x000e);
// if uid == GDCM_UNFOUND then consistently we should find GDCM_UNFOUND
// no need here to do anything special
// 0020,0032 : Image Position Patient
// 0020,0030 : Image Position (RET)
- strImPos = (*it)->GetEntryValue(0x0020,0x0032);
+ strImPos = (*it)->GetEntryString(0x0020,0x0032);
if ( strImPos == GDCM_UNFOUND)
{
gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
- strImPos = (*it)->GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
+ strImPos = (*it)->GetEntryString(0x0020,0x0030); // For ACR-NEMA images
if ( strImPos == GDCM_UNFOUND )
{
gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
// 0020,0032 : Image Position Patient
// 0020,0030 : Image Position (RET)
- strTagValue = (*it)->GetEntryValue(group,element);
+ strTagValue = (*it)->GetEntryString(group,element);
if ( CoherentFileSet.count(strTagValue) == 0 )
{
}
// Current Tag value and DICOM header match; add the file:
CoherentFileSet[strTagValue]->push_back( (*it) );
- }
+ }
return CoherentFileSet;
}
Program: gdcm
Module: $RCSfile: gdcmUtil.cxx,v $
Language: C++
- Date: $Date: 2005/10/06 18:49:30 $
- Version: $Revision: 1.164 $
+ Date: $Date: 2005/10/18 08:35:50 $
+ Version: $Revision: 1.165 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
bool Util::IsCleanString(std::string const &s)
{
- std::cout<< std::endl << s << std::endl;
+ std::cout<< std::endl << s << std::endl;
for(unsigned int i=0; i<s.size(); i++)
{
//std::cout<< std::endl << i << " : " << (unsigned char)s[i] << std::endl;
return false;
}
}
-return true;
+ return true;
}
/**
Program: gdcm
Module: $RCSfile: gdcmUtil.h,v $
Language: C++
- Date: $Date: 2005/08/25 14:55:47 $
- Version: $Revision: 1.62 $
+ Date: $Date: 2005/10/18 08:35:51 $
+ Version: $Revision: 1.63 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
std::vector<std::string> &tokens,
const std::string &delimiters = " ");
static int CountSubstring (const std::string &str,
- const std::string &subStr);
+ const std::string &subStr);
static std::string CreateCleanString(std::string const &s);
static std::string CreateCleanString(uint8_t *s, int l);
Program: gdcm
Module: $RCSfile: gdcmVR.cxx,v $
Language: C++
- Date: $Date: 2005/09/07 14:12:23 $
- Version: $Revision: 1.40 $
+ Date: $Date: 2005/10/18 08:35:51 $
+ Version: $Revision: 1.41 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/**
* \brief Simple predicate that checks whether the given argument
- * corresponds to the Value Representation of a \ref BinEntry .
+ * corresponds to the Value Representation of a \ref DataEntry .
* @param tested value representation to check for.
*/
bool VR::IsVROfBinaryRepresentable(VRKey const &tested)
/**
* \brief Simple predicate that checks whether the given argument
- * corresponds to the Value Representation of a \ref ValEntry
- * but NOT a \ref BinEntry.
+ * corresponds to the Value Representation of a representable
+ * string.
* @param tested value representation to be checked.
*/
bool VR::IsVROfStringRepresentable(VRKey const &tested)
{
-
-
return tested == "AE" ||
tested == "AS" ||
tested == "CS" ||
*/
}
+unsigned short VR::GetAtomicElementLength(VRKey const &vr)
+{
+ // Unsigned & signed short
+ if( vr == "US" || vr == "SS" )
+ return 2;
+ // Unsigned & signed long
+ if( vr == "UL" || vr == "SL" )
+ return 4;
+ // Float
+ if( vr == "FL" )
+ return 4;
+ // Double
+ if( vr == "FD" )
+ return 8;
+ // Word string
+ if( vr == "OW" )
+ return 2;
+ return 1;
+}
+
//-----------------------------------------------------------------------------
// Protected
Program: gdcm
Module: $RCSfile: gdcmVR.h,v $
Language: C++
- Date: $Date: 2005/09/06 15:36:03 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2005/10/18 08:35:51 $
+ Version: $Revision: 1.20 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
bool IsValidVR(VRKey const &key) { return vr.find(key) != vr.end(); }
+ unsigned short GetAtomicElementLength(VRKey const &vr);
+
private:
VRHT vr;
};
+++ /dev/null
-/*=========================================================================
-
- Program: gdcm
- Module: $RCSfile: gdcmValEntry.cxx,v $
- Language: C++
- Date: $Date: 2005/07/05 14:55:24 $
- Version: $Revision: 1.63 $
-
- 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.
-
-=========================================================================*/
-
-#include "gdcmValEntry.h"
-#include "gdcmVR.h"
-#include "gdcmTS.h"
-#include "gdcmGlobal.h"
-#include "gdcmUtil.h"
-#include "gdcmDebug.h"
-#include "gdcmDocument.h"
-
-#include <fstream>
-#include <ctype.h> // for isdigit
-#include <stdlib.h> // for atoi
-
-namespace gdcm
-{
-//-----------------------------------------------------------------------------
-#define MAX_SIZE_PRINT_ELEMENT_VALUE 0x7fffffff
-uint32_t ValEntry::MaxSizePrintEntry = MAX_SIZE_PRINT_ELEMENT_VALUE;
-//-----------------------------------------------------------------------------
-// Constructor / Destructor
-/**
- * \brief Constructor from a given DictEntry
- * @param e Pointer to existing dictionary entry
- */
-ValEntry::ValEntry(DictEntry *e)
- : ContentEntry(e)
-{
-}
-
-/**
- * \brief Constructor from a given DocEntry
- * @param e Pointer to existing Doc entry
- */
-ValEntry::ValEntry(DocEntry *e)
- : ContentEntry(e->GetDictEntry())
-{
- Copy(e);
-}
-
-/**
- * \brief Canonical destructor.
- */
-ValEntry::~ValEntry ()
-{
-}
-
-//-----------------------------------------------------------------------------
-// Public
-/**
- * \brief Writes the std::string representable' value of a ValEntry
- * @param fp already open ofstream pointer
- * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
- */
-void ValEntry::WriteContent(std::ofstream *fp, FileType filetype)
-{
- DocEntry::WriteContent(fp, filetype);
-
- if ( GetGroup() == 0xfffe )
- {
- return; //delimitors have NO value
- }
-
- const VRKey &vr = GetVR();
- unsigned int lgth = GetLength();
- if (vr == "US" || vr == "SS")
- {
- // some 'Short integer' fields may be multivaluated
- // each single value is separated from the next one by '\'
- // we split the string and write each value as a short int
- std::vector<std::string> tokens;
- tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
- Util::Tokenize (GetValue(), tokens, "\\");
- for (unsigned int i=0; i<tokens.size();i++)
- {
- uint16_t val_uint16 = atoi(tokens[i].c_str());
- binary_write( *fp, val_uint16);
- }
- tokens.clear();
- return;
- }
- if (vr == "UL" || vr == "SL")
- {
- // Some 'Integer' fields may be multivaluated (multiple instances
- // of integer). But each single integer value is separated from the
- // next one by '\' (backslash character). Hence we split the string
- // along the '\' and write each value as an int:
- std::vector<std::string> tokens;
- tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
- Util::Tokenize (GetValue(), tokens, "\\");
- for (unsigned int i=0; i<tokens.size();i++)
- {
- uint32_t val_uint32 = atoi(tokens[i].c_str());
- binary_write( *fp, val_uint32);
- }
- tokens.clear();
- return;
- }
-
- gdcmAssertMacro( lgth == GetValue().length() );
- binary_write(*fp, GetValue());
-}
-
-
-/**
- * \brief Header Elements too long will not be printed
- * @param newSize new size
- */
-void ValEntry::SetMaxSizePrintEntry(long newSize)
-{
- if ( newSize < 0 )
- {
- return;
- }
- if ((uint32_t)newSize >= (uint32_t)0xffffffff )
- {
- ValEntry::MaxSizePrintEntry = 0xffffffff;
- return;
- }
- ValEntry::MaxSizePrintEntry = newSize;
-}
-
-
-/**
- * \brief Sets the std::string representable' value of a ValEntry
- * @param val value to set
- */
-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
- {
- const VRKey &vr = GetVR();
- if ( vr == "US" || vr == "SS" )
- {
- // for multivaluated items
- l = (Util::CountSubstring(val, "\\") + 1) * 2;
- ContentEntry::SetValue(val);
- }
- else if ( vr == "UL" || vr == "SL" )
- {
- // for multivaluated items
- l = (Util::CountSubstring(val, "\\") + 1) * 4;;
- ContentEntry::SetValue(val);
- }
- else
- {
- std::string finalVal = Util::DicomString( val.c_str() );
- gdcmAssertMacro( !(finalVal.size() % 2) );
-
- l = finalVal.length();
- ContentEntry::SetValue(finalVal);
- }
- }
- else
- {
- std::string finalVal = Util::DicomString( val.c_str() );
- gdcmAssertMacro( !(finalVal.size() % 2) );
-
- l = finalVal.length();
- ContentEntry::SetValue(finalVal);
- }
-
- SetLength(l);
-}
-
-//-----------------------------------------------------------------------------
-// Protected
-
-//-----------------------------------------------------------------------------
-// Private
-
-//-----------------------------------------------------------------------------
-// Print
-/**
- * \brief Prints the 'std::string representable' value of ValEntry
- * @param os ostream we want to print in
- * @param indent Indentation string to be prepended during printing
- */
-void ValEntry::Print(std::ostream &os, std::string const &)
-{
- uint16_t g = GetGroup();
- uint16_t e = GetElement();
- VRKey vr = GetVR();
- std::ostringstream s;
- std::string st;
- std::string d2;
-
- os << "V ";
- DocEntry::Print(os);
-
- if (g == 0xfffe) // delimiters have NO value
- {
- // just to avoid identing all the remaining code
- return;
- }
-
- TS *ts = Global::GetTS();
-
- TSAtr v = GetValue();
- d2 = Util::CreateCleanString(v); // replace non printable characters by '.'
- if ( (long)GetLength() <= ValEntry::GetMaxSizePrintEntry()
- || PrintLevel >= 3
- || d2.find(GDCM_NOTLOADED) < d2.length() )
- {
- s << " [" << d2 << "]";
- }
- else
- {
- s << " [gdcm::too long for print (" << GetLength() << ") ]";
- }
-
- // Display the UID value (instead of displaying only the rough code)
- // First 'clean' trailing character (space or zero)
- if (g == 0x0002)
- {
- // Any more to be displayed ?
- if ( e == 0x0010 || e == 0x0002 )
- {
- if ( v.length() != 0 ) // for brain damaged headers
- {
- if ( ! isdigit((unsigned char)v[v.length()-1]) )
- {
- v.erase(v.length()-1, 1);
- }
- }
- s << " ==>\t[" << ts->GetValue(v) << "]";
- }
- }
- else
- {
- if (g == 0x0008)
- {
- if ( e == 0x0016 || e == 0x1150 )
- {
- if ( v.length() != 0 ) // for brain damaged headers
- {
- if ( ! isdigit((unsigned char)v[v.length()-1]) )
- {
- v.erase(v.length()-1, 1);
- }
- }
- s << " ==>\t[" << ts->GetValue(v) << "]";
- }
- }
- else
- {
- if (g == 0x0004)
- {
- if ( e == 0x1510 || e == 0x1512 )
- {
- if ( v.length() != 0 ) // for brain damaged headers
- {
- if ( ! isdigit((unsigned char)v[v.length()-1]) )
- {
- v.erase(v.length()-1, 1);
- }
- }
- s << " ==>\t[" << ts->GetValue(v) << "]";
- }
- }
- }
- }
- //if (e == 0x0000) { // elem 0x0000 --> group length
- if ( vr == "UL" || vr == "US" || vr == "SL" || vr == "SS" )
- {
- if (v == "4294967295") // to avoid troubles in convertion
- {
- st = "ffffffff";
- }
- else
- {
- if ( GetLength() != 0 )
- {
- st = Util::Format(" x(%x)", atoi(v.c_str()));//FIXME
- }
- else
- {
- st = " ";
- }
- }
- s << st;
- }
- os << s.str();
-}
-
-//-----------------------------------------------------------------------------
-} // end namespace gdcm
-
+++ /dev/null
-/*=========================================================================
-
- Program: gdcm
- Module: $RCSfile: gdcmValEntry.h,v $
- Language: C++
- Date: $Date: 2005/09/02 07:10:03 $
- 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
- 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 GDCMVALENTRY_H
-#define GDCMVALENTRY_H
-
-#include "gdcmDocEntry.h"
-#include "gdcmContentEntry.h"
-
-#include <iostream>
-
-namespace gdcm
-{
-//-----------------------------------------------------------------------------
-/**
- * \brief Any Dicom Document (File or DicomDir) contains
- * a set of DocEntry - Dicom entries -
- * ValEntry is an elementary DocEntry (i.e. a ContentEntry,
- * as opposed to SeqEntry)
- * whose content is 'std::string representable' : characters,
- * or integers (loaded in memory as a std::string)
- * ValEntry is a specialisation of ContentEntry
- */
-class GDCM_EXPORT ValEntry : public ContentEntry
-{
-public:
-
- // Contructors and Destructor are public.
- ValEntry(DictEntry *e);
- ValEntry(DocEntry *d);
-
- ~ValEntry();
-
- // Other accessors are inherited from gdcm::ContentEntry
-
- void Print(std::ostream &os = std::cout, std::string const &indent = "");
-
- void WriteContent(std::ofstream *fp, FileType filetype);
-
- /// Sets the value (string) of the current Dicom entry.
- /// The size is updated
- void SetValue(std::string const &val);
-
-
- /// \brief returns the size threshold above which an element value
- /// will NOT be *printed* in order no to polute the screen output
- static long GetMaxSizePrintEntry() { return ValEntry::MaxSizePrintEntry; }
-
- static void SetMaxSizePrintEntry(long);
-
-protected:
-
-private:
-
- /// \brief Size threshold above which an element val
- /// By default, this upper bound is fixed to 64 bytes.
-
- static uint32_t MaxSizePrintEntry;
-
-};
-
-} // end namespace gdcm
-
-//-----------------------------------------------------------------------------
-#endif
-
Program: gdcm
Module: $RCSfile: gdcmValidator.cxx,v $
Language: C++
- Date: $Date: 2005/06/24 10:55:59 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2005/10/18 08:35:51 $
+ 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
#include "gdcmValidator.h"
#include "gdcmElementSet.h"
-#include "gdcmBinEntry.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
#include <sstream>
{
}
-// Function to compare the VM found while parsing d->GetValue()
+// Function to compare the VM found while parsing d->GetString()
// compare to the one from the dictionary
-bool CheckVM(ValEntry *v)
+bool CheckVM(DataEntry *entry)
{
- const std::string &s = v->GetValue();
+ const std::string &s = entry->GetString();
std::string::size_type n = s.find("\\");
if ( n == s.npos ) // none found
{
unsigned int m;
std::istringstream os;
- os.str( v->GetVM());
+ os.str( entry->GetVM());
os >> m;
return n == m;
void Validator::SetInput(ElementSet *input)
{
// berk for now SetInput do two things at the same time
- gdcm::DocEntry *d=input->GetFirstEntry();
+ DocEntry *d=input->GetFirstEntry();
while(d)
{
- if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
- {
-// copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(),
-// b->GetGroup(),b->GetElement(),
-// b->GetVR() );
- (void)b;
- }
- else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
+ if ( DataEntry *v = dynamic_cast<DataEntry *>(d) )
{
if ( !CheckVM(v) )
{
std::cout << "Rah this DICOM contains one wrong tag:" <<
- v->GetValue() << " " <<
+ v->GetString() << " " <<
v->GetGroup() << "," << v->GetElement() << "," <<
v->GetVR() << " " << v->GetVM() << " " << v->GetName() << std::endl;
}
Program: gdcm
Module: $RCSfile: vtkGdcmWriter.cxx,v $
Language: C++
- Date: $Date: 2005/08/22 12:23:26 $
- Version: $Revision: 1.24 $
+ Date: $Date: 2005/10/18 08:35:55 $
+ Version: $Revision: 1.25 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#define vtkFloatingPointType float
#endif
-vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.24 $")
+vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.25 $")
vtkStandardNewMacro(vtkGdcmWriter)
//-----------------------------------------------------------------------------
str.str("");
str << dim[0];
- file->InsertValEntry(str.str(),0x0028,0x0011); // Columns
+ file->InsertEntryString(str.str(),0x0028,0x0011); // Columns
str.str("");
str << dim[1];
- file->InsertValEntry(str.str(),0x0028,0x0010); // Rows
+ file->InsertEntryString(str.str(),0x0028,0x0010); // Rows
if(dim[2]>1)
{
str.str("");
str << dim[2];
//file->Insert(str.str(),0x0028,0x0012); // Planes
- file->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames
+ file->InsertEntryString(str.str(),0x0028,0x0008); // Number of Frames
}
// Pixel type
str.str("");
str << image->GetScalarSize()*8;
- file->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
- file->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
+ file->InsertEntryString(str.str(),0x0028,0x0100); // Bits Allocated
+ file->InsertEntryString(str.str(),0x0028,0x0101); // Bits Stored
str.str("");
str << image->GetScalarSize()*8-1;
- file->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
+ file->InsertEntryString(str.str(),0x0028,0x0102); // High Bit
// Pixel Repr
// FIXME : what do we do when the ScalarType is
{
str << "1"; // Signed
}
- file->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
+ file->InsertEntryString(str.str(),0x0028,0x0103); // Pixel Representation
// Samples per pixel
str.str("");
str << image->GetNumberOfScalarComponents();
- file->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
+ file->InsertEntryString(str.str(),0x0028,0x0002); // Samples per Pixel
/// \todo : Spacing Between Slices is meaningfull ONLY for CT an MR modality
/// We should perform some checkings before forcing the Entry creation
// thus forcing to fixed point value
str.setf( std::ios::fixed );
str << sp[1] << "\\" << sp[0];
- file->InsertValEntry(str.str(),0x0028,0x0030); // Pixel Spacing
+ file->InsertEntryString(str.str(),0x0028,0x0030); // Pixel Spacing
str.str("");
str << sp[2];
- file->InsertValEntry(str.str(),0x0018,0x0088); // Spacing Between Slices
+ file->InsertEntryString(str.str(),0x0018,0x0088); // Spacing Between Slices
// Origin
vtkFloatingPointType *org = image->GetOrigin();
str.str("");
str << org[0] << "\\" << org[1] << "\\" << org[2];
- file->InsertValEntry(str.str(),0x0020,0x0032); // Image Position Patient
+ file->InsertEntryString(str.str(),0x0020,0x0032); // Image Position Patient
str.unsetf( std::ios::fixed ); //done with floating point values
// Window / Level
str.str("");
str << rng[1]-rng[0];
- file->InsertValEntry(str.str(),0x0028,0x1051); // Window Width
+ file->InsertEntryString(str.str(),0x0028,0x1051); // Window Width
str.str("");
str << (rng[1]+rng[0])/2.0;
- file->InsertValEntry(str.str(),0x0028,0x1050); // Window Center
+ file->InsertEntryString(str.str(),0x0028,0x1050); // Window Center
// Pixels
unsigned char *data;
Program: gdcm
Module: $RCSfile: vtkgdcmSerieViewer.cxx,v $
Language: C++
- Date: $Date: 2005/09/07 08:21:28 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2005/10/18 08:35:55 $
+ 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
#include "gdcmDocument.h" // for NO_SHADOWSEQ
#include "gdcmSerieHelper.h"
#include "gdcmDebug.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
#include "gdcmArgMgr.h" // for Argument Manager functions
#include <string.h> // for strcmp
// for *this* user supplied function, I supposed only ValEntries are checked.
//
std::string s1, s2;
- gdcm::ValEntry *e1,*e2;
+ gdcm::DataEntry *e1,*e2;
for (int ri=0; ri<orderNb; ri++)
{
std::cout << std::hex << elemsToOrderOn[2*ri] << "|"
<< elemsToOrderOn[2*ri+1]
<< std::endl;
- e1= f1->gdcm::Document::GetValEntry( elemsToOrderOn[2*ri],
+ e1= f1->gdcm::Document::GetDataEntry( elemsToOrderOn[2*ri],
elemsToOrderOn[2*ri+1]);
- e2= f2->gdcm::Document::GetValEntry( elemsToOrderOn[2*ri],
+ e2= f2->gdcm::Document::GetDataEntry( elemsToOrderOn[2*ri],
elemsToOrderOn[2*ri+1]);
if(!e2 || !e2)
{
<< " not found" << std::endl;
continue;
}
- s1 = e1->gdcm::ValEntry::GetValue();
- s2 = e2->gdcm::ValEntry::GetValue();
+ s1 = e1->GetString();
+ s2 = e2->GetString();
std::cout << "[" << s1 << "] vs [" << s2 << "]" << std::endl;
if ( s1 < s2 )
return true;