X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=Example%2FTestPapyrus.cxx;h=b64b6e52508e7ddae4602cb00abf25a6040eeef0;hb=964607da17055748464e4fdacd807d7e60a9c322;hp=e0f956f17e0e1e3ad172f91462658e3ad28355e7;hpb=f7f7680dd2d0e5e92be24039cd50ff0ecfff501f;p=gdcm.git diff --git a/Example/TestPapyrus.cxx b/Example/TestPapyrus.cxx index e0f956f1..b64b6e52 100644 --- a/Example/TestPapyrus.cxx +++ b/Example/TestPapyrus.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestPapyrus.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 13:28:23 $ - Version: $Revision: 1.3 $ + Date: $Date: 2005/02/01 10:34:59 $ + 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 @@ -15,8 +15,8 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ -#include "gdcmHeader.h" #include "gdcmFile.h" +#include "gdcmFileHelper.h" #include "gdcmDocument.h" #include "gdcmValEntry.h" #include "gdcmBinEntry.h" @@ -61,7 +61,7 @@ bool RemoveFile(const char* source) } // ---------------------------------------------------------------------- -// Here we load a supposed to be Papyrus File (gdcm::Header compliant) +// Here we load a supposed to be Papyrus File (gdcm::File compliant) // and then try to get the pixels, using low-level SeqEntry accessors. // Since it's not a general purpose Papyrus related program // (just a light example) we suppose *everything* is clean @@ -81,7 +81,7 @@ int main(int argc, char* argv[]) std::string output = argv[2]; if (argc > 3) - gdcm::Debug::SetDebugOn(); + gdcm::Debug::DebugOn(); if( FileExists( output.c_str() ) ) { @@ -91,12 +91,12 @@ int main(int argc, char* argv[]) return 1; } } - gdcm::File *original = new gdcm::File( filename ); - gdcm::Header *h = original->GetHeader(); + gdcm::FileHelper *original = new gdcm::FileHelper( filename ); + gdcm::File *h = original->GetFile(); // Look for private Papyrus Sequence gdcm::SeqEntry *seqPapyrus= h->GetSeqEntry(0x0041, 0x1050); - if (!h) + if (!seqPapyrus) { std::cout << "NOT a Papyrus File" << std::endl; delete h; @@ -123,12 +123,12 @@ int main(int argc, char* argv[]) // Modality, Transfer Syntax, Study Date, Study Time // Patient Name, Media Storage SOP Instance UID, etc - MediaStSOPinstUID = h->GetEntry(0x0002,0x0002); - TransferSyntax = h->GetEntry(0x0002,0x0010); - StudyDate = sqi->GetEntry(0x0008,0x0020); - StudyTime = sqi->GetEntry(0x0008,0x0030); - Modality = sqi->GetEntry(0x0008,0x0060); - PatientName = sqi->GetEntry(0x0010,0x0010); + MediaStSOPinstUID = h->GetEntryValue(0x0002,0x0002); + TransferSyntax = h->GetEntryValue(0x0002,0x0010); + StudyDate = sqi->GetEntryValue(0x0008,0x0020); + StudyTime = sqi->GetEntryValue(0x0008,0x0030); + Modality = sqi->GetEntryValue(0x0008,0x0060); + PatientName = sqi->GetEntryValue(0x0010,0x0010); std::cout << "TransferSyntax " << TransferSyntax << std::endl; @@ -143,18 +143,17 @@ int main(int argc, char* argv[]) // we brutally suppose all the images within a Papyrus file // have the same caracteristics. - // if you're aware they have not, just move the GetEntry + // if you're aware they have not, just move the GetEntryValue // inside the loop // Get caracteristics of the first image - - SamplesPerPixel = sqi->GetEntry(0x0028,0x0002); - Rows = sqi->GetEntry(0x0028,0x0010); - Columns = sqi->GetEntry(0x0028,0x0011); - BitsAllocated = sqi->GetEntry(0x0028,0x0100); - BitsStored = sqi->GetEntry(0x0028,0x0101); - HighBit = sqi->GetEntry(0x0028,0x0102); - PixelRepresentation = sqi->GetEntry(0x0028,0x0102); + 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,0x0102); // just convert those needed to compute PixelArea length int iRows = (uint32_t) atoi( Rows.c_str() ); @@ -165,16 +164,10 @@ int main(int argc, char* argv[]) int lgrImage = iRows*iColumns * iSamplesPerPixel * (iBitsAllocated/8); // compute number of images - int nbImages = 0; - while (sqi) - { - nbImages++; - sqi = seqPapyrus->GetNextSQItem(); - } + int nbImages = seqPapyrus->GetNumberOfSQItems(); std::cout <<"Number of frames :" << nbImages << std::endl; // 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; @@ -199,7 +192,7 @@ int main(int argc, char* argv[]) while (sqi) { std::cout << "One more image read. Keep waiting" << std::endl; - Rows = sqi->GetEntry(0x0028,0x0010); + Rows = sqi->GetEntryValue(0x0028,0x0010); // minimum integrity check if (Rows != previousRows) { @@ -224,29 +217,28 @@ int main(int argc, char* argv[]) std::string NumberOfFrames = gdcm::Util::Format("%d", nbImages); - gdcm::Header *n = new gdcm::Header(); - n->InitializeDefaultHeader(); + gdcm::File *n = new gdcm::File(); - n->ReplaceOrCreate(MediaStSOPinstUID, 0x0002,0x0002); + n->InsertValEntry(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->ReplaceOrCreate(TransferSyntax, 0x0002,0x0010); - n->ReplaceOrCreate(StudyDate, 0x0008,0x0020); - n->ReplaceOrCreate(StudyTime, 0x0008,0x0030); - n->ReplaceOrCreate(Modality, 0x0008,0x0060); - n->ReplaceOrCreate(PatientName, 0x0010,0x0010); - - n->ReplaceOrCreate(SamplesPerPixel, 0x0028,0x0002); - n->ReplaceOrCreate(NumberOfFrames, 0x0028,0x0008); - n->ReplaceOrCreate(Rows, 0x0028,0x0010); - n->ReplaceOrCreate(Columns, 0x0028,0x0011); - n->ReplaceOrCreate(BitsAllocated, 0x0028,0x0100); - n->ReplaceOrCreate(BitsStored, 0x0028,0x0101); - n->ReplaceOrCreate(HighBit, 0x0028,0x0102); - n->ReplaceOrCreate(PixelRepresentation,0x0028,0x0102); + //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,0x0102); // create the file - gdcm::File *file = new gdcm::File(n); + gdcm::FileHelper *file = new gdcm::FileHelper(n); file->SetImageData(PixelArea,lgrImage*nbImages); file->SetWriteTypeToDcmExplVR();