summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2015-09-16 12:01:02 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2015-09-16 12:01:02 +0200
commit55cbaa5df6f91594b7cd69754e04c186c7c88c97 (patch)
treeb1456253660a7762df6868d1452a6d9480e25b19 /src
parent7584ffbd6748bcca8c3f7ed2dc961be01f2fcfdc (diff)
parent026aa46c5db24ddd687cec0fa6e056a2ee3790c5 (diff)
downloadastra-55cbaa5df6f91594b7cd69754e04c186c7c88c97.tar.gz
astra-55cbaa5df6f91594b7cd69754e04c186c7c88c97.tar.bz2
astra-55cbaa5df6f91594b7cd69754e04c186c7c88c97.tar.xz
astra-55cbaa5df6f91594b7cd69754e04c186c7c88c97.zip
Merge branch 'master' into volgeom3d
Conflicts: src/CudaBackProjectionAlgorithm3D.cpp
Diffstat (limited to 'src')
-rw-r--r--src/ArtAlgorithm.cpp6
-rw-r--r--src/ConeProjectionGeometry3D.cpp26
-rw-r--r--src/ConeVecProjectionGeometry3D.cpp25
-rw-r--r--src/Config.cpp24
-rw-r--r--src/CudaBackProjectionAlgorithm3D.cpp18
-rw-r--r--src/CudaCglsAlgorithm3D.cpp24
-rw-r--r--src/CudaDartMaskAlgorithm.cpp22
-rw-r--r--src/CudaDartMaskAlgorithm3D.cpp22
-rw-r--r--src/CudaDartSmoothingAlgorithm.cpp20
-rw-r--r--src/CudaDartSmoothingAlgorithm3D.cpp20
-rw-r--r--src/CudaDataOperationAlgorithm.cpp25
-rw-r--r--src/CudaFDKAlgorithm3D.cpp17
-rw-r--r--src/CudaFilteredBackProjectionAlgorithm.cpp67
-rw-r--r--src/CudaForwardProjectionAlgorithm.cpp53
-rw-r--r--src/CudaForwardProjectionAlgorithm3D.cpp35
-rw-r--r--src/CudaProjector2D.cpp13
-rw-r--r--src/CudaProjector3D.cpp13
-rw-r--r--src/CudaReconstructionAlgorithm2D.cpp83
-rw-r--r--src/CudaRoiSelectAlgorithm.cpp13
-rw-r--r--src/CudaSartAlgorithm.cpp4
-rw-r--r--src/CudaSirtAlgorithm.cpp8
-rw-r--r--src/CudaSirtAlgorithm3D.cpp25
-rw-r--r--src/FanFlatProjectionGeometry2D.cpp22
-rw-r--r--src/FanFlatVecProjectionGeometry2D.cpp18
-rw-r--r--src/FilteredBackProjectionAlgorithm.cpp20
-rw-r--r--src/ForwardProjectionAlgorithm.cpp23
-rw-r--r--src/ParallelBeamBlobKernelProjector2D.cpp22
-rw-r--r--src/ParallelProjectionGeometry2D.cpp13
-rw-r--r--src/ParallelProjectionGeometry3D.cpp12
-rw-r--r--src/ParallelVecProjectionGeometry3D.cpp25
-rw-r--r--src/ProjectionGeometry2D.cpp17
-rw-r--r--src/ProjectionGeometry3D.cpp25
-rw-r--r--src/Projector2D.cpp6
-rw-r--r--src/Projector3D.cpp8
-rw-r--r--src/ReconstructionAlgorithm2D.cpp39
-rw-r--r--src/ReconstructionAlgorithm3D.cpp54
-rw-r--r--src/SartAlgorithm.cpp4
-rw-r--r--src/SparseMatrixProjectionGeometry2D.cpp15
-rw-r--r--src/VolumeGeometry2D.cpp30
-rw-r--r--src/VolumeGeometry3D.cpp45
-rw-r--r--src/XMLDocument.cpp10
-rw-r--r--src/XMLNode.cpp284
42 files changed, 653 insertions, 602 deletions
diff --git a/src/ArtAlgorithm.cpp b/src/ArtAlgorithm.cpp
index 8f058a3..6a699ec 100644
--- a/src/ArtAlgorithm.cpp
+++ b/src/ArtAlgorithm.cpp
@@ -132,7 +132,7 @@ bool CArtAlgorithm::initialize(const Config& _cfg)
}
// ray order
- string projOrder = _cfg.self->getOption("RayOrder", "sequential");
+ string projOrder = _cfg.self.getOption("RayOrder", "sequential");
CC.markOptionParsed("RayOrder");
m_iCurrentRay = 0;
m_iRayCount = m_pProjector->getProjectionGeometry()->getProjectionAngleCount() *
@@ -145,7 +145,7 @@ bool CArtAlgorithm::initialize(const Config& _cfg)
m_piDetectorOrder[i] = i % m_pProjector->getProjectionGeometry()->getDetectorCount();
}
} else if (projOrder == "custom") {
- vector<float32> rayOrderList = _cfg.self->getOptionNumericalArray("RayOrderList");
+ vector<float32> rayOrderList = _cfg.self.getOptionNumericalArray("RayOrderList");
m_iRayCount = rayOrderList.size() / 2;
m_piProjectionOrder = new int[m_iRayCount];
m_piDetectorOrder = new int[m_iRayCount];
@@ -158,7 +158,7 @@ bool CArtAlgorithm::initialize(const Config& _cfg)
return false;
}
- m_fLambda = _cfg.self->getOptionNumerical("Lambda", 1.0f);
+ m_fLambda = _cfg.self.getOptionNumerical("Lambda", 1.0f);
CC.markOptionParsed("Lambda");
// success
diff --git a/src/ConeProjectionGeometry3D.cpp b/src/ConeProjectionGeometry3D.cpp
index 1976901..dd22eba 100644
--- a/src/ConeProjectionGeometry3D.cpp
+++ b/src/ConeProjectionGeometry3D.cpp
@@ -87,17 +87,15 @@ bool CConeProjectionGeometry3D::initialize(const Config& _cfg)
CProjectionGeometry3D::initialize(_cfg);
// Required: DistanceOriginDetector
- XMLNode* node = _cfg.self->getSingleNode("DistanceOriginDetector");
+ XMLNode node = _cfg.self.getSingleNode("DistanceOriginDetector");
ASTRA_CONFIG_CHECK(node, "ConeProjectionGeometry3D", "No DistanceOriginDetector tag specified.");
- m_fOriginDetectorDistance = boost::lexical_cast<float32>(node->getContent());
- ASTRA_DELETE(node);
+ m_fOriginDetectorDistance = boost::lexical_cast<float32>(node.getContent());
CC.markNodeParsed("DistanceOriginDetector");
// Required: DetectorOriginSource
- node = _cfg.self->getSingleNode("DistanceOriginSource");
+ node = _cfg.self.getSingleNode("DistanceOriginSource");
ASTRA_CONFIG_CHECK(node, "ConeProjectionGeometry3D", "No DistanceOriginSource tag specified.");
- m_fOriginSourceDistance = boost::lexical_cast<float32>(node->getContent());
- ASTRA_DELETE(node);
+ m_fOriginSourceDistance = boost::lexical_cast<float32>(node.getContent());
CC.markNodeParsed("DistanceOriginSource");
// success
@@ -193,14 +191,14 @@ 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);
+ 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;
}
diff --git a/src/ConeVecProjectionGeometry3D.cpp b/src/ConeVecProjectionGeometry3D.cpp
index 9dc273d..47ed630 100644
--- a/src/ConeVecProjectionGeometry3D.cpp
+++ b/src/ConeVecProjectionGeometry3D.cpp
@@ -73,33 +73,30 @@ bool CConeVecProjectionGeometry3D::initialize(const Config& _cfg)
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CProjectionGeometry3D> CC("ConeVecProjectionGeometry3D", this, _cfg);
- XMLNode* node;
+ XMLNode node;
// TODO: Fix up class hierarchy... this class doesn't fit very well.
// initialization of parent class
//CProjectionGeometry3D::initialize(_cfg);
// Required: DetectorRowCount
- node = _cfg.self->getSingleNode("DetectorRowCount");
+ node = _cfg.self.getSingleNode("DetectorRowCount");
ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No DetectorRowCount tag specified.");
- m_iDetectorRowCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iDetectorRowCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("DetectorRowCount");
// Required: DetectorColCount
- node = _cfg.self->getSingleNode("DetectorColCount");
+ node = _cfg.self.getSingleNode("DetectorColCount");
ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No DetectorColCount tag specified.");
- m_iDetectorColCount = boost::lexical_cast<int>(node->getContent());
+ m_iDetectorColCount = boost::lexical_cast<int>(node.getContent());
m_iDetectorTotCount = m_iDetectorRowCount * m_iDetectorColCount;
- ASTRA_DELETE(node);
CC.markNodeParsed("DetectorColCount");
// Required: Vectors
- node = _cfg.self->getSingleNode("Vectors");
+ node = _cfg.self.getSingleNode("Vectors");
ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No Vectors tag specified.");
- vector<double> data = node->getContentNumericalArrayDouble();
+ vector<double> data = node.getContentNumericalArrayDouble();
CC.markNodeParsed("Vectors");
- ASTRA_DELETE(node);
ASTRA_CONFIG_CHECK(data.size() % 12 == 0, "ConeVecProjectionGeometry3D", "Vectors doesn't consist of 12-tuples.");
m_iProjectionAngleCount = data.size() / 12;
m_pProjectionAngles = new SConeProjection[m_iProjectionAngleCount];
@@ -208,9 +205,9 @@ Config* CConeVecProjectionGeometry3D::getConfiguration() const
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);
+ 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) {
@@ -229,7 +226,7 @@ Config* CConeVecProjectionGeometry3D::getConfiguration() const
vectors += boost::lexical_cast<string>(p.fDetVZ);
if (i < m_iProjectionAngleCount-1) vectors += ';';
}
- cfg->self->addChildNode("Vectors", vectors);
+ cfg->self.addChildNode("Vectors", vectors);
return cfg;
}
diff --git a/src/Config.cpp b/src/Config.cpp
index d860638..395080b 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -45,31 +45,33 @@ using namespace std;
//-----------------------------------------------------------------------------
// default constructor
-Config::Config()
+Config::Config() : self()
{
- self = 0;
+ _doc = 0;
}
//-----------------------------------------------------------------------------
// not so default constructor
-Config::Config(XMLNode* _self)
+Config::Config(XMLNode _self)
{
self = _self;
+ _doc = 0;
}
//-----------------------------------------------------------------------------
Config::~Config()
{
- delete self;
- self = 0;
+ delete _doc;
+ _doc = 0;
}
//-----------------------------------------------------------------------------
void Config::initialize(std::string rootname)
{
- if (self == 0) {
+ if (!self) {
XMLDocument* doc = XMLDocument::createDocument(rootname);
self = doc->getRootNode();
+ _doc = doc;
}
}
@@ -124,13 +126,13 @@ bool ConfigStackCheck<T>::stopParsing()
std::string errors;
- std::list<XMLNode*> nodes = cfg->self->getNodes();
- for (std::list<XMLNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i)
+ std::list<XMLNode> nodes = cfg->self.getNodes();
+ for (std::list<XMLNode>::iterator i = nodes.begin(); i != nodes.end(); ++i)
{
- std::string nodeName = (*i)->getName();
+ std::string nodeName = i->getName();
if (nodeName == "Option") {
- nodeName = (*i)->getAttribute("key", "");
+ nodeName = i->getAttribute("key", "");
if (object->configCheckData->parsedOptions.find(nodeName) == object->configCheckData->parsedOptions.end()) {
if (!errors.empty()) errors += ", ";
errors += nodeName;
@@ -142,8 +144,6 @@ bool ConfigStackCheck<T>::stopParsing()
}
}
}
- for (std::list<XMLNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i)
- delete (*i);
nodes.clear();
if (!errors.empty()) {
diff --git a/src/CudaBackProjectionAlgorithm3D.cpp b/src/CudaBackProjectionAlgorithm3D.cpp
index a8a1b0a..a5c3445 100644
--- a/src/CudaBackProjectionAlgorithm3D.cpp
+++ b/src/CudaBackProjectionAlgorithm3D.cpp
@@ -32,6 +32,7 @@ $Id$
#include "astra/AstraObjectManager.h"
+#include "astra/CudaProjector3D.h"
#include "astra/ConeProjectionGeometry3D.h"
#include "astra/ParallelProjectionGeometry3D.h"
#include "astra/ParallelVecProjectionGeometry3D.h"
@@ -102,12 +103,23 @@ bool CCudaBackProjectionAlgorithm3D::initialize(const Config& _cfg)
return false;
}
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
+ CCudaProjector3D* pCudaProjector = 0;
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
+
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iVoxelSuperSampling = (int)_cfg.self->getOptionNumerical("VoxelSuperSampling", 1);
+
+
+ m_iVoxelSuperSampling = 1;
+ if (pCudaProjector)
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
CC.markOptionParsed("VoxelSuperSampling");
- m_bSIRTWeighting = _cfg.self->getOptionBool("SIRTWeighting", false);
+ m_bSIRTWeighting = _cfg.self.getOptionBool("SIRTWeighting", false);
CC.markOptionParsed("SIRTWeighting");
// success
diff --git a/src/CudaCglsAlgorithm3D.cpp b/src/CudaCglsAlgorithm3D.cpp
index 3677458..2d28964 100644
--- a/src/CudaCglsAlgorithm3D.cpp
+++ b/src/CudaCglsAlgorithm3D.cpp
@@ -32,6 +32,7 @@ $Id$
#include "astra/AstraObjectManager.h"
+#include "astra/CudaProjector3D.h"
#include "astra/ConeProjectionGeometry3D.h"
#include "astra/ParallelVecProjectionGeometry3D.h"
#include "astra/ConeVecProjectionGeometry3D.h"
@@ -106,12 +107,27 @@ bool CCudaCglsAlgorithm3D::initialize(const Config& _cfg)
return false;
}
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
+ CCudaProjector3D* pCudaProjector = 0;
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
+
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iDetectorSuperSampling = (int)_cfg.self->getOptionNumerical("DetectorSuperSampling", 1);
- CC.markOptionParsed("DetectorSuperSampling");
- m_iVoxelSuperSampling = (int)_cfg.self->getOptionNumerical("VoxelSuperSampling", 1);
+
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ }
+ // Deprecated options
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
CC.markOptionParsed("VoxelSuperSampling");
+ CC.markOptionParsed("DetectorSuperSampling");
m_pCgls = new AstraCGLS3d();
diff --git a/src/CudaDartMaskAlgorithm.cpp b/src/CudaDartMaskAlgorithm.cpp
index dcdefcc..950b428 100644
--- a/src/CudaDartMaskAlgorithm.cpp
+++ b/src/CudaDartMaskAlgorithm.cpp
@@ -65,38 +65,36 @@ bool CCudaDartMaskAlgorithm::initialize(const Config& _cfg)
ConfigStackCheck<CAlgorithm> CC("CudaDartMaskAlgorithm", this, _cfg);
// reconstruction data
- XMLNode* node = _cfg.self->getSingleNode("SegmentationDataId");
+ XMLNode node = _cfg.self.getSingleNode("SegmentationDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No SegmentationDataId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pSegmentation = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("SegmentationDataId");
// reconstruction data
- node = _cfg.self->getSingleNode("MaskDataId");
+ node = _cfg.self.getSingleNode("MaskDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No MaskDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("MaskDataId");
// Option: GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("GPUindex");
- if (!_cfg.self->hasOption("GPUindex"))
+ if (!_cfg.self.hasOption("GPUindex"))
CC.markOptionParsed("GPUIndex");
// Option: Connectivity
- m_iConn = (unsigned int)_cfg.self->getOptionNumerical("Connectivity", 8);
+ m_iConn = (unsigned int)_cfg.self.getOptionNumerical("Connectivity", 8);
CC.markOptionParsed("Connectivity");
// Option: Threshold
- m_iThreshold = (unsigned int)_cfg.self->getOptionNumerical("Threshold", 1);
+ m_iThreshold = (unsigned int)_cfg.self.getOptionNumerical("Threshold", 1);
CC.markOptionParsed("Threshold");
// Option: Radius
- m_iRadius = (unsigned int)_cfg.self->getOptionNumerical("Radius", 1);
+ m_iRadius = (unsigned int)_cfg.self.getOptionNumerical("Radius", 1);
CC.markOptionParsed("Radius");
_check();
diff --git a/src/CudaDartMaskAlgorithm3D.cpp b/src/CudaDartMaskAlgorithm3D.cpp
index f3500b9..b0dfc5b 100644
--- a/src/CudaDartMaskAlgorithm3D.cpp
+++ b/src/CudaDartMaskAlgorithm3D.cpp
@@ -65,38 +65,36 @@ bool CCudaDartMaskAlgorithm3D::initialize(const Config& _cfg)
ConfigStackCheck<CAlgorithm> CC("CudaDartMaskAlgorithm", this, _cfg);
// reconstruction data
- XMLNode* node = _cfg.self->getSingleNode("SegmentationDataId");
+ XMLNode node = _cfg.self.getSingleNode("SegmentationDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No SegmentationDataId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pSegmentation = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("SegmentationDataId");
// reconstruction data
- node = _cfg.self->getSingleNode("MaskDataId");
+ node = _cfg.self.getSingleNode("MaskDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No MaskDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pMask = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("MaskDataId");
// Option: GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("GPUindex");
- if (!_cfg.self->hasOption("GPUindex"))
+ if (!_cfg.self.hasOption("GPUindex"))
CC.markOptionParsed("GPUIndex");
// Option: Connectivity
- m_iConn = (unsigned int)_cfg.self->getOptionNumerical("Connectivity", 8);
+ m_iConn = (unsigned int)_cfg.self.getOptionNumerical("Connectivity", 8);
CC.markOptionParsed("Connectivity");
// Option: Threshold
- m_iThreshold = (unsigned int)_cfg.self->getOptionNumerical("Threshold", 1);
+ m_iThreshold = (unsigned int)_cfg.self.getOptionNumerical("Threshold", 1);
CC.markOptionParsed("Threshold");
// Option: Radius
- m_iRadius = (unsigned int)_cfg.self->getOptionNumerical("Radius", 1);
+ m_iRadius = (unsigned int)_cfg.self.getOptionNumerical("Radius", 1);
CC.markOptionParsed("Radius");
_check();
diff --git a/src/CudaDartSmoothingAlgorithm.cpp b/src/CudaDartSmoothingAlgorithm.cpp
index 2f2103f..7e22809 100644
--- a/src/CudaDartSmoothingAlgorithm.cpp
+++ b/src/CudaDartSmoothingAlgorithm.cpp
@@ -65,34 +65,32 @@ bool CCudaDartSmoothingAlgorithm::initialize(const Config& _cfg)
ConfigStackCheck<CAlgorithm> CC("CudaDartSmoothingAlgorithm", this, _cfg);
// reconstruction data
- XMLNode* node = _cfg.self->getSingleNode("InDataId");
+ XMLNode node = _cfg.self.getSingleNode("InDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No InDataId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pIn = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("InDataId");
// reconstruction data
- node = _cfg.self->getSingleNode("OutDataId");
+ node = _cfg.self.getSingleNode("OutDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No OutDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pOut = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("OutDataId");
// Option: GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("GPUindex");
- if (!_cfg.self->hasOption("GPUindex"))
+ if (!_cfg.self.hasOption("GPUindex"))
CC.markOptionParsed("GPUIndex");
// Option: Radius
- m_fB = (float)_cfg.self->getOptionNumerical("Intensity", 0.3f);
+ m_fB = (float)_cfg.self.getOptionNumerical("Intensity", 0.3f);
CC.markOptionParsed("Intensity");
// Option: Radius
- m_iRadius = (unsigned int)_cfg.self->getOptionNumerical("Radius", 1);
+ m_iRadius = (unsigned int)_cfg.self.getOptionNumerical("Radius", 1);
CC.markOptionParsed("Radius");
diff --git a/src/CudaDartSmoothingAlgorithm3D.cpp b/src/CudaDartSmoothingAlgorithm3D.cpp
index f3cf015..9c4437a 100644
--- a/src/CudaDartSmoothingAlgorithm3D.cpp
+++ b/src/CudaDartSmoothingAlgorithm3D.cpp
@@ -65,34 +65,32 @@ bool CCudaDartSmoothingAlgorithm3D::initialize(const Config& _cfg)
ConfigStackCheck<CAlgorithm> CC("CudaDartSmoothingAlgorithm", this, _cfg);
// reconstruction data
- XMLNode* node = _cfg.self->getSingleNode("InDataId");
+ XMLNode node = _cfg.self.getSingleNode("InDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No InDataId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pIn = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("InDataId");
// reconstruction data
- node = _cfg.self->getSingleNode("OutDataId");
+ node = _cfg.self.getSingleNode("OutDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No OutDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pOut = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("OutDataId");
// Option: GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("GPUindex");
- if (!_cfg.self->hasOption("GPUindex"))
+ if (!_cfg.self.hasOption("GPUindex"))
CC.markOptionParsed("GPUIndex");
// Option: Intensity
- m_fB = (float)_cfg.self->getOptionNumerical("Intensity", 0.3f);
+ m_fB = (float)_cfg.self.getOptionNumerical("Intensity", 0.3f);
CC.markOptionParsed("Intensity");
// Option: Radius
- m_iRadius = (unsigned int)_cfg.self->getOptionNumerical("Radius", 1);
+ m_iRadius = (unsigned int)_cfg.self.getOptionNumerical("Radius", 1);
CC.markOptionParsed("Radius");
_check();
diff --git a/src/CudaDataOperationAlgorithm.cpp b/src/CudaDataOperationAlgorithm.cpp
index 79a9d7f..ae133c2 100644
--- a/src/CudaDataOperationAlgorithm.cpp
+++ b/src/CudaDataOperationAlgorithm.cpp
@@ -67,40 +67,37 @@ bool CCudaDataOperationAlgorithm::initialize(const Config& _cfg)
ConfigStackCheck<CAlgorithm> CC("CCudaDataOperationAlgorithm", this, _cfg);
// operation
- XMLNode* node = _cfg.self->getSingleNode("Operation");
+ XMLNode node = _cfg.self.getSingleNode("Operation");
ASTRA_CONFIG_CHECK(node, "CCudaDataOperationAlgorithm", "No Operation tag specified.");
- m_sOperation = node->getContent();
+ m_sOperation = node.getContent();
m_sOperation.erase(std::remove(m_sOperation.begin(), m_sOperation.end(), ' '), m_sOperation.end());
- ASTRA_DELETE(node);
CC.markNodeParsed("Operation");
// data
- node = _cfg.self->getSingleNode("DataId");
+ node = _cfg.self.getSingleNode("DataId");
ASTRA_CONFIG_CHECK(node, "CCudaDataOperationAlgorithm", "No DataId tag specified.");
- vector<string> data = node->getContentArray();
+ vector<string> data = node.getContentArray();
for (vector<string>::iterator it = data.begin(); it != data.end(); it++){
int id = boost::lexical_cast<int>(*it);
m_pData.push_back(dynamic_cast<CFloat32Data2D*>(CData2DManager::getSingleton().get(id)));
}
- ASTRA_DELETE(node);
CC.markNodeParsed("DataId");
// scalar
- node = _cfg.self->getSingleNode("Scalar");
+ node = _cfg.self.getSingleNode("Scalar");
ASTRA_CONFIG_CHECK(node, "CCudaDataOperationAlgorithm", "No Scalar tag specified.");
- m_fScalar = node->getContentNumericalArray();
- ASTRA_DELETE(node);
+ m_fScalar = node.getContentNumericalArray();
CC.markNodeParsed("Scalar");
// Option: GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("GPUindex");
- if (!_cfg.self->hasOption("GPUindex"))
+ if (!_cfg.self.hasOption("GPUindex"))
CC.markOptionParsed("GPUIndex");
- if (_cfg.self->hasOption("MaskId")) {
- int id = boost::lexical_cast<int>(_cfg.self->getOption("MaskId"));
+ if (_cfg.self.hasOption("MaskId")) {
+ int id = boost::lexical_cast<int>(_cfg.self.getOption("MaskId"));
m_pMask = dynamic_cast<CFloat32Data2D*>(CData2DManager::getSingleton().get(id));
}
CC.markOptionParsed("MaskId");
diff --git a/src/CudaFDKAlgorithm3D.cpp b/src/CudaFDKAlgorithm3D.cpp
index 0a46ff6..e700945 100644
--- a/src/CudaFDKAlgorithm3D.cpp
+++ b/src/CudaFDKAlgorithm3D.cpp
@@ -32,6 +32,7 @@ $Id$
#include "astra/AstraObjectManager.h"
+#include "astra/CudaProjector3D.h"
#include "astra/ConeProjectionGeometry3D.h"
#include "../cuda/3d/astra3d.h"
@@ -100,12 +101,22 @@ bool CCudaFDKAlgorithm3D::initialize(const Config& _cfg)
return false;
}
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
+ CCudaProjector3D* pCudaProjector = 0;
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
+
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iVoxelSuperSampling = (int)_cfg.self->getOptionNumerical("VoxelSuperSampling", 1);
+
+ m_iVoxelSuperSampling = 1;
+ if (pCudaProjector)
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
CC.markOptionParsed("VoxelSuperSampling");
- m_bShortScan = _cfg.self->getOptionBool("ShortScan", false);
+ m_bShortScan = _cfg.self.getOptionBool("ShortScan", false);
CC.markOptionParsed("ShortScan");
// success
diff --git a/src/CudaFilteredBackProjectionAlgorithm.cpp b/src/CudaFilteredBackProjectionAlgorithm.cpp
index 0badc20..aac96d6 100644
--- a/src/CudaFilteredBackProjectionAlgorithm.cpp
+++ b/src/CudaFilteredBackProjectionAlgorithm.cpp
@@ -32,6 +32,7 @@ $Id$
#include <cstring>
#include "astra/AstraObjectManager.h"
+#include "astra/CudaProjector2D.h"
#include "../cuda/2d/astra.h"
#include "astra/Logging.h"
@@ -77,40 +78,51 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
clear();
}
+ // Projector
+ XMLNode node = _cfg.self.getSingleNode("ProjectorId");
+ CCudaProjector2D* pCudaProjector = 0;
+ if (node) {
+ int id = boost::lexical_cast<int>(node.getContent());
+ CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
+ pCudaProjector = dynamic_cast<CCudaProjector2D*>(projector);
+ if (!pCudaProjector) {
+ ASTRA_WARN("non-CUDA Projector2D passed");
+ }
+ }
+ CC.markNodeParsed("ProjectorId");
+
+
// sinogram data
- XMLNode* node = _cfg.self->getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "CudaFBP", "No ProjectionDataId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
- node = _cfg.self->getSingleNode("ReconstructionDataId");
+ node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "CudaFBP", "No ReconstructionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pReconstruction = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ReconstructionDataId");
// filter type
- node = _cfg.self->getSingleNode("FilterType");
- if(node != NULL)
+ node = _cfg.self.getSingleNode("FilterType");
+ if (node)
{
- m_eFilter = _convertStringToFilter(node->getContent().c_str());
+ m_eFilter = _convertStringToFilter(node.getContent().c_str());
}
else
{
m_eFilter = FILTER_RAMLAK;
}
CC.markNodeParsed("FilterType");
- ASTRA_DELETE(node);
// filter
- node = _cfg.self->getSingleNode("FilterSinogramId");
- if(node != NULL)
+ node = _cfg.self.getSingleNode("FilterSinogramId");
+ if (node)
{
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
const CFloat32ProjectionData2D * pFilterData = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
m_iFilterWidth = pFilterData->getGeometry()->getDetectorCount();
int iFilterProjectionCount = pFilterData->getGeometry()->getProjectionAngleCount();
@@ -124,13 +136,12 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
m_pfFilter = NULL;
}
CC.markNodeParsed("FilterSinogramId"); // TODO: Only for some types!
- ASTRA_DELETE(node);
// filter parameter
- node = _cfg.self->getSingleNode("FilterParameter");
- if(node != NULL)
+ node = _cfg.self.getSingleNode("FilterParameter");
+ if (node)
{
- float fParameter = boost::lexical_cast<float>(node->getContent());
+ float fParameter = boost::lexical_cast<float>(node.getContent());
m_fFilterParameter = fParameter;
}
else
@@ -138,13 +149,12 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
m_fFilterParameter = -1.0f;
}
CC.markNodeParsed("FilterParameter"); // TODO: Only for some types!
- ASTRA_DELETE(node);
// D value
- node = _cfg.self->getSingleNode("FilterD");
- if(node != NULL)
+ node = _cfg.self.getSingleNode("FilterD");
+ if (node)
{
- float fD = boost::lexical_cast<float>(node->getContent());
+ float fD = boost::lexical_cast<float>(node.getContent());
m_fFilterD = fD;
}
else
@@ -152,19 +162,24 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
m_fFilterD = 1.0f;
}
CC.markNodeParsed("FilterD"); // TODO: Only for some types!
- ASTRA_DELETE(node);
// GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- // Pixel supersampling factor
- m_iPixelSuperSampling = (int)_cfg.self->getOptionNumerical("PixelSuperSampling", 1);
+ m_iPixelSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iPixelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ }
+ // Deprecated options
+ m_iPixelSuperSampling = (int)_cfg.self.getOptionNumerical("PixelSuperSampling", m_iPixelSuperSampling);
CC.markOptionParsed("PixelSuperSampling");
+
// Fan beam short scan mode
if (m_pSinogram && dynamic_cast<CFanFlatProjectionGeometry2D*>(m_pSinogram->getGeometry())) {
- m_bShortScan = (int)_cfg.self->getOptionBool("ShortScan", false);
+ m_bShortScan = (int)_cfg.self.getOptionBool("ShortScan", false);
CC.markOptionParsed("ShortScan");
}
diff --git a/src/CudaForwardProjectionAlgorithm.cpp b/src/CudaForwardProjectionAlgorithm.cpp
index 95abb62..b382f2e 100644
--- a/src/CudaForwardProjectionAlgorithm.cpp
+++ b/src/CudaForwardProjectionAlgorithm.cpp
@@ -71,47 +71,52 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg)
{
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CAlgorithm> CC("CudaForwardProjectionAlgorithm", this, _cfg);
+
+ // Projector
+ XMLNode node = _cfg.self.getSingleNode("ProjectorId");
+ CCudaProjector2D* pCudaProjector = 0;
+ if (node) {
+ int id = boost::lexical_cast<int>(node.getContent());
+ CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
+ pCudaProjector = dynamic_cast<CCudaProjector2D*>(projector);
+ if (!pCudaProjector) {
+ ASTRA_WARN("non-CUDA Projector2D passed to FP_CUDA");
+ }
+ }
+ CC.markNodeParsed("ProjectorId");
+
+
// sinogram data
- XMLNode* node = _cfg.self->getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "FP_CUDA", "No ProjectionDataId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ProjectionDataId");
// volume data
- node = _cfg.self->getSingleNode("VolumeDataId");
+ node = _cfg.self.getSingleNode("VolumeDataId");
ASTRA_CONFIG_CHECK(node, "FP_CUDA", "No VolumeDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pVolume = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("VolumeDataId");
// GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("GPUindex");
- if (!_cfg.self->hasOption("GPUindex"))
+ if (!_cfg.self.hasOption("GPUindex"))
CC.markOptionParsed("GPUIndex");
// Detector supersampling factor
- m_iDetectorSuperSampling = (int)_cfg.self->getOptionNumerical("DetectorSuperSampling", 1);
- CC.markOptionParsed("DetectorSuperSampling");
-
-
- // This isn't used yet, but passing it is not something to warn about
- node = _cfg.self->getSingleNode("ProjectorId");
- if (node) {
- id = boost::lexical_cast<int>(node->getContent());
- CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
- if (!dynamic_cast<CCudaProjector2D*>(projector)) {
- ASTRA_WARN("non-CUDA Projector2D passed to FP_CUDA");
- }
- delete node;
+ m_iDetectorSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
}
- CC.markNodeParsed("ProjectorId");
-
+ // Deprecated option
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
+ CC.markOptionParsed("DetectorSuperSampling");
// return success
diff --git a/src/CudaForwardProjectionAlgorithm3D.cpp b/src/CudaForwardProjectionAlgorithm3D.cpp
index aa36715..3da61ff 100644
--- a/src/CudaForwardProjectionAlgorithm3D.cpp
+++ b/src/CudaForwardProjectionAlgorithm3D.cpp
@@ -78,40 +78,47 @@ bool CCudaForwardProjectionAlgorithm3D::initialize(const Config& _cfg)
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CAlgorithm> CC("CudaForwardProjectionAlgorithm3D", this, _cfg);
- XMLNode* node;
+ XMLNode node;
int id;
// sinogram data
- node = _cfg.self->getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "CudaForwardProjection3D", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pProjections = dynamic_cast<CFloat32ProjectionData3DMemory*>(CData3DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
- node = _cfg.self->getSingleNode("VolumeDataId");
+ node = _cfg.self.getSingleNode("VolumeDataId");
ASTRA_CONFIG_CHECK(node, "CudaForwardProjection3D", "No VolumeDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pVolume = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("VolumeDataId");
// optional: projector
- node = _cfg.self->getSingleNode("ProjectorId");
+ node = _cfg.self.getSingleNode("ProjectorId");
+ CCudaProjector3D* pCudaProjector = 0;
+ m_pProjector = 0;
if (node) {
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pProjector = CProjector3DManager::getSingleton().get(id);
- ASTRA_DELETE(node);
- } else {
- m_pProjector = 0; // TODO: or manually construct default projector?
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(CProjector3DManager::getSingleton().get(id));
+ m_pProjector = pCudaProjector;
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
}
CC.markNodeParsed("ProjectorId");
// GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iDetectorSuperSampling = (int)_cfg.self->getOptionNumerical("DetectorSuperSampling", 1);
+
+
+ m_iDetectorSuperSampling = 1;
+ if (pCudaProjector)
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
CC.markOptionParsed("DetectorSuperSampling");
// success
diff --git a/src/CudaProjector2D.cpp b/src/CudaProjector2D.cpp
index 056ea3b..a26e32d 100644
--- a/src/CudaProjector2D.cpp
+++ b/src/CudaProjector2D.cpp
@@ -59,6 +59,8 @@ void CCudaProjector2D::_clear()
m_bIsInitialized = false;
m_projectionKernel = ker2d_default;
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
}
//----------------------------------------------------------------------------------------
@@ -104,10 +106,10 @@ bool CCudaProjector2D::initialize(const Config& _cfg)
// TODO: Check the projection geometry is a supported type
- XMLNode* node = _cfg.self->getSingleNode("ProjectionKernel");
+ XMLNode node = _cfg.self.getSingleNode("ProjectionKernel");
m_projectionKernel = ker2d_default;
if (node) {
- std::string sProjKernel = node->getContent();
+ std::string sProjKernel = node.getContent();
if (sProjKernel == "default") {
@@ -115,9 +117,14 @@ bool CCudaProjector2D::initialize(const Config& _cfg)
return false;
}
}
- ASTRA_DELETE(node);
CC.markNodeParsed("ProjectionKernel");
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", 1);
+ CC.markOptionParsed("VoxelSuperSampling");
+
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
+ CC.markOptionParsed("DetectorSuperSampling");
+
m_bIsInitialized = _check();
return m_bIsInitialized;
}
diff --git a/src/CudaProjector3D.cpp b/src/CudaProjector3D.cpp
index 2f4c799..d2fd74c 100644
--- a/src/CudaProjector3D.cpp
+++ b/src/CudaProjector3D.cpp
@@ -62,6 +62,8 @@ void CCudaProjector3D::_clear()
m_bIsInitialized = false;
m_projectionKernel = ker3d_default;
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
}
//----------------------------------------------------------------------------------------
@@ -105,10 +107,10 @@ bool CCudaProjector3D::initialize(const Config& _cfg)
return false;
}
- XMLNode* node = _cfg.self->getSingleNode("ProjectionKernel");
+ XMLNode node = _cfg.self.getSingleNode("ProjectionKernel");
m_projectionKernel = ker3d_default;
if (node) {
- std::string sProjKernel = node->getContent();
+ std::string sProjKernel = node.getContent();
if (sProjKernel == "default") {
@@ -118,9 +120,14 @@ bool CCudaProjector3D::initialize(const Config& _cfg)
return false;
}
}
- ASTRA_DELETE(node);
CC.markNodeParsed("ProjectionKernel");
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", 1);
+ CC.markOptionParsed("VoxelSuperSampling");
+
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
+ CC.markOptionParsed("DetectorSuperSampling");
+
m_bIsInitialized = _check();
return m_bIsInitialized;
}
diff --git a/src/CudaReconstructionAlgorithm2D.cpp b/src/CudaReconstructionAlgorithm2D.cpp
index 1c6b763..71b6637 100644
--- a/src/CudaReconstructionAlgorithm2D.cpp
+++ b/src/CudaReconstructionAlgorithm2D.cpp
@@ -95,96 +95,101 @@ bool CCudaReconstructionAlgorithm2D::initialize(const Config& _cfg)
clear();
}
+ // Projector
+ XMLNode node = _cfg.self.getSingleNode("ProjectorId");
+ CCudaProjector2D* pCudaProjector = 0;
+ if (node) {
+ int id = boost::lexical_cast<int>(node.getContent());
+ CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
+ pCudaProjector = dynamic_cast<CCudaProjector2D*>(projector);
+ if (!pCudaProjector) {
+ ASTRA_WARN("non-CUDA Projector2D passed");
+ }
+ }
+ CC.markNodeParsed("ProjectorId");
+
+
// sinogram data
- XMLNode* node = _cfg.self->getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "CudaSirt2", "No ProjectionDataId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
- node = _cfg.self->getSingleNode("ReconstructionDataId");
+ node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "CudaSirt2", "No ReconstructionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pReconstruction = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ReconstructionDataId");
// fixed mask
- if (_cfg.self->hasOption("ReconstructionMaskId")) {
+ if (_cfg.self.hasOption("ReconstructionMaskId")) {
m_bUseReconstructionMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("ReconstructionMaskId"));
+ id = boost::lexical_cast<int>(_cfg.self.getOption("ReconstructionMaskId"));
m_pReconstructionMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
ASTRA_CONFIG_CHECK(m_pReconstructionMask, "CudaReconstruction2D", "Invalid ReconstructionMaskId.");
}
CC.markOptionParsed("ReconstructionMaskId");
// fixed mask
- if (_cfg.self->hasOption("SinogramMaskId")) {
+ if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("SinogramMaskId"));
+ id = boost::lexical_cast<int>(_cfg.self.getOption("SinogramMaskId"));
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
ASTRA_CONFIG_CHECK(m_pSinogramMask, "CudaReconstruction2D", "Invalid SinogramMaskId.");
}
CC.markOptionParsed("SinogramMaskId");
// Constraints - NEW
- if (_cfg.self->hasOption("MinConstraint")) {
+ if (_cfg.self.hasOption("MinConstraint")) {
m_bUseMinConstraint = true;
- m_fMinValue = _cfg.self->getOptionNumerical("MinConstraint", 0.0f);
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraint", 0.0f);
CC.markOptionParsed("MinConstraint");
} else {
// Constraint - OLD
- m_bUseMinConstraint = _cfg.self->getOptionBool("UseMinConstraint", false);
+ m_bUseMinConstraint = _cfg.self.getOptionBool("UseMinConstraint", false);
CC.markOptionParsed("UseMinConstraint");
if (m_bUseMinConstraint) {
- m_fMinValue = _cfg.self->getOptionNumerical("MinConstraintValue", 0.0f);
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraintValue", 0.0f);
CC.markOptionParsed("MinConstraintValue");
}
}
- if (_cfg.self->hasOption("MaxConstraint")) {
+ if (_cfg.self.hasOption("MaxConstraint")) {
m_bUseMaxConstraint = true;
- m_fMaxValue = _cfg.self->getOptionNumerical("MaxConstraint", 255.0f);
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraint", 255.0f);
CC.markOptionParsed("MaxConstraint");
} else {
// Constraint - OLD
- m_bUseMaxConstraint = _cfg.self->getOptionBool("UseMaxConstraint", false);
+ m_bUseMaxConstraint = _cfg.self.getOptionBool("UseMaxConstraint", false);
CC.markOptionParsed("UseMaxConstraint");
if (m_bUseMaxConstraint) {
- m_fMaxValue = _cfg.self->getOptionNumerical("MaxConstraintValue", 0.0f);
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraintValue", 0.0f);
CC.markOptionParsed("MaxConstraintValue");
}
}
// GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("GPUindex");
- if (!_cfg.self->hasOption("GPUindex"))
+ if (!_cfg.self.hasOption("GPUindex"))
CC.markOptionParsed("GPUIndex");
- // Detector supersampling factor
- m_iDetectorSuperSampling = (int)_cfg.self->getOptionNumerical("DetectorSuperSampling", 1);
+ // Supersampling factors
+ m_iDetectorSuperSampling = 1;
+ m_iPixelSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ m_iPixelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ }
+ // Deprecated options
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
+ m_iPixelSuperSampling = (int)_cfg.self.getOptionNumerical("PixelSuperSampling", m_iPixelSuperSampling);
CC.markOptionParsed("DetectorSuperSampling");
-
- // Pixel supersampling factor
- m_iPixelSuperSampling = (int)_cfg.self->getOptionNumerical("PixelSuperSampling", 1);
CC.markOptionParsed("PixelSuperSampling");
- // This isn't used yet, but passing it is not something to warn about
- node = _cfg.self->getSingleNode("ProjectorId");
- if (node) {
- id = boost::lexical_cast<int>(node->getContent());
- CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
- if (!dynamic_cast<CCudaProjector2D*>(projector)) {
- ASTRA_WARN("non-CUDA Projector2D passed");
- }
- delete node;
- }
- CC.markNodeParsed("ProjectorId");
-
-
return _check();
}
diff --git a/src/CudaRoiSelectAlgorithm.cpp b/src/CudaRoiSelectAlgorithm.cpp
index bfccb3a..7635c69 100644
--- a/src/CudaRoiSelectAlgorithm.cpp
+++ b/src/CudaRoiSelectAlgorithm.cpp
@@ -66,22 +66,21 @@ bool CCudaRoiSelectAlgorithm::initialize(const Config& _cfg)
ConfigStackCheck<CAlgorithm> CC("CudaDartMaskAlgorithm", this, _cfg);
// reconstruction data
- XMLNode* node = _cfg.self->getSingleNode("DataId");
+ XMLNode node = _cfg.self.getSingleNode("DataId");
ASTRA_CONFIG_CHECK(node, "CudaRoiSelect", "No DataId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pData = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("DataId");
// Option: GPU number
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUIndex", m_iGPUIndex);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUIndex", m_iGPUIndex);
CC.markOptionParsed("GPUindex");
- if (!_cfg.self->hasOption("GPUindex"))
+ if (!_cfg.self.hasOption("GPUindex"))
CC.markOptionParsed("GPUIndex");
// Option: Radius
- m_fRadius = (unsigned int)_cfg.self->getOptionNumerical("Radius", 0.0f);
+ m_fRadius = (unsigned int)_cfg.self.getOptionNumerical("Radius", 0.0f);
CC.markOptionParsed("Radius");
_check();
diff --git a/src/CudaSartAlgorithm.cpp b/src/CudaSartAlgorithm.cpp
index 8e22c59..8c0c6d7 100644
--- a/src/CudaSartAlgorithm.cpp
+++ b/src/CudaSartAlgorithm.cpp
@@ -74,7 +74,7 @@ bool CCudaSartAlgorithm::initialize(const Config& _cfg)
// projection order
int projectionCount = m_pSinogram->getGeometry()->getProjectionAngleCount();
int* projectionOrder = NULL;
- string projOrder = _cfg.self->getOption("ProjectionOrder", "random");
+ string projOrder = _cfg.self.getOption("ProjectionOrder", "random");
CC.markOptionParsed("ProjectionOrder");
if (projOrder == "sequential") {
projectionOrder = new int[projectionCount];
@@ -97,7 +97,7 @@ bool CCudaSartAlgorithm::initialize(const Config& _cfg)
sart->setProjectionOrder(projectionOrder, projectionCount);
delete[] projectionOrder;
} else if (projOrder == "custom") {
- vector<float32> projOrderList = _cfg.self->getOptionNumericalArray("ProjectionOrderList");
+ vector<float32> projOrderList = _cfg.self.getOptionNumericalArray("ProjectionOrderList");
projectionOrder = new int[projOrderList.size()];
for (int i = 0; i < projOrderList.size(); i++) {
projectionOrder[i] = static_cast<int>(projOrderList[i]);
diff --git a/src/CudaSirtAlgorithm.cpp b/src/CudaSirtAlgorithm.cpp
index f6eb79a..d424915 100644
--- a/src/CudaSirtAlgorithm.cpp
+++ b/src/CudaSirtAlgorithm.cpp
@@ -76,13 +76,13 @@ bool CCudaSirtAlgorithm::initialize(const Config& _cfg)
return false;
// min/max masks
- if (_cfg.self->hasOption("MinMaskId")) {
- int id = boost::lexical_cast<int>(_cfg.self->getOption("MinMaskId"));
+ if (_cfg.self.hasOption("MinMaskId")) {
+ int id = boost::lexical_cast<int>(_cfg.self.getOption("MinMaskId"));
m_pMinMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
}
CC.markOptionParsed("MinMaskId");
- if (_cfg.self->hasOption("MaxMaskId")) {
- int id = boost::lexical_cast<int>(_cfg.self->getOption("MaxMaskId"));
+ if (_cfg.self.hasOption("MaxMaskId")) {
+ int id = boost::lexical_cast<int>(_cfg.self.getOption("MaxMaskId"));
m_pMaxMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
}
CC.markOptionParsed("MaxMaskId");
diff --git a/src/CudaSirtAlgorithm3D.cpp b/src/CudaSirtAlgorithm3D.cpp
index d67778f..b833e07 100644
--- a/src/CudaSirtAlgorithm3D.cpp
+++ b/src/CudaSirtAlgorithm3D.cpp
@@ -36,6 +36,7 @@ $Id$
#include "astra/ParallelProjectionGeometry3D.h"
#include "astra/ParallelVecProjectionGeometry3D.h"
#include "astra/ConeVecProjectionGeometry3D.h"
+#include "astra/CudaProjector3D.h"
#include "../cuda/3d/astra3d.h"
@@ -107,12 +108,28 @@ bool CCudaSirtAlgorithm3D::initialize(const Config& _cfg)
return false;
}
- m_iGPUIndex = (int)_cfg.self->getOptionNumerical("GPUindex", -1);
+ CCudaProjector3D* pCudaProjector = 0;
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
+
+ m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iDetectorSuperSampling = (int)_cfg.self->getOptionNumerical("DetectorSuperSampling", 1);
- CC.markOptionParsed("DetectorSuperSampling");
- m_iVoxelSuperSampling = (int)_cfg.self->getOptionNumerical("VoxelSuperSampling", 1);
+
+
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ }
+ // Deprecated options
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
CC.markOptionParsed("VoxelSuperSampling");
+ CC.markOptionParsed("DetectorSuperSampling");
m_pSirt = new AstraSIRT3d();
diff --git a/src/FanFlatProjectionGeometry2D.cpp b/src/FanFlatProjectionGeometry2D.cpp
index d757f18..32a19bc 100644
--- a/src/FanFlatProjectionGeometry2D.cpp
+++ b/src/FanFlatProjectionGeometry2D.cpp
@@ -134,17 +134,15 @@ bool CFanFlatProjectionGeometry2D::initialize(const Config& _cfg)
CProjectionGeometry2D::initialize(_cfg);
// Required: DistanceOriginDetector
- XMLNode* node = _cfg.self->getSingleNode("DistanceOriginDetector");
+ XMLNode node = _cfg.self.getSingleNode("DistanceOriginDetector");
ASTRA_CONFIG_CHECK(node, "FanFlatProjectionGeometry2D", "No DistanceOriginDetector tag specified.");
- m_fOriginDetectorDistance = boost::lexical_cast<float32>(node->getContent());
- ASTRA_DELETE(node);
+ m_fOriginDetectorDistance = boost::lexical_cast<float32>(node.getContent());
CC.markNodeParsed("DistanceOriginDetector");
// Required: DetectorOriginSource
- node = _cfg.self->getSingleNode("DistanceOriginSource");
+ node = _cfg.self.getSingleNode("DistanceOriginSource");
ASTRA_CONFIG_CHECK(node, "FanFlatProjectionGeometry2D", "No DistanceOriginSource tag specified.");
- m_fOriginSourceDistance = boost::lexical_cast<float32>(node->getContent());
- ASTRA_DELETE(node);
+ m_fOriginSourceDistance = boost::lexical_cast<float32>(node.getContent());
CC.markNodeParsed("DistanceOriginSource");
// success
@@ -209,12 +207,12 @@ 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);
+ 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;
}
//----------------------------------------------------------------------------------------
diff --git a/src/FanFlatVecProjectionGeometry2D.cpp b/src/FanFlatVecProjectionGeometry2D.cpp
index 9c7b596..4104379 100644
--- a/src/FanFlatVecProjectionGeometry2D.cpp
+++ b/src/FanFlatVecProjectionGeometry2D.cpp
@@ -116,25 +116,23 @@ bool CFanFlatVecProjectionGeometry2D::initialize(const Config& _cfg)
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CProjectionGeometry2D> CC("FanFlatVecProjectionGeometry2D", this, _cfg);
- XMLNode* node;
+ XMLNode node;
// TODO: Fix up class hierarchy... this class doesn't fit very well.
// initialization of parent class
//CProjectionGeometry2D::initialize(_cfg);
// Required: DetectorCount
- node = _cfg.self->getSingleNode("DetectorCount");
+ node = _cfg.self.getSingleNode("DetectorCount");
ASTRA_CONFIG_CHECK(node, "FanFlatVecProjectionGeometry3D", "No DetectorRowCount tag specified.");
- m_iDetectorCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iDetectorCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("DetectorCount");
// Required: Vectors
- node = _cfg.self->getSingleNode("Vectors");
+ node = _cfg.self.getSingleNode("Vectors");
ASTRA_CONFIG_CHECK(node, "FanFlatVecProjectionGeometry3D", "No Vectors tag specified.");
- vector<float32> data = node->getContentNumericalArray();
+ vector<float32> data = node.getContentNumericalArray();
CC.markNodeParsed("Vectors");
- ASTRA_DELETE(node);
ASTRA_CONFIG_CHECK(data.size() % 6 == 0, "FanFlatVecProjectionGeometry3D", "Vectors doesn't consist of 6-tuples.");
m_iProjectionAngleCount = data.size() / 6;
m_pProjectionAngles = new SFanProjection[m_iProjectionAngleCount];
@@ -232,8 +230,8 @@ Config* CFanFlatVecProjectionGeometry2D::getConfiguration() const
{
Config* cfg = new Config();
cfg->initialize("ProjectionGeometry2D");
- cfg->self->addAttribute("type", "fanflat_vec");
- cfg->self->addChildNode("DetectorCount", getDetectorCount());
+ 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];
@@ -245,7 +243,7 @@ Config* CFanFlatVecProjectionGeometry2D::getConfiguration() const
vectors += boost::lexical_cast<string>(p.fDetUY);
if (i < m_iProjectionAngleCount-1) vectors += ';';
}
- cfg->self->addChildNode("Vectors", vectors);
+ cfg->self.addChildNode("Vectors", vectors);
return cfg;
}
//----------------------------------------------------------------------------------------
diff --git a/src/FilteredBackProjectionAlgorithm.cpp b/src/FilteredBackProjectionAlgorithm.cpp
index 4a8e5ac..f494d22 100644
--- a/src/FilteredBackProjectionAlgorithm.cpp
+++ b/src/FilteredBackProjectionAlgorithm.cpp
@@ -94,30 +94,27 @@ bool CFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
ASTRA_ASSERT(_cfg.self);
// projector
- XMLNode* node = _cfg.self->getSingleNode("ProjectorId");
+ XMLNode node = _cfg.self.getSingleNode("ProjectorId");
ASTRA_CONFIG_CHECK(node, "FilteredBackProjection", "No ProjectorId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pProjector = CProjector2DManager::getSingleton().get(id);
- ASTRA_DELETE(node);
// sinogram data
- node = _cfg.self->getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "FilteredBackProjection", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
// volume data
- node = _cfg.self->getSingleNode("ReconstructionDataId");
+ node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "FilteredBackProjection", "No ReconstructionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pReconstruction = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
- node = _cfg.self->getSingleNode("ProjectionIndex");
+ node = _cfg.self.getSingleNode("ProjectionIndex");
if (node)
{
- vector<float32> projectionIndex = node->getContentNumericalArray();
+ vector<float32> projectionIndex = node.getContentNumericalArray();
int angleCount = projectionIndex.size();
int detectorCount = m_pProjector->getProjectionGeometry()->getDetectorCount();
@@ -154,7 +151,6 @@ bool CFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
m_pProjector = new CParallelBeamLineKernelProjector2D(pg,m_pReconstruction->getGeometry());
m_pSinogram = new CFloat32ProjectionData2D(pg, sinogramData2D);
}
- ASTRA_DELETE(node);
// TODO: check that the angles are linearly spaced between 0 and pi
diff --git a/src/ForwardProjectionAlgorithm.cpp b/src/ForwardProjectionAlgorithm.cpp
index b530491..f356824 100644
--- a/src/ForwardProjectionAlgorithm.cpp
+++ b/src/ForwardProjectionAlgorithm.cpp
@@ -126,37 +126,34 @@ bool CForwardProjectionAlgorithm::initialize(const Config& _cfg)
}
// projector
- XMLNode* node = _cfg.self->getSingleNode("ProjectorId");
+ XMLNode node = _cfg.self.getSingleNode("ProjectorId");
ASTRA_CONFIG_CHECK(node, "ForwardProjection", "No ProjectorId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pProjector = CProjector2DManager::getSingleton().get(id);
- ASTRA_DELETE(node);
// sinogram data
- node = _cfg.self->getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "ForwardProjection", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
// volume data
- node = _cfg.self->getSingleNode("VolumeDataId");
+ node = _cfg.self.getSingleNode("VolumeDataId");
ASTRA_CONFIG_CHECK(node, "ForwardProjection", "No VolumeDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pVolume = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
// volume mask
- if (_cfg.self->hasOption("VolumeMaskId")) {
+ if (_cfg.self.hasOption("VolumeMaskId")) {
m_bUseVolumeMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("VolumeMaskId"));
+ id = boost::lexical_cast<int>(_cfg.self.getOption("VolumeMaskId"));
m_pVolumeMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
}
// sino mask
- if (_cfg.self->hasOption("SinogramMaskId")) {
+ if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("SinogramMaskId"));
+ id = boost::lexical_cast<int>(_cfg.self.getOption("SinogramMaskId"));
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
}
diff --git a/src/ParallelBeamBlobKernelProjector2D.cpp b/src/ParallelBeamBlobKernelProjector2D.cpp
index 3253f88..4559a48 100644
--- a/src/ParallelBeamBlobKernelProjector2D.cpp
+++ b/src/ParallelBeamBlobKernelProjector2D.cpp
@@ -128,28 +128,28 @@ bool CParallelBeamBlobKernelProjector2D::initialize(const Config& _cfg)
}
// required: Kernel
- XMLNode* node = _cfg.self->getSingleNode("Kernel");
+ XMLNode node = _cfg.self.getSingleNode("Kernel");
ASTRA_CONFIG_CHECK(node, "BlobProjector", "No Kernel tag specified.");
{
// Required: KernelSize
- XMLNode* node2 = node->getSingleNode("KernelSize");
+ XMLNode node2 = node.getSingleNode("KernelSize");
ASTRA_CONFIG_CHECK(node2, "BlobProjector", "No Kernel/KernelSize tag specified.");
- m_fBlobSize = boost::lexical_cast<float32>(node2->getContent());
+ m_fBlobSize = boost::lexical_cast<float32>(node2.getContent());
// Required: SampleRate
- node2 = node->getSingleNode("SampleRate");
+ node2 = node.getSingleNode("SampleRate");
ASTRA_CONFIG_CHECK(node2, "BlobProjector", "No Kernel/SampleRate tag specified.");
- m_fBlobSampleRate = boost::lexical_cast<float32>(node2->getContent());
+ m_fBlobSampleRate = boost::lexical_cast<float32>(node2.getContent());
// Required: SampleCount
- node2 = node->getSingleNode("SampleCount");
+ node2 = node.getSingleNode("SampleCount");
ASTRA_CONFIG_CHECK(node2, "BlobProjector", "No Kernel/SampleCount tag specified.");
- m_iBlobSampleCount = boost::lexical_cast<int>(node2->getContent());
+ m_iBlobSampleCount = boost::lexical_cast<int>(node2.getContent());
// Required: KernelValues
- node2 = node->getSingleNode("KernelValues");
+ node2 = node.getSingleNode("KernelValues");
ASTRA_CONFIG_CHECK(node2, "BlobProjector", "No Kernel/KernelValues tag specified.");
- vector<float32> values = node2->getContentNumericalArray();
+ vector<float32> values = node2.getContentNumericalArray();
ASTRA_CONFIG_CHECK(values.size() == (unsigned int)m_iBlobSampleCount, "BlobProjector", "Number of specified values doesn't match SampleCount.");
m_pfBlobValues = new float32[m_iBlobSampleCount];
for (int i = 0; i < m_iBlobSampleCount; i++) {
@@ -157,9 +157,9 @@ bool CParallelBeamBlobKernelProjector2D::initialize(const Config& _cfg)
}
// Required: KernelValues
- node2 = node->getSingleNode("KernelValuesNeg");
+ node2 = node.getSingleNode("KernelValuesNeg");
ASTRA_CONFIG_CHECK(node2, "BlobProjector", "No Kernel/KernelValuesNeg tag specified.");
- vector<float32> values2 = node2->getContentNumericalArray();
+ vector<float32> values2 = node2.getContentNumericalArray();
ASTRA_CONFIG_CHECK(values2.size() == (unsigned int)m_iBlobSampleCount, "BlobProjector", "Number of specified values doesn't match SampleCount.");
m_pfBlobValuesNeg = new float32[m_iBlobSampleCount];
for (int i = 0; i < m_iBlobSampleCount; i++) {
diff --git a/src/ParallelProjectionGeometry2D.cpp b/src/ParallelProjectionGeometry2D.cpp
index cac8f30..7260b83 100644
--- a/src/ParallelProjectionGeometry2D.cpp
+++ b/src/ParallelProjectionGeometry2D.cpp
@@ -176,10 +176,15 @@ 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);
+ cfg->self.addAttribute("type", "parallel");
+ cfg->self.addChildNode("DetectorCount", getDetectorCount());
+ cfg->self.addChildNode("DetectorWidth", getDetectorWidth());
+ cfg->self.addChildNode("ProjectionAngles", m_pfProjectionAngles, m_iProjectionAngleCount);
+ if(m_pfExtraDetectorOffset!=NULL){
+ XMLNode opt = cfg->self.addChildNode("Option");
+ opt.addAttribute("key","ExtraDetectorOffset");
+ opt.setContent(m_pfExtraDetectorOffset, m_iProjectionAngleCount);
+ }
return cfg;
}
//----------------------------------------------------------------------------------------
diff --git a/src/ParallelProjectionGeometry3D.cpp b/src/ParallelProjectionGeometry3D.cpp
index eb200f9..1c87157 100644
--- a/src/ParallelProjectionGeometry3D.cpp
+++ b/src/ParallelProjectionGeometry3D.cpp
@@ -164,12 +164,12 @@ 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);
+ 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;
}
//----------------------------------------------------------------------------------------
diff --git a/src/ParallelVecProjectionGeometry3D.cpp b/src/ParallelVecProjectionGeometry3D.cpp
index dc325e9..ffad6d0 100644
--- a/src/ParallelVecProjectionGeometry3D.cpp
+++ b/src/ParallelVecProjectionGeometry3D.cpp
@@ -73,33 +73,30 @@ bool CParallelVecProjectionGeometry3D::initialize(const Config& _cfg)
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CProjectionGeometry3D> CC("ParallelVecProjectionGeometry3D", this, _cfg);
- XMLNode* node;
+ XMLNode node;
// TODO: Fix up class hierarchy... this class doesn't fit very well.
// initialization of parent class
//CProjectionGeometry3D::initialize(_cfg);
// Required: DetectorRowCount
- node = _cfg.self->getSingleNode("DetectorRowCount");
+ node = _cfg.self.getSingleNode("DetectorRowCount");
ASTRA_CONFIG_CHECK(node, "ParallelVecProjectionGeometry3D", "No DetectorRowCount tag specified.");
- m_iDetectorRowCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iDetectorRowCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("DetectorRowCount");
// Required: DetectorCount
- node = _cfg.self->getSingleNode("DetectorColCount");
+ node = _cfg.self.getSingleNode("DetectorColCount");
ASTRA_CONFIG_CHECK(node, "", "No DetectorColCount tag specified.");
- m_iDetectorColCount = boost::lexical_cast<int>(node->getContent());
+ m_iDetectorColCount = boost::lexical_cast<int>(node.getContent());
m_iDetectorTotCount = m_iDetectorRowCount * m_iDetectorColCount;
- ASTRA_DELETE(node);
CC.markNodeParsed("DetectorColCount");
// Required: Vectors
- node = _cfg.self->getSingleNode("Vectors");
+ node = _cfg.self.getSingleNode("Vectors");
ASTRA_CONFIG_CHECK(node, "ParallelVecProjectionGeometry3D", "No Vectors tag specified.");
- vector<double> data = node->getContentNumericalArrayDouble();
+ vector<double> data = node.getContentNumericalArrayDouble();
CC.markNodeParsed("Vectors");
- ASTRA_DELETE(node);
ASTRA_CONFIG_CHECK(data.size() % 12 == 0, "ParallelVecProjectionGeometry3D", "Vectors doesn't consist of 12-tuples.");
m_iProjectionAngleCount = data.size() / 12;
m_pProjectionAngles = new SPar3DProjection[m_iProjectionAngleCount];
@@ -208,9 +205,9 @@ Config* CParallelVecProjectionGeometry3D::getConfiguration() const
Config* cfg = new Config();
cfg->initialize("ProjectionGeometry3D");
- cfg->self->addAttribute("type", "parallel3d_vec");
- cfg->self->addChildNode("DetectorRowCount", m_iDetectorRowCount);
- cfg->self->addChildNode("DetectorColCount", m_iDetectorColCount);
+ cfg->self.addAttribute("type", "parallel3d_vec");
+ cfg->self.addChildNode("DetectorRowCount", m_iDetectorRowCount);
+ cfg->self.addChildNode("DetectorColCount", m_iDetectorColCount);
std::string vectors = "";
for (int i = 0; i < m_iProjectionAngleCount; ++i) {
@@ -229,7 +226,7 @@ Config* CParallelVecProjectionGeometry3D::getConfiguration() const
vectors += boost::lexical_cast<string>(p.fDetVZ);
if (i < m_iProjectionAngleCount-1) vectors += ';';
}
- cfg->self->addChildNode("Vectors", vectors);
+ cfg->self.addChildNode("Vectors", vectors);
return cfg;
}
diff --git a/src/ProjectionGeometry2D.cpp b/src/ProjectionGeometry2D.cpp
index 89b5fe0..b89605b 100644
--- a/src/ProjectionGeometry2D.cpp
+++ b/src/ProjectionGeometry2D.cpp
@@ -124,24 +124,21 @@ bool CProjectionGeometry2D::initialize(const Config& _cfg)
}
// Required: DetectorWidth
- XMLNode* node = _cfg.self->getSingleNode("DetectorWidth");
+ XMLNode node = _cfg.self.getSingleNode("DetectorWidth");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry2D", "No DetectorWidth tag specified.");
- m_fDetectorWidth = boost::lexical_cast<float32>(node->getContent());
- ASTRA_DELETE(node);
+ m_fDetectorWidth = boost::lexical_cast<float32>(node.getContent());
CC.markNodeParsed("DetectorWidth");
// Required: DetectorCount
- node = _cfg.self->getSingleNode("DetectorCount");
+ node = _cfg.self.getSingleNode("DetectorCount");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry2D", "No DetectorCount tag specified.");
- m_iDetectorCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iDetectorCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("DetectorCount");
// Required: ProjectionAngles
- node = _cfg.self->getSingleNode("ProjectionAngles");
+ node = _cfg.self.getSingleNode("ProjectionAngles");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry2D", "No ProjectionAngles tag specified.");
- vector<float32> angles = node->getContentNumericalArray();
- delete node;
+ vector<float32> angles = node.getContentNumericalArray();
m_iProjectionAngleCount = angles.size();
ASTRA_CONFIG_CHECK(m_iProjectionAngleCount > 0, "ProjectionGeometry2D", "Not enough ProjectionAngles specified.");
m_pfProjectionAngles = new float32[m_iProjectionAngleCount];
@@ -150,7 +147,7 @@ bool CProjectionGeometry2D::initialize(const Config& _cfg)
}
CC.markNodeParsed("ProjectionAngles");
- vector<float32> offset = _cfg.self->getOptionNumericalArray("ExtraDetectorOffset");
+ vector<float32> offset = _cfg.self.getOptionNumericalArray("ExtraDetectorOffset");
m_pfExtraDetectorOffset = new float32[m_iProjectionAngleCount];
if (offset.size() == (size_t)m_iProjectionAngleCount) {
for (int i = 0; i < m_iProjectionAngleCount; i++) {
diff --git a/src/ProjectionGeometry3D.cpp b/src/ProjectionGeometry3D.cpp
index 5b77767..ef0246c 100644
--- a/src/ProjectionGeometry3D.cpp
+++ b/src/ProjectionGeometry3D.cpp
@@ -149,38 +149,34 @@ bool CProjectionGeometry3D::initialize(const Config& _cfg)
ASTRA_ASSERT(_cfg.self);
// Required: DetectorWidth
- XMLNode* node = _cfg.self->getSingleNode("DetectorSpacingX");
+ XMLNode node = _cfg.self.getSingleNode("DetectorSpacingX");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry3D", "No DetectorSpacingX tag specified.");
- m_fDetectorSpacingX = boost::lexical_cast<float32>(node->getContent());
- ASTRA_DELETE(node);
+ m_fDetectorSpacingX = boost::lexical_cast<float32>(node.getContent());
CC.markNodeParsed("DetectorSpacingX");
// Required: DetectorHeight
- node = _cfg.self->getSingleNode("DetectorSpacingY");
+ node = _cfg.self.getSingleNode("DetectorSpacingY");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry3D", "No DetectorSpacingY tag specified.");
- m_fDetectorSpacingY = boost::lexical_cast<float32>(node->getContent());
- ASTRA_DELETE(node);
+ m_fDetectorSpacingY = boost::lexical_cast<float32>(node.getContent());
CC.markNodeParsed("DetectorSpacingY");
// Required: DetectorRowCount
- node = _cfg.self->getSingleNode("DetectorRowCount");
+ node = _cfg.self.getSingleNode("DetectorRowCount");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry3D", "No DetectorRowCount tag specified.");
- m_iDetectorRowCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iDetectorRowCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("DetectorRowCount");
// Required: DetectorCount
- node = _cfg.self->getSingleNode("DetectorColCount");
+ node = _cfg.self.getSingleNode("DetectorColCount");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry3D", "No DetectorColCount tag specified.");
- m_iDetectorColCount = boost::lexical_cast<int>(node->getContent());
+ m_iDetectorColCount = boost::lexical_cast<int>(node.getContent());
m_iDetectorTotCount = m_iDetectorRowCount * m_iDetectorColCount;
- ASTRA_DELETE(node);
CC.markNodeParsed("DetectorColCount");
// Required: ProjectionAngles
- node = _cfg.self->getSingleNode("ProjectionAngles");
+ node = _cfg.self.getSingleNode("ProjectionAngles");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry3D", "No ProjectionAngles tag specified.");
- vector<float32> angles = node->getContentNumericalArray();
+ vector<float32> angles = node.getContentNumericalArray();
m_iProjectionAngleCount = angles.size();
ASTRA_CONFIG_CHECK(m_iProjectionAngleCount > 0, "ProjectionGeometry3D", "Not enough ProjectionAngles specified.");
m_pfProjectionAngles = new float32[m_iProjectionAngleCount];
@@ -188,7 +184,6 @@ bool CProjectionGeometry3D::initialize(const Config& _cfg)
m_pfProjectionAngles[i] = angles[i];
}
CC.markNodeParsed("ProjectionAngles");
- ASTRA_DELETE(node);
// Interface class, so don't return true
return false;
diff --git a/src/Projector2D.cpp b/src/Projector2D.cpp
index 32a2956..cf233a0 100644
--- a/src/Projector2D.cpp
+++ b/src/Projector2D.cpp
@@ -114,12 +114,12 @@ bool CProjector2D::initialize(const Config& _cfg)
}
// required: ProjectionGeometry
- XMLNode* node = _cfg.self->getSingleNode("ProjectionGeometry");
+ XMLNode node = _cfg.self.getSingleNode("ProjectionGeometry");
ASTRA_CONFIG_CHECK(node, "Projector2D", "No ProjectionGeometry tag specified.");
// FIXME: Change how the base class is created. (This is duplicated
// in astra_mex_data2d.cpp.)
- std::string type = node->getAttribute("type");
+ std::string type = node.getAttribute("type");
if (type == "sparse_matrix") {
m_pProjectionGeometry = new CSparseMatrixProjectionGeometry2D();
m_pProjectionGeometry->initialize(Config(node));
@@ -141,7 +141,7 @@ bool CProjector2D::initialize(const Config& _cfg)
// required: VolumeGeometry
- node = _cfg.self->getSingleNode("VolumeGeometry");
+ node = _cfg.self.getSingleNode("VolumeGeometry");
ASTRA_CONFIG_CHECK(node, "Projector2D", "No VolumeGeometry tag specified.");
m_pVolumeGeometry = new CVolumeGeometry2D();
m_pVolumeGeometry->initialize(Config(node));
diff --git a/src/Projector3D.cpp b/src/Projector3D.cpp
index 14cb16a..5e22105 100644
--- a/src/Projector3D.cpp
+++ b/src/Projector3D.cpp
@@ -92,11 +92,11 @@ bool CProjector3D::initialize(const Config& _cfg)
assert(_cfg.self);
ConfigStackCheck<CProjector3D> CC("Projector3D", this, _cfg);
- XMLNode* node;
+ XMLNode node;
- node = _cfg.self->getSingleNode("ProjectionGeometry");
+ node = _cfg.self.getSingleNode("ProjectionGeometry");
ASTRA_CONFIG_CHECK(node, "Projector3D", "No ProjectionGeometry tag specified.");
- std::string type = node->getAttribute("type");
+ std::string type = node.getAttribute("type");
CProjectionGeometry3D* pProjGeometry = 0;
if (type == "parallel3d") {
pProjGeometry = new CParallelProjectionGeometry3D();
@@ -115,7 +115,7 @@ bool CProjector3D::initialize(const Config& _cfg)
ASTRA_CONFIG_CHECK(m_pProjectionGeometry->isInitialized(), "Projector3D", "ProjectionGeometry not initialized.");
CC.markNodeParsed("ProjectionGeometry");
- node = _cfg.self->getSingleNode("VolumeGeometry");
+ node = _cfg.self.getSingleNode("VolumeGeometry");
ASTRA_CONFIG_CHECK(node, "Projector3D", "No VolumeGeometry tag specified.");
CVolumeGeometry3D* pVolGeometry = new CVolumeGeometry3D();
pVolGeometry->initialize(Config(node)); // this deletes node
diff --git a/src/ReconstructionAlgorithm2D.cpp b/src/ReconstructionAlgorithm2D.cpp
index e089fac..767efe6 100644
--- a/src/ReconstructionAlgorithm2D.cpp
+++ b/src/ReconstructionAlgorithm2D.cpp
@@ -84,71 +84,68 @@ bool CReconstructionAlgorithm2D::initialize(const Config& _cfg)
ConfigStackCheck<CAlgorithm> CC("ReconstructionAlgorithm2D", this, _cfg);
// projector
- XMLNode* node = _cfg.self->getSingleNode("ProjectorId");
+ XMLNode node = _cfg.self.getSingleNode("ProjectorId");
ASTRA_CONFIG_CHECK(node, "Reconstruction2D", "No ProjectorId tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pProjector = CProjector2DManager::getSingleton().get(id);
- ASTRA_DELETE(node);
CC.markNodeParsed("ProjectorId");
// sinogram data
- node = _cfg.self->getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction2D", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
- node = _cfg.self->getSingleNode("ReconstructionDataId");
+ node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction2D", "No ReconstructionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pReconstruction = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ReconstructionDataId");
// fixed mask
- if (_cfg.self->hasOption("ReconstructionMaskId")) {
+ if (_cfg.self.hasOption("ReconstructionMaskId")) {
m_bUseReconstructionMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("ReconstructionMaskId"));
+ id = boost::lexical_cast<int>(_cfg.self.getOption("ReconstructionMaskId"));
m_pReconstructionMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
ASTRA_CONFIG_CHECK(m_pReconstructionMask, "Reconstruction2D", "Invalid ReconstructionMaskId.");
}
CC.markOptionParsed("ReconstructionMaskId");
// fixed mask
- if (_cfg.self->hasOption("SinogramMaskId")) {
+ if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("SinogramMaskId"));
+ id = boost::lexical_cast<int>(_cfg.self.getOption("SinogramMaskId"));
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
ASTRA_CONFIG_CHECK(m_pSinogramMask, "Reconstruction2D", "Invalid SinogramMaskId.");
}
CC.markOptionParsed("SinogramMaskId");
// Constraints - NEW
- if (_cfg.self->hasOption("MinConstraint")) {
+ if (_cfg.self.hasOption("MinConstraint")) {
m_bUseMinConstraint = true;
- m_fMinValue = _cfg.self->getOptionNumerical("MinConstraint", 0.0f);
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraint", 0.0f);
CC.markOptionParsed("MinConstraint");
} else {
// Constraint - OLD
- m_bUseMinConstraint = _cfg.self->getOptionBool("UseMinConstraint", false);
+ m_bUseMinConstraint = _cfg.self.getOptionBool("UseMinConstraint", false);
CC.markOptionParsed("UseMinConstraint");
if (m_bUseMinConstraint) {
- m_fMinValue = _cfg.self->getOptionNumerical("MinConstraintValue", 0.0f);
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraintValue", 0.0f);
CC.markOptionParsed("MinConstraintValue");
}
}
- if (_cfg.self->hasOption("MaxConstraint")) {
+ if (_cfg.self.hasOption("MaxConstraint")) {
m_bUseMaxConstraint = true;
- m_fMaxValue = _cfg.self->getOptionNumerical("MaxConstraint", 255.0f);
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraint", 255.0f);
CC.markOptionParsed("MaxConstraint");
} else {
// Constraint - OLD
- m_bUseMaxConstraint = _cfg.self->getOptionBool("UseMaxConstraint", false);
+ m_bUseMaxConstraint = _cfg.self.getOptionBool("UseMaxConstraint", false);
CC.markOptionParsed("UseMaxConstraint");
if (m_bUseMaxConstraint) {
- m_fMaxValue = _cfg.self->getOptionNumerical("MaxConstraintValue", 0.0f);
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraintValue", 0.0f);
CC.markOptionParsed("MaxConstraintValue");
}
}
diff --git a/src/ReconstructionAlgorithm3D.cpp b/src/ReconstructionAlgorithm3D.cpp
index 13d069d..f975ace 100644
--- a/src/ReconstructionAlgorithm3D.cpp
+++ b/src/ReconstructionAlgorithm3D.cpp
@@ -104,72 +104,74 @@ bool CReconstructionAlgorithm3D::initialize(const Config& _cfg)
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CAlgorithm> CC("ReconstructionAlgorithm3D", this, _cfg);
- XMLNode* node;
+ XMLNode node;
int id;
-#if 0
+
// projector
- node = _cfg.self->getSingleNode("ProjectorId");
- ASTRA_CONFIG_CHECK(node, "Reconstruction3D", "No ProjectorId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
- m_pProjector = CProjector3DManager::getSingleton().get(id);
- ASTRA_DELETE(node);
-#endif
+ node = _cfg.self.getSingleNode("ProjectorId");
+ m_pProjector = 0;
+ if (node) {
+ id = boost::lexical_cast<int>(node.getContent());
+ m_pProjector = CProjector3DManager::getSingleton().get(id);
+ if (!m_pProjector) {
+ // TODO: Report
+ }
+ }
+ CC.markNodeParsed("ProjectorId");
// sinogram data
- node = _cfg.self->getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction3D", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData3D*>(CData3DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
- node = _cfg.self->getSingleNode("ReconstructionDataId");
+ node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction3D", "No ReconstructionDataId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
+ id = boost::lexical_cast<int>(node.getContent());
m_pReconstruction = dynamic_cast<CFloat32VolumeData3D*>(CData3DManager::getSingleton().get(id));
- ASTRA_DELETE(node);
CC.markNodeParsed("ReconstructionDataId");
// fixed mask
- if (_cfg.self->hasOption("ReconstructionMaskId")) {
+ if (_cfg.self.hasOption("ReconstructionMaskId")) {
m_bUseReconstructionMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("ReconstructionMaskId"));
+ id = boost::lexical_cast<int>(_cfg.self.getOption("ReconstructionMaskId"));
m_pReconstructionMask = dynamic_cast<CFloat32VolumeData3D*>(CData3DManager::getSingleton().get(id));
}
CC.markOptionParsed("ReconstructionMaskId");
// fixed mask
- if (_cfg.self->hasOption("SinogramMaskId")) {
+ if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("SinogramMaskId"));
+ id = boost::lexical_cast<int>(_cfg.self.getOption("SinogramMaskId"));
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData3D*>(CData3DManager::getSingleton().get(id));
}
// Constraints - NEW
- if (_cfg.self->hasOption("MinConstraint")) {
+ if (_cfg.self.hasOption("MinConstraint")) {
m_bUseMinConstraint = true;
- m_fMinValue = _cfg.self->getOptionNumerical("MinConstraint", 0.0f);
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraint", 0.0f);
CC.markOptionParsed("MinConstraint");
} else {
// Constraint - OLD
- m_bUseMinConstraint = _cfg.self->getOptionBool("UseMinConstraint", false);
+ m_bUseMinConstraint = _cfg.self.getOptionBool("UseMinConstraint", false);
CC.markOptionParsed("UseMinConstraint");
if (m_bUseMinConstraint) {
- m_fMinValue = _cfg.self->getOptionNumerical("MinConstraintValue", 0.0f);
+ m_fMinValue = _cfg.self.getOptionNumerical("MinConstraintValue", 0.0f);
CC.markOptionParsed("MinConstraintValue");
}
}
- if (_cfg.self->hasOption("MaxConstraint")) {
+ if (_cfg.self.hasOption("MaxConstraint")) {
m_bUseMaxConstraint = true;
- m_fMaxValue = _cfg.self->getOptionNumerical("MaxConstraint", 255.0f);
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraint", 255.0f);
CC.markOptionParsed("MaxConstraint");
} else {
// Constraint - OLD
- m_bUseMaxConstraint = _cfg.self->getOptionBool("UseMaxConstraint", false);
+ m_bUseMaxConstraint = _cfg.self.getOptionBool("UseMaxConstraint", false);
CC.markOptionParsed("UseMaxConstraint");
if (m_bUseMaxConstraint) {
- m_fMaxValue = _cfg.self->getOptionNumerical("MaxConstraintValue", 0.0f);
+ m_fMaxValue = _cfg.self.getOptionNumerical("MaxConstraintValue", 0.0f);
CC.markOptionParsed("MaxConstraintValue");
}
}
diff --git a/src/SartAlgorithm.cpp b/src/SartAlgorithm.cpp
index f7a1677..e4dc5c7 100644
--- a/src/SartAlgorithm.cpp
+++ b/src/SartAlgorithm.cpp
@@ -126,7 +126,7 @@ bool CSartAlgorithm::initialize(const Config& _cfg)
// projection order
m_iCurrentProjection = 0;
m_iProjectionCount = m_pProjector->getProjectionGeometry()->getProjectionAngleCount();
- string projOrder = _cfg.self->getOption("ProjectionOrder", "sequential");
+ string projOrder = _cfg.self.getOption("ProjectionOrder", "sequential");
CC.markOptionParsed("ProjectionOrder");
if (projOrder == "sequential") {
m_piProjectionOrder = new int[m_iProjectionCount];
@@ -145,7 +145,7 @@ bool CSartAlgorithm::initialize(const Config& _cfg)
m_piProjectionOrder[i + k] = t;
}
} else if (projOrder == "custom") {
- vector<float32> projOrderList = _cfg.self->getOptionNumericalArray("ProjectionOrderList");
+ vector<float32> projOrderList = _cfg.self.getOptionNumericalArray("ProjectionOrderList");
m_piProjectionOrder = new int[projOrderList.size()];
for (int i = 0; i < m_iProjectionCount; i++) {
m_piProjectionOrder[i] = static_cast<int>(projOrderList[i]);
diff --git a/src/SparseMatrixProjectionGeometry2D.cpp b/src/SparseMatrixProjectionGeometry2D.cpp
index 86357d2..073720f 100644
--- a/src/SparseMatrixProjectionGeometry2D.cpp
+++ b/src/SparseMatrixProjectionGeometry2D.cpp
@@ -98,11 +98,10 @@ bool CSparseMatrixProjectionGeometry2D::initialize(const Config& _cfg)
CProjectionGeometry2D::initialize(_cfg);
// get matrix
- XMLNode* node = _cfg.self->getSingleNode("MatrixID");
+ XMLNode node = _cfg.self.getSingleNode("MatrixID");
ASTRA_CONFIG_CHECK(node, "SparseMatrixProjectionGeometry2D", "No MatrixID tag specified.");
- int id = boost::lexical_cast<int>(node->getContent());
+ int id = boost::lexical_cast<int>(node.getContent());
m_pMatrix = CMatrixManager::getSingleton().get(id);
- ASTRA_DELETE(node);
CC.markNodeParsed("MatrixID");
// success
@@ -194,11 +193,11 @@ 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));
+ 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;
}
diff --git a/src/VolumeGeometry2D.cpp b/src/VolumeGeometry2D.cpp
index d412914..6eea1b2 100644
--- a/src/VolumeGeometry2D.cpp
+++ b/src/VolumeGeometry2D.cpp
@@ -164,24 +164,22 @@ bool CVolumeGeometry2D::initialize(const Config& _cfg)
}
// Required: GridColCount
- XMLNode* node = _cfg.self->getSingleNode("GridColCount");
+ XMLNode node = _cfg.self.getSingleNode("GridColCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridColCount tag specified.");
- m_iGridColCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iGridColCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("GridColCount");
// Required: GridRowCount
- node = _cfg.self->getSingleNode("GridRowCount");
+ node = _cfg.self.getSingleNode("GridRowCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridRowCount tag specified.");
- m_iGridRowCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iGridRowCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("GridRowCount");
// Optional: Window minima and maxima
- m_fWindowMinX = _cfg.self->getOptionNumerical("WindowMinX", -m_iGridColCount/2.0f);
- m_fWindowMaxX = _cfg.self->getOptionNumerical("WindowMaxX", m_iGridColCount/2.0f);
- m_fWindowMinY = _cfg.self->getOptionNumerical("WindowMinY", -m_iGridRowCount/2.0f);
- m_fWindowMaxY = _cfg.self->getOptionNumerical("WindowMaxY", m_iGridRowCount/2.0f);
+ m_fWindowMinX = _cfg.self.getOptionNumerical("WindowMinX", -m_iGridColCount/2.0f);
+ m_fWindowMaxX = _cfg.self.getOptionNumerical("WindowMaxX", m_iGridColCount/2.0f);
+ m_fWindowMinY = _cfg.self.getOptionNumerical("WindowMinY", -m_iGridRowCount/2.0f);
+ m_fWindowMaxY = _cfg.self.getOptionNumerical("WindowMaxY", m_iGridRowCount/2.0f);
CC.markOptionParsed("WindowMinX");
CC.markOptionParsed("WindowMaxX");
CC.markOptionParsed("WindowMinY");
@@ -285,13 +283,13 @@ Config* CVolumeGeometry2D::getConfiguration() const
Config* cfg = new Config();
cfg->initialize("VolumeGeometry2D");
- cfg->self->addChildNode("GridColCount", m_iGridColCount);
- cfg->self->addChildNode("GridRowCount", m_iGridRowCount);
+ cfg->self.addChildNode("GridColCount", m_iGridColCount);
+ cfg->self.addChildNode("GridRowCount", m_iGridRowCount);
- cfg->self->addOption("WindowMinX", m_fWindowMinX);
- cfg->self->addOption("WindowMaxX", m_fWindowMaxX);
- cfg->self->addOption("WindowMinY", m_fWindowMinY);
- cfg->self->addOption("WindowMaxY", m_fWindowMaxY);
+ cfg->self.addOption("WindowMinX", m_fWindowMinX);
+ cfg->self.addOption("WindowMaxX", m_fWindowMaxX);
+ cfg->self.addOption("WindowMinY", m_fWindowMinY);
+ cfg->self.addOption("WindowMaxY", m_fWindowMaxY);
return cfg;
}
diff --git a/src/VolumeGeometry3D.cpp b/src/VolumeGeometry3D.cpp
index 66e6f0c..a1cf424 100644
--- a/src/VolumeGeometry3D.cpp
+++ b/src/VolumeGeometry3D.cpp
@@ -192,33 +192,30 @@ bool CVolumeGeometry3D::initialize(const Config& _cfg)
}
// Required: GridColCount
- XMLNode* node = _cfg.self->getSingleNode("GridColCount");
+ XMLNode node = _cfg.self.getSingleNode("GridColCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridColCount tag specified.");
- m_iGridColCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iGridColCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("GridColCount");
// Required: GridRowCount
- node = _cfg.self->getSingleNode("GridRowCount");
+ node = _cfg.self.getSingleNode("GridRowCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridRowCount tag specified.");
- m_iGridRowCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iGridRowCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("GridRowCount");
// Required: GridRowCount
- node = _cfg.self->getSingleNode("GridSliceCount");
+ node = _cfg.self.getSingleNode("GridSliceCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridSliceCount tag specified.");
- m_iGridSliceCount = boost::lexical_cast<int>(node->getContent());
- ASTRA_DELETE(node);
+ m_iGridSliceCount = boost::lexical_cast<int>(node.getContent());
CC.markNodeParsed("GridSliceCount");
// Optional: Window minima and maxima
- m_fWindowMinX = _cfg.self->getOptionNumerical("WindowMinX", -m_iGridColCount/2.0f);
- m_fWindowMaxX = _cfg.self->getOptionNumerical("WindowMaxX", m_iGridColCount/2.0f);
- m_fWindowMinY = _cfg.self->getOptionNumerical("WindowMinY", -m_iGridRowCount/2.0f);
- m_fWindowMaxY = _cfg.self->getOptionNumerical("WindowMaxY", m_iGridRowCount/2.0f);
- m_fWindowMinZ = _cfg.self->getOptionNumerical("WindowMinZ", -m_iGridSliceCount/2.0f);
- m_fWindowMaxZ = _cfg.self->getOptionNumerical("WindowMaxZ", m_iGridSliceCount/2.0f);
+ m_fWindowMinX = _cfg.self.getOptionNumerical("WindowMinX", -m_iGridColCount/2.0f);
+ m_fWindowMaxX = _cfg.self.getOptionNumerical("WindowMaxX", m_iGridColCount/2.0f);
+ m_fWindowMinY = _cfg.self.getOptionNumerical("WindowMinY", -m_iGridRowCount/2.0f);
+ m_fWindowMaxY = _cfg.self.getOptionNumerical("WindowMaxY", m_iGridRowCount/2.0f);
+ m_fWindowMinZ = _cfg.self.getOptionNumerical("WindowMinZ", -m_iGridSliceCount/2.0f);
+ m_fWindowMaxZ = _cfg.self.getOptionNumerical("WindowMaxZ", m_iGridSliceCount/2.0f);
CC.markOptionParsed("WindowMinX");
CC.markOptionParsed("WindowMaxX");
CC.markOptionParsed("WindowMinY");
@@ -386,16 +383,16 @@ Config* CVolumeGeometry3D::getConfiguration() const
Config* cfg = new Config();
cfg->initialize("VolumeGeometry3D");
- cfg->self->addChildNode("GridColCount", m_iGridColCount);
- cfg->self->addChildNode("GridRowCount", m_iGridRowCount);
- cfg->self->addChildNode("GridSliceCount", m_iGridSliceCount);
+ cfg->self.addChildNode("GridColCount", m_iGridColCount);
+ cfg->self.addChildNode("GridRowCount", m_iGridRowCount);
+ cfg->self.addChildNode("GridSliceCount", m_iGridSliceCount);
- cfg->self->addOption("WindowMinX", m_fWindowMinX);
- cfg->self->addOption("WindowMaxX", m_fWindowMaxX);
- cfg->self->addOption("WindowMinY", m_fWindowMinY);
- cfg->self->addOption("WindowMaxY", m_fWindowMaxY);
- cfg->self->addOption("WindowMinZ", m_fWindowMinZ);
- cfg->self->addOption("WindowMaxZ", m_fWindowMaxZ);
+ cfg->self.addOption("WindowMinX", m_fWindowMinX);
+ cfg->self.addOption("WindowMaxX", m_fWindowMaxX);
+ cfg->self.addOption("WindowMinY", m_fWindowMinY);
+ cfg->self.addOption("WindowMaxY", m_fWindowMaxY);
+ cfg->self.addOption("WindowMinZ", m_fWindowMinZ);
+ cfg->self.addOption("WindowMaxZ", m_fWindowMaxZ);
return cfg;
}
diff --git a/src/XMLDocument.cpp b/src/XMLDocument.cpp
index 406564f..716ed9e 100644
--- a/src/XMLDocument.cpp
+++ b/src/XMLDocument.cpp
@@ -32,13 +32,8 @@ $Id$
#include <iostream>
#include <sstream>
-#ifdef _MSC_VER
#include "rapidxml/rapidxml.hpp"
#include "rapidxml/rapidxml_print.hpp"
-#else
-#include "rapidxml.hpp"
-#include "rapidxml_print.hpp"
-#endif
using namespace rapidxml;
using namespace astra;
@@ -94,10 +89,9 @@ XMLDocument* XMLDocument::createDocument(string sRootName)
}
//-----------------------------------------------------------------------------
-XMLNode* XMLDocument::getRootNode()
+XMLNode XMLDocument::getRootNode()
{
- // TODO: clean up: this 'new' requires callers to do memory management
- return new XMLNode(fDOMDocument->first_node());
+ return XMLNode(fDOMDocument->first_node());
}
//-----------------------------------------------------------------------------
diff --git a/src/XMLNode.cpp b/src/XMLNode.cpp
index 4b2bdf4..0ec701f 100644
--- a/src/XMLNode.cpp
+++ b/src/XMLNode.cpp
@@ -28,15 +28,15 @@ $Id$
#include "astra/XMLNode.h"
-#ifdef _MSC_VER
#include "rapidxml/rapidxml.hpp"
#include "rapidxml/rapidxml_print.hpp"
-#else
-#include "rapidxml.hpp"
-#include "rapidxml_print.hpp"
-#endif
#include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
+
+
using namespace rapidxml;
using namespace astra;
@@ -44,21 +44,10 @@ using namespace std;
//-----------------------------------------------------------------------------
-// Utility function to delete a list of nodes
-static void deleteNodes(list<XMLNode*>& nodes)
-{
- for (list<XMLNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i)
- delete (*i);
-
- nodes.clear();
-}
-
-
-//-----------------------------------------------------------------------------
// default constructor
XMLNode::XMLNode()
{
-
+ fDOMElement = 0;
}
//-----------------------------------------------------------------------------
@@ -84,14 +73,14 @@ void XMLNode::setDOMNode(xml_node<>* n)
//-----------------------------------------------------------------------------
// print XML Node
-void XMLNode::print()
+void XMLNode::print() const
{
std::cout << fDOMElement;
}
//-----------------------------------------------------------------------------
// print XML Node
-std::string XMLNode::toString()
+std::string XMLNode::toString() const
{
std::string s;
::print(std::back_inserter(s), *fDOMElement, 0);
@@ -100,64 +89,61 @@ std::string XMLNode::toString()
//-----------------------------------------------------------------------------
// Get single node
-XMLNode* XMLNode::getSingleNode(string name)
+XMLNode XMLNode::getSingleNode(string name) const
{
xml_node<> *node = fDOMElement->first_node(name.c_str());
- if (node)
- return new XMLNode(node);
- else
- return 0;
+ return XMLNode(node);
}
//-----------------------------------------------------------------------------
// Get list of nodes
-list<XMLNode*> XMLNode::getNodes(string name)
+list<XMLNode> XMLNode::getNodes(string name) const
{
- list<XMLNode*> result;
+ list<XMLNode> result;
xml_node<> *iter;
for (iter = fDOMElement->first_node(name.c_str()); iter; iter = iter->next_sibling(name.c_str())) {
- result.push_back(new XMLNode(iter));
+ result.push_back(XMLNode(iter));
}
return result;
}
//-----------------------------------------------------------------------------
// Get list of nodes
-list<XMLNode*> XMLNode::getNodes()
+list<XMLNode> XMLNode::getNodes() const
{
- list<XMLNode*> result;
+ list<XMLNode> result;
xml_node<> *iter;
for (iter = fDOMElement->first_node(); iter; iter = iter->next_sibling()) {
- result.push_back(new XMLNode(iter));
+ result.push_back(XMLNode(iter));
}
return result;
}
//-----------------------------------------------------------------------------
// Get name of this node
-std::string XMLNode::getName()
+std::string XMLNode::getName() const
{
return fDOMElement->name();
}
//-----------------------------------------------------------------------------
// Get node content - STRING
-string XMLNode::getContent()
+string XMLNode::getContent() const
{
return fDOMElement->value();
}
//-----------------------------------------------------------------------------
// Get node content - NUMERICAL
-float32 XMLNode::getContentNumerical()
+float32 XMLNode::getContentNumerical() const
{
return boost::lexical_cast<float32>(getContent());
}
//-----------------------------------------------------------------------------
// Get node content - BOOLEAN
-bool XMLNode::getContentBool()
+bool XMLNode::getContentBool() const
{
string res = getContent();
return ((res == "1") || (res == "yes") || (res == "true") || (res == "on"));
@@ -165,21 +151,20 @@ bool XMLNode::getContentBool()
//-----------------------------------------------------------------------------
// Get node content - STRING LIST
-vector<string> XMLNode::getContentArray()
+vector<string> XMLNode::getContentArray() const
{
// get listsize
int iSize = boost::lexical_cast<int>(getAttribute("listsize"));
// create result array
vector<string> res(iSize);
// loop all list item nodes
- list<XMLNode*> nodes = getNodes("ListItem");
- for (list<XMLNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
- int iIndex = (*it)->getAttributeNumerical("index");
- string sValue = (*it)->getAttribute("value");
+ list<XMLNode> nodes = getNodes("ListItem");
+ for (list<XMLNode>::iterator it = nodes.begin(); it != nodes.end(); it++) {
+ int iIndex = it->getAttributeNumerical("index");
+ string sValue = it->getAttribute("value");
ASTRA_ASSERT(iIndex < iSize);
res[iIndex] = sValue;
}
- deleteNodes(nodes);
// return
return res;
@@ -187,85 +172,48 @@ vector<string> XMLNode::getContentArray()
//-----------------------------------------------------------------------------
// Get node content - NUMERICAL LIST
-vector<float32> XMLNode::getContentNumericalArray()
+// NB: A 2D matrix is returned as a linear list
+vector<float32> XMLNode::getContentNumericalArray() const
{
- // is scalar
- if (!hasAttribute("listsize")) {
- vector<float32> res(1);
- res[0] = getContentNumerical();
- return res;
- }
+ string input = getContent();
- int iSize = boost::lexical_cast<int>(getAttribute("listsize"));
- // create result array
- vector<float32> res(iSize);
- // loop all list item nodes
- list<XMLNode*> nodes = getNodes("ListItem");
- for (list<XMLNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
- int iIndex = (*it)->getAttributeNumerical("index");
- float32 fValue = (*it)->getAttributeNumerical("value");
- ASTRA_ASSERT(iIndex < iSize);
- res[iIndex] = fValue;
- }
- deleteNodes(nodes);
- // return
- return res;
-}
+ // split
+ std::vector<std::string> items;
+ boost::split(items, input, boost::is_any_of(",;"));
-vector<double> XMLNode::getContentNumericalArrayDouble()
-{
- // is scalar
- if (!hasAttribute("listsize")) {
- vector<double> res(1);
- res[0] = getContentNumerical();
- return res;
- }
+ // init list
+ vector<float32> out;
+ out.resize(items.size());
- int iSize = boost::lexical_cast<int>(getAttribute("listsize"));
- // create result array
- vector<double> res(iSize);
- // loop all list item nodes
- list<XMLNode*> nodes = getNodes("ListItem");
- for (list<XMLNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
- int iIndex = (*it)->getAttributeNumerical("index");
- double fValue = (*it)->getAttributeNumericalDouble("value");
- ASTRA_ASSERT(iIndex < iSize);
- res[iIndex] = fValue;
+ // loop elements
+ for (unsigned int i = 0; i < items.size(); i++) {
+ out[i] = boost::lexical_cast<float32>(items[i]);
}
- deleteNodes(nodes);
- // return
- return res;
+ return out;
}
-//-----------------------------------------------------------------------------
-// Get node content - NUMERICAL LIST 2
-void XMLNode::getContentNumericalArray(float32*& _pfData, int& _iSize)
+vector<double> XMLNode::getContentNumericalArrayDouble() const
{
- // is scalar
- if (!hasAttribute("listsize")) {
- _iSize = 1;
- _pfData = new float32[_iSize];
- _pfData[0] = getContentNumerical();
- return;
- }
- // get listsize
- _iSize = boost::lexical_cast<int>(getAttribute("listsize"));
- // create result array
- _pfData = new float32[_iSize];
- // loop all list item nodes
- list<XMLNode*> nodes = getNodes("ListItem");
- for (list<XMLNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
- int iIndex = (*it)->getAttributeNumerical("index");
- float32 fValue = (*it)->getAttributeNumerical("value");
- ASTRA_ASSERT(iIndex < _iSize);
- _pfData[iIndex] = fValue;
+ string input = getContent();
+
+ // split
+ std::vector<std::string> items;
+ boost::split(items, input, boost::is_any_of(",;"));
+
+ // init list
+ vector<double> out;
+ out.resize(items.size());
+
+ // loop elements
+ for (unsigned int i = 0; i < items.size(); i++) {
+ out[i] = boost::lexical_cast<double>(items[i]);
}
- deleteNodes(nodes);
+ return out;
}
//-----------------------------------------------------------------------------
// Is attribute?
-bool XMLNode::hasAttribute(string _sName)
+bool XMLNode::hasAttribute(string _sName) const
{
xml_attribute<> *attr = fDOMElement->first_attribute(_sName.c_str());
return (attr != 0);
@@ -273,7 +221,7 @@ bool XMLNode::hasAttribute(string _sName)
//-----------------------------------------------------------------------------
// Get attribute - STRING
-string XMLNode::getAttribute(string _sName, string _sDefaultValue)
+string XMLNode::getAttribute(string _sName, string _sDefaultValue) const
{
xml_attribute<> *attr = fDOMElement->first_attribute(_sName.c_str());
@@ -284,12 +232,12 @@ string XMLNode::getAttribute(string _sName, string _sDefaultValue)
//-----------------------------------------------------------------------------
// Get attribute - NUMERICAL
-float32 XMLNode::getAttributeNumerical(string _sName, float32 _fDefaultValue)
+float32 XMLNode::getAttributeNumerical(string _sName, float32 _fDefaultValue) const
{
if (!hasAttribute(_sName)) return _fDefaultValue;
return boost::lexical_cast<float32>(getAttribute(_sName));
}
-double XMLNode::getAttributeNumericalDouble(string _sName, double _fDefaultValue)
+double XMLNode::getAttributeNumericalDouble(string _sName, double _fDefaultValue) const
{
if (!hasAttribute(_sName)) return _fDefaultValue;
return boost::lexical_cast<double>(getAttribute(_sName));
@@ -297,7 +245,7 @@ double XMLNode::getAttributeNumericalDouble(string _sName, double _fDefaultValue
//-----------------------------------------------------------------------------
// Get attribute - BOOLEAN
-bool XMLNode::getAttributeBool(string _sName, bool _bDefaultValue)
+bool XMLNode::getAttributeBool(string _sName, bool _bDefaultValue) const
{
if (!hasAttribute(_sName)) return _bDefaultValue;
string res = getAttribute(_sName);
@@ -306,7 +254,7 @@ bool XMLNode::getAttributeBool(string _sName, bool _bDefaultValue)
//-----------------------------------------------------------------------------
// Has option?
-bool XMLNode::hasOption(string _sKey)
+bool XMLNode::hasOption(string _sKey) const
{
xml_node<> *iter;
for (iter = fDOMElement->first_node("Option"); iter; iter = iter->next_sibling("Option")) {
@@ -319,7 +267,7 @@ bool XMLNode::hasOption(string _sKey)
//-----------------------------------------------------------------------------
// Get option - STRING
-string XMLNode::getOption(string _sKey, string _sDefaultValue)
+string XMLNode::getOption(string _sKey, string _sDefaultValue) const
{
xml_node<> *iter;
for (iter = fDOMElement->first_node("Option"); iter; iter = iter->next_sibling("Option")) {
@@ -336,7 +284,7 @@ string XMLNode::getOption(string _sKey, string _sDefaultValue)
//-----------------------------------------------------------------------------
// Get option - NUMERICAL
-float32 XMLNode::getOptionNumerical(string _sKey, float32 _fDefaultValue)
+float32 XMLNode::getOptionNumerical(string _sKey, float32 _fDefaultValue) const
{
if (!hasOption(_sKey)) return _fDefaultValue;
return boost::lexical_cast<float32>(getOption(_sKey));
@@ -344,7 +292,7 @@ float32 XMLNode::getOptionNumerical(string _sKey, float32 _fDefaultValue)
//-----------------------------------------------------------------------------
// Get option - BOOL
-bool XMLNode::getOptionBool(string _sKey, bool _bDefaultValue)
+bool XMLNode::getOptionBool(string _sKey, bool _bDefaultValue) const
{
bool bHasOption = hasOption(_sKey);
if (!bHasOption) return _bDefaultValue;
@@ -354,20 +302,18 @@ bool XMLNode::getOptionBool(string _sKey, bool _bDefaultValue)
//-----------------------------------------------------------------------------
// Get option - NUMERICAL ARRAY
-vector<float32> XMLNode::getOptionNumericalArray(string _sKey)
+vector<float32> XMLNode::getOptionNumericalArray(string _sKey) const
{
if (!hasOption(_sKey)) return vector<float32>();
- list<XMLNode*> nodes = getNodes("Option");
- for (list<XMLNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
- if ((*it)->getAttribute("key") == _sKey) {
- vector<float32> vals = (*it)->getContentNumericalArray();
- deleteNodes(nodes);
+ list<XMLNode> nodes = getNodes("Option");
+ for (list<XMLNode>::iterator it = nodes.begin(); it != nodes.end(); it++) {
+ if (it->getAttribute("key") == _sKey) {
+ vector<float32> vals = it->getContentNumericalArray();
return vals;
}
}
- deleteNodes(nodes);
return vector<float32>();
}
@@ -390,41 +336,40 @@ vector<float32> XMLNode::getOptionNumericalArray(string _sKey)
//-----------------------------------------------------------------------------
// Add child node - EMPTY
-XMLNode* XMLNode::addChildNode(string _sNodeName)
+XMLNode XMLNode::addChildNode(string _sNodeName)
{
xml_document<> *doc = fDOMElement->document();
char *node_name = doc->allocate_string(_sNodeName.c_str());
xml_node<> *node = doc->allocate_node(node_element, node_name);
fDOMElement->append_node(node);
- // TODO: clean up: this 'new' requires callers to do memory management
- return new XMLNode(node);
+ return XMLNode(node);
}
//-----------------------------------------------------------------------------
// Add child node - STRING
-XMLNode* XMLNode::addChildNode(string _sNodeName, string _sText)
+XMLNode XMLNode::addChildNode(string _sNodeName, string _sText)
{
- XMLNode* res = addChildNode(_sNodeName);
- res->setContent(_sText);
+ XMLNode res = addChildNode(_sNodeName);
+ res.setContent(_sText);
return res;
}
//-----------------------------------------------------------------------------
// Add child node - FLOAT
-XMLNode* XMLNode::addChildNode(string _sNodeName, float32 _fValue)
+XMLNode XMLNode::addChildNode(string _sNodeName, float32 _fValue)
{
- XMLNode* res = addChildNode(_sNodeName);
- res->setContent(_fValue);
+ XMLNode res = addChildNode(_sNodeName);
+ res.setContent(_fValue);
return res;
}
//-----------------------------------------------------------------------------
// Add child node - LIST
-XMLNode* XMLNode::addChildNode(string _sNodeName, float32* _pfList, int _iSize)
+XMLNode XMLNode::addChildNode(string _sNodeName, float32* _pfList, int _iSize)
{
- XMLNode* res = addChildNode(_sNodeName);
- res->setContent(_pfList, _iSize);
+ XMLNode res = addChildNode(_sNodeName);
+ res.setContent(_pfList, _iSize);
return res;
}
@@ -446,15 +391,68 @@ void XMLNode::setContent(float32 _fValue)
//-----------------------------------------------------------------------------
// Set content - LIST
-void XMLNode::setContent(float32* pfList, int _iSize)
-{
+
+template<typename T>
+static std::string setContentList_internal(T* pfList, int _iSize) {
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);
+ return str;
+}
+
+void XMLNode::setContent(float32* pfList, int _iSize)
+{
+ setContent(setContentList_internal<float32>(pfList, _iSize));
+}
+
+void XMLNode::setContent(double* pfList, int _iSize)
+{
+ setContent(setContentList_internal<double>(pfList, _iSize));
+}
+
+//-----------------------------------------------------------------------------
+// Set content - MATRIX
+
+template<typename T>
+static std::string setContentMatrix_internal(T* _pfMatrix, int _iWidth, int _iHeight, bool transposed)
+{
+ std::string str = "";
+
+ int s1,s2;
+
+ if (!transposed) {
+ s1 = 1;
+ s2 = _iWidth;
+ } else {
+ s1 = _iHeight;
+ s2 = 1;
+ }
+
+ for (int y = 0; y < _iHeight; ++y) {
+ if (_iWidth > 0)
+ str += boost::lexical_cast<std::string>(_pfMatrix[0*s1 + y*s2]);
+ for (int x = 1; x < _iWidth; x++)
+ str += "," + boost::lexical_cast<std::string>(_pfMatrix[x*s1 + y*s2]);
+
+ if (y != _iHeight-1)
+ str += ";";
+ }
+
+ return str;
}
+void XMLNode::setContent(float32* _pfMatrix, int _iWidth, int _iHeight, bool transposed)
+{
+ setContent(setContentMatrix_internal<float32>(_pfMatrix, _iWidth, _iHeight, transposed));
+}
+
+void XMLNode::setContent(double* _pfMatrix, int _iWidth, int _iHeight, bool transposed)
+{
+ setContent(setContentMatrix_internal<double>(_pfMatrix, _iWidth, _iHeight, transposed));
+}
+
+
//-----------------------------------------------------------------------------
// Add attribute - STRING
void XMLNode::addAttribute(string _sName, string _sText)
@@ -477,20 +475,18 @@ void XMLNode::addAttribute(string _sName, float32 _fValue)
// Add option - STRING
void XMLNode::addOption(string _sName, string _sText)
{
- XMLNode* node = addChildNode("Option");
- node->addAttribute("key", _sName);
- node->addAttribute("value", _sText);
- delete node;
+ XMLNode node = addChildNode("Option");
+ node.addAttribute("key", _sName);
+ node.addAttribute("value", _sText);
}
//-----------------------------------------------------------------------------
// Add option - FLOAT
void XMLNode::addOption(string _sName, float32 _sText)
{
- XMLNode* node = addChildNode("Option");
- node->addAttribute("key", _sName);
- node->addAttribute("value", _sText);
- delete node;
+ XMLNode node = addChildNode("Option");
+ node.addAttribute("key", _sName);
+ node.addAttribute("value", _sText);
}
//-----------------------------------------------------------------------------