summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2015-12-17 14:37:41 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-01-05 11:15:17 +0100
commitfc86917da1a175c04e9bd2e5f0bedb0a48a81c26 (patch)
tree6996a3e2e2cfd110a566d4093e22ca746a52038d
parent73fa0a8df8203288aca032c71caa5ff47d35a3e2 (diff)
downloadastra-fc86917da1a175c04e9bd2e5f0bedb0a48a81c26.tar.gz
astra-fc86917da1a175c04e9bd2e5f0bedb0a48a81c26.tar.bz2
astra-fc86917da1a175c04e9bd2e5f0bedb0a48a81c26.tar.xz
astra-fc86917da1a175c04e9bd2e5f0bedb0a48a81c26.zip
Replace boost::lexical_cast by stringstreams
This is to avoid the dependence of lexical_cast on the current locale. The stringstreams used for the new string parsing/output functions are explicitly imbued with the C/classic locale.
-rw-r--r--build/linux/configure.ac1
-rw-r--r--include/astra/Utilities.h51
-rw-r--r--include/astra/XMLNode.h8
-rw-r--r--matlab/mex/mexHelpFunctions.cpp8
-rw-r--r--matlab/mex/mexHelpFunctions.h1
-rw-r--r--src/ArtAlgorithm.cpp2
-rw-r--r--src/BackProjectionAlgorithm.cpp2
-rw-r--r--src/CglsAlgorithm.cpp2
-rw-r--r--src/ConeProjectionGeometry3D.cpp5
-rw-r--r--src/ConeVecProjectionGeometry3D.cpp30
-rw-r--r--src/CudaBackProjectionAlgorithm3D.cpp2
-rw-r--r--src/CudaCglsAlgorithm3D.cpp2
-rw-r--r--src/CudaDartMaskAlgorithm.cpp5
-rw-r--r--src/CudaDartMaskAlgorithm3D.cpp5
-rw-r--r--src/CudaDartSmoothingAlgorithm.cpp5
-rw-r--r--src/CudaDartSmoothingAlgorithm3D.cpp5
-rw-r--r--src/CudaDataOperationAlgorithm.cpp5
-rw-r--r--src/CudaFDKAlgorithm3D.cpp2
-rw-r--r--src/CudaFilteredBackProjectionAlgorithm.cpp13
-rw-r--r--src/CudaForwardProjectionAlgorithm.cpp8
-rw-r--r--src/CudaForwardProjectionAlgorithm3D.cpp8
-rw-r--r--src/CudaReconstructionAlgorithm2D.cpp2
-rw-r--r--src/CudaRoiSelectAlgorithm.cpp3
-rw-r--r--src/CudaSirtAlgorithm.cpp5
-rw-r--r--src/CudaSirtAlgorithm3D.cpp2
-rw-r--r--src/FanFlatBeamLineKernelProjector2D.cpp1
-rw-r--r--src/FanFlatBeamStripKernelProjector2D.cpp1
-rw-r--r--src/FanFlatProjectionGeometry2D.cpp5
-rw-r--r--src/FanFlatVecProjectionGeometry2D.cpp15
-rw-r--r--src/FilteredBackProjectionAlgorithm.cpp8
-rw-r--r--src/ForwardProjectionAlgorithm.cpp12
-rw-r--r--src/ParallelBeamBlobKernelProjector2D.cpp7
-rw-r--r--src/ParallelBeamLineKernelProjector2D.cpp1
-rw-r--r--src/ParallelBeamLinearKernelProjector2D.cpp1
-rw-r--r--src/ParallelBeamStripKernelProjector2D.cpp1
-rw-r--r--src/ParallelProjectionGeometry2D.cpp1
-rw-r--r--src/ParallelProjectionGeometry3D.cpp1
-rw-r--r--src/ParallelVecProjectionGeometry3D.cpp30
-rw-r--r--src/PluginAlgorithm.cpp14
-rw-r--r--src/ProjectionGeometry2D.cpp6
-rw-r--r--src/ProjectionGeometry3D.cpp10
-rw-r--r--src/ReconstructionAlgorithm2D.cpp12
-rw-r--r--src/ReconstructionAlgorithm3D.cpp12
-rw-r--r--src/ReconstructionAlgorithmMultiSlice2D.cpp8
-rw-r--r--src/SartAlgorithm.cpp2
-rw-r--r--src/SirtAlgorithm.cpp2
-rw-r--r--src/SparseMatrixProjectionGeometry2D.cpp3
-rw-r--r--src/SparseMatrixProjector2D.cpp1
-rw-r--r--src/Utilities.cpp95
-rw-r--r--src/VolumeGeometry2D.cpp5
-rw-r--r--src/VolumeGeometry3D.cpp8
-rw-r--r--src/XMLNode.cpp77
52 files changed, 297 insertions, 224 deletions
diff --git a/build/linux/configure.ac b/build/linux/configure.ac
index 85e4324..9b6f7ab 100644
--- a/build/linux/configure.ac
+++ b/build/linux/configure.ac
@@ -73,7 +73,6 @@ AC_SUBST(HAVEBOOSTUTF)
AC_SUBST(LIBS_BOOSTUTF)
BOOSTok=yes
-AC_CHECK_HEADER([boost/lexical_cast.hpp],[],[BOOSTok=no],[])
AC_CHECK_HEADER([boost/any.hpp],[],[BOOSTok=no],[])
dnl AC_CHECK_HEADER([boost/thread.hpp],[],[BOOSTok=no],[])
dnl AC_CHECK_HEADER([boost/bind.hpp],[],[BOOSTok=no],[])
diff --git a/include/astra/Utilities.h b/include/astra/Utilities.h
index a3655a8..3ae0e6c 100644
--- a/include/astra/Utilities.h
+++ b/include/astra/Utilities.h
@@ -39,6 +39,57 @@ namespace astra {
+namespace StringUtil {
+
+// Exception thrown by functions below
+class bad_cast : public std::exception {
+public:
+ bad_cast() { }
+};
+
+
+//< Parse string as int.
+//< Throw exception on failure.
+int stringToInt(const std::string& s);
+
+//< Parse string as float.
+//< Throw exception on failure.
+float stringToFloat(const std::string& s);
+
+//< Parse string as double.
+//< Throw exception on failure.
+double stringToDouble(const std::string& s);
+
+template<typename T>
+T stringTo(const std::string& s);
+
+//< Parse comma/semicolon-separated string as float vector.
+//< Throw exception on failure.
+std::vector<float> stringToFloatVector(const std::string& s);
+
+//< Parse comma/semicolon-separated string as double vector.
+//< Throw exception on failure.
+std::vector<double> stringToDoubleVector(const std::string& s);
+
+template<typename T>
+std::vector<T> stringToVector(const std::string& s);
+
+
+
+//< Generate string from float.
+std::string floatToString(float f);
+
+//< Generate string from double.
+std::string doubleToString(double f);
+
+template<typename T>
+std::string toString(T f);
+
+}
+
+
+
+
template<typename T, typename S>
std::map<T,S> mergeMap(std::map<T,S> _mMap1, std::map<T,S> _mMap2)
{
diff --git a/include/astra/XMLNode.h b/include/astra/XMLNode.h
index 4d29d5c..7d1edf5 100644
--- a/include/astra/XMLNode.h
+++ b/include/astra/XMLNode.h
@@ -101,6 +101,12 @@ public:
*/
string getContent() const;
+ /** Get the content of the XML node as an integer
+ *
+ * @return node content
+ */
+ int getContentInt() const;
+
/** Get the content of the XML node as a numerical.
*
* @return node content
@@ -152,6 +158,7 @@ public:
*/
float32 getAttributeNumerical(string _sName, float32 _fDefaultValue = 0) const;
double getAttributeNumericalDouble(string _sName, double _fDefaultValue = 0) const;
+ int getAttributeInt(string _sName, int _fDefaultValue = 0) const;
/** Get the value of a boolean attribute.
*
@@ -186,6 +193,7 @@ public:
* @return option value, _fDefaultValue if the option doesn't exist
*/
float32 getOptionNumerical(string _sKey, float32 _fDefaultValue = 0) const;
+ int getOptionInt(string _sKey, int _fDefaultValue = 0) const;
/** Get the value of an option within this XML Node
*
diff --git a/matlab/mex/mexHelpFunctions.cpp b/matlab/mex/mexHelpFunctions.cpp
index 58e84d2..13c4ade 100644
--- a/matlab/mex/mexHelpFunctions.cpp
+++ b/matlab/mex/mexHelpFunctions.cpp
@@ -31,9 +31,9 @@ $Id$
* \brief Contains some functions for interfacing matlab with c data structures
*/
#include "mexHelpFunctions.h"
+#include "astra/Utilities.h"
#include <algorithm>
-#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
@@ -58,7 +58,7 @@ string mexToString(const mxArray* pInput)
// is scalar?
if (mxIsNumeric(pInput) && mxGetM(pInput)*mxGetN(pInput) == 1) {
- return boost::lexical_cast<string>(mxGetScalar(pInput));
+ return StringUtil::doubleToString(mxGetScalar(pInput));
}
return "";
@@ -378,7 +378,7 @@ mxArray* stringToMxArray(std::string input)
boost::split(col_strings, row_strings[row], boost::is_any_of(","));
// check size
for (unsigned int col = 0; col < col_strings.size(); col++) {
- out[col*rows + row] = boost::lexical_cast<float32>(col_strings[col]);
+ out[col*rows + row] = StringUtil::stringToFloat(col_strings[col]);
}
}
return pMatrix;
@@ -397,7 +397,7 @@ mxArray* stringToMxArray(std::string input)
// loop elements
for (unsigned int i = 0; i < items.size(); i++) {
- out[i] = boost::lexical_cast<float32>(items[i]);
+ out[i] = StringUtil::stringToFloat(items[i]);
}
return pVector;
}
diff --git a/matlab/mex/mexHelpFunctions.h b/matlab/mex/mexHelpFunctions.h
index 3ac5bd8..07edc64 100644
--- a/matlab/mex/mexHelpFunctions.h
+++ b/matlab/mex/mexHelpFunctions.h
@@ -37,7 +37,6 @@ $Id$
#include <algorithm>
#include <mex.h>
-#include <boost/lexical_cast.hpp>
#include <boost/any.hpp>
#include "astra/Globals.h"
diff --git a/src/ArtAlgorithm.cpp b/src/ArtAlgorithm.cpp
index 6a699ec..b59bd93 100644
--- a/src/ArtAlgorithm.cpp
+++ b/src/ArtAlgorithm.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/ArtAlgorithm.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
using namespace std;
diff --git a/src/BackProjectionAlgorithm.cpp b/src/BackProjectionAlgorithm.cpp
index f561a90..c9beee1 100644
--- a/src/BackProjectionAlgorithm.cpp
+++ b/src/BackProjectionAlgorithm.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/BackProjectionAlgorithm.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/DataProjectorPolicies.h"
diff --git a/src/CglsAlgorithm.cpp b/src/CglsAlgorithm.cpp
index b9031e3..1ca2549 100644
--- a/src/CglsAlgorithm.cpp
+++ b/src/CglsAlgorithm.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/CglsAlgorithm.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
using namespace std;
diff --git a/src/ConeProjectionGeometry3D.cpp b/src/ConeProjectionGeometry3D.cpp
index 18f0f8a..99b4bf4 100644
--- a/src/ConeProjectionGeometry3D.cpp
+++ b/src/ConeProjectionGeometry3D.cpp
@@ -31,7 +31,6 @@ $Id$
#include "astra/Logging.h"
#include "astra/GeometryUtil3D.h"
-#include <boost/lexical_cast.hpp>
#include <cstring>
using namespace std;
@@ -90,13 +89,13 @@ bool CConeProjectionGeometry3D::initialize(const Config& _cfg)
// Required: DistanceOriginDetector
XMLNode node = _cfg.self.getSingleNode("DistanceOriginDetector");
ASTRA_CONFIG_CHECK(node, "ConeProjectionGeometry3D", "No DistanceOriginDetector tag specified.");
- m_fOriginDetectorDistance = boost::lexical_cast<float32>(node.getContent());
+ m_fOriginDetectorDistance = node.getContentNumerical();
CC.markNodeParsed("DistanceOriginDetector");
// Required: DetectorOriginSource
node = _cfg.self.getSingleNode("DistanceOriginSource");
ASTRA_CONFIG_CHECK(node, "ConeProjectionGeometry3D", "No DistanceOriginSource tag specified.");
- m_fOriginSourceDistance = boost::lexical_cast<float32>(node.getContent());
+ m_fOriginSourceDistance = node.getContentNumerical();
CC.markNodeParsed("DistanceOriginSource");
// success
diff --git a/src/ConeVecProjectionGeometry3D.cpp b/src/ConeVecProjectionGeometry3D.cpp
index 86e3bd6..f4f900d 100644
--- a/src/ConeVecProjectionGeometry3D.cpp
+++ b/src/ConeVecProjectionGeometry3D.cpp
@@ -27,9 +27,9 @@ $Id$
*/
#include "astra/ConeVecProjectionGeometry3D.h"
+#include "astra/Utilities.h"
#include <cstring>
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -82,13 +82,13 @@ bool CConeVecProjectionGeometry3D::initialize(const Config& _cfg)
// Required: DetectorRowCount
node = _cfg.self.getSingleNode("DetectorRowCount");
ASTRA_CONFIG_CHECK(node, "ConeVecProjectionGeometry3D", "No DetectorRowCount tag specified.");
- m_iDetectorRowCount = boost::lexical_cast<int>(node.getContent());
+ m_iDetectorRowCount = node.getContentInt();
CC.markNodeParsed("DetectorRowCount");
// Required: 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 = node.getContentInt();
m_iDetectorTotCount = m_iDetectorRowCount * m_iDetectorColCount;
CC.markNodeParsed("DetectorColCount");
@@ -212,18 +212,18 @@ Config* CConeVecProjectionGeometry3D::getConfiguration() const
std::string vectors = "";
for (int i = 0; i < m_iProjectionAngleCount; ++i) {
SConeProjection& p = m_pProjectionAngles[i];
- vectors += boost::lexical_cast<string>(p.fSrcX) + ",";
- vectors += boost::lexical_cast<string>(p.fSrcY) + ",";
- vectors += boost::lexical_cast<string>(p.fSrcZ) + ",";
- vectors += boost::lexical_cast<string>(p.fDetSX + 0.5f*m_iDetectorRowCount*p.fDetVX + 0.5f*m_iDetectorColCount*p.fDetUX) + ",";
- vectors += boost::lexical_cast<string>(p.fDetSY + 0.5f*m_iDetectorRowCount*p.fDetVY + 0.5f*m_iDetectorColCount*p.fDetUY) + ",";
- vectors += boost::lexical_cast<string>(p.fDetSZ + 0.5f*m_iDetectorRowCount*p.fDetVZ + 0.5f*m_iDetectorColCount*p.fDetUZ) + ",";
- vectors += boost::lexical_cast<string>(p.fDetUX) + ",";
- vectors += boost::lexical_cast<string>(p.fDetUY) + ",";
- vectors += boost::lexical_cast<string>(p.fDetUZ) + ",";
- vectors += boost::lexical_cast<string>(p.fDetVX) + ",";
- vectors += boost::lexical_cast<string>(p.fDetVY) + ",";
- vectors += boost::lexical_cast<string>(p.fDetVZ);
+ vectors += StringUtil::toString(p.fSrcX) + ",";
+ vectors += StringUtil::toString(p.fSrcY) + ",";
+ vectors += StringUtil::toString(p.fSrcZ) + ",";
+ vectors += StringUtil::toString(p.fDetSX + 0.5f*m_iDetectorRowCount*p.fDetVX + 0.5f*m_iDetectorColCount*p.fDetUX) + ",";
+ vectors += StringUtil::toString(p.fDetSY + 0.5f*m_iDetectorRowCount*p.fDetVY + 0.5f*m_iDetectorColCount*p.fDetUY) + ",";
+ vectors += StringUtil::toString(p.fDetSZ + 0.5f*m_iDetectorRowCount*p.fDetVZ + 0.5f*m_iDetectorColCount*p.fDetUZ) + ",";
+ vectors += StringUtil::toString(p.fDetUX) + ",";
+ vectors += StringUtil::toString(p.fDetUY) + ",";
+ vectors += StringUtil::toString(p.fDetUZ) + ",";
+ vectors += StringUtil::toString(p.fDetVX) + ",";
+ vectors += StringUtil::toString(p.fDetVY) + ",";
+ vectors += StringUtil::toString(p.fDetVZ);
if (i < m_iProjectionAngleCount-1) vectors += ';';
}
cfg->self.addChildNode("Vectors", vectors);
diff --git a/src/CudaBackProjectionAlgorithm3D.cpp b/src/CudaBackProjectionAlgorithm3D.cpp
index ce8e111..76d7b35 100644
--- a/src/CudaBackProjectionAlgorithm3D.cpp
+++ b/src/CudaBackProjectionAlgorithm3D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/CudaBackProjectionAlgorithm3D.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/CudaProjector3D.h"
diff --git a/src/CudaCglsAlgorithm3D.cpp b/src/CudaCglsAlgorithm3D.cpp
index abc18d1..930a71e 100644
--- a/src/CudaCglsAlgorithm3D.cpp
+++ b/src/CudaCglsAlgorithm3D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/CudaCglsAlgorithm3D.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/CudaProjector3D.h"
diff --git a/src/CudaDartMaskAlgorithm.cpp b/src/CudaDartMaskAlgorithm.cpp
index 950b428..c2a4cca 100644
--- a/src/CudaDartMaskAlgorithm.cpp
+++ b/src/CudaDartMaskAlgorithm.cpp
@@ -34,7 +34,6 @@ $Id$
#include "../cuda/2d/algo.h"
#include "astra/AstraObjectManager.h"
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -67,14 +66,14 @@ bool CCudaDartMaskAlgorithm::initialize(const Config& _cfg)
// reconstruction data
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 = node.getContentInt();
m_pSegmentation = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("SegmentationDataId");
// reconstruction data
node = _cfg.self.getSingleNode("MaskDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No MaskDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("MaskDataId");
diff --git a/src/CudaDartMaskAlgorithm3D.cpp b/src/CudaDartMaskAlgorithm3D.cpp
index b0dfc5b..dd12c58 100644
--- a/src/CudaDartMaskAlgorithm3D.cpp
+++ b/src/CudaDartMaskAlgorithm3D.cpp
@@ -34,7 +34,6 @@ $Id$
#include "../cuda/3d/dims3d.h"
#include "astra/AstraObjectManager.h"
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -67,14 +66,14 @@ bool CCudaDartMaskAlgorithm3D::initialize(const Config& _cfg)
// reconstruction data
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 = node.getContentInt();
m_pSegmentation = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("SegmentationDataId");
// reconstruction data
node = _cfg.self.getSingleNode("MaskDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No MaskDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pMask = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("MaskDataId");
diff --git a/src/CudaDartSmoothingAlgorithm.cpp b/src/CudaDartSmoothingAlgorithm.cpp
index 7e22809..425f0a3 100644
--- a/src/CudaDartSmoothingAlgorithm.cpp
+++ b/src/CudaDartSmoothingAlgorithm.cpp
@@ -34,7 +34,6 @@ $Id$
#include "../cuda/2d/algo.h"
#include "astra/AstraObjectManager.h"
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -67,14 +66,14 @@ bool CCudaDartSmoothingAlgorithm::initialize(const Config& _cfg)
// reconstruction data
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 = node.getContentInt();
m_pIn = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("InDataId");
// reconstruction data
node = _cfg.self.getSingleNode("OutDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No OutDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pOut = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("OutDataId");
diff --git a/src/CudaDartSmoothingAlgorithm3D.cpp b/src/CudaDartSmoothingAlgorithm3D.cpp
index 9c4437a..df7e0df 100644
--- a/src/CudaDartSmoothingAlgorithm3D.cpp
+++ b/src/CudaDartSmoothingAlgorithm3D.cpp
@@ -34,7 +34,6 @@ $Id$
#include "../cuda/3d/dims3d.h"
#include "astra/AstraObjectManager.h"
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -67,14 +66,14 @@ bool CCudaDartSmoothingAlgorithm3D::initialize(const Config& _cfg)
// reconstruction data
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 = node.getContentInt();
m_pIn = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("InDataId");
// reconstruction data
node = _cfg.self.getSingleNode("OutDataId");
ASTRA_CONFIG_CHECK(node, "CudaDartMask", "No OutDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pOut = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("OutDataId");
diff --git a/src/CudaDataOperationAlgorithm.cpp b/src/CudaDataOperationAlgorithm.cpp
index ae133c2..15886a4 100644
--- a/src/CudaDataOperationAlgorithm.cpp
+++ b/src/CudaDataOperationAlgorithm.cpp
@@ -35,7 +35,6 @@ $Id$
#include "../cuda/2d/arith.h"
#include "astra/AstraObjectManager.h"
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -78,7 +77,7 @@ bool CCudaDataOperationAlgorithm::initialize(const Config& _cfg)
ASTRA_CONFIG_CHECK(node, "CCudaDataOperationAlgorithm", "No DataId tag specified.");
vector<string> data = node.getContentArray();
for (vector<string>::iterator it = data.begin(); it != data.end(); it++){
- int id = boost::lexical_cast<int>(*it);
+ int id = StringUtil::stringToInt(*it);
m_pData.push_back(dynamic_cast<CFloat32Data2D*>(CData2DManager::getSingleton().get(id)));
}
CC.markNodeParsed("DataId");
@@ -97,7 +96,7 @@ bool CCudaDataOperationAlgorithm::initialize(const Config& _cfg)
CC.markOptionParsed("GPUIndex");
if (_cfg.self.hasOption("MaskId")) {
- int id = boost::lexical_cast<int>(_cfg.self.getOption("MaskId"));
+ int id = _cfg.self.getOptionInt("MaskId");
m_pMask = dynamic_cast<CFloat32Data2D*>(CData2DManager::getSingleton().get(id));
}
CC.markOptionParsed("MaskId");
diff --git a/src/CudaFDKAlgorithm3D.cpp b/src/CudaFDKAlgorithm3D.cpp
index 1316daa..b5ce545 100644
--- a/src/CudaFDKAlgorithm3D.cpp
+++ b/src/CudaFDKAlgorithm3D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/CudaFDKAlgorithm3D.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/CudaProjector3D.h"
diff --git a/src/CudaFilteredBackProjectionAlgorithm.cpp b/src/CudaFilteredBackProjectionAlgorithm.cpp
index bcd70c4..aa97eec 100644
--- a/src/CudaFilteredBackProjectionAlgorithm.cpp
+++ b/src/CudaFilteredBackProjectionAlgorithm.cpp
@@ -28,7 +28,6 @@ $Id$
#include <astra/CudaFilteredBackProjectionAlgorithm.h>
#include <astra/FanFlatProjectionGeometry2D.h>
-#include <boost/lexical_cast.hpp>
#include <cstring>
#include "astra/AstraObjectManager.h"
@@ -100,7 +99,7 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
XMLNode node = _cfg.self.getSingleNode("ProjectorId");
CCudaProjector2D* pCudaProjector = 0;
if (node) {
- int id = boost::lexical_cast<int>(node.getContent());
+ int id = node.getContentInt();
CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
pCudaProjector = dynamic_cast<CCudaProjector2D*>(projector);
if (!pCudaProjector) {
@@ -113,14 +112,14 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "CudaFBP", "No ProjectionDataId tag specified.");
- int id = boost::lexical_cast<int>(node.getContent());
+ int id = node.getContentInt();
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "CudaFBP", "No ReconstructionDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pReconstruction = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ReconstructionDataId");
@@ -140,7 +139,7 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
node = _cfg.self.getSingleNode("FilterSinogramId");
if (node)
{
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
const CFloat32ProjectionData2D * pFilterData = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
m_iFilterWidth = pFilterData->getGeometry()->getDetectorCount();
int iFilterProjectionCount = pFilterData->getGeometry()->getProjectionAngleCount();
@@ -159,7 +158,7 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
node = _cfg.self.getSingleNode("FilterParameter");
if (node)
{
- float fParameter = boost::lexical_cast<float>(node.getContent());
+ float fParameter = node.getContentNumerical();
m_fFilterParameter = fParameter;
}
else
@@ -172,7 +171,7 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
node = _cfg.self.getSingleNode("FilterD");
if (node)
{
- float fD = boost::lexical_cast<float>(node.getContent());
+ float fD = node.getContentNumerical();
m_fFilterD = fD;
}
else
diff --git a/src/CudaForwardProjectionAlgorithm.cpp b/src/CudaForwardProjectionAlgorithm.cpp
index d38469c..80f2e02 100644
--- a/src/CudaForwardProjectionAlgorithm.cpp
+++ b/src/CudaForwardProjectionAlgorithm.cpp
@@ -35,8 +35,6 @@ $Id$
#include <driver_types.h>
#include <cuda_runtime_api.h>
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/ParallelProjectionGeometry2D.h"
#include "astra/FanFlatProjectionGeometry2D.h"
@@ -97,7 +95,7 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg)
m_pProjector = 0;
XMLNode node = _cfg.self.getSingleNode("ProjectorId");
if (node) {
- int id = boost::lexical_cast<int>(node.getContent());
+ int id = node.getContentInt();
m_pProjector = CProjector2DManager::getSingleton().get(id);
}
CC.markNodeParsed("ProjectorId");
@@ -107,14 +105,14 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg)
// sinogram data
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 = node.getContentInt();
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// volume data
node = _cfg.self.getSingleNode("VolumeDataId");
ASTRA_CONFIG_CHECK(node, "FP_CUDA", "No VolumeDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pVolume = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("VolumeDataId");
diff --git a/src/CudaForwardProjectionAlgorithm3D.cpp b/src/CudaForwardProjectionAlgorithm3D.cpp
index 209f5a5..f709e34 100644
--- a/src/CudaForwardProjectionAlgorithm3D.cpp
+++ b/src/CudaForwardProjectionAlgorithm3D.cpp
@@ -30,8 +30,6 @@ $Id$
#ifdef ASTRA_CUDA
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/CudaProjector3D.h"
@@ -103,14 +101,14 @@ bool CCudaForwardProjectionAlgorithm3D::initialize(const Config& _cfg)
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "CudaForwardProjection3D", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pProjections = dynamic_cast<CFloat32ProjectionData3DMemory*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
node = _cfg.self.getSingleNode("VolumeDataId");
ASTRA_CONFIG_CHECK(node, "CudaForwardProjection3D", "No VolumeDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pVolume = dynamic_cast<CFloat32VolumeData3DMemory*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("VolumeDataId");
@@ -118,7 +116,7 @@ bool CCudaForwardProjectionAlgorithm3D::initialize(const Config& _cfg)
node = _cfg.self.getSingleNode("ProjectorId");
m_pProjector = 0;
if (node) {
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pProjector = CProjector3DManager::getSingleton().get(id);
}
CC.markNodeParsed("ProjectorId");
diff --git a/src/CudaReconstructionAlgorithm2D.cpp b/src/CudaReconstructionAlgorithm2D.cpp
index 71dddf7..5a1910c 100644
--- a/src/CudaReconstructionAlgorithm2D.cpp
+++ b/src/CudaReconstructionAlgorithm2D.cpp
@@ -30,8 +30,6 @@ $Id$
#include "astra/CudaReconstructionAlgorithm2D.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/FanFlatProjectionGeometry2D.h"
#include "astra/FanFlatVecProjectionGeometry2D.h"
diff --git a/src/CudaRoiSelectAlgorithm.cpp b/src/CudaRoiSelectAlgorithm.cpp
index 7635c69..dfb8056 100644
--- a/src/CudaRoiSelectAlgorithm.cpp
+++ b/src/CudaRoiSelectAlgorithm.cpp
@@ -34,7 +34,6 @@ $Id$
#include "../cuda/2d/algo.h"
#include "astra/AstraObjectManager.h"
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -68,7 +67,7 @@ bool CCudaRoiSelectAlgorithm::initialize(const Config& _cfg)
// reconstruction data
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 = node.getContentInt();
m_pData = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("DataId");
diff --git a/src/CudaSirtAlgorithm.cpp b/src/CudaSirtAlgorithm.cpp
index ab0a418..33e381a 100644
--- a/src/CudaSirtAlgorithm.cpp
+++ b/src/CudaSirtAlgorithm.cpp
@@ -30,7 +30,6 @@ $Id$
#include "astra/CudaSirtAlgorithm.h"
-#include <boost/lexical_cast.hpp>
#include "astra/AstraObjectManager.h"
#include "../cuda/2d/sirt.h"
@@ -77,12 +76,12 @@ bool CCudaSirtAlgorithm::initialize(const Config& _cfg)
// min/max masks
if (_cfg.self.hasOption("MinMaskId")) {
- int id = boost::lexical_cast<int>(_cfg.self.getOption("MinMaskId"));
+ int id = _cfg.self.getOptionInt("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"));
+ int id = _cfg.self.getOptionInt("MaxMaskId");
m_pMaxMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
}
CC.markOptionParsed("MaxMaskId");
diff --git a/src/CudaSirtAlgorithm3D.cpp b/src/CudaSirtAlgorithm3D.cpp
index 1fa0da2..605c470 100644
--- a/src/CudaSirtAlgorithm3D.cpp
+++ b/src/CudaSirtAlgorithm3D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/CudaSirtAlgorithm3D.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/ConeProjectionGeometry3D.h"
diff --git a/src/FanFlatBeamLineKernelProjector2D.cpp b/src/FanFlatBeamLineKernelProjector2D.cpp
index 0681715..fd4195b 100644
--- a/src/FanFlatBeamLineKernelProjector2D.cpp
+++ b/src/FanFlatBeamLineKernelProjector2D.cpp
@@ -30,7 +30,6 @@ $Id$
#include <cmath>
#include <cstring>
-#include <boost/lexical_cast.hpp>
#include "astra/DataProjectorPolicies.h"
diff --git a/src/FanFlatBeamStripKernelProjector2D.cpp b/src/FanFlatBeamStripKernelProjector2D.cpp
index e94d3da..b48beab 100644
--- a/src/FanFlatBeamStripKernelProjector2D.cpp
+++ b/src/FanFlatBeamStripKernelProjector2D.cpp
@@ -29,7 +29,6 @@ $Id$
#include "astra/FanFlatBeamStripKernelProjector2D.h"
#include <cmath>
-#include <boost/lexical_cast.hpp>
#include "astra/DataProjectorPolicies.h"
diff --git a/src/FanFlatProjectionGeometry2D.cpp b/src/FanFlatProjectionGeometry2D.cpp
index 32a19bc..8bee0d6 100644
--- a/src/FanFlatProjectionGeometry2D.cpp
+++ b/src/FanFlatProjectionGeometry2D.cpp
@@ -30,7 +30,6 @@ $Id$
#include <cstring>
#include <sstream>
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -136,13 +135,13 @@ bool CFanFlatProjectionGeometry2D::initialize(const Config& _cfg)
// Required: DistanceOriginDetector
XMLNode node = _cfg.self.getSingleNode("DistanceOriginDetector");
ASTRA_CONFIG_CHECK(node, "FanFlatProjectionGeometry2D", "No DistanceOriginDetector tag specified.");
- m_fOriginDetectorDistance = boost::lexical_cast<float32>(node.getContent());
+ m_fOriginDetectorDistance = node.getContentNumerical();
CC.markNodeParsed("DistanceOriginDetector");
// Required: DetectorOriginSource
node = _cfg.self.getSingleNode("DistanceOriginSource");
ASTRA_CONFIG_CHECK(node, "FanFlatProjectionGeometry2D", "No DistanceOriginSource tag specified.");
- m_fOriginSourceDistance = boost::lexical_cast<float32>(node.getContent());
+ m_fOriginSourceDistance = node.getContentNumerical();
CC.markNodeParsed("DistanceOriginSource");
// success
diff --git a/src/FanFlatVecProjectionGeometry2D.cpp b/src/FanFlatVecProjectionGeometry2D.cpp
index 4104379..0b76fc5 100644
--- a/src/FanFlatVecProjectionGeometry2D.cpp
+++ b/src/FanFlatVecProjectionGeometry2D.cpp
@@ -30,7 +30,6 @@ $Id$
#include <cstring>
#include <sstream>
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -125,7 +124,7 @@ bool CFanFlatVecProjectionGeometry2D::initialize(const Config& _cfg)
// Required: DetectorCount
node = _cfg.self.getSingleNode("DetectorCount");
ASTRA_CONFIG_CHECK(node, "FanFlatVecProjectionGeometry3D", "No DetectorRowCount tag specified.");
- m_iDetectorCount = boost::lexical_cast<int>(node.getContent());
+ m_iDetectorCount = node.getContentInt();
CC.markNodeParsed("DetectorCount");
// Required: Vectors
@@ -235,12 +234,12 @@ Config* CFanFlatVecProjectionGeometry2D::getConfiguration() const
std::string vectors = "";
for (int i = 0; i < m_iProjectionAngleCount; ++i) {
SFanProjection& p = m_pProjectionAngles[i];
- vectors += boost::lexical_cast<string>(p.fSrcX) + ",";
- vectors += boost::lexical_cast<string>(p.fSrcY) + ",";
- vectors += boost::lexical_cast<string>(p.fDetSX + 0.5f * m_iDetectorCount * p.fDetUX) + ",";
- vectors += boost::lexical_cast<string>(p.fDetSY + 0.5f * m_iDetectorCount * p.fDetUY) + ",";
- vectors += boost::lexical_cast<string>(p.fDetUX) + ",";
- vectors += boost::lexical_cast<string>(p.fDetUY);
+ vectors += StringUtil::toString(p.fSrcX) + ",";
+ vectors += StringUtil::toString(p.fSrcY) + ",";
+ vectors += StringUtil::toString(p.fDetSX + 0.5f * m_iDetectorCount * p.fDetUX) + ",";
+ vectors += StringUtil::toString(p.fDetSY + 0.5f * m_iDetectorCount * p.fDetUY) + ",";
+ vectors += StringUtil::toString(p.fDetUX) + ",";
+ vectors += StringUtil::toString(p.fDetUY);
if (i < m_iProjectionAngleCount-1) vectors += ';';
}
cfg->self.addChildNode("Vectors", vectors);
diff --git a/src/FilteredBackProjectionAlgorithm.cpp b/src/FilteredBackProjectionAlgorithm.cpp
index f494d22..c195578 100644
--- a/src/FilteredBackProjectionAlgorithm.cpp
+++ b/src/FilteredBackProjectionAlgorithm.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/FilteredBackProjectionAlgorithm.h"
-#include <boost/lexical_cast.hpp>
-
#include <iostream>
#include <iomanip>
#include <math.h>
@@ -96,19 +94,19 @@ bool CFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
// projector
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 = node.getContentInt();
m_pProjector = CProjector2DManager::getSingleton().get(id);
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "FilteredBackProjection", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
// volume data
node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "FilteredBackProjection", "No ReconstructionDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pReconstruction = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
node = _cfg.self.getSingleNode("ProjectionIndex");
diff --git a/src/ForwardProjectionAlgorithm.cpp b/src/ForwardProjectionAlgorithm.cpp
index f356824..dcf5790 100644
--- a/src/ForwardProjectionAlgorithm.cpp
+++ b/src/ForwardProjectionAlgorithm.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/ForwardProjectionAlgorithm.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/DataProjectorPolicies.h"
@@ -128,32 +126,32 @@ bool CForwardProjectionAlgorithm::initialize(const Config& _cfg)
// projector
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 = node.getContentInt();
m_pProjector = CProjector2DManager::getSingleton().get(id);
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "ForwardProjection", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
// volume data
node = _cfg.self.getSingleNode("VolumeDataId");
ASTRA_CONFIG_CHECK(node, "ForwardProjection", "No VolumeDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pVolume = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
// volume mask
if (_cfg.self.hasOption("VolumeMaskId")) {
m_bUseVolumeMask = true;
- id = boost::lexical_cast<int>(_cfg.self.getOption("VolumeMaskId"));
+ id = _cfg.self.getOptionInt("VolumeMaskId");
m_pVolumeMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
}
// sino mask
if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = boost::lexical_cast<int>(_cfg.self.getOption("SinogramMaskId"));
+ id = _cfg.self.getOptionInt("SinogramMaskId");
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
}
diff --git a/src/ParallelBeamBlobKernelProjector2D.cpp b/src/ParallelBeamBlobKernelProjector2D.cpp
index 4559a48..679d5c6 100644
--- a/src/ParallelBeamBlobKernelProjector2D.cpp
+++ b/src/ParallelBeamBlobKernelProjector2D.cpp
@@ -29,7 +29,6 @@ $Id$
#include "astra/ParallelBeamBlobKernelProjector2D.h"
#include <cmath>
-#include <boost/lexical_cast.hpp>
#include "astra/DataProjectorPolicies.h"
@@ -134,17 +133,17 @@ bool CParallelBeamBlobKernelProjector2D::initialize(const Config& _cfg)
// Required: 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 = node2.getContentNumerical();
// Required: 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 = node2.getContentNumerical();
// Required: 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 = node2.getContentInt();
// Required: KernelValues
node2 = node.getSingleNode("KernelValues");
diff --git a/src/ParallelBeamLineKernelProjector2D.cpp b/src/ParallelBeamLineKernelProjector2D.cpp
index 5a23413..e4a1bff 100644
--- a/src/ParallelBeamLineKernelProjector2D.cpp
+++ b/src/ParallelBeamLineKernelProjector2D.cpp
@@ -29,7 +29,6 @@ $Id$
#include "astra/ParallelBeamLineKernelProjector2D.h"
#include <cmath>
-#include <boost/lexical_cast.hpp>
#include "astra/DataProjectorPolicies.h"
diff --git a/src/ParallelBeamLinearKernelProjector2D.cpp b/src/ParallelBeamLinearKernelProjector2D.cpp
index a710664..27aa168 100644
--- a/src/ParallelBeamLinearKernelProjector2D.cpp
+++ b/src/ParallelBeamLinearKernelProjector2D.cpp
@@ -29,7 +29,6 @@ $Id$
#include "astra/ParallelBeamLinearKernelProjector2D.h"
#include <cmath>
-#include <boost/lexical_cast.hpp>
#include "astra/DataProjectorPolicies.h"
diff --git a/src/ParallelBeamStripKernelProjector2D.cpp b/src/ParallelBeamStripKernelProjector2D.cpp
index 44c6fec..3f4e7f3 100644
--- a/src/ParallelBeamStripKernelProjector2D.cpp
+++ b/src/ParallelBeamStripKernelProjector2D.cpp
@@ -29,7 +29,6 @@ $Id$
#include "astra/ParallelBeamStripKernelProjector2D.h"
#include <cmath>
-#include <boost/lexical_cast.hpp>
#include "astra/DataProjectorPolicies.h"
diff --git a/src/ParallelProjectionGeometry2D.cpp b/src/ParallelProjectionGeometry2D.cpp
index 7260b83..cc2a129 100644
--- a/src/ParallelProjectionGeometry2D.cpp
+++ b/src/ParallelProjectionGeometry2D.cpp
@@ -27,7 +27,6 @@ $Id$
*/
#include "astra/ParallelProjectionGeometry2D.h"
-#include <boost/lexical_cast.hpp>
#include <cstring>
diff --git a/src/ParallelProjectionGeometry3D.cpp b/src/ParallelProjectionGeometry3D.cpp
index 7b64fd9..2f80883 100644
--- a/src/ParallelProjectionGeometry3D.cpp
+++ b/src/ParallelProjectionGeometry3D.cpp
@@ -30,7 +30,6 @@ $Id$
#include "astra/GeometryUtil3D.h"
-#include <boost/lexical_cast.hpp>
#include <cstring>
using namespace std;
diff --git a/src/ParallelVecProjectionGeometry3D.cpp b/src/ParallelVecProjectionGeometry3D.cpp
index d04400b..3172818 100644
--- a/src/ParallelVecProjectionGeometry3D.cpp
+++ b/src/ParallelVecProjectionGeometry3D.cpp
@@ -27,9 +27,9 @@ $Id$
*/
#include "astra/ParallelVecProjectionGeometry3D.h"
+#include "astra/Utilities.h"
#include <cstring>
-#include <boost/lexical_cast.hpp>
using namespace std;
@@ -82,13 +82,13 @@ bool CParallelVecProjectionGeometry3D::initialize(const Config& _cfg)
// Required: DetectorRowCount
node = _cfg.self.getSingleNode("DetectorRowCount");
ASTRA_CONFIG_CHECK(node, "ParallelVecProjectionGeometry3D", "No DetectorRowCount tag specified.");
- m_iDetectorRowCount = boost::lexical_cast<int>(node.getContent());
+ m_iDetectorRowCount = node.getContentInt();
CC.markNodeParsed("DetectorRowCount");
// Required: DetectorCount
node = _cfg.self.getSingleNode("DetectorColCount");
ASTRA_CONFIG_CHECK(node, "", "No DetectorColCount tag specified.");
- m_iDetectorColCount = boost::lexical_cast<int>(node.getContent());
+ m_iDetectorColCount = node.getContentInt();
m_iDetectorTotCount = m_iDetectorRowCount * m_iDetectorColCount;
CC.markNodeParsed("DetectorColCount");
@@ -212,18 +212,18 @@ Config* CParallelVecProjectionGeometry3D::getConfiguration() const
std::string vectors = "";
for (int i = 0; i < m_iProjectionAngleCount; ++i) {
SPar3DProjection& p = m_pProjectionAngles[i];
- vectors += boost::lexical_cast<string>(p.fRayX) + ",";
- vectors += boost::lexical_cast<string>(p.fRayY) + ",";
- vectors += boost::lexical_cast<string>(p.fRayZ) + ",";
- vectors += boost::lexical_cast<string>(p.fDetSX + 0.5f*m_iDetectorRowCount*p.fDetVX + 0.5f*m_iDetectorColCount*p.fDetUX) + ",";
- vectors += boost::lexical_cast<string>(p.fDetSY + 0.5f*m_iDetectorRowCount*p.fDetVY + 0.5f*m_iDetectorColCount*p.fDetUY) + ",";
- vectors += boost::lexical_cast<string>(p.fDetSZ + 0.5f*m_iDetectorRowCount*p.fDetVZ + 0.5f*m_iDetectorColCount*p.fDetUZ) + ",";
- vectors += boost::lexical_cast<string>(p.fDetUX) + ",";
- vectors += boost::lexical_cast<string>(p.fDetUY) + ",";
- vectors += boost::lexical_cast<string>(p.fDetUZ) + ",";
- vectors += boost::lexical_cast<string>(p.fDetVX) + ",";
- vectors += boost::lexical_cast<string>(p.fDetVY) + ",";
- vectors += boost::lexical_cast<string>(p.fDetVZ);
+ vectors += StringUtil::toString(p.fRayX) + ",";
+ vectors += StringUtil::toString(p.fRayY) + ",";
+ vectors += StringUtil::toString(p.fRayZ) + ",";
+ vectors += StringUtil::toString(p.fDetSX + 0.5f*m_iDetectorRowCount*p.fDetVX + 0.5f*m_iDetectorColCount*p.fDetUX) + ",";
+ vectors += StringUtil::toString(p.fDetSY + 0.5f*m_iDetectorRowCount*p.fDetVY + 0.5f*m_iDetectorColCount*p.fDetUY) + ",";
+ vectors += StringUtil::toString(p.fDetSZ + 0.5f*m_iDetectorRowCount*p.fDetVZ + 0.5f*m_iDetectorColCount*p.fDetUZ) + ",";
+ vectors += StringUtil::toString(p.fDetUX) + ",";
+ vectors += StringUtil::toString(p.fDetUY) + ",";
+ vectors += StringUtil::toString(p.fDetUZ) + ",";
+ vectors += StringUtil::toString(p.fDetVX) + ",";
+ vectors += StringUtil::toString(p.fDetVY) + ",";
+ vectors += StringUtil::toString(p.fDetVZ);
if (i < m_iProjectionAngleCount-1) vectors += ';';
}
cfg->self.addChildNode("Vectors", vectors);
diff --git a/src/PluginAlgorithm.cpp b/src/PluginAlgorithm.cpp
index 8f7dfc5..9fc511a 100644
--- a/src/PluginAlgorithm.cpp
+++ b/src/PluginAlgorithm.cpp
@@ -30,9 +30,9 @@ $Id$
#include "astra/PluginAlgorithm.h"
#include "astra/Logging.h"
+#include "astra/Utilities.h"
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
-#include <boost/lexical_cast.hpp>
#include <iostream>
#include <fstream>
#include <string>
@@ -338,7 +338,7 @@ PyObject* stringToPythonValue(std::string str){
boost::split(row, rows[i], boost::is_any_of(","));
PyObject *rowlist = PyList_New(row.size());
for(unsigned int j=0;j<row.size();j++){
- PyList_SetItem(rowlist, j, PyFloat_FromDouble(boost::lexical_cast<double>(row[j])));
+ PyList_SetItem(rowlist, j, PyFloat_FromDouble(StringUtil::stringToDouble(row[j])));
}
PyList_SetItem(mat, i, rowlist);
}
@@ -349,16 +349,16 @@ PyObject* stringToPythonValue(std::string str){
boost::split(vec, str, boost::is_any_of(","));
PyObject *veclist = PyList_New(vec.size());
for(unsigned int i=0;i<vec.size();i++){
- PyList_SetItem(veclist, i, PyFloat_FromDouble(boost::lexical_cast<double>(vec[i])));
+ PyList_SetItem(veclist, i, PyFloat_FromDouble(StringUtil::stringToDouble(vec[i])));
}
return veclist;
}
try{
- return PyLong_FromLong(boost::lexical_cast<long>(str));
- }catch(const boost::bad_lexical_cast &){
+ return PyLong_FromLong(StringUtil::stringToInt(str));
+ }catch(const StringUtil::bad_cast &){
try{
- return PyFloat_FromDouble(boost::lexical_cast<double>(str));
- }catch(const boost::bad_lexical_cast &){
+ return PyFloat_FromDouble(StringUtil::stringToDouble(str));
+ }catch(const StringUtil::bad_cast &){
return pyStringFromString(str);
}
}
diff --git a/src/ProjectionGeometry2D.cpp b/src/ProjectionGeometry2D.cpp
index b89605b..8ce06dc 100644
--- a/src/ProjectionGeometry2D.cpp
+++ b/src/ProjectionGeometry2D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/ProjectionGeometry2D.h"
-#include <boost/lexical_cast.hpp>
-
using namespace std;
namespace astra
@@ -126,13 +124,13 @@ bool CProjectionGeometry2D::initialize(const Config& _cfg)
// Required: DetectorWidth
XMLNode node = _cfg.self.getSingleNode("DetectorWidth");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry2D", "No DetectorWidth tag specified.");
- m_fDetectorWidth = boost::lexical_cast<float32>(node.getContent());
+ m_fDetectorWidth = node.getContentNumerical();
CC.markNodeParsed("DetectorWidth");
// Required: DetectorCount
node = _cfg.self.getSingleNode("DetectorCount");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry2D", "No DetectorCount tag specified.");
- m_iDetectorCount = boost::lexical_cast<int>(node.getContent());
+ m_iDetectorCount = node.getContentInt();
CC.markNodeParsed("DetectorCount");
// Required: ProjectionAngles
diff --git a/src/ProjectionGeometry3D.cpp b/src/ProjectionGeometry3D.cpp
index ef0246c..281db7c 100644
--- a/src/ProjectionGeometry3D.cpp
+++ b/src/ProjectionGeometry3D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/ProjectionGeometry3D.h"
-#include <boost/lexical_cast.hpp>
-
using namespace std;
namespace astra
@@ -151,25 +149,25 @@ bool CProjectionGeometry3D::initialize(const Config& _cfg)
// Required: DetectorWidth
XMLNode node = _cfg.self.getSingleNode("DetectorSpacingX");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry3D", "No DetectorSpacingX tag specified.");
- m_fDetectorSpacingX = boost::lexical_cast<float32>(node.getContent());
+ m_fDetectorSpacingX = node.getContentNumerical();
CC.markNodeParsed("DetectorSpacingX");
// Required: DetectorHeight
node = _cfg.self.getSingleNode("DetectorSpacingY");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry3D", "No DetectorSpacingY tag specified.");
- m_fDetectorSpacingY = boost::lexical_cast<float32>(node.getContent());
+ m_fDetectorSpacingY = node.getContentNumerical();
CC.markNodeParsed("DetectorSpacingY");
// Required: DetectorRowCount
node = _cfg.self.getSingleNode("DetectorRowCount");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry3D", "No DetectorRowCount tag specified.");
- m_iDetectorRowCount = boost::lexical_cast<int>(node.getContent());
+ m_iDetectorRowCount = node.getContentInt();
CC.markNodeParsed("DetectorRowCount");
// Required: DetectorCount
node = _cfg.self.getSingleNode("DetectorColCount");
ASTRA_CONFIG_CHECK(node, "ProjectionGeometry3D", "No DetectorColCount tag specified.");
- m_iDetectorColCount = boost::lexical_cast<int>(node.getContent());
+ m_iDetectorColCount = node.getContentInt();
m_iDetectorTotCount = m_iDetectorRowCount * m_iDetectorColCount;
CC.markNodeParsed("DetectorColCount");
diff --git a/src/ReconstructionAlgorithm2D.cpp b/src/ReconstructionAlgorithm2D.cpp
index 4575ff7..1c6d855 100644
--- a/src/ReconstructionAlgorithm2D.cpp
+++ b/src/ReconstructionAlgorithm2D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/ReconstructionAlgorithm2D.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
using namespace std;
@@ -90,7 +88,7 @@ bool CReconstructionAlgorithm2D::initialize(const Config& _cfg)
}
int id;
if (node) {
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pProjector = CProjector2DManager::getSingleton().get(id);
} else {
m_pProjector = 0;
@@ -100,21 +98,21 @@ bool CReconstructionAlgorithm2D::initialize(const Config& _cfg)
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction2D", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction2D", "No ReconstructionDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pReconstruction = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
CC.markNodeParsed("ReconstructionDataId");
// fixed mask
if (_cfg.self.hasOption("ReconstructionMaskId")) {
m_bUseReconstructionMask = true;
- id = boost::lexical_cast<int>(_cfg.self.getOption("ReconstructionMaskId"));
+ id = _cfg.self.getOptionInt("ReconstructionMaskId");
m_pReconstructionMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
ASTRA_CONFIG_CHECK(m_pReconstructionMask, "Reconstruction2D", "Invalid ReconstructionMaskId.");
}
@@ -123,7 +121,7 @@ bool CReconstructionAlgorithm2D::initialize(const Config& _cfg)
// fixed mask
if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = boost::lexical_cast<int>(_cfg.self.getOption("SinogramMaskId"));
+ id = _cfg.self.getOptionInt("SinogramMaskId");
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
ASTRA_CONFIG_CHECK(m_pSinogramMask, "Reconstruction2D", "Invalid SinogramMaskId.");
}
diff --git a/src/ReconstructionAlgorithm3D.cpp b/src/ReconstructionAlgorithm3D.cpp
index 13d4b07..55f1031 100644
--- a/src/ReconstructionAlgorithm3D.cpp
+++ b/src/ReconstructionAlgorithm3D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/ReconstructionAlgorithm3D.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
using namespace std;
@@ -111,7 +109,7 @@ bool CReconstructionAlgorithm3D::initialize(const Config& _cfg)
node = _cfg.self.getSingleNode("ProjectorId");
m_pProjector = 0;
if (node) {
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pProjector = CProjector3DManager::getSingleton().get(id);
if (!m_pProjector) {
// TODO: Report
@@ -122,21 +120,21 @@ bool CReconstructionAlgorithm3D::initialize(const Config& _cfg)
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction3D", "No ProjectionDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pSinogram = dynamic_cast<CFloat32ProjectionData3D*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("ProjectionDataId");
// reconstruction data
node = _cfg.self.getSingleNode("ReconstructionDataId");
ASTRA_CONFIG_CHECK(node, "Reconstruction3D", "No ReconstructionDataId tag specified.");
- id = boost::lexical_cast<int>(node.getContent());
+ id = node.getContentInt();
m_pReconstruction = dynamic_cast<CFloat32VolumeData3D*>(CData3DManager::getSingleton().get(id));
CC.markNodeParsed("ReconstructionDataId");
// fixed mask
if (_cfg.self.hasOption("ReconstructionMaskId")) {
m_bUseReconstructionMask = true;
- id = boost::lexical_cast<int>(_cfg.self.getOption("ReconstructionMaskId"));
+ id = _cfg.self.getOptionInt("ReconstructionMaskId");
m_pReconstructionMask = dynamic_cast<CFloat32VolumeData3D*>(CData3DManager::getSingleton().get(id));
}
CC.markOptionParsed("ReconstructionMaskId");
@@ -144,7 +142,7 @@ bool CReconstructionAlgorithm3D::initialize(const Config& _cfg)
// fixed mask
if (_cfg.self.hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = boost::lexical_cast<int>(_cfg.self.getOption("SinogramMaskId"));
+ id = _cfg.self.getOptionInt("SinogramMaskId");
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData3D*>(CData3DManager::getSingleton().get(id));
}
CC.markOptionParsed("SinogramMaskId");
diff --git a/src/ReconstructionAlgorithmMultiSlice2D.cpp b/src/ReconstructionAlgorithmMultiSlice2D.cpp
index fe64c86..39c337f 100644
--- a/src/ReconstructionAlgorithmMultiSlice2D.cpp
+++ b/src/ReconstructionAlgorithmMultiSlice2D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/ReconstructionAlgorithmMultiSlice2D.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
using namespace std;
@@ -96,7 +94,7 @@ bool CReconstructionAlgorithmMultiSlice2D::initialize(const Config& _cfg)
// projector
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 = node->getContentInt();
m_pProjector = CProjector2DManager::getSingleton().get(id);
ASTRA_DELETE(node);
CC.markNodeParsed("ProjectorId");
@@ -125,7 +123,7 @@ bool CReconstructionAlgorithmMultiSlice2D::initialize(const Config& _cfg)
// reconstruction masks
if (_cfg.self->hasOption("ReconstructionMaskId")) {
m_bUseReconstructionMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("ReconstructionMaskId"));
+ id = _cfg.self->getOptionInt("ReconstructionMaskId");
m_pReconstructionMask = dynamic_cast<CFloat32VolumeData2D*>(CData2DManager::getSingleton().get(id));
}
CC.markOptionParsed("ReconstructionMaskId");
@@ -133,7 +131,7 @@ bool CReconstructionAlgorithmMultiSlice2D::initialize(const Config& _cfg)
// sinogram masks
if (_cfg.self->hasOption("SinogramMaskId")) {
m_bUseSinogramMask = true;
- id = boost::lexical_cast<int>(_cfg.self->getOption("SinogramMaskId"));
+ id = _cfg.self->getOptionInt("SinogramMaskId");
m_pSinogramMask = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
}
CC.markOptionParsed("SinogramMaskId");
diff --git a/src/SartAlgorithm.cpp b/src/SartAlgorithm.cpp
index e4dc5c7..9346160 100644
--- a/src/SartAlgorithm.cpp
+++ b/src/SartAlgorithm.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/SartAlgorithm.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/DataProjectorPolicies.h"
diff --git a/src/SirtAlgorithm.cpp b/src/SirtAlgorithm.cpp
index ae3b3bc..d9f3a65 100644
--- a/src/SirtAlgorithm.cpp
+++ b/src/SirtAlgorithm.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/SirtAlgorithm.h"
-#include <boost/lexical_cast.hpp>
-
#include "astra/AstraObjectManager.h"
#include "astra/DataProjectorPolicies.h"
diff --git a/src/SparseMatrixProjectionGeometry2D.cpp b/src/SparseMatrixProjectionGeometry2D.cpp
index 073720f..358c992 100644
--- a/src/SparseMatrixProjectionGeometry2D.cpp
+++ b/src/SparseMatrixProjectionGeometry2D.cpp
@@ -28,7 +28,6 @@ $Id$
#include "astra/SparseMatrixProjectionGeometry2D.h"
-#include <boost/lexical_cast.hpp>
#include "astra/AstraObjectManager.h"
@@ -100,7 +99,7 @@ bool CSparseMatrixProjectionGeometry2D::initialize(const Config& _cfg)
// get matrix
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 = node.getContentInt();
m_pMatrix = CMatrixManager::getSingleton().get(id);
CC.markNodeParsed("MatrixID");
diff --git a/src/SparseMatrixProjector2D.cpp b/src/SparseMatrixProjector2D.cpp
index bc2e974..be7e069 100644
--- a/src/SparseMatrixProjector2D.cpp
+++ b/src/SparseMatrixProjector2D.cpp
@@ -29,7 +29,6 @@ $Id$
#include "astra/SparseMatrixProjector2D.h"
#include <cmath>
-#include <boost/lexical_cast.hpp>
#include "astra/DataProjectorPolicies.h"
diff --git a/src/Utilities.cpp b/src/Utilities.cpp
index cb54e93..4b80503 100644
--- a/src/Utilities.cpp
+++ b/src/Utilities.cpp
@@ -28,4 +28,99 @@ $Id$
#include "astra/Utilities.h"
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string/classification.hpp>
+#include <sstream>
+#include <locale>
+#include <iomanip>
+
+namespace astra {
+
+namespace StringUtil {
+
+int stringToInt(const std::string& s)
+{
+ double i;
+ std::istringstream iss(s);
+ iss.imbue(std::locale::classic());
+ iss >> i;
+ if (iss.fail() || !iss.eof())
+ throw bad_cast();
+ return i;
+
+}
+
+float stringToFloat(const std::string& s)
+{
+ return (float)stringToDouble(s);
+}
+
+double stringToDouble(const std::string& s)
+{
+ double f;
+ std::istringstream iss(s);
+ iss.imbue(std::locale::classic());
+ iss >> f;
+ if (iss.fail() || !iss.eof())
+ throw bad_cast();
+ return f;
+}
+
+template<> float stringTo(const std::string& s) { return stringToFloat(s); }
+template<> double stringTo(const std::string& s) { return stringToDouble(s); }
+
+std::vector<float> stringToFloatVector(const std::string &s)
+{
+ return stringToVector<float>(s);
+}
+
+std::vector<double> stringToDoubleVector(const std::string &s)
+{
+ return stringToVector<double>(s);
+}
+
+template<typename T>
+std::vector<T> stringToVector(const std::string& s)
+{
+ // split
+ std::vector<std::string> items;
+ boost::split(items, s, boost::is_any_of(",;"));
+
+ // init list
+ std::vector<T> out;
+ out.resize(items.size());
+
+ // loop elements
+ for (unsigned int i = 0; i < items.size(); i++) {
+ out[i] = stringTo<T>(items[i]);
+ }
+ return out;
+}
+
+
+std::string floatToString(float f)
+{
+ std::ostringstream s;
+ s.imbue(std::locale::classic());
+ s << std::setprecision(9) << f;
+ return s.str();
+}
+
+std::string doubleToString(double f)
+{
+ std::ostringstream s;
+ s.imbue(std::locale::classic());
+ s << std::setprecision(17) << f;
+ return s.str();
+}
+
+
+template<> std::string toString(float f) { return floatToString(f); }
+template<> std::string toString(double f) { return doubleToString(f); }
+
+
+}
+
+}
diff --git a/src/VolumeGeometry2D.cpp b/src/VolumeGeometry2D.cpp
index 6eea1b2..9d74e47 100644
--- a/src/VolumeGeometry2D.cpp
+++ b/src/VolumeGeometry2D.cpp
@@ -28,7 +28,6 @@ $Id$
#include "astra/VolumeGeometry2D.h"
-#include <boost/lexical_cast.hpp>
#include <cmath>
namespace astra
@@ -166,13 +165,13 @@ bool CVolumeGeometry2D::initialize(const Config& _cfg)
// Required: GridColCount
XMLNode node = _cfg.self.getSingleNode("GridColCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridColCount tag specified.");
- m_iGridColCount = boost::lexical_cast<int>(node.getContent());
+ m_iGridColCount = node.getContentInt();
CC.markNodeParsed("GridColCount");
// Required: GridRowCount
node = _cfg.self.getSingleNode("GridRowCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridRowCount tag specified.");
- m_iGridRowCount = boost::lexical_cast<int>(node.getContent());
+ m_iGridRowCount = node.getContentInt();
CC.markNodeParsed("GridRowCount");
// Optional: Window minima and maxima
diff --git a/src/VolumeGeometry3D.cpp b/src/VolumeGeometry3D.cpp
index 3de146f..5d72c24 100644
--- a/src/VolumeGeometry3D.cpp
+++ b/src/VolumeGeometry3D.cpp
@@ -28,8 +28,6 @@ $Id$
#include "astra/VolumeGeometry3D.h"
-#include <boost/lexical_cast.hpp>
-
namespace astra
{
@@ -196,19 +194,19 @@ bool CVolumeGeometry3D::initialize(const Config& _cfg)
// Required: GridColCount
XMLNode node = _cfg.self.getSingleNode("GridColCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridColCount tag specified.");
- m_iGridColCount = boost::lexical_cast<int>(node.getContent());
+ m_iGridColCount = node.getContentInt();
CC.markNodeParsed("GridColCount");
// Required: GridRowCount
node = _cfg.self.getSingleNode("GridRowCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridRowCount tag specified.");
- m_iGridRowCount = boost::lexical_cast<int>(node.getContent());
+ m_iGridRowCount = node.getContentInt();
CC.markNodeParsed("GridRowCount");
// Required: GridRowCount
node = _cfg.self.getSingleNode("GridSliceCount");
ASTRA_CONFIG_CHECK(node, "ReconstructionGeometry2D", "No GridSliceCount tag specified.");
- m_iGridSliceCount = boost::lexical_cast<int>(node.getContent());
+ m_iGridSliceCount = node.getContentInt();
CC.markNodeParsed("GridSliceCount");
// Optional: Window minima and maxima
diff --git a/src/XMLNode.cpp b/src/XMLNode.cpp
index 0ec701f..40a9b22 100644
--- a/src/XMLNode.cpp
+++ b/src/XMLNode.cpp
@@ -31,12 +31,6 @@ $Id$
#include "rapidxml/rapidxml.hpp"
#include "rapidxml/rapidxml_print.hpp"
-#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;
@@ -138,8 +132,13 @@ string XMLNode::getContent() const
// Get node content - NUMERICAL
float32 XMLNode::getContentNumerical() const
{
- return boost::lexical_cast<float32>(getContent());
+ return StringUtil::stringToFloat(getContent());
}
+int XMLNode::getContentInt() const
+{
+ return StringUtil::stringToInt(getContent());
+}
+
//-----------------------------------------------------------------------------
// Get node content - BOOLEAN
@@ -154,7 +153,7 @@ bool XMLNode::getContentBool() const
vector<string> XMLNode::getContentArray() const
{
// get listsize
- int iSize = boost::lexical_cast<int>(getAttribute("listsize"));
+ int iSize = StringUtil::stringToInt(getAttribute("listsize"));
// create result array
vector<string> res(iSize);
// loop all list item nodes
@@ -175,40 +174,12 @@ vector<string> XMLNode::getContentArray() const
// NB: A 2D matrix is returned as a linear list
vector<float32> XMLNode::getContentNumericalArray() const
{
- string input = getContent();
-
- // split
- std::vector<std::string> items;
- boost::split(items, input, boost::is_any_of(",;"));
-
- // init list
- vector<float32> out;
- out.resize(items.size());
-
- // loop elements
- for (unsigned int i = 0; i < items.size(); i++) {
- out[i] = boost::lexical_cast<float32>(items[i]);
- }
- return out;
+ return StringUtil::stringToFloatVector(getContent());
}
vector<double> XMLNode::getContentNumericalArrayDouble() const
{
- 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]);
- }
- return out;
+ return StringUtil::stringToDoubleVector(getContent());
}
//-----------------------------------------------------------------------------
@@ -235,14 +206,20 @@ string XMLNode::getAttribute(string _sName, string _sDefaultValue) const
float32 XMLNode::getAttributeNumerical(string _sName, float32 _fDefaultValue) const
{
if (!hasAttribute(_sName)) return _fDefaultValue;
- return boost::lexical_cast<float32>(getAttribute(_sName));
+ return StringUtil::stringToFloat(getAttribute(_sName));
}
double XMLNode::getAttributeNumericalDouble(string _sName, double _fDefaultValue) const
{
if (!hasAttribute(_sName)) return _fDefaultValue;
- return boost::lexical_cast<double>(getAttribute(_sName));
+ return StringUtil::stringToDouble(getAttribute(_sName));
+}
+int XMLNode::getAttributeInt(string _sName, int _iDefaultValue) const
+{
+ if (!hasAttribute(_sName)) return _iDefaultValue;
+ return StringUtil::stringToInt(getAttribute(_sName));
}
+
//-----------------------------------------------------------------------------
// Get attribute - BOOLEAN
bool XMLNode::getAttributeBool(string _sName, bool _bDefaultValue) const
@@ -287,9 +264,15 @@ string XMLNode::getOption(string _sKey, string _sDefaultValue) const
float32 XMLNode::getOptionNumerical(string _sKey, float32 _fDefaultValue) const
{
if (!hasOption(_sKey)) return _fDefaultValue;
- return boost::lexical_cast<float32>(getOption(_sKey));
+ return StringUtil::stringToFloat(getOption(_sKey));
+}
+int XMLNode::getOptionInt(string _sKey, int _iDefaultValue) const
+{
+ if (!hasOption(_sKey)) return _iDefaultValue;
+ return StringUtil::stringToInt(getOption(_sKey));
}
+
//-----------------------------------------------------------------------------
// Get option - BOOL
bool XMLNode::getOptionBool(string _sKey, bool _bDefaultValue) const
@@ -386,7 +369,7 @@ void XMLNode::setContent(string _sText)
// Set content - FLOAT
void XMLNode::setContent(float32 _fValue)
{
- setContent(boost::lexical_cast<string>(_fValue));
+ setContent(StringUtil::floatToString(_fValue));
}
//-----------------------------------------------------------------------------
@@ -394,9 +377,9 @@ void XMLNode::setContent(float32 _fValue)
template<typename T>
static std::string setContentList_internal(T* pfList, int _iSize) {
- std::string str = (_iSize > 0) ? boost::lexical_cast<std::string>(pfList[0]) : "";
+ std::string str = (_iSize > 0) ? StringUtil::toString(pfList[0]) : "";
for (int i = 1; i < _iSize; i++) {
- str += "," + boost::lexical_cast<std::string>(pfList[i]);
+ str += "," + StringUtil::toString(pfList[i]);
}
return str;
}
@@ -431,9 +414,9 @@ static std::string setContentMatrix_internal(T* _pfMatrix, int _iWidth, int _iHe
for (int y = 0; y < _iHeight; ++y) {
if (_iWidth > 0)
- str += boost::lexical_cast<std::string>(_pfMatrix[0*s1 + y*s2]);
+ str += StringUtil::toString(_pfMatrix[0*s1 + y*s2]);
for (int x = 1; x < _iWidth; x++)
- str += "," + boost::lexical_cast<std::string>(_pfMatrix[x*s1 + y*s2]);
+ str += "," + StringUtil::toString(_pfMatrix[x*s1 + y*s2]);
if (y != _iHeight-1)
str += ";";
@@ -468,7 +451,7 @@ void XMLNode::addAttribute(string _sName, string _sText)
// Add attribute - FLOAT
void XMLNode::addAttribute(string _sName, float32 _fValue)
{
- addAttribute(_sName, boost::lexical_cast<string>(_fValue));
+ addAttribute(_sName, StringUtil::floatToString(_fValue));
}
//-----------------------------------------------------------------------------