1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/*
-----------------------------------------------------------------------
Copyright 2012 iMinds-Vision Lab, University of Antwerp
Contact: astra@ua.ac.be
Website: http://astra.ua.ac.be
This file is part of the
All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox").
The ASTRA Toolbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The ASTRA Toolbox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------
$Id$
*/
#include "astra/ParallelProjectionGeometry3D.h"
#include <cstring>
using namespace std;
namespace astra
{
//----------------------------------------------------------------------------------------
// Default constructor.
CParallelProjectionGeometry3D::CParallelProjectionGeometry3D() :
CProjectionGeometry3D()
{
}
//----------------------------------------------------------------------------------------
// Constructor.
CParallelProjectionGeometry3D::CParallelProjectionGeometry3D(int _iProjectionAngleCount,
int _iDetectorRowCount,
int _iDetectorColCount,
float32 _fDetectorWidth,
float32 _fDetectorHeight,
const float32* _pfProjectionAngles,
const float32* _pfExtraDetectorOffsetsX,
const float32* _pfExtraDetectorOffsetsY) :
CProjectionGeometry3D()
{
initialize(_iProjectionAngleCount,
_iDetectorRowCount,
_iDetectorColCount,
_fDetectorWidth,
_fDetectorHeight,
_pfProjectionAngles,
_pfExtraDetectorOffsetsX,
_pfExtraDetectorOffsetsY);
}
//----------------------------------------------------------------------------------------
// Destructor.
CParallelProjectionGeometry3D::~CParallelProjectionGeometry3D()
{
}
//---------------------------------------------------------------------------------------
// Initialize - Config
bool CParallelProjectionGeometry3D::initialize(const Config& _cfg)
{
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CProjectionGeometry3D> CC("ParallelProjectionGeometry3D", this, _cfg);
// initialization of parent class
CProjectionGeometry3D::initialize(_cfg);
// success
m_bInitialized = _check();
return m_bInitialized;
}
//----------------------------------------------------------------------------------------
// Initialization.
bool CParallelProjectionGeometry3D::initialize(int _iProjectionAngleCount,
int _iDetectorRowCount,
int _iDetectorColCount,
float32 _fDetectorWidth,
float32 _fDetectorHeight,
const float32* _pfProjectionAngles,
const float32* _pfExtraDetectorOffsetsX,
const float32* _pfExtraDetectorOffsetsY)
{
_initialize(_iProjectionAngleCount,
_iDetectorRowCount,
_iDetectorColCount,
_fDetectorWidth,
_fDetectorHeight,
_pfProjectionAngles,
_pfExtraDetectorOffsetsX,
_pfExtraDetectorOffsetsY);
// success
m_bInitialized = _check();
return m_bInitialized;
}
//----------------------------------------------------------------------------------------
// Clone
CProjectionGeometry3D* CParallelProjectionGeometry3D::clone() const
{
CParallelProjectionGeometry3D* res = new CParallelProjectionGeometry3D();
res->m_bInitialized = m_bInitialized;
res->m_iProjectionAngleCount = m_iProjectionAngleCount;
res->m_iDetectorRowCount = m_iDetectorRowCount;
res->m_iDetectorColCount = m_iDetectorColCount;
res->m_iDetectorTotCount = m_iDetectorTotCount;
res->m_fDetectorSpacingX = m_fDetectorSpacingX;
res->m_fDetectorSpacingY = m_fDetectorSpacingY;
res->m_pfProjectionAngles = new float32[m_iProjectionAngleCount];
memcpy(res->m_pfProjectionAngles, m_pfProjectionAngles, sizeof(float32)*m_iProjectionAngleCount);
res->m_pfExtraDetectorOffsetsX = new float32[m_iProjectionAngleCount];
memcpy(res->m_pfExtraDetectorOffsetsX, m_pfExtraDetectorOffsetsX, sizeof(float32)*m_iProjectionAngleCount);
res->m_pfExtraDetectorOffsetsY = new float32[m_iProjectionAngleCount];
memcpy(res->m_pfExtraDetectorOffsetsY, m_pfExtraDetectorOffsetsY, sizeof(float32)*m_iProjectionAngleCount);
return res;
}
//----------------------------------------------------------------------------------------
// is equal
bool CParallelProjectionGeometry3D::isEqual(const CProjectionGeometry3D * _pGeom2) const
{
if (_pGeom2 == NULL) return false;
// try to cast argument to CParallelProjectionGeometry3D
const CParallelProjectionGeometry3D* pGeom2 = dynamic_cast<const CParallelProjectionGeometry3D*>(_pGeom2);
if (pGeom2 == NULL) return false;
// both objects must be initialized
if (!m_bInitialized || !pGeom2->m_bInitialized) return false;
// check all values
if (m_iProjectionAngleCount != pGeom2->m_iProjectionAngleCount) return false;
if (m_iDetectorRowCount != pGeom2->m_iDetectorRowCount) return false;
if (m_iDetectorColCount != pGeom2->m_iDetectorColCount) return false;
if (m_iDetectorTotCount != pGeom2->m_iDetectorTotCount) return false;
if (m_fDetectorSpacingX != pGeom2->m_fDetectorSpacingX) return false;
if (m_fDetectorSpacingY != pGeom2->m_fDetectorSpacingY) return false;
for (int i = 0; i < m_iProjectionAngleCount; ++i) {
if (m_pfProjectionAngles[i] != pGeom2->m_pfProjectionAngles[i]) return false;
}
return true;
}
//----------------------------------------------------------------------------------------
// is of type
bool CParallelProjectionGeometry3D::isOfType(const std::string& _sType) const
{
return (_sType == "parallel");
}
//----------------------------------------------------------------------------------------
void CParallelProjectionGeometry3D::toXML(XMLNode* _sNode) const
{
_sNode->addAttribute("type","parallel3d");
_sNode->addChildNode("DetectorSpacingX", m_fDetectorSpacingX);
_sNode->addChildNode("DetectorSpacingY", m_fDetectorSpacingY);
_sNode->addChildNode("DetectorRowCount", m_iDetectorRowCount);
_sNode->addChildNode("DetectorColCount", m_iDetectorColCount);
_sNode->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
_sNode->addChildNode("ExtraDetectorOffsetsX", m_pfExtraDetectorOffsetsX, m_iProjectionAngleCount);
_sNode->addChildNode("ExtraDetectorOffsetsY", m_pfExtraDetectorOffsetsY, m_iProjectionAngleCount);
}
CVector3D CParallelProjectionGeometry3D::getProjectionDirection(int _iProjectionIndex, int _iDetectorIndex) const
{
float fTheta = m_pfProjectionAngles[_iProjectionIndex];
float fDirX = cosf(fTheta);
float fDirY = sinf(fTheta);
float fDirZ = 0.0f;
return CVector3D(fDirX, fDirY, fDirZ);
}
CParallelProjectionGeometry2D * CParallelProjectionGeometry3D::createProjectionGeometry2D() const
{
const float32 * pfProjectionAngles = getProjectionAngles(); //new float32[getProjectionCount()];
//getProjectionAngles(pfProjectionAngles);
CParallelProjectionGeometry2D * pOutput = new CParallelProjectionGeometry2D(getProjectionCount(),
getDetectorColCount(), getDetectorSpacingX(), pfProjectionAngles,getExtraDetectorOffsetsX());
//delete [] pfProjectionAngles;
return pOutput;
}
//----------------------------------------------------------------------------------------
} // end namespace astra
|