Program: gdcm
Module: $RCSfile: TestCopyDicom.cxx,v $
Language: C++
- Date: $Date: 2005/01/25 15:44:22 $
- Version: $Revision: 1.36 $
+ Date: $Date: 2005/01/26 16:43:10 $
+ Version: $Revision: 1.37 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
gdcm::File *originalH = new gdcm::File( filename );
gdcm::File *copyH = new gdcm::File( );
- //First of all copy the header field by field
+ //First of all copy the file, field by field
//////////////// Step 2:
std::cout << "2...";
size_t dataSize = original->GetImageDataSize();
uint8_t* imageData = original->GetImageData();
- // Useless to set the image datas, because it's already made when
- // copying the corresponding BinEntry that contains the pixel datas
+ // Useless to set the image data, because it's already made when
+ // copying the corresponding BinEntry that contains the pixel data
copy->SetImageData(imageData, dataSize);
//////////////// Step 3:
<< "GetImageDataSize() "
<< std::endl;
std::cout << " step 2: create a copy of the readed file and the new"
- << " pixel datas are set to the copy"
+ << " pixel data are set to the copy"
<< std::endl;
std::cout << " step 3: write the copy of the image"
<< std::endl;
Program: gdcm
Module: $RCSfile: TestCopyRescaleDicom.cxx,v $
Language: C++
- Date: $Date: 2005/01/25 15:44:22 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2005/01/26 16:43:10 $
+ 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
//////////////// Step 1:
std::cout << " 1...";
- gdcm::File *originalH = new gdcm::File( filename );
- gdcm::File *copyH = new gdcm::File( );
+ gdcm::File *originalF = new gdcm::File( filename );
+ gdcm::File *copyF = new gdcm::File( );
- //First of all copy the header field by field
+ //First of all copy the file, field by field
//////////////// Step 2:
std::cout << "2...";
// Copy of the header content
- gdcm::DocEntry* d = originalH->GetFirstEntry();
+ gdcm::DocEntry* d = originalF->GetFirstEntry();
while(d)
{
if ( gdcm::BinEntry* b = dynamic_cast<gdcm::BinEntry*>(d) )
{
- copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(),
+ copyF->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(),
+ copyF->InsertValEntry( v->GetValue(),
v->GetGroup(),v->GetElement(),
v->GetVR() );
}
// We skip pb of SQ recursive exploration
}
- d=originalH->GetNextEntry();
+ d=originalF->GetNextEntry();
}
- gdcm::FileHelper *original = new gdcm::FileHelper( originalH );
- gdcm::FileHelper *copy = new gdcm::FileHelper( copyH );
+ gdcm::FileHelper *original = new gdcm::FileHelper( originalF );
+ gdcm::FileHelper *copy = new gdcm::FileHelper( copyF );
size_t dataSize = original->GetImageDataSize();
size_t rescaleSize;
uint8_t *rescaleImage;
- const std::string & bitsStored = originalH->GetEntryValue(0x0028,0x0101);
+ const std::string & bitsStored = originalF->GetEntryValue(0x0028,0x0101);
if( bitsStored == "16" )
{
std::cout << "Rescale...";
- copyH->InsertValEntry( "8", 0x0028, 0x0100); // BitsAllocated
- copyH->InsertValEntry( "8", 0x0028, 0x0101); // BitsStored
- copyH->InsertValEntry( "7", 0x0028, 0x0102); // HighBit
- copyH->InsertValEntry( "0", 0x0028, 0x0103); //Pixel Representation
+ copyF->InsertValEntry( "8", 0x0028, 0x0100); // BitsAllocated
+ copyF->InsertValEntry( "8", 0x0028, 0x0101); // BitsStored
+ copyF->InsertValEntry( "7", 0x0028, 0x0102); // HighBit
+ copyF->InsertValEntry( "0", 0x0028, 0x0103); //Pixel Representation
// We assume the value were from 0 to uint16_t max
rescaleSize = dataSize / 2;
delete original;
delete copy;
- delete originalH;
- delete copyH;
+ delete originalF;
+ delete copyF;
delete[] rescaleImage;
return 1;
}
delete copy;
- delete copyH;
+ delete copyF;
//////////////// Step 4:
std::cout << "4...";
<< " " << output << " not readable" << std::endl;
delete original;
- delete originalH;
+ delete originalF;
delete[] rescaleImage;
return 1;
size_t dataSizeWritten = copy->GetImageDataSize();
uint8_t* imageDataWritten = copy->GetImageData();
- if (originalH->GetXSize() != copy->GetFile()->GetXSize() ||
- originalH->GetYSize() != copy->GetFile()->GetYSize() ||
- originalH->GetZSize() != copy->GetFile()->GetZSize())
+ if (originalF->GetXSize() != copy->GetFile()->GetXSize() ||
+ originalF->GetYSize() != copy->GetFile()->GetYSize() ||
+ originalF->GetZSize() != copy->GetFile()->GetZSize())
{
std::cout << "Failed" << std::endl
<< " X Size differs: "
- << "X: " << originalH->GetXSize() << " # "
+ << "X: " << originalF->GetXSize() << " # "
<< copy->GetFile()->GetXSize() << " | "
- << "Y: " << originalH->GetYSize() << " # "
+ << "Y: " << originalF->GetYSize() << " # "
<< copy->GetFile()->GetYSize() << " | "
- << "Z: " << originalH->GetZSize() << " # "
+ << "Z: " << originalF->GetZSize() << " # "
<< copy->GetFile()->GetZSize() << std::endl;
delete original;
delete copy;
- delete originalH;
+ delete originalF;
delete[] rescaleImage;
return 1;
delete original;
delete copy;
- delete originalH;
+ delete originalF;
delete[] rescaleImage;
return 1;
delete original;
delete copy;
- delete originalH;
+ delete originalF;
delete[] rescaleImage;
return 1;
delete original;
delete copy;
- delete originalH;
+ delete originalF;
delete[] rescaleImage;
return 0;
<< "GetImageDataSize() "
<< std::endl;
std::cout << " step 2: create a copy of the readed file and the new"
- << " pixel datas are set to the copy"
+ << " pixel data are set to the copy"
<< std::endl;
std::cout << " step 3: write the copy of the image"
<< std::endl;
Program: gdcm
Module: $RCSfile: TestDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/01/24 16:10:50 $
- Version: $Revision: 1.32 $
+ Date: $Date: 2005/01/26 16:43:10 $
+ Version: $Revision: 1.33 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
int TestDicomDir(int argc, char* argv[])
{
- gdcm::DicomDir *e1;
+ gdcm::DicomDir *dicomdir;
gdcm::DicomDirPatient *pa;
gdcm::DicomDirStudy *st;
file += "/DICOMDIR";
}
- e1 = new gdcm::DicomDir(file);
+ dicomdir = new gdcm::DicomDir(file);
if (argc > 2)
{
int level = atoi(argv[2]);
- e1->SetPrintLevel(level);
+ dicomdir->SetPrintLevel(level);
}
// Test if the DicomDir is readable
- if( !e1->IsReadable() )
+ if( !dicomdir->IsReadable() )
{
std::cout<<" DicomDir '"<<file
<<"' is not readable"<<std::endl
<<" ...Failed"<<std::endl;
- delete e1;
+ delete dicomdir;
return 1;
}
else
}
// Test if the DicomDir contains any Patient
- if( !e1->GetFirstPatient() )
+ if( !dicomdir->GetFirstPatient() )
{
std::cout<<" DicomDir '"<<file
<<" has no patient"<<std::endl
<<" ...Failed"<<std::endl;
- delete e1;
+ delete dicomdir;
return 1;
}
<< " = PATIENT/STUDY/SERIE/IMAGE List ============================"
<< std::endl<< std::endl;
- pa = e1->GetFirstPatient();
+ pa = dicomdir->GetFirstPatient();
while ( pa )
{ // we process all the PATIENT of this DICOMDIR
std::cout << pa->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name
}
st = pa->GetNextStudy();
}
- pa = e1->GetNextPatient();
+ pa = dicomdir->GetNextPatient();
}
std::cout << std::endl << std::endl
<< " = DICOMDIR full content ===================================="
<< std::endl<< std::endl;
- e1->Print();
+ dicomdir->Print();
std::cout<<std::flush;
- delete e1;
+ delete dicomdir;
return 0;
}
Program: gdcm
Module: $RCSfile: TestDicomDirElement.cxx,v $
Language: C++
- Date: $Date: 2005/01/24 14:14:09 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2005/01/26 16:43:10 $
+ 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
int TestDicomDirElement(int , char *[])
{
- gdcm::DicomDirElement ddElt;
- ddElt.Print( std::cout );
+ gdcm::DicomDirElement *ddElt = new gdcm::DicomDirElement();
+ if (ddElt == 0)
+ {
+ std::cout << "new DicomDirElement failed" << std::endl;
+ return 1;
+ }
+ ddElt->Print( std::cout );
+ delete ddElt;
return 0;
}
Program: gdcm
Module: $RCSfile: TestDict.cxx,v $
Language: C++
- Date: $Date: 2005/01/24 14:14:09 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2005/01/26 16:43:10 $
+ 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
#include <iomanip>
int TestDict(int , char* [])
-{
+{
+
+ std::cout << "-------- Test Default Dicom Dictionary : ----------" << std::endl;
+ // Just to improve test coverage:
+ gdcm::Dict *tempDict = new gdcm::Dict("dummyFileNameThatDoesntExist");
+ // Default dict is supposed to be used.
+ tempDict->Print();
+ std::cout << "-------- end Test Default Dicom Dictionary : --------" << std::endl;
+
+ // Lets delete it.
+ delete tempDict;
+
+
// Print the DictSet
std::cout<<"#######################################################\n";
gdcm::DictSet *dicts=gdcm::Global::GetDicts();
std::cout << "Dictset is empty" << std::endl;
return 1;
}
+
+ std::cout << "----------- Print DictSet contents: ----------" << std::endl;
+ dicts->Print();
+ std::cout << "----------- End Print DictSet contents: ------" << std::endl;
+
while (d)
{
std::cout << "------------- a Dict is found : ----------" << std::endl;
entry=pubDict->GetNextEntry();
}
+ // Let's play with DicEntry stuff !
+
+ // First, we try to break an Entry.
+ entry=pubDict->GetFirstEntry();
+ entry->SetVR("PN");
+ // Should warn us !
+
return(0);
}
Program: gdcm
Module: $RCSfile: TestWriteSimple.cxx,v $
Language: C++
- Date: $Date: 2005/01/25 15:44:23 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2005/01/26 16:43:10 $
+ 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
// Step 1 : Create the header of the image
std::cout << " 1...";
- gdcm::File *header = new gdcm::File();
+ gdcm::File *fileToBuild = new gdcm::File();
std::ostringstream str;
// Set the image size
str.str("");
str << img.sizeX;
- header->InsertValEntry(str.str(),0x0028,0x0011); // Columns
+ fileToBuild->InsertValEntry(str.str(),0x0028,0x0011); // Columns
str.str("");
str << img.sizeY;
- header->InsertValEntry(str.str(),0x0028,0x0010); // Rows
+ fileToBuild->InsertValEntry(str.str(),0x0028,0x0010); // Rows
if(img.sizeZ>1)
{
str.str("");
str << img.sizeZ;
- header->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames
+ fileToBuild->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames
}
// Set the pixel type
str.str("");
str << img.componentSize;
- header->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
+ fileToBuild->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
str.str("");
str << img.componentUse;
- header->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
+ fileToBuild->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
str.str("");
str << img.componentSize - 1;
- header->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
+ fileToBuild->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
// Set the pixel representation
str.str("");
str << img.sign;
- header->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
+ fileToBuild->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
// Set the samples per pixel
str.str("");
str << img.components;
- header->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
+ fileToBuild->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
- if( !header->IsReadable() )
+ if( !fileToBuild->IsReadable() )
{
std::cout << "Failed\n"
<< " Prepared image isn't readable\n";
- delete header;
+ delete fileToBuild;
return 1;
}
// Step 3 : Create the file of the image
std::cout << "3...";
- gdcm::FileHelper *file = new gdcm::FileHelper(header);
+ gdcm::FileHelper *file = new gdcm::FileHelper(fileToBuild);
file->SetImageData(imageData,size);
// Step 4 : Set the writting mode and write the image
<< " Write mode '"<<img.writeMode<<"' is undefined\n";
delete file;
- delete header;
+ delete fileToBuild;
delete[] imageData;
return 1;
}
<< "File in unwrittable\n";
delete file;
- delete header;
+ delete fileToBuild;
delete[] imageData;
return 1;
}
std::cerr << "Failed" << std::endl
<< "Test::TestReadWriteReadCompare: Could not reread image "
<< "written:" << fileName << std::endl;
- delete header;
+ delete fileToBuild;
delete file;
delete reread;
return 1;
uint8_t* imageDataWritten = reread->GetImageData();
// Test the image size
- if (header->GetXSize() != reread->GetFile()->GetXSize() ||
- header->GetYSize() != reread->GetFile()->GetYSize() ||
- header->GetZSize() != reread->GetFile()->GetZSize())
+ if (fileToBuild->GetXSize() != reread->GetFile()->GetXSize() ||
+ fileToBuild->GetYSize() != reread->GetFile()->GetYSize() ||
+ fileToBuild->GetZSize() != reread->GetFile()->GetZSize())
{
std::cout << "Failed" << std::endl
<< " X Size differs: "
- << "X: " << header->GetXSize() << " # "
+ << "X: " << fileToBuild->GetXSize() << " # "
<< reread->GetFile()->GetXSize() << " | "
- << "Y: " << header->GetYSize() << " # "
+ << "Y: " << fileToBuild->GetYSize() << " # "
<< reread->GetFile()->GetYSize() << " | "
- << "Z: " << header->GetZSize() << " # "
+ << "Z: " << fileToBuild->GetZSize() << " # "
<< reread->GetFile()->GetZSize() << std::endl;
- delete header;
+ delete fileToBuild;
delete file;
delete reread;
delete[] imageData;
std::cout << "Failed" << std::endl
<< " Pixel areas lengths differ: "
<< size << " # " << dataSizeWritten << std::endl;
- delete header;
+ delete fileToBuild;
delete file;
delete reread;
delete[] imageData;
(void)res;
std::cout << "Failed" << std::endl
<< " Pixel differ (as expanded in memory)." << std::endl;
- delete header;
+ delete fileToBuild;
delete file;
delete reread;
delete[] imageData;
std::cout << "OK" << std::endl;
- delete header;
+ delete fileToBuild;
delete file;
delete reread;
delete[] imageData;