GDCM 3.0.24
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();
gen.SetFilenames( filenames );
gen.SetDescriptor( descriptor );
if( !gen.Generate() )
{
return 1;
}
gdcm.Writer writer = new Writer();
writer.SetFile( gen.GetFile() );
writer.SetFileName( outfilename );
if( !writer.Write() )
{
return 1;
}
return 0;
}
}
DICOMDIRGenerator class.
Definition gdcmDICOMDIRGenerator.h:57
bool Generate()
Main function to generate the DICOMDIR.
void SetDescriptor(const char *d)
void SetFilenames(FilenamesType const &fns)
Set the list of filenames from which the DICOMDIR should be generated from.
Class for manipulation directories.
Definition gdcmDirectory.h:43
unsigned int Load(FilenameType const &name, bool recursive=false)
FilenamesType const & GetFilenames() const
Set/Get the file names within the directory.
Definition gdcmDirectory.h:58
Class to represent a File Meta Information.
Definition gdcmFileMetaInformation.h:41
static void SetSourceApplicationEntityTitle(const char *title)
Writer ala DOM (Document Object Model)
Definition gdcmWriter.h:49
virtual bool Write()
Main function to tell the writer to write.
void SetFile(const File &f)
Set/Get the DICOM file (DataSet + Header)
Definition gdcmWriter.h:66
void SetFileName(const char *filename_native)
Set the filename of DICOM file to write:
Definition gdcmASN1.h:21