From: jpr Date: Fri, 8 Jul 2005 12:02:02 +0000 (+0000) Subject: End of gdcm/Example kosherization (Load related stuff) X-Git-Tag: Version1.2.bp~344 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b8e0590883fbaf04288c45cf1149ce1989e6e01f;p=gdcm.git End of gdcm/Example kosherization (Load related stuff) --- diff --git a/Example/FindTags.cxx b/Example/FindTags.cxx index 566c8634..3805438d 100644 --- a/Example/FindTags.cxx +++ b/Example/FindTags.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: FindTags.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 10:06:31 $ - Version: $Revision: 1.13 $ + Date: $Date: 2005/07/08 12:02:02 $ + 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 @@ -26,16 +26,24 @@ int main(int argc, char *argv[]) { std::string fileName; - gdcm::FileHelper *f1; - - if(argc > 1 ) - f1 = new gdcm::FileHelper(argv[1]); - else { + gdcm::FileHelper *h; + gdcm::File *f = new gdcm::File(); + + + if(argc > 1 ) + f->SetFileName(argv[1]); + else + { fileName = GDCM_DATA_ROOT; fileName += "/test.acr"; - f1 = new gdcm::FileHelper(fileName); + f->SetFileName(fileName); } - + + f->Load(); + // Should test if it worked ! + + h = new gdcm::FileHelper(f); + std::string ManufacturerName="SIEMENS "; std::string RecCode="ACR-NEMA 2.0"; std::string ImagePositionPatient, Location, ImageLocation; @@ -44,17 +52,17 @@ int main(int argc, char *argv[]) float x, y, z, l; - int dataSize = f1->GetImageDataSize(); + int dataSize = h->GetImageDataSize(); std::cout << "---> pourFindTaggs : dataSize " << dataSize << std::endl; - f1->SetValEntry(RecCode ,0x0008,0x0010); - f1->SetValEntry(ManufacturerName ,0x0008,0x0070); + h->SetValEntry(RecCode ,0x0008,0x0010); + h->SetValEntry(ManufacturerName ,0x0008,0x0070); // ImagePositionPatient - ImagePositionPatient = f1->GetFile()->GetEntryValue(0x0020,0x0032); + ImagePositionPatient = h->GetFile()->GetEntryValue(0x0020,0x0032); // Image Position (RET) - f1->SetValEntry(ImagePositionPatient, 0x0020,0x0030); + h->SetValEntry(ImagePositionPatient, 0x0020,0x0030); sscanf(ImagePositionPatient.c_str(), "%f%c%f%c%f", &x,&c,&y,&c,&z); @@ -70,7 +78,7 @@ int main(int argc, char *argv[]) // Location std::string zizi = gdcm::Util::Format("%f",l); Location = gdcm::Util::DicomString(zizi.c_str()); - f1->SetValEntry(Location, 0x0020,0x0050); + h->SetValEntry(Location, 0x0020,0x0050); // sinon, la longueur du champ est erronée (?!?) // Probable sac de noeud entre strlen(xxx.c_str()) et xxx.length() @@ -79,21 +87,21 @@ int main(int argc, char *argv[]) // SetEntryLength is private now. //TO DO : see if the pb goes on... -//f1->GetFile()->SetEntryLength(strlen(Location.c_str())-1, 0x0020,0x0050); +//h->GetFile()->SetEntryLength(strlen(Location.c_str())-1, 0x0020,0x0050); // Image Location zizi = gdcm::Util::Format("%d",0x7FE0); ImageLocation = gdcm::Util::DicomString(zizi.c_str()); -//f1->SetValEntry(Location, 0x0028,0x0200); -//f1->GetFile()->SetEntryLength(strlen(ImageLocation.c_str())-1, 0x0020,0x0050); // prudence ! +//h->SetValEntry(Location, 0x0028,0x0200); +//h->GetFile()->SetEntryLength(strlen(ImageLocation.c_str())-1, 0x0020,0x0050); // prudence ! -// void *imageData= f1->GetImageData(); +// void *imageData= h->GetImageData(); // ecriture d'un fichier ACR à partir d'un dcmFile correct. std::cout << "----------------before PrintEntry---------------------" << std::endl; - f1->GetFile()->Print(); + h->GetFile()->Print(); std::cout << "----------------before WriteDcm---------------------" << std::endl; @@ -101,7 +109,7 @@ int main(int argc, char *argv[]) fileNameToWrite = fileName + ".acr"; std::cout << "WriteACR" << std::endl; - f1->WriteAcr(fileNameToWrite); + h->WriteAcr(fileNameToWrite); std::cout << "----------------apres Write---------------------" << std::endl; diff --git a/Example/FlatHashTablePrint.cxx b/Example/FlatHashTablePrint.cxx index 183ec8c1..6aa17d22 100644 --- a/Example/FlatHashTablePrint.cxx +++ b/Example/FlatHashTablePrint.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: FlatHashTablePrint.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 10:06:31 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/07/08 12:02:02 $ + 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 @@ -30,8 +30,10 @@ int main(int, char*[]) argv[0] << " input_dicom " << std::endl; return 1; } - - gdcm::File *header = new gdcm::File( argv[1] ); + gdcm::File *header = new gdcm::File(); + header->SetFileName(argv[1] ); + header->Load(); + gdcm::TagDocEntryHT *Ht = header->BuildFlatHashTable(); for (gdcm::TagDocEntryHT::iterator tag = Ht->begin(); tag != Ht->end(); ++tag) diff --git a/Example/TestChangeHeader.cxx b/Example/TestChangeHeader.cxx index 1d74abe2..bbc4d6fa 100644 --- a/Example/TestChangeHeader.cxx +++ b/Example/TestChangeHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestChangeHeader.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 14:26:30 $ - Version: $Revision: 1.14 $ + Date: $Date: 2005/07/08 12:02:02 $ + 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 @@ -31,9 +31,16 @@ int main(int argc, char *argv[]) return 1; } - gdcm::File *h1 = new gdcm::File( argv[1] ); + gdcm::File *h1 = new gdcm::File( ); + h1->SetFileName ( argv[1] ); + h1->Load( ); gdcm::FileHelper *f1 = new gdcm::FileHelper( h1 ); - gdcm::FileHelper *f2 = new gdcm::FileHelper( argv[2] ); + + gdcm::File *h2 = new gdcm::File( ); + h2->SetFileName ( argv[2] ); + h2->Load( ); + gdcm::FileHelper *f2 = new gdcm::FileHelper( h2 ); + // 0018 1310 US ACQ Acquisition Matrix gdcm::DictEntry *dictEntry = @@ -52,6 +59,11 @@ int main(int argc, char *argv[]) h1->Print(); f1->WriteDcmExplVR("output-matrix.dcm"); + + delete f1; + delete f2; + delete h1; + delete h2; return 0; } diff --git a/Example/TestCopyDicom.cxx b/Example/TestCopyDicom.cxx index 554f3a5c..c8f67dc9 100644 --- a/Example/TestCopyDicom.cxx +++ b/Example/TestCopyDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestCopyDicom.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 14:26:30 $ - Version: $Revision: 1.24 $ + Date: $Date: 2005/07/08 12:02:02 $ + 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 @@ -80,7 +80,10 @@ int main(int argc, char *argv[]) return 1; } } - gdcm::FileHelper *original = new gdcm::FileHelper( filename ); + gdcm::File *fileOr = new gdcm::File(); + fileOr->SetFileName( filename ); + fileOr->Load(); + gdcm::FileHelper *original = new gdcm::FileHelper( fileOr ); std::cout << "--- Original ----------------------" << std::endl; //original->GetFile()->Print(); diff --git a/Example/TestFromScratch.cxx b/Example/TestFromScratch.cxx index 7bb68847..20f52c07 100644 --- a/Example/TestFromScratch.cxx +++ b/Example/TestFromScratch.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestFromScratch.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 10:06:32 $ - Version: $Revision: 1.17 $ + Date: $Date: 2005/07/08 12:02:02 $ + Version: $Revision: 1.18 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -43,8 +43,11 @@ int main(int argc, char *argv[]) //gdcm::Debug::GetReference().SetDebug(1); std::string filename = argv[1]; - gdcm::FileHelper *f1 = new gdcm::FileHelper( filename ); - gdcm::File *h1 = f1->GetFile(); + gdcm::File *h1 = new gdcm::File(); + h1->SetFileName( filename ); + h1->Load( ); + gdcm::FileHelper *f1 = new gdcm::FileHelper( h1 ); + int dataSize = f1->GetImageDataSize(); std::cout << "DataSize: " << dataSize << std::endl; @@ -84,6 +87,7 @@ int main(int argc, char *argv[]) delete f1; delete f2; + delete h1; delete h2; return 0; diff --git a/Example/TestPrintTime.cxx b/Example/TestPrintTime.cxx index 06529e29..9dbcff5a 100644 --- a/Example/TestPrintTime.cxx +++ b/Example/TestPrintTime.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestPrintTime.cxx,v $ Language: C++ - Date: $Date: 2005/05/11 14:40:56 $ - Version: $Revision: 1.2 $ + Date: $Date: 2005/07/08 12:02:02 $ + 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 @@ -52,7 +52,8 @@ int main(int, char *[]) e1= new gdcm::File( ); r1 = times(&tms1); - e1->Load( filename ); + e1->SetFileName( filename ); + e1->Load( ); r2 = times(&tms2); if (!e1->IsReadable()) std::cout << "-----------Not Readable " << std::endl; @@ -60,7 +61,9 @@ int main(int, char *[]) e1= new gdcm::File( ); e1->SetLoadMode( NO_SEQ | NO_SHADOW ); r3 = times(&tms3); - e1->Load( filename ); + e1->SetFileName( filename ); + e1->Load( ); + r4 = times(&tms4); if (!e1->IsReadable()) std::cout << "-----------Not Readable " << std::endl; @@ -92,7 +95,8 @@ int main(int, char *[]) filename += gdcmDataImages[i]; e1= new gdcm::File( ); - e1->Load( filename ); + e1->SetFileName( filename ); + e1->Load( ); if (!e1->IsReadable()) std::cout << "-----------Not Readable " << std::endl; delete e1; @@ -117,7 +121,8 @@ int main(int, char *[]) e1= new gdcm::File( ); e1->SetLoadMode( NO_SEQ | NO_SHADOW ); - e1->Load( filename ); + e1->SetFileName( filename ); + e1->Load( ); if (!e1->IsReadable()) std::cout << "-----------Not Readable " << std::endl; delete e1; diff --git a/Example/TestWriteSimple.cxx b/Example/TestWriteSimple.cxx index ee4f15f9..957ec144 100644 --- a/Example/TestWriteSimple.cxx +++ b/Example/TestWriteSimple.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestWriteSimple.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 10:06:32 $ - Version: $Revision: 1.11 $ + Date: $Date: 2005/07/08 12:02:02 $ + 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 @@ -30,7 +30,10 @@ int main(int argc, char *argv[]) std::string header = argv[1]; const char *output = argv[2]; - gdcm::File *f1 = new gdcm::File( header ); + gdcm::File *f1 = new gdcm::File( ); + f1->SetFileName ( header ); + f1->Load( ); + gdcm::FileHelper *f2 = new gdcm::FileHelper( f1 ); // If the following call is important, then the API sucks. Why is it diff --git a/Example/Volume2Dicom.cxx b/Example/Volume2Dicom.cxx index 3b852d27..5b551031 100644 --- a/Example/Volume2Dicom.cxx +++ b/Example/Volume2Dicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: Volume2Dicom.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 10:06:32 $ - Version: $Revision: 1.6 $ + Date: $Date: 2005/07/08 12:02:02 $ + 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 @@ -100,33 +100,33 @@ int main( int argc, char *argv[] ) //////////////////////////////////////////////////////////// // Create a new dicom header and fill in some info // //////////////////////////////////////////////////////////// - gdcm::File *h1 = new gdcm::File(); - - //h1->SetDateAndTime(filedate, filetime); - //h1->SetModality("CT"); - //h1->SetPatientName( "TestPatient"); - //h1->SetPatientID( "TestID"); - //h1->SetStudyID( "1"); - //h1->SetSeriesNumber( "1"); - //h1->SetSliceThickness(spacing[2]); - //h1->SetSpaceBetweenSlices(spacing[2]); - //h1->SetXYSpacing( spacing[0], spacing[1]); - //h1->SetXSize(sizex); - //h1->SetYSize(sizey); - //h1->SetNbBitsAllocated(16); - //h1->SetNbBitsStored(12); - //h1->SetNbBitsStored(12); - //h1->SetPixelSigned(true); - //h1->SetCenter( wcenter); - //h1->SetWindow( wwidth); + gdcm::File *f = new gdcm::File(); + + //f->SetDateAndTime(filedate, filetime); + //f->SetModality("CT"); + //f->SetPatientName( "TestPatient"); + //f->SetPatientID( "TestID"); + //f->SetStudyID( "1"); + //f->SetSeriesNumber( "1"); + //f->SetSliceThickness(spacing[2]); + //f->SetSpaceBetweenSlices(spacing[2]); + //f->SetXYSpacing( spacing[0], spacing[1]); + //f->SetXSize(sizex); + //f->SetYSize(sizey); + //f->SetNbBitsAllocated(16); + //f->SetNbBitsStored(12); + //f->SetNbBitsStored(12); + //f->SetPixelSigned(true); + //f->SetCenter( wcenter); + //f->SetWindow( wwidth); //////////////////////////////////////////////////////////// // Create a new dicom file object from the header // //////////////////////////////////////////////////////////// - gdcm::FileHelper *f1 = new gdcm::FileHelper(h1); - uint8_t *myData = f1->GetImageData(); // Get an Image pointer - f1->SetImageData( myData, sliceSize); // This callback ensures that the internal - // Pixel_Data of f1 is set correctly + gdcm::FileHelper *fh = new gdcm::FileHelper(f); + uint8_t *myData = fh->GetImageData(); // Get an Image pointer + fh->SetImageData( myData, sliceSize); // This callback ensures that the internal + // Pixel_Data of fh is set correctly //////////////////////////////////////////////////////////// @@ -135,8 +135,8 @@ int main( int argc, char *argv[] ) for (int z=0; zSetImageUIDFromSliceNumber(z); - //h1->SetImageLocation(orig[0],orig[1],orig[2]+z*spacing[2]); + //f->SetImageUIDFromSliceNumber(z); + //f->SetImageLocation(orig[0],orig[1],orig[2]+z*spacing[2]); // copy image slice content memcpy(myData,imageData+z*sizex*sizey,sliceSize); @@ -144,15 +144,15 @@ int main( int argc, char *argv[] ) // write the image std::string filename = directory + gdcm::Util::Format("%Image_%05d.dcm", z); std::cout << "Writing file " << filename; - f1->WriteDcmExplVR(filename); + fh->WriteDcmExplVR(filename); std::cout << " OK" << std::endl; } //////////////////////////////////////////////////////////// // Free the allocated objects // //////////////////////////////////////////////////////////// - // delete f1; // FIXME: these calls sometimes crashes under .NET ???? - // delete h1; + // delete fh; // FIXME: these calls sometimes crashes under .NET ???? + // delete f; return 0; } diff --git a/Example/WriteDicomSimple.cxx b/Example/WriteDicomSimple.cxx index 874194a0..84d98a92 100644 --- a/Example/WriteDicomSimple.cxx +++ b/Example/WriteDicomSimple.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteDicomSimple.cxx,v $ Language: C++ - Date: $Date: 2005/04/20 11:25:35 $ - Version: $Revision: 1.12 $ + Date: $Date: 2005/07/08 12:02:02 $ + 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 @@ -24,7 +24,7 @@ */ #include "gdcmFile.h" #include "gdcmFileHelper.h" - + #include #include diff --git a/Example/WriteRead.cxx b/Example/WriteRead.cxx index 8ff10006..2f247d92 100644 --- a/Example/WriteRead.cxx +++ b/Example/WriteRead.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: WriteRead.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 10:06:32 $ - Version: $Revision: 1.13 $ + Date: $Date: 2005/07/08 12:02:02 $ + 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 @@ -42,8 +42,9 @@ int main(int argc, char *argv[]) // --------------------- we read the input image std::cout << argv[1] << std::endl; - - e1 = new gdcm::File( fileName ); + e1 = new gdcm::File( ); + e1->SetFileName( fileName ); + e1->Load(); if (!e1->IsReadable()) { std::cerr << "Sorry, " << fileName <<" not a Readable DICOM / ACR File" <WriteDcmExplVR(fileNameToWrite); // --------------------- we read the written image - - e2 = new gdcm::File( fileNameToWrite ); + e2 = new gdcm::File( ); + e2->SetFileName( fileNameToWrite ); + e2->Load(); if (!e2->IsReadable()) { std::cerr << "Sorry, " << fileNameToWrite << " not a Readable DICOM / ACR File" <SetLoadMode( NO_SEQ ); - e1->Load( fileName.c_str() ); + f = new gdcm::File( ); + f->SetLoadMode( NO_SEQ ); + f->SetFileName( fileName ); + f->Load( ); - if (!e1->IsReadable()) + if (!f->IsReadable()) { std::cerr << "Sorry, not a Readable DICOM / ACR File" <Print(); + f->Print(); - imageData= f1->GetImageData(); - dataSize = f1->GetImageDataSize(); + imageData= fh->GetImageData(); + dataSize = fh->GetImageDataSize(); - f1->SetWriteModeToRGB(); + fh->SetWriteModeToRGB(); switch (mode[0]) { @@ -86,7 +87,7 @@ int main(int argc, char *argv[]) fileNameToWrite = fileName + ".ACR"; std::cout << "WriteACR" << std::endl; - f1->WriteAcr(fileNameToWrite); + fh->WriteAcr(fileNameToWrite); break; case 'd' : @@ -96,7 +97,7 @@ int main(int argc, char *argv[]) fileNameToWrite = fileName + ".DCM"; std::cout << "WriteDCM Implicit VR" << std::endl; - f1->WriteDcmImplVR(fileNameToWrite); + fh->WriteDcmImplVR(fileNameToWrite); break; case 'x' : @@ -105,7 +106,7 @@ int main(int argc, char *argv[]) fileNameToWrite = fileName + ".XDCM"; std::cout << "WriteDCM Explicit VR" << std::endl; - f1->WriteDcmExplVR(fileNameToWrite); + fh->WriteDcmExplVR(fileNameToWrite); break; case 'r' : @@ -114,15 +115,15 @@ int main(int argc, char *argv[]) fileNameToWrite = fileName + ".RAW"; std::cout << "WriteRaw" << std::endl; - f1->WriteRawData(fileNameToWrite); + fh->WriteRawData(fileNameToWrite); break; } std::cout << "-----------------------------------------------------------------" << std::endl; - e1->Print(); - delete e1; - delete f1; + f->Print(); + delete f; + delete fh; return 0; }