summaryrefslogtreecommitdiffstats
path: root/src/ConeVecProjectionGeometry3D.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ConeVecProjectionGeometry3D.cpp')
-rw-r--r--src/ConeVecProjectionGeometry3D.cpp58
1 files changed, 51 insertions, 7 deletions
diff --git a/src/ConeVecProjectionGeometry3D.cpp b/src/ConeVecProjectionGeometry3D.cpp
index 512b26c..9dc273d 100644
--- a/src/ConeVecProjectionGeometry3D.cpp
+++ b/src/ConeVecProjectionGeometry3D.cpp
@@ -198,18 +198,42 @@ bool CConeVecProjectionGeometry3D::isEqual(const CProjectionGeometry3D * _pGeom2
// is of type
bool CConeVecProjectionGeometry3D::isOfType(const std::string& _sType) const
{
- return (_sType == "cone3d_vec");
+ return (_sType == "cone_vec");
}
//----------------------------------------------------------------------------------------
-void CConeVecProjectionGeometry3D::toXML(XMLNode* _sNode) const
+// Get the configuration object
+Config* CConeVecProjectionGeometry3D::getConfiguration() const
{
- _sNode->addAttribute("type","cone3d_vec");
- _sNode->addChildNode("DetectorRowCount", m_iDetectorRowCount);
- _sNode->addChildNode("DetectorColCount", m_iDetectorColCount);
- // TODO:
- //_sNode->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
+ Config* cfg = new Config();
+ cfg->initialize("ProjectionGeometry3D");
+
+ cfg->self->addAttribute("type", "cone_vec");
+ cfg->self->addChildNode("DetectorRowCount", m_iDetectorRowCount);
+ cfg->self->addChildNode("DetectorColCount", m_iDetectorColCount);
+
+ std::string vectors = "";
+ for (int i = 0; i < m_iProjectionAngleCount; ++i) {
+ SConeProjection& p = m_pProjectionAngles[i];
+ vectors += boost::lexical_cast<string>(p.fSrcX) + ",";
+ vectors += boost::lexical_cast<string>(p.fSrcY) + ",";
+ vectors += boost::lexical_cast<string>(p.fSrcZ) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSX + 0.5f*m_iDetectorRowCount*p.fDetVX + 0.5f*m_iDetectorColCount*p.fDetUX) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSY + 0.5f*m_iDetectorRowCount*p.fDetVY + 0.5f*m_iDetectorColCount*p.fDetUY) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSZ + 0.5f*m_iDetectorRowCount*p.fDetVZ + 0.5f*m_iDetectorColCount*p.fDetUZ) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetUX) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetUY) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetUZ) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetVX) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetVY) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetVZ);
+ if (i < m_iProjectionAngleCount-1) vectors += ';';
+ }
+ cfg->self->addChildNode("Vectors", vectors);
+
+ return cfg;
}
+//----------------------------------------------------------------------------------------
CVector3D CConeVecProjectionGeometry3D::getProjectionDirection(int _iProjectionIndex, int _iDetectorIndex) const
{
@@ -220,6 +244,26 @@ CVector3D CConeVecProjectionGeometry3D::getProjectionDirection(int _iProjectionI
return CVector3D(p.fDetSX + (u+0.5)*p.fDetUX + (v+0.5)*p.fDetVX - p.fSrcX, p.fDetSY + (u+0.5)*p.fDetUY + (v+0.5)*p.fDetVY - p.fSrcY, p.fDetSZ + (u+0.5)*p.fDetUZ + (v+0.5)*p.fDetVZ - p.fSrcZ);
}
+void CConeVecProjectionGeometry3D::projectPoint(float32 fX, float32 fY, float32 fZ,
+ int iAngleIndex,
+ float32 &fU, float32 &fV) const
+{
+ ASTRA_ASSERT(iAngleIndex >= 0);
+ ASTRA_ASSERT(iAngleIndex < m_iProjectionAngleCount);
+
+ double fUX, fUY, fUZ, fUC;
+ double fVX, fVY, fVZ, fVC;
+ double fDX, fDY, fDZ, fDC;
+
+ computeBP_UV_Coeffs(m_pProjectionAngles[iAngleIndex],
+ fUX, fUY, fUZ, fUC, fVX, fVY, fVZ, fVC, fDX, fDY, fDZ, fDC);
+
+ // The -0.5f shifts from corner to center of detector pixels
+ double fD = fDX*fX + fDY*fY + fDZ*fZ + fDC;
+ fU = (fUX*fX + fUY*fY + fUZ*fZ + fUC) / fD - 0.5f;
+ fV = (fVX*fX + fVY*fY + fVZ*fZ + fVC) / fD - 0.5f;
+}
+
//----------------------------------------------------------------------------------------