GDCM: GenerateDICOMDIR.cs

GDCM 3.2.10

GenerateDICOMDIR.cs

This is a C# example on how to use DICOMDIRGenerator

/*=========================================================================
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.
=========================================================================*/
/*
* Simple C# example to show how to use DICOMDIRGenerator
*
* Usage:
* $ export LD_LIBRARY_PATH=$HOME/Projects/gdcm/debug-gcc/bin
* $ mono bin/GenerateDICOMDIR.exe path output_filename
*/
using System;
using gdcm;
public class GenerateDICOMDIR
{
public static int Main(string[] args)
{
string directory = args[0];
string outfilename = args[1];
Directory d = new Directory();
uint nfiles = d. Load( directory, true );
if(nfiles == 0) return 1;
//System.Console.WriteLine( "Files:\n" + d.toString() );
// Implement fast path ?
// Scanner s = new Scanner();
string descriptor = "My_Descriptor";
FilenamesType filenames = d. GetFilenames();
gdcm.DICOMDIRGenerator gen = new DICOMDIRGenerator();
gen. SetFilenames( filenames );
gen. SetDescriptor( descriptor );
if( !gen. Generate() )
{
return 1;
}
gdcm.FileMetaInformation. SetSourceApplicationEntityTitle( "GenerateDICOMDIR" );
gdcm.Writer writer = new Writer();
writer. SetFile( gen. GetFile() );
writer. SetFileName( outfilename );
if( !writer. Write() )
{
return 1;
}
return 0;
}
}
gdcm::DICOMDIRGenerator
DICOMDIRGenerator class.
Definition gdcmDICOMDIRGenerator.h:57
gdcm::DICOMDIRGenerator::Generate
bool Generate()
Main function to generate the DICOMDIR.
gdcm::DICOMDIRGenerator::SetDescriptor
void SetDescriptor(const char *d)
gdcm::DICOMDIRGenerator::SetFilenames
void SetFilenames(FilenamesType const &fns)
Set the list of filenames from which the DICOMDIR should be generated from.
gdcm::DICOMDIRGenerator::GetFile
File & GetFile()
gdcm::Directory
Class for manipulation directories.
Definition gdcmDirectory.h:43
gdcm::Directory::Load
unsigned int Load(FilenameType const &name, bool recursive=false)
gdcm::Directory::GetFilenames
FilenamesType const & GetFilenames() const
Set/Get the file names within the directory.
Definition gdcmDirectory.h:58
gdcm::FileMetaInformation
Class to represent a File Meta Information.
Definition gdcmFileMetaInformation.h:41
gdcm::FileMetaInformation::SetSourceApplicationEntityTitle
static void SetSourceApplicationEntityTitle(const char *title)
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:
gdcm
Definition gdcmASN1.h:21