From dcc41d20b6b476e529048fa0a86122067f595c7c Mon Sep 17 00:00:00 2001 From: nyoungbq Date: Wed, 18 Oct 2023 13:13:57 -0400 Subject: [PATCH] Uncertain grid seed updates --- .../UncertainRegularGridSampleSurfaceMesh.cpp | 10 +--------- .../UncertainRegularGridSampleSurfaceMesh.hpp | 1 - ...tainRegularGridSampleSurfaceMeshFilter.cpp | 20 ++++++++++++++++--- ...tainRegularGridSampleSurfaceMeshFilter.hpp | 1 + 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.cpp b/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.cpp index 03a2b209a7..032cf25650 100644 --- a/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.cpp +++ b/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.cpp @@ -1,7 +1,6 @@ #include "UncertainRegularGridSampleSurfaceMesh.hpp" #include "complex/DataStructure/DataArray.hpp" -#include "complex/DataStructure/DataGroup.hpp" #include @@ -39,14 +38,7 @@ void UncertainRegularGridSampleSurfaceMesh::generatePoints(std::vector std::random_device randomDevice; // Will be used to obtain a seed for the random number engine std::mt19937 generator(randomDevice()); // Standard mersenne_twister_engine seeded with rd() - std::mt19937::result_type seed = m_InputValues->SeedValue; - - if(!m_InputValues->UseSeed) - { - seed = static_cast(std::chrono::steady_clock::now().time_since_epoch().count()); - } - - generator.seed(seed); + generator.seed(m_InputValues->SeedValue); std::uniform_real_distribution distribution(0.0F, 1.0F); for(usize k = 0; k < dims[2]; k++) diff --git a/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.hpp b/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.hpp index ebe6347124..50b9998023 100644 --- a/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.hpp +++ b/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.hpp @@ -16,7 +16,6 @@ namespace complex { struct COMPLEXCORE_EXPORT UncertainRegularGridSampleSurfaceMeshInputValues { - bool UseSeed; uint64 SeedValue; VectorUInt64Parameter::ValueType Dimensions; VectorFloat32Parameter::ValueType Spacing; diff --git a/src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp b/src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp index 5dceca2df2..1525bd5b2b 100644 --- a/src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp +++ b/src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp @@ -56,9 +56,10 @@ Parameters UncertainRegularGridSampleSurfaceMeshFilter::parameters() const Parameters params; // Create the parameter descriptors that are needed for this filter - params.insertSeparator(Parameters::Separator{"Optional Variables"}); + params.insertSeparator(Parameters::Separator{"Seeded Randomness"}); params.insertLinkableParameter(std::make_unique(k_UseSeed_Key, "Use Seed for Random Generation", "When true the user will be able to put in a seed for random generation", false)); params.insert(std::make_unique>(k_SeedValue_Key, "Seed", "The seed fed into the random generator", std::mt19937::default_seed)); + params.insert(std::make_unique(k_SeedArrayName_Key, "Stored Seed Value Array Name", "", "_Uncertain_Regular_Grid_Sample_Surface_Mesh_Seed_Value_")); params.insertSeparator(Parameters::Separator{"Input Parameters"}); params.insert(std::make_unique(k_Dimensions_Key, "Number of Cells per Axis", "The dimensions of the created Image geometry", std::vector{128, 128, 128}, @@ -102,6 +103,7 @@ IFilter::PreflightResult UncertainRegularGridSampleSurfaceMeshFilter::preflightI auto pImageGeomPathValue = filterArgs.value(k_ImageGeomPath_Key); auto pCellAMNameValue = filterArgs.value(k_CellAMName_Key); auto pFeatureIdsArrayNameValue = filterArgs.value(k_FeatureIdsArrayName_Key); + auto pSeedArrayNameValue = filterArgs.value(k_SeedArrayName_Key); PreflightResult preflightResult; complex::Result resultOutputActions; @@ -125,6 +127,11 @@ IFilter::PreflightResult UncertainRegularGridSampleSurfaceMeshFilter::preflightI resultOutputActions.value().appendAction(std::move(createDataGroupAction)); } + { + auto createAction = std::make_unique(DataType::uint64, std::vector{1}, std::vector{1}, DataPath({pSeedArrayNameValue})); + resultOutputActions.value().appendAction(std::move(createAction)); + } + // Return both the resultOutputActions and the preflightUpdatedValues via std::move() return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; } @@ -133,11 +140,18 @@ IFilter::PreflightResult UncertainRegularGridSampleSurfaceMeshFilter::preflightI Result<> UncertainRegularGridSampleSurfaceMeshFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { + 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()); + } + + // Store Seed Value in Top Level Array + dataStructure.getDataRefAs(DataPath({filterArgs.value(k_SeedArrayName_Key)}))[0] = seed; UncertainRegularGridSampleSurfaceMeshInputValues inputValues; - inputValues.UseSeed = filterArgs.value(k_UseSeed_Key); - inputValues.SeedValue = filterArgs.value(k_SeedValue_Key); + inputValues.SeedValue = seed; inputValues.Dimensions = filterArgs.value(k_Dimensions_Key); inputValues.Spacing = filterArgs.value(k_Spacing_Key); inputValues.Origin = filterArgs.value(k_Origin_Key); diff --git a/src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.hpp b/src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.hpp index b503d78153..1a14b13b3d 100644 --- a/src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.hpp +++ b/src/Plugins/ComplexCore/src/ComplexCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.hpp @@ -34,6 +34,7 @@ class COMPLEXCORE_EXPORT UncertainRegularGridSampleSurfaceMeshFilter : public IF static inline constexpr StringLiteral k_FeatureIdsArrayName_Key = "feature_ids_array_name"; 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_Dimensions_Key = "dimensions"; /**