From e4be6b99c324fc9d75832e5a4130b3d1be39ff34 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Fri, 30 Aug 2024 08:54:25 -0400 Subject: [PATCH 01/10] ENH: Add Initialize Data Array functionality to Create Data Array Signed-off-by: Michael Jackson ENH: --- src/Plugins/SimplnxCore/CMakeLists.txt | 1 + .../Filters/Algorithms/InitializeData.cpp | 336 ++++++++++++++ .../Filters/Algorithms/InitializeData.hpp | 119 +++++ .../Filters/CreateDataArrayFilter.cpp | 294 +++++++++++- .../Filters/CreateDataArrayFilter.hpp | 11 + .../Filters/InitializeDataFilter.cpp | 432 ++---------------- 6 files changed, 772 insertions(+), 421 deletions(-) create mode 100644 src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.cpp create mode 100644 src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.hpp diff --git a/src/Plugins/SimplnxCore/CMakeLists.txt b/src/Plugins/SimplnxCore/CMakeLists.txt index 9f644cc27d..d327c9280c 100644 --- a/src/Plugins/SimplnxCore/CMakeLists.txt +++ b/src/Plugins/SimplnxCore/CMakeLists.txt @@ -186,6 +186,7 @@ set(AlgorithmList ComputeTriangleGeomSizes FlyingEdges3D CreateColorMap + InitializeData LabelTriangleGeometry LaplacianSmoothing NearestPointFuseRegularGrids diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.cpp new file mode 100644 index 0000000000..c8befaa456 --- /dev/null +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.cpp @@ -0,0 +1,336 @@ + + +#include "InitializeData.hpp" + +#include "simplnx/Utilities/DataArrayUtilities.hpp" +#include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Common/TypeTraits.hpp" +#include "simplnx/DataStructure/IDataArray.hpp" +#include "simplnx/DataStructure/AbstractDataStore.hpp" + +#include +#include + +using namespace nx::core; + +namespace +{ + +// At the current time this code could be simplified with a bool in the incremental template, HOWEVER, +// it was done this way to allow for expansion of operations down the line multiplication, division, etc. +template +struct IncrementalOptions +{ + static constexpr bool UsingAddition = UseAddition; + static constexpr bool UsingSubtraction = UseSubtraction; +}; + +using AdditionT = IncrementalOptions; +using SubtractionT = IncrementalOptions; + +template +void ValueFill(AbstractDataStore& dataStore, const std::vector& stringValues) +{ + usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free + + if(numComp > 1) + { + std::vector values; + + for(const auto& str : stringValues) + { + values.emplace_back(ConvertTo::convert(str).value()); + } + + usize numTup = dataStore.getNumberOfTuples(); + + for(usize tup = 0; tup < numTup; tup++) + { + for(usize comp = 0; comp < numComp; comp++) + { + dataStore[tup * numComp + comp] = values[comp]; + } + } + } + else + { + Result result = ConvertTo::convert(stringValues[0]); + T value = result.value(); + dataStore.fill(value); + } +} + +template +void IncrementalFill(AbstractDataStore& dataStore, const std::vector& startValues, const std::vector& stepValues) +{ + usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free + + std::vector values(numComp); + std::vector steps(numComp); + + for(usize comp = 0; comp < numComp; comp++) + { + Result result = ConvertTo::convert(startValues[comp]); + values[comp] = result.value(); + if constexpr(!std::is_same_v) + { + result = ConvertTo::convert(stepValues[comp]); + steps[comp] = result.value(); + } + } + + usize numTup = dataStore.getNumberOfTuples(); + + if constexpr(std::is_same_v) + { + for(usize comp = 0; comp < numComp; comp++) + { + dataStore[comp] = values[comp]; + + if constexpr(IncrementalOptions::UsingAddition) + { + values[comp] = ConvertTo::convert(stepValues[comp]).value() != 0 ? true : values[comp]; + } + if constexpr(IncrementalOptions::UsingSubtraction) + { + values[comp] = ConvertTo::convert(stepValues[comp]).value() != 0 ? false : values[comp]; + } + } + + for(usize tup = 1; tup < numTup; tup++) + { + for(usize comp = 0; comp < numComp; comp++) + { + dataStore[tup * numComp + comp] = values[comp]; + } + } + } + + if constexpr(!std::is_same_v) + { + for(usize tup = 0; tup < numTup; tup++) + { + for(usize comp = 0; comp < numComp; comp++) + { + dataStore[tup * numComp + comp] = values[comp]; + + if constexpr(IncrementalOptions::UsingAddition) + { + values[comp] += steps[comp]; + } + if constexpr(IncrementalOptions::UsingSubtraction) + { + values[comp] -= steps[comp]; + } + } + } + } +} + +template +void RandomFill(std::vector& dist, AbstractDataStore& dataStore, const uint64 seed, const bool standardizeSeed) +{ + usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free + + std::vector generators(numComp, std::mt19937_64{}); + + for(usize comp = 0; comp < numComp; comp++) + { + generators[comp].seed((standardizeSeed ? seed : seed + comp)); // If standardizing seed all generators use the same else, use modified seeds + } + + usize numTup = dataStore.getNumberOfTuples(); + + for(usize tup = 0; tup < numTup; tup++) + { + for(usize comp = 0; comp < numComp; comp++) + { + if constexpr(std::is_floating_point_v) + { + if constexpr(Ranged) + { + dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp])); + } + if constexpr(!Ranged) + { + if constexpr(std::is_signed_v) + { + dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp]) * (std::numeric_limits::max() - 1) * (((rand() & 1) == 0) ? 1 : -1)); + } + if constexpr(!std::is_signed_v) + { + dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp]) * std::numeric_limits::max()); + } + } + } + if constexpr(!std::is_floating_point_v) + { + dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp])); + } + } + } +} + +template +void FillIncForwarder(const StepType& stepType, ArgsT&&... args) +{ + switch(stepType) + { + case StepType::Addition: { + ::IncrementalFill(std::forward(args)...); + return; + } + case StepType::Subtraction: { + ::IncrementalFill(std::forward(args)...); + return; + } + } +} + +template +void FillRandomForwarder(const std::vector& range, usize numComp, ArgsT&&... args) +{ + if constexpr(std::is_same_v) + { + std::vector> dists; + for(usize comp = 0; comp < numComp * 2; comp += 2) + { + dists.emplace_back((range.at(comp) ? 1 : 0), (range.at(comp + 1) ? 1 : 0)); + } + ::RandomFill>(dists, std::forward(args)...); + return; + } + if constexpr(!std::is_floating_point_v) + { + std::vector> dists; + for(usize comp = 0; comp < numComp * 2; comp += 2) + { + dists.emplace_back(range.at(comp), range.at(comp + 1)); + } + ::RandomFill>(dists, std::forward(args)...); + } + if constexpr(std::is_floating_point_v) + { + if constexpr(Ranged) + { + + std::vector> dists; + for(usize comp = 0; comp < numComp * 2; comp += 2) + { + dists.emplace_back(range.at(comp), range.at(comp + 1)); + } + ::RandomFill>(dists, std::forward(args)...); + } + if constexpr(!Ranged) + { + std::vector> dists; + for(usize comp = 0; comp < numComp * 2; comp += 2) + { + dists.emplace_back(0, 1); + } + ::RandomFill>(dists, std::forward(args)...); + } + } +} + +std::vector standardizeMultiComponent(const usize numComps, const std::vector& componentValues) +{ + if(componentValues.size() == numComps) + { + return {componentValues}; + } + else + { + std::vector standardized(numComps); + for(usize comp = 0; comp < numComps; comp++) + { + standardized[comp] = componentValues[0]; + } + return standardized; + } +} + +struct FillArrayFunctor +{ + template + void operator()(IDataArray& iDataArray, const InitializeDataInputValues& inputValues) + { + auto& dataStore = iDataArray.template getIDataStoreRefAs>(); + usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free + + switch(inputValues.initType) + { + case InitializeType::FillValue: { + return ::ValueFill(dataStore, standardizeMultiComponent(numComp, inputValues.stringValues)); + } + case InitializeType::Incremental: { + return ::FillIncForwarder(inputValues.stepType, dataStore, standardizeMultiComponent(numComp, inputValues.startValues), standardizeMultiComponent(numComp, inputValues.stepValues)); + } + case InitializeType::Random: { + std::vector range; + if constexpr(!std::is_same_v) + { + for(usize comp = 0; comp < numComp; comp++) + { + range.push_back(std::numeric_limits::min()); + range.push_back(std::numeric_limits::max()); + } + } + if constexpr(std::is_same_v) + { + for(usize comp = 0; comp < numComp; comp++) + { + range.push_back(false); + range.push_back(true); + } + } + return ::FillRandomForwarder(range, numComp, dataStore, inputValues.seed, inputValues.standardizeSeed); + } + case InitializeType::RangedRandom: { + auto randBegin = standardizeMultiComponent(numComp, inputValues.randBegin); + auto randEnd = standardizeMultiComponent(numComp, inputValues.randEnd); + + std::vector range; + for(usize comp = 0; comp < numComp; comp++) + { + Result result = ConvertTo::convert(randBegin[comp]); + range.push_back(result.value()); + result = ConvertTo::convert(randEnd[comp]); + range.push_back(result.value()); + } + return ::FillRandomForwarder(range, numComp, dataStore, inputValues.seed, inputValues.standardizeSeed); + } + } + } +}; + +} // namespace + +// ----------------------------------------------------------------------------- +InitializeData::InitializeData(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, InitializeDataInputValues* inputValues) +: m_DataStructure(dataStructure) +, m_InputValues(inputValues) +, m_ShouldCancel(shouldCancel) +, m_MessageHandler(mesgHandler) +{ +} + +// ----------------------------------------------------------------------------- +InitializeData::~InitializeData() noexcept = default; + +// ----------------------------------------------------------------------------- +const std::atomic_bool& InitializeData::getCancel() +{ + return m_ShouldCancel; +} + +// ----------------------------------------------------------------------------- +Result<> InitializeData::operator()() +{ + + auto& iDataArray = m_DataStructure.getDataRefAs(m_InputValues->InputArrayPath); + + ExecuteDataFunction(::FillArrayFunctor{}, iDataArray.getDataType(), iDataArray, *m_InputValues); + + return {}; +} diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.hpp new file mode 100644 index 0000000000..3b2a620d23 --- /dev/null +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.hpp @@ -0,0 +1,119 @@ +#pragma once + +#include "SimplnxCore/SimplnxCore_export.hpp" + +#include "simplnx/Filter/IFilter.hpp" +#include "simplnx/Utilities/StringUtilities.hpp" +#include "simplnx/Utilities/DataArrayUtilities.hpp" + + +namespace nx::core +{ + +constexpr char k_DelimiterChar = ';'; + +enum InitializeType : uint64 +{ + FillValue, + Incremental, + Random, + RangedRandom +}; + +enum StepType : uint64 +{ + Addition, + Subtraction +}; + +struct SIMPLNXCORE_EXPORT InitializeDataInputValues +{ + DataPath InputArrayPath; + InitializeType initType; + StepType stepType; + std::vector stringValues; + std::vector startValues; + std::vector stepValues; + uint64 seed; + std::vector randBegin; + std::vector randEnd; + bool standardizeSeed; +}; + + +struct SIMPLNXCORE_EXPORT ValidateMultiInputFunctor +{ + // The single comp size validation defaults to off as size 0 is checked earlier in the function + template + IFilter::PreflightResult operator()(const usize expectedComp, const std::string& unfilteredStr, const usize singleCompSize = 0) + { + std::vector splitVals = StringUtilities::split(StringUtilities::trimmed(unfilteredStr), k_DelimiterChar); + + if(splitVals.empty()) + { + return IFilter::MakePreflightErrorResult(-11610, fmt::format("A required parameter is unable to be processed with '{}' delimiter. Input: {}", k_DelimiterChar, unfilteredStr)); + } + + for(usize comp = 0; comp < splitVals.size(); comp++) + { + if(splitVals[comp].empty()) + { + return IFilter::MakePreflightErrorResult(-11611, fmt::format("Empty value found after '{}' components were converted. Check for duplicate '{}' next to one another.", comp, k_DelimiterChar)); + } + + Result result = ConvertTo::convert(splitVals[comp]); + + if(result.invalid()) + { + return IFilter::MakePreflightErrorResult(-11612, fmt::format("Unable to process '{}' into a {} value.", splitVals[comp], DataTypeToString(GetDataType()))); + } + } + + if(splitVals.size() == expectedComp) + { + return {}; // Valid + } + + if(splitVals.size() == singleCompSize) + { + return {}; // Valid + } + + if(splitVals.size() == expectedComp + 1) + { + if(unfilteredStr.back() == k_DelimiterChar) + { + return IFilter::MakePreflightErrorResult(-11613, fmt::format("Remove the extra delimiter '{}' at the end of your value sequence: {}.", k_DelimiterChar, unfilteredStr)); + } + } + + return IFilter::MakePreflightErrorResult(-11614, + fmt::format("Using '{}' as a delimiter we are unable to break '{}' into the required {} components.", k_DelimiterChar, unfilteredStr, expectedComp)); + } +}; + + +class InitializeData +{ +public: + InitializeData(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, InitializeDataInputValues* inputValues); + ~InitializeData() noexcept; + + InitializeData(const InitializeData&) = delete; + InitializeData(InitializeData&&) noexcept = delete; + InitializeData& operator=(const InitializeData&) = delete; + InitializeData& operator=(InitializeData&&) noexcept = delete; + + Result<> operator()(); + + const std::atomic_bool& getCancel(); + +private: + DataStructure& m_DataStructure; + const InitializeDataInputValues* m_InputValues = nullptr; + const std::atomic_bool& m_ShouldCancel; + const IFilter::MessageHandler& m_MessageHandler; + +}; + +} diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp index b93e305e5c..b21912158d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp @@ -1,5 +1,7 @@ #include "CreateDataArrayFilter.hpp" +#include "SimplnxCore/Filters/Algorithms/InitializeData.hpp" + #include "simplnx/Common/TypesUtility.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Parameters/ArrayCreationParameter.hpp" @@ -19,8 +21,6 @@ using namespace nx::core; namespace { -constexpr int32 k_EmptyParameterError = -123; - struct CreateAndInitArrayFunctor { template @@ -73,9 +73,32 @@ Parameters CreateDataArrayFilter::parameters() const params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); params.insert(std::make_unique(k_NumericType_Key, "Output Numeric Type", "Numeric Type of data to create", NumericType::int32)); - params.insert(std::make_unique(k_InitializationValue_Key, "Initialization Value", "This value will be used to fill the new array", "0")); + // params.insert(std::make_unique(k_InitializationValue_Key, "Initialization Value", "This value will be used to fill the new array", "0")); params.insert(std::make_unique(k_NumComps_Key, "Number of Components", "Number of components", 1)); + params.insertSeparator(Parameters::Separator{"Initialization Options"}); + params.insertLinkableParameter(std::make_unique(k_InitType_Key, "Initialization Type", "Method for determining the what values of the data in the array should be initialized to", + static_cast(0), + ChoicesParameter::Choices{"Fill Value", "Incremental", "Random", "Random With Range"})); // sequence dependent DO NOT REORDER + + params.insert(std::make_unique(k_InitValue_Key, "Fill Values [Seperated with ;]", + "Specify values for each component. Ex: A 3-component array would be 6;8;12 and every tuple would have these same component values", "1;1;1")); + + params.insert(std::make_unique(k_StartingFillValue_Key, "Starting Value [Seperated with ;]", "The value to start incrementing from", "0;1;2")); + params.insert(std::make_unique(k_StepOperation_Key, "Step Operation", "The type of step operation to preform", static_cast(0), + ChoicesParameter::Choices{"Addition", "Subtraction"})); + params.insert(std::make_unique(k_StepValue_Key, "Increment/Step Value [Seperated with ;]", "The number to increment/decrement the fill value by", "1;1;1")); + + params.insert(std::make_unique(k_UseSeed_Key, "Use Seed for Random Generation", "When true the Seed Value will be used to seed the generator", false)); + params.insert(std::make_unique>(k_SeedValue_Key, "Seed Value", "The seed fed into the random generator", std::mt19937::default_seed)); + params.insert(std::make_unique(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "InitializeDataFilter SeedValue")); + params.insert(std::make_unique(k_StandardizeSeed_Key, "Use the Same Seed for Each Component", + "When true the same seed will be used for each component's generator in a multi-component array", false)); + + params.insert( + std::make_unique(k_InitStartRange_Key, "Initialization Start Range [Seperated with ;]", "[Inclusive] The lower bound initialization range for random values", "0;0;0")); + params.insert(std::make_unique(k_InitEndRange_Key, "Initialization End Range [Seperated with ;]", "[Inclusive] The upper bound initialization range for random values", "1;1;1")); + params.insertSeparator(Parameters::Separator{"Output Data Array"}); params.insert(std::make_unique(k_DataPath_Key, "Created Array", "Array storing the data", DataPath{})); params.insert(std::make_unique(k_DataFormat_Key, "Data Format", @@ -95,6 +118,28 @@ Parameters CreateDataArrayFilter::parameters() const // Associate the Linkable Parameter(s) to the children parameters that they control params.linkParameters(k_AdvancedOptions_Key, k_TupleDims_Key, true); + // Associate the Linkable Parameter(s) to the children parameters that they control + /* Using Fill Value */ + params.linkParameters(k_InitType_Key, k_InitValue_Key, static_cast(0)); + + /* Using Incremental */ + params.linkParameters(k_InitType_Key, k_StartingFillValue_Key, static_cast(1)); + params.linkParameters(k_InitType_Key, k_StepOperation_Key, static_cast(1)); + params.linkParameters(k_InitType_Key, k_StepValue_Key, static_cast(1)); + + /* Random - Using Random */ + params.linkParameters(k_InitType_Key, k_UseSeed_Key, static_cast(2)); + params.linkParameters(k_InitType_Key, k_SeedValue_Key, static_cast(2)); + params.linkParameters(k_InitType_Key, k_SeedArrayName_Key, static_cast(2)); + params.linkParameters(k_InitType_Key, k_StandardizeSeed_Key, static_cast(2)); + + /* Random - Using Random With Range */ + params.linkParameters(k_InitType_Key, k_UseSeed_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_SeedValue_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_SeedArrayName_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_StandardizeSeed_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_InitStartRange_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_InitEndRange_Key, static_cast(3)); return params; } @@ -112,22 +157,22 @@ IFilter::PreflightResult CreateDataArrayFilter::preflightImpl(const DataStructur auto numericType = filterArgs.value(k_NumericType_Key); auto numComponents = filterArgs.value(k_NumComps_Key); auto dataArrayPath = filterArgs.value(k_DataPath_Key); - auto initValue = filterArgs.value(k_InitializationValue_Key); auto tableData = filterArgs.value(k_TupleDims_Key); auto dataFormat = filterArgs.value(k_DataFormat_Key); + // auto initValue = filterArgs.value(k_InitializationValue_Key); nx::core::Result resultOutputActions; - if(initValue.empty()) - { - return MakePreflightErrorResult(k_EmptyParameterError, fmt::format("{}: Init Value cannot be empty.{}({})", humanName(), __FILE__, __LINE__)); - } - // Sanity check that what the user entered for an init value can be converted safely to the final numeric type - Result<> result = CheckValueConverts(initValue, numericType); - if(result.invalid()) - { - return {ConvertResultTo(std::move(result), {})}; - } +// if(initValue.empty()) +// { +// return MakePreflightErrorResult(k_EmptyParameterError, fmt::format("{}: Init Value cannot be empty.{}({})", humanName(), __FILE__, __LINE__)); +// } +// // Sanity check that what the user entered for an init value can be converted safely to the final numeric type +// Result<> result = CheckValueConverts(initValue, numericType); +// if(result.invalid()) +// { +// return {ConvertResultTo(std::move(result), {})}; +// } std::vector compDims = std::vector{numComponents}; std::vector tupleDims = {}; @@ -167,23 +212,232 @@ IFilter::PreflightResult CreateDataArrayFilter::preflightImpl(const DataStructur } } + auto arrayDataType = ConvertNumericTypeToDataType(numericType); auto action = std::make_unique(ConvertNumericTypeToDataType(numericType), tupleDims, compDims, dataArrayPath, dataFormat); resultOutputActions.value().appendAction(std::move(action)); - return {std::move(resultOutputActions)}; + auto seedArrayNameValue = filterArgs.value(k_SeedArrayName_Key); + auto initializeTypeValue = static_cast(filterArgs.value(k_InitType_Key)); + +// nx::core::Result resultOutputActions; + std::vector preflightUpdatedValues; + +// auto& iDataArray = dataStructure.getDataRefAs(filterArgs.value(k_ArrayPath_Key)); + + if(arrayDataType == DataType::boolean) + { + std::stringstream updatedValStrm; + + updatedValStrm << "We detected that you are doing an operation on a boolean array.\n"; + updatedValStrm << "The ONLY two ways to specify a 'false' boolean value are as follows:\n"; + updatedValStrm << "- boolean value string types as follows ignoring apostrophe marks: 'False', 'FALSE', 'false'\n"; + updatedValStrm << "- all well formed integers and well formed floating point definitions of 0\n\n"; + + updatedValStrm << "ANY OTHER string or number WILL BE 'true', although it is good practice to define true values as follows:\n"; + updatedValStrm << "- boolean value string types as follows ignoring apostrophe marks: 'True', 'TRUE', 'true'\n"; + updatedValStrm << "- all well formed integers and well formed floating point definitions of 1"; + + preflightUpdatedValues.push_back({"Boolean Note", updatedValStrm.str()}); + } + + if(numComponents > 1) + { + std::stringstream updatedValStrm; + + updatedValStrm << "We detected that you are doing an operation on a multi-component array.\n"; + updatedValStrm + << "If you do NOT want to use unique values for each component, you can just supply one value to the input box and we will apply that value to every component for the tuple.\nExample: 1\n\n"; + + updatedValStrm << fmt::format("If you DO want to use unique values for each component, you need to supply {} values of type {} seperated by '{}'.\n", numComponents, + DataTypeToString(arrayDataType), k_DelimiterChar); + updatedValStrm << "Example: "; + + for(usize comp = 0; comp < numComponents; comp++) + { + updatedValStrm << "1"; + + if(comp != numComponents - 1) + { + updatedValStrm << k_DelimiterChar; + } + } + + preflightUpdatedValues.push_back({"Multi-Component Note", updatedValStrm.str()}); + } + + std::stringstream operationNuancesStrm; + + switch(initializeTypeValue) + { + case InitializeType::FillValue: { + auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_InitValue_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + + operationNuancesStrm << "None to note"; + + break; + } + case InitializeType::Incremental: { + auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_StartingFillValue_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + + if(arrayDataType == DataType::boolean) + { + // custom bool checks here + std::stringstream updatedValStrm; + + updatedValStrm << "We detected that you are doing an incremental operation on a boolean array.\n"; + updatedValStrm << "For the step values please enter uint8 values, preferably a 0 or 1 only.\n"; + + switch(static_cast(filterArgs.value(k_StepOperation_Key))) + { + case Addition: { + updatedValStrm << "You have currently selected the addition operation.\nAny step value that is greater than 0 will cause all values to be 'true' after the first tuple, 'true' " + "values will remain unchanged.\n"; + updatedValStrm << "The two possibilities:\n"; + updatedValStrm << "- If your start value is 'false' and step value > 0, the array will initialize to | false | true | true | ... |\n"; + updatedValStrm << "- If your start value is 'true' and step value > 0, the array will initialize to | true | true | true | ... |"; + break; + } + case Subtraction: { + updatedValStrm << "You have currently selected the addition operation.\nAny step value that is greater than 0 will cause all values to be 'false' after the first tuple, 'false' " + "values will remain unchanged.\n"; + updatedValStrm << "The two possibilities:\n"; + updatedValStrm << "- If your start value is 'true' and step value > 0, the array will initialize to | true | false | false | ... |\n"; + updatedValStrm << "- If your start value is 'false' and step value > 0, the array will initialize to | false | false | false | ... |"; + break; + } + } + + preflightUpdatedValues.push_back({"Boolean Incremental Nuances", updatedValStrm.str()}); + + result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, DataType::uint8, numComponents, filterArgs.value(k_StepValue_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + } + else + { + result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_StepValue_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + } + auto values = StringUtilities::split(filterArgs.value(k_StepValue_Key), ";", false); + std::vector zeroIdx; + for(size_t i = 0; i < values.size(); i++) + { + if(values[i] == "0") + { + zeroIdx.push_back(i); + } + } + if(!zeroIdx.empty()) + { + + operationNuancesStrm << "Warning: Zero Step Value found. Component(s) " << fmt::format("[{}]", fmt::join(zeroIdx, ",")) + << " have a ZERO value for the step/increment.\n The values for those components will be unchanged from the starting value.\n"; + operationNuancesStrm << fmt::format(" Example: Suppose we have a two component array with a Step Values of '2{}0', Starting Values of '0', and an addition Step Operation\n", k_DelimiterChar); + operationNuancesStrm << " The output array would look like 0,0 | 2,0 | 4,0 | 6,0 | ..."; + } + break; + } + case InitializeType::RangedRandom: { + auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_InitStartRange_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + + result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_InitEndRange_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + + [[fallthrough]]; + } + case InitializeType::Random: { + auto createAction = std::make_unique(DataType::uint64, std::vector{1}, std::vector{1}, DataPath({seedArrayNameValue})); + resultOutputActions.value().appendAction(std::move(createAction)); + + if(numComponents == 1) + { + if(filterArgs.value(k_StandardizeSeed_Key)) + { + operationNuancesStrm << fmt::format("You chose to standardize the seed for each component, but the array {} is a single component so it will not alter the randomization scheme.", + dataArrayPath.getTargetName()); + } + } + else + { + if(filterArgs.value(k_StandardizeSeed_Key)) + { + operationNuancesStrm << "This generates THE SAME sequences of random numbers for each component in the array based on one seed.\n"; + operationNuancesStrm << "The resulting array will look like | 1,1,1 | 9,9,9 | ...\n"; + } + else + { + operationNuancesStrm << "This generates DIFFERENT sequences of random numbers for each component in the array based on x seeds all modified versions of an original seed.\n"; + operationNuancesStrm << "The resulting array will look like | 1,9,5 | 7,1,6 | ...\n"; + } + } + + break; + } + } + + preflightUpdatedValues.push_back({"Operation Nuances", operationNuancesStrm.str()}); + + return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; } //------------------------------------------------------------------------------ -Result<> CreateDataArrayFilter::executeImpl(DataStructure& dataStructure, const Arguments& args, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, +Result<> CreateDataArrayFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto path = args.value(k_DataPath_Key); - auto initValue = args.value(k_InitializationValue_Key); + auto path = filterArgs.value(k_DataPath_Key); + auto initValue = filterArgs.value(k_InitializationValue_Key); + + ExecuteNeighborFunction(CreateAndInitArrayFunctor{}, ConvertNumericTypeToDataType(filterArgs.value(k_NumericType_Key)), dataStructure.getDataAs(path), initValue); + - ExecuteNeighborFunction(CreateAndInitArrayFunctor{}, ConvertNumericTypeToDataType(args.value(k_NumericType_Key)), dataStructure.getDataAs(path), initValue); + auto initType = static_cast(filterArgs.value(k_InitType_Key)); + + auto seed = filterArgs.value(k_SeedValue_Key); + if(!filterArgs.value(k_UseSeed_Key)) + { + seed = static_cast(std::chrono::steady_clock::now().time_since_epoch().count()); + } + + if(initType == InitializeType::Random || initType == InitializeType::RangedRandom) + { + // Store Seed Value in Top Level Array + dataStructure.getDataRefAs(DataPath({filterArgs.value(k_SeedArrayName_Key)}))[0] = seed; + } - return {}; + InitializeDataInputValues inputValues; + inputValues.InputArrayPath = filterArgs.value(k_DataPath_Key); + inputValues.initType = initType; + inputValues.stepType = static_cast(filterArgs.value(k_StepOperation_Key)); + inputValues.stringValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitValue_Key)), k_DelimiterChar); + inputValues.startValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_StartingFillValue_Key)), k_DelimiterChar); + inputValues.stepValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_StepValue_Key)), k_DelimiterChar); + inputValues.seed = seed; + inputValues.randBegin = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitStartRange_Key)), k_DelimiterChar); + inputValues.randEnd = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitEndRange_Key)), k_DelimiterChar); + inputValues.standardizeSeed = filterArgs.value(k_StandardizeSeed_Key); + + return InitializeData(dataStructure, messageHandler, shouldCancel, &inputValues)(); } namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp index e3e38e9856..6b2ac76a08 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp @@ -28,6 +28,17 @@ class SIMPLNXCORE_EXPORT CreateDataArrayFilter : public IFilter static inline constexpr StringLiteral k_DataPath_Key = "output_array_path"; static inline constexpr StringLiteral k_InitializationValue_Key = "initialization_value_str"; static inline constexpr StringLiteral k_DataFormat_Key = "data_format"; + static inline constexpr StringLiteral k_InitType_Key = "init_type_index"; + static inline constexpr StringLiteral k_InitValue_Key = "init_value"; + static inline constexpr StringLiteral k_StartingFillValue_Key = "starting_fill_value"; + static inline constexpr StringLiteral k_StepOperation_Key = "step_operation_index"; + static inline constexpr StringLiteral k_StepValue_Key = "step_value"; + static inline constexpr StringLiteral k_UseSeed_Key = "use_seed"; + static inline constexpr StringLiteral k_SeedValue_Key = "seed_value"; + static inline constexpr StringLiteral k_SeedArrayName_Key = "seed_array_name"; + static inline constexpr StringLiteral k_InitStartRange_Key = "init_start_range"; + static inline constexpr StringLiteral k_InitEndRange_Key = "init_end_range"; + static inline constexpr StringLiteral k_StandardizeSeed_Key = "standardize_seed"; /** * @brief Reads SIMPL json and converts it simplnx Arguments. diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp index c7867427a1..3451cf87b6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp @@ -1,6 +1,7 @@ #include "InitializeDataFilter.hpp" -#include "simplnx/Common/TypeTraits.hpp" +#include "SimplnxCore/Filters/Algorithms/InitializeData.hpp" + #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" @@ -14,8 +15,7 @@ #include -#include -#include + #include #include #include @@ -24,375 +24,9 @@ using namespace nx::core; namespace { -constexpr char k_DelimiterChar = ';'; - -enum InitializeType : uint64 -{ - FillValue, - Incremental, - Random, - RangedRandom -}; - -enum StepType : uint64 -{ - Addition, - Subtraction -}; - -struct InitializeDataInputValues -{ - InitializeType initType; - StepType stepType; - std::vector stringValues; - std::vector startValues; - std::vector stepValues; - uint64 seed; - std::vector randBegin; - std::vector randEnd; - bool standardizeSeed; -}; - -// At the current time this code could be simplified with a bool in the incremental template, HOWEVER, -// it was done this way to allow for expansion of operations down the line multiplication, division, etc. -template -struct IncrementalOptions -{ - static constexpr bool UsingAddition = UseAddition; - static constexpr bool UsingSubtraction = UseSubtraction; -}; - -using AdditionT = IncrementalOptions; -using SubtractionT = IncrementalOptions; - -template -void ValueFill(AbstractDataStore& dataStore, const std::vector& stringValues) -{ - usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free - - if(numComp > 1) - { - std::vector values; - - for(const auto& str : stringValues) - { - values.emplace_back(ConvertTo::convert(str).value()); - } - - usize numTup = dataStore.getNumberOfTuples(); - - for(usize tup = 0; tup < numTup; tup++) - { - for(usize comp = 0; comp < numComp; comp++) - { - dataStore[tup * numComp + comp] = values[comp]; - } - } - } - else - { - Result result = ConvertTo::convert(stringValues[0]); - T value = result.value(); - dataStore.fill(value); - } -} - -template -void IncrementalFill(AbstractDataStore& dataStore, const std::vector& startValues, const std::vector& stepValues) -{ - usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free - - std::vector values(numComp); - std::vector steps(numComp); - - for(usize comp = 0; comp < numComp; comp++) - { - Result result = ConvertTo::convert(startValues[comp]); - values[comp] = result.value(); - if constexpr(!std::is_same_v) - { - result = ConvertTo::convert(stepValues[comp]); - steps[comp] = result.value(); - } - } - - usize numTup = dataStore.getNumberOfTuples(); - - if constexpr(std::is_same_v) - { - for(usize comp = 0; comp < numComp; comp++) - { - dataStore[comp] = values[comp]; - - if constexpr(IncrementalOptions::UsingAddition) - { - values[comp] = ConvertTo::convert(stepValues[comp]).value() != 0 ? true : values[comp]; - } - if constexpr(IncrementalOptions::UsingSubtraction) - { - values[comp] = ConvertTo::convert(stepValues[comp]).value() != 0 ? false : values[comp]; - } - } - - for(usize tup = 1; tup < numTup; tup++) - { - for(usize comp = 0; comp < numComp; comp++) - { - dataStore[tup * numComp + comp] = values[comp]; - } - } - } - - if constexpr(!std::is_same_v) - { - for(usize tup = 0; tup < numTup; tup++) - { - for(usize comp = 0; comp < numComp; comp++) - { - dataStore[tup * numComp + comp] = values[comp]; - - if constexpr(IncrementalOptions::UsingAddition) - { - values[comp] += steps[comp]; - } - if constexpr(IncrementalOptions::UsingSubtraction) - { - values[comp] -= steps[comp]; - } - } - } - } -} - -template -void RandomFill(std::vector& dist, AbstractDataStore& dataStore, const uint64 seed, const bool standardizeSeed) -{ - usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free - - std::vector generators(numComp, std::mt19937_64{}); - - for(usize comp = 0; comp < numComp; comp++) - { - generators[comp].seed((standardizeSeed ? seed : seed + comp)); // If standardizing seed all generators use the same else, use modified seeds - } - - usize numTup = dataStore.getNumberOfTuples(); - - for(usize tup = 0; tup < numTup; tup++) - { - for(usize comp = 0; comp < numComp; comp++) - { - if constexpr(std::is_floating_point_v) - { - if constexpr(Ranged) - { - dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp])); - } - if constexpr(!Ranged) - { - if constexpr(std::is_signed_v) - { - dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp]) * (std::numeric_limits::max() - 1) * (((rand() & 1) == 0) ? 1 : -1)); - } - if constexpr(!std::is_signed_v) - { - dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp]) * std::numeric_limits::max()); - } - } - } - if constexpr(!std::is_floating_point_v) - { - dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp])); - } - } - } -} - -template -void FillIncForwarder(const StepType& stepType, ArgsT&&... args) -{ - switch(stepType) - { - case StepType::Addition: { - ::IncrementalFill(std::forward(args)...); - return; - } - case StepType::Subtraction: { - ::IncrementalFill(std::forward(args)...); - return; - } - } -} - -template -void FillRandomForwarder(const std::vector& range, usize numComp, ArgsT&&... args) -{ - if constexpr(std::is_same_v) - { - std::vector> dists; - for(usize comp = 0; comp < numComp * 2; comp += 2) - { - dists.emplace_back((range.at(comp) ? 1 : 0), (range.at(comp + 1) ? 1 : 0)); - } - ::RandomFill>(dists, std::forward(args)...); - return; - } - if constexpr(!std::is_floating_point_v) - { - std::vector> dists; - for(usize comp = 0; comp < numComp * 2; comp += 2) - { - dists.emplace_back(range.at(comp), range.at(comp + 1)); - } - ::RandomFill>(dists, std::forward(args)...); - } - if constexpr(std::is_floating_point_v) - { - if constexpr(Ranged) - { - std::vector> dists; - for(usize comp = 0; comp < numComp * 2; comp += 2) - { - dists.emplace_back(range.at(comp), range.at(comp + 1)); - } - ::RandomFill>(dists, std::forward(args)...); - } - if constexpr(!Ranged) - { - std::vector> dists; - for(usize comp = 0; comp < numComp * 2; comp += 2) - { - dists.emplace_back(0, 1); - } - ::RandomFill>(dists, std::forward(args)...); - } - } -} - -std::vector standardizeMultiComponent(const usize numComps, const std::vector& componentValues) -{ - if(componentValues.size() == numComps) - { - return {componentValues}; - } - else - { - std::vector standardized(numComps); - for(usize comp = 0; comp < numComps; comp++) - { - standardized[comp] = componentValues[0]; - } - return standardized; - } } -struct FillArrayFunctor -{ - template - void operator()(IDataArray& iDataArray, const InitializeDataInputValues& inputValues) - { - auto& dataStore = iDataArray.template getIDataStoreRefAs>(); - usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free - - switch(inputValues.initType) - { - case InitializeType::FillValue: { - return ::ValueFill(dataStore, standardizeMultiComponent(numComp, inputValues.stringValues)); - } - case InitializeType::Incremental: { - return ::FillIncForwarder(inputValues.stepType, dataStore, standardizeMultiComponent(numComp, inputValues.startValues), standardizeMultiComponent(numComp, inputValues.stepValues)); - } - case InitializeType::Random: { - std::vector range; - if constexpr(!std::is_same_v) - { - for(usize comp = 0; comp < numComp; comp++) - { - range.push_back(std::numeric_limits::min()); - range.push_back(std::numeric_limits::max()); - } - } - if constexpr(std::is_same_v) - { - for(usize comp = 0; comp < numComp; comp++) - { - range.push_back(false); - range.push_back(true); - } - } - return ::FillRandomForwarder(range, numComp, dataStore, inputValues.seed, inputValues.standardizeSeed); - } - case InitializeType::RangedRandom: { - auto randBegin = standardizeMultiComponent(numComp, inputValues.randBegin); - auto randEnd = standardizeMultiComponent(numComp, inputValues.randEnd); - - std::vector range; - for(usize comp = 0; comp < numComp; comp++) - { - Result result = ConvertTo::convert(randBegin[comp]); - range.push_back(result.value()); - result = ConvertTo::convert(randEnd[comp]); - range.push_back(result.value()); - } - return ::FillRandomForwarder(range, numComp, dataStore, inputValues.seed, inputValues.standardizeSeed); - } - } - } -}; - -struct ValidateMultiInputFunctor -{ - // The single comp size validation defaults to off as size 0 is checked earlier in the function - template - IFilter::PreflightResult operator()(const usize expectedComp, const std::string& unfilteredStr, const usize singleCompSize = 0) - { - std::vector splitVals = StringUtilities::split(StringUtilities::trimmed(unfilteredStr), k_DelimiterChar); - - if(splitVals.empty()) - { - return IFilter::MakePreflightErrorResult(-11610, fmt::format("A required parameter is unable to be processed with '{}' delimiter. Input: {}", k_DelimiterChar, unfilteredStr)); - } - - for(usize comp = 0; comp < splitVals.size(); comp++) - { - if(splitVals[comp].empty()) - { - return IFilter::MakePreflightErrorResult(-11611, fmt::format("Empty value found after '{}' components were converted. Check for duplicate '{}' next to one another.", comp, k_DelimiterChar)); - } - - Result result = ConvertTo::convert(splitVals[comp]); - - if(result.invalid()) - { - return IFilter::MakePreflightErrorResult(-11612, fmt::format("Unable to process '{}' into a {} value.", splitVals[comp], DataTypeToString(GetDataType()))); - } - } - - if(splitVals.size() == expectedComp) - { - return {}; // Valid - } - - if(splitVals.size() == singleCompSize) - { - return {}; // Valid - } - - if(splitVals.size() == expectedComp + 1) - { - if(unfilteredStr.back() == k_DelimiterChar) - { - return IFilter::MakePreflightErrorResult(-11613, fmt::format("Remove the extra delimiter '{}' at the end of your value sequence: {}.", k_DelimiterChar, unfilteredStr)); - } - } - - return IFilter::MakePreflightErrorResult(-11614, - fmt::format("Using '{}' as a delimiter we are unable to break '{}' into the required {} components.", k_DelimiterChar, unfilteredStr, expectedComp)); - } -}; -} // namespace - namespace nx::core { //------------------------------------------------------------------------------ @@ -490,16 +124,16 @@ IFilter::UniquePointer InitializeDataFilter::clone() const } //------------------------------------------------------------------------------ -IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& args, const MessageHandler& messageHandler, +IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto seedArrayNameValue = args.value(k_SeedArrayName_Key); - auto initializeTypeValue = static_cast(args.value(k_InitType_Key)); + auto seedArrayNameValue = filterArgs.value(k_SeedArrayName_Key); + auto initializeTypeValue = static_cast(filterArgs.value(k_InitType_Key)); nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; - auto& iDataArray = dataStructure.getDataRefAs(args.value(k_ArrayPath_Key)); + auto& iDataArray = dataStructure.getDataRefAs(filterArgs.value(k_ArrayPath_Key)); usize numComp = iDataArray.getNumberOfComponents(); // check that the values string is greater than max comps if(iDataArray.getDataType() == DataType::boolean) @@ -548,7 +182,7 @@ IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure switch(initializeTypeValue) { case InitializeType::FillValue: { - auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, args.value(k_InitValue_Key), 1); + auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, filterArgs.value(k_InitValue_Key), 1); if(result.outputActions.invalid()) { return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; @@ -559,7 +193,7 @@ IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure break; } case InitializeType::Incremental: { - auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, args.value(k_StartingFillValue_Key), 1); + auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, filterArgs.value(k_StartingFillValue_Key), 1); if(result.outputActions.invalid()) { return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; @@ -573,7 +207,7 @@ IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure updatedValStrm << "We detected that you are doing an incremental operation on a boolean array.\n"; updatedValStrm << "For the step values please enter uint8 values, preferably a 0 or 1 only.\n"; - switch(static_cast(args.value(k_StepOperation_Key))) + switch(static_cast(filterArgs.value(k_StepOperation_Key))) { case Addition: { updatedValStrm << "You have currently selected the addition operation.\nAny step value that is greater than 0 will cause all values to be 'true' after the first tuple, 'true' " @@ -595,7 +229,7 @@ IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure preflightUpdatedValues.push_back({"Boolean Incremental Nuances", updatedValStrm.str()}); - result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, DataType::uint8, numComp, args.value(k_StepValue_Key), 1); + result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, DataType::uint8, numComp, filterArgs.value(k_StepValue_Key), 1); if(result.outputActions.invalid()) { return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; @@ -603,13 +237,13 @@ IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure } else { - result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, args.value(k_StepValue_Key), 1); + result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, filterArgs.value(k_StepValue_Key), 1); if(result.outputActions.invalid()) { return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; } } - auto values = StringUtilities::split(args.value(k_StepValue_Key), ";", false); + auto values = StringUtilities::split(filterArgs.value(k_StepValue_Key), ";", false); std::vector zeroIdx; for(size_t i = 0; i < values.size(); i++) { @@ -629,13 +263,13 @@ IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure break; } case InitializeType::RangedRandom: { - auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, args.value(k_InitStartRange_Key), 1); + auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, filterArgs.value(k_InitStartRange_Key), 1); if(result.outputActions.invalid()) { return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; } - result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, args.value(k_InitEndRange_Key), 1); + result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, iDataArray.getDataType(), numComp, filterArgs.value(k_InitEndRange_Key), 1); if(result.outputActions.invalid()) { return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; @@ -649,7 +283,7 @@ IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure if(numComp == 1) { - if(args.value(k_StandardizeSeed_Key)) + if(filterArgs.value(k_StandardizeSeed_Key)) { operationNuancesStrm << fmt::format("You chose to standardize the seed for each component, but the array {} is a single component so it will not alter the randomization scheme.", iDataArray.getName()); @@ -657,7 +291,7 @@ IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure } else { - if(args.value(k_StandardizeSeed_Key)) + if(filterArgs.value(k_StandardizeSeed_Key)) { operationNuancesStrm << "This generates THE SAME sequences of random numbers for each component in the array based on one seed.\n"; operationNuancesStrm << "The resulting array will look like | 1,1,1 | 9,9,9 | ...\n"; @@ -679,13 +313,13 @@ IFilter::PreflightResult InitializeDataFilter::preflightImpl(const DataStructure } //------------------------------------------------------------------------------ -Result<> InitializeDataFilter::executeImpl(DataStructure& dataStructure, const Arguments& args, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, +Result<> InitializeDataFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto initType = static_cast(args.value(k_InitType_Key)); + auto initType = static_cast(filterArgs.value(k_InitType_Key)); - auto seed = args.value(k_SeedValue_Key); - if(!args.value(k_UseSeed_Key)) + auto seed = filterArgs.value(k_SeedValue_Key); + if(!filterArgs.value(k_UseSeed_Key)) { seed = static_cast(std::chrono::steady_clock::now().time_since_epoch().count()); } @@ -693,25 +327,21 @@ Result<> InitializeDataFilter::executeImpl(DataStructure& dataStructure, const A if(initType == InitializeType::Random || initType == InitializeType::RangedRandom) { // Store Seed Value in Top Level Array - dataStructure.getDataRefAs(DataPath({args.value(k_SeedArrayName_Key)}))[0] = seed; + dataStructure.getDataRefAs(DataPath({filterArgs.value(k_SeedArrayName_Key)}))[0] = seed; } InitializeDataInputValues inputValues; - + inputValues.InputArrayPath = filterArgs.value(k_ArrayPath_Key); inputValues.initType = initType; - inputValues.stepType = static_cast(args.value(k_StepOperation_Key)); - inputValues.stringValues = StringUtilities::split(StringUtilities::trimmed(args.value(k_InitValue_Key)), k_DelimiterChar); - inputValues.startValues = StringUtilities::split(StringUtilities::trimmed(args.value(k_StartingFillValue_Key)), k_DelimiterChar); - inputValues.stepValues = StringUtilities::split(StringUtilities::trimmed(args.value(k_StepValue_Key)), k_DelimiterChar); + inputValues.stepType = static_cast(filterArgs.value(k_StepOperation_Key)); + inputValues.stringValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitValue_Key)), k_DelimiterChar); + inputValues.startValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_StartingFillValue_Key)), k_DelimiterChar); + inputValues.stepValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_StepValue_Key)), k_DelimiterChar); inputValues.seed = seed; - inputValues.randBegin = StringUtilities::split(StringUtilities::trimmed(args.value(k_InitStartRange_Key)), k_DelimiterChar); - inputValues.randEnd = StringUtilities::split(StringUtilities::trimmed(args.value(k_InitEndRange_Key)), k_DelimiterChar); - inputValues.standardizeSeed = args.value(k_StandardizeSeed_Key); - - auto& iDataArray = dataStructure.getDataRefAs(args.value(k_ArrayPath_Key)); - - ExecuteDataFunction(::FillArrayFunctor{}, iDataArray.getDataType(), iDataArray, inputValues); + inputValues.randBegin = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitStartRange_Key)), k_DelimiterChar); + inputValues.randEnd = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitEndRange_Key)), k_DelimiterChar); + inputValues.standardizeSeed = filterArgs.value(k_StandardizeSeed_Key); - return {}; + return InitializeData(dataStructure, messageHandler, shouldCancel, &inputValues)(); } } // namespace nx::core From 55feb8780cba88edcf22290013723c6d0e0d38e9 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Tue, 3 Sep 2024 17:40:07 -0400 Subject: [PATCH 02/10] Fix crashing bug. Initialization should be working correctly now. Signed-off-by: Michael Jackson --- .../Algorithms/ComputeArrayStatistics.cpp | 2 +- .../Filters/Algorithms/InitializeData.cpp | 6 ++-- .../Filters/Algorithms/InitializeData.hpp | 10 ++---- .../Filters/CreateDataArrayFilter.cpp | 31 +++++++++---------- .../Filters/CreateDataArrayFilter.hpp | 1 - .../Filters/InitializeDataFilter.cpp | 1 - .../src/SimplnxCore/utils/nanoflann.hpp | 2 +- .../SimplnxCore/test/CreateDataArrayTest.cpp | 22 ++++++------- .../SimplnxCore/wrapping/python/simplnxpy.cpp | 15 +++------ 9 files changed, 39 insertions(+), 51 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp index 09875f9fea..0e1747af32 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp @@ -271,7 +271,7 @@ class ComputeArrayStatisticsByIndexImpl histogram[m_NumBins - 1]++; } } // end of numTuples loop - } // end of increment else + } // end of increment else if(m_ModalBinRanges) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.cpp index c8befaa456..5545a09a9f 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.cpp @@ -2,11 +2,11 @@ #include "InitializeData.hpp" -#include "simplnx/Utilities/DataArrayUtilities.hpp" -#include "simplnx/Utilities/FilterUtilities.hpp" #include "simplnx/Common/TypeTraits.hpp" -#include "simplnx/DataStructure/IDataArray.hpp" #include "simplnx/DataStructure/AbstractDataStore.hpp" +#include "simplnx/DataStructure/IDataArray.hpp" +#include "simplnx/Utilities/DataArrayUtilities.hpp" +#include "simplnx/Utilities/FilterUtilities.hpp" #include #include diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.hpp index 3b2a620d23..7403460ab6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/InitializeData.hpp @@ -3,9 +3,8 @@ #include "SimplnxCore/SimplnxCore_export.hpp" #include "simplnx/Filter/IFilter.hpp" -#include "simplnx/Utilities/StringUtilities.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" - +#include "simplnx/Utilities/StringUtilities.hpp" namespace nx::core { @@ -40,7 +39,6 @@ struct SIMPLNXCORE_EXPORT InitializeDataInputValues bool standardizeSeed; }; - struct SIMPLNXCORE_EXPORT ValidateMultiInputFunctor { // The single comp size validation defaults to off as size 0 is checked earlier in the function @@ -92,13 +90,12 @@ struct SIMPLNXCORE_EXPORT ValidateMultiInputFunctor } }; - class InitializeData { public: InitializeData(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, InitializeDataInputValues* inputValues); ~InitializeData() noexcept; - + InitializeData(const InitializeData&) = delete; InitializeData(InitializeData&&) noexcept = delete; InitializeData& operator=(const InitializeData&) = delete; @@ -113,7 +110,6 @@ class InitializeData const InitializeDataInputValues* m_InputValues = nullptr; const std::atomic_bool& m_ShouldCancel; const IFilter::MessageHandler& m_MessageHandler; - }; -} +} // namespace nx::core diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp index b21912158d..3144c8e93d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp @@ -163,16 +163,16 @@ IFilter::PreflightResult CreateDataArrayFilter::preflightImpl(const DataStructur nx::core::Result resultOutputActions; -// if(initValue.empty()) -// { -// return MakePreflightErrorResult(k_EmptyParameterError, fmt::format("{}: Init Value cannot be empty.{}({})", humanName(), __FILE__, __LINE__)); -// } -// // Sanity check that what the user entered for an init value can be converted safely to the final numeric type -// Result<> result = CheckValueConverts(initValue, numericType); -// if(result.invalid()) -// { -// return {ConvertResultTo(std::move(result), {})}; -// } + // if(initValue.empty()) + // { + // return MakePreflightErrorResult(k_EmptyParameterError, fmt::format("{}: Init Value cannot be empty.{}({})", humanName(), __FILE__, __LINE__)); + // } + // // Sanity check that what the user entered for an init value can be converted safely to the final numeric type + // Result<> result = CheckValueConverts(initValue, numericType); + // if(result.invalid()) + // { + // return {ConvertResultTo(std::move(result), {})}; + // } std::vector compDims = std::vector{numComponents}; std::vector tupleDims = {}; @@ -220,10 +220,10 @@ IFilter::PreflightResult CreateDataArrayFilter::preflightImpl(const DataStructur auto seedArrayNameValue = filterArgs.value(k_SeedArrayName_Key); auto initializeTypeValue = static_cast(filterArgs.value(k_InitType_Key)); -// nx::core::Result resultOutputActions; + // nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; -// auto& iDataArray = dataStructure.getDataRefAs(filterArgs.value(k_ArrayPath_Key)); + // auto& iDataArray = dataStructure.getDataRefAs(filterArgs.value(k_ArrayPath_Key)); if(arrayDataType == DataType::boolean) { @@ -406,10 +406,9 @@ Result<> CreateDataArrayFilter::executeImpl(DataStructure& dataStructure, const const std::atomic_bool& shouldCancel) const { auto path = filterArgs.value(k_DataPath_Key); - auto initValue = filterArgs.value(k_InitializationValue_Key); - - ExecuteNeighborFunction(CreateAndInitArrayFunctor{}, ConvertNumericTypeToDataType(filterArgs.value(k_NumericType_Key)), dataStructure.getDataAs(path), initValue); + // auto initValue = filterArgs.value(k_InitializationValue_Key); + ExecuteNeighborFunction(CreateAndInitArrayFunctor{}, ConvertNumericTypeToDataType(filterArgs.value(k_NumericType_Key)), dataStructure.getDataAs(path), "0"); auto initType = static_cast(filterArgs.value(k_InitType_Key)); @@ -462,7 +461,7 @@ Result CreateDataArrayFilter::FromSIMPLJson(const nlohmann::json& jso results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_ScalarTypeKey, k_NumericType_Key)); results.push_back(SIMPLConversion::ConvertParameter>(args, json, SIMPL::k_NumberOfComponentsKey, k_NumComps_Key)); // Initialize Type parameter is not applicable in NX - results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_InitializationValueKey, k_InitializationValue_Key)); + results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_InitializationValueKey, k_InitValue_Key)); // Initialization Range parameter is not applicable in NX // Starting Index value parameter is not applicable in NX results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_NewArrayKey, k_DataPath_Key)); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp index 6b2ac76a08..997c7e3c6a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp @@ -26,7 +26,6 @@ class SIMPLNXCORE_EXPORT CreateDataArrayFilter : public IFilter static inline constexpr StringLiteral k_NumComps_Key = "component_count"; static inline constexpr StringLiteral k_TupleDims_Key = "tuple_dimensions"; static inline constexpr StringLiteral k_DataPath_Key = "output_array_path"; - static inline constexpr StringLiteral k_InitializationValue_Key = "initialization_value_str"; static inline constexpr StringLiteral k_DataFormat_Key = "data_format"; static inline constexpr StringLiteral k_InitType_Key = "init_type_index"; static inline constexpr StringLiteral k_InitValue_Key = "init_value"; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp index 3451cf87b6..4e6d307880 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp @@ -15,7 +15,6 @@ #include - #include #include #include diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp index 42fc0372fe..1d462f1c34 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp @@ -2205,7 +2205,7 @@ struct KDTreeEigenMatrixAdaptor /** @} */ }; // end of KDTreeEigenMatrixAdaptor - /** @} */ +/** @} */ /** @} */ // end of grouping } // namespace nanoflann diff --git a/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp b/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp index 41aa318dd4..700a88befc 100644 --- a/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp +++ b/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp @@ -46,7 +46,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(k_NComp)); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("-1")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("-1")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -57,7 +57,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(k_NComp)); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("1024")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1024")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -68,7 +68,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(0)); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("1")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -81,7 +81,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor DynamicTableInfo::TableDataType tupleDims = {{static_cast(0.0)}}; args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(tupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("1")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -93,7 +93,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor DynamicTableInfo::TableDataType tupleDims = {{static_cast(1.0)}}; args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(tupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -105,33 +105,33 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor DynamicTableInfo::TableDataType tupleDims = {{static_cast(1.0)}}; args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(tupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("1000")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1000")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::uint8)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("-1")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("-1")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int16)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("70000")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("70000")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::uint16)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("-1")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("-1")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int32)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("4294967297")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("4294967297")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int32)); - args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("-4294967297")); + args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("-4294967297")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); } diff --git a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp index 6821e4a83b..7f196cfbd2 100644 --- a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp +++ b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp @@ -584,8 +584,7 @@ PYBIND11_MODULE(simplnx, mod) parameters.def("insert_linkable_parameter", &PyInsertLinkableParameter); parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, BoolParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); }); parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, ChoicesParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); }); - parameters.def( - "__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal); + parameters.def("__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal); py::class_> iArrayThreshold(mod, "IArrayThreshold"); @@ -1422,12 +1421,10 @@ PYBIND11_MODULE(simplnx, mod) "path"_a); pipeline.def_property("name", &Pipeline::getName, &Pipeline::setName); pipeline.def("execute", &ExecutePipeline); - pipeline.def( - "__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal); + pipeline.def("__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal); pipeline.def("__len__", &Pipeline::size); pipeline.def("size", &Pipeline::size); - pipeline.def( - "__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>()); + pipeline.def("__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>()); pipeline.def( "insert", [internals](Pipeline& self, Pipeline::index_type index, const IFilter& filter, const py::dict& args) { @@ -1441,10 +1438,8 @@ PYBIND11_MODULE(simplnx, mod) pipeline.def("remove", &Pipeline::removeAt, "index"_a); pipelineFilter.def("get_args", [internals](PipelineFilter& self) { return ConvertArgsToDict(*internals, self.getParameters(), self.getArguments()); }); - pipelineFilter.def( - "set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a); - pipelineFilter.def( - "get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); + pipelineFilter.def("set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a); + pipelineFilter.def("get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); pipelineFilter.def( "name", [](const PipelineFilter& self) { From dbb64e5b0027097e93701d2b7711c9bdcb94b73e Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Wed, 4 Sep 2024 20:56:32 -0400 Subject: [PATCH 03/10] ClangFormat the code Signed-off-by: Michael Jackson --- .../ITKImageProcessing/Common/ITKArrayHelper.hpp | 3 ++- .../Filters/Algorithms/ComputeArrayStatistics.cpp | 2 +- .../SimplnxCore/wrapping/python/simplnxpy.cpp | 15 ++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp index 6d6d655f83..2b7e76bf1d 100644 --- a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp +++ b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp @@ -384,7 +384,8 @@ DataStore> ConvertImageToDataStore(itk::Image -concept NotBoolT = !std::is_same_v; +concept NotBoolT = ! +std::is_same_v; template Result<> ConvertImageToDataStore(DataStore& dataStore, itk::Image& image) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp index 0e1747af32..09875f9fea 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp @@ -271,7 +271,7 @@ class ComputeArrayStatisticsByIndexImpl histogram[m_NumBins - 1]++; } } // end of numTuples loop - } // end of increment else + } // end of increment else if(m_ModalBinRanges) { diff --git a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp index 7f196cfbd2..6821e4a83b 100644 --- a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp +++ b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp @@ -584,7 +584,8 @@ PYBIND11_MODULE(simplnx, mod) parameters.def("insert_linkable_parameter", &PyInsertLinkableParameter); parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, BoolParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); }); parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, ChoicesParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); }); - parameters.def("__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal); + parameters.def( + "__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal); py::class_> iArrayThreshold(mod, "IArrayThreshold"); @@ -1421,10 +1422,12 @@ PYBIND11_MODULE(simplnx, mod) "path"_a); pipeline.def_property("name", &Pipeline::getName, &Pipeline::setName); pipeline.def("execute", &ExecutePipeline); - pipeline.def("__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal); + pipeline.def( + "__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal); pipeline.def("__len__", &Pipeline::size); pipeline.def("size", &Pipeline::size); - pipeline.def("__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>()); + pipeline.def( + "__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>()); pipeline.def( "insert", [internals](Pipeline& self, Pipeline::index_type index, const IFilter& filter, const py::dict& args) { @@ -1438,8 +1441,10 @@ PYBIND11_MODULE(simplnx, mod) pipeline.def("remove", &Pipeline::removeAt, "index"_a); pipelineFilter.def("get_args", [internals](PipelineFilter& self) { return ConvertArgsToDict(*internals, self.getParameters(), self.getArguments()); }); - pipelineFilter.def("set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a); - pipelineFilter.def("get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); + pipelineFilter.def( + "set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a); + pipelineFilter.def( + "get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); pipelineFilter.def( "name", [](const PipelineFilter& self) { From 4a1825027cb9d6a5b99a33a0337422abdbf4d333 Mon Sep 17 00:00:00 2001 From: Joey Kleingers Date: Fri, 6 Sep 2024 15:43:41 -0400 Subject: [PATCH 04/10] Update CreateDataArray to require comp dims instead of number of comps. Signed-off-by: Joey Kleingers --- .../SimplnxCore/docs/CreateDataArrayFilter.md | 5 +- .../Filters/CreateDataArrayFilter.cpp | 52 ++++++++++--------- .../Filters/CreateDataArrayFilter.hpp | 3 +- .../SimplnxCore/test/CreateDataArrayTest.cpp | 14 ++--- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/Plugins/SimplnxCore/docs/CreateDataArrayFilter.md b/src/Plugins/SimplnxCore/docs/CreateDataArrayFilter.md index 9d4ee58da9..ba5b092cfa 100644 --- a/src/Plugins/SimplnxCore/docs/CreateDataArrayFilter.md +++ b/src/Plugins/SimplnxCore/docs/CreateDataArrayFilter.md @@ -6,7 +6,7 @@ Core (Generation) ## Description -This **Filter** creates an **Data Array** of any primitive type with any number of components along a *single component dimension*. For example, a scalar as (1) or a 3-vector as (3), but *not* a matrix as (3, 3). The array is initialized to a user define value or with random values within a specified range. +This **Filter** creates a **Data Array** of any primitive type with any set of component dimensions. The array is initialized to a user define value or with random values within a specified range. When initializing a multicomponent array square bracket notation can be used to specify different initialization values for each component. For example say that I want to intialize a 2 component array where the first component is 0 and the second component is 1 we would use the following input string for the *Initialization Value* @@ -52,8 +52,7 @@ If the parent is **NOT an Attribute Matrix**, then the user ***MUST*** set the t | Double | 64 bit | -1.7e+308 to -2.2e-308, 0.0, 2.2e-308 to 1.7e+308 (15 digits)| | Boolean | 8 bit |0 = false and any other value will be forced to 1 = true| -The number of components should be at least 1. Examples of *Number of Components* would be 3 for an RGB Image, 1 for a gray scale image, 1 for a scalar array, 4 for a quaternions array, etc. All values of the array will be initialized to the user set value. The initialization value text box -must have a user entry or the default value *0* will be used. +The component dimensions should multiply together into a total number of components equal to at least 1. Examples of *Component Dimensions* would be [3] for an RGB Image, [1] for a gray scale image, [1] for a scalar array, [4] for a quaternions array, [10x5] for an array with 10x5 grids at each tuple, etc. All values of the array will be initialized using the chosen initialization option. % Auto generated parameter table will be inserted here diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp index 3144c8e93d..af61b3ceba 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp @@ -73,8 +73,14 @@ Parameters CreateDataArrayFilter::parameters() const params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); params.insert(std::make_unique(k_NumericType_Key, "Output Numeric Type", "Numeric Type of data to create", NumericType::int32)); - // params.insert(std::make_unique(k_InitializationValue_Key, "Initialization Value", "This value will be used to fill the new array", "0")); - params.insert(std::make_unique(k_NumComps_Key, "Number of Components", "Number of components", 1)); + + params.insertSeparator(Parameters::Separator{"Component Handling"}); + { + DynamicTableInfo tableInfo; + tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); + tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "COMP DIM {}")); + params.insert(std::make_unique(k_CompDims_Key, "Data Array Component Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Dimensions.", tableInfo)); + } params.insertSeparator(Parameters::Separator{"Initialization Options"}); params.insertLinkableParameter(std::make_unique(k_InitType_Key, "Initialization Type", "Method for determining the what values of the data in the array should be initialized to", @@ -108,12 +114,14 @@ Parameters CreateDataArrayFilter::parameters() const params.insertLinkableParameter(std::make_unique( k_AdvancedOptions_Key, "Set Tuple Dimensions [not required if creating inside an Attribute Matrix]", "This allows the user to set the tuple dimensions directly rather than just inheriting them. This option is NOT required if you are creating the Data Array in an Attribute Matrix", true)); - DynamicTableInfo tableInfo; - tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); - tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "DIM {}")); - params.insert(std::make_unique(k_TupleDims_Key, "Data Array Dimensions (Slowest to Fastest Dimensions)", - "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", tableInfo)); + { + DynamicTableInfo tableInfo; + tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); + tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "TUPLE DIM {}")); + params.insert(std::make_unique(k_TupleDims_Key, "Data Array Tuple Dimensions (Slowest to Fastest Dimensions)", + "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", tableInfo)); + } // Associate the Linkable Parameter(s) to the children parameters that they control params.linkParameters(k_AdvancedOptions_Key, k_TupleDims_Key, true); @@ -155,26 +163,24 @@ IFilter::PreflightResult CreateDataArrayFilter::preflightImpl(const DataStructur { auto useDims = filterArgs.value(k_AdvancedOptions_Key); auto numericType = filterArgs.value(k_NumericType_Key); - auto numComponents = filterArgs.value(k_NumComps_Key); + auto compDimsData = filterArgs.value(k_CompDims_Key); auto dataArrayPath = filterArgs.value(k_DataPath_Key); auto tableData = filterArgs.value(k_TupleDims_Key); auto dataFormat = filterArgs.value(k_DataFormat_Key); - // auto initValue = filterArgs.value(k_InitializationValue_Key); nx::core::Result resultOutputActions; - // if(initValue.empty()) - // { - // return MakePreflightErrorResult(k_EmptyParameterError, fmt::format("{}: Init Value cannot be empty.{}({})", humanName(), __FILE__, __LINE__)); - // } - // // Sanity check that what the user entered for an init value can be converted safely to the final numeric type - // Result<> result = CheckValueConverts(initValue, numericType); - // if(result.invalid()) - // { - // return {ConvertResultTo(std::move(result), {})}; - // } - - std::vector compDims = std::vector{numComponents}; + std::vector compDims(compDimsData[0].size()); + std::transform(compDimsData[0].begin(), compDimsData[0].end(), compDims.begin(), [](double val) { return static_cast(val); }); + usize numComponents = std::accumulate(compDims.begin(), compDims.end(), static_cast(1), std::multiplies<>()); + if(numComponents <= 0) + { + std::string compDimsStr = std::accumulate(compDims.begin() + 1, compDims.end(), std::to_string(compDims[0]), [](const std::string& a, int b) { return a + " x " + std::to_string(b); }); + return MakePreflightErrorResult( + -78601, + fmt::format("The chosen component dimensions ({}) results in 0 total components. Please choose component dimensions that result in a positive number of total components.", compDimsStr)); + } + std::vector tupleDims = {}; auto* parentAM = dataStructure.getDataAs(dataArrayPath.getParent()); @@ -223,8 +229,6 @@ IFilter::PreflightResult CreateDataArrayFilter::preflightImpl(const DataStructur // nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; - // auto& iDataArray = dataStructure.getDataRefAs(filterArgs.value(k_ArrayPath_Key)); - if(arrayDataType == DataType::boolean) { std::stringstream updatedValStrm; @@ -406,7 +410,6 @@ Result<> CreateDataArrayFilter::executeImpl(DataStructure& dataStructure, const const std::atomic_bool& shouldCancel) const { auto path = filterArgs.value(k_DataPath_Key); - // auto initValue = filterArgs.value(k_InitializationValue_Key); ExecuteNeighborFunction(CreateAndInitArrayFunctor{}, ConvertNumericTypeToDataType(filterArgs.value(k_NumericType_Key)), dataStructure.getDataAs(path), "0"); @@ -459,7 +462,6 @@ Result CreateDataArrayFilter::FromSIMPLJson(const nlohmann::json& jso std::vector> results; results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_ScalarTypeKey, k_NumericType_Key)); - results.push_back(SIMPLConversion::ConvertParameter>(args, json, SIMPL::k_NumberOfComponentsKey, k_NumComps_Key)); // Initialize Type parameter is not applicable in NX results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_InitializationValueKey, k_InitValue_Key)); // Initialization Range parameter is not applicable in NX diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp index 997c7e3c6a..8ebcccdf62 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp @@ -23,7 +23,8 @@ class SIMPLNXCORE_EXPORT CreateDataArrayFilter : public IFilter // Parameter Keys static inline constexpr StringLiteral k_NumericType_Key = "numeric_type_index"; static inline constexpr StringLiteral k_AdvancedOptions_Key = "set_tuple_dimensions"; - static inline constexpr StringLiteral k_NumComps_Key = "component_count"; + // static inline constexpr StringLiteral k_NumComps_Key = "component_count"; + static inline constexpr StringLiteral k_CompDims_Key = "component_dimensions"; static inline constexpr StringLiteral k_TupleDims_Key = "tuple_dimensions"; static inline constexpr StringLiteral k_DataPath_Key = "output_array_path"; static inline constexpr StringLiteral k_DataFormat_Key = "data_format"; diff --git a/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp b/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp index 700a88befc..bd6cfa76ee 100644 --- a/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp +++ b/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp @@ -21,7 +21,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Instantiate)", "[SimplnxCore][Crea Arguments args; args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int32)); - args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(k_NComp)); + args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{static_cast(k_NComp)}})); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); @@ -43,7 +43,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section1") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::uint16)); - args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(k_NComp)); + args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{static_cast(k_NComp)}})); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("-1")); @@ -54,7 +54,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section2") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int8)); - args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(k_NComp)); + args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{static_cast(k_NComp)}})); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1024")); @@ -65,7 +65,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section3") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::float32)); - args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(0)); + args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{0.0}})); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1")); @@ -76,7 +76,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section4") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::float32)); - args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(1)); + args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{1.0}})); DynamicTableInfo::TableDataType tupleDims = {{static_cast(0.0)}}; args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(tupleDims)); @@ -89,7 +89,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section5") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int8)); - args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(1)); + args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{1.0}})); DynamicTableInfo::TableDataType tupleDims = {{static_cast(1.0)}}; args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(tupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); @@ -101,7 +101,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section6") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int8)); - args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(1)); + args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{1.0}})); DynamicTableInfo::TableDataType tupleDims = {{static_cast(1.0)}}; args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(tupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); From 272c2538bf1a117c237cb414ebe92ff10c4d982c Mon Sep 17 00:00:00 2001 From: Joey Kleingers Date: Fri, 6 Sep 2024 15:51:30 -0400 Subject: [PATCH 05/10] Clang format. Signed-off-by: Joey Kleingers --- .../src/ITKImageProcessing/Common/ITKArrayHelper.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp index 2b7e76bf1d..6d6d655f83 100644 --- a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp +++ b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp @@ -384,8 +384,7 @@ DataStore> ConvertImageToDataStore(itk::Image -concept NotBoolT = ! -std::is_same_v; +concept NotBoolT = !std::is_same_v; template Result<> ConvertImageToDataStore(DataStore& dataStore, itk::Image& image) From f44021657dc2e28f50d680841606358cbe7bc9f3 Mon Sep 17 00:00:00 2001 From: Joey Kleingers Date: Sat, 7 Sep 2024 11:55:59 -0400 Subject: [PATCH 06/10] Fix example pipelines, python files, unit tests. Signed-off-by: Joey Kleingers --- .../(02) Image Segmentation.d3dpipeline | 71 ++++++++++---- .../(04) Porosity Analysis.d3dpipeline | 33 +++++-- .../pipelines/EnsembleInfoReader.d3dpipeline | 41 +++++--- .../ApplyTransformation_Demo.d3dpipeline | 28 ++++-- .../ArrayCalculatorExample.d3dpipeline | 95 ++++++++++++++----- .../pipelines/CreateEdgeGeom.d3dpipeline | 40 ++++++-- .../CreateHexahedralGeom.d3dpipeline | 40 ++++++-- .../pipelines/CreateImageGeom.d3dpipeline | 40 ++++++-- .../pipelines/CreateQuadGeom.d3dpipeline | 40 ++++++-- .../pipelines/CreateRectGridGeom.d3dpipeline | 40 ++++++-- .../CreateTetrahedralGeom.d3dpipeline | 40 ++++++-- .../pipelines/CreateTriangleGeom.d3dpipeline | 40 ++++++-- .../pipelines/CreateVertexGeom.d3dpipeline | 40 ++++++-- .../pipelines/Import_CSV_File.d3dpipeline | 44 ++++++--- .../pipelines/Import_STL_Model.d3dpipeline | 38 ++++++-- .../Filters/CreateDataArrayFilter.cpp | 14 +-- .../Filters/CreateDataArrayFilter.hpp | 1 - .../SimplnxCore/test/DREAM3DFileTest.cpp | 4 +- .../Filters/CreateOutOfCoreArrayFilter.hpp | 2 +- wrapping/python/docs/source/DataObjects.rst | 17 ++-- .../docs/source/Python_Introduction.rst | 24 ++--- wrapping/python/docs/source/Tutorial_1.rst | 4 +- wrapping/python/docs/source/Tutorial_2.rst | 2 +- .../source/release_notes/ReleaseNotes_121.rst | 4 +- .../examples/notebooks/angle_conversion.ipynb | 4 +- .../examples/notebooks/basic_arrays.ipynb | 12 +-- .../examples/notebooks/basic_numpy.ipynb | 4 +- .../notebooks/create_image_geom.ipynb | 4 +- .../examples/notebooks/output_file.ipynb | 4 +- .../python/examples/notebooks/pipeline.ipynb | 4 +- .../02_Image_Segmentation.py | 4 +- .../Simplnx/ApplyTransformation_Demo.py | 4 +- .../Simplnx/ArrayCalculatorExample.py | 12 +-- .../pipelines/Simplnx/EnsembleInfoReader.py | 4 +- .../pipelines/Simplnx/Import_ASCII.py | 4 +- .../pipelines/Simplnx/Import_STL_Model.py | 4 +- .../examples/scripts/angle_conversion.py | 6 +- .../python/examples/scripts/basic_arrays.py | 12 +-- .../python/examples/scripts/basic_numpy.py | 4 +- .../examples/scripts/geometry_examples.py | 60 ++++++------ .../python/examples/scripts/output_file.py | 2 +- .../src/ExamplePlugin/CreateArray.py | 2 +- 42 files changed, 646 insertions(+), 246 deletions(-) diff --git a/src/Plugins/ITKImageProcessing/pipelines/(02) Image Segmentation.d3dpipeline b/src/Plugins/ITKImageProcessing/pipelines/(02) Image Segmentation.d3dpipeline index 7f8e440c19..4dfaaa6265 100644 --- a/src/Plugins/ITKImageProcessing/pipelines/(02) Image Segmentation.d3dpipeline +++ b/src/Plugins/ITKImageProcessing/pipelines/(02) Image Segmentation.d3dpipeline @@ -6,8 +6,15 @@ { "args": { "cell_attribute_matrix_name": "Cell Data", + "change_image_data_type": false, + "color_weights": [ + 0.21250000596046448, + 0.715399980545044, + 0.07209999859333038 + ], + "convert_to_gray_scale": false, "image_data_array_name": "ImageData", - "output_image_geometry_path": "ImageDataContainer", + "image_data_type_index": 0, "image_transform_index": 0, "input_file_list_object": { "end_index": 174, @@ -25,6 +32,9 @@ 0.0, 0.0 ], + "output_image_geometry_path": "ImageDataContainer", + "scale_images": false, + "scaling": 1.0, "spacing": [ 1.0, 1.0, @@ -33,7 +43,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ITKImportImageStack", + "name": "nx::core::ITKImportImageStackFilter", "uuid": "dcf980b7-ecca-46d1-af31-ac65f6e3b6bb" }, "isDisabled": false @@ -55,11 +65,16 @@ "type": "collection", "union": 0 }, - "output_data_array_name": "Mask" + "created_mask_type": 10, + "custom_false_value": 0.0, + "custom_true_value": 1.0, + "output_data_array_name": "Mask", + "use_custom_false_value": false, + "use_custom_true_value": false }, "comments": "", "filter": { - "name": "simplnx::MultiThresholdObjects", + "name": "nx::core::MultiThresholdObjectsFilter", "uuid": "4246245e-1011-4add-8436-0af6bed19228" }, "isDisabled": false @@ -69,8 +84,8 @@ "active_array_name": "Active", "cell_feature_group_name": "Cell Feature Data", "feature_ids_name": "FeatureIds", - "input_image_geometry_path": "ImageDataContainer", "input_array_path": "ImageDataContainer/Cell Data/ImageData", + "input_image_geometry_path": "ImageDataContainer", "mask_path": "ImageDataContainer/Cell Data/Mask", "randomize_features": true, "scalar_tolerance": 0, @@ -78,7 +93,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ScalarSegmentFeaturesFilter", + "name": "nx::core::ScalarSegmentFeaturesFilter", "uuid": "e067cd97-9bbf-4c92-89a6-3cb4fdb76c93" }, "isDisabled": false @@ -95,7 +110,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ComputeFeatureSizesFilter", + "name": "nx::core::ComputeFeatureSizesFilter", "uuid": "c666ee17-ca58-4969-80d0-819986c72485" }, "isDisabled": false @@ -104,34 +119,50 @@ "args": { "created_array_suffix": "", "feature_ids_path": "ImageDataContainer/Cell Data/FeatureIds", - "selected_feature_array_paths": ["ImageDataContainer/Cell Feature Data/EquivalentDiameters"] + "selected_feature_array_paths": [ + "ImageDataContainer/Cell Feature Data/EquivalentDiameters" + ] }, "comments": "", "filter": { - "name": "simplnx::CopyFeatureArrayToElementArrayFilter", + "name": "nx::core::CopyFeatureArrayToElementArrayFilter", "uuid": "4c8c976a-993d-438b-bd8e-99f71114b9a1" }, "isDisabled": false }, { "args": { - "set_tuple_dimensions": false, - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "1", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "1", "numeric_type_index": 4, "output_array_path": "ImageDataContainer/Cell Data/Phases", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, + "set_tuple_dimensions": false, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 164.0, 390.0, 524.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { - "name": "simplnx::CreateDataArrayFilter", + "name": "nx::core::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false @@ -139,6 +170,7 @@ { "args": { "conditional_array_path": "ImageDataContainer/Cell Data/Mask", + "invert_mask": false, "remove_value": "0", "replace_value": "2", "selected_array_path": "ImageDataContainer/Cell Data/Phases", @@ -146,7 +178,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ConditionalSetValueFilter", + "name": "nx::core::ConditionalSetValueFilter", "uuid": "bad9b7bd-1dc9-4f21-a889-6520e7a41881" }, "isDisabled": false @@ -160,7 +192,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ComputeFeaturePhasesFilter", + "name": "nx::core::ComputeFeaturePhasesFilter", "uuid": "da5bb20e-4a8e-49d9-9434-fbab7bc434fc" }, "isDisabled": false @@ -174,7 +206,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ComputeFeatureCentroidsFilter", + "name": "nx::core::ComputeFeatureCentroidsFilter", "uuid": "c6875ac7-8bdd-4f69-b6ce-82ac09bd3421" }, "isDisabled": false @@ -190,7 +222,7 @@ }, "comments": "", "filter": { - "name": "simplnx::CreateAttributeMatrixFilter", + "name": "nx::core::CreateAttributeMatrixFilter", "uuid": "a6a28355-ee69-4874-bcac-76ed427423ed" }, "isDisabled": false @@ -202,11 +234,12 @@ }, "comments": "", "filter": { - "name": "simplnx::WriteDREAM3DFilter", + "name": "nx::core::WriteDREAM3DFilter", "uuid": "b3a95784-2ced-41ec-8d3d-0242ac130003" }, "isDisabled": false } ], + "version": 1, "workflowParams": [] } diff --git a/src/Plugins/ITKImageProcessing/pipelines/(04) Porosity Analysis.d3dpipeline b/src/Plugins/ITKImageProcessing/pipelines/(04) Porosity Analysis.d3dpipeline index 3d578c5843..df3d581637 100644 --- a/src/Plugins/ITKImageProcessing/pipelines/(04) Porosity Analysis.d3dpipeline +++ b/src/Plugins/ITKImageProcessing/pipelines/(04) Porosity Analysis.d3dpipeline @@ -1,10 +1,12 @@ { "isDisabled": false, - "name": "(04) Porosity Analysis", + "name": "(04) Porosity Analysis.d3dpipeline", + "pinnedParams": [], "pipeline": [ { "args": { "cell_attribute_matrix_name": "Optical Data", + "change_image_data_type": false, "color_weights": [ 0.21250000596046448, 0.715399980545044, @@ -12,6 +14,7 @@ ], "convert_to_gray_scale": false, "image_data_array_name": "ImageData", + "image_data_type_index": 0, "image_transform_index": 0, "input_file_list_object": { "end_index": 174, @@ -30,6 +33,8 @@ 0.0 ], "output_image_geometry_path": "RoboMet.3D Image Stack", + "scale_images": false, + "scaling": 1.0, "spacing": [ 1.0, 1.0, @@ -127,17 +132,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "1", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "1", "numeric_type_index": 4, "output_array_path": "RoboMet.3D Image Stack/Optical Data/Phases", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": false, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -212,7 +231,6 @@ "cell_ensemble_attribute_matrix_path": "RoboMet.3D Image Stack/Ensemble Data", "centroids_array_path": "RoboMet.3D Image Stack/Pore Data/Centroids", "clustering_list_array_name": "ClusteringList", - "equivalent_diameters_array_path": "RoboMet.3D Image Stack/Pore Data/EquivalentDiameters", "feature_phases_array_path": "RoboMet.3D Image Stack/Pore Data/Phases", "input_image_geometry_path": "RoboMet.3D Image Stack", "max_min_array_name": "RDFMaxMinDistances", @@ -244,5 +262,6 @@ "isDisabled": false } ], - "version": 1 -} \ No newline at end of file + "version": 1, + "workflowParams": [] +} diff --git a/src/Plugins/OrientationAnalysis/pipelines/EnsembleInfoReader.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EnsembleInfoReader.d3dpipeline index eab706dee4..d56394ae55 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EnsembleInfoReader.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EnsembleInfoReader.d3dpipeline @@ -1,6 +1,6 @@ { "isDisabled": false, - "name": "ReadEnsembleInfo.d3dpipeline", + "name": "EnsembleInfoReader.d3dpipeline", "pinnedParams": [], "pipeline": [ { @@ -11,12 +11,12 @@ 100, 2 ], - "output_image_geometry_path": "[Image Geometry]", "origin": [ 0.0, 0.0, 0.0 ], + "output_image_geometry_path": "[Image Geometry]", "spacing": [ 1.0, 1.0, @@ -25,7 +25,7 @@ }, "comments": "", "filter": { - "name": "simplnx::CreateImageGeometryFilter", + "name": "nx::core::CreateImageGeometryFilter", "uuid": "c4320659-1a84-461d-939e-c7c10229a504" }, "isDisabled": false @@ -48,7 +48,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ReadRawBinaryFilter", + "name": "nx::core::ReadRawBinaryFilter", "uuid": "dd159366-5f12-42db-af6d-a33592ae8a89" }, "isDisabled": false @@ -62,28 +62,44 @@ }, "comments": "", "filter": { - "name": "simplnx::ConvertOrientations", + "name": "nx::core::ConvertOrientationsFilter", "uuid": "501e54e6-a66f-4eeb-ae37-00e649c00d4b" }, "isDisabled": false }, { "args": { - "component_count": 1, - "initialization_value_str": "1", + "component_dimensions": [ + [ + 1.0 + ] + ], + "data_format": "", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "1", "numeric_type_index": 4, "output_array_path": "[Image Geometry]/Cell Data/Phases", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, + "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 2.0, 100.0, 100.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { - "name": "simplnx::CreateDataArrayFilter", + "name": "nx::core::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false @@ -98,7 +114,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ReadEnsembleInfoFilter", + "name": "nx::core::ReadEnsembleInfoFilter", "uuid": "ecf1ec45-bc27-4ddb-b2c0-3d465b8c182a" }, "isDisabled": false @@ -119,7 +135,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ComputeIPFColorsFilter", + "name": "nx::core::ComputeIPFColorsFilter", "uuid": "64cb4f27-6e5e-4dd2-8a03-0c448cb8f5e6" }, "isDisabled": false @@ -131,11 +147,12 @@ }, "comments": "", "filter": { - "name": "simplnx::WriteDREAM3DFilter", + "name": "nx::core::WriteDREAM3DFilter", "uuid": "b3a95784-2ced-41ec-8d3d-0242ac130003" }, "isDisabled": false } ], + "version": 1, "workflowParams": [] } diff --git a/src/Plugins/SimplnxCore/pipelines/ApplyTransformation_Demo.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/ApplyTransformation_Demo.d3dpipeline index 0df9fc92ba..0508c4f30a 100644 --- a/src/Plugins/SimplnxCore/pipelines/ApplyTransformation_Demo.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/ApplyTransformation_Demo.d3dpipeline @@ -1,6 +1,7 @@ { "isDisabled": false, - "name": "Apply Transformation To Geometry Demo", + "name": "ApplyTransformation_Demo.d3dpipeline", + "pinnedParams": [], "pipeline": [ { "args": { @@ -47,19 +48,33 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "2", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "2", "numeric_type_index": 4, "output_array_path": "Geometry/Cell Data/Data", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": false, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 2.0, 10.0, 10.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -127,5 +142,6 @@ "isDisabled": false } ], - "version": 1 -} \ No newline at end of file + "version": 1, + "workflowParams": [] +} diff --git a/src/Plugins/SimplnxCore/pipelines/ArrayCalculatorExample.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/ArrayCalculatorExample.d3dpipeline index 51e5b64ebc..ea5c0e5ffa 100644 --- a/src/Plugins/SimplnxCore/pipelines/ArrayCalculatorExample.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/ArrayCalculatorExample.d3dpipeline @@ -1,60 +1,109 @@ { "isDisabled": false, - "name": "Untitled Pipeline", + "name": "ArrayCalculatorExample.d3dpipeline", + "pinnedParams": [], "pipeline": [ { "args": { - "component_count": 1, - "initialization_value_str": "2", + "component_dimensions": [ + [ + 1.0 + ] + ], + "data_format": "", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "2", "numeric_type_index": 4, "output_array_path": "TestArray", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, + "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 10.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { - "name": "simplnx::CreateDataArrayFilter", + "name": "nx::core::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false }, { "args": { - "component_count": 1, - "initialization_value_str": "1.23878", + "component_dimensions": [ + [ + 1.0 + ] + ], + "data_format": "", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "1.23878", "numeric_type_index": 8, "output_array_path": "Confidence Index", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, + "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 10.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { - "name": "simplnx::CreateDataArrayFilter", + "name": "nx::core::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false }, { "args": { - "component_count": 3, - "initialization_value_str": "1.23878", + "component_dimensions": [ + [ + 3.0 + ] + ], + "data_format": "", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "1.23878", "numeric_type_index": 8, "output_array_path": "EulerAngles", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, + "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 10.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { - "name": "simplnx::CreateDataArrayFilter", + "name": "nx::core::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false @@ -71,7 +120,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ArrayCalculatorFilter", + "name": "nx::core::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -88,7 +137,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ArrayCalculatorFilter", + "name": "nx::core::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -105,7 +154,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ArrayCalculatorFilter", + "name": "nx::core::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -122,7 +171,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ArrayCalculatorFilter", + "name": "nx::core::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -139,7 +188,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ArrayCalculatorFilter", + "name": "nx::core::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -156,7 +205,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ArrayCalculatorFilter", + "name": "nx::core::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -168,10 +217,12 @@ }, "comments": "", "filter": { - "name": "simplnx::WriteDREAM3DFilter", + "name": "nx::core::WriteDREAM3DFilter", "uuid": "b3a95784-2ced-41ec-8d3d-0242ac130003" }, "isDisabled": false } - ] -} \ No newline at end of file + ], + "version": 1, + "workflowParams": [] +} diff --git a/src/Plugins/SimplnxCore/pipelines/CreateEdgeGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateEdgeGeom.d3dpipeline index 29ee3bb56b..bc4b558153 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateEdgeGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateEdgeGeom.d3dpipeline @@ -155,17 +155,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Edge Data/Int32Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -198,17 +212,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Edge Data/Int64Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateHexahedralGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateHexahedralGeom.d3dpipeline index 3878797320..c70a6e08db 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateHexahedralGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateHexahedralGeom.d3dpipeline @@ -173,17 +173,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Cell Data/Int32Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -216,17 +230,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Cell Data/Int64Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateImageGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateImageGeom.d3dpipeline index de5010f239..acffcbbb2f 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateImageGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateImageGeom.d3dpipeline @@ -48,17 +48,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 4, "output_array_path": "Image Geometry/Cell Data/Int32Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -91,17 +105,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 6, "output_array_path": "Image Geometry/Cell Data/Int64Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateQuadGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateQuadGeom.d3dpipeline index 22e07a97bb..7d805a4447 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateQuadGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateQuadGeom.d3dpipeline @@ -161,17 +161,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Face Data/Int32Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -204,17 +218,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Face Data/Int64Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateRectGridGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateRectGridGeom.d3dpipeline index 43f2b04b90..ab5102a93f 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateRectGridGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateRectGridGeom.d3dpipeline @@ -85,17 +85,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Cell Data/Int32Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -128,17 +142,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Cell Data/Int64Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateTetrahedralGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateTetrahedralGeom.d3dpipeline index c1237a6ee9..44719460ff 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateTetrahedralGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateTetrahedralGeom.d3dpipeline @@ -161,17 +161,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Cell Data/Int32Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -204,17 +218,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Cell Data/Int64Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateTriangleGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateTriangleGeom.d3dpipeline index fe4a137f90..efbf97feb7 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateTriangleGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateTriangleGeom.d3dpipeline @@ -158,17 +158,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Face Data/Int32Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -201,17 +215,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Face Data/Int64Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateVertexGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateVertexGeom.d3dpipeline index f461a6c40a..bdaa18160c 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateVertexGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateVertexGeom.d3dpipeline @@ -103,17 +103,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Vertex Data/Int32Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -146,17 +160,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "0", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Vertex Data/Int64Array", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/Import_CSV_File.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/Import_CSV_File.d3dpipeline index 3c24c32fac..2945eda819 100644 --- a/src/Plugins/SimplnxCore/pipelines/Import_CSV_File.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/Import_CSV_File.d3dpipeline @@ -1,6 +1,7 @@ { "isDisabled": false, - "name": "Import CSV File", + "name": "Import_CSV_File.d3dpipeline", + "pinnedParams": [], "pipeline": [ { "args": { @@ -72,7 +73,7 @@ 480000 ] }, - "selected_attribute_matrix_path": "[Image Geometry]/Cell Data/", + "selected_attribute_matrix_path": "[Image Geometry]/Cell Data", "use_existing_group": true }, "comments": "", @@ -85,9 +86,9 @@ { "args": { "input_data_array_paths": [ - "[Image Geometry]/Cell Data//phi1", - "[Image Geometry]/Cell Data//Phi", - "[Image Geometry]/Cell Data//phi2" + "[Image Geometry]/Cell Data/phi1", + "[Image Geometry]/Cell Data/Phi", + "[Image Geometry]/Cell Data/phi2" ], "move_values": true, "normalize_data": false, @@ -123,17 +124,31 @@ }, { "args": { - "component_count": 1, + "component_dimensions": [ + [ + 1.0 + ] + ], "data_format": "", - "initialization_value_str": "1", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "1", "numeric_type_index": 4, - "output_array_path": "[Image Geometry]/Cell Data//Phases", + "output_array_path": "[Image Geometry]/Cell Data/Phases", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { @@ -144,9 +159,9 @@ }, { "args": { - "cell_euler_angles_array_path": "[Image Geometry]/Cell Data//Eulers", + "cell_euler_angles_array_path": "[Image Geometry]/Cell Data/Eulers", "cell_ipf_colors_array_name": "IPFColors", - "cell_phases_array_path": "[Image Geometry]/Cell Data//Phases", + "cell_phases_array_path": "[Image Geometry]/Cell Data/Phases", "crystal_structures_array_path": "[Image Geometry]/EnsembleAttributeMatrix/CrystalStructures", "mask_array_path": "", "reference_dir": [ @@ -166,7 +181,7 @@ { "args": { "file_name": "Data/Output/Import_CSV_Example/Import_ASCII_IPF.png", - "image_array_path": "[Image Geometry]/Cell Data//IPFColors", + "image_array_path": "[Image Geometry]/Cell Data/IPFColors", "index_offset": 0, "input_image_geometry_path": "[Image Geometry]", "plane_index": 0 @@ -179,5 +194,6 @@ "isDisabled": false } ], - "version": 1 -} \ No newline at end of file + "version": 1, + "workflowParams": [] +} diff --git a/src/Plugins/SimplnxCore/pipelines/Import_STL_Model.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/Import_STL_Model.d3dpipeline index ddbb0fc4f3..657b7a4047 100644 --- a/src/Plugins/SimplnxCore/pipelines/Import_STL_Model.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/Import_STL_Model.d3dpipeline @@ -5,49 +5,69 @@ "pipeline": [ { "args": { + "face_attribute_matrix_name": "Face Data", + "face_normals_name": "Face Normals", "output_triangle_geometry_path": "[Triangle Geometry]", "scale_factor": 1.0, "scale_output": false, - "stl_file_path": "Data/STL_Models/Cylinder.stl" + "stl_file_path": "Data/STL_Models/Cylinder.stl", + "vertex_attribute_matrix_name": "Vertex Data" }, "comments": "", "filter": { - "name": "simplnx::ReadStlFileFilter", + "name": "nx::core::ReadStlFileFilter", "uuid": "2f64bd45-9d28-4254-9e07-6aa7c6d3d015" }, "isDisabled": false }, { "args": { - "triangle_areas_array_name": "Areas", - "input_triangle_geometry_path": "[Triangle Geometry]" + "input_triangle_geometry_path": "[Triangle Geometry]", + "triangle_areas_array_name": "Areas" }, "comments": "", "filter": { - "name": "simplnx::ComputeTriangleAreasFilter", + "name": "nx::core::ComputeTriangleAreasFilter", "uuid": "b149addd-c0c8-4010-a264-596005eaf2a5" }, "isDisabled": false }, { "args": { - "component_count": 1, - "initialization_value_str": "0", + "component_dimensions": [ + [ + 1.0 + ] + ], + "data_format": "", + "init_end_range": "1;1;1", + "init_start_range": "0;0;0", + "init_type_index": 0, + "init_value": "0", "numeric_type_index": 8, "output_array_path": "[Triangle Geometry]/Vertex Data/Node Type", + "seed_array_name": "InitializeDataFilter SeedValue", + "seed_value": 5489, + "set_tuple_dimensions": true, + "standardize_seed": false, + "starting_fill_value": "0;1;2", + "step_operation_index": 0, + "step_value": "1;1;1", "tuple_dimensions": [ [ 1.0 ] - ] + ], + "use_seed": false }, "comments": "", "filter": { - "name": "simplnx::CreateDataArrayFilter", + "name": "nx::core::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": true } ], + "version": 1, "workflowParams": [] } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp index af61b3ceba..e78c21c764 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp @@ -79,7 +79,7 @@ Parameters CreateDataArrayFilter::parameters() const DynamicTableInfo tableInfo; tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "COMP DIM {}")); - params.insert(std::make_unique(k_CompDims_Key, "Data Array Component Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Dimensions.", tableInfo)); + params.insert(std::make_unique(k_CompDims_Key, "Data Array Component Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Component Dimensions.", tableInfo)); } params.insertSeparator(Parameters::Separator{"Initialization Options"}); @@ -90,20 +90,22 @@ Parameters CreateDataArrayFilter::parameters() const params.insert(std::make_unique(k_InitValue_Key, "Fill Values [Seperated with ;]", "Specify values for each component. Ex: A 3-component array would be 6;8;12 and every tuple would have these same component values", "1;1;1")); - params.insert(std::make_unique(k_StartingFillValue_Key, "Starting Value [Seperated with ;]", "The value to start incrementing from", "0;1;2")); - params.insert(std::make_unique(k_StepOperation_Key, "Step Operation", "The type of step operation to preform", static_cast(0), + params.insert(std::make_unique( + k_StartingFillValue_Key, "Starting Value [Seperated with ;]", + "The value to start incrementing from. Ex: 6;8;12 would increment a 3-component array starting at 6 for the first component, 8 for the 2nd, and 12 for the 3rd.", "0;1;2")); + params.insert(std::make_unique(k_StepOperation_Key, "Step Operation", "The type of step operation to perform", static_cast(0), ChoicesParameter::Choices{"Addition", "Subtraction"})); params.insert(std::make_unique(k_StepValue_Key, "Increment/Step Value [Seperated with ;]", "The number to increment/decrement the fill value by", "1;1;1")); - params.insert(std::make_unique(k_UseSeed_Key, "Use Seed for Random Generation", "When true the Seed Value will be used to seed the generator", false)); + params.insert(std::make_unique(k_UseSeed_Key, "Use Seed for Random Generation", "When true, the Seed Value will be used to seed the generator", false)); params.insert(std::make_unique>(k_SeedValue_Key, "Seed Value", "The seed fed into the random generator", std::mt19937::default_seed)); - params.insert(std::make_unique(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "InitializeDataFilter SeedValue")); + params.insert(std::make_unique(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of the array holding the seed value", "InitializeDataFilter SeedValue")); params.insert(std::make_unique(k_StandardizeSeed_Key, "Use the Same Seed for Each Component", "When true the same seed will be used for each component's generator in a multi-component array", false)); params.insert( std::make_unique(k_InitStartRange_Key, "Initialization Start Range [Seperated with ;]", "[Inclusive] The lower bound initialization range for random values", "0;0;0")); - params.insert(std::make_unique(k_InitEndRange_Key, "Initialization End Range [Seperated with ;]", "[Inclusive] The upper bound initialization range for random values", "1;1;1")); + params.insert(std::make_unique(k_InitEndRange_Key, "Initialization End Range [Seperated with ;]", "[Inclusive] The upper bound initialization range for random values", "1;1;1")); params.insertSeparator(Parameters::Separator{"Output Data Array"}); params.insert(std::make_unique(k_DataPath_Key, "Created Array", "Array storing the data", DataPath{})); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp index 8ebcccdf62..bf225bc39d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp @@ -23,7 +23,6 @@ class SIMPLNXCORE_EXPORT CreateDataArrayFilter : public IFilter // Parameter Keys static inline constexpr StringLiteral k_NumericType_Key = "numeric_type_index"; static inline constexpr StringLiteral k_AdvancedOptions_Key = "set_tuple_dimensions"; - // static inline constexpr StringLiteral k_NumComps_Key = "component_count"; static inline constexpr StringLiteral k_CompDims_Key = "component_dimensions"; static inline constexpr StringLiteral k_TupleDims_Key = "tuple_dimensions"; static inline constexpr StringLiteral k_DataPath_Key = "output_array_path"; diff --git a/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp b/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp index 87fdc875e0..8c8cf99da8 100644 --- a/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp +++ b/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp @@ -160,10 +160,10 @@ Pipeline CreateExportPipeline() Arguments args; args.insert("set_tuple_dimensions", std::make_any(true)); args.insert("numeric_type_index", std::make_any(NumericType::int8)); - args.insert("component_count", std::make_any(3)); + args.insert("component_dimensions", DynamicTableInfo::TableDataType{{3.0}}); args.insert("tuple_dimensions", DynamicTableInfo::TableDataType{{1.0}}); - args.insert("initialization_value_str", std::make_any("7")); + args.insert("init_value", std::make_any("7")); args.insert("output_array_path", DataPath({DataNames::k_ArrayName})); args.insert("data_format", std::string("")); pipeline.push_back(k_CreateDataArrayHandle, args); diff --git a/src/Plugins/TestOne/src/TestOne/Filters/CreateOutOfCoreArrayFilter.hpp b/src/Plugins/TestOne/src/TestOne/Filters/CreateOutOfCoreArrayFilter.hpp index 0912ca8ea2..2b63c45269 100644 --- a/src/Plugins/TestOne/src/TestOne/Filters/CreateOutOfCoreArrayFilter.hpp +++ b/src/Plugins/TestOne/src/TestOne/Filters/CreateOutOfCoreArrayFilter.hpp @@ -21,7 +21,7 @@ class TESTONE_EXPORT CreateOutOfCoreArray : public IFilter // Parameter Keys static inline constexpr StringLiteral k_NumericType_Key = "numeric_type_index"; - static inline constexpr StringLiteral k_NumComps_Key = "component_count"; + static inline constexpr StringLiteral k_NumComps_Key = "component_dimensions"; static inline constexpr StringLiteral k_TupleDims_Key = "tuple_dimensions"; static inline constexpr StringLiteral k_DataPath_Key = "output_array_path"; static inline constexpr StringLiteral k_InitilizationValue_Key = "initialization_value_str"; diff --git a/wrapping/python/docs/source/DataObjects.rst b/wrapping/python/docs/source/DataObjects.rst index 1c136ef08a..758951dbb0 100644 --- a/wrapping/python/docs/source/DataObjects.rst +++ b/wrapping/python/docs/source/DataObjects.rst @@ -297,12 +297,13 @@ and then print the name, tuple_dimensions and component_dims of the created DatA data_structure = nx.DataStructure() result = nx.CreateDataArrayFilter.execute(data_structure=data_structure, - component_count=3, - data_format="", - initialization_value="0", - numeric_type=nx.NumericType.float32, - output_data_array=nx.DataPath(["2D Array"]), - tuple_dimensions=[[4, 5]]) + component_dimensions=[[3]], + data_format="", + init_type_index=0, + init_value="0", + numeric_type_index=nx.NumericType.float32, + output_array_path=nx.DataPath(["2D Array"]), + tuple_dimensions=[[4, 5]]) data_array = data_structure[output_array_path] print(f'name: {data_array.name}') @@ -474,9 +475,9 @@ Pipeline create_data_array_args:dict = { "data_format": "", - "component_count":1, + "component_dimensions":[1], "initialization_value":"0", - "numeric_type":nx.NumericType.int8, + "numeric_type_index":nx.NumericType.int8, "output_data_array":nx.DataPath("Geometry/Cell Data/data"), "advanced_options": False, "tuple_dimensions": [[10,20,30]] diff --git a/wrapping/python/docs/source/Python_Introduction.rst b/wrapping/python/docs/source/Python_Introduction.rst index 752834b8fe..b2b65e23bb 100644 --- a/wrapping/python/docs/source/Python_Introduction.rst +++ b/wrapping/python/docs/source/Python_Introduction.rst @@ -77,10 +77,10 @@ An example of executing a file in immediate mode using a filter from the simplnx import simplnx as nx result = nx.CreateDataArrayFilter.execute(data_structure=data_structure, - component_count=1, + component_dimensions=[[1]], data_format="", initialization_value="10", - numeric_type=nx.NumericType.float32, + numeric_type_index=nx.NumericType.float32, output_data_array=nx.DataPath(["3D Array"]), tuple_dimensions= [[3, 2, 5]]) npdata = data_structure[nx.DataPath(["3D Array"])].npview() @@ -130,10 +130,10 @@ of the method is as follows. # Instantiate and execute immediately teh CreateDataArrayFilter Filter result = nx.CreateDataArrayFilter.execute(data_structure=data_structure, - component_count=1, + component_dimensions=[[1]], data_format="", initialization_value="10", - numeric_type=nx.NumericType.float32, + numeric_type_index=nx.NumericType.float32, output_data_array=nx.DataPath(["3D Array"]), tuple_dimensions= [[3, 2, 5]]) # The returned result holds any warnings or errors that occurred during execution @@ -254,8 +254,8 @@ connectivity from a sample file. # Create the vertex array and fill it from data on disk array_path = nx.DataPath(['Vertices']) result = nx.CreateDataArrayFilter.execute(data_structure, - numeric_type=nx.NumericType.float32, - component_count=3, + numeric_type_index=nx.NumericType.float32, + component_dimensions=[[3]], tuple_dimensions=[[144]], output_data_array=array_path, initialization_value='0') @@ -266,8 +266,8 @@ connectivity from a sample file. # Create the triangle connectivity array and fill it from data on disk array_path = nx.DataPath(['Triangles']) result = nx.CreateDataArrayFilter.execute(data_structure, - numeric_type=nx.NumericType.uint64, - component_count=3, + numeric_type_index=nx.NumericType.uint64, + component_dimensions=[[3]], tuple_dimensions=[[242]], output_data_array=array_path, initialization_value='0') @@ -336,10 +336,10 @@ The next code section was take from `basic_arrays.py class CreateArrayFilter: NUMERIC_TYPE_KEY = "numeric_type_index" - INITILIZATION_VALUE_KEY = "initialization_value_str" + INITILIZATION_VALUE_KEY = "init_value" NUM_COMPS_KEY = "component_count" DATA_PATH_KEY = "output_array_path" TUPLE_DIMS_KEY = "tuple_dimensions" From da6ba210460a95f1b41f2a9966860f5205336599 Mon Sep 17 00:00:00 2001 From: Joey Kleingers Date: Tue, 10 Sep 2024 12:50:51 -0400 Subject: [PATCH 07/10] Move new features to new "Create Data Array (Advanced)" filter. Signed-off-by: Joey Kleingers --- .../(02) Image Segmentation.d3dpipeline | 71 +-- .../(04) Porosity Analysis.d3dpipeline | 33 +- .../pipelines/EnsembleInfoReader.d3dpipeline | 41 +- src/Plugins/SimplnxCore/CMakeLists.txt | 1 + .../docs/CreateDataArrayAdvancedFilter.md | 67 +++ .../SimplnxCore/docs/CreateDataArrayFilter.md | 5 +- .../ApplyTransformation_Demo.d3dpipeline | 28 +- .../ArrayCalculatorExample.d3dpipeline | 95 +--- .../pipelines/CreateEdgeGeom.d3dpipeline | 40 +- .../CreateHexahedralGeom.d3dpipeline | 40 +- .../pipelines/CreateImageGeom.d3dpipeline | 40 +- .../pipelines/CreateQuadGeom.d3dpipeline | 40 +- .../pipelines/CreateRectGridGeom.d3dpipeline | 40 +- .../CreateTetrahedralGeom.d3dpipeline | 40 +- .../pipelines/CreateTriangleGeom.d3dpipeline | 40 +- .../pipelines/CreateVertexGeom.d3dpipeline | 40 +- .../pipelines/Import_CSV_File.d3dpipeline | 44 +- .../pipelines/Import_STL_Model.d3dpipeline | 38 +- .../Filters/CreateDataArrayAdvancedFilter.cpp | 477 ++++++++++++++++++ .../Filters/CreateDataArrayAdvancedFilter.hpp | 114 +++++ .../Filters/CreateDataArrayFilter.cpp | 313 +----------- .../Filters/CreateDataArrayFilter.hpp | 14 +- .../src/SimplnxCore/utils/nanoflann.hpp | 2 +- src/Plugins/SimplnxCore/test/CMakeLists.txt | 1 + .../test/CreateDataArrayAdvancedTest.cpp | 138 +++++ .../SimplnxCore/test/CreateDataArrayTest.cpp | 36 +- .../SimplnxCore/test/DREAM3DFileTest.cpp | 4 +- .../Filters/CreateOutOfCoreArrayFilter.hpp | 2 +- wrapping/python/docs/source/DataObjects.rst | 17 +- .../docs/source/Python_Introduction.rst | 24 +- wrapping/python/docs/source/Tutorial_1.rst | 4 +- wrapping/python/docs/source/Tutorial_2.rst | 2 +- .../source/release_notes/ReleaseNotes_121.rst | 4 +- .../examples/notebooks/angle_conversion.ipynb | 4 +- .../examples/notebooks/basic_arrays.ipynb | 12 +- .../examples/notebooks/basic_numpy.ipynb | 4 +- .../notebooks/create_image_geom.ipynb | 4 +- .../examples/notebooks/output_file.ipynb | 4 +- .../python/examples/notebooks/pipeline.ipynb | 4 +- .../02_Image_Segmentation.py | 4 +- .../Simplnx/ApplyTransformation_Demo.py | 4 +- .../Simplnx/ArrayCalculatorExample.py | 12 +- .../pipelines/Simplnx/EnsembleInfoReader.py | 4 +- .../pipelines/Simplnx/Import_ASCII.py | 4 +- .../pipelines/Simplnx/Import_STL_Model.py | 4 +- .../examples/scripts/angle_conversion.py | 6 +- .../python/examples/scripts/basic_arrays.py | 12 +- .../python/examples/scripts/basic_numpy.py | 4 +- .../examples/scripts/geometry_examples.py | 60 +-- .../python/examples/scripts/output_file.py | 2 +- .../src/ExamplePlugin/CreateArray.py | 2 +- 51 files changed, 1089 insertions(+), 956 deletions(-) create mode 100644 src/Plugins/SimplnxCore/docs/CreateDataArrayAdvancedFilter.md create mode 100644 src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp create mode 100644 src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.hpp create mode 100644 src/Plugins/SimplnxCore/test/CreateDataArrayAdvancedTest.cpp diff --git a/src/Plugins/ITKImageProcessing/pipelines/(02) Image Segmentation.d3dpipeline b/src/Plugins/ITKImageProcessing/pipelines/(02) Image Segmentation.d3dpipeline index 4dfaaa6265..7f8e440c19 100644 --- a/src/Plugins/ITKImageProcessing/pipelines/(02) Image Segmentation.d3dpipeline +++ b/src/Plugins/ITKImageProcessing/pipelines/(02) Image Segmentation.d3dpipeline @@ -6,15 +6,8 @@ { "args": { "cell_attribute_matrix_name": "Cell Data", - "change_image_data_type": false, - "color_weights": [ - 0.21250000596046448, - 0.715399980545044, - 0.07209999859333038 - ], - "convert_to_gray_scale": false, "image_data_array_name": "ImageData", - "image_data_type_index": 0, + "output_image_geometry_path": "ImageDataContainer", "image_transform_index": 0, "input_file_list_object": { "end_index": 174, @@ -32,9 +25,6 @@ 0.0, 0.0 ], - "output_image_geometry_path": "ImageDataContainer", - "scale_images": false, - "scaling": 1.0, "spacing": [ 1.0, 1.0, @@ -43,7 +33,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ITKImportImageStackFilter", + "name": "simplnx::ITKImportImageStack", "uuid": "dcf980b7-ecca-46d1-af31-ac65f6e3b6bb" }, "isDisabled": false @@ -65,16 +55,11 @@ "type": "collection", "union": 0 }, - "created_mask_type": 10, - "custom_false_value": 0.0, - "custom_true_value": 1.0, - "output_data_array_name": "Mask", - "use_custom_false_value": false, - "use_custom_true_value": false + "output_data_array_name": "Mask" }, "comments": "", "filter": { - "name": "nx::core::MultiThresholdObjectsFilter", + "name": "simplnx::MultiThresholdObjects", "uuid": "4246245e-1011-4add-8436-0af6bed19228" }, "isDisabled": false @@ -84,8 +69,8 @@ "active_array_name": "Active", "cell_feature_group_name": "Cell Feature Data", "feature_ids_name": "FeatureIds", - "input_array_path": "ImageDataContainer/Cell Data/ImageData", "input_image_geometry_path": "ImageDataContainer", + "input_array_path": "ImageDataContainer/Cell Data/ImageData", "mask_path": "ImageDataContainer/Cell Data/Mask", "randomize_features": true, "scalar_tolerance": 0, @@ -93,7 +78,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ScalarSegmentFeaturesFilter", + "name": "simplnx::ScalarSegmentFeaturesFilter", "uuid": "e067cd97-9bbf-4c92-89a6-3cb4fdb76c93" }, "isDisabled": false @@ -110,7 +95,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ComputeFeatureSizesFilter", + "name": "simplnx::ComputeFeatureSizesFilter", "uuid": "c666ee17-ca58-4969-80d0-819986c72485" }, "isDisabled": false @@ -119,50 +104,34 @@ "args": { "created_array_suffix": "", "feature_ids_path": "ImageDataContainer/Cell Data/FeatureIds", - "selected_feature_array_paths": [ - "ImageDataContainer/Cell Feature Data/EquivalentDiameters" - ] + "selected_feature_array_paths": ["ImageDataContainer/Cell Feature Data/EquivalentDiameters"] }, "comments": "", "filter": { - "name": "nx::core::CopyFeatureArrayToElementArrayFilter", + "name": "simplnx::CopyFeatureArrayToElementArrayFilter", "uuid": "4c8c976a-993d-438b-bd8e-99f71114b9a1" }, "isDisabled": false }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "set_tuple_dimensions": false, + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "1", + "initialization_value_str": "1", "numeric_type_index": 4, "output_array_path": "ImageDataContainer/Cell Data/Phases", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, - "set_tuple_dimensions": false, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 164.0, 390.0, 524.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { - "name": "nx::core::CreateDataArrayFilter", + "name": "simplnx::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false @@ -170,7 +139,6 @@ { "args": { "conditional_array_path": "ImageDataContainer/Cell Data/Mask", - "invert_mask": false, "remove_value": "0", "replace_value": "2", "selected_array_path": "ImageDataContainer/Cell Data/Phases", @@ -178,7 +146,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ConditionalSetValueFilter", + "name": "simplnx::ConditionalSetValueFilter", "uuid": "bad9b7bd-1dc9-4f21-a889-6520e7a41881" }, "isDisabled": false @@ -192,7 +160,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ComputeFeaturePhasesFilter", + "name": "simplnx::ComputeFeaturePhasesFilter", "uuid": "da5bb20e-4a8e-49d9-9434-fbab7bc434fc" }, "isDisabled": false @@ -206,7 +174,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ComputeFeatureCentroidsFilter", + "name": "simplnx::ComputeFeatureCentroidsFilter", "uuid": "c6875ac7-8bdd-4f69-b6ce-82ac09bd3421" }, "isDisabled": false @@ -222,7 +190,7 @@ }, "comments": "", "filter": { - "name": "nx::core::CreateAttributeMatrixFilter", + "name": "simplnx::CreateAttributeMatrixFilter", "uuid": "a6a28355-ee69-4874-bcac-76ed427423ed" }, "isDisabled": false @@ -234,12 +202,11 @@ }, "comments": "", "filter": { - "name": "nx::core::WriteDREAM3DFilter", + "name": "simplnx::WriteDREAM3DFilter", "uuid": "b3a95784-2ced-41ec-8d3d-0242ac130003" }, "isDisabled": false } ], - "version": 1, "workflowParams": [] } diff --git a/src/Plugins/ITKImageProcessing/pipelines/(04) Porosity Analysis.d3dpipeline b/src/Plugins/ITKImageProcessing/pipelines/(04) Porosity Analysis.d3dpipeline index df3d581637..3d578c5843 100644 --- a/src/Plugins/ITKImageProcessing/pipelines/(04) Porosity Analysis.d3dpipeline +++ b/src/Plugins/ITKImageProcessing/pipelines/(04) Porosity Analysis.d3dpipeline @@ -1,12 +1,10 @@ { "isDisabled": false, - "name": "(04) Porosity Analysis.d3dpipeline", - "pinnedParams": [], + "name": "(04) Porosity Analysis", "pipeline": [ { "args": { "cell_attribute_matrix_name": "Optical Data", - "change_image_data_type": false, "color_weights": [ 0.21250000596046448, 0.715399980545044, @@ -14,7 +12,6 @@ ], "convert_to_gray_scale": false, "image_data_array_name": "ImageData", - "image_data_type_index": 0, "image_transform_index": 0, "input_file_list_object": { "end_index": 174, @@ -33,8 +30,6 @@ 0.0 ], "output_image_geometry_path": "RoboMet.3D Image Stack", - "scale_images": false, - "scaling": 1.0, "spacing": [ 1.0, 1.0, @@ -132,31 +127,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "1", + "initialization_value_str": "1", "numeric_type_index": 4, "output_array_path": "RoboMet.3D Image Stack/Optical Data/Phases", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": false, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -231,6 +212,7 @@ "cell_ensemble_attribute_matrix_path": "RoboMet.3D Image Stack/Ensemble Data", "centroids_array_path": "RoboMet.3D Image Stack/Pore Data/Centroids", "clustering_list_array_name": "ClusteringList", + "equivalent_diameters_array_path": "RoboMet.3D Image Stack/Pore Data/EquivalentDiameters", "feature_phases_array_path": "RoboMet.3D Image Stack/Pore Data/Phases", "input_image_geometry_path": "RoboMet.3D Image Stack", "max_min_array_name": "RDFMaxMinDistances", @@ -262,6 +244,5 @@ "isDisabled": false } ], - "version": 1, - "workflowParams": [] -} + "version": 1 +} \ No newline at end of file diff --git a/src/Plugins/OrientationAnalysis/pipelines/EnsembleInfoReader.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EnsembleInfoReader.d3dpipeline index d56394ae55..eab706dee4 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EnsembleInfoReader.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EnsembleInfoReader.d3dpipeline @@ -1,6 +1,6 @@ { "isDisabled": false, - "name": "EnsembleInfoReader.d3dpipeline", + "name": "ReadEnsembleInfo.d3dpipeline", "pinnedParams": [], "pipeline": [ { @@ -11,12 +11,12 @@ 100, 2 ], + "output_image_geometry_path": "[Image Geometry]", "origin": [ 0.0, 0.0, 0.0 ], - "output_image_geometry_path": "[Image Geometry]", "spacing": [ 1.0, 1.0, @@ -25,7 +25,7 @@ }, "comments": "", "filter": { - "name": "nx::core::CreateImageGeometryFilter", + "name": "simplnx::CreateImageGeometryFilter", "uuid": "c4320659-1a84-461d-939e-c7c10229a504" }, "isDisabled": false @@ -48,7 +48,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ReadRawBinaryFilter", + "name": "simplnx::ReadRawBinaryFilter", "uuid": "dd159366-5f12-42db-af6d-a33592ae8a89" }, "isDisabled": false @@ -62,44 +62,28 @@ }, "comments": "", "filter": { - "name": "nx::core::ConvertOrientationsFilter", + "name": "simplnx::ConvertOrientations", "uuid": "501e54e6-a66f-4eeb-ae37-00e649c00d4b" }, "isDisabled": false }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], - "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "1", + "component_count": 1, + "initialization_value_str": "1", "numeric_type_index": 4, "output_array_path": "[Image Geometry]/Cell Data/Phases", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, - "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 2.0, 100.0, 100.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { - "name": "nx::core::CreateDataArrayFilter", + "name": "simplnx::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false @@ -114,7 +98,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ReadEnsembleInfoFilter", + "name": "simplnx::ReadEnsembleInfoFilter", "uuid": "ecf1ec45-bc27-4ddb-b2c0-3d465b8c182a" }, "isDisabled": false @@ -135,7 +119,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ComputeIPFColorsFilter", + "name": "simplnx::ComputeIPFColorsFilter", "uuid": "64cb4f27-6e5e-4dd2-8a03-0c448cb8f5e6" }, "isDisabled": false @@ -147,12 +131,11 @@ }, "comments": "", "filter": { - "name": "nx::core::WriteDREAM3DFilter", + "name": "simplnx::WriteDREAM3DFilter", "uuid": "b3a95784-2ced-41ec-8d3d-0242ac130003" }, "isDisabled": false } ], - "version": 1, "workflowParams": [] } diff --git a/src/Plugins/SimplnxCore/CMakeLists.txt b/src/Plugins/SimplnxCore/CMakeLists.txt index d327c9280c..0b9c01bf98 100644 --- a/src/Plugins/SimplnxCore/CMakeLists.txt +++ b/src/Plugins/SimplnxCore/CMakeLists.txt @@ -51,6 +51,7 @@ set(FilterList CopyFeatureArrayToElementArrayFilter CreateAttributeMatrixFilter CreateDataArrayFilter + CreateDataArrayAdvancedFilter CreateDataGroupFilter CreateFeatureArrayFromElementArrayFilter CreateGeometryFilter diff --git a/src/Plugins/SimplnxCore/docs/CreateDataArrayAdvancedFilter.md b/src/Plugins/SimplnxCore/docs/CreateDataArrayAdvancedFilter.md new file mode 100644 index 0000000000..8decabea5e --- /dev/null +++ b/src/Plugins/SimplnxCore/docs/CreateDataArrayAdvancedFilter.md @@ -0,0 +1,67 @@ +# Create Data Array (Advanced) + +## Group (Subgroup) + +Core (Generation) + +## Description + +This **Filter** creates a **Data Array** of any primitive type with any set of component dimensions. The array is initialized to a user defined value or with random values within a specified range. + +When initializing a multicomponent array square bracket notation can be used to specify different initialization values for each component. For example say that I want to intialize a 2 component array where the first component is 0 and the second component is 1 we would use the following input string for the *Initialization Value* + + 0;1 + +We are using semicolons instead of commas or decimal points due to different international standards (European versus United States?). + +Another example is if you want to create a floating point array where each tuple has 10 components but you just want the value of 2.5 to be used for each, then simply use: + + 2.5 + +When creating a Data Array within an Attribute matrix, the tuple dimensions will **always** be taken direct from the Attribute Matrix. This means that the *Set Tuple Dimensions* parameter can be unchecked to hide the tuple dimensions entry table. + +If the parent is **NOT an Attribute Matrix**, then the user ***MUST*** set the tuple dimensions themselves. + +### Scalar Type Values + + static const int Int8 = 0; + static const int UInt8 = 1; + static const int Int16 = 2; + static const int UInt16 = 3; + static const int Int32 = 4; + static const int UInt32 = 5; + static const int Int64 = 6; + static const int UInt64 = 7; + static const int Float = 8; + static const int Double = 9; + static const int Bool = 10; + +### Primitive Data Type Valid Ranges + +| Type | Size | Range | +|------------------|------|--------------------| +| Signed Integer | 8 bit |0 to 255| +| Unsigned Integer | 8 bit |-128 to 127| +| Signed Integer | 16 bit |-32,768 to 32,767| +| Unsigned Integer | 16 bit |0 to 65,535| +| Signed Integer | 32 bit |-2,147,483,648 to 2,147,483,647| +| Unsigned Integer | 32 bit |0 to 4,294,967,295| +| Signed Integer | 64 bit | 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807| +| Unsigned Integer | 64 bit |0 to 18,446,744,073,709,551,615| +| Float | 32 bit | -3.4e+38 to -1.1e-38, 0.0, 1.1e-38 to 3.4e+38 (7 digits)| +| Double | 64 bit | -1.7e+308 to -2.2e-308, 0.0, 2.2e-308 to 1.7e+308 (15 digits)| +| Boolean | 8 bit |0 = false and any other value will be forced to 1 = true| + +The component dimensions should multiply together into a total number of components equal to at least 1. Examples of *Component Dimensions* would be [3] for an RGB Image, [1] for a gray scale image, [1] for a scalar array, [4] for a quaternions array, [10x5] for an array with 10x5 grids at each tuple, etc. All values of the array will be initialized using the chosen initialization option. + +% Auto generated parameter table will be inserted here + +## Example Pipelines + +## License & Copyright + +Please see the description file distributed with this **Plugin** + +## DREAM3D-NX Help + +If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues/discussions) GitHub site where the community of DREAM3D-NX users can help answer your questions. diff --git a/src/Plugins/SimplnxCore/docs/CreateDataArrayFilter.md b/src/Plugins/SimplnxCore/docs/CreateDataArrayFilter.md index ba5b092cfa..9d4ee58da9 100644 --- a/src/Plugins/SimplnxCore/docs/CreateDataArrayFilter.md +++ b/src/Plugins/SimplnxCore/docs/CreateDataArrayFilter.md @@ -6,7 +6,7 @@ Core (Generation) ## Description -This **Filter** creates a **Data Array** of any primitive type with any set of component dimensions. The array is initialized to a user define value or with random values within a specified range. +This **Filter** creates an **Data Array** of any primitive type with any number of components along a *single component dimension*. For example, a scalar as (1) or a 3-vector as (3), but *not* a matrix as (3, 3). The array is initialized to a user define value or with random values within a specified range. When initializing a multicomponent array square bracket notation can be used to specify different initialization values for each component. For example say that I want to intialize a 2 component array where the first component is 0 and the second component is 1 we would use the following input string for the *Initialization Value* @@ -52,7 +52,8 @@ If the parent is **NOT an Attribute Matrix**, then the user ***MUST*** set the t | Double | 64 bit | -1.7e+308 to -2.2e-308, 0.0, 2.2e-308 to 1.7e+308 (15 digits)| | Boolean | 8 bit |0 = false and any other value will be forced to 1 = true| -The component dimensions should multiply together into a total number of components equal to at least 1. Examples of *Component Dimensions* would be [3] for an RGB Image, [1] for a gray scale image, [1] for a scalar array, [4] for a quaternions array, [10x5] for an array with 10x5 grids at each tuple, etc. All values of the array will be initialized using the chosen initialization option. +The number of components should be at least 1. Examples of *Number of Components* would be 3 for an RGB Image, 1 for a gray scale image, 1 for a scalar array, 4 for a quaternions array, etc. All values of the array will be initialized to the user set value. The initialization value text box +must have a user entry or the default value *0* will be used. % Auto generated parameter table will be inserted here diff --git a/src/Plugins/SimplnxCore/pipelines/ApplyTransformation_Demo.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/ApplyTransformation_Demo.d3dpipeline index 0508c4f30a..0df9fc92ba 100644 --- a/src/Plugins/SimplnxCore/pipelines/ApplyTransformation_Demo.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/ApplyTransformation_Demo.d3dpipeline @@ -1,7 +1,6 @@ { "isDisabled": false, - "name": "ApplyTransformation_Demo.d3dpipeline", - "pinnedParams": [], + "name": "Apply Transformation To Geometry Demo", "pipeline": [ { "args": { @@ -48,33 +47,19 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "2", + "initialization_value_str": "2", "numeric_type_index": 4, "output_array_path": "Geometry/Cell Data/Data", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": false, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 2.0, 10.0, 10.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -142,6 +127,5 @@ "isDisabled": false } ], - "version": 1, - "workflowParams": [] -} + "version": 1 +} \ No newline at end of file diff --git a/src/Plugins/SimplnxCore/pipelines/ArrayCalculatorExample.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/ArrayCalculatorExample.d3dpipeline index ea5c0e5ffa..51e5b64ebc 100644 --- a/src/Plugins/SimplnxCore/pipelines/ArrayCalculatorExample.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/ArrayCalculatorExample.d3dpipeline @@ -1,109 +1,60 @@ { "isDisabled": false, - "name": "ArrayCalculatorExample.d3dpipeline", - "pinnedParams": [], + "name": "Untitled Pipeline", "pipeline": [ { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], - "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "2", + "component_count": 1, + "initialization_value_str": "2", "numeric_type_index": 4, "output_array_path": "TestArray", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, - "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 10.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { - "name": "nx::core::CreateDataArrayFilter", + "name": "simplnx::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], - "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "1.23878", + "component_count": 1, + "initialization_value_str": "1.23878", "numeric_type_index": 8, "output_array_path": "Confidence Index", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, - "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 10.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { - "name": "nx::core::CreateDataArrayFilter", + "name": "simplnx::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false }, { "args": { - "component_dimensions": [ - [ - 3.0 - ] - ], - "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "1.23878", + "component_count": 3, + "initialization_value_str": "1.23878", "numeric_type_index": 8, "output_array_path": "EulerAngles", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, - "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 10.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { - "name": "nx::core::CreateDataArrayFilter", + "name": "simplnx::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": false @@ -120,7 +71,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ArrayCalculatorFilter", + "name": "simplnx::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -137,7 +88,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ArrayCalculatorFilter", + "name": "simplnx::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -154,7 +105,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ArrayCalculatorFilter", + "name": "simplnx::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -171,7 +122,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ArrayCalculatorFilter", + "name": "simplnx::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -188,7 +139,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ArrayCalculatorFilter", + "name": "simplnx::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -205,7 +156,7 @@ }, "comments": "", "filter": { - "name": "nx::core::ArrayCalculatorFilter", + "name": "simplnx::ArrayCalculatorFilter", "uuid": "eea49b17-0db2-5bbc-80ef-f44249cc8d55" }, "isDisabled": false @@ -217,12 +168,10 @@ }, "comments": "", "filter": { - "name": "nx::core::WriteDREAM3DFilter", + "name": "simplnx::WriteDREAM3DFilter", "uuid": "b3a95784-2ced-41ec-8d3d-0242ac130003" }, "isDisabled": false } - ], - "version": 1, - "workflowParams": [] -} + ] +} \ No newline at end of file diff --git a/src/Plugins/SimplnxCore/pipelines/CreateEdgeGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateEdgeGeom.d3dpipeline index bc4b558153..29ee3bb56b 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateEdgeGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateEdgeGeom.d3dpipeline @@ -155,31 +155,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Edge Data/Int32Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -212,31 +198,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Edge Data/Int64Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateHexahedralGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateHexahedralGeom.d3dpipeline index c70a6e08db..3878797320 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateHexahedralGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateHexahedralGeom.d3dpipeline @@ -173,31 +173,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Cell Data/Int32Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -230,31 +216,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Cell Data/Int64Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateImageGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateImageGeom.d3dpipeline index acffcbbb2f..de5010f239 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateImageGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateImageGeom.d3dpipeline @@ -48,31 +48,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 4, "output_array_path": "Image Geometry/Cell Data/Int32Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -105,31 +91,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 6, "output_array_path": "Image Geometry/Cell Data/Int64Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateQuadGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateQuadGeom.d3dpipeline index 7d805a4447..22e07a97bb 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateQuadGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateQuadGeom.d3dpipeline @@ -161,31 +161,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Face Data/Int32Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -218,31 +204,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Face Data/Int64Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateRectGridGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateRectGridGeom.d3dpipeline index ab5102a93f..43f2b04b90 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateRectGridGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateRectGridGeom.d3dpipeline @@ -85,31 +85,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Cell Data/Int32Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -142,31 +128,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Cell Data/Int64Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateTetrahedralGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateTetrahedralGeom.d3dpipeline index 44719460ff..c1237a6ee9 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateTetrahedralGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateTetrahedralGeom.d3dpipeline @@ -161,31 +161,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Cell Data/Int32Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -218,31 +204,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Cell Data/Int64Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateTriangleGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateTriangleGeom.d3dpipeline index efbf97feb7..fe4a137f90 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateTriangleGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateTriangleGeom.d3dpipeline @@ -158,31 +158,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Face Data/Int32Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -215,31 +201,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Face Data/Int64Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/CreateVertexGeom.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/CreateVertexGeom.d3dpipeline index bdaa18160c..f461a6c40a 100644 --- a/src/Plugins/SimplnxCore/pipelines/CreateVertexGeom.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/CreateVertexGeom.d3dpipeline @@ -103,31 +103,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 4, "output_array_path": "Geometry/Vertex Data/Int32Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -160,31 +146,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "initialization_value_str": "0", "numeric_type_index": 6, "output_array_path": "Geometry/Vertex Data/Int64Array", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { diff --git a/src/Plugins/SimplnxCore/pipelines/Import_CSV_File.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/Import_CSV_File.d3dpipeline index 2945eda819..3c24c32fac 100644 --- a/src/Plugins/SimplnxCore/pipelines/Import_CSV_File.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/Import_CSV_File.d3dpipeline @@ -1,7 +1,6 @@ { "isDisabled": false, - "name": "Import_CSV_File.d3dpipeline", - "pinnedParams": [], + "name": "Import CSV File", "pipeline": [ { "args": { @@ -73,7 +72,7 @@ 480000 ] }, - "selected_attribute_matrix_path": "[Image Geometry]/Cell Data", + "selected_attribute_matrix_path": "[Image Geometry]/Cell Data/", "use_existing_group": true }, "comments": "", @@ -86,9 +85,9 @@ { "args": { "input_data_array_paths": [ - "[Image Geometry]/Cell Data/phi1", - "[Image Geometry]/Cell Data/Phi", - "[Image Geometry]/Cell Data/phi2" + "[Image Geometry]/Cell Data//phi1", + "[Image Geometry]/Cell Data//Phi", + "[Image Geometry]/Cell Data//phi2" ], "move_values": true, "normalize_data": false, @@ -124,31 +123,17 @@ }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], + "component_count": 1, "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "1", + "initialization_value_str": "1", "numeric_type_index": 4, - "output_array_path": "[Image Geometry]/Cell Data/Phases", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, + "output_array_path": "[Image Geometry]/Cell Data//Phases", "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 0.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { @@ -159,9 +144,9 @@ }, { "args": { - "cell_euler_angles_array_path": "[Image Geometry]/Cell Data/Eulers", + "cell_euler_angles_array_path": "[Image Geometry]/Cell Data//Eulers", "cell_ipf_colors_array_name": "IPFColors", - "cell_phases_array_path": "[Image Geometry]/Cell Data/Phases", + "cell_phases_array_path": "[Image Geometry]/Cell Data//Phases", "crystal_structures_array_path": "[Image Geometry]/EnsembleAttributeMatrix/CrystalStructures", "mask_array_path": "", "reference_dir": [ @@ -181,7 +166,7 @@ { "args": { "file_name": "Data/Output/Import_CSV_Example/Import_ASCII_IPF.png", - "image_array_path": "[Image Geometry]/Cell Data/IPFColors", + "image_array_path": "[Image Geometry]/Cell Data//IPFColors", "index_offset": 0, "input_image_geometry_path": "[Image Geometry]", "plane_index": 0 @@ -194,6 +179,5 @@ "isDisabled": false } ], - "version": 1, - "workflowParams": [] -} + "version": 1 +} \ No newline at end of file diff --git a/src/Plugins/SimplnxCore/pipelines/Import_STL_Model.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/Import_STL_Model.d3dpipeline index 657b7a4047..ddbb0fc4f3 100644 --- a/src/Plugins/SimplnxCore/pipelines/Import_STL_Model.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/Import_STL_Model.d3dpipeline @@ -5,69 +5,49 @@ "pipeline": [ { "args": { - "face_attribute_matrix_name": "Face Data", - "face_normals_name": "Face Normals", "output_triangle_geometry_path": "[Triangle Geometry]", "scale_factor": 1.0, "scale_output": false, - "stl_file_path": "Data/STL_Models/Cylinder.stl", - "vertex_attribute_matrix_name": "Vertex Data" + "stl_file_path": "Data/STL_Models/Cylinder.stl" }, "comments": "", "filter": { - "name": "nx::core::ReadStlFileFilter", + "name": "simplnx::ReadStlFileFilter", "uuid": "2f64bd45-9d28-4254-9e07-6aa7c6d3d015" }, "isDisabled": false }, { "args": { - "input_triangle_geometry_path": "[Triangle Geometry]", - "triangle_areas_array_name": "Areas" + "triangle_areas_array_name": "Areas", + "input_triangle_geometry_path": "[Triangle Geometry]" }, "comments": "", "filter": { - "name": "nx::core::ComputeTriangleAreasFilter", + "name": "simplnx::ComputeTriangleAreasFilter", "uuid": "b149addd-c0c8-4010-a264-596005eaf2a5" }, "isDisabled": false }, { "args": { - "component_dimensions": [ - [ - 1.0 - ] - ], - "data_format": "", - "init_end_range": "1;1;1", - "init_start_range": "0;0;0", - "init_type_index": 0, - "init_value": "0", + "component_count": 1, + "initialization_value_str": "0", "numeric_type_index": 8, "output_array_path": "[Triangle Geometry]/Vertex Data/Node Type", - "seed_array_name": "InitializeDataFilter SeedValue", - "seed_value": 5489, - "set_tuple_dimensions": true, - "standardize_seed": false, - "starting_fill_value": "0;1;2", - "step_operation_index": 0, - "step_value": "1;1;1", "tuple_dimensions": [ [ 1.0 ] - ], - "use_seed": false + ] }, "comments": "", "filter": { - "name": "nx::core::CreateDataArrayFilter", + "name": "simplnx::CreateDataArrayFilter", "uuid": "67041f9b-bdc6-4122-acc6-c9fe9280e90d" }, "isDisabled": true } ], - "version": 1, "workflowParams": [] } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp new file mode 100644 index 0000000000..1a76a74480 --- /dev/null +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp @@ -0,0 +1,477 @@ +#include "CreateDataArrayAdvancedFilter.hpp" + +#include "SimplnxCore/Filters/Algorithms/InitializeData.hpp" + +#include "simplnx/Common/TypesUtility.hpp" +#include "simplnx/Filter/Actions/CreateArrayAction.hpp" +#include "simplnx/Parameters/ArrayCreationParameter.hpp" +#include "simplnx/Parameters/BoolParameter.hpp" +#include "simplnx/Parameters/DataStoreFormatParameter.hpp" +#include "simplnx/Parameters/DynamicTableParameter.hpp" +#include "simplnx/Parameters/NumberParameter.hpp" +#include "simplnx/Parameters/NumericTypeParameter.hpp" +#include "simplnx/Parameters/StringParameter.hpp" +#include "simplnx/Utilities/DataArrayUtilities.hpp" +#include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" + +#include + +using namespace nx::core; + +namespace +{ +struct CreateAndInitArrayFunctor +{ + template + void operator()(IDataArray* iDataArray, const std::string& initValue) + { + Result result = ConvertTo::convert(initValue); + + auto* dataStore = iDataArray->template getIDataStoreAs>(); + dataStore->fill(result.value()); + } +}; +} // namespace + +namespace nx::core +{ +//------------------------------------------------------------------------------ +std::string CreateDataArrayAdvancedFilter::name() const +{ + return FilterTraits::name; +} + +//------------------------------------------------------------------------------ +std::string CreateDataArrayAdvancedFilter::className() const +{ + return FilterTraits::className; +} + +//------------------------------------------------------------------------------ +Uuid CreateDataArrayAdvancedFilter::uuid() const +{ + return FilterTraits::uuid; +} + +//------------------------------------------------------------------------------ +std::string CreateDataArrayAdvancedFilter::humanName() const +{ + return "Create Data Array (Advanced)"; +} + +//------------------------------------------------------------------------------ +std::vector CreateDataArrayAdvancedFilter::defaultTags() const +{ + return {className(), "Create", "Data Structure", "Data Array", "Initialize", "Make"}; +} + +//------------------------------------------------------------------------------ +Parameters CreateDataArrayAdvancedFilter::parameters() const +{ + Parameters params; + + params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); + params.insert(std::make_unique(k_NumericType_Key, "Output Numeric Type", "Numeric Type of data to create", NumericType::int32)); + + params.insertSeparator(Parameters::Separator{"Component Handling"}); + { + DynamicTableInfo tableInfo; + tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); + tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "COMP DIM {}")); + params.insert(std::make_unique(k_CompDims_Key, "Data Array Component Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Component Dimensions.", tableInfo)); + } + + params.insertSeparator(Parameters::Separator{"Initialization Options"}); + params.insertLinkableParameter(std::make_unique(k_InitType_Key, "Initialization Type", "Method for determining the what values of the data in the array should be initialized to", + static_cast(0), + ChoicesParameter::Choices{"Fill Value", "Incremental", "Random", "Random With Range"})); // sequence dependent DO NOT REORDER + + params.insert(std::make_unique(k_InitValue_Key, "Fill Values [Seperated with ;]", + "Specify values for each component. Ex: A 3-component array would be 6;8;12 and every tuple would have these same component values", "1;1;1")); + + params.insert(std::make_unique( + k_StartingFillValue_Key, "Starting Value [Seperated with ;]", + "The value to start incrementing from. Ex: 6;8;12 would increment a 3-component array starting at 6 for the first component, 8 for the 2nd, and 12 for the 3rd.", "0;1;2")); + params.insert(std::make_unique(k_StepOperation_Key, "Step Operation", "The type of step operation to perform", static_cast(0), + ChoicesParameter::Choices{"Addition", "Subtraction"})); + params.insert(std::make_unique(k_StepValue_Key, "Increment/Step Value [Seperated with ;]", "The number to increment/decrement the fill value by", "1;1;1")); + + params.insert(std::make_unique(k_UseSeed_Key, "Use Seed for Random Generation", "When true, the Seed Value will be used to seed the generator", false)); + params.insert(std::make_unique>(k_SeedValue_Key, "Seed Value", "The seed fed into the random generator", std::mt19937::default_seed)); + params.insert(std::make_unique(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of the array holding the seed value", "InitializeDataFilter SeedValue")); + params.insert(std::make_unique(k_StandardizeSeed_Key, "Use the Same Seed for Each Component", + "When true the same seed will be used for each component's generator in a multi-component array", false)); + + params.insert( + std::make_unique(k_InitStartRange_Key, "Initialization Start Range [Seperated with ;]", "[Inclusive] The lower bound initialization range for random values", "0;0;0")); + params.insert(std::make_unique(k_InitEndRange_Key, "Initialization End Range [Seperated with ;]", "[Inclusive] The upper bound initialization range for random values", "1;1;1")); + + params.insertSeparator(Parameters::Separator{"Output Data Array"}); + params.insert(std::make_unique(k_DataPath_Key, "Created Array", "Array storing the data", DataPath{})); + params.insert(std::make_unique(k_DataFormat_Key, "Data Format", + "This value will specify which data format is used by the array's data store. An empty string results in in-memory data store.", "")); + + params.insertSeparator(Parameters::Separator{"Tuple Handling"}); + params.insertLinkableParameter(std::make_unique( + k_AdvancedOptions_Key, "Set Tuple Dimensions [not required if creating inside an Attribute Matrix]", + "This allows the user to set the tuple dimensions directly rather than just inheriting them. This option is NOT required if you are creating the Data Array in an Attribute Matrix", true)); + + { + DynamicTableInfo tableInfo; + tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); + tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "TUPLE DIM {}")); + params.insert(std::make_unique(k_TupleDims_Key, "Data Array Tuple Dimensions (Slowest to Fastest Dimensions)", + "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", tableInfo)); + } + + // Associate the Linkable Parameter(s) to the children parameters that they control + params.linkParameters(k_AdvancedOptions_Key, k_TupleDims_Key, true); + + // Associate the Linkable Parameter(s) to the children parameters that they control + /* Using Fill Value */ + params.linkParameters(k_InitType_Key, k_InitValue_Key, static_cast(0)); + + /* Using Incremental */ + params.linkParameters(k_InitType_Key, k_StartingFillValue_Key, static_cast(1)); + params.linkParameters(k_InitType_Key, k_StepOperation_Key, static_cast(1)); + params.linkParameters(k_InitType_Key, k_StepValue_Key, static_cast(1)); + + /* Random - Using Random */ + params.linkParameters(k_InitType_Key, k_UseSeed_Key, static_cast(2)); + params.linkParameters(k_InitType_Key, k_SeedValue_Key, static_cast(2)); + params.linkParameters(k_InitType_Key, k_SeedArrayName_Key, static_cast(2)); + params.linkParameters(k_InitType_Key, k_StandardizeSeed_Key, static_cast(2)); + + /* Random - Using Random With Range */ + params.linkParameters(k_InitType_Key, k_UseSeed_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_SeedValue_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_SeedArrayName_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_StandardizeSeed_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_InitStartRange_Key, static_cast(3)); + params.linkParameters(k_InitType_Key, k_InitEndRange_Key, static_cast(3)); + return params; +} + +//------------------------------------------------------------------------------ +IFilter::UniquePointer CreateDataArrayAdvancedFilter::clone() const +{ + return std::make_unique(); +} + +//------------------------------------------------------------------------------ +IFilter::PreflightResult CreateDataArrayAdvancedFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, + const std::atomic_bool& shouldCancel) const +{ + auto useDims = filterArgs.value(k_AdvancedOptions_Key); + auto numericType = filterArgs.value(k_NumericType_Key); + auto compDimsData = filterArgs.value(k_CompDims_Key); + auto dataArrayPath = filterArgs.value(k_DataPath_Key); + auto tableData = filterArgs.value(k_TupleDims_Key); + auto dataFormat = filterArgs.value(k_DataFormat_Key); + + nx::core::Result resultOutputActions; + + std::vector compDims(compDimsData[0].size()); + std::transform(compDimsData[0].begin(), compDimsData[0].end(), compDims.begin(), [](double val) { return static_cast(val); }); + usize numComponents = std::accumulate(compDims.begin(), compDims.end(), static_cast(1), std::multiplies<>()); + if(numComponents <= 0) + { + std::string compDimsStr = std::accumulate(compDims.begin() + 1, compDims.end(), std::to_string(compDims[0]), [](const std::string& a, int b) { return a + " x " + std::to_string(b); }); + return MakePreflightErrorResult( + -78601, + fmt::format("The chosen component dimensions ({}) results in 0 total components. Please choose component dimensions that result in a positive number of total components.", compDimsStr)); + } + + std::vector tupleDims = {}; + + auto* parentAM = dataStructure.getDataAs(dataArrayPath.getParent()); + if(parentAM == nullptr) + { + if(!useDims) + { + return MakePreflightErrorResult( + -78602, fmt::format("The DataArray to be created '{}'is not within an AttributeMatrix, so the dimensions cannot be determined implicitly. Check Set Tuple Dimensions to set the dimensions", + dataArrayPath.toString())); + } + else + { + const auto& rowData = tableData.at(0); + tupleDims.reserve(rowData.size()); + for(auto floatValue : rowData) + { + if(floatValue == 0) + { + return MakePreflightErrorResult(-78603, "Tuple dimension cannot be zero"); + } + + tupleDims.push_back(static_cast(floatValue)); + } + } + } + else + { + tupleDims = parentAM->getShape(); + if(useDims) + { + resultOutputActions.warnings().push_back( + Warning{-78604, "You checked Set Tuple Dimensions, but selected a DataPath that has an Attribute Matrix as the parent. The Attribute Matrix tuples will override your " + "custom dimensions. It is recommended to uncheck Set Tuple Dimensions for the sake of clarity."}); + } + } + + auto arrayDataType = ConvertNumericTypeToDataType(numericType); + auto action = std::make_unique(ConvertNumericTypeToDataType(numericType), tupleDims, compDims, dataArrayPath, dataFormat); + + resultOutputActions.value().appendAction(std::move(action)); + + auto seedArrayNameValue = filterArgs.value(k_SeedArrayName_Key); + auto initializeTypeValue = static_cast(filterArgs.value(k_InitType_Key)); + + // nx::core::Result resultOutputActions; + std::vector preflightUpdatedValues; + + if(arrayDataType == DataType::boolean) + { + std::stringstream updatedValStrm; + + updatedValStrm << "We detected that you are doing an operation on a boolean array.\n"; + updatedValStrm << "The ONLY two ways to specify a 'false' boolean value are as follows:\n"; + updatedValStrm << "- boolean value string types as follows ignoring apostrophe marks: 'False', 'FALSE', 'false'\n"; + updatedValStrm << "- all well formed integers and well formed floating point definitions of 0\n\n"; + + updatedValStrm << "ANY OTHER string or number WILL BE 'true', although it is good practice to define true values as follows:\n"; + updatedValStrm << "- boolean value string types as follows ignoring apostrophe marks: 'True', 'TRUE', 'true'\n"; + updatedValStrm << "- all well formed integers and well formed floating point definitions of 1"; + + preflightUpdatedValues.push_back({"Boolean Note", updatedValStrm.str()}); + } + + if(numComponents > 1) + { + std::stringstream updatedValStrm; + + updatedValStrm << "We detected that you are doing an operation on a multi-component array.\n"; + updatedValStrm + << "If you do NOT want to use unique values for each component, you can just supply one value to the input box and we will apply that value to every component for the tuple.\nExample: 1\n\n"; + + updatedValStrm << fmt::format("If you DO want to use unique values for each component, you need to supply {} values of type {} seperated by '{}'.\n", numComponents, + DataTypeToString(arrayDataType), k_DelimiterChar); + updatedValStrm << "Example: "; + + for(usize comp = 0; comp < numComponents; comp++) + { + updatedValStrm << "1"; + + if(comp != numComponents - 1) + { + updatedValStrm << k_DelimiterChar; + } + } + + preflightUpdatedValues.push_back({"Multi-Component Note", updatedValStrm.str()}); + } + + std::stringstream operationNuancesStrm; + + switch(initializeTypeValue) + { + case InitializeType::FillValue: { + auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_InitValue_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + + operationNuancesStrm << "None to note"; + + break; + } + case InitializeType::Incremental: { + auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_StartingFillValue_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + + if(arrayDataType == DataType::boolean) + { + // custom bool checks here + std::stringstream updatedValStrm; + + updatedValStrm << "We detected that you are doing an incremental operation on a boolean array.\n"; + updatedValStrm << "For the step values please enter uint8 values, preferably a 0 or 1 only.\n"; + + switch(static_cast(filterArgs.value(k_StepOperation_Key))) + { + case Addition: { + updatedValStrm << "You have currently selected the addition operation.\nAny step value that is greater than 0 will cause all values to be 'true' after the first tuple, 'true' " + "values will remain unchanged.\n"; + updatedValStrm << "The two possibilities:\n"; + updatedValStrm << "- If your start value is 'false' and step value > 0, the array will initialize to | false | true | true | ... |\n"; + updatedValStrm << "- If your start value is 'true' and step value > 0, the array will initialize to | true | true | true | ... |"; + break; + } + case Subtraction: { + updatedValStrm << "You have currently selected the addition operation.\nAny step value that is greater than 0 will cause all values to be 'false' after the first tuple, 'false' " + "values will remain unchanged.\n"; + updatedValStrm << "The two possibilities:\n"; + updatedValStrm << "- If your start value is 'true' and step value > 0, the array will initialize to | true | false | false | ... |\n"; + updatedValStrm << "- If your start value is 'false' and step value > 0, the array will initialize to | false | false | false | ... |"; + break; + } + } + + preflightUpdatedValues.push_back({"Boolean Incremental Nuances", updatedValStrm.str()}); + + result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, DataType::uint8, numComponents, filterArgs.value(k_StepValue_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + } + else + { + result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_StepValue_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + } + auto values = StringUtilities::split(filterArgs.value(k_StepValue_Key), ";", false); + std::vector zeroIdx; + for(size_t i = 0; i < values.size(); i++) + { + if(values[i] == "0") + { + zeroIdx.push_back(i); + } + } + if(!zeroIdx.empty()) + { + + operationNuancesStrm << "Warning: Zero Step Value found. Component(s) " << fmt::format("[{}]", fmt::join(zeroIdx, ",")) + << " have a ZERO value for the step/increment.\n The values for those components will be unchanged from the starting value.\n"; + operationNuancesStrm << fmt::format(" Example: Suppose we have a two component array with a Step Values of '2{}0', Starting Values of '0', and an addition Step Operation\n", k_DelimiterChar); + operationNuancesStrm << " The output array would look like 0,0 | 2,0 | 4,0 | 6,0 | ..."; + } + break; + } + case InitializeType::RangedRandom: { + auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_InitStartRange_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + + result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_InitEndRange_Key), 1); + if(result.outputActions.invalid()) + { + return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; + } + + [[fallthrough]]; + } + case InitializeType::Random: { + auto createAction = std::make_unique(DataType::uint64, std::vector{1}, std::vector{1}, DataPath({seedArrayNameValue})); + resultOutputActions.value().appendAction(std::move(createAction)); + + if(numComponents == 1) + { + if(filterArgs.value(k_StandardizeSeed_Key)) + { + operationNuancesStrm << fmt::format("You chose to standardize the seed for each component, but the array {} is a single component so it will not alter the randomization scheme.", + dataArrayPath.getTargetName()); + } + } + else + { + if(filterArgs.value(k_StandardizeSeed_Key)) + { + operationNuancesStrm << "This generates THE SAME sequences of random numbers for each component in the array based on one seed.\n"; + operationNuancesStrm << "The resulting array will look like | 1,1,1 | 9,9,9 | ...\n"; + } + else + { + operationNuancesStrm << "This generates DIFFERENT sequences of random numbers for each component in the array based on x seeds all modified versions of an original seed.\n"; + operationNuancesStrm << "The resulting array will look like | 1,9,5 | 7,1,6 | ...\n"; + } + } + + break; + } + } + + preflightUpdatedValues.push_back({"Operation Nuances", operationNuancesStrm.str()}); + + return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; +} + +//------------------------------------------------------------------------------ +Result<> CreateDataArrayAdvancedFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, + const std::atomic_bool& shouldCancel) const +{ + auto path = filterArgs.value(k_DataPath_Key); + + ExecuteNeighborFunction(CreateAndInitArrayFunctor{}, ConvertNumericTypeToDataType(filterArgs.value(k_NumericType_Key)), dataStructure.getDataAs(path), "0"); + + auto initType = static_cast(filterArgs.value(k_InitType_Key)); + + auto seed = filterArgs.value(k_SeedValue_Key); + if(!filterArgs.value(k_UseSeed_Key)) + { + seed = static_cast(std::chrono::steady_clock::now().time_since_epoch().count()); + } + + if(initType == InitializeType::Random || initType == InitializeType::RangedRandom) + { + // Store Seed Value in Top Level Array + dataStructure.getDataRefAs(DataPath({filterArgs.value(k_SeedArrayName_Key)}))[0] = seed; + } + + InitializeDataInputValues inputValues; + inputValues.InputArrayPath = filterArgs.value(k_DataPath_Key); + inputValues.initType = initType; + inputValues.stepType = static_cast(filterArgs.value(k_StepOperation_Key)); + inputValues.stringValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitValue_Key)), k_DelimiterChar); + inputValues.startValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_StartingFillValue_Key)), k_DelimiterChar); + inputValues.stepValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_StepValue_Key)), k_DelimiterChar); + inputValues.seed = seed; + inputValues.randBegin = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitStartRange_Key)), k_DelimiterChar); + inputValues.randEnd = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitEndRange_Key)), k_DelimiterChar); + inputValues.standardizeSeed = filterArgs.value(k_StandardizeSeed_Key); + + return InitializeData(dataStructure, messageHandler, shouldCancel, &inputValues)(); +} + +namespace +{ +namespace SIMPL +{ +constexpr StringLiteral k_ScalarTypeKey = "ScalarType"; +constexpr StringLiteral k_NumberOfComponentsKey = "NumberOfComponents"; +constexpr StringLiteral k_InitializationValueKey = "InitializationValue"; +constexpr StringLiteral k_NewArrayKey = "NewArray"; +} // namespace SIMPL +} // namespace + +Result CreateDataArrayAdvancedFilter::FromSIMPLJson(const nlohmann::json& json) +{ + Arguments args = CreateDataArrayAdvancedFilter().getDefaultArguments(); + + args.insertOrAssign(k_AdvancedOptions_Key, false); + + std::vector> results; + + results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_ScalarTypeKey, k_NumericType_Key)); + // Initialize Type parameter is not applicable in NX + results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_InitializationValueKey, k_InitValue_Key)); + // Initialization Range parameter is not applicable in NX + // Starting Index value parameter is not applicable in NX + results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_NewArrayKey, k_DataPath_Key)); + + Result<> conversionResult = MergeResults(std::move(results)); + + return ConvertResultTo(std::move(conversionResult), std::move(args)); +} +} // namespace nx::core diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.hpp new file mode 100644 index 0000000000..87e1728f0a --- /dev/null +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.hpp @@ -0,0 +1,114 @@ +#pragma once + +#include "SimplnxCore/SimplnxCore_export.hpp" + +#include "simplnx/Common/StringLiteral.hpp" +#include "simplnx/Filter/FilterTraits.hpp" +#include "simplnx/Filter/IFilter.hpp" + +namespace nx::core +{ +class SIMPLNXCORE_EXPORT CreateDataArrayAdvancedFilter : public IFilter +{ +public: + CreateDataArrayAdvancedFilter() = default; + ~CreateDataArrayAdvancedFilter() noexcept override = default; + + CreateDataArrayAdvancedFilter(const CreateDataArrayAdvancedFilter&) = delete; + CreateDataArrayAdvancedFilter(CreateDataArrayAdvancedFilter&&) noexcept = delete; + + CreateDataArrayAdvancedFilter& operator=(const CreateDataArrayAdvancedFilter&) = delete; + CreateDataArrayAdvancedFilter& operator=(CreateDataArrayAdvancedFilter&&) noexcept = delete; + + // Parameter Keys + static inline constexpr StringLiteral k_NumericType_Key = "numeric_type_index"; + static inline constexpr StringLiteral k_AdvancedOptions_Key = "set_tuple_dimensions"; + static inline constexpr StringLiteral k_CompDims_Key = "component_dimensions"; + static inline constexpr StringLiteral k_TupleDims_Key = "tuple_dimensions"; + static inline constexpr StringLiteral k_DataPath_Key = "output_array_path"; + static inline constexpr StringLiteral k_DataFormat_Key = "data_format"; + static inline constexpr StringLiteral k_InitType_Key = "init_type_index"; + static inline constexpr StringLiteral k_InitValue_Key = "init_value"; + static inline constexpr StringLiteral k_StartingFillValue_Key = "starting_fill_value"; + static inline constexpr StringLiteral k_StepOperation_Key = "step_operation_index"; + static inline constexpr StringLiteral k_StepValue_Key = "step_value"; + static inline constexpr StringLiteral k_UseSeed_Key = "use_seed"; + static inline constexpr StringLiteral k_SeedValue_Key = "seed_value"; + static inline constexpr StringLiteral k_SeedArrayName_Key = "seed_array_name"; + static inline constexpr StringLiteral k_InitStartRange_Key = "init_start_range"; + static inline constexpr StringLiteral k_InitEndRange_Key = "init_end_range"; + static inline constexpr StringLiteral k_StandardizeSeed_Key = "standardize_seed"; + + /** + * @brief Reads SIMPL json and converts it simplnx Arguments. + * @param json + * @return Result + */ + static Result FromSIMPLJson(const nlohmann::json& json); + + /** + * @brief Returns the filter's name. + * @return std::string + */ + std::string name() const override; + + /** + * @brief Returns the C++ classname of this filter. + * @return std::string + */ + std::string className() const override; + + /** + * @brief Returns the filter's UUID. + * @return Uuid + */ + Uuid uuid() const override; + + /** + * @brief Returns the filter name as a human-readable string. + * @return std::string + */ + std::string humanName() const override; + + /** + * @brief Returns the default tags for this filter. + * @return + */ + std::vector defaultTags() const override; + + /** + * @brief Returns a collection of parameters required to execute the filter. + * @return Parameters + */ + Parameters parameters() const override; + + /** + * @brief Creates and returns a copy of the filter. + * @return UniquePointer + */ + UniquePointer clone() const override; + +protected: + /** + * @brief + * @param data + * @param filterArgs + * @param messageHandler + * @return Result + */ + PreflightResult preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const override; + + /** + * @brief + * @param dataStructure + * @param args + * @param pipelineNode + * @param messageHandler + * @return Result<> + */ + Result<> executeImpl(DataStructure& dataStructure, const Arguments& args, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, + const std::atomic_bool& shouldCancel) const override; +}; +} // namespace nx::core + +SIMPLNX_DEF_FILTER_TRAITS(nx::core, CreateDataArrayAdvancedFilter, "f23464df-abcc-40cf-bf99-f71463df633c"); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp index e78c21c764..b93e305e5c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp @@ -1,7 +1,5 @@ #include "CreateDataArrayFilter.hpp" -#include "SimplnxCore/Filters/Algorithms/InitializeData.hpp" - #include "simplnx/Common/TypesUtility.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Parameters/ArrayCreationParameter.hpp" @@ -21,6 +19,8 @@ using namespace nx::core; namespace { +constexpr int32 k_EmptyParameterError = -123; + struct CreateAndInitArrayFunctor { template @@ -73,39 +73,8 @@ Parameters CreateDataArrayFilter::parameters() const params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); params.insert(std::make_unique(k_NumericType_Key, "Output Numeric Type", "Numeric Type of data to create", NumericType::int32)); - - params.insertSeparator(Parameters::Separator{"Component Handling"}); - { - DynamicTableInfo tableInfo; - tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); - tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "COMP DIM {}")); - params.insert(std::make_unique(k_CompDims_Key, "Data Array Component Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Component Dimensions.", tableInfo)); - } - - params.insertSeparator(Parameters::Separator{"Initialization Options"}); - params.insertLinkableParameter(std::make_unique(k_InitType_Key, "Initialization Type", "Method for determining the what values of the data in the array should be initialized to", - static_cast(0), - ChoicesParameter::Choices{"Fill Value", "Incremental", "Random", "Random With Range"})); // sequence dependent DO NOT REORDER - - params.insert(std::make_unique(k_InitValue_Key, "Fill Values [Seperated with ;]", - "Specify values for each component. Ex: A 3-component array would be 6;8;12 and every tuple would have these same component values", "1;1;1")); - - params.insert(std::make_unique( - k_StartingFillValue_Key, "Starting Value [Seperated with ;]", - "The value to start incrementing from. Ex: 6;8;12 would increment a 3-component array starting at 6 for the first component, 8 for the 2nd, and 12 for the 3rd.", "0;1;2")); - params.insert(std::make_unique(k_StepOperation_Key, "Step Operation", "The type of step operation to perform", static_cast(0), - ChoicesParameter::Choices{"Addition", "Subtraction"})); - params.insert(std::make_unique(k_StepValue_Key, "Increment/Step Value [Seperated with ;]", "The number to increment/decrement the fill value by", "1;1;1")); - - params.insert(std::make_unique(k_UseSeed_Key, "Use Seed for Random Generation", "When true, the Seed Value will be used to seed the generator", false)); - params.insert(std::make_unique>(k_SeedValue_Key, "Seed Value", "The seed fed into the random generator", std::mt19937::default_seed)); - params.insert(std::make_unique(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of the array holding the seed value", "InitializeDataFilter SeedValue")); - params.insert(std::make_unique(k_StandardizeSeed_Key, "Use the Same Seed for Each Component", - "When true the same seed will be used for each component's generator in a multi-component array", false)); - - params.insert( - std::make_unique(k_InitStartRange_Key, "Initialization Start Range [Seperated with ;]", "[Inclusive] The lower bound initialization range for random values", "0;0;0")); - params.insert(std::make_unique(k_InitEndRange_Key, "Initialization End Range [Seperated with ;]", "[Inclusive] The upper bound initialization range for random values", "1;1;1")); + params.insert(std::make_unique(k_InitializationValue_Key, "Initialization Value", "This value will be used to fill the new array", "0")); + params.insert(std::make_unique(k_NumComps_Key, "Number of Components", "Number of components", 1)); params.insertSeparator(Parameters::Separator{"Output Data Array"}); params.insert(std::make_unique(k_DataPath_Key, "Created Array", "Array storing the data", DataPath{})); @@ -116,40 +85,16 @@ Parameters CreateDataArrayFilter::parameters() const params.insertLinkableParameter(std::make_unique( k_AdvancedOptions_Key, "Set Tuple Dimensions [not required if creating inside an Attribute Matrix]", "This allows the user to set the tuple dimensions directly rather than just inheriting them. This option is NOT required if you are creating the Data Array in an Attribute Matrix", true)); + DynamicTableInfo tableInfo; + tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); + tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "DIM {}")); - { - DynamicTableInfo tableInfo; - tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); - tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "TUPLE DIM {}")); - params.insert(std::make_unique(k_TupleDims_Key, "Data Array Tuple Dimensions (Slowest to Fastest Dimensions)", - "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", tableInfo)); - } + params.insert(std::make_unique(k_TupleDims_Key, "Data Array Dimensions (Slowest to Fastest Dimensions)", + "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", tableInfo)); // Associate the Linkable Parameter(s) to the children parameters that they control params.linkParameters(k_AdvancedOptions_Key, k_TupleDims_Key, true); - // Associate the Linkable Parameter(s) to the children parameters that they control - /* Using Fill Value */ - params.linkParameters(k_InitType_Key, k_InitValue_Key, static_cast(0)); - - /* Using Incremental */ - params.linkParameters(k_InitType_Key, k_StartingFillValue_Key, static_cast(1)); - params.linkParameters(k_InitType_Key, k_StepOperation_Key, static_cast(1)); - params.linkParameters(k_InitType_Key, k_StepValue_Key, static_cast(1)); - - /* Random - Using Random */ - params.linkParameters(k_InitType_Key, k_UseSeed_Key, static_cast(2)); - params.linkParameters(k_InitType_Key, k_SeedValue_Key, static_cast(2)); - params.linkParameters(k_InitType_Key, k_SeedArrayName_Key, static_cast(2)); - params.linkParameters(k_InitType_Key, k_StandardizeSeed_Key, static_cast(2)); - - /* Random - Using Random With Range */ - params.linkParameters(k_InitType_Key, k_UseSeed_Key, static_cast(3)); - params.linkParameters(k_InitType_Key, k_SeedValue_Key, static_cast(3)); - params.linkParameters(k_InitType_Key, k_SeedArrayName_Key, static_cast(3)); - params.linkParameters(k_InitType_Key, k_StandardizeSeed_Key, static_cast(3)); - params.linkParameters(k_InitType_Key, k_InitStartRange_Key, static_cast(3)); - params.linkParameters(k_InitType_Key, k_InitEndRange_Key, static_cast(3)); return params; } @@ -165,24 +110,26 @@ IFilter::PreflightResult CreateDataArrayFilter::preflightImpl(const DataStructur { auto useDims = filterArgs.value(k_AdvancedOptions_Key); auto numericType = filterArgs.value(k_NumericType_Key); - auto compDimsData = filterArgs.value(k_CompDims_Key); + auto numComponents = filterArgs.value(k_NumComps_Key); auto dataArrayPath = filterArgs.value(k_DataPath_Key); + auto initValue = filterArgs.value(k_InitializationValue_Key); auto tableData = filterArgs.value(k_TupleDims_Key); auto dataFormat = filterArgs.value(k_DataFormat_Key); nx::core::Result resultOutputActions; - std::vector compDims(compDimsData[0].size()); - std::transform(compDimsData[0].begin(), compDimsData[0].end(), compDims.begin(), [](double val) { return static_cast(val); }); - usize numComponents = std::accumulate(compDims.begin(), compDims.end(), static_cast(1), std::multiplies<>()); - if(numComponents <= 0) + if(initValue.empty()) { - std::string compDimsStr = std::accumulate(compDims.begin() + 1, compDims.end(), std::to_string(compDims[0]), [](const std::string& a, int b) { return a + " x " + std::to_string(b); }); - return MakePreflightErrorResult( - -78601, - fmt::format("The chosen component dimensions ({}) results in 0 total components. Please choose component dimensions that result in a positive number of total components.", compDimsStr)); + return MakePreflightErrorResult(k_EmptyParameterError, fmt::format("{}: Init Value cannot be empty.{}({})", humanName(), __FILE__, __LINE__)); + } + // Sanity check that what the user entered for an init value can be converted safely to the final numeric type + Result<> result = CheckValueConverts(initValue, numericType); + if(result.invalid()) + { + return {ConvertResultTo(std::move(result), {})}; } + std::vector compDims = std::vector{numComponents}; std::vector tupleDims = {}; auto* parentAM = dataStructure.getDataAs(dataArrayPath.getParent()); @@ -220,228 +167,23 @@ IFilter::PreflightResult CreateDataArrayFilter::preflightImpl(const DataStructur } } - auto arrayDataType = ConvertNumericTypeToDataType(numericType); auto action = std::make_unique(ConvertNumericTypeToDataType(numericType), tupleDims, compDims, dataArrayPath, dataFormat); resultOutputActions.value().appendAction(std::move(action)); - auto seedArrayNameValue = filterArgs.value(k_SeedArrayName_Key); - auto initializeTypeValue = static_cast(filterArgs.value(k_InitType_Key)); - - // nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - - if(arrayDataType == DataType::boolean) - { - std::stringstream updatedValStrm; - - updatedValStrm << "We detected that you are doing an operation on a boolean array.\n"; - updatedValStrm << "The ONLY two ways to specify a 'false' boolean value are as follows:\n"; - updatedValStrm << "- boolean value string types as follows ignoring apostrophe marks: 'False', 'FALSE', 'false'\n"; - updatedValStrm << "- all well formed integers and well formed floating point definitions of 0\n\n"; - - updatedValStrm << "ANY OTHER string or number WILL BE 'true', although it is good practice to define true values as follows:\n"; - updatedValStrm << "- boolean value string types as follows ignoring apostrophe marks: 'True', 'TRUE', 'true'\n"; - updatedValStrm << "- all well formed integers and well formed floating point definitions of 1"; - - preflightUpdatedValues.push_back({"Boolean Note", updatedValStrm.str()}); - } - - if(numComponents > 1) - { - std::stringstream updatedValStrm; - - updatedValStrm << "We detected that you are doing an operation on a multi-component array.\n"; - updatedValStrm - << "If you do NOT want to use unique values for each component, you can just supply one value to the input box and we will apply that value to every component for the tuple.\nExample: 1\n\n"; - - updatedValStrm << fmt::format("If you DO want to use unique values for each component, you need to supply {} values of type {} seperated by '{}'.\n", numComponents, - DataTypeToString(arrayDataType), k_DelimiterChar); - updatedValStrm << "Example: "; - - for(usize comp = 0; comp < numComponents; comp++) - { - updatedValStrm << "1"; - - if(comp != numComponents - 1) - { - updatedValStrm << k_DelimiterChar; - } - } - - preflightUpdatedValues.push_back({"Multi-Component Note", updatedValStrm.str()}); - } - - std::stringstream operationNuancesStrm; - - switch(initializeTypeValue) - { - case InitializeType::FillValue: { - auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_InitValue_Key), 1); - if(result.outputActions.invalid()) - { - return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; - } - - operationNuancesStrm << "None to note"; - - break; - } - case InitializeType::Incremental: { - auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_StartingFillValue_Key), 1); - if(result.outputActions.invalid()) - { - return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; - } - - if(arrayDataType == DataType::boolean) - { - // custom bool checks here - std::stringstream updatedValStrm; - - updatedValStrm << "We detected that you are doing an incremental operation on a boolean array.\n"; - updatedValStrm << "For the step values please enter uint8 values, preferably a 0 or 1 only.\n"; - - switch(static_cast(filterArgs.value(k_StepOperation_Key))) - { - case Addition: { - updatedValStrm << "You have currently selected the addition operation.\nAny step value that is greater than 0 will cause all values to be 'true' after the first tuple, 'true' " - "values will remain unchanged.\n"; - updatedValStrm << "The two possibilities:\n"; - updatedValStrm << "- If your start value is 'false' and step value > 0, the array will initialize to | false | true | true | ... |\n"; - updatedValStrm << "- If your start value is 'true' and step value > 0, the array will initialize to | true | true | true | ... |"; - break; - } - case Subtraction: { - updatedValStrm << "You have currently selected the addition operation.\nAny step value that is greater than 0 will cause all values to be 'false' after the first tuple, 'false' " - "values will remain unchanged.\n"; - updatedValStrm << "The two possibilities:\n"; - updatedValStrm << "- If your start value is 'true' and step value > 0, the array will initialize to | true | false | false | ... |\n"; - updatedValStrm << "- If your start value is 'false' and step value > 0, the array will initialize to | false | false | false | ... |"; - break; - } - } - - preflightUpdatedValues.push_back({"Boolean Incremental Nuances", updatedValStrm.str()}); - - result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, DataType::uint8, numComponents, filterArgs.value(k_StepValue_Key), 1); - if(result.outputActions.invalid()) - { - return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; - } - } - else - { - result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_StepValue_Key), 1); - if(result.outputActions.invalid()) - { - return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; - } - } - auto values = StringUtilities::split(filterArgs.value(k_StepValue_Key), ";", false); - std::vector zeroIdx; - for(size_t i = 0; i < values.size(); i++) - { - if(values[i] == "0") - { - zeroIdx.push_back(i); - } - } - if(!zeroIdx.empty()) - { - - operationNuancesStrm << "Warning: Zero Step Value found. Component(s) " << fmt::format("[{}]", fmt::join(zeroIdx, ",")) - << " have a ZERO value for the step/increment.\n The values for those components will be unchanged from the starting value.\n"; - operationNuancesStrm << fmt::format(" Example: Suppose we have a two component array with a Step Values of '2{}0', Starting Values of '0', and an addition Step Operation\n", k_DelimiterChar); - operationNuancesStrm << " The output array would look like 0,0 | 2,0 | 4,0 | 6,0 | ..."; - } - break; - } - case InitializeType::RangedRandom: { - auto result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_InitStartRange_Key), 1); - if(result.outputActions.invalid()) - { - return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; - } - - result = ExecuteDataFunction(::ValidateMultiInputFunctor{}, arrayDataType, numComponents, filterArgs.value(k_InitEndRange_Key), 1); - if(result.outputActions.invalid()) - { - return {MergeResults(result.outputActions, std::move(resultOutputActions)), std::move(preflightUpdatedValues)}; - } - - [[fallthrough]]; - } - case InitializeType::Random: { - auto createAction = std::make_unique(DataType::uint64, std::vector{1}, std::vector{1}, DataPath({seedArrayNameValue})); - resultOutputActions.value().appendAction(std::move(createAction)); - - if(numComponents == 1) - { - if(filterArgs.value(k_StandardizeSeed_Key)) - { - operationNuancesStrm << fmt::format("You chose to standardize the seed for each component, but the array {} is a single component so it will not alter the randomization scheme.", - dataArrayPath.getTargetName()); - } - } - else - { - if(filterArgs.value(k_StandardizeSeed_Key)) - { - operationNuancesStrm << "This generates THE SAME sequences of random numbers for each component in the array based on one seed.\n"; - operationNuancesStrm << "The resulting array will look like | 1,1,1 | 9,9,9 | ...\n"; - } - else - { - operationNuancesStrm << "This generates DIFFERENT sequences of random numbers for each component in the array based on x seeds all modified versions of an original seed.\n"; - operationNuancesStrm << "The resulting array will look like | 1,9,5 | 7,1,6 | ...\n"; - } - } - - break; - } - } - - preflightUpdatedValues.push_back({"Operation Nuances", operationNuancesStrm.str()}); - - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ -Result<> CreateDataArrayFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, +Result<> CreateDataArrayFilter::executeImpl(DataStructure& dataStructure, const Arguments& args, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto path = filterArgs.value(k_DataPath_Key); - - ExecuteNeighborFunction(CreateAndInitArrayFunctor{}, ConvertNumericTypeToDataType(filterArgs.value(k_NumericType_Key)), dataStructure.getDataAs(path), "0"); + auto path = args.value(k_DataPath_Key); + auto initValue = args.value(k_InitializationValue_Key); - auto initType = static_cast(filterArgs.value(k_InitType_Key)); - - auto seed = filterArgs.value(k_SeedValue_Key); - if(!filterArgs.value(k_UseSeed_Key)) - { - seed = static_cast(std::chrono::steady_clock::now().time_since_epoch().count()); - } - - if(initType == InitializeType::Random || initType == InitializeType::RangedRandom) - { - // Store Seed Value in Top Level Array - dataStructure.getDataRefAs(DataPath({filterArgs.value(k_SeedArrayName_Key)}))[0] = seed; - } + ExecuteNeighborFunction(CreateAndInitArrayFunctor{}, ConvertNumericTypeToDataType(args.value(k_NumericType_Key)), dataStructure.getDataAs(path), initValue); - InitializeDataInputValues inputValues; - inputValues.InputArrayPath = filterArgs.value(k_DataPath_Key); - inputValues.initType = initType; - inputValues.stepType = static_cast(filterArgs.value(k_StepOperation_Key)); - inputValues.stringValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitValue_Key)), k_DelimiterChar); - inputValues.startValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_StartingFillValue_Key)), k_DelimiterChar); - inputValues.stepValues = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_StepValue_Key)), k_DelimiterChar); - inputValues.seed = seed; - inputValues.randBegin = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitStartRange_Key)), k_DelimiterChar); - inputValues.randEnd = StringUtilities::split(StringUtilities::trimmed(filterArgs.value(k_InitEndRange_Key)), k_DelimiterChar); - inputValues.standardizeSeed = filterArgs.value(k_StandardizeSeed_Key); - - return InitializeData(dataStructure, messageHandler, shouldCancel, &inputValues)(); + return {}; } namespace @@ -464,8 +206,9 @@ Result CreateDataArrayFilter::FromSIMPLJson(const nlohmann::json& jso std::vector> results; results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_ScalarTypeKey, k_NumericType_Key)); + results.push_back(SIMPLConversion::ConvertParameter>(args, json, SIMPL::k_NumberOfComponentsKey, k_NumComps_Key)); // Initialize Type parameter is not applicable in NX - results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_InitializationValueKey, k_InitValue_Key)); + results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_InitializationValueKey, k_InitializationValue_Key)); // Initialization Range parameter is not applicable in NX // Starting Index value parameter is not applicable in NX results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_NewArrayKey, k_DataPath_Key)); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp index bf225bc39d..e3e38e9856 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.hpp @@ -23,21 +23,11 @@ class SIMPLNXCORE_EXPORT CreateDataArrayFilter : public IFilter // Parameter Keys static inline constexpr StringLiteral k_NumericType_Key = "numeric_type_index"; static inline constexpr StringLiteral k_AdvancedOptions_Key = "set_tuple_dimensions"; - static inline constexpr StringLiteral k_CompDims_Key = "component_dimensions"; + static inline constexpr StringLiteral k_NumComps_Key = "component_count"; static inline constexpr StringLiteral k_TupleDims_Key = "tuple_dimensions"; static inline constexpr StringLiteral k_DataPath_Key = "output_array_path"; + static inline constexpr StringLiteral k_InitializationValue_Key = "initialization_value_str"; static inline constexpr StringLiteral k_DataFormat_Key = "data_format"; - static inline constexpr StringLiteral k_InitType_Key = "init_type_index"; - static inline constexpr StringLiteral k_InitValue_Key = "init_value"; - static inline constexpr StringLiteral k_StartingFillValue_Key = "starting_fill_value"; - static inline constexpr StringLiteral k_StepOperation_Key = "step_operation_index"; - static inline constexpr StringLiteral k_StepValue_Key = "step_value"; - static inline constexpr StringLiteral k_UseSeed_Key = "use_seed"; - static inline constexpr StringLiteral k_SeedValue_Key = "seed_value"; - static inline constexpr StringLiteral k_SeedArrayName_Key = "seed_array_name"; - static inline constexpr StringLiteral k_InitStartRange_Key = "init_start_range"; - static inline constexpr StringLiteral k_InitEndRange_Key = "init_end_range"; - static inline constexpr StringLiteral k_StandardizeSeed_Key = "standardize_seed"; /** * @brief Reads SIMPL json and converts it simplnx Arguments. diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp index 1d462f1c34..42fc0372fe 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp @@ -2205,7 +2205,7 @@ struct KDTreeEigenMatrixAdaptor /** @} */ }; // end of KDTreeEigenMatrixAdaptor -/** @} */ + /** @} */ /** @} */ // end of grouping } // namespace nanoflann diff --git a/src/Plugins/SimplnxCore/test/CMakeLists.txt b/src/Plugins/SimplnxCore/test/CMakeLists.txt index 93e0bab441..691dc537d1 100644 --- a/src/Plugins/SimplnxCore/test/CMakeLists.txt +++ b/src/Plugins/SimplnxCore/test/CMakeLists.txt @@ -52,6 +52,7 @@ set(${PLUGIN_NAME}UnitTest_SRCS CoreFilterTest.cpp CreateAttributeMatrixTest.cpp CreateDataArrayTest.cpp + CreateDataArrayAdvancedTest.cpp CreateFeatureArrayFromElementArrayTest.cpp CreateGeometryTest.cpp CreateImageGeometryTest.cpp diff --git a/src/Plugins/SimplnxCore/test/CreateDataArrayAdvancedTest.cpp b/src/Plugins/SimplnxCore/test/CreateDataArrayAdvancedTest.cpp new file mode 100644 index 0000000000..670acac366 --- /dev/null +++ b/src/Plugins/SimplnxCore/test/CreateDataArrayAdvancedTest.cpp @@ -0,0 +1,138 @@ +#include "SimplnxCore/Filters/CreateDataArrayAdvancedFilter.hpp" +#include "SimplnxCore/SimplnxCore_test_dirs.hpp" + +#include "simplnx/Parameters/DynamicTableParameter.hpp" +#include "simplnx/UnitTest/UnitTestCommon.hpp" + +#include + +using namespace nx::core; + +TEST_CASE("SimplnxCore::CreateDataArrayAdvancedFilter(Instantiate)", "[SimplnxCore][CreateDataArrayAdvancedFilter]") +{ + static constexpr uint64 k_NComp = 3; + static constexpr uint64 k_NumTuples = 25; + const static DynamicTableInfo::TableDataType k_TupleDims = {{static_cast(k_NumTuples)}}; + + static const DataPath k_DataPath({"foo"}); + + CreateDataArrayAdvancedFilter filter; + DataStructure dataStructure; + Arguments args; + + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::int32)); + args.insert(CreateDataArrayAdvancedFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{static_cast(k_NComp)}})); + args.insert(CreateDataArrayAdvancedFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); + args.insert(CreateDataArrayAdvancedFilter::k_DataPath_Key, std::make_any(k_DataPath)); + + auto result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_VALID(result.result); +} + +TEST_CASE("SimplnxCore::CreateDataArrayAdvancedFilter(Invalid Parameters)", "[SimplnxCore][CreateDataArrayAdvancedFilter]") +{ + static constexpr uint64 k_NComp = 3; + static constexpr uint64 k_NumTuples = 25; + const static DynamicTableInfo::TableDataType k_TupleDims = {{static_cast(k_NumTuples)}}; + static const DataPath k_DataPath({"foo"}); + + CreateDataArrayAdvancedFilter filter; + DataStructure dataStructure; + Arguments args; + + SECTION("Section1") + { + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::uint16)); + args.insert(CreateDataArrayAdvancedFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{static_cast(k_NComp)}})); + args.insert(CreateDataArrayAdvancedFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); + args.insert(CreateDataArrayAdvancedFilter::k_DataPath_Key, std::make_any(k_DataPath)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("-1")); + + auto result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + } + SECTION("Section2") + { + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::int8)); + args.insert(CreateDataArrayAdvancedFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{static_cast(k_NComp)}})); + args.insert(CreateDataArrayAdvancedFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); + args.insert(CreateDataArrayAdvancedFilter::k_DataPath_Key, std::make_any(k_DataPath)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("1024")); + + auto result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + } + SECTION("Section3") + { + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::float32)); + args.insert(CreateDataArrayAdvancedFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{0.0}})); + args.insert(CreateDataArrayAdvancedFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); + args.insert(CreateDataArrayAdvancedFilter::k_DataPath_Key, std::make_any(k_DataPath)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("1")); + + auto result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + } + SECTION("Section4") + { + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::float32)); + args.insert(CreateDataArrayAdvancedFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{1.0}})); + + DynamicTableInfo::TableDataType tupleDims = {{static_cast(0.0)}}; + args.insert(CreateDataArrayAdvancedFilter::k_TupleDims_Key, std::make_any(tupleDims)); + args.insert(CreateDataArrayAdvancedFilter::k_DataPath_Key, std::make_any(k_DataPath)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("1")); + + auto result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + } + SECTION("Section5") + { + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::int8)); + args.insert(CreateDataArrayAdvancedFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{1.0}})); + DynamicTableInfo::TableDataType tupleDims = {{static_cast(1.0)}}; + args.insert(CreateDataArrayAdvancedFilter::k_TupleDims_Key, std::make_any(tupleDims)); + args.insert(CreateDataArrayAdvancedFilter::k_DataPath_Key, std::make_any(k_DataPath)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("")); + + auto result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + } + SECTION("Section6") + { + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::int8)); + args.insert(CreateDataArrayAdvancedFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{1.0}})); + DynamicTableInfo::TableDataType tupleDims = {{static_cast(1.0)}}; + args.insert(CreateDataArrayAdvancedFilter::k_TupleDims_Key, std::make_any(tupleDims)); + args.insert(CreateDataArrayAdvancedFilter::k_DataPath_Key, std::make_any(k_DataPath)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("1000")); + + auto result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::uint8)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("-1")); + result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::int16)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("70000")); + result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::uint16)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("-1")); + result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::int32)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("4294967297")); + result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + + args.insert(CreateDataArrayAdvancedFilter::k_NumericType_Key, std::make_any(NumericType::int32)); + args.insert(CreateDataArrayAdvancedFilter::k_InitValue_Key, std::make_any("-4294967297")); + result = filter.execute(dataStructure, args); + SIMPLNX_RESULT_REQUIRE_INVALID(result.result); + } +} diff --git a/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp b/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp index bd6cfa76ee..41aa318dd4 100644 --- a/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp +++ b/src/Plugins/SimplnxCore/test/CreateDataArrayTest.cpp @@ -21,7 +21,7 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Instantiate)", "[SimplnxCore][Crea Arguments args; args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int32)); - args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{static_cast(k_NComp)}})); + args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(k_NComp)); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); @@ -43,10 +43,10 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section1") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::uint16)); - args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{static_cast(k_NComp)}})); + args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(k_NComp)); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("-1")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("-1")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -54,10 +54,10 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section2") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int8)); - args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{static_cast(k_NComp)}})); + args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(k_NComp)); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1024")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("1024")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -65,10 +65,10 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section3") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::float32)); - args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{0.0}})); + args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(0)); args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(k_TupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("1")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -76,12 +76,12 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section4") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::float32)); - args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{1.0}})); + args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(1)); DynamicTableInfo::TableDataType tupleDims = {{static_cast(0.0)}}; args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(tupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("1")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -89,11 +89,11 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section5") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int8)); - args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{1.0}})); + args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(1)); DynamicTableInfo::TableDataType tupleDims = {{static_cast(1.0)}}; args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(tupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); @@ -101,37 +101,37 @@ TEST_CASE("SimplnxCore::CreateDataArrayFilter(Invalid Parameters)", "[SimplnxCor SECTION("Section6") { args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int8)); - args.insert(CreateDataArrayFilter::k_CompDims_Key, std::make_any(DynamicTableInfo::TableDataType{{1.0}})); + args.insert(CreateDataArrayFilter::k_NumComps_Key, std::make_any(1)); DynamicTableInfo::TableDataType tupleDims = {{static_cast(1.0)}}; args.insert(CreateDataArrayFilter::k_TupleDims_Key, std::make_any(tupleDims)); args.insert(CreateDataArrayFilter::k_DataPath_Key, std::make_any(k_DataPath)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("1000")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("1000")); auto result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::uint8)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("-1")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("-1")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int16)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("70000")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("70000")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::uint16)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("-1")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("-1")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int32)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("4294967297")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("4294967297")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); args.insert(CreateDataArrayFilter::k_NumericType_Key, std::make_any(NumericType::int32)); - args.insert(CreateDataArrayFilter::k_InitValue_Key, std::make_any("-4294967297")); + args.insert(CreateDataArrayFilter::k_InitializationValue_Key, std::make_any("-4294967297")); result = filter.execute(dataStructure, args); SIMPLNX_RESULT_REQUIRE_INVALID(result.result); } diff --git a/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp b/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp index 8c8cf99da8..87fdc875e0 100644 --- a/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp +++ b/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp @@ -160,10 +160,10 @@ Pipeline CreateExportPipeline() Arguments args; args.insert("set_tuple_dimensions", std::make_any(true)); args.insert("numeric_type_index", std::make_any(NumericType::int8)); - args.insert("component_dimensions", DynamicTableInfo::TableDataType{{3.0}}); + args.insert("component_count", std::make_any(3)); args.insert("tuple_dimensions", DynamicTableInfo::TableDataType{{1.0}}); - args.insert("init_value", std::make_any("7")); + args.insert("initialization_value_str", std::make_any("7")); args.insert("output_array_path", DataPath({DataNames::k_ArrayName})); args.insert("data_format", std::string("")); pipeline.push_back(k_CreateDataArrayHandle, args); diff --git a/src/Plugins/TestOne/src/TestOne/Filters/CreateOutOfCoreArrayFilter.hpp b/src/Plugins/TestOne/src/TestOne/Filters/CreateOutOfCoreArrayFilter.hpp index 2b63c45269..0912ca8ea2 100644 --- a/src/Plugins/TestOne/src/TestOne/Filters/CreateOutOfCoreArrayFilter.hpp +++ b/src/Plugins/TestOne/src/TestOne/Filters/CreateOutOfCoreArrayFilter.hpp @@ -21,7 +21,7 @@ class TESTONE_EXPORT CreateOutOfCoreArray : public IFilter // Parameter Keys static inline constexpr StringLiteral k_NumericType_Key = "numeric_type_index"; - static inline constexpr StringLiteral k_NumComps_Key = "component_dimensions"; + static inline constexpr StringLiteral k_NumComps_Key = "component_count"; static inline constexpr StringLiteral k_TupleDims_Key = "tuple_dimensions"; static inline constexpr StringLiteral k_DataPath_Key = "output_array_path"; static inline constexpr StringLiteral k_InitilizationValue_Key = "initialization_value_str"; diff --git a/wrapping/python/docs/source/DataObjects.rst b/wrapping/python/docs/source/DataObjects.rst index 758951dbb0..1c136ef08a 100644 --- a/wrapping/python/docs/source/DataObjects.rst +++ b/wrapping/python/docs/source/DataObjects.rst @@ -297,13 +297,12 @@ and then print the name, tuple_dimensions and component_dims of the created DatA data_structure = nx.DataStructure() result = nx.CreateDataArrayFilter.execute(data_structure=data_structure, - component_dimensions=[[3]], - data_format="", - init_type_index=0, - init_value="0", - numeric_type_index=nx.NumericType.float32, - output_array_path=nx.DataPath(["2D Array"]), - tuple_dimensions=[[4, 5]]) + component_count=3, + data_format="", + initialization_value="0", + numeric_type=nx.NumericType.float32, + output_data_array=nx.DataPath(["2D Array"]), + tuple_dimensions=[[4, 5]]) data_array = data_structure[output_array_path] print(f'name: {data_array.name}') @@ -475,9 +474,9 @@ Pipeline create_data_array_args:dict = { "data_format": "", - "component_dimensions":[1], + "component_count":1, "initialization_value":"0", - "numeric_type_index":nx.NumericType.int8, + "numeric_type":nx.NumericType.int8, "output_data_array":nx.DataPath("Geometry/Cell Data/data"), "advanced_options": False, "tuple_dimensions": [[10,20,30]] diff --git a/wrapping/python/docs/source/Python_Introduction.rst b/wrapping/python/docs/source/Python_Introduction.rst index b2b65e23bb..752834b8fe 100644 --- a/wrapping/python/docs/source/Python_Introduction.rst +++ b/wrapping/python/docs/source/Python_Introduction.rst @@ -77,10 +77,10 @@ An example of executing a file in immediate mode using a filter from the simplnx import simplnx as nx result = nx.CreateDataArrayFilter.execute(data_structure=data_structure, - component_dimensions=[[1]], + component_count=1, data_format="", initialization_value="10", - numeric_type_index=nx.NumericType.float32, + numeric_type=nx.NumericType.float32, output_data_array=nx.DataPath(["3D Array"]), tuple_dimensions= [[3, 2, 5]]) npdata = data_structure[nx.DataPath(["3D Array"])].npview() @@ -130,10 +130,10 @@ of the method is as follows. # Instantiate and execute immediately teh CreateDataArrayFilter Filter result = nx.CreateDataArrayFilter.execute(data_structure=data_structure, - component_dimensions=[[1]], + component_count=1, data_format="", initialization_value="10", - numeric_type_index=nx.NumericType.float32, + numeric_type=nx.NumericType.float32, output_data_array=nx.DataPath(["3D Array"]), tuple_dimensions= [[3, 2, 5]]) # The returned result holds any warnings or errors that occurred during execution @@ -254,8 +254,8 @@ connectivity from a sample file. # Create the vertex array and fill it from data on disk array_path = nx.DataPath(['Vertices']) result = nx.CreateDataArrayFilter.execute(data_structure, - numeric_type_index=nx.NumericType.float32, - component_dimensions=[[3]], + numeric_type=nx.NumericType.float32, + component_count=3, tuple_dimensions=[[144]], output_data_array=array_path, initialization_value='0') @@ -266,8 +266,8 @@ connectivity from a sample file. # Create the triangle connectivity array and fill it from data on disk array_path = nx.DataPath(['Triangles']) result = nx.CreateDataArrayFilter.execute(data_structure, - numeric_type_index=nx.NumericType.uint64, - component_dimensions=[[3]], + numeric_type=nx.NumericType.uint64, + component_count=3, tuple_dimensions=[[242]], output_data_array=array_path, initialization_value='0') @@ -336,10 +336,10 @@ The next code section was take from `basic_arrays.py class CreateArrayFilter: NUMERIC_TYPE_KEY = "numeric_type_index" - INITILIZATION_VALUE_KEY = "init_value" + INITILIZATION_VALUE_KEY = "initialization_value_str" NUM_COMPS_KEY = "component_count" DATA_PATH_KEY = "output_array_path" TUPLE_DIMS_KEY = "tuple_dimensions" From 59230260c09752e65cffe772dc8418737d49e5cf Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 19 Sep 2024 13:45:50 -0400 Subject: [PATCH 08/10] Rearrange the parameters a bit to make the flow more logical. The user should start from the "top down" when filling out the parameters. 1: Name 2: Type 3: Number of Tuples 4: Number of Components 5: Initialize values. Signed-off-by: Michael Jackson --- .../Common/ITKArrayHelper.hpp | 2 + .../Filters/CreateDataArrayAdvancedFilter.cpp | 42 +++++++++---------- .../Filters/CreateDataArrayFilter.cpp | 16 +++---- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp index 6d6d655f83..ff19849845 100644 --- a/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp +++ b/src/Plugins/ITKImageProcessing/src/ITKImageProcessing/Common/ITKArrayHelper.hpp @@ -383,8 +383,10 @@ DataStore> ConvertImageToDataStore(itk::Image concept NotBoolT = !std::is_same_v; +// clang-format on template Result<> ConvertImageToDataStore(DataStore& dataStore, itk::Image& image) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp index 1a76a74480..bb9d3036c0 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp @@ -71,15 +71,33 @@ Parameters CreateDataArrayAdvancedFilter::parameters() const { Parameters params; - params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); + params.insertSeparator(Parameters::Separator{"Output Data Array"}); + params.insert(std::make_unique(k_DataPath_Key, "Created Array", "Array storing the data", DataPath({"Data"}))); params.insert(std::make_unique(k_NumericType_Key, "Output Numeric Type", "Numeric Type of data to create", NumericType::int32)); + params.insert(std::make_unique(k_DataFormat_Key, "Data Format", + "This value will specify which data format is used by the array's data store. An empty string results in in-memory data store.", "")); + + params.insertSeparator(Parameters::Separator{"Tuple Dimensions"}); + params.insertLinkableParameter(std::make_unique( + k_AdvancedOptions_Key, "Set Tuple Dimensions [not required if creating inside an existing Attribute Matrix]", + "This allows the user to set the tuple dimensions directly rather than just inheriting them. This option is NOT required if you are creating the Data Array in an Attribute Matrix", true)); - params.insertSeparator(Parameters::Separator{"Component Handling"}); { + DynamicTableInfo tableInfo; + tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); + tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "TUPLE DIM {}")); + params.insert(std::make_unique(k_TupleDims_Key, "Data Array Tuple Dimensions (Slowest to Fastest Dimensions)", + "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", tableInfo)); + } + + params.insertSeparator(Parameters::Separator{"Component Dimensions"}); + { + DynamicTableInfo::TableDataType defaultValues = {{1ULL}}; DynamicTableInfo tableInfo; tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "COMP DIM {}")); - params.insert(std::make_unique(k_CompDims_Key, "Data Array Component Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Component Dimensions.", tableInfo)); + params.insert(std::make_unique(k_CompDims_Key, "Data Array Component Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Component Dimensions.", defaultValues, + tableInfo)); } params.insertSeparator(Parameters::Separator{"Initialization Options"}); @@ -107,24 +125,6 @@ Parameters CreateDataArrayAdvancedFilter::parameters() const std::make_unique(k_InitStartRange_Key, "Initialization Start Range [Seperated with ;]", "[Inclusive] The lower bound initialization range for random values", "0;0;0")); params.insert(std::make_unique(k_InitEndRange_Key, "Initialization End Range [Seperated with ;]", "[Inclusive] The upper bound initialization range for random values", "1;1;1")); - params.insertSeparator(Parameters::Separator{"Output Data Array"}); - params.insert(std::make_unique(k_DataPath_Key, "Created Array", "Array storing the data", DataPath{})); - params.insert(std::make_unique(k_DataFormat_Key, "Data Format", - "This value will specify which data format is used by the array's data store. An empty string results in in-memory data store.", "")); - - params.insertSeparator(Parameters::Separator{"Tuple Handling"}); - params.insertLinkableParameter(std::make_unique( - k_AdvancedOptions_Key, "Set Tuple Dimensions [not required if creating inside an Attribute Matrix]", - "This allows the user to set the tuple dimensions directly rather than just inheriting them. This option is NOT required if you are creating the Data Array in an Attribute Matrix", true)); - - { - DynamicTableInfo tableInfo; - tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); - tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "TUPLE DIM {}")); - params.insert(std::make_unique(k_TupleDims_Key, "Data Array Tuple Dimensions (Slowest to Fastest Dimensions)", - "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", tableInfo)); - } - // Associate the Linkable Parameter(s) to the children parameters that they control params.linkParameters(k_AdvancedOptions_Key, k_TupleDims_Key, true); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp index b93e305e5c..834668b774 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp @@ -71,17 +71,13 @@ Parameters CreateDataArrayFilter::parameters() const { Parameters params; - params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); - params.insert(std::make_unique(k_NumericType_Key, "Output Numeric Type", "Numeric Type of data to create", NumericType::int32)); - params.insert(std::make_unique(k_InitializationValue_Key, "Initialization Value", "This value will be used to fill the new array", "0")); - params.insert(std::make_unique(k_NumComps_Key, "Number of Components", "Number of components", 1)); - params.insertSeparator(Parameters::Separator{"Output Data Array"}); - params.insert(std::make_unique(k_DataPath_Key, "Created Array", "Array storing the data", DataPath{})); + params.insert(std::make_unique(k_DataPath_Key, "Created Array", "Array storing the data", DataPath({"Data"}))); + params.insert(std::make_unique(k_NumericType_Key, "Output Numeric Type", "Numeric Type of data to create", NumericType::int32)); params.insert(std::make_unique(k_DataFormat_Key, "Data Format", "This value will specify which data format is used by the array's data store. An empty string results in in-memory data store.", "")); - params.insertSeparator(Parameters::Separator{"Tuple Handling"}); + params.insertSeparator(Parameters::Separator{"Tuple Dimensions"}); params.insertLinkableParameter(std::make_unique( k_AdvancedOptions_Key, "Set Tuple Dimensions [not required if creating inside an Attribute Matrix]", "This allows the user to set the tuple dimensions directly rather than just inheriting them. This option is NOT required if you are creating the Data Array in an Attribute Matrix", true)); @@ -92,6 +88,12 @@ Parameters CreateDataArrayFilter::parameters() const params.insert(std::make_unique(k_TupleDims_Key, "Data Array Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", tableInfo)); + params.insertSeparator(Parameters::Separator{"Component Dimensions"}); + params.insert(std::make_unique(k_NumComps_Key, "Total Number of Components", "Total number of components. Do not set the component dimensions.", 1)); + + params.insertSeparator(Parameters::Separator{"Initialization Options"}); + params.insert(std::make_unique(k_InitializationValue_Key, "Initialization Value", "This value will be used to fill the new array", "0")); + // Associate the Linkable Parameter(s) to the children parameters that they control params.linkParameters(k_AdvancedOptions_Key, k_TupleDims_Key, true); From a326a82a0002714b629e483064970d4c1c16182c Mon Sep 17 00:00:00 2001 From: Joey Kleingers Date: Fri, 20 Sep 2024 10:09:25 -0400 Subject: [PATCH 09/10] Adjust parameter human labels and help text, add default tuple dims. Signed-off-by: Joey Kleingers --- .../Filters/CreateDataArrayAdvancedFilter.cpp | 50 ++++++++++++++----- .../Filters/InitializeDataFilter.cpp | 10 ++-- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp index bb9d3036c0..83aadcbe52 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp @@ -86,24 +86,25 @@ Parameters CreateDataArrayAdvancedFilter::parameters() const DynamicTableInfo tableInfo; tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "TUPLE DIM {}")); + const DynamicTableInfo::TableDataType defaultTable{{1.0F}}; params.insert(std::make_unique(k_TupleDims_Key, "Data Array Tuple Dimensions (Slowest to Fastest Dimensions)", - "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", tableInfo)); + "Slowest to Fastest Dimensions. Note this might be opposite displayed by an image geometry.", defaultTable, tableInfo)); } params.insertSeparator(Parameters::Separator{"Component Dimensions"}); { - DynamicTableInfo::TableDataType defaultValues = {{1ULL}}; DynamicTableInfo tableInfo; tableInfo.setRowsInfo(DynamicTableInfo::StaticVectorInfo(1)); tableInfo.setColsInfo(DynamicTableInfo::DynamicVectorInfo(1, "COMP DIM {}")); - params.insert(std::make_unique(k_CompDims_Key, "Data Array Component Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Component Dimensions.", defaultValues, + const DynamicTableInfo::TableDataType defaultTable{{1.0F}}; + params.insert(std::make_unique(k_CompDims_Key, "Data Array Component Dimensions (Slowest to Fastest Dimensions)", "Slowest to Fastest Component Dimensions.", defaultTable, tableInfo)); } params.insertSeparator(Parameters::Separator{"Initialization Options"}); - params.insertLinkableParameter(std::make_unique(k_InitType_Key, "Initialization Type", "Method for determining the what values of the data in the array should be initialized to", - static_cast(0), - ChoicesParameter::Choices{"Fill Value", "Incremental", "Random", "Random With Range"})); // sequence dependent DO NOT REORDER + params.insertLinkableParameter(std::make_unique( + k_InitType_Key, "Initialization Type", "Method for determining the what values of the data in the array should be initialized to", static_cast(0), + ChoicesParameter::Choices{"Fill Value", "Incremental/Decremental", "Random", "Random With Range"})); // sequence dependent DO NOT REORDER params.insert(std::make_unique(k_InitValue_Key, "Fill Values [Seperated with ;]", "Specify values for each component. Ex: A 3-component array would be 6;8;12 and every tuple would have these same component values", "1;1;1")); @@ -112,8 +113,8 @@ Parameters CreateDataArrayAdvancedFilter::parameters() const k_StartingFillValue_Key, "Starting Value [Seperated with ;]", "The value to start incrementing from. Ex: 6;8;12 would increment a 3-component array starting at 6 for the first component, 8 for the 2nd, and 12 for the 3rd.", "0;1;2")); params.insert(std::make_unique(k_StepOperation_Key, "Step Operation", "The type of step operation to perform", static_cast(0), - ChoicesParameter::Choices{"Addition", "Subtraction"})); - params.insert(std::make_unique(k_StepValue_Key, "Increment/Step Value [Seperated with ;]", "The number to increment/decrement the fill value by", "1;1;1")); + ChoicesParameter::Choices{"Incrementing", "Decrementing"})); + params.insert(std::make_unique(k_StepValue_Key, "Step Value [Seperated with ;]", "The number to increment/decrement the fill value by", "1;1;1")); params.insert(std::make_unique(k_UseSeed_Key, "Use Seed for Random Generation", "When true, the Seed Value will be used to seed the generator", false)); params.insert(std::make_unique>(k_SeedValue_Key, "Seed Value", "The seed fed into the random generator", std::mt19937::default_seed)); @@ -255,18 +256,41 @@ IFilter::PreflightResult CreateDataArrayAdvancedFilter::preflightImpl(const Data updatedValStrm << "If you do NOT want to use unique values for each component, you can just supply one value to the input box and we will apply that value to every component for the tuple.\nExample: 1\n\n"; - updatedValStrm << fmt::format("If you DO want to use unique values for each component, you need to supply {} values of type {} seperated by '{}'.\n", numComponents, + updatedValStrm << fmt::format("If you DO want to use unique values for each component, you need to supply {} values of type {} separated by '{}'.\n", numComponents, DataTypeToString(arrayDataType), k_DelimiterChar); + + // Define a threshold for displaying all components + const usize threshold = 10; + updatedValStrm << "Example: "; - for(usize comp = 0; comp < numComponents; comp++) + if(numComponents <= threshold) { - updatedValStrm << "1"; + // Show all component values + for(usize comp = 0; comp < numComponents; comp++) + { + updatedValStrm << "1"; - if(comp != numComponents - 1) + if(comp != numComponents - 1) + { + updatedValStrm << k_DelimiterChar; + } + } + } + else + { + // Show a limited number of component values followed by a summary + const usize displayCount = 10; + for(usize comp = 0; comp < displayCount; comp++) { - updatedValStrm << k_DelimiterChar; + updatedValStrm << "1"; + + if(comp != displayCount - 1) + { + updatedValStrm << k_DelimiterChar; + } } + updatedValStrm << fmt::format(" ... {} more '1's", numComponents - displayCount); } preflightUpdatedValues.push_back({"Multi-Component Note", updatedValStrm.str()}); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp index 4e6d307880..f69b25e01b 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp @@ -65,17 +65,17 @@ Parameters InitializeDataFilter::parameters() const params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); - params.insertLinkableParameter(std::make_unique(k_InitType_Key, "Initialization Type", "Method for determining the what values of the data in the array should be initialized to", - static_cast(0), - ChoicesParameter::Choices{"Fill Value", "Incremental", "Random", "Random With Range"})); // sequence dependent DO NOT REORDER + params.insertLinkableParameter(std::make_unique( + k_InitType_Key, "Initialization Type", "Method for determining the what values of the data in the array should be initialized to", static_cast(0), + ChoicesParameter::Choices{"Fill Value", "Incremental/Decremental", "Random", "Random With Range"})); // sequence dependent DO NOT REORDER params.insert(std::make_unique(k_InitValue_Key, "Fill Values [Seperated with ;]", "Specify values for each component. Ex: A 3-component array would be 6;8;12 and every tuple would have these same component values", "1;1;1")); params.insert(std::make_unique(k_StartingFillValue_Key, "Starting Value [Seperated with ;]", "The value to start incrementing from", "0;1;2")); params.insert(std::make_unique(k_StepOperation_Key, "Step Operation", "The type of step operation to preform", static_cast(0), - ChoicesParameter::Choices{"Addition", "Subtraction"})); - params.insert(std::make_unique(k_StepValue_Key, "Increment/Step Value [Seperated with ;]", "The number to increment/decrement the fill value by", "1;1;1")); + ChoicesParameter::Choices{"Incrementing", "Decrementing"})); + params.insert(std::make_unique(k_StepValue_Key, "Step Value [Seperated with ;]", "The number to increment/decrement the fill value by", "1;1;1")); params.insert(std::make_unique(k_UseSeed_Key, "Use Seed for Random Generation", "When true the Seed Value will be used to seed the generator", false)); params.insert(std::make_unique>(k_SeedValue_Key, "Seed Value", "The seed fed into the random generator", std::mt19937::default_seed)); From 05a4093db1886463f1a1301f2fdbf8eab7f911a2 Mon Sep 17 00:00:00 2001 From: Joey Kleingers Date: Fri, 20 Sep 2024 10:10:05 -0400 Subject: [PATCH 10/10] Added Python script showing how to use advanced Create Data Array filter. Signed-off-by: Joey Kleingers --- .../scripts/create_data_array_advanced.py | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 wrapping/python/examples/scripts/create_data_array_advanced.py diff --git a/wrapping/python/examples/scripts/create_data_array_advanced.py b/wrapping/python/examples/scripts/create_data_array_advanced.py new file mode 100644 index 0000000000..066de1dae3 --- /dev/null +++ b/wrapping/python/examples/scripts/create_data_array_advanced.py @@ -0,0 +1,168 @@ +""" +Important Note +============== + +This python file can be used as an example of how to execute the Create Data Array +(Advanced) filter using all the various initialization options. + +If you plan to use the codes below (and you are welcome to), there are a few things +that you, the developer, should take note of: + +Import Statements +----------------- + +You will most likely *NOT* need to include the following code: + + .. code:: python + + import simplnx_test_dirs as nxtest + +Filter Error Detection +---------------------- + +In each section of code a filter is created and executed immediately. This may or +may *not* be what you want to do. You can also preflight the filter to verify the +correctness of the filters before executing the filter **although** this is done +for you when the filter is executed. As such, you will want to check the 'result' +variable to see if there are any errors or warnings. If there **are** any then +you, as the developer, should act appropriately on the errors or warnings. +More specifically, this bit of code: + + .. code:: python + + nxtest.check_filter_result(nxor.ReadAngDataFilter, result) + +is used by the simplnx unit testing framework and should be replaced by your own +error checking code. You are welcome to look up the function definition and use +that. + +""" +import simplnx as nx + +import simplnx_test_dirs as nxtest + +import numpy as np + +# Create a Data Structure +data_structure = nx.DataStructure() + +#------------------------------------------------------------------------------ +# Create Data Array With Fill Value +#------------------------------------------------------------------------------ +output_array_path = nx.DataPath(["Fill Value Array"]) +array_type = nx.NumericType.float32 +tuple_dims = [[10]] +component_dims = [[3, 2]] +create_array_nx_filter = nx.CreateDataArrayAdvancedFilter() +result = create_array_nx_filter.execute(data_structure=data_structure, + component_dimensions=component_dims, + data_format="", + init_type_index=0, # Fill value initialization type + init_value="1;4;7;2;1;5", + numeric_type_index=array_type, + output_array_path=output_array_path, + tuple_dimensions=tuple_dims) +nxtest.check_filter_result(nx.CreateDataArrayFilter, result) + + +# We can check the output of the filter by simply printing the array +npdata = data_structure[output_array_path].npview() +print(npdata) + +#------------------------------------------------------------------------------ +# Create Data Array With Incremental Values +#------------------------------------------------------------------------------ +output_array_path = nx.DataPath(["Incremental Value Array"]) +array_type = nx.NumericType.int16 +tuple_dims = [[3, 3]] +component_dims = [[3]] +create_array_nx_filter = nx.CreateDataArrayAdvancedFilter() +result = create_array_nx_filter.execute(data_structure=data_structure, + component_dimensions=component_dims, + data_format="", + init_type_index=1, # Initialization type = Incremental/Decremental + starting_fill_value="1;4;7", + step_operation_index=0, # Step type = Incrementing + step_value="1;2;3", + numeric_type_index=array_type, + output_array_path=output_array_path, + tuple_dimensions=tuple_dims) +nxtest.check_filter_result(nx.CreateDataArrayFilter, result) + + +# We can check the output of the filter by simply printing the array +npdata = data_structure[output_array_path].npview() +print(npdata) + +#------------------------------------------------------------------------------ +# Create Data Array With Decremental Values +#------------------------------------------------------------------------------ +output_array_path = nx.DataPath(["Decremental Value Array"]) +array_type = nx.NumericType.int32 +tuple_dims = [[3, 3]] +component_dims = [[3]] +create_array_nx_filter = nx.CreateDataArrayAdvancedFilter() +result = create_array_nx_filter.execute(data_structure=data_structure, + component_dimensions=component_dims, + data_format="", + init_type_index=1, # Initialization type = Incremental/Decremental + starting_fill_value="1;4;7", + step_operation_index=1, # Step type = Decrementing + step_value="1;2;3", + numeric_type_index=array_type, + output_array_path=output_array_path, + tuple_dimensions=tuple_dims) +nxtest.check_filter_result(nx.CreateDataArrayFilter, result) + + +# We can check the output of the filter by simply printing the array +npdata = data_structure[output_array_path].npview() +print(npdata) + +#------------------------------------------------------------------------------ +# Create Data Array With Random Values +#------------------------------------------------------------------------------ +output_array_path = nx.DataPath(["Random Value Array"]) +array_type = nx.NumericType.int8 +tuple_dims = [[4, 4]] +component_dims = [[2]] +create_array_nx_filter = nx.CreateDataArrayAdvancedFilter() +result = create_array_nx_filter.execute(data_structure=data_structure, + component_dimensions=component_dims, + data_format="", + init_type_index=2, # Initialization type = Random + numeric_type_index=array_type, + output_array_path=output_array_path, + tuple_dimensions=tuple_dims, + seed_array_name="Seed Value Array") +nxtest.check_filter_result(nx.CreateDataArrayFilter, result) + + +# We can check the output of the filter by simply printing the array +npdata = data_structure[output_array_path].npview() +print(npdata) + +#------------------------------------------------------------------------------ +# Create Data Array With Random Values In A Range +#------------------------------------------------------------------------------ +output_array_path = nx.DataPath(["Random Values In A Range Array"]) +array_type = nx.NumericType.int8 +tuple_dims = [[4, 4]] +component_dims = [[2]] +create_array_nx_filter = nx.CreateDataArrayAdvancedFilter() +result = create_array_nx_filter.execute(data_structure=data_structure, + component_dimensions=component_dims, + data_format="", + init_type_index=3, # Initialization type = Random With Range + init_start_range="-2;4", + init_end_range="4;7", + numeric_type_index=array_type, + output_array_path=output_array_path, + tuple_dimensions=tuple_dims, + seed_array_name="Seed Value Array 2") +nxtest.check_filter_result(nx.CreateDataArrayFilter, result) + + +# We can check the output of the filter by simply printing the array +npdata = data_structure[output_array_path].npview() +print(npdata) \ No newline at end of file