summaryrefslogtreecommitdiffstats
path: root/src/ConeProjectionGeometry3D.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ConeProjectionGeometry3D.cpp')
-rw-r--r--src/ConeProjectionGeometry3D.cpp57
1 files changed, 48 insertions, 9 deletions
diff --git a/src/ConeProjectionGeometry3D.cpp b/src/ConeProjectionGeometry3D.cpp
index ec64701..1976901 100644
--- a/src/ConeProjectionGeometry3D.cpp
+++ b/src/ConeProjectionGeometry3D.cpp
@@ -28,6 +28,8 @@ $Id$
#include "astra/ConeProjectionGeometry3D.h"
+#include "astra/Logging.h"
+
#include <boost/lexical_cast.hpp>
#include <cstring>
@@ -186,17 +188,22 @@ bool CConeProjectionGeometry3D::isOfType(const std::string& _sType) const
}
//----------------------------------------------------------------------------------------
-void CConeProjectionGeometry3D::toXML(XMLNode* _sNode) const
+// Get the configuration object
+Config* CConeProjectionGeometry3D::getConfiguration() const
{
- _sNode->addAttribute("type", "cone");
- _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("DistanceOriginDetector", m_fOriginDetectorDistance);
- _sNode->addChildNode("DistanceOriginSource", m_fOriginSourceDistance);
+ Config* cfg = new Config();
+ cfg->initialize("ProjectionGeometry3D");
+ cfg->self->addAttribute("type", "cone");
+ cfg->self->addChildNode("DetectorSpacingX", m_fDetectorSpacingX);
+ cfg->self->addChildNode("DetectorSpacingY", m_fDetectorSpacingY);
+ cfg->self->addChildNode("DetectorRowCount", m_iDetectorRowCount);
+ cfg->self->addChildNode("DetectorColCount", m_iDetectorColCount);
+ cfg->self->addChildNode("DistanceOriginDetector", m_fOriginDetectorDistance);
+ cfg->self->addChildNode("DistanceOriginSource", m_fOriginSourceDistance);
+ cfg->self->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
+ return cfg;
}
+
//----------------------------------------------------------------------------------------
CVector3D CConeProjectionGeometry3D::getProjectionDirection(int _iProjectionIndex, int _iDetectorIndex) const
@@ -225,4 +232,36 @@ CVector3D CConeProjectionGeometry3D::getProjectionDirection(int _iProjectionInde
return ret;
}
+void CConeProjectionGeometry3D::projectPoint(float32 fX, float32 fY, float32 fZ,
+ int iAngleIndex,
+ float32 &fU, float32 &fV) const
+{
+ ASTRA_ASSERT(iAngleIndex >= 0);
+ ASTRA_ASSERT(iAngleIndex < m_iProjectionAngleCount);
+
+ float alpha = m_pfProjectionAngles[iAngleIndex];
+
+ // Project point onto optical axis
+
+ // Projector direction is (cos(alpha), sin(alpha))
+ // Vector source->origin is (-sin(alpha), cos(alpha))
+
+ // Distance from source, projected on optical axis
+ float fD = -sin(alpha) * fX + cos(alpha) * fY + m_fOriginSourceDistance;
+
+ // Scale fZ to detector plane
+ fV = detectorOffsetYToRowIndexFloat( (fZ * (m_fOriginSourceDistance + m_fOriginDetectorDistance)) / fD );
+
+
+ // Orthogonal distance in XY-plane to optical axis
+ float fS = cos(alpha) * fX + sin(alpha) * fY;
+
+ // Scale fS to detector plane
+ fU = detectorOffsetXToColIndexFloat( (fS * (m_fOriginSourceDistance + m_fOriginDetectorDistance)) / fD );
+
+ ASTRA_DEBUG("alpha: %f, D: %f, V: %f, S: %f, U: %f", alpha, fD, fV, fS, fU);
+
+}
+
+
} // end namespace astra