Update copyright date; remove old CVS keyword
[ctsim.git] / include / ctndicom.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **      Name:           ctndicomp.cpp
5 **  Purpose:      Interface to CTN Dicom header
6 **      Programmer:   Kevin Rosenberg
7 **      Date Started: March 2001
8 **
9 **  This is part of the CTSim program
10 **  Copyright (c) 1983-2009 Kevin Rosenberg
11 **
12 **  This program is free software; you can redistribute it and/or modify
13 **  it under the terms of the GNU General Public License (version 2) as
14 **  published by the Free Software Foundation.
15 **
16 **  This program is distributed in the hope that it will be useful,
17 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 **  GNU General Public License for more details.
20 **
21 **  You should have received a copy of the GNU General Public License
22 **  along with this program; if not, write to the Free Software
23 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24 ******************************************************************************/
25
26 #ifndef _CTNDICOM_H_
27 #define _CTNDICOM_H_
28 #if HAVE_CTN_DICOM
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #ifdef GCCSUNOS
34 #include <sys/types.h>
35 #endif
36
37 #include "ctsupport.h"
38
39 #if SIZEOF_LONG == 4
40 #define LONGSIZE 32
41 #elif SIZEOF_LONG ==8
42 #define LONGSIZE 64
43 #endif
44
45 #if SIZEOF_INT == 2
46 #define INTSIZE 16
47 #elif SIZEOF_INT == 4
48 #define INTSIZE 32
49 #elif SIZEOF_INT == 8
50 #define INTSIZE 64
51 #endif
52
53 #if SIZEOF_SHORT == 2
54 #define SHORTSIZE 16
55 #elif SIZEOF_SHORT == 4
56 #define SHORTSIZE 32
57 #endif
58
59 #include "dicom.h"
60 #include "ctnthread.h"
61 #include "lst.h"
62 #include "condition.h"
63 #include "dicom_objects.h"
64
65 #include <string>
66 class ImageFile;
67 class Projections;
68
69 class DicomImporter {
70 private:
71   std::string m_strFilename;
72   bool m_bFail;
73   std::string m_strFailMessage;
74   int m_iContents;
75   ImageFile* m_pImageFile;
76   Projections* m_pProjections;
77   DCM_OBJECT* m_pFile;
78
79   void loadImage(unsigned short iNRows, unsigned short iNCols, unsigned short iBitsAllocated,
80             unsigned short iBitsStored, unsigned short iHighBit, unsigned short iPixRep);
81
82   void loadProjections();
83
84   enum {
85     TAG_GROUP_SOMATOM = 0x7fe1,
86     TAG_MEMBER_SOMATOM_DATA = 0x1000,
87   };
88
89 public:
90   enum {
91     DICOM_CONTENTS_INVALID = -1,
92     DICOM_CONTENTS_IMAGE,
93     DICOM_CONTENTS_PROJECTIONS,
94   };
95
96   DicomImporter (const char* const pszFile);
97   ~DicomImporter();
98
99   bool testImage() const {return m_iContents == DICOM_CONTENTS_IMAGE;}
100   bool testProjections() const {return m_iContents == DICOM_CONTENTS_PROJECTIONS;}
101   bool fail() const {return m_bFail;}
102   const std::string& failMessage() const {return m_strFailMessage;}
103
104   ImageFile* getImageFile() const {return m_pImageFile;}
105   Projections* getProjections() const {return m_pProjections;}
106 };
107
108
109 class DicomExporter {
110 private:
111   const ImageFile* m_pImageFile;
112   std::string m_strFilename;
113   bool m_bFail;
114   std::string m_strFailMessage;
115   DCM_OBJECT* m_pObject;
116
117   bool createDicomObject();
118
119 public:
120
121   DicomExporter (ImageFile* pImageFile);
122   ~DicomExporter();
123
124   bool writeFile (const char* const pszFilename);
125   bool fail() const {return m_bFail;}
126   const std::string& failMessage() const {return m_strFailMessage;}
127 };
128
129 #endif // HAVE_CTN_DICOM
130 #endif // _CTNDICOM_H_