X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FVolume2Dicom.cxx;h=5b5510313e00f856954d89c3e37d9ddec83f1085;hb=f45f440f9ba41ad0a37c23a93c1c8f5705c511a6;hp=05eeeb84f8b5a075f0523744f0474ad723eccdc5;hpb=145d405e9e35d7338bd1a7a3cccfa5b84befc042;p=gdcm.git diff --git a/Example/Volume2Dicom.cxx b/Example/Volume2Dicom.cxx index 05eeeb84..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: 2004/12/04 08:57:19 $ - Version: $Revision: 1.2 $ + 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 @@ -23,10 +23,10 @@ * It's aim is to show people how to write their data volume into DICOM slices */ -#include "gdcmHeader.h" +#include "gdcmFile.h" #include "gdcmDocEntry.h" #include "gdcmBinEntry.h" -#include "gdcmFile.h" +#include "gdcmFileHelper.h" #include "gdcmUtil.h" #define USAGE "USAGE: Input3DImage OutputDirectory" @@ -41,9 +41,10 @@ const unsigned int Dimension = 3; void gdcmwrite(const char *inputfile, std::string directory); -void GetFileDateAndTime(const char *inputfile, std::string &date, std::string &time); +void GetFileDateAndTime(const char *inputfile, + std::string &date, std::string &time); -int main( int argc, char * argv[] ) +int main( int argc, char *argv[] ) { if (argc < 2) { @@ -87,8 +88,8 @@ int main( int argc, char * argv[] ) if (val < min) min = val; } - float wcenter = (max+min) / 2.; - float wwidth = (max-min)>0 ? (max-min) : 1.; + //float wcenter = (max+min) / 2.; + //float wwidth = (max-min)>0 ? (max-min) : 1.; //////////////////////////////////////////////////////////// // Get file date and time // @@ -99,33 +100,33 @@ int main( int argc, char * argv[] ) //////////////////////////////////////////////////////////// // Create a new dicom header and fill in some info // //////////////////////////////////////////////////////////// - gdcm::Header *h1 = new gdcm::Header(); - - //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::File *f1 = new gdcm::File(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 //////////////////////////////////////////////////////////// @@ -134,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); @@ -143,22 +144,23 @@ 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; } // just an utility function to retrieve date and time of a file -void GetFileDateAndTime(const char *inputfile, std::string &date, std::string &time) +void GetFileDateAndTime(const char *inputfile, std::string &date, + std::string &time) { struct stat buf; if (stat(inputfile, &buf) == 0)