From 3a1e4dffdb8b4facba0d4ae85525de943c5f625e Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Sun, 19 Sep 2021 11:23:35 +0100 Subject: [PATCH 1/2] FluidGrid: proposed dimensions output to the fitTransform method --- include/algorithms/public/Grid.hpp | 6 +++++- include/clients/nrt/GridClient.hpp | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/algorithms/public/Grid.hpp b/include/algorithms/public/Grid.hpp index 30971a627..4fd942e1c 100644 --- a/include/algorithms/public/Grid.hpp +++ b/include/algorithms/public/Grid.hpp @@ -47,7 +47,6 @@ class Grid double area = (xMax - xMin) * (yMax - yMin); double size = static_cast(N); double step = sqrt(area / M); - index numCols, numRows; if (area <= 0) return DataSet(); @@ -100,8 +99,13 @@ class Grid return result; } + std::pair const getGridMax() { + return {numCols,numRows}; + } + private: Assign2D assign2D; + index numCols = 0, numRows = 0; }; }; // namespace algorithm }; // namespace fluid diff --git a/include/clients/nrt/GridClient.hpp b/include/clients/nrt/GridClient.hpp index 349f05174..78f959fb6 100644 --- a/include/clients/nrt/GridClient.hpp +++ b/include/clients/nrt/GridClient.hpp @@ -32,6 +32,7 @@ class GridClient : public FluidBaseClient, OfflineIn, OfflineOut, ModelObject using string = std::string; using BufferPtr = std::shared_ptr; using StringVector = FluidTensor; + using IndexPair = std::tuple; template Result process(FluidContext&) @@ -56,21 +57,22 @@ class GridClient : public FluidBaseClient, OfflineIn, OfflineOut, ModelObject GridClient(ParamSetViewType& p) : mParams(p) {} - MessageResult fitTransform(DataSetClientRef sourceClient, + MessageResult fitTransform(DataSetClientRef sourceClient, DataSetClientRef destClient) { auto srcPtr = sourceClient.get().lock(); auto destPtr = destClient.get().lock(); - if (!srcPtr || !destPtr) return Error(NoDataSet); + if (!srcPtr || !destPtr) return Error(NoDataSet); auto src = srcPtr->getDataSet(); auto dest = destPtr->getDataSet(); - if (src.dims() != 2) return Error("Dataset should be 2D"); - if (src.size() == 0) return Error(EmptyDataSet); + if (src.dims() != 2) return Error("Dataset should be 2D"); + if (src.size() == 0) return Error(EmptyDataSet); FluidDataSet result; result = mAlgorithm.process(src, get(), get(), get()); destPtr->setDataSet(result); - return OK(); + IndexPair casted = mAlgorithm.getGridMax(); + return {casted}; } static auto getMessageDescriptors() From 9679e75b34995f53d73d216f304fbeb3f4d88bcc Mon Sep 17 00:00:00 2001 From: tremblap Date: Sun, 19 Sep 2021 12:29:09 +0100 Subject: [PATCH 2/2] Update include/algorithms/public/Grid.hpp Co-authored-by: weefuzzy --- include/algorithms/public/Grid.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/algorithms/public/Grid.hpp b/include/algorithms/public/Grid.hpp index 4fd942e1c..db43b6a88 100644 --- a/include/algorithms/public/Grid.hpp +++ b/include/algorithms/public/Grid.hpp @@ -105,7 +105,8 @@ class Grid private: Assign2D assign2D; - index numCols = 0, numRows = 0; +index numCols{0}; +indes numRows{0}; }; }; // namespace algorithm }; // namespace fluid