diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CompositeGeometryManager.cpp | 6 | ||||
-rw-r--r-- | src/CudaDartMaskAlgorithm.cpp | 1 | ||||
-rw-r--r-- | src/CudaDartSmoothingAlgorithm.cpp | 1 | ||||
-rw-r--r-- | src/CudaDataOperationAlgorithm.cpp | 1 | ||||
-rw-r--r-- | src/CudaRoiSelectAlgorithm.cpp | 1 | ||||
-rw-r--r-- | src/Float32Data3DMemory.cpp | 33 | ||||
-rw-r--r-- | src/Utilities.cpp | 35 | ||||
-rw-r--r-- | src/XMLNode.cpp | 24 | ||||
-rw-r--r-- | src/swrap.cpp | 46 |
9 files changed, 54 insertions, 94 deletions
diff --git a/src/CompositeGeometryManager.cpp b/src/CompositeGeometryManager.cpp index a4dace2..184144c 100644 --- a/src/CompositeGeometryManager.cpp +++ b/src/CompositeGeometryManager.cpp @@ -1386,6 +1386,12 @@ static bool doJob(const CCompositeGeometryManager::TJobSet::const_iterator& iter bool ok = dstMem->allocateGPUMemory(outx, outy, outz, zero ? astraCUDA3d::INIT_ZERO : astraCUDA3d::INIT_NO); if (!ok) ASTRA_ERROR("Error allocating GPU memory"); + if (!zero) { + // instead of zeroing output memory, copy from host + ok = dstMem->copyToGPUMemory(dstdims); + if (!ok) ASTRA_ERROR("Error copying output data to GPU"); + } + for (CCompositeGeometryManager::TJobList::const_iterator i = L.begin(); i != L.end(); ++i) { const CCompositeGeometryManager::SJob &j = *i; diff --git a/src/CudaDartMaskAlgorithm.cpp b/src/CudaDartMaskAlgorithm.cpp index 375d565..a2e1ee6 100644 --- a/src/CudaDartMaskAlgorithm.cpp +++ b/src/CudaDartMaskAlgorithm.cpp @@ -29,6 +29,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/CudaDartMaskAlgorithm.h" +#include "../cuda/2d/astra.h" #include "../cuda/2d/darthelper.h" #include "../cuda/2d/algo.h" diff --git a/src/CudaDartSmoothingAlgorithm.cpp b/src/CudaDartSmoothingAlgorithm.cpp index 0759ea0..9e586c0 100644 --- a/src/CudaDartSmoothingAlgorithm.cpp +++ b/src/CudaDartSmoothingAlgorithm.cpp @@ -29,6 +29,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/CudaDartSmoothingAlgorithm.h" +#include "../cuda/2d/astra.h" #include "../cuda/2d/darthelper.h" #include "../cuda/2d/algo.h" diff --git a/src/CudaDataOperationAlgorithm.cpp b/src/CudaDataOperationAlgorithm.cpp index f9466e2..6c6b27c 100644 --- a/src/CudaDataOperationAlgorithm.cpp +++ b/src/CudaDataOperationAlgorithm.cpp @@ -31,6 +31,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "../cuda/2d/algo.h" #include "../cuda/2d/darthelper.h" +#include "../cuda/2d/astra.h" #include "../cuda/2d/arith.h" #include "astra/AstraObjectManager.h" diff --git a/src/CudaRoiSelectAlgorithm.cpp b/src/CudaRoiSelectAlgorithm.cpp index baf8a6f..2b0ba15 100644 --- a/src/CudaRoiSelectAlgorithm.cpp +++ b/src/CudaRoiSelectAlgorithm.cpp @@ -29,6 +29,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "astra/CudaRoiSelectAlgorithm.h" +#include "../cuda/2d/astra.h" #include "../cuda/2d/darthelper.h" #include "../cuda/2d/algo.h" diff --git a/src/Float32Data3DMemory.cpp b/src/Float32Data3DMemory.cpp index 5c5c310..017625b 100644 --- a/src/Float32Data3DMemory.cpp +++ b/src/Float32Data3DMemory.cpp @@ -71,8 +71,6 @@ bool CFloat32Data3DMemory::_initialize(int _iWidth, int _iHeight, int _iDepth) // allocate memory for the data, but do not fill it m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; m_pCustomMemory = 0; _allocateData(); @@ -103,8 +101,6 @@ bool CFloat32Data3DMemory::_initialize(int _iWidth, int _iHeight, int _iDepth, c // allocate memory for the data, but do not fill it m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; m_pCustomMemory = 0; _allocateData(); @@ -140,8 +136,6 @@ bool CFloat32Data3DMemory::_initialize(int _iWidth, int _iHeight, int _iDepth, f // allocate memory for the data, but do not fill it m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; m_pCustomMemory = 0; _allocateData(); @@ -178,8 +172,6 @@ bool CFloat32Data3DMemory::_initialize(int _iWidth, int _iHeight, int _iDepth, C // allocate memory for the data, but do not fill it m_pCustomMemory = _pCustomMemory; m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; _allocateData(); // initialization complete @@ -198,8 +190,6 @@ void CFloat32Data3DMemory::_allocateData() ASTRA_ASSERT(m_iSize > 0); ASTRA_ASSERT(m_iSize == (size_t)m_iWidth * m_iHeight * m_iDepth); ASTRA_ASSERT(m_pfData == NULL); - ASTRA_ASSERT(m_ppfDataRowInd == NULL); - ASTRA_ASSERT(m_pppfDataSliceInd == NULL); if (!m_pCustomMemory) { // allocate contiguous block @@ -213,20 +203,6 @@ void CFloat32Data3DMemory::_allocateData() } else { m_pfData = m_pCustomMemory->m_fPtr; } - - // create array of pointers to each row of the data block - m_ppfDataRowInd = new float32*[m_iHeight*m_iDepth]; - for (int iy = 0; iy < m_iHeight*m_iDepth; iy++) - { - m_ppfDataRowInd[iy] = &(m_pfData[iy * m_iWidth]); - } - - // create array of pointers to each row of the data block - m_pppfDataSliceInd = new float32**[m_iDepth]; - for (int iy = 0; iy < m_iDepth; iy++) - { - m_pppfDataSliceInd[iy] = &(m_ppfDataRowInd[iy * m_iHeight]); - } } //---------------------------------------------------------------------------------------- @@ -235,13 +211,6 @@ void CFloat32Data3DMemory::_freeData() { // basic checks ASTRA_ASSERT(m_pfData != NULL); - ASTRA_ASSERT(m_ppfDataRowInd != NULL); - ASTRA_ASSERT(m_pppfDataSliceInd != NULL); - - // free memory for index table - delete[] m_pppfDataSliceInd; - // free memory for index table - delete[] m_ppfDataRowInd; if (!m_pCustomMemory) { // free memory for data block @@ -266,8 +235,6 @@ void CFloat32Data3DMemory::_clear() m_iSize = 0; m_pfData = NULL; - m_ppfDataRowInd = NULL; - m_pppfDataSliceInd = NULL; m_pCustomMemory = NULL; } diff --git a/src/Utilities.cpp b/src/Utilities.cpp index eb06d8b..2ae1b66 100644 --- a/src/Utilities.cpp +++ b/src/Utilities.cpp @@ -66,20 +66,44 @@ double stringToDouble(const std::string& s) 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) +template<typename T> +std::vector<T> stringToNumericVector(const std::string &s) { - return stringToVector<float>(s); + std::vector<T> out; + out.reserve(100); + std::istringstream iss; + iss.imbue(std::locale::classic()); + size_t length = s.size(); + size_t current = 0; + size_t next; + do { + next = s.find_first_of(",;", current); + std::string t = s.substr(current, next - current); + iss.str(t); + iss.clear(); + T f; + iss >> f; + out.push_back(f); + current = next + 1; + } while (next != std::string::npos && current != length); + + return out; } +std::vector<float> stringToFloatVector(const std::string &s) +{ + return stringToNumericVector<float>(s); +} std::vector<double> stringToDoubleVector(const std::string &s) { - return stringToVector<double>(s); + return stringToNumericVector<double>(s); } template<typename T> std::vector<T> stringToVector(const std::string& s) { std::vector<T> out; + size_t length = s.size(); size_t current = 0; size_t next; do { @@ -87,7 +111,7 @@ std::vector<T> stringToVector(const std::string& s) std::string t = s.substr(current, next - current); out.push_back(stringTo<T>(t)); current = next + 1; - } while (next != std::string::npos); + } while (next != std::string::npos && current != length); return out; } @@ -117,13 +141,14 @@ void splitString(std::vector<std::string> &items, const std::string& s, const char *delim) { items.clear(); + size_t length = s.size(); size_t current = 0; size_t next; do { next = s.find_first_of(delim, current); items.push_back(s.substr(current, next - current)); current = next + 1; - } while (next != std::string::npos); + } while (next != std::string::npos && current != length); } } diff --git a/src/XMLNode.cpp b/src/XMLNode.cpp index 3b7237f..2bf1330 100644 --- a/src/XMLNode.cpp +++ b/src/XMLNode.cpp @@ -30,6 +30,9 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. #include "rapidxml/rapidxml.hpp" #include "rapidxml/rapidxml_print.hpp" +#include <sstream> +#include <iomanip> + using namespace rapidxml; using namespace astra; @@ -376,9 +379,9 @@ void XMLNode::setContent(float32 _fValue) template<typename T> static std::string setContentList_internal(T* pfList, int _iSize) { - std::string str = (_iSize > 0) ? StringUtil::toString(pfList[0]) : ""; - for (int i = 1; i < _iSize; i++) { - str += "," + StringUtil::toString(pfList[i]); + std::string str; + for (int i = 0; i < _iSize; i++) { + str += StringUtil::toString(pfList[i]) + ","; } return str; } @@ -399,8 +402,6 @@ void XMLNode::setContent(double* pfList, int _iSize) template<typename T> static std::string setContentMatrix_internal(T* _pfMatrix, int _iWidth, int _iHeight, bool transposed) { - std::string str = ""; - int s1,s2; if (!transposed) { @@ -411,17 +412,20 @@ static std::string setContentMatrix_internal(T* _pfMatrix, int _iWidth, int _iHe s2 = 1; } + std::ostringstream s; + s.imbue(std::locale::classic()); + s << std::setprecision(17); + for (int y = 0; y < _iHeight; ++y) { if (_iWidth > 0) - str += StringUtil::toString(_pfMatrix[0*s1 + y*s2]); + s << _pfMatrix[0*s1 + y*s2]; for (int x = 1; x < _iWidth; x++) - str += "," + StringUtil::toString(_pfMatrix[x*s1 + y*s2]); + s << "," << _pfMatrix[x*s1 + y*s2]; - if (y != _iHeight-1) - str += ";"; + s << ";"; } - return str; + return s.str(); } void XMLNode::setContent(float32* _pfMatrix, int _iWidth, int _iHeight, bool transposed) diff --git a/src/swrap.cpp b/src/swrap.cpp deleted file mode 100644 index c970ab5..0000000 --- a/src/swrap.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2016, iMinds-Vision Lab, University of Antwerp - 2014-2016, CWI, Amsterdam - -Contact: astra@uantwerpen.be -Website: http://www.astra-toolbox.com/ - -This file is part of the ASTRA Toolbox. - - -The ASTRA Toolbox is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -The ASTRA Toolbox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>. - ------------------------------------------------------------------------ -*/ - -#ifndef _MSC_VER - -#include "astra/swrap.h" -#include <cerrno> - -errno_t fopen_s(FILE** pFile, const char* filename, const char* mode) -{ - if (!pFile) - return EINVAL; - - FILE* x = fopen(filename, mode); - if (!x) - return errno; - - *pFile = x; - return 0; -} - -#endif |