GDCM: MakeTemplate.cxx

GDCM 3.2.5

MakeTemplate.cxx
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.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 notice for more information.
=========================================================================*/
#include "gdcmFileAnonymizer.h"
#include "gdcmReader.h"
#include "gdcmWriter.h"
int main(int argc, char *argv[])
{
if( argc < 3 ) return 1;
const char* filename = argv[1];
const char* outfilename = argv[2];
//gdcm::Trace::DebugOn();
// Remove Pixel Data element:
gdcm::FileAnonymizer fa;
fa. SetInputFileName( filename );
fa. SetOutputFileName( outfilename );
fa. Empty( gdcm::Tag(0x7fe0,0x10) );
// cannot replace in-place DICOM header:
//fa.Replace( gdcm::Tag(0x2,0x2), "1.2.840.10008.5.1.4.1.1.7" );
if( !fa. Write() )
{
std::cerr << "impossible to remove Pixel Data attribute" << std::endl;
return 1;
}
// Update the DICOM Header:
gdcm::Reader reader;
reader. SetFileName( outfilename );
if( !reader. Read() )
{
std::cerr << "could not read back" << std::endl;
return 1;
}
gdcm::File & file = reader. GetFile();
gdcm::FileMetaInformation &fmi = file. GetHeader();
gdcm::TransferSyntax ts = gdcm::TransferSyntax::ImplicitVRLittleEndian;
ts = gdcm::TransferSyntax::ExplicitVRLittleEndian;
fmi. SetDataSetTransferSyntax(ts);
gdcm::Writer writer;
writer. SetFile( file );
writer. SetFileName( outfilename ); // warning overwrite file !
if( !writer. Write() )
{
std::cerr << "could not write back" << std::endl;
return 1;
}
return 0;
}
gdcm::FileAnonymizer
FileAnonymizer.
Definition gdcmFileAnonymizer.h:48
gdcm::FileAnonymizer::Write
bool Write()
Write the output file.
gdcm::FileAnonymizer::SetInputFileName
void SetInputFileName(const char *filename_native)
Set input filename.
gdcm::FileAnonymizer::Empty
void Empty(Tag const &t)
gdcm::FileAnonymizer::SetOutputFileName
void SetOutputFileName(const char *filename_native)
Set output filename.
gdcm::FileMetaInformation
Class to represent a File Meta Information.
Definition gdcmFileMetaInformation.h:41
gdcm::FileMetaInformation::SetDataSetTransferSyntax
void SetDataSetTransferSyntax(const TransferSyntax &ts)
gdcm::File
a DICOM File
Definition gdcmFile.h:34
gdcm::File::GetHeader
const FileMetaInformation & GetHeader() const
Get File Meta Information.
Definition gdcmFile.h:48
gdcm::Reader
Reader ala DOM (Document Object Model).
Definition gdcmReader.h:54
gdcm::Reader::GetFile
const File & GetFile() const
Set/Get File.
Definition gdcmReader.h:72
gdcm::Reader::Read
virtual bool Read()
Main function to read a file.
gdcm::Reader::SetFileName
void SetFileName(const char *filename_native)
gdcm::Tag
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
gdcm::TransferSyntax
Class to manipulate Transfer Syntax.
Definition gdcmTransferSyntax.h:40
gdcm::TransferSyntax::ExplicitVRLittleEndian
@ ExplicitVRLittleEndian
Definition gdcmTransferSyntax.h:64
gdcm::TransferSyntax::ImplicitVRLittleEndian
@ ImplicitVRLittleEndian
Definition gdcmTransferSyntax.h:62
gdcm::Writer
Writer ala DOM (Document Object Model).
Definition gdcmWriter.h:49
gdcm::Writer::Write
virtual bool Write()
Main function to tell the writer to write.
gdcm::Writer::SetFile
void SetFile(const File &f)
Set/Get the DICOM file (DataSet + Header).
Definition gdcmWriter.h:66
gdcm::Writer::SetFileName
void SetFileName(const char *filename_native)
Set the filename of DICOM file to write:
gdcmFileAnonymizer.h
gdcmReader.h
gdcmWriter.h