From fc86917da1a175c04e9bd2e5f0bedb0a48a81c26 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 17 Dec 2015 14:37:41 +0100 Subject: 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. --- src/ArtAlgorithm.cpp | 2 - src/BackProjectionAlgorithm.cpp | 2 - src/CglsAlgorithm.cpp | 2 - src/ConeProjectionGeometry3D.cpp | 5 +- src/ConeVecProjectionGeometry3D.cpp | 30 ++++----- src/CudaBackProjectionAlgorithm3D.cpp | 2 - src/CudaCglsAlgorithm3D.cpp | 2 - src/CudaDartMaskAlgorithm.cpp | 5 +- src/CudaDartMaskAlgorithm3D.cpp | 5 +- src/CudaDartSmoothingAlgorithm.cpp | 5 +- src/CudaDartSmoothingAlgorithm3D.cpp | 5 +- src/CudaDataOperationAlgorithm.cpp | 5 +- src/CudaFDKAlgorithm3D.cpp | 2 - src/CudaFilteredBackProjectionAlgorithm.cpp | 13 ++-- src/CudaForwardProjectionAlgorithm.cpp | 8 +-- src/CudaForwardProjectionAlgorithm3D.cpp | 8 +-- src/CudaReconstructionAlgorithm2D.cpp | 2 - src/CudaRoiSelectAlgorithm.cpp | 3 +- src/CudaSirtAlgorithm.cpp | 5 +- src/CudaSirtAlgorithm3D.cpp | 2 - src/FanFlatBeamLineKernelProjector2D.cpp | 1 - src/FanFlatBeamStripKernelProjector2D.cpp | 1 - src/FanFlatProjectionGeometry2D.cpp | 5 +- src/FanFlatVecProjectionGeometry2D.cpp | 15 +++-- src/FilteredBackProjectionAlgorithm.cpp | 8 +-- src/ForwardProjectionAlgorithm.cpp | 12 ++-- src/ParallelBeamBlobKernelProjector2D.cpp | 7 +-- src/ParallelBeamLineKernelProjector2D.cpp | 1 - src/ParallelBeamLinearKernelProjector2D.cpp | 1 - src/ParallelBeamStripKernelProjector2D.cpp | 1 - src/ParallelProjectionGeometry2D.cpp | 1 - src/ParallelProjectionGeometry3D.cpp | 1 - src/ParallelVecProjectionGeometry3D.cpp | 30 ++++----- src/PluginAlgorithm.cpp | 14 ++--- src/ProjectionGeometry2D.cpp | 6 +- src/ProjectionGeometry3D.cpp | 10 ++- src/ReconstructionAlgorithm2D.cpp | 12 ++-- src/ReconstructionAlgorithm3D.cpp | 12 ++-- src/ReconstructionAlgorithmMultiSlice2D.cpp | 8 +-- src/SartAlgorithm.cpp | 2 - src/SirtAlgorithm.cpp | 2 - src/SparseMatrixProjectionGeometry2D.cpp | 3 +- src/SparseMatrixProjector2D.cpp | 1 - src/Utilities.cpp | 95 +++++++++++++++++++++++++++++ src/VolumeGeometry2D.cpp | 5 +- src/VolumeGeometry3D.cpp | 8 +-- src/XMLNode.cpp | 77 +++++++++-------------- 47 files changed, 234 insertions(+), 218 deletions(-) (limited to 'src') 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 - #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 - #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 - #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 #include 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(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(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 -#include 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(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(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(p.fSrcX) + ","; - vectors += boost::lexical_cast(p.fSrcY) + ","; - vectors += boost::lexical_cast(p.fSrcZ) + ","; - vectors += boost::lexical_cast(p.fDetSX + 0.5f*m_iDetectorRowCount*p.fDetVX + 0.5f*m_iDetectorColCount*p.fDetUX) + ","; - vectors += boost::lexical_cast(p.fDetSY + 0.5f*m_iDetectorRowCount*p.fDetVY + 0.5f*m_iDetectorColCount*p.fDetUY) + ","; - vectors += boost::lexical_cast(p.fDetSZ + 0.5f*m_iDetectorRowCount*p.fDetVZ + 0.5f*m_iDetectorColCount*p.fDetUZ) + ","; - vectors += boost::lexical_cast(p.fDetUX) + ","; - vectors += boost::lexical_cast(p.fDetUY) + ","; - vectors += boost::lexical_cast(p.fDetUZ) + ","; - vectors += boost::lexical_cast(p.fDetVX) + ","; - vectors += boost::lexical_cast(p.fDetVY) + ","; - vectors += boost::lexical_cast(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 - #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 - #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 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(node.getContent()); + int id = node.getContentInt(); m_pSegmentation = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); m_pMask = dynamic_cast(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 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(node.getContent()); + int id = node.getContentInt(); m_pSegmentation = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); m_pMask = dynamic_cast(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 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(node.getContent()); + int id = node.getContentInt(); m_pIn = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); m_pOut = dynamic_cast(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 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(node.getContent()); + int id = node.getContentInt(); m_pIn = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); m_pOut = dynamic_cast(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 using namespace std; @@ -78,7 +77,7 @@ bool CCudaDataOperationAlgorithm::initialize(const Config& _cfg) ASTRA_CONFIG_CHECK(node, "CCudaDataOperationAlgorithm", "No DataId tag specified."); vector data = node.getContentArray(); for (vector::iterator it = data.begin(); it != data.end(); it++){ - int id = boost::lexical_cast(*it); + int id = StringUtil::stringToInt(*it); m_pData.push_back(dynamic_cast(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(_cfg.self.getOption("MaskId")); + int id = _cfg.self.getOptionInt("MaskId"); m_pMask = dynamic_cast(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 - #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 #include -#include #include #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(node.getContent()); + int id = node.getContentInt(); CProjector2D *projector = CProjector2DManager::getSingleton().get(id); pCudaProjector = dynamic_cast(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(node.getContent()); + int id = node.getContentInt(); m_pSinogram = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); m_pReconstruction = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); const CFloat32ProjectionData2D * pFilterData = dynamic_cast(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(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(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 #include -#include - #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(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(node.getContent()); + int id = node.getContentInt(); m_pSinogram = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); m_pVolume = dynamic_cast(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 - #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(node.getContent()); + id = node.getContentInt(); m_pProjections = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); m_pVolume = dynamic_cast(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(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 - #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 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(node.getContent()); + int id = node.getContentInt(); m_pData = dynamic_cast(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 #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(_cfg.self.getOption("MinMaskId")); + int id = _cfg.self.getOptionInt("MinMaskId"); m_pMinMask = dynamic_cast(CData2DManager::getSingleton().get(id)); } CC.markOptionParsed("MinMaskId"); if (_cfg.self.hasOption("MaxMaskId")) { - int id = boost::lexical_cast(_cfg.self.getOption("MaxMaskId")); + int id = _cfg.self.getOptionInt("MaxMaskId"); m_pMaxMask = dynamic_cast(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 - #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 #include -#include #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 -#include #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 #include -#include 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(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(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 #include -#include 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(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(p.fSrcX) + ","; - vectors += boost::lexical_cast(p.fSrcY) + ","; - vectors += boost::lexical_cast(p.fDetSX + 0.5f * m_iDetectorCount * p.fDetUX) + ","; - vectors += boost::lexical_cast(p.fDetSY + 0.5f * m_iDetectorCount * p.fDetUY) + ","; - vectors += boost::lexical_cast(p.fDetUX) + ","; - vectors += boost::lexical_cast(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 - #include #include #include @@ -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(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(node.getContent()); + id = node.getContentInt(); m_pSinogram = dynamic_cast(CData2DManager::getSingleton().get(id)); // volume data node = _cfg.self.getSingleNode("ReconstructionDataId"); ASTRA_CONFIG_CHECK(node, "FilteredBackProjection", "No ReconstructionDataId tag specified."); - id = boost::lexical_cast(node.getContent()); + id = node.getContentInt(); m_pReconstruction = dynamic_cast(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 - #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(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(node.getContent()); + id = node.getContentInt(); m_pSinogram = dynamic_cast(CData2DManager::getSingleton().get(id)); // volume data node = _cfg.self.getSingleNode("VolumeDataId"); ASTRA_CONFIG_CHECK(node, "ForwardProjection", "No VolumeDataId tag specified."); - id = boost::lexical_cast(node.getContent()); + id = node.getContentInt(); m_pVolume = dynamic_cast(CData2DManager::getSingleton().get(id)); // volume mask if (_cfg.self.hasOption("VolumeMaskId")) { m_bUseVolumeMask = true; - id = boost::lexical_cast(_cfg.self.getOption("VolumeMaskId")); + id = _cfg.self.getOptionInt("VolumeMaskId"); m_pVolumeMask = dynamic_cast(CData2DManager::getSingleton().get(id)); } // sino mask if (_cfg.self.hasOption("SinogramMaskId")) { m_bUseSinogramMask = true; - id = boost::lexical_cast(_cfg.self.getOption("SinogramMaskId")); + id = _cfg.self.getOptionInt("SinogramMaskId"); m_pSinogramMask = dynamic_cast(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 -#include #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(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(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(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 -#include #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 -#include #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 -#include #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 #include 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 #include 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 -#include 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(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(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(p.fRayX) + ","; - vectors += boost::lexical_cast(p.fRayY) + ","; - vectors += boost::lexical_cast(p.fRayZ) + ","; - vectors += boost::lexical_cast(p.fDetSX + 0.5f*m_iDetectorRowCount*p.fDetVX + 0.5f*m_iDetectorColCount*p.fDetUX) + ","; - vectors += boost::lexical_cast(p.fDetSY + 0.5f*m_iDetectorRowCount*p.fDetVY + 0.5f*m_iDetectorColCount*p.fDetUY) + ","; - vectors += boost::lexical_cast(p.fDetSZ + 0.5f*m_iDetectorRowCount*p.fDetVZ + 0.5f*m_iDetectorColCount*p.fDetUZ) + ","; - vectors += boost::lexical_cast(p.fDetUX) + ","; - vectors += boost::lexical_cast(p.fDetUY) + ","; - vectors += boost::lexical_cast(p.fDetUZ) + ","; - vectors += boost::lexical_cast(p.fDetVX) + ","; - vectors += boost::lexical_cast(p.fDetVY) + ","; - vectors += boost::lexical_cast(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 #include -#include #include #include #include @@ -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[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[i]))); + PyList_SetItem(veclist, i, PyFloat_FromDouble(StringUtil::stringToDouble(vec[i]))); } return veclist; } try{ - return PyLong_FromLong(boost::lexical_cast(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(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 - 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(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(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 - 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(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(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(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(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 - #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(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(node.getContent()); + id = node.getContentInt(); m_pSinogram = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); m_pReconstruction = dynamic_cast(CData2DManager::getSingleton().get(id)); CC.markNodeParsed("ReconstructionDataId"); // fixed mask if (_cfg.self.hasOption("ReconstructionMaskId")) { m_bUseReconstructionMask = true; - id = boost::lexical_cast(_cfg.self.getOption("ReconstructionMaskId")); + id = _cfg.self.getOptionInt("ReconstructionMaskId"); m_pReconstructionMask = dynamic_cast(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(_cfg.self.getOption("SinogramMaskId")); + id = _cfg.self.getOptionInt("SinogramMaskId"); m_pSinogramMask = dynamic_cast(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 - #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(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(node.getContent()); + id = node.getContentInt(); m_pSinogram = dynamic_cast(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(node.getContent()); + id = node.getContentInt(); m_pReconstruction = dynamic_cast(CData3DManager::getSingleton().get(id)); CC.markNodeParsed("ReconstructionDataId"); // fixed mask if (_cfg.self.hasOption("ReconstructionMaskId")) { m_bUseReconstructionMask = true; - id = boost::lexical_cast(_cfg.self.getOption("ReconstructionMaskId")); + id = _cfg.self.getOptionInt("ReconstructionMaskId"); m_pReconstructionMask = dynamic_cast(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(_cfg.self.getOption("SinogramMaskId")); + id = _cfg.self.getOptionInt("SinogramMaskId"); m_pSinogramMask = dynamic_cast(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 - #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(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(_cfg.self->getOption("ReconstructionMaskId")); + id = _cfg.self->getOptionInt("ReconstructionMaskId"); m_pReconstructionMask = dynamic_cast(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(_cfg.self->getOption("SinogramMaskId")); + id = _cfg.self->getOptionInt("SinogramMaskId"); m_pSinogramMask = dynamic_cast(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 - #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 - #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 #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(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 -#include #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 +#include +#include +#include +#include +#include + +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 stringToFloatVector(const std::string &s) +{ + return stringToVector(s); +} + +std::vector stringToDoubleVector(const std::string &s) +{ + return stringToVector(s); +} + +template +std::vector stringToVector(const std::string& s) +{ + // split + std::vector items; + boost::split(items, s, boost::is_any_of(",;")); + + // init list + std::vector out; + out.resize(items.size()); + + // loop elements + for (unsigned int i = 0; i < items.size(); i++) { + out[i] = stringTo(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 #include 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(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(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 - 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(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(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(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 -#include -#include -#include - - 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(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 XMLNode::getContentArray() const { // get listsize - int iSize = boost::lexical_cast(getAttribute("listsize")); + int iSize = StringUtil::stringToInt(getAttribute("listsize")); // create result array vector res(iSize); // loop all list item nodes @@ -175,40 +174,12 @@ vector XMLNode::getContentArray() const // NB: A 2D matrix is returned as a linear list vector XMLNode::getContentNumericalArray() const { - string input = getContent(); - - // split - std::vector items; - boost::split(items, input, boost::is_any_of(",;")); - - // init list - vector out; - out.resize(items.size()); - - // loop elements - for (unsigned int i = 0; i < items.size(); i++) { - out[i] = boost::lexical_cast(items[i]); - } - return out; + return StringUtil::stringToFloatVector(getContent()); } vector XMLNode::getContentNumericalArrayDouble() const { - string input = getContent(); - - // split - std::vector items; - boost::split(items, input, boost::is_any_of(",;")); - - // init list - vector out; - out.resize(items.size()); - - // loop elements - for (unsigned int i = 0; i < items.size(); i++) { - out[i] = boost::lexical_cast(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(getAttribute(_sName)); + return StringUtil::stringToFloat(getAttribute(_sName)); } double XMLNode::getAttributeNumericalDouble(string _sName, double _fDefaultValue) const { if (!hasAttribute(_sName)) return _fDefaultValue; - return boost::lexical_cast(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(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(_fValue)); + setContent(StringUtil::floatToString(_fValue)); } //----------------------------------------------------------------------------- @@ -394,9 +377,9 @@ void XMLNode::setContent(float32 _fValue) template static std::string setContentList_internal(T* pfList, int _iSize) { - std::string str = (_iSize > 0) ? boost::lexical_cast(pfList[0]) : ""; + std::string str = (_iSize > 0) ? StringUtil::toString(pfList[0]) : ""; for (int i = 1; i < _iSize; i++) { - str += "," + boost::lexical_cast(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(_pfMatrix[0*s1 + y*s2]); + str += StringUtil::toString(_pfMatrix[0*s1 + y*s2]); for (int x = 1; x < _iWidth; x++) - str += "," + boost::lexical_cast(_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(_fValue)); + addAttribute(_sName, StringUtil::floatToString(_fValue)); } //----------------------------------------------------------------------------- -- cgit v1.2.3