From 93ddb8a6de0dc7b82c7b6411ea3de8c49f2b48c0 Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Tue, 30 Jan 2018 14:34:39 +0100 Subject: [PATCH] IntensityDataFunctions::getFourierTransform renamed to createFFT and switched to smart ptr. --- Core/Instrument/IntensityDataFunctions.cpp | 7 ++----- Core/Instrument/IntensityDataFunctions.h | 4 +++- .../Views/IntensityDataWidgets/IntensityDataCanvas.cpp | 2 +- .../Core/CoreSpecial/FourierTransformationTest.cpp | 4 ++-- .../Core/DataStructure/IntensityDataFunctionsTest.h | 6 +++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Core/Instrument/IntensityDataFunctions.cpp b/Core/Instrument/IntensityDataFunctions.cpp index 12d24f24ed4..4a64e45050c 100644 --- a/Core/Instrument/IntensityDataFunctions.cpp +++ b/Core/Instrument/IntensityDataFunctions.cpp @@ -265,7 +265,7 @@ OutputData<double>* IntensityDataFunctions::createOutputDatafrom2DArray( return result; } -OutputData<double>* IntensityDataFunctions::getFourierTransform(const OutputData<double> &data) +std::unique_ptr<OutputData<double>> IntensityDataFunctions::createFFT(const OutputData<double> &data) { std::vector<std::vector<double>> array_2d = IntensityDataFunctions::create2DArrayfromOutputData(data); @@ -273,8 +273,5 @@ OutputData<double>* IntensityDataFunctions::getFourierTransform(const OutputData std::vector<std::vector<double>> fft_array_2d = IntensityDataFunctions::FT2DArray(array_2d); - OutputData<double>* fftOutputData = IntensityDataFunctions::createOutputDatafrom2DArray( - fft_array_2d); - - return fftOutputData; + return std::unique_ptr<OutputData<double>>(IntensityDataFunctions::createOutputDatafrom2DArray(fft_array_2d)); } diff --git a/Core/Instrument/IntensityDataFunctions.h b/Core/Instrument/IntensityDataFunctions.h index 2181f192149..e6ffa9ebe0f 100644 --- a/Core/Instrument/IntensityDataFunctions.h +++ b/Core/Instrument/IntensityDataFunctions.h @@ -76,8 +76,10 @@ BA_CORE_API_ std::vector<std::vector<double>> FT2DArray( BA_CORE_API_ OutputData<double>* createOutputDatafrom2DArray( const std::vector<std::vector<double>>& array_2d); +#ifndef SWIG //! Creates Fourier Transform (OutputData format) of intensity map (OutputData format). -BA_CORE_API_ OutputData<double>* getFourierTransform(const OutputData<double> &data); +BA_CORE_API_ std::unique_ptr<OutputData<double>> createFFT(const OutputData<double> &data); +#endif //SWIG }; // namespace IntensityDataFunctions diff --git a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp index ace6d7c90cf..882c5ea0ec6 100644 --- a/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp +++ b/GUI/coregui/Views/IntensityDataWidgets/IntensityDataCanvas.cpp @@ -112,7 +112,7 @@ void IntensityDataCanvas::onfftAction() m_backup->copyFrom(*dataItem->getOutputData()); dataItem->setOutputData( - (IntensityDataFunctions::getFourierTransform(*dataItem->getOutputData()))); + (IntensityDataFunctions::createFFT(*dataItem->getOutputData())).release()); } } diff --git a/Tests/Functional/Core/CoreSpecial/FourierTransformationTest.cpp b/Tests/Functional/Core/CoreSpecial/FourierTransformationTest.cpp index 882b4956e3c..7fe38d162e9 100644 --- a/Tests/Functional/Core/CoreSpecial/FourierTransformationTest.cpp +++ b/Tests/Functional/Core/CoreSpecial/FourierTransformationTest.cpp @@ -77,8 +77,8 @@ bool FourierTransformationTest::test_fft(const std::string& input_image_name, } // making fourier transformation - std::unique_ptr<OutputData<double>> fft( - IntensityDataFunctions::getFourierTransform(*input_image.get())); + std::unique_ptr<OutputData<double>> fft = + IntensityDataFunctions::createFFT(*input_image.get()); // loading reference fft std::unique_ptr<OutputData<double>> reference_fft; diff --git a/Tests/UnitTests/Core/DataStructure/IntensityDataFunctionsTest.h b/Tests/UnitTests/Core/DataStructure/IntensityDataFunctionsTest.h index 600539cd770..951be4fc0c1 100644 --- a/Tests/UnitTests/Core/DataStructure/IntensityDataFunctionsTest.h +++ b/Tests/UnitTests/Core/DataStructure/IntensityDataFunctionsTest.h @@ -168,10 +168,10 @@ TEST_F(IntensityDataFunctionsTest, create2DArrayfromOutputDataTest) OutputData<double> out_data; out_data.addAxis("axis0", 2, 1.0, 2.0); out_data.addAxis("axis1", 3, 3.0, 4.0); - EXPECT_EQ(6, out_data.getAllocatedSize()); + EXPECT_EQ(6u, out_data.getAllocatedSize()); - EXPECT_EQ(2, out_data.getAxis(0).size()); // no. of rows - EXPECT_EQ(3, out_data.getAxis(1).size()); // no. of cols + EXPECT_EQ(2u, out_data.getAxis(0).size()); // no. of rows + EXPECT_EQ(3u, out_data.getAxis(1).size()); // no. of cols std::vector<double> arr_in{1,2,3,4,5,6}; out_data.setRawDataVector(arr_in); -- GitLab