QIDO-RS.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 "gdcmReader.h"
#include "gdcmWriter.h"
#include "gdcmJSON.h"
/*
* Simple QIDO-RS round-trip to test implementation of gdcm::JSON
* See Sup166 for details
*/
int main(int argc, char *argv[])
{
if( argc < 2 ) return 1;
using namespace gdcm;
const char *filename = argv[1];
gdcm::Reader reader;
reader.SetFileName( filename );
if( !reader.Read() ) return 1;
gdcm::JSON json;
json.PrettyPrintOn();
std::stringstream ss;
const gdcm::File & f = reader.GetFile();
json.Code( f.GetDataSet(), ss);
std::cout << ss.str() << std::endl;
gdcm::Writer w;
gdcm::File & ff = w.GetFile();
ff.GetHeader().SetDataSetTransferSyntax( gdcm::TransferSyntax::ExplicitVRLittleEndian );
if( !json.Decode(ss, ff.GetDataSet() ) )
{
std::cerr << "Could not decode" << std::endl;
return 1;
}
w.SetFileName( "/tmp/debug.dcm" );
if( !w.Write() ) return 1;
return 0;
}
gdcm::FileMetaInformation::SetDataSetTransferSyntax
void SetDataSetTransferSyntax(const TransferSyntax &ts)
gdcm::File
a DICOM File
Definition gdcmFile.h:34
gdcm::File::GetDataSet
const DataSet & GetDataSet() const
Get Data Set.
Definition gdcmFile.h:57
gdcm::File::GetHeader
const FileMetaInformation & GetHeader() const
Get File Meta Information.
Definition gdcmFile.h:48
gdcm::JSON
Definition gdcmJSON.h:30
gdcm::JSON::PrettyPrintOn
void PrettyPrintOn()
gdcm::JSON::Code
bool Code(DataSet const &in, std::ostream &os)
gdcm::JSON::Decode
bool Decode(std::istream &is, DataSet &out)
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::TransferSyntax::ExplicitVRLittleEndian
@ ExplicitVRLittleEndian
Definition gdcmTransferSyntax.h:64
gdcm::Writer
Writer ala DOM (Document Object Model).
Definition gdcmWriter.h:49
gdcm::Writer::GetFile
File & GetFile()
Definition gdcmWriter.h:67
gdcm::Writer::Write
virtual bool Write()
Main function to tell the writer to write.
gdcm::Writer::SetFileName
void SetFileName(const char *filename_native)
Set the filename of DICOM file to write:
gdcmJSON.h
gdcmReader.h
gdcmWriter.h
gdcm
Definition gdcmASN1.h:21