From c3d72cbafaa0f0a853d547ac4cd2eed57a554746 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sun, 28 Apr 2024 09:15:19 -0400 Subject: [PATCH] BUG: Filters that delete NeighborLists from the DataStructure send strong warning messages. (#926) Signed-off-by: Michael Jackson Co-authored-by: Nathan Young --- ...mall IN100 Full Reconstruction.d3dpipeline | 108 ++++++++++++------ ...IN100 Morphological Statistics.d3dpipeline | 2 +- ...00 Crystallographic Statistics.d3dpipeline | 4 +- .../(01) Small IN100 Quick Mesh.d3dpipeline | 2 +- .../(02) Small IN100 Smooth Mesh.d3dpipeline | 2 +- ...3) Small IN100 Mesh Statistics.d3dpipeline | 2 +- .../(04) Small IN100 GBCD.d3dpipeline | 2 +- .../(05) Small IN100 GBCD Metric.d3dpipeline | 2 +- .../FindGBCD-GBPDMetricBased.d3dpipeline | 12 +- .../SimplnxCore/docs/CropImageGeometry.md | 6 + src/Plugins/SimplnxCore/docs/MinNeighbors.md | 4 +- .../docs/RemoveFlaggedFeaturesFilter.md | 10 ++ .../docs/RemoveMinimumSizeFeaturesFilter.md | 4 +- .../docs/ResampleImageGeomFilter.md | 4 + .../pipelines/AvizoWriters.d3dpipeline | 2 +- .../pipelines/FindBoundaryCells.d3dpipeline | 2 +- .../VtkRectilinearGridWriter.d3dpipeline | 2 +- .../Algorithms/RemoveFlaggedFeatures.cpp | 2 +- .../Filters/Algorithms/ResampleImageGeom.cpp | 2 +- .../SimplnxCore/Filters/CropImageGeometry.cpp | 15 +-- .../Filters/FindFeatureClusteringFilter.cpp | 3 +- .../src/SimplnxCore/Filters/MinNeighbors.cpp | 30 +++-- .../Filters/RemoveFlaggedFeaturesFilter.cpp | 11 +- .../RemoveMinimumSizeFeaturesFilter.cpp | 41 ++----- .../RemoveMinimumSizeFeaturesFilter.hpp | 4 +- .../Filters/ResampleImageGeomFilter.cpp | 10 +- .../Filter/Actions/DeleteDataAction.cpp | 2 +- src/simplnx/Utilities/DataGroupUtilities.cpp | 6 +- src/simplnx/Utilities/DataGroupUtilities.hpp | 8 +- src/simplnx/Utilities/FilterUtilities.cpp | 38 ++++++ src/simplnx/Utilities/FilterUtilities.hpp | 13 ++- src/simplnx/Utilities/SamplingUtils.hpp | 4 +- 32 files changed, 230 insertions(+), 129 deletions(-) diff --git a/src/Plugins/OrientationAnalysis/pipelines/EBSD Reconstruction/(08) Small IN100 Full Reconstruction.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EBSD Reconstruction/(08) Small IN100 Full Reconstruction.d3dpipeline index 023ab26ae1..28fd04ddd5 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EBSD Reconstruction/(08) Small IN100 Full Reconstruction.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EBSD Reconstruction/(08) Small IN100 Full Reconstruction.d3dpipeline @@ -28,7 +28,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ReadH5EbsdFilter", + "name": "nx::core::ReadH5EbsdFilter", "uuid": "db291b6c-9aaf-432d-9547-430c865a539c" }, "isDisabled": false @@ -58,11 +58,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::MultiThresholdObjects", "uuid": "4246245e-1011-4add-8436-0af6bed19228" }, "isDisabled": false @@ -76,7 +81,7 @@ }, "comments": "", "filter": { - "name": "simplnx::ConvertOrientations", + "name": "nx::core::ConvertOrientations", "uuid": "501e54e6-a66f-4eeb-ae37-00e649c00d4b" }, "isDisabled": false @@ -86,16 +91,16 @@ "alignment_shift_file_name": "Data/Output/Alignment_By_Misorientation_Shifts.txt", "cell_phases_array_path": "DataContainer/CellData/Phases", "crystal_structures_array_path": "DataContainer/CellEnsembleData/CrystalStructures", + "input_image_geometry_path": "DataContainer", "mask_array_path": "DataContainer/CellData/Mask", "misorientation_tolerance": 5.0, "quats_array_path": "DataContainer/CellData/Quats", - "input_image_geometry_path": "DataContainer", "use_mask": true, "write_alignment_shifts": false }, "comments": "", "filter": { - "name": "simplnx::AlignSectionsMisorientationFilter", + "name": "nx::core::AlignSectionsMisorientationFilter", "uuid": "8df2135c-7079-49f4-9756-4f3c028a5ced" }, "isDisabled": false @@ -103,12 +108,12 @@ { "args": { "fill_holes": false, - "mask_array_path": "DataContainer/CellData/Mask", - "input_image_geometry_path": "DataContainer" + "input_image_geometry_path": "DataContainer", + "mask_array_path": "DataContainer/CellData/Mask" }, "comments": "", "filter": { - "name": "simplnx::IdentifySample", + "name": "nx::core::IdentifySample", "uuid": "94d47495-5a89-4c7f-a0ee-5ff20e6bd273" }, "isDisabled": false @@ -116,16 +121,16 @@ { "args": { "alignment_shift_file_name": "Data/Output/Alignment_By_Feature_Centroid_Shifts.txt", + "input_image_geometry_path": "DataContainer", "mask_array_path": "DataContainer/CellData/Mask", "reference_slice": 0, "selected_cell_data_path": "DataContainer/CellData", - "input_image_geometry_path": "DataContainer", "use_reference_slice": true, "write_alignment_shifts": false }, "comments": "", "filter": { - "name": "simplnx::AlignSectionsFeatureCentroidFilter", + "name": "nx::core::AlignSectionsFeatureCentroidFilter", "uuid": "b83f9bae-9ccf-4932-96c3-7f2fdb091452" }, "isDisabled": false @@ -134,15 +139,15 @@ "args": { "cell_phases_array_path": "DataContainer/CellData/Phases", "crystal_structures_array_path": "DataContainer/CellEnsembleData/CrystalStructures", - "mask_array_path": "DataContainer/CellData/Mask", "input_image_geometry_path": "DataContainer", + "mask_array_path": "DataContainer/CellData/Mask", "misorientation_tolerance": 5.0, "number_of_neighbors": 4, "quats_array_path": "DataContainer/CellData/Quats" }, "comments": "", "filter": { - "name": "simplnx::BadDataNeighborOrientationCheckFilter", + "name": "nx::core::BadDataNeighborOrientationCheckFilter", "uuid": "3f342977-aea1-49e1-a9c2-f73760eba0d3" }, "isDisabled": false @@ -161,7 +166,7 @@ }, "comments": "", "filter": { - "name": "simplnx::NeighborOrientationCorrelationFilter", + "name": "nx::core::NeighborOrientationCorrelationFilter", "uuid": "4625c192-7e46-4333-a294-67a2eb64cb37" }, "isDisabled": false @@ -170,19 +175,19 @@ "args": { "active_array_name": "Active", "cell_feature_attribute_matrix_name": "CellFeatureData", + "cell_mask_array_path": "DataContainer/CellData/Mask", "cell_phases_array_path": "DataContainer/CellData/Phases", + "cell_quats_array_path": "DataContainer/CellData/Quats", "crystal_structures_array_path": "DataContainer/CellEnsembleData/CrystalStructures", "feature_ids_array_name": "FeatureIds", - "cell_mask_array_path": "DataContainer/CellData/Mask", "input_image_geometry_path": "DataContainer", "misorientation_tolerance": 5.0, - "cell_quats_array_path": "DataContainer/CellData/Quats", "randomize_features": true, "use_mask": true }, "comments": "", "filter": { - "name": "simplnx::EBSDSegmentFeaturesFilter", + "name": "nx::core::EBSDSegmentFeaturesFilter", "uuid": "1810c2c7-63e3-41db-b204-a5821e6271c0" }, "isDisabled": false @@ -196,7 +201,7 @@ }, "comments": "", "filter": { - "name": "simplnx::FindFeaturePhasesFilter", + "name": "nx::core::FindFeaturePhasesFilter", "uuid": "da5bb20e-4a8e-49d9-9434-fbab7bc434fc" }, "isDisabled": false @@ -213,7 +218,7 @@ }, "comments": "", "filter": { - "name": "simplnx::FindAvgOrientationsFilter", + "name": "nx::core::FindAvgOrientationsFilter", "uuid": "086ddb9a-928f-46ab-bad6-b1498270d71e" }, "isDisabled": false @@ -233,7 +238,7 @@ }, "comments": "", "filter": { - "name": "simplnx::FindNeighbors", + "name": "nx::core::FindNeighbors", "uuid": "7177e88c-c3ab-4169-abe9-1fdaff20e598" }, "isDisabled": false @@ -246,17 +251,20 @@ "axis_tolerance": 3.0, "cell_parent_ids_array_name": "ParentIds", "contiguous_neighbor_list_array_path": "DataContainer/CellFeatureData/NeighborList2", + "created_feature_attribute_matrix_name": "NewGrain Data", "crystal_structures_array_path": "DataContainer/CellEnsembleData/CrystalStructures", "feature_ids_path": "DataContainer/CellData/FeatureIds", "feature_parent_ids_array_name": "ParentIds", "feature_phases_array_path": "DataContainer/CellFeatureData/Phases", - "created_feature_attribute_matrix_name": "NewGrain Data", "non_contiguous_neighbor_list_array_path": "", - "use_non_contiguous_neighbors": false + "seed_array_name": "MergeTwins SeedValue", + "seed_value": 5489, + "use_non_contiguous_neighbors": false, + "use_seed": false }, "comments": "", "filter": { - "name": "simplnx::MergeTwinsFilter", + "name": "nx::core::MergeTwinsFilter", "uuid": "f173786a-50cd-4c3c-9518-48ef6fc2bac9" }, "isDisabled": false @@ -273,7 +281,7 @@ }, "comments": "", "filter": { - "name": "simplnx::CalculateFeatureSizesFilter", + "name": "nx::core::CalculateFeatureSizesFilter", "uuid": "c666ee17-ca58-4969-80d0-819986c72485" }, "isDisabled": false @@ -290,11 +298,24 @@ }, "comments": "", "filter": { - "name": "simplnx::RemoveMinimumSizeFeaturesFilter", + "name": "nx::core::RemoveMinimumSizeFeaturesFilter", "uuid": "074472d3-ba8d-4a1a-99f2-2d56a0d082a0" }, "isDisabled": false }, + { + "args": { + "removed_data_path": [ + "DataContainer/CellFeatureData/NumNeighbors2" + ] + }, + "comments": "We are going to remove the DataContainer/CellFeatureData/NumNeighbors data because there is no way to ensure that it is correct after the last filter was executed.", + "filter": { + "name": "nx::core::DeleteData", + "uuid": "bf286740-e987-49fe-a7c8-6e566e3a0606" + }, + "isDisabled": false + }, { "args": { "boundary_cells_name": "BoundaryCells", @@ -310,7 +331,7 @@ }, "comments": "", "filter": { - "name": "simplnx::FindNeighbors", + "name": "nx::core::FindNeighbors", "uuid": "7177e88c-c3ab-4169-abe9-1fdaff20e598" }, "isDisabled": false @@ -329,24 +350,36 @@ }, "comments": "", "filter": { - "name": "simplnx::MinNeighbors", + "name": "nx::core::MinNeighbors", "uuid": "4ab5153f-6014-4e6d-bbd6-194068620389" }, "isDisabled": false }, + { + "args": { + "removed_data_path": [ + "DataContainer/CellFeatureData/NumNeighbors" + ] + }, + "comments": "We are going to remove the DataContainer/CellFeatureData/NumNeighbors data because there is no way to ensure that it is correct after the last filter was executed.", + "filter": { + "name": "nx::core::DeleteData", + "uuid": "bf286740-e987-49fe-a7c8-6e566e3a0606" + }, + "isDisabled": false + }, { "args": { "cell_phases_array_path": "Phases", "feature_ids_path": "DataContainer/CellData/FeatureIds", "ignored_data_array_paths": [], - "min_allowed_defect_size": 1000, - "selected_cell_data_group": "DataContainer/CellData", "input_image_geometry_path": "DataContainer", + "min_allowed_defect_size": 1000, "store_as_new_phase": false }, "comments": "", "filter": { - "name": "simplnx::FillBadDataFilter", + "name": "nx::core::FillBadDataFilter", "uuid": "a59eb864-9e6b-40bb-9292-e5281b0b4f3e" }, "isDisabled": false @@ -355,17 +388,16 @@ "args": { "feature_ids_path": "DataContainer/CellData/FeatureIds", "ignored_data_array_paths": [], + "input_image_geometry_path": "DataContainer", "num_iterations": 2, "operation_index": 0, - "selected_feature_group_path": "DataContainer/CellFeatureData", - "input_image_geometry_path": "DataContainer", "x_dir_on": true, "y_dir_on": true, "z_dir_on": true }, "comments": "", "filter": { - "name": "simplnx::ErodeDilateBadDataFilter", + "name": "nx::core::ErodeDilateBadDataFilter", "uuid": "7f2f7378-580e-4337-8c04-a29e7883db0b" }, "isDisabled": false @@ -374,17 +406,16 @@ "args": { "feature_ids_path": "DataContainer/CellData/FeatureIds", "ignored_data_array_paths": [], + "input_image_geometry_path": "DataContainer", "num_iterations": 2, "operation_index": 1, - "selected_feature_group_path": "DataContainer/CellFeatureData", - "input_image_geometry_path": "DataContainer", "x_dir_on": true, "y_dir_on": true, "z_dir_on": true }, "comments": "", "filter": { - "name": "simplnx::ErodeDilateBadDataFilter", + "name": "nx::core::ErodeDilateBadDataFilter", "uuid": "7f2f7378-580e-4337-8c04-a29e7883db0b" }, "isDisabled": false @@ -405,7 +436,7 @@ }, "comments": "", "filter": { - "name": "simplnx::GenerateIPFColorsFilter", + "name": "nx::core::GenerateIPFColorsFilter", "uuid": "64cb4f27-6e5e-4dd2-8a03-0c448cb8f5e6" }, "isDisabled": false @@ -417,11 +448,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/OrientationAnalysis/pipelines/EBSD Statistics/(01) Small IN100 Morphological Statistics.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EBSD Statistics/(01) Small IN100 Morphological Statistics.d3dpipeline index c1028550a9..35a436b090 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EBSD Statistics/(01) Small IN100 Morphological Statistics.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EBSD Statistics/(01) Small IN100 Morphological Statistics.d3dpipeline @@ -26,7 +26,7 @@ "DataContainer/CellFeatureData/Phases", "DataContainer/CellFeatureData/AvgQuats", "DataContainer/CellFeatureData/AvgEulerAngles", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", diff --git a/src/Plugins/OrientationAnalysis/pipelines/EBSD Statistics/(05) Small IN100 Crystallographic Statistics.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EBSD Statistics/(05) Small IN100 Crystallographic Statistics.d3dpipeline index 5e03982fbf..8f21b115b7 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EBSD Statistics/(05) Small IN100 Crystallographic Statistics.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EBSD Statistics/(05) Small IN100 Crystallographic Statistics.d3dpipeline @@ -24,7 +24,7 @@ "DataContainer/CellFeatureData/Active", "DataContainer/CellData/FeatureIds", "DataContainer/CellFeatureData/Phases", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", @@ -77,7 +77,7 @@ "DataContainer/CellFeatureData/Phases", "DataContainer/CellFeatureData/AvgQuats", "DataContainer/CellFeatureData/AvgEulerAngles", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", diff --git a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(01) Small IN100 Quick Mesh.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(01) Small IN100 Quick Mesh.d3dpipeline index 4d9086f5eb..4cdad677f2 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(01) Small IN100 Quick Mesh.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(01) Small IN100 Quick Mesh.d3dpipeline @@ -24,7 +24,7 @@ "DataContainer/CellFeatureData/Active", "DataContainer/CellData/FeatureIds", "DataContainer/CellFeatureData/Phases", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", diff --git a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(02) Small IN100 Smooth Mesh.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(02) Small IN100 Smooth Mesh.d3dpipeline index bdd5a97902..dea7c4d4e8 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(02) Small IN100 Smooth Mesh.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(02) Small IN100 Smooth Mesh.d3dpipeline @@ -28,7 +28,7 @@ "DataContainer/CellFeatureData", "DataContainer/CellFeatureData/Active", "DataContainer/CellFeatureData/Phases", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/CellFeatureData/ParentIds", "DataContainer/CellFeatureData/Centroids", "DataContainer/CellFeatureData/EquivalentDiameters", diff --git a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(03) Small IN100 Mesh Statistics.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(03) Small IN100 Mesh Statistics.d3dpipeline index a9f78c6b95..5242ef7eee 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(03) Small IN100 Mesh Statistics.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(03) Small IN100 Mesh Statistics.d3dpipeline @@ -43,7 +43,7 @@ "DataContainer/CellFeatureData/Neighborhoods", "DataContainer/CellFeatureData/NumElements", "DataContainer/CellFeatureData/NumNeighbors", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/CellFeatureData/Omega3s", "DataContainer/CellFeatureData/ParentIds", "DataContainer/CellFeatureData/Phases", diff --git a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(04) Small IN100 GBCD.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(04) Small IN100 GBCD.d3dpipeline index 676a5b171d..998a247eb7 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(04) Small IN100 GBCD.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(04) Small IN100 GBCD.d3dpipeline @@ -43,7 +43,7 @@ "DataContainer/CellFeatureData/Neighborhoods", "DataContainer/CellFeatureData/NumElements", "DataContainer/CellFeatureData/NumNeighbors", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/CellFeatureData/Omega3s", "DataContainer/CellFeatureData/ParentIds", "DataContainer/CellFeatureData/Phases", diff --git a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(05) Small IN100 GBCD Metric.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(05) Small IN100 GBCD Metric.d3dpipeline index d62b2db768..578f47404c 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(05) Small IN100 GBCD Metric.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/EBSD SurfaceMeshing/(05) Small IN100 GBCD Metric.d3dpipeline @@ -43,7 +43,7 @@ "DataContainer/CellFeatureData/Neighborhoods", "DataContainer/CellFeatureData/NumElements", "DataContainer/CellFeatureData/NumNeighbors", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/CellFeatureData/Omega3s", "DataContainer/CellFeatureData/ParentIds", "DataContainer/CellFeatureData/Phases", diff --git a/src/Plugins/OrientationAnalysis/pipelines/FindGBCD-GBPDMetricBased.d3dpipeline b/src/Plugins/OrientationAnalysis/pipelines/FindGBCD-GBPDMetricBased.d3dpipeline index 9373178e78..50edf5dfb9 100644 --- a/src/Plugins/OrientationAnalysis/pipelines/FindGBCD-GBPDMetricBased.d3dpipeline +++ b/src/Plugins/OrientationAnalysis/pipelines/FindGBCD-GBPDMetricBased.d3dpipeline @@ -43,7 +43,7 @@ "DataContainer/CellFeatureData/Neighborhoods", "DataContainer/CellFeatureData/NumElements", "DataContainer/CellFeatureData/NumNeighbors", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/CellFeatureData/Omega3s", "DataContainer/CellFeatureData/ParentIds", "DataContainer/CellFeatureData/Phases", @@ -112,7 +112,7 @@ "DataContainer/CellFeatureData/Neighborhoods", "DataContainer/CellFeatureData/NumElements", "DataContainer/CellFeatureData/NumNeighbors", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/CellFeatureData/Omega3s", "DataContainer/CellFeatureData/ParentIds", "DataContainer/CellFeatureData/Phases", @@ -176,7 +176,7 @@ "DataContainer/CellFeatureData/Neighborhoods", "DataContainer/CellFeatureData/NumElements", "DataContainer/CellFeatureData/NumNeighbors", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/CellFeatureData/Omega3s", "DataContainer/CellFeatureData/ParentIds", "DataContainer/CellFeatureData/Phases", @@ -220,7 +220,7 @@ "DataContainer/CellFeatureData/Active", "DataContainer/CellData/FeatureIds", "DataContainer/CellFeatureData/Phases", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", @@ -280,7 +280,7 @@ "DataContainer/CellFeatureData/Active", "DataContainer/CellData/FeatureIds", "DataContainer/CellFeatureData/Phases", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", @@ -333,7 +333,7 @@ "DataContainer/CellFeatureData/Phases", "DataContainer/CellFeatureData/AvgQuats", "DataContainer/CellFeatureData/AvgEulerAngles", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", diff --git a/src/Plugins/SimplnxCore/docs/CropImageGeometry.md b/src/Plugins/SimplnxCore/docs/CropImageGeometry.md index 7037dfe0c9..e954d7f976 100644 --- a/src/Plugins/SimplnxCore/docs/CropImageGeometry.md +++ b/src/Plugins/SimplnxCore/docs/CropImageGeometry.md @@ -4,6 +4,12 @@ This **Filter** allows the user to crop a region of interest (ROI) from an **Image Geometry**. The input parameters are in units of voxels or physical coordinates. + +## WARNING: NeighborList Removal + +If the option to "Renumber Features" is turn ON and the Cell Feature AttributeMatrix contains any *NeighborList* data arrays, those arrays will be **REMOVED** because those lists are now invalid. Re-run the *Find Neighbors* filter to re-create the lists. + + ## Examples In the following examples, the following image is being used. diff --git a/src/Plugins/SimplnxCore/docs/MinNeighbors.md b/src/Plugins/SimplnxCore/docs/MinNeighbors.md index 84e4d5b288..329db61bbc 100644 --- a/src/Plugins/SimplnxCore/docs/MinNeighbors.md +++ b/src/Plugins/SimplnxCore/docs/MinNeighbors.md @@ -10,9 +10,9 @@ This **Filter** sets the minimum number of contiguous neighboring **Features** a The **Filter** can be run in a mode where the minimum number of neighbors is applied to a single **Ensemble**. The user can select to apply the minimum to one specific **Ensemble**. -## Notes +## WARNING: NeighborList Removal -If any features are removed **and** the Cell Feature AttributeMatrix contains any *NeighborList* data arrays those arrays will be **REMOVED** because those lists are now invalid. Re-run the *Find Neighbors* filter to re-create the lists. +If the Cell Feature AttributeMatrix contains any *NeighborList* data arrays, those arrays will be **REMOVED** because those lists are now invalid. Re-run the *Find Neighbors* filter to re-create the lists. % Auto generated parameter table will be inserted here diff --git a/src/Plugins/SimplnxCore/docs/RemoveFlaggedFeaturesFilter.md b/src/Plugins/SimplnxCore/docs/RemoveFlaggedFeaturesFilter.md index 27b00bc0dd..dfdb550fa2 100644 --- a/src/Plugins/SimplnxCore/docs/RemoveFlaggedFeaturesFilter.md +++ b/src/Plugins/SimplnxCore/docs/RemoveFlaggedFeaturesFilter.md @@ -8,6 +8,16 @@ Processing (Cleanup) This **Filter** will remove **Features** that have been flagged by another **Filter** from the structure. The **Filter** requires that the user point to a boolean array at the **Feature** level that tells the **Filter** whether the **Feature** should remain in the structure. If the boolean array is *false* for a **Feature**, then all **Cells** that belong to that **Feature** are temporarily *unassigned*. Optionally, after all *undesired* **Features** are removed, the remaining **Features** are isotropically coarsened to fill in the gaps left by the removed **Features**. +| Operation | Meaning | +|-----------|---------| +| 0 | Remove features. | +| 1 | Extract features into new geometry. | +| 2 | Extract features and then remove them. | + +## WARNING: NeighborList Removal + +If the operation is [0] or [2] and the Cell Feature AttributeMatrix contains any *NeighborList* data arrays, those arrays will be **REMOVED** because those lists are now invalid. Re-run the *Find Neighbors* filter to re-create the lists. + ## Caveats This filter will **ONLY** run on an Image Geometry. diff --git a/src/Plugins/SimplnxCore/docs/RemoveMinimumSizeFeaturesFilter.md b/src/Plugins/SimplnxCore/docs/RemoveMinimumSizeFeaturesFilter.md index d140698fb7..2851c4dcfd 100644 --- a/src/Plugins/SimplnxCore/docs/RemoveMinimumSizeFeaturesFilter.md +++ b/src/Plugins/SimplnxCore/docs/RemoveMinimumSizeFeaturesFilter.md @@ -10,9 +10,9 @@ This **Filter** removes **Features** that have a total number of **Cells** below The **Filter** can be run in a mode where the minimum number of neighbors is applied to a single **Ensemble**. The user can select to apply the minimum to one specific **Ensemble**. -## Notes +## WARNING: NeighborList Removal -If any features are removed **and** the Cell Feature AttributeMatrix contains any *NeighborList* data arrays those arrays will be **REMOVED** because those lists are now invalid. Re-run the *Find Neighbors* filter to re-create the lists. +If the Cell Feature AttributeMatrix contains any *NeighborList* data arrays, those arrays will be **REMOVED** because those lists are now invalid. Re-run the *Find Neighbors* filter to re-create the lists. % Auto generated parameter table will be inserted here diff --git a/src/Plugins/SimplnxCore/docs/ResampleImageGeomFilter.md b/src/Plugins/SimplnxCore/docs/ResampleImageGeomFilter.md index 8fd8cf8f4c..a7bc6fd6ad 100644 --- a/src/Plugins/SimplnxCore/docs/ResampleImageGeomFilter.md +++ b/src/Plugins/SimplnxCore/docs/ResampleImageGeomFilter.md @@ -8,6 +8,10 @@ Sampling (Resample) This **Filter** changes the **Cell** spacing/resolution based on inputs from the user. There are several resampling modes: +## WARNING: NeighborList Removal + +If the option to "Renumber Features" is turn ON and the Cell Feature AttributeMatrix contains any *NeighborList* data arrays, those arrays will be **REMOVED** because those lists are now invalid. Re-run the *Find Neighbors* filter to re-create the lists. + ### Spacing The values entered are the desired new spacings (not multiples of the current resolution). The number of **Cells** in the volume will change when the spacing values are changed and thus the user should be cautious of generating "too many" **Cells** by entering very small values (i.e., very high resolution). diff --git a/src/Plugins/SimplnxCore/pipelines/AvizoWriters.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/AvizoWriters.d3dpipeline index 64dfe1d154..0d33b17ae6 100644 --- a/src/Plugins/SimplnxCore/pipelines/AvizoWriters.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/AvizoWriters.d3dpipeline @@ -28,7 +28,7 @@ "DataContainer/CellFeatureData/Phases", "DataContainer/CellFeatureData/AvgQuats", "DataContainer/CellFeatureData/AvgEulerAngles", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", diff --git a/src/Plugins/SimplnxCore/pipelines/FindBoundaryCells.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/FindBoundaryCells.d3dpipeline index 75b057b81e..52b2c205b2 100644 --- a/src/Plugins/SimplnxCore/pipelines/FindBoundaryCells.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/FindBoundaryCells.d3dpipeline @@ -28,7 +28,7 @@ "DataContainer/CellFeatureData/Phases", "DataContainer/CellFeatureData/AvgQuats", "DataContainer/CellFeatureData/AvgEulerAngles", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", diff --git a/src/Plugins/SimplnxCore/pipelines/VtkRectilinearGridWriter.d3dpipeline b/src/Plugins/SimplnxCore/pipelines/VtkRectilinearGridWriter.d3dpipeline index beb7d7c12f..fcc0601999 100644 --- a/src/Plugins/SimplnxCore/pipelines/VtkRectilinearGridWriter.d3dpipeline +++ b/src/Plugins/SimplnxCore/pipelines/VtkRectilinearGridWriter.d3dpipeline @@ -28,7 +28,7 @@ "DataContainer/CellFeatureData/Phases", "DataContainer/CellFeatureData/AvgQuats", "DataContainer/CellFeatureData/AvgEulerAngles", - "DataContainer/CellFeatureData/NumNeighbors2", + "DataContainer/NewGrain Data", "DataContainer/CellData/ParentIds", "DataContainer/CellFeatureData/ParentIds", diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/RemoveFlaggedFeatures.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/RemoveFlaggedFeatures.cpp index 314bc7a124..9d61add6a2 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/RemoveFlaggedFeatures.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/RemoveFlaggedFeatures.cpp @@ -429,7 +429,7 @@ Result<> RemoveFlaggedFeatures::operator()() m_MessageHandler(IFilter::ProgressMessage{IFilter::Message::Type::Info, fmt::format("Stripping excess inactive objects from model...")}); DataPath featureGroupPath = m_InputValues->FlaggedFeaturesArrayPath.getParent(); - if(!RemoveInactiveObjects(m_DataStructure, featureGroupPath, activeObjects, featureIds, flaggedFeatures->getNumberOfTuples())) + if(!RemoveInactiveObjects(m_DataStructure, featureGroupPath, activeObjects, featureIds, flaggedFeatures->getNumberOfTuples(), m_MessageHandler)) { return MakeErrorResult(-45434, "The removal has failed!"); } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ResampleImageGeom.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ResampleImageGeom.cpp index 1aeb05825c..6d451f7a28 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ResampleImageGeom.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ResampleImageGeom.cpp @@ -202,7 +202,7 @@ Result<> ResampleImageGeom::operator()() // NOW DO THE ACTUAL RENUMBERING and updating. DataPath destFeatureIdsPath = destImagePath.createChildPath(srcCellDataAM.getName()).createChildPath(featureIdsArrayPath.getTargetName()); - return Sampling::RenumberFeatures(m_DataStructure, destImagePath, destCellFeatureAMPath, featureIdsArrayPath, destFeatureIdsPath, m_ShouldCancel); + return Sampling::RenumberFeatures(m_DataStructure, destImagePath, destCellFeatureAMPath, featureIdsArrayPath, destFeatureIdsPath, m_MessageHandler, m_ShouldCancel); } return {}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropImageGeometry.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropImageGeometry.cpp index f0c2ffe45c..d8300b4c1d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropImageGeometry.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropImageGeometry.cpp @@ -18,14 +18,13 @@ #include "simplnx/Parameters/VectorParameter.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" #include "simplnx/Utilities/DataGroupUtilities.hpp" +#include "simplnx/Utilities/FilterUtilities.hpp" #include "simplnx/Utilities/GeometryHelpers.hpp" #include "simplnx/Utilities/ParallelAlgorithmUtilities.hpp" #include "simplnx/Utilities/ParallelDataAlgorithm.hpp" #include "simplnx/Utilities/ParallelTaskAlgorithm.hpp" -#include "simplnx/Utilities/SamplingUtils.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" - +#include "simplnx/Utilities/SamplingUtils.hpp" #include "simplnx/Utilities/StringUtilities.hpp" using namespace nx::core; @@ -480,9 +479,11 @@ IFilter::PreflightResult CropImageGeometry::preflightImpl(const DataStructure& d } if(!warningMsg.empty()) { - resultOutputActions.m_Warnings.push_back( - Warning({-55503, fmt::format("This filter modifies the Cell Level Array '{}', the following arrays are of type NeighborList and will not be copied over:{}", featureIdsArrayPath.toString(), - warningMsg)})); + resultOutputActions.m_Warnings.push_back(Warning( + {-55503, + fmt::format( + "This filter will modify the Cell Level Array '{}' which causes all Feature level NeighborLists to become invalid. These NeighborLists will not be copied to the new geometry:{}", + featureIdsArrayPath.toString(), warningMsg)})); } } @@ -672,7 +673,7 @@ Result<> CropImageGeometry::executeImpl(DataStructure& dataStructure, const Argu // NOW DO THE ACTUAL RENUMBERING and updating. DataPath destFeatureIdsPath = destImagePath.createChildPath(srcCellDataAM.getName()).createChildPath(featureIdsArrayPath.getTargetName()); - return Sampling::RenumberFeatures(dataStructure, destImagePath, destCellFeatureAMPath, featureIdsArrayPath, destFeatureIdsPath, shouldCancel); + return Sampling::RenumberFeatures(dataStructure, destImagePath, destCellFeatureAMPath, featureIdsArrayPath, destFeatureIdsPath, messageHandler, shouldCancel); } // The deferred actions will take care of removing the original and renaming the output if diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FindFeatureClusteringFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FindFeatureClusteringFilter.cpp index 164a40b9b8..13f37898b5 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FindFeatureClusteringFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FindFeatureClusteringFilter.cpp @@ -84,8 +84,7 @@ Parameters FindFeatureClusteringFilter::parameters() const params.insert(std::make_unique(k_CellEnsembleAttributeMatrixPath_Key, "Cell Ensemble Attribute Matrix", "The path to the cell ensemble attribute matrix where the RDF and RDF min and max distance arrays will be stored", DataPath{})); params.insertSeparator(Parameters::Separator{"Created Cell Feature Data"}); - params.insert( - std::make_unique(k_ClusteringListArrayName_Key, "Clustering List", "Distance of each Features's centroid to ever other Features's centroid", "ClusteringList")); + params.insert(std::make_unique(k_ClusteringListArrayName_Key, "Clustering List", "Distance of each Feature's centroid to every other Feature's centroid", "ClusteringList")); params.insertSeparator(Parameters::Separator{"Created Cell Ensemble Data"}); params.insert(std::make_unique(k_RDFArrayName_Key, "Radial Distribution Function", "A histogram of the normalized frequency at each bin", "RDF")); params.insert(std::make_unique(k_MaxMinArrayName_Key, "Max and Min Separation Distances", "The max and min distance found between Features", "RDFMaxMinDistances")); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MinNeighbors.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MinNeighbors.cpp index 266db27d02..e4c57577f6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MinNeighbors.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MinNeighbors.cpp @@ -2,17 +2,16 @@ #include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/DataStructure/Geometry/ImageGeom.hpp" +#include "simplnx/Filter/Actions/DeleteDataAction.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/AttributeMatrixSelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Utilities/DataGroupUtilities.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" namespace nx::core { @@ -21,6 +20,7 @@ namespace constexpr int64 k_TupleCountInvalidError = -250; constexpr int64 k_MissingFeaturePhasesError = -251; constexpr int32 k_InconsistentTupleCount = -252; +constexpr int32 k_FetchChildArrayError = -5559; void assignBadPoints(DataStructure& data, const Arguments& args, const std::atomic_bool& shouldCancel) { @@ -401,12 +401,20 @@ IFilter::PreflightResult MinNeighbors::preflightImpl(const DataStructure& dataSt // Feature Data is going to be modified nx::core::AppendDataObjectModifications(dataStructure, resultOutputActions.value().modifiedActions, numNeighborsPath.getParent(), {}); + // This section will warn the user about the removal of NeighborLists + auto result = nx::core::NeighborListRemovalPreflightCode(dataStructure, featureIdsPath, numNeighborsPath, resultOutputActions); + if(result.outputActions.invalid()) + { + return result; + } + // Return both the resultOutputActions and the preflightUpdatedValues via std::move() return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; } //------------------------------------------------------------------------------ -Result<> MinNeighbors::executeImpl(DataStructure& data, const Arguments& args, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const +Result<> MinNeighbors::executeImpl(DataStructure& dataStructure, const Arguments& args, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, + const std::atomic_bool& shouldCancel) const { auto featurePhasesPath = args.value(k_FeaturePhasesPath_Key); auto applyToSinglePhase = args.value(k_ApplyToSinglePhase_Key); @@ -418,7 +426,7 @@ Result<> MinNeighbors::executeImpl(DataStructure& data, const Arguments& args, c // we don't have access to the data yet if(applyToSinglePhase) { - auto& featurePhasesArray = data.getDataRefAs(featurePhasesPath); + auto& featurePhasesArray = dataStructure.getDataRefAs(featurePhasesPath); auto& featurePhases = featurePhasesArray.getDataStoreRef(); usize numFeatures = featurePhasesArray.getNumberOfTuples(); @@ -439,27 +447,27 @@ Result<> MinNeighbors::executeImpl(DataStructure& data, const Arguments& args, c } } - auto activeObjectsResult = mergeContainedFeatures(data, args, shouldCancel); + auto activeObjectsResult = mergeContainedFeatures(dataStructure, args, shouldCancel); if(!activeObjectsResult.has_value()) { return {nonstd::make_unexpected(std::vector{activeObjectsResult.error()})}; } auto cellDataAttrMatrix = args.value(MinNeighbors::k_CellDataAttributeMatrixPath_Key); - auto result = nx::core::GetAllChildDataPaths(data, cellDataAttrMatrix, DataObject::Type::DataArray); + auto result = nx::core::GetAllChildDataPaths(dataStructure, cellDataAttrMatrix, DataObject::Type::DataArray); if(!result.has_value()) { return MakeErrorResult(-5556, fmt::format("Error fetching all Data Arrays from Group '{}'", cellDataAttrMatrix.toString())); } // Run the algorithm. - assignBadPoints(data, args, shouldCancel); + assignBadPoints(dataStructure, args, shouldCancel); auto featureIdsPath = args.value(MinNeighbors::k_FeatureIdsPath_Key); - auto& featureIdsArray = data.getDataRefAs(featureIdsPath); + auto& featureIdsArray = dataStructure.getDataRefAs(featureIdsPath); auto numNeighborsPath = args.value(MinNeighbors::k_NumNeighborsPath_Key); - auto& numNeighborsArray = data.getDataRefAs(numNeighborsPath); + auto& numNeighborsArray = dataStructure.getDataRefAs(numNeighborsPath); DataPath cellFeatureGroupPath = numNeighborsPath.getParent(); size_t currentFeatureCount = numNeighborsArray.getNumberOfTuples(); @@ -473,7 +481,7 @@ Result<> MinNeighbors::executeImpl(DataStructure& data, const Arguments& args, c std::string message = fmt::format("Feature Count Changed: Previous: {} New: {}", currentFeatureCount, count); messageHandler(nx::core::IFilter::Message{nx::core::IFilter::Message::Type::Info, message}); - nx::core::RemoveInactiveObjects(data, cellFeatureGroupPath, activeObjects, featureIdsArray, currentFeatureCount); + nx::core::RemoveInactiveObjects(dataStructure, cellFeatureGroupPath, activeObjects, featureIdsArray, currentFeatureCount, messageHandler); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedFeaturesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedFeaturesFilter.cpp index 17786220ce..240299c6da 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedFeaturesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedFeaturesFilter.cpp @@ -13,11 +13,9 @@ #include "simplnx/Parameters/ChoicesParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/StringParameter.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -171,6 +169,13 @@ IFilter::PreflightResult RemoveFlaggedFeaturesFilter::preflightImpl(const DataSt nx::core::AppendDataObjectModifications(dataStructure, resultOutputActions.value().modifiedActions, pFeatureIdsArrayPathValue.getParent(), {}); // Feature Data is going to be modified nx::core::AppendDataObjectModifications(dataStructure, resultOutputActions.value().modifiedActions, pFlaggedFeaturesArrayPathValue.getParent(), {}); + + // This section will warn the user about the removal of NeighborLists + auto result = nx::core::NeighborListRemovalPreflightCode(dataStructure, pFeatureIdsArrayPathValue, pFlaggedFeaturesArrayPathValue, resultOutputActions); + if(result.outputActions.invalid()) + { + return result; + } } return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveMinimumSizeFeaturesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveMinimumSizeFeaturesFilter.cpp index ae3a0da6e4..d641c5067d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveMinimumSizeFeaturesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveMinimumSizeFeaturesFilter.cpp @@ -318,7 +318,7 @@ IFilter::UniquePointer RemoveMinimumSizeFeaturesFilter::clone() const return std::make_unique(); } -IFilter::PreflightResult RemoveMinimumSizeFeaturesFilter::preflightImpl(const DataStructure& data, const Arguments& args, const MessageHandler& messageHandler, +IFilter::PreflightResult RemoveMinimumSizeFeaturesFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& args, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { auto featurePhasesPath = args.value(k_FeaturePhasesPath_Key); @@ -336,12 +336,12 @@ IFilter::PreflightResult RemoveMinimumSizeFeaturesFilter::preflightImpl(const Da return {nonstd::make_unexpected(std::vector{Error{-k_BadMinAllowedFeatureSize, ss}})}; } - const FeatureIdsArrayType* featureIdsPtr = data.getDataAs(featureIdsPath); + const FeatureIdsArrayType* featureIdsPtr = dataStructure.getDataAs(featureIdsPath); if(featureIdsPtr == nullptr) { return {nonstd::make_unexpected(std::vector{Error{k_BadNumCellsPath, "FeatureIds not provided as an Int32 Array."}})}; } - const NumCellsArrayType* numCellsPtr = data.getDataAs(numCellsPath); + const NumCellsArrayType* numCellsPtr = dataStructure.getDataAs(numCellsPath); if(numCellsPtr == nullptr) { return {nonstd::make_unexpected(std::vector{Error{k_BadNumCellsPath, "Num Cells not provided as an Int32 Array."}})}; @@ -350,19 +350,17 @@ IFilter::PreflightResult RemoveMinimumSizeFeaturesFilter::preflightImpl(const Da if(applyToSinglePhase) { - const PhasesArrayType* featurePhasesPtr = data.getDataAs(featurePhasesPath); - const PhasesArrayType::store_type* featurePhases = nullptr; + const PhasesArrayType* featurePhasesPtr = dataStructure.getDataAs(featurePhasesPath); if(featurePhasesPtr != nullptr) { dataArrayPaths.push_back(featurePhasesPath); - featurePhases = featurePhasesPtr->getDataStore(); } } - data.validateNumberOfTuples(dataArrayPaths); + dataStructure.validateNumberOfTuples(dataArrayPaths); DataPath featureGroupDataPath = numCellsPath.getParent(); - const BaseGroup* featureDataGroup = data.getDataAs(featureGroupDataPath); + const BaseGroup* featureDataGroup = dataStructure.getDataAs(featureGroupDataPath); if(nullptr == featureDataGroup) { return {nonstd::make_unexpected(std::vector{Error{k_ParentlessPathError, "The provided NumCells DataPath does not have a parent."}})}; @@ -372,30 +370,13 @@ IFilter::PreflightResult RemoveMinimumSizeFeaturesFilter::preflightImpl(const Da nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; - // Throw a warning to inform the user that the neighbor list arrays could be deleted by this filter - std::string ss = fmt::format("If this filter modifies the Cell Level Array '{}', all arrays of type NeighborList will be deleted from the feature data group '{}'. These arrays are:\n", - featureIdsPath.toString(), featureGroupDataPath.toString()); - - auto result = nx::core::GetAllChildDataPaths(data, featureGroupDataPath, DataObject::Type::NeighborList); - if(!result.has_value()) - { - return {nonstd::make_unexpected( - std::vector{Error{k_FetchChildArrayError, fmt::format("Errors were encountered trying to retrieve the neighbor list children of group '{}'", featureGroupDataPath.toString())}})}; - } - std::vector featureNeighborListArrays = result.value(); - for(const auto& featureNeighborList : featureNeighborListArrays) + // This section will warn the user about the removal of NeighborLists + auto result = nx::core::NeighborListRemovalPreflightCode(dataStructure, featureIdsPath, numCellsPath, resultOutputActions); + if(result.outputActions.invalid()) { - ss.append(" " + featureNeighborList.toString() + "\n"); - auto action = std::make_unique(featureNeighborList); - resultOutputActions.value().actions.emplace_back(std::move(action)); + return result; } - // Inform users that the following arrays are going to be modified in place - // Feature Data is going to be modified - nx::core::AppendDataObjectModifications(data, resultOutputActions.value().modifiedActions, featureGroupDataPath, {}); - - resultOutputActions.warnings().push_back(Warning{k_NeighborListRemoval, ss}); - // Return both the resultOutputActions and the preflightUpdatedValues via std::move() return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; } @@ -466,7 +447,7 @@ Result<> RemoveMinimumSizeFeaturesFilter::executeImpl(DataStructure& dataStructu std::string message = fmt::format("Feature Count Changed: Previous: {} New: {}", currentFeatureCount, count); messageHandler(nx::core::IFilter::Message{nx::core::IFilter::Message::Type::Info, message}); - nx::core::RemoveInactiveObjects(dataStructure, cellFeatureGroupPath, activeObjects, featureIdsArrayRef, currentFeatureCount); + nx::core::RemoveInactiveObjects(dataStructure, cellFeatureGroupPath, activeObjects, featureIdsArrayRef, currentFeatureCount, messageHandler); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveMinimumSizeFeaturesFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveMinimumSizeFeaturesFilter.hpp index 189623f884..e592d004ae 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveMinimumSizeFeaturesFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveMinimumSizeFeaturesFilter.hpp @@ -84,12 +84,12 @@ class SIMPLNXCORE_EXPORT RemoveMinimumSizeFeaturesFilter : public IFilter protected: /** * @brief - * @param data + * @param dataStructure * @param args * @param messageHandler * @return PreflightResult */ - PreflightResult preflightImpl(const DataStructure& data, const Arguments& args, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const override; + PreflightResult preflightImpl(const DataStructure& dataStructure, const Arguments& args, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const override; /** * @brief diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleImageGeomFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleImageGeomFilter.cpp index 2d236db440..ed886fd003 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleImageGeomFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleImageGeomFilter.cpp @@ -292,9 +292,11 @@ IFilter::PreflightResult ResampleImageGeomFilter::preflightImpl(const DataStruct } if(!warningMsg.empty()) { - resultOutputActions.m_Warnings.push_back( - Warning({-55503, fmt::format("This filter modifies the Cell Level Array '{}', the following arrays are of type NeighborList and will not be copied over:{}", featureIdsArrayPath.toString(), - warningMsg)})); + resultOutputActions.m_Warnings.push_back(Warning( + {-55503, + fmt::format( + "This filter will modify the Cell Level Array '{}' which causes all Feature level NeighborLists to become invalid. These NeighborLists will not be copied to the new geometry:{}", + featureIdsArrayPath.toString(), warningMsg)})); } } @@ -396,9 +398,7 @@ namespace { namespace SIMPL { -constexpr StringLiteral k_CurrentGeomtryInfoKey = "CurrentGeomtryInfo"; constexpr StringLiteral k_SpacingKey = "Spacing"; -constexpr StringLiteral k_NewGeomtryInfoKey = "NewGeomtryInfo"; constexpr StringLiteral k_RenumberFeaturesKey = "RenumberFeatures"; constexpr StringLiteral k_SaveAsNewDataContainerKey = "SaveAsNewDataContainer"; constexpr StringLiteral k_CellAttributeMatrixPathKey = "CellAttributeMatrixPath"; diff --git a/src/simplnx/Filter/Actions/DeleteDataAction.cpp b/src/simplnx/Filter/Actions/DeleteDataAction.cpp index 6caad648e4..344ebd1ce0 100644 --- a/src/simplnx/Filter/Actions/DeleteDataAction.cpp +++ b/src/simplnx/Filter/Actions/DeleteDataAction.cpp @@ -21,7 +21,7 @@ Result<> TerminateNode(DataStructure& dataStructure, const DataPath& path, IData DataObject* targetObject = dataStructure.getData(path); if(targetObject == nullptr) { - return {nonstd::make_unexpected(std::vector{{k_TargetNotFoundErrorCode, fmt::format("Trying to delete DataObject '{}' which does not exist.", path.getTargetName())}})}; + return MakeErrorResult(k_TargetNotFoundErrorCode, fmt::format("Trying to delete DataObject '{}' which does not exist.", path.getTargetName())); } dataStructure.removeData(targetObject->getId()); diff --git a/src/simplnx/Utilities/DataGroupUtilities.cpp b/src/simplnx/Utilities/DataGroupUtilities.cpp index d07d3213d3..48b8f6ff3d 100644 --- a/src/simplnx/Utilities/DataGroupUtilities.cpp +++ b/src/simplnx/Utilities/DataGroupUtilities.cpp @@ -5,7 +5,8 @@ namespace nx::core { -bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& featureDataGroupPath, const std::vector& activeObjects, Int32Array& cellFeatureIds, size_t currentFeatureCount) +bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& featureDataGroupPath, const std::vector& activeObjects, Int32Array& cellFeatureIds, size_t currentFeatureCount, + const IFilter::MessageHandler& messageHandler) { bool acceptableMatrix = true; @@ -97,7 +98,8 @@ bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& feature std::vector neighborListDataPaths = result.value(); for(const auto& neighborListDataPath : neighborListDataPaths) { - dataStructure.removeData(neighborListDataPath); + messageHandler( + nx::core::IFilter::Message{nx::core::IFilter::Message::Type::Info, fmt::format("NeighborList '{}' will be removed from the DataStructure.", neighborListDataPath.toString())}); } } } diff --git a/src/simplnx/Utilities/DataGroupUtilities.hpp b/src/simplnx/Utilities/DataGroupUtilities.hpp index db713aa810..f525069477 100644 --- a/src/simplnx/Utilities/DataGroupUtilities.hpp +++ b/src/simplnx/Utilities/DataGroupUtilities.hpp @@ -4,6 +4,7 @@ #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/DataStructure/DataStructure.hpp" #include "simplnx/DataStructure/IDataArray.hpp" +#include "simplnx/Filter/IFilter.hpp" #include "simplnx/simplnx_export.hpp" #include @@ -13,16 +14,19 @@ namespace nx::core { /** - * @brief RemoveInactiveObjects This assumes a single Dimension TupleShape, i.e., a Linear array, (1D). + * @brief RemoveInactiveObjects This assumes a single Dimension TupleShape, i.e., a Linear array, (1D) + * + * NeighborLists are NO LONGER Removed. That is the responsibility of the filter. * * @param dataStructure * @param featureDataGroupPath * @param activeObjects * @param cellFeatureIds + * @param messageHandler * @return */ SIMPLNX_EXPORT bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& featureDataGroupPath, const std::vector& activeObjects, Int32Array& cellFeatureIds, - size_t currentFeatureCount); + size_t currentFeatureCount, const IFilter::MessageHandler& messageHandler); /** * @brief This function will gather all of the sibling DataArrays to the input DataPath, then filter out all the 'IgnoredDataPaths` diff --git a/src/simplnx/Utilities/FilterUtilities.cpp b/src/simplnx/Utilities/FilterUtilities.cpp index cc314140be..770c30f410 100644 --- a/src/simplnx/Utilities/FilterUtilities.cpp +++ b/src/simplnx/Utilities/FilterUtilities.cpp @@ -1,5 +1,8 @@ #include "FilterUtilities.hpp" +#include "simplnx/Filter/Actions/DeleteDataAction.hpp" +#include "simplnx/Utilities/DataGroupUtilities.hpp" + #include #include @@ -39,4 +42,39 @@ void AppendDataObjectModifications(const DataStructure& dataStructure, std::vect } } +// ----------------------------------------------------------------------------- +IFilter::PreflightResult NeighborListRemovalPreflightCode(const DataStructure& dataStructure, const DataPath& featureIdsPath, const DataPath& numNeighborsPath, + nx::core::Result& resultOutputActions) +{ + constexpr int32 k_FetchChildArrayError = -5559; + constexpr int32 k_NeighborListRemoval = -5558; + + DataPath featureGroupDataPath = numNeighborsPath.getParent(); + + // Throw a warning to inform the user that the neighbor list arrays could be deleted by this filter + std::string ss = + fmt::format("This filter WILL remove all arrays of type NeighborList from the feature Attribute Matrix '{}'. These arrays are:\n", featureIdsPath.toString(), featureGroupDataPath.toString()); + + auto result = nx::core::GetAllChildDataPaths(dataStructure, featureGroupDataPath, DataObject::Type::NeighborList); + if(!result.has_value()) + { + return {nonstd::make_unexpected( + std::vector{Error{k_FetchChildArrayError, fmt::format("Errors were encountered trying to retrieve the neighbor list children of group '{}'", featureGroupDataPath.toString())}})}; + } + std::vector featureNeighborListArrays = result.value(); + for(const auto& featureNeighborList : featureNeighborListArrays) + { + ss.append(" " + featureNeighborList.toString() + "\n"); + auto action = std::make_unique(featureNeighborList); + resultOutputActions.value().deferredActions.emplace_back(std::move(action)); + } + + // Inform users that the following arrays are going to be modified in place + // Feature Data is going to be modified + nx::core::AppendDataObjectModifications(dataStructure, resultOutputActions.value().modifiedActions, featureGroupDataPath, {}); + + resultOutputActions.warnings().push_back(Warning{k_NeighborListRemoval, ss}); + return {}; +} + } // namespace nx::core diff --git a/src/simplnx/Utilities/FilterUtilities.hpp b/src/simplnx/Utilities/FilterUtilities.hpp index 13f016903c..cbea57c2e7 100644 --- a/src/simplnx/Utilities/FilterUtilities.hpp +++ b/src/simplnx/Utilities/FilterUtilities.hpp @@ -3,8 +3,8 @@ #include "ParallelAlgorithmUtilities.hpp" #include "simplnx/Common/Result.hpp" #include "simplnx/Common/Types.hpp" +#include "simplnx/Filter/IFilter.hpp" #include "simplnx/Filter/Output.hpp" -#include "simplnx/Utilities/DataGroupUtilities.hpp" #include "simplnx/simplnx_export.hpp" #include @@ -206,4 +206,15 @@ SIMPLNX_EXPORT std::vector CreateDelimitersVector(bool tabAsDelimiter, boo */ SIMPLNX_EXPORT void AppendDataObjectModifications(const DataStructure& dataStructure, std::vector& modifiedActions, const DataPath& parentPath, const std::vector& ignoredDataPaths); + +/** + * @brief This will create warnings about the removal of NeighborLists + * @param dataStructure The DataStructure object + * @param featureIdsPath The DataPath to the "FeatureIds" Array + * @param numNeighborsPath The DataPath to the "NumberNeighbors" Array + * @param resultOutputActions Reference to the OutputActions that needs to be updated. + */ +SIMPLNX_EXPORT IFilter::PreflightResult NeighborListRemovalPreflightCode(const DataStructure& dataStructure, const DataPath& featureIdsPath, const DataPath& numNeighborsPath, + nx::core::Result& resultOutputActions); + } // namespace nx::core diff --git a/src/simplnx/Utilities/SamplingUtils.hpp b/src/simplnx/Utilities/SamplingUtils.hpp index 3b94544725..ce0d51df5a 100644 --- a/src/simplnx/Utilities/SamplingUtils.hpp +++ b/src/simplnx/Utilities/SamplingUtils.hpp @@ -12,7 +12,7 @@ namespace nx::core namespace Sampling { inline Result<> RenumberFeatures(DataStructure& dataStructure, const DataPath& newGeomPath, const DataPath& destCellFeatAttributeMatrixPath, const DataPath& featureIdsArrayPath, - const DataPath& destFeatureIdsArrayPath, const std::atomic_bool& shouldCancel = false) + const DataPath& destFeatureIdsArrayPath, const IFilter::MessageHandler& messageHandler, const std::atomic_bool& shouldCancel = false) { auto& destImageGeom = dataStructure.getDataRefAs(newGeomPath); // This just sanity checks to make sure there were existing features before the cropping @@ -58,7 +58,7 @@ inline Result<> RenumberFeatures(DataStructure& dataStructure, const DataPath& n } } - if(!RemoveInactiveObjects(dataStructure, destCellFeatAttributeMatrixPath, activeObjects, destFeatureIdsRef, totalFeatures)) + if(!RemoveInactiveObjects(dataStructure, destCellFeatAttributeMatrixPath, activeObjects, destFeatureIdsRef, totalFeatures, messageHandler)) { std::string ss = fmt::format("An error occurred while trying to remove the inactive objects from Attribute Matrix '{}'", destCellFeatAttributeMatrixPath.toString()); return MakeErrorResult(-606, ss);