From 825143f6f73e4b0f0ebca0b4da72be19551637fd Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Mon, 3 Jun 2024 11:44:58 -0400 Subject: [PATCH] ENH: Filter Parameter for COPY/MOVE options are consistent (#983) Created Enums that should be used for Array handling in these kinds of filters Update the python bindings to also expose the enums to the python side. Signed-off-by: Michael Jackson --- .../Algorithms/ExtractVertexGeometry.cpp | 4 +- .../Algorithms/ExtractVertexGeometry.hpp | 6 --- .../Filters/CopyDataObjectFilter.cpp | 12 ++--- .../Filters/CreateGeometryFilter.cpp | 33 +++++--------- .../Filters/ExtractVertexGeometryFilter.cpp | 10 ++--- .../test/ExtractPipelineToFileTest.cpp | 4 +- .../test/ExtractVertexGeometryTest.cpp | 14 +++--- .../SimplnxCore/wrapping/python/simplnxpy.cpp | 44 ++++++++++--------- src/simplnx/Common/Types.hpp | 8 ++++ src/simplnx/Filter/Output.hpp | 8 ---- 10 files changed, 64 insertions(+), 79 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.cpp index 483b506b7a..08a9bd39ed 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.cpp @@ -149,7 +149,7 @@ Result<> ExtractVertexGeometry::operator()() } // If we are copying arrays, either with or without a mask, this code is applicable. - if(m_InputValues->ArrayHandling == static_cast(ArrayHandlingType::CopyArrays)) + if(m_InputValues->ArrayHandling == to_underlying(ArrayHandlingType::Copy)) { // Since we made copies of the DataArrays, we can safely resize the entire Attribute Matrix, // which will resize all the contained DataArrays @@ -168,7 +168,7 @@ Result<> ExtractVertexGeometry::operator()() // took care of renaming/moving the arrays for us and we are done. // If we are MOVING arrays AND we are using a mask then we need this code block to execute - if(m_InputValues->ArrayHandling == static_cast(ArrayHandlingType::MoveArrays) && m_InputValues->UseMask && vertexCount != cellCount) + if(m_InputValues->ArrayHandling == to_underlying(ArrayHandlingType::Move) && m_InputValues->UseMask && vertexCount != cellCount) { // The arrays have already been moved at this point, so the source and // destinations are the same. This should work. diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.hpp index 9f10527f36..ff90d601d6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.hpp @@ -33,12 +33,6 @@ class SIMPLNXCORE_EXPORT ExtractVertexGeometry ExtractVertexGeometry& operator=(const ExtractVertexGeometry&) = delete; ExtractVertexGeometry& operator=(ExtractVertexGeometry&&) noexcept = delete; - enum class ArrayHandlingType : ChoicesParameter::ValueType - { - MoveArrays, - CopyArrays - }; - Result<> operator()(); const std::atomic_bool& getCancel(); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CopyDataObjectFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CopyDataObjectFilter.cpp index a8e2f1e02b..6d1735bcc2 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CopyDataObjectFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CopyDataObjectFilter.cpp @@ -51,15 +51,17 @@ Parameters CopyDataObjectFilter::parameters() const { Parameters params; + params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); + params.insertLinkableParameter(std::make_unique(k_UseNewParent_Key, "Copy to New Parent", "Copy all the DataObjects to a different Group", false)); + params.insert(std::make_unique(k_NewPath_Key, "New Parent Destination", "DataPath to parent Group in which to store the copied DataObject(s)", DataPath{}, + BaseGroup::GetAllGroupTypes())); + params.insert(std::make_unique(k_NewPathSuffix_Key, "Copied Object(s) Suffix", "Suffix string to be appended to each copied DataObject. Can be blank.", "_COPY")); + params.insertSeparator(Parameters::Separator{"Input Data Objects"}); params.insert(std::make_unique(k_DataPath_Key, "Objects to copy", "A list of DataPaths to the DataObjects to be copied", MultiPathSelectionParameter::ValueType{})); - params.insertLinkableParameter(std::make_unique(k_UseNewParent_Key, "Copy to New Parent", "Copy all the DataObjects to a new BaseGroup", false)); - params.insert(std::make_unique(k_NewPath_Key, "Copied Parent Group", "DataPath to parent BaseGroup in which to store the copied DataObject(s)", DataPath{}, - BaseGroup::GetAllGroupTypes())); - params.insert(std::make_unique(k_NewPathSuffix_Key, "Copied Object(s) Suffix", "Suffix string to be appended to each copied DataObject", "_COPY")); - params.linkParameters(k_UseNewParent_Key, k_NewPath_Key, true); + return params; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateGeometryFilter.cpp index 594602714f..da848107ca 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateGeometryFilter.cpp @@ -37,10 +37,7 @@ Result<> checkGeometryArraysCompatible(const Float32Array& vertices, const UInt6 uint64 idx = 0; for(usize i = 0; i < cells.getSize(); i++) { - if(cells[i] > idx) - { - idx = cells[i]; - } + idx = std::max(cells[i], idx); } if((idx + 1) > numVertices) { @@ -120,8 +117,8 @@ Parameters CreateGeometryFilter::parameters() const IGeometry::GetAllLengthUnitStrings())); params.insert(std::make_unique(k_WarningsAsErrors_Key, "Treat Geometry Warnings as Errors", "Whether run time warnings for Geometries should be treated as errors", false)); params.insert(std::make_unique(k_ArrayHandling_Key, "Array Handling", - "Determines if the arrays that make up the geometry primitives should be Moved or Copied to the created Geometry object.", 0, - ChoicesParameter::Choices{"Copy Array", "Move Array" /*, "Reference Array"*/})); + "Determines if the arrays that make up the geometry primitives should be Moved or Copied to the created Geometry object.", + to_underlying(ArrayHandlingType::Move), ChoicesParameter::Choices{"Copy Attribute Arrays", "Move Attribute Arrays" /*, "Reference Array"*/})); params.insert(std::make_unique(k_Dimensions_Key, "Dimensions", "The number of cells in each of the X, Y, Z directions", std::vector{20ULL, 60ULL, 200ULL}, std::vector{"X"s, "Y"s, "Z"s})); @@ -216,9 +213,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure { auto pGeometryPath = filterArgs.value(k_GeometryPath_Key); auto pGeometryType = filterArgs.value(k_GeometryType_Key); - auto pWarningsAsErrors = filterArgs.value(k_WarningsAsErrors_Key); auto pArrayHandling = filterArgs.value(k_ArrayHandling_Key); - auto pMoveArrays = pArrayHandling == k_MoveArray; nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; @@ -305,13 +300,12 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure xBounds->getNumberOfTuples(), yBounds->getNumberOfTuples(), zBounds->getNumberOfTuples())}})}; } - auto createRectGridGeometryAction = - std::make_unique(pGeometryPath, pXBoundsPath, pYBoundsPath, pZBoundsPath, pCellAMName, IDataCreationAction::ArrayHandlingType{pArrayHandling}); + auto createRectGridGeometryAction = std::make_unique(pGeometryPath, pXBoundsPath, pYBoundsPath, pZBoundsPath, pCellAMName, ArrayHandlingType{pArrayHandling}); resultOutputActions.value().appendAction(std::move(createRectGridGeometryAction)); } if(pGeometryType == k_VertexGeometry) // VertexGeom { - auto createVertexGeomAction = std::make_unique(pGeometryPath, pVertexListPath, pVertexAMName, IDataCreationAction::ArrayHandlingType{pArrayHandling}); + auto createVertexGeomAction = std::make_unique(pGeometryPath, pVertexListPath, pVertexAMName, ArrayHandlingType{pArrayHandling}); resultOutputActions.value().appendAction(std::move(createVertexGeomAction)); } if(pGeometryType == k_EdgeGeometry) // EdgeGeom @@ -323,8 +317,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure return {nonstd::make_unexpected(std::vector{Error{-9845, fmt::format("Cannot find selected edge list at path '{}'", pEdgeListPath.toString())}})}; } - auto createEdgeGeomAction = - std::make_unique(pGeometryPath, pVertexListPath, pEdgeListPath, pVertexAMName, pEdgeAMName, IDataCreationAction::ArrayHandlingType{pArrayHandling}); + auto createEdgeGeomAction = std::make_unique(pGeometryPath, pVertexListPath, pEdgeListPath, pVertexAMName, pEdgeAMName, ArrayHandlingType{pArrayHandling}); resultOutputActions.value().appendAction(std::move(createEdgeGeomAction)); } if(pGeometryType == k_TriangleGeometry) // TriangleGeom @@ -335,8 +328,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure return {nonstd::make_unexpected(std::vector{Error{-9846, fmt::format("Cannot find selected triangle list at path '{}'", pTriangleListPath.toString())}})}; } - auto createTriangleGeomAction = - std::make_unique(pGeometryPath, pVertexListPath, pTriangleListPath, pVertexAMName, pFaceAMName, IDataCreationAction::ArrayHandlingType{pArrayHandling}); + auto createTriangleGeomAction = std::make_unique(pGeometryPath, pVertexListPath, pTriangleListPath, pVertexAMName, pFaceAMName, ArrayHandlingType{pArrayHandling}); resultOutputActions.value().appendAction(std::move(createTriangleGeomAction)); } if(pGeometryType == k_QuadGeometry) // QuadGeom @@ -347,8 +339,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure return {nonstd::make_unexpected(std::vector{Error{-9847, fmt::format("Cannot find selected quadrilateral list at path '{}'", pQuadListPath.toString())}})}; } - auto createQuadGeomAction = - std::make_unique(pGeometryPath, pVertexListPath, pQuadListPath, pVertexAMName, pFaceAMName, IDataCreationAction::ArrayHandlingType{pArrayHandling}); + auto createQuadGeomAction = std::make_unique(pGeometryPath, pVertexListPath, pQuadListPath, pVertexAMName, pFaceAMName, ArrayHandlingType{pArrayHandling}); resultOutputActions.value().appendAction(std::move(createQuadGeomAction)); } if(pGeometryType == k_TetGeometry) // TetrahedralGeom @@ -359,8 +350,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure return {nonstd::make_unexpected(std::vector{Error{-9848, fmt::format("Cannot find selected quadrilateral list at path '{}'", pTetListPath.toString())}})}; } - auto createTetGeomAction = - std::make_unique(pGeometryPath, pVertexListPath, pTetListPath, pVertexAMName, pCellAMName, IDataCreationAction::ArrayHandlingType{pArrayHandling}); + auto createTetGeomAction = std::make_unique(pGeometryPath, pVertexListPath, pTetListPath, pVertexAMName, pCellAMName, ArrayHandlingType{pArrayHandling}); resultOutputActions.value().appendAction(std::move(createTetGeomAction)); } if(pGeometryType == k_HexGeometry) // HexahedralGeom @@ -371,8 +361,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure return {nonstd::make_unexpected(std::vector{Error{-9849, fmt::format("Cannot find selected quadrilateral list at path '{}'", pHexListPath.toString())}})}; } - auto createHexGeomAction = - std::make_unique(pGeometryPath, pVertexListPath, pHexListPath, pVertexAMName, pCellAMName, IDataCreationAction::ArrayHandlingType{pArrayHandling}); + auto createHexGeomAction = std::make_unique(pGeometryPath, pVertexListPath, pHexListPath, pVertexAMName, pCellAMName, ArrayHandlingType{pArrayHandling}); resultOutputActions.value().appendAction(std::move(createHexGeomAction)); } @@ -387,7 +376,7 @@ Result<> CreateGeometryFilter::executeImpl(DataStructure& dataStructure, const A auto geometryPath = filterArgs.value(k_GeometryPath_Key); auto geometryType = filterArgs.value(k_GeometryType_Key); auto treatWarningsAsErrors = filterArgs.value(k_WarningsAsErrors_Key); - auto moveArrays = filterArgs.value(k_ArrayHandling_Key) == k_MoveArray; + // auto moveArrays = filterArgs.value(k_ArrayHandling_Key) == k_MoveArray; auto iGeometry = dataStructure.getDataAs(geometryPath); auto lengthUnit = static_cast(filterArgs.value(k_LengthUnitType_Key)); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractVertexGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractVertexGeometryFilter.cpp index 095bb40471..8046a84b4f 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractVertexGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractVertexGeometryFilter.cpp @@ -67,8 +67,8 @@ Parameters ExtractVertexGeometryFilter::parameters() const Parameters params; // Create the parameter descriptors that are needed for this filter params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); - params.insert(std::make_unique(k_ArrayHandling_Key, "Array Handling", "[0] Move or [1] Copy input data arrays", 0, - ChoicesParameter::Choices{"Move Attribute Arrays", "Copy Attribute Arrays"})); + params.insert(std::make_unique(k_ArrayHandling_Key, "Array Handling", "[0] Move or [1] Copy input data arrays", to_underlying(ArrayHandlingType::Move), + ChoicesParameter::Choices{"Copy Attribute Arrays", "Move Attribute Arrays"})); params.insertSeparator(Parameters::Separator{"Optional Data Mask"}); params.insertLinkableParameter(std::make_unique(k_UseMask_Key, "Use Mask Array", "Specifies whether or not to use a mask array", false)); @@ -118,8 +118,6 @@ IFilter::PreflightResult ExtractVertexGeometryFilter::preflightImpl(const DataSt nx::core::Result resultOutputActions; - const ExtractVertexGeometry::ArrayHandlingType arrayHandlingType = static_cast(pArrayHandlingValue); - const IGridGeometry& geometry = dataStructure.getDataRefAs({pInputGeometryPathValue}); SizeVec3 dims = geometry.getDimensions(); usize geomElementCount = dims[0] * dims[1] * dims[2]; @@ -173,13 +171,13 @@ IFilter::PreflightResult ExtractVertexGeometryFilter::preflightImpl(const DataSt { const IDataArray& dataArray = dataStructure.getDataRefAs(dataPath); - if(arrayHandlingType == ExtractVertexGeometry::ArrayHandlingType::CopyArrays) + if(pArrayHandlingValue == to_underlying(ArrayHandlingType::Copy)) { DataPath newDataPath = vertexAttrMatrixPath.createChildPath(dataPath.getTargetName()); auto createArrayAction = std::make_unique(dataArray.getDataType(), dataArray.getTupleShape(), dataArray.getComponentShape(), newDataPath); resultOutputActions.value().appendAction(std::move(createArrayAction)); } - else if(arrayHandlingType == ExtractVertexGeometry::ArrayHandlingType::MoveArrays) + else if(pArrayHandlingValue == to_underlying(ArrayHandlingType::Move)) { auto moveDataAction = std::make_unique(dataPath, vertexAttrMatrixPath); resultOutputActions.value().appendAction(std::move(moveDataAction)); diff --git a/src/Plugins/SimplnxCore/test/ExtractPipelineToFileTest.cpp b/src/Plugins/SimplnxCore/test/ExtractPipelineToFileTest.cpp index 4f72942a59..6bebce5ff8 100644 --- a/src/Plugins/SimplnxCore/test/ExtractPipelineToFileTest.cpp +++ b/src/Plugins/SimplnxCore/test/ExtractPipelineToFileTest.cpp @@ -22,7 +22,7 @@ fs::path k_JsonOutputFile(k_OutputFileName.string() + Pipeline::k_SIMPLExtension fs::path k_NXOutputFile(k_OutputFileName.string() + Pipeline::k_Extension.str()); } // namespace -TEST_CASE("SimplnxCore::ExtractPipelineToFileFilter : Valid Execution", "[SimplnxCore][ExtractPipelineToFileFilter]") +TEST_CASE("SimplnxCore::ExtractPipelineToFileFilter: Valid Execution", "[SimplnxCore][ExtractPipelineToFileFilter]") { // Instantiate the filter, a DataStructure object and an Arguments Object DataStructure dataStructure; @@ -49,7 +49,7 @@ TEST_CASE("SimplnxCore::ExtractPipelineToFileFilter : Valid Execution", "[Simpln fs::remove(k_JsonOutputFile); } -TEST_CASE("SimplnxCore::ExtractPipelineToFileFilter : Valid Execution - incorrect output extension", "[SimplnxCore][ExtractPipelineToFileFilter]") +TEST_CASE("SimplnxCore::ExtractPipelineToFileFilter: Valid Execution - incorrect output extension", "[SimplnxCore][ExtractPipelineToFileFilter]") { // Instantiate the filter, a DataStructure object and an Arguments Object DataStructure dataStructure; diff --git a/src/Plugins/SimplnxCore/test/ExtractVertexGeometryTest.cpp b/src/Plugins/SimplnxCore/test/ExtractVertexGeometryTest.cpp index cd3232667b..009bdbc681 100644 --- a/src/Plugins/SimplnxCore/test/ExtractVertexGeometryTest.cpp +++ b/src/Plugins/SimplnxCore/test/ExtractVertexGeometryTest.cpp @@ -25,8 +25,6 @@ const std::string k_WrongAttrMatName = "WrongAttrMatrix"; const std::string k_FloatArrayName = "FloatArray"; const std::string k_MaskArrayName = "MaskArray"; const DataPath k_VertexDataContainerPath = {{"VertexDataContainer"}}; -const int32 k_MoveArrays = 0; -const int32 k_CopyArrays = 1; namespace ExtractVertexGeometryTest { @@ -88,7 +86,7 @@ TEST_CASE("SimplnxCore::ExtractVertexGeometry: Data Array With Wrong Tuple Count Arguments args; // Create default Parameters for the filter. - args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(k_MoveArrays)); + args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(to_underlying(ArrayHandlingType::Move))); args.insertOrAssign(ExtractVertexGeometryFilter::k_InputGeometryPath_Key, std::make_any(DataPath{{k_ImageGeometryName}})); args.insertOrAssign(ExtractVertexGeometryFilter::k_IncludedDataArrayPaths_Key, std::make_any(MultiArraySelectionParameter::ValueType{DataPath{{k_ImageGeometryName, k_WrongAttrMatName, k_FloatArrayName}}})); @@ -108,7 +106,7 @@ TEST_CASE("SimplnxCore::ExtractVertexGeometry: Mask Array With Wrong Tuple Count Arguments args; // Create default Parameters for the filter. - args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(k_MoveArrays)); + args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(to_underlying(ArrayHandlingType::Move))); args.insertOrAssign(ExtractVertexGeometryFilter::k_InputGeometryPath_Key, std::make_any(DataPath{{k_ImageGeometryName}})); args.insertOrAssign(ExtractVertexGeometryFilter::k_IncludedDataArrayPaths_Key, std::make_any(MultiArraySelectionParameter::ValueType{DataPath{{k_ImageGeometryName, k_CellAttrMatName, k_FloatArrayName}}})); @@ -132,7 +130,7 @@ TEST_CASE("SimplnxCore::ExtractVertexGeometry: Move cell data arrays", "[Simplnx MultiArraySelectionParameter::ValueType inputDataPaths = {DataPath({k_ImageGeometryName, k_CellAttrMatName, k_FloatArrayName})}; // Create default Parameters for the filter. - args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(k_MoveArrays)); + args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(to_underlying(ArrayHandlingType::Move))); args.insertOrAssign(ExtractVertexGeometryFilter::k_InputGeometryPath_Key, std::make_any(DataPath{{k_ImageGeometryName}})); args.insertOrAssign(ExtractVertexGeometryFilter::k_IncludedDataArrayPaths_Key, std::make_any(inputDataPaths)); args.insertOrAssign(ExtractVertexGeometryFilter::k_VertexGeometryPath_Key, std::make_any(DataPath{k_VertexDataContainerPath})); @@ -162,7 +160,7 @@ TEST_CASE("SimplnxCore::ExtractVertexGeometry: Copy cell data arrays", "[Simplnx MultiArraySelectionParameter::ValueType inputDataPaths = {DataPath({k_ImageGeometryName, k_CellAttrMatName, k_FloatArrayName})}; // Create default Parameters for the filter. - args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(k_CopyArrays)); + args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(to_underlying(ArrayHandlingType::Copy))); args.insertOrAssign(ExtractVertexGeometryFilter::k_InputGeometryPath_Key, std::make_any(DataPath{{k_ImageGeometryName}})); args.insertOrAssign(ExtractVertexGeometryFilter::k_IncludedDataArrayPaths_Key, std::make_any(inputDataPaths)); args.insertOrAssign(ExtractVertexGeometryFilter::k_VertexGeometryPath_Key, std::make_any(DataPath{k_VertexDataContainerPath})); @@ -205,7 +203,7 @@ TEST_CASE("SimplnxCore::ExtractVertexGeometry: Move cell data arrays with mask", MultiArraySelectionParameter::ValueType inputDataPaths = {DataPath({k_ImageGeometryName, k_CellAttrMatName, k_FloatArrayName})}; // Create default Parameters for the filter. - args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(k_MoveArrays)); + args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(to_underlying(ArrayHandlingType::Move))); args.insertOrAssign(ExtractVertexGeometryFilter::k_InputGeometryPath_Key, std::make_any(DataPath{{k_ImageGeometryName}})); args.insertOrAssign(ExtractVertexGeometryFilter::k_IncludedDataArrayPaths_Key, std::make_any(inputDataPaths)); args.insertOrAssign(ExtractVertexGeometryFilter::k_VertexGeometryPath_Key, std::make_any(DataPath{k_VertexDataContainerPath})); @@ -238,7 +236,7 @@ TEST_CASE("SimplnxCore::ExtractVertexGeometry: Copy cell data arrays with mask", MultiArraySelectionParameter::ValueType inputDataPaths = {DataPath({k_ImageGeometryName, k_CellAttrMatName, k_FloatArrayName})}; // Create default Parameters for the filter. - args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(k_CopyArrays)); + args.insertOrAssign(ExtractVertexGeometryFilter::k_ArrayHandling_Key, std::make_any(to_underlying(ArrayHandlingType::Copy))); args.insertOrAssign(ExtractVertexGeometryFilter::k_InputGeometryPath_Key, std::make_any(DataPath{{k_ImageGeometryName}})); args.insertOrAssign(ExtractVertexGeometryFilter::k_IncludedDataArrayPaths_Key, std::make_any(inputDataPaths)); args.insertOrAssign(ExtractVertexGeometryFilter::k_VertexGeometryPath_Key, std::make_any(DataPath{k_VertexDataContainerPath})); diff --git a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp index 99c0836c83..d693595d9d 100644 --- a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp +++ b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp @@ -200,7 +200,7 @@ auto BindCreateGeometry2DAction(py::handle scope, const char* name) auto createGeometry2DAction = py::class_(scope, name); createGeometry2DAction.def(py::init(), "geometry_path"_a, "num_faces"_a, "num_vertices"_a, "vertex_attribute_matrix_name"_a, "face_attribute_matrix_name"_a, "shared_vertices_name"_a, "shared_faces_name"_a); - createGeometry2DAction.def(py::init(), "geometry_path"_a, + createGeometry2DAction.def(py::init(), "geometry_path"_a, "input_vertices_array_path"_a, "input_faces_array_path"_a, "vertex_attribute_matrix_name"_a, "face_attribute_matrix_name"_a, "array_type"_a); return createGeometry2DAction; } @@ -211,7 +211,7 @@ auto BindCreateGeometry3DAction(py::handle scope, const char* name) auto createGeometry3DAction = py::class_(scope, name); createGeometry3DAction.def(py::init(), "geometry_path"_a, "num_cells"_a, "num_vertices"_a, "vertex_data_name"_a, "cell_data_name"_a, "shared_vertices_name"_a, "shared_cells_name"_a); - createGeometry3DAction.def(py::init(), "geometry_path"_a, + createGeometry3DAction.def(py::init(), "geometry_path"_a, "input_vertices_array_path"_a, "input_cell_array_path"_a, "vertex_attribute_matrix_name"_a, "cell_attribute_matrix_name"_a, "array_type"_a); return createGeometry3DAction; } @@ -450,6 +450,10 @@ PYBIND11_MODULE(simplnx, mod) dataType.value("float64", DataType::float64); dataType.value("boolean", DataType::boolean); + py::enum_ arrayHandlingType(mod, "ArrayHandlingType"); + arrayHandlingType.value("Copy", ArrayHandlingType::Copy); + arrayHandlingType.value("Move", ArrayHandlingType::Move); + py::class_ uuid(mod, "Uuid"); uuid.def(py::init<>()); uuid.def(py::init([](std::string_view text) { @@ -539,11 +543,11 @@ PYBIND11_MODULE(simplnx, mod) py::class_> arrayThreshold(mod, "ArrayThreshold"); - py::enum_ comparisionType(arrayThreshold, "ComparisonType"); - comparisionType.value("GreaterThan", ArrayThreshold::ComparisonType::GreaterThan); - comparisionType.value("LessThan", ArrayThreshold::ComparisonType::LessThan); - comparisionType.value("Equal", ArrayThreshold::ComparisonType::Operator_Equal); - comparisionType.value("NotEqual", ArrayThreshold::ComparisonType::Operator_NotEqual); + py::enum_ comparisonType(arrayThreshold, "ComparisonType"); + comparisonType.value("GreaterThan", ArrayThreshold::ComparisonType::GreaterThan); + comparisonType.value("LessThan", ArrayThreshold::ComparisonType::LessThan); + comparisonType.value("Equal", ArrayThreshold::ComparisonType::Operator_Equal); + comparisonType.value("NotEqual", ArrayThreshold::ComparisonType::Operator_NotEqual); arrayThreshold.def(py::init<>()); arrayThreshold.def_property("array_path", &ArrayThreshold::getArrayPath, &ArrayThreshold::setArrayPath); @@ -937,11 +941,11 @@ PYBIND11_MODULE(simplnx, mod) auto iDataCreationAction = py::class_(mod, "IDataCreationAction"); - auto iDataCreationActionArrayHandlingType = py::enum_(iDataCreationAction, "ArrayHandlingType"); - iDataCreationActionArrayHandlingType.value("Copy", IDataCreationAction::ArrayHandlingType::Copy); - iDataCreationActionArrayHandlingType.value("Move", IDataCreationAction::ArrayHandlingType::Move); - iDataCreationActionArrayHandlingType.value("Reference", IDataCreationAction::ArrayHandlingType::Reference); - iDataCreationActionArrayHandlingType.value("Create", IDataCreationAction::ArrayHandlingType::Create); + // auto iDataCreationActionArrayHandlingType = py::enum_(iDataCreationAction, "ArrayHandlingType"); + // iDataCreationActionArrayHandlingType.value("Copy", ArrayHandlingType::Copy); + // iDataCreationActionArrayHandlingType.value("Move", ArrayHandlingType::Move); + // iDataCreationActionArrayHandlingType.value("Reference", ArrayHandlingType::Reference); + // iDataCreationActionArrayHandlingType.value("Create", ArrayHandlingType::Create); auto copyArrayInstanceAction = SIMPLNX_PY_BIND_CLASS_VARIADIC(mod, CopyArrayInstanceAction, IDataCreationAction); copyArrayInstanceAction.def(py::init(), "input_data_array_path"_a, "output_data_array_path"_a); @@ -962,7 +966,7 @@ PYBIND11_MODULE(simplnx, mod) auto createEdgeGeometryAction = SIMPLNX_PY_BIND_CLASS_VARIADIC(mod, CreateEdgeGeometryAction, IDataCreationAction); createEdgeGeometryAction.def(py::init(), "geometry_path"_a, "num_edges"_a, "num_vertices"_a, "vertex_attribute_matrix_name"_a, "edge_attribute_matrix_name"_a, "shared_vertices_name"_a, "shared_edges_name"_a); - createEdgeGeometryAction.def(py::init(), "geometry_path"_a, + createEdgeGeometryAction.def(py::init(), "geometry_path"_a, "input_vertices_array_path"_a, "input_edges_array_path"_a, "vertex_attribute_matrix_name"_a, "edge_attribute_matrix_name"_a, "array_type"_a); auto createTriangleGeometryAction = SIMPLNX_PY_BIND_CREATE_GEOMETRY_2D_ACTION(mod, CreateTriangleGeometryAction); @@ -982,8 +986,8 @@ PYBIND11_MODULE(simplnx, mod) auto createRectGridGeometryAction = SIMPLNX_PY_BIND_CLASS_VARIADIC(mod, CreateRectGridGeometryAction, IDataCreationAction); createRectGridGeometryAction.def(py::init(), "path"_a, "x_bounds_dim"_a, "y_bounds_dim"_a, "z_bounds_dim"_a, "cell_attribute_matrix_name"_a, "x_bounds_name"_a, "y_bounds_name"_a, "z_bounds_name"_a); - createRectGridGeometryAction.def(py::init(), "path"_a, - "input_x_bounds_path"_a, "input_y_bounds_path"_a, "input_z_bounds_path"_a, "cell_attribute_matrix_name"_a, "array_type"_a); + createRectGridGeometryAction.def(py::init(), "path"_a, "input_x_bounds_path"_a, + "input_y_bounds_path"_a, "input_z_bounds_path"_a, "cell_attribute_matrix_name"_a, "array_type"_a); auto createStringArrayAction = SIMPLNX_PY_BIND_CLASS_VARIADIC(mod, CreateStringArrayAction, IDataCreationAction); createStringArrayAction.def(py::init&, const DataPath&, const std::string&>(), "t_dims"_a, "path"_a, "initialize_value"_a = std::string("")); @@ -991,7 +995,7 @@ PYBIND11_MODULE(simplnx, mod) auto createVertexGeometryAction = SIMPLNX_PY_BIND_CLASS_VARIADIC(mod, CreateVertexGeometryAction, IDataCreationAction); createVertexGeometryAction.def(py::init(), "geometry_path"_a, "num_vertices"_a, "vertex_attribute_matrix_name"_a, "shared_vertex_list_name"_a); - createVertexGeometryAction.def(py::init(), "geometry_path"_a, "input_vertices_array_path"_a, + createVertexGeometryAction.def(py::init(), "geometry_path"_a, "input_vertices_array_path"_a, "vertex_attribute_matrix_name"_a, "array_type"_a); auto deleteDataAction = SIMPLNX_PY_BIND_CLASS_VARIADIC(mod, DeleteDataAction, IDataAction); @@ -1103,10 +1107,10 @@ PYBIND11_MODULE(simplnx, mod) dream3dImportData.def_readwrite("data_paths", &Dream3dImportParameter::ImportData::DataPaths); dream3dImportData.def("__repr__", [](const Dream3dImportParameter::ImportData& self) { return "Dream3dImportParameter.ImportData()"; }); - auto arraySelectionParamterDataLocation = py::enum_(arraySelectionParameter, "DataLocation"); - arraySelectionParamterDataLocation.value("Any", ArraySelectionParameter::DataLocation::Any); - arraySelectionParamterDataLocation.value("InMemory", ArraySelectionParameter::DataLocation::InMemory); - arraySelectionParamterDataLocation.value("OutOfCore", ArraySelectionParameter::DataLocation::OutOfCore); + auto arraySelectionParameterDataLocation = py::enum_(arraySelectionParameter, "DataLocation"); + arraySelectionParameterDataLocation.value("Any", ArraySelectionParameter::DataLocation::Any); + arraySelectionParameterDataLocation.value("InMemory", ArraySelectionParameter::DataLocation::InMemory); + arraySelectionParameterDataLocation.value("OutOfCore", ArraySelectionParameter::DataLocation::OutOfCore); auto dynamicTableInfo = py::class_(mod, "DynamicTableInfo"); diff --git a/src/simplnx/Common/Types.hpp b/src/simplnx/Common/Types.hpp index c392e4be85..a4590ea99c 100644 --- a/src/simplnx/Common/Types.hpp +++ b/src/simplnx/Common/Types.hpp @@ -76,6 +76,14 @@ enum class DataType : uint8 boolean }; +enum class ArrayHandlingType : uint64 +{ + Copy = 0, // Copy an existing array to the constructed object + Move = 1, // Move an existing array to the constructed object + Reference = 2, // Reference an existing array + Create = 3 // Allocate a new array +}; + enum class RunState { Idle = 0, diff --git a/src/simplnx/Filter/Output.hpp b/src/simplnx/Filter/Output.hpp index 61e56a6697..9fbfc5434d 100644 --- a/src/simplnx/Filter/Output.hpp +++ b/src/simplnx/Filter/Output.hpp @@ -62,14 +62,6 @@ using AnyDataAction = AnyCloneable; class SIMPLNX_EXPORT IDataCreationAction : public IDataAction { public: - enum class ArrayHandlingType : uint64 - { - Copy = 0, // Copy an existing array to the constructed object - Move = 1, // Move an existing array to the constructed object - Reference = 2, // Reference an existing array - Create = 3 // Allocate a new array - }; - /** * @brief Constructs an IDataCreationAction that takes a DataPath specifying the path to be created. * @param createdPath