1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #include "clitkEsrfHstXMLFileReader.h"
22 #include <itksys/SystemTools.hxx>
23 #include <itkMetaDataObject.h>
29 EsrfHstXMLFileReader::
30 CanReadFile(const char *name)
32 if(!itksys::SystemTools::FileExists(name) ||
33 itksys::SystemTools::FileIsDirectory(name) ||
34 itksys::SystemTools::FileLength(name) == 0)
40 EsrfHstXMLFileReader::
41 StartElement(const char * itkNotUsed(name),const char ** itkNotUsed(atts))
43 m_CurCharacterData = "";
47 EsrfHstXMLFileReader::
48 EndElement(const char *name)
50 #define ENCAPLULATE_META_DATA_DOUBLE(metaName) \
51 if(itksys::SystemTools::Strucmp(name, metaName) == 0) { \
52 double d = atof(m_CurCharacterData.c_str() ); \
53 itk::EncapsulateMetaData<double>(m_Dictionary, metaName, d); \
56 #define ENCAPLULATE_META_DATA_INT(metaName) \
57 if(itksys::SystemTools::Strucmp(name, metaName) == 0) { \
58 double d = atof(m_CurCharacterData.c_str() ); \
59 itk::EncapsulateMetaData<int>(m_Dictionary, metaName, d); \
62 #define ENCAPLULATE_META_DATA_STRING(metaName) \
63 if(itksys::SystemTools::Strucmp(name, metaName) == 0) { \
64 itk::EncapsulateMetaData<std::string>(m_Dictionary, metaName, m_CurCharacterData); \
67 ENCAPLULATE_META_DATA_INT("idAc");
68 ENCAPLULATE_META_DATA_STRING("SUBVOLUME_NAME");
69 ENCAPLULATE_META_DATA_INT("SIZEX");
70 ENCAPLULATE_META_DATA_INT("SIZEY");
71 ENCAPLULATE_META_DATA_INT("SIZEZ");
72 ENCAPLULATE_META_DATA_INT("ORIGINX");
73 ENCAPLULATE_META_DATA_INT("ORIGINY");
74 ENCAPLULATE_META_DATA_INT("ORIGINZ");
75 ENCAPLULATE_META_DATA_INT("DIM_REC");
76 ENCAPLULATE_META_DATA_DOUBLE("voxelsize");
77 ENCAPLULATE_META_DATA_STRING("BYTE_ORDER");
81 EsrfHstXMLFileReader::
82 CharacterDataHandler(const char *inData, int inLength)
84 for(int i = 0; i < inLength; i++)
85 m_CurCharacterData = m_CurCharacterData + inData[i];