summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWim van Aarle <wimvanaarle@gmail.com>2015-02-26 13:47:59 +0100
committerWim van Aarle <wimvanaarle@gmail.com>2015-02-26 13:47:59 +0100
commitcca150841cd1de4f3b4d24c1188263b9623bc511 (patch)
treedca9846737f33fd9173a53231bd0bec566fb6bb3 /src
parent065d9c6a18f2b8eececc608ce850a9a308ca6356 (diff)
downloadastra-cca150841cd1de4f3b4d24c1188263b9623bc511.tar.gz
astra-cca150841cd1de4f3b4d24c1188263b9623bc511.tar.bz2
astra-cca150841cd1de4f3b4d24c1188263b9623bc511.tar.xz
astra-cca150841cd1de4f3b4d24c1188263b9623bc511.zip
get_geometry now uses XML config object (for projections)
Diffstat (limited to 'src')
-rw-r--r--src/ConeProjectionGeometry3D.cpp18
-rw-r--r--src/ConeVecProjectionGeometry3D.cpp33
-rw-r--r--src/FanFlatProjectionGeometry2D.cpp14
-rw-r--r--src/FanFlatVecProjectionGeometry2D.cpp24
-rw-r--r--src/ParallelProjectionGeometry2D.cpp14
-rw-r--r--src/ParallelProjectionGeometry3D.cpp17
-rw-r--r--src/ParallelVecProjectionGeometry3D.cpp34
-rw-r--r--src/SparseMatrixProjectionGeometry2D.cpp13
-rw-r--r--src/XMLNode.cpp10
9 files changed, 170 insertions, 7 deletions
diff --git a/src/ConeProjectionGeometry3D.cpp b/src/ConeProjectionGeometry3D.cpp
index e6999df..50f2c8f 100644
--- a/src/ConeProjectionGeometry3D.cpp
+++ b/src/ConeProjectionGeometry3D.cpp
@@ -197,6 +197,24 @@ void CConeProjectionGeometry3D::toXML(XMLNode* _sNode) const
_sNode->addChildNode("DistanceOriginDetector", m_fOriginDetectorDistance);
_sNode->addChildNode("DistanceOriginSource", m_fOriginSourceDistance);
}
+
+//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CConeProjectionGeometry3D::getConfiguration() const
+{
+ 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
diff --git a/src/ConeVecProjectionGeometry3D.cpp b/src/ConeVecProjectionGeometry3D.cpp
index 3c32527..4f58188 100644
--- a/src/ConeVecProjectionGeometry3D.cpp
+++ b/src/ConeVecProjectionGeometry3D.cpp
@@ -210,6 +210,39 @@ void CConeVecProjectionGeometry3D::toXML(XMLNode* _sNode) const
// TODO:
//_sNode->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
}
+//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CConeVecProjectionGeometry3D::getConfiguration() const
+{
+ Config* cfg = new Config();
+ cfg->initialize("ProjectionGeometry3D");
+
+ cfg->self->addAttribute("type", "cone");
+ 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.fDetUX + 0.5f*m_iDetectorColCount*p.fDetVX) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSY + 0.5f*m_iDetectorRowCount*p.fDetUY + 0.5f*m_iDetectorColCount*p.fDetVY) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSZ + 0.5f*m_iDetectorRowCount*p.fDetUZ + 0.5f*m_iDetectorColCount*p.fDetVZ) + ",";
+ 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
{
diff --git a/src/FanFlatProjectionGeometry2D.cpp b/src/FanFlatProjectionGeometry2D.cpp
index bfc7fa9..d757f18 100644
--- a/src/FanFlatProjectionGeometry2D.cpp
+++ b/src/FanFlatProjectionGeometry2D.cpp
@@ -204,6 +204,20 @@ CVector3D CFanFlatProjectionGeometry2D::getProjectionDirection(int _iProjectionI
}
//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CFanFlatProjectionGeometry2D::getConfiguration() const
+{
+ Config* cfg = new Config();
+ cfg->initialize("ProjectionGeometry2D");
+ cfg->self->addAttribute("type", "fanflat");
+ cfg->self->addChildNode("DetectorCount", getDetectorCount());
+ cfg->self->addChildNode("DetectorWidth", getDetectorWidth());
+ cfg->self->addChildNode("DistanceOriginSource", getOriginSourceDistance());
+ cfg->self->addChildNode("DistanceOriginDetector", getOriginDetectorDistance());
+ cfg->self->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
+ return cfg;
+}
+//----------------------------------------------------------------------------------------
} // namespace astra
diff --git a/src/FanFlatVecProjectionGeometry2D.cpp b/src/FanFlatVecProjectionGeometry2D.cpp
index 77f9db7..9c7b596 100644
--- a/src/FanFlatVecProjectionGeometry2D.cpp
+++ b/src/FanFlatVecProjectionGeometry2D.cpp
@@ -194,7 +194,7 @@ bool CFanFlatVecProjectionGeometry2D::isEqual(CProjectionGeometry2D* _pGeom2) co
// Is of type
bool CFanFlatVecProjectionGeometry2D::isOfType(const std::string& _sType)
{
- return (_sType == "fanflat_vec");
+ return (_sType == "fanflat_vec");
}
//----------------------------------------------------------------------------------------
@@ -227,6 +227,28 @@ bool CFanFlatVecProjectionGeometry2D::_check()
//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CFanFlatVecProjectionGeometry2D::getConfiguration() const
+{
+ Config* cfg = new Config();
+ cfg->initialize("ProjectionGeometry2D");
+ cfg->self->addAttribute("type", "fanflat_vec");
+ cfg->self->addChildNode("DetectorCount", getDetectorCount());
+ std::string vectors = "";
+ for (int i = 0; i < m_iProjectionAngleCount; ++i) {
+ SFanProjection& p = m_pProjectionAngles[i];
+ vectors += boost::lexical_cast<string>(p.fSrcX) + ",";
+ vectors += boost::lexical_cast<string>(p.fSrcY) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSX + 0.5f * m_iDetectorCount * p.fDetUX) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSY + 0.5f * m_iDetectorCount * p.fDetUY) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetUX) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetUY);
+ if (i < m_iProjectionAngleCount-1) vectors += ';';
+ }
+ cfg->self->addChildNode("Vectors", vectors);
+ return cfg;
+}
+//----------------------------------------------------------------------------------------
} // namespace astra
diff --git a/src/ParallelProjectionGeometry2D.cpp b/src/ParallelProjectionGeometry2D.cpp
index 8f8faa4..cac8f30 100644
--- a/src/ParallelProjectionGeometry2D.cpp
+++ b/src/ParallelProjectionGeometry2D.cpp
@@ -27,6 +27,7 @@ $Id$
*/
#include "astra/ParallelProjectionGeometry2D.h"
+#include <boost/lexical_cast.hpp>
#include <cstring>
@@ -168,6 +169,19 @@ bool CParallelProjectionGeometry2D::isOfType(const std::string& _sType)
{
return (_sType == "parallel");
}
+
+//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CParallelProjectionGeometry2D::getConfiguration() const
+{
+ Config* cfg = new Config();
+ cfg->initialize("ProjectionGeometry2D");
+ cfg->self->addAttribute("type", "parallel");
+ cfg->self->addChildNode("DetectorCount", getDetectorCount());
+ cfg->self->addChildNode("DetectorWidth", getDetectorWidth());
+ cfg->self->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
+ return cfg;
+}
//----------------------------------------------------------------------------------------
CVector3D CParallelProjectionGeometry2D::getProjectionDirection(int _iProjectionIndex, int _iDetectorIndex /* = 0 */)
diff --git a/src/ParallelProjectionGeometry3D.cpp b/src/ParallelProjectionGeometry3D.cpp
index 7130d71..d47a4bb 100644
--- a/src/ParallelProjectionGeometry3D.cpp
+++ b/src/ParallelProjectionGeometry3D.cpp
@@ -27,6 +27,7 @@ $Id$
*/
#include "astra/ParallelProjectionGeometry3D.h"
+#include <boost/lexical_cast.hpp>
#include <cstring>
@@ -168,6 +169,22 @@ void CParallelProjectionGeometry3D::toXML(XMLNode* _sNode) const
_sNode->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
}
+//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CParallelProjectionGeometry3D::getConfiguration() const
+{
+ Config* cfg = new Config();
+ cfg->initialize("ProjectionGeometry3D");
+ cfg->self->addAttribute("type", "parallel3d");
+ cfg->self->addChildNode("DetectorRowCount", m_iDetectorRowCount);
+ cfg->self->addChildNode("DetectorColCount", m_iDetectorColCount);
+ cfg->self->addChildNode("DetectorSpacingX", m_fDetectorSpacingX);
+ cfg->self->addChildNode("DetectorSpacingY", m_fDetectorSpacingY);
+ cfg->self->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
+ return cfg;
+}
+//----------------------------------------------------------------------------------------
+
CVector3D CParallelProjectionGeometry3D::getProjectionDirection(int _iProjectionIndex, int _iDetectorIndex) const
{
float fTheta = m_pfProjectionAngles[_iProjectionIndex];
diff --git a/src/ParallelVecProjectionGeometry3D.cpp b/src/ParallelVecProjectionGeometry3D.cpp
index 17f00a4..0f39c4a 100644
--- a/src/ParallelVecProjectionGeometry3D.cpp
+++ b/src/ParallelVecProjectionGeometry3D.cpp
@@ -211,6 +211,40 @@ void CParallelVecProjectionGeometry3D::toXML(XMLNode* _sNode) const
//_sNode->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
}
+//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CParallelVecProjectionGeometry3D::getConfiguration() const
+{
+ Config* cfg = new Config();
+ cfg->initialize("ProjectionGeometry3D");
+
+ cfg->self->addAttribute("type", "parallel3d");
+ cfg->self->addChildNode("DetectorRowCount", m_iDetectorRowCount);
+ cfg->self->addChildNode("DetectorColCount", m_iDetectorColCount);
+
+ std::string vectors = "";
+ for (int i = 0; i < m_iProjectionAngleCount; ++i) {
+ SPar3DProjection& p = m_pProjectionAngles[i];
+ vectors += boost::lexical_cast<string>(p.fRayX) + ",";
+ vectors += boost::lexical_cast<string>(p.fRayY) + ",";
+ vectors += boost::lexical_cast<string>(p.fRayZ) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSX + 0.5f*m_iDetectorRowCount*p.fDetUX + 0.5f*m_iDetectorColCount*p.fDetVX) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSY + 0.5f*m_iDetectorRowCount*p.fDetUY + 0.5f*m_iDetectorColCount*p.fDetVY) + ",";
+ vectors += boost::lexical_cast<string>(p.fDetSZ + 0.5f*m_iDetectorRowCount*p.fDetUZ + 0.5f*m_iDetectorColCount*p.fDetVZ) + ",";
+ 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 CParallelVecProjectionGeometry3D::getProjectionDirection(int _iProjectionIndex, int _iDetectorIndex) const
{
const SPar3DProjection& p = m_pProjectionAngles[_iProjectionIndex];
diff --git a/src/SparseMatrixProjectionGeometry2D.cpp b/src/SparseMatrixProjectionGeometry2D.cpp
index 7f14d9d..86357d2 100644
--- a/src/SparseMatrixProjectionGeometry2D.cpp
+++ b/src/SparseMatrixProjectionGeometry2D.cpp
@@ -189,7 +189,20 @@ bool CSparseMatrixProjectionGeometry2D::isOfType(const std::string& _sType)
return (_sType == "sparse_matrix");
}
//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CSparseMatrixProjectionGeometry2D::getConfiguration() const
+{
+ Config* cfg = new Config();
+ cfg->initialize("ProjectionGeometry2D");
+ cfg->self->addAttribute("type", "sparse matrix");
+ cfg->self->addChildNode("DetectorCount", getDetectorCount());
+ cfg->self->addChildNode("DetectorWidth", getDetectorWidth());
+ cfg->self->addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
+ cfg->self->addChildNode("MatrixID", CMatrixManager::getSingleton().getIndex(m_pMatrix));
+ return cfg;
+}
+//----------------------------------------------------------------------------------------
CVector3D CSparseMatrixProjectionGeometry2D::getProjectionDirection(int _iProjectionIndex, int _iDetectorIndex)
{
CVector3D vOutput(0.0f, 0.0f, 0.0f);
diff --git a/src/XMLNode.cpp b/src/XMLNode.cpp
index a5b6796..4b2bdf4 100644
--- a/src/XMLNode.cpp
+++ b/src/XMLNode.cpp
@@ -448,13 +448,11 @@ void XMLNode::setContent(float32 _fValue)
// Set content - LIST
void XMLNode::setContent(float32* pfList, int _iSize)
{
- addAttribute("listsize", _iSize);
- for (int i = 0; i < _iSize; i++) {
- XMLNode* item = addChildNode("ListItem");
- item->addAttribute("index", i);
- item->addAttribute("value",pfList[i]);
- delete item;
+ std::string str = (_iSize > 0) ? boost::lexical_cast<std::string>(pfList[0]) : "";
+ for (int i = 1; i < _iSize; i++) {
+ str += "," + boost::lexical_cast<std::string>(pfList[i]);
}
+ setContent(str);
}
//-----------------------------------------------------------------------------