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