From 5c4354c44f5e3c28172302ca9f3243885a8649e8 Mon Sep 17 00:00:00 2001 From: nyoungbq Date: Tue, 20 Aug 2024 12:41:30 -0400 Subject: [PATCH] Utilities updates --- .../Filters/RemoveFlaggedEdgesFilter.cpp | 8 +-- .../Filters/RemoveFlaggedTrianglesFilter.cpp | 8 +-- .../src/SimplnxCore/utils/CSVDataParser.hpp | 6 +- src/simplnx/Utilities/AlignSections.cpp | 8 +-- src/simplnx/Utilities/AlignSections.hpp | 4 +- src/simplnx/Utilities/ArrayThreshold.cpp | 68 ++++--------------- src/simplnx/Utilities/ArrayThreshold.hpp | 25 ++++--- src/simplnx/Utilities/DataArrayUtilities.cpp | 16 ++++- src/simplnx/Utilities/DataArrayUtilities.hpp | 29 ++------ src/simplnx/Utilities/FilePathGenerator.cpp | 5 +- .../Utilities/ImageRotationUtilities.cpp | 2 +- src/simplnx/Utilities/OStreamUtilities.cpp | 45 ++++++------ src/simplnx/Utilities/SampleSurfaceMesh.cpp | 10 ++- 13 files changed, 91 insertions(+), 143 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedEdgesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedEdgesFilter.cpp index 9d8d11b080..b1f0df224f 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedEdgesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedEdgesFilter.cpp @@ -140,7 +140,7 @@ IFilter::PreflightResult RemoveFlaggedEdgesFilter::preflightImpl(const DataStruc { return {MakeErrorResult(-5651, fmt::format("'{}' must have edge data attribute matrix", pInitialGeometryPathValue.toString()))}; } - TransferGeometryElementData::createDataArrayActions(dataStructure, srcEdgeAttrMatPtr, selectedEdgeArrays, reducedEdgeAttributeMatrixPath, resultOutputActions); + TransferGeometryElementData::CreateDataArrayActions(dataStructure, srcEdgeAttrMatPtr, selectedEdgeArrays, reducedEdgeAttributeMatrixPath, resultOutputActions); } else if(pEdgeArrayHandling == detail::k_CopyAllEdgeArraysIdx) { @@ -154,7 +154,7 @@ IFilter::PreflightResult RemoveFlaggedEdgesFilter::preflightImpl(const DataStruc if(getChildrenResult.has_value()) { selectedEdgeArrays = getChildrenResult.value(); - TransferGeometryElementData::createDataArrayActions(dataStructure, srcEdgeAttrMatPtr, selectedEdgeArrays, reducedEdgeAttributeMatrixPath, resultOutputActions); + TransferGeometryElementData::CreateDataArrayActions(dataStructure, srcEdgeAttrMatPtr, selectedEdgeArrays, reducedEdgeAttributeMatrixPath, resultOutputActions); } } } @@ -170,7 +170,7 @@ IFilter::PreflightResult RemoveFlaggedEdgesFilter::preflightImpl(const DataStruc { return {MakeErrorResult(-5653, fmt::format("'{}' must have Vertex data attribute matrix", pInitialGeometryPathValue.toString()))}; } - TransferGeometryElementData::createDataArrayActions(dataStructure, srcVertexAttrMatPtr, selectedVertexArrays, reducedVertexAttributeMatrixPath, resultOutputActions); + TransferGeometryElementData::CreateDataArrayActions(dataStructure, srcVertexAttrMatPtr, selectedVertexArrays, reducedVertexAttributeMatrixPath, resultOutputActions); } else if(pVertexArrayHandling == detail::k_CopyAllVertexArraysIdx) { @@ -184,7 +184,7 @@ IFilter::PreflightResult RemoveFlaggedEdgesFilter::preflightImpl(const DataStruc if(getChildrenResult.has_value()) { selectedVertexArrays = getChildrenResult.value(); - TransferGeometryElementData::createDataArrayActions(dataStructure, srcVertexAttrMatPtr, selectedVertexArrays, reducedVertexAttributeMatrixPath, resultOutputActions); + TransferGeometryElementData::CreateDataArrayActions(dataStructure, srcVertexAttrMatPtr, selectedVertexArrays, reducedVertexAttributeMatrixPath, resultOutputActions); } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedTrianglesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedTrianglesFilter.cpp index 34220e4c1c..ff4dcc3cbe 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedTrianglesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedTrianglesFilter.cpp @@ -148,7 +148,7 @@ IFilter::PreflightResult RemoveFlaggedTrianglesFilter::preflightImpl(const DataS { return {MakeErrorResult(-5251, fmt::format("'{}' must have face data attribute matrix", pInitialGeometryPathValue.toString()))}; } - TransferGeometryElementData::createDataArrayActions(dataStructure, srcTriangleAttrMatPtr, selectedTriangleArrays, reducedFaceAttributeMatrixPath, resultOutputActions); + TransferGeometryElementData::CreateDataArrayActions(dataStructure, srcTriangleAttrMatPtr, selectedTriangleArrays, reducedFaceAttributeMatrixPath, resultOutputActions); } else if(pTriangleArrayHandling == detail::k_CopyAllTriangleArraysIdx) { @@ -162,7 +162,7 @@ IFilter::PreflightResult RemoveFlaggedTrianglesFilter::preflightImpl(const DataS if(getChildrenResult.has_value()) { selectedTriangleArrays = getChildrenResult.value(); - TransferGeometryElementData::createDataArrayActions(dataStructure, srcTriangleAttrMatPtr, selectedTriangleArrays, reducedFaceAttributeMatrixPath, resultOutputActions); + TransferGeometryElementData::CreateDataArrayActions(dataStructure, srcTriangleAttrMatPtr, selectedTriangleArrays, reducedFaceAttributeMatrixPath, resultOutputActions); } } } @@ -178,7 +178,7 @@ IFilter::PreflightResult RemoveFlaggedTrianglesFilter::preflightImpl(const DataS { return {MakeErrorResult(-5553, fmt::format("'{}' must have Vertex data attribute matrix", pInitialGeometryPathValue.toString()))}; } - TransferGeometryElementData::createDataArrayActions(dataStructure, srcVertexAttrMatPtr, selectedVertexArrays, reducedVertexAttributeMatrixPath, resultOutputActions); + TransferGeometryElementData::CreateDataArrayActions(dataStructure, srcVertexAttrMatPtr, selectedVertexArrays, reducedVertexAttributeMatrixPath, resultOutputActions); } else if(pVertexArrayHandling == detail::k_CopyAllVertexArraysIdx) { @@ -192,7 +192,7 @@ IFilter::PreflightResult RemoveFlaggedTrianglesFilter::preflightImpl(const DataS if(getChildrenResult.has_value()) { selectedVertexArrays = getChildrenResult.value(); - TransferGeometryElementData::createDataArrayActions(dataStructure, srcVertexAttrMatPtr, selectedVertexArrays, reducedVertexAttributeMatrixPath, resultOutputActions); + TransferGeometryElementData::CreateDataArrayActions(dataStructure, srcVertexAttrMatPtr, selectedVertexArrays, reducedVertexAttributeMatrixPath, resultOutputActions); } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/utils/CSVDataParser.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/CSVDataParser.hpp index 463c961700..0826fc7b13 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/utils/CSVDataParser.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/CSVDataParser.hpp @@ -45,17 +45,17 @@ class AbstractDataParser AbstractDataParser& operator=(const AbstractDataParser&) = delete; // Copy Assignment Not Implemented AbstractDataParser& operator=(AbstractDataParser&&) = delete; // Move Assignment - std::string columnName() const + [[nodiscard]] std::string columnName() const { return m_ColumnName; } - usize columnIndex() const + [[nodiscard]] usize columnIndex() const { return m_ColumnIndex; } - const IDataArray& dataArray() const + [[nodiscard]] const IDataArray& dataArray() const { return m_DataArray; } diff --git a/src/simplnx/Utilities/AlignSections.cpp b/src/simplnx/Utilities/AlignSections.cpp index ae869004af..3db2b85c68 100644 --- a/src/simplnx/Utilities/AlignSections.cpp +++ b/src/simplnx/Utilities/AlignSections.cpp @@ -167,7 +167,7 @@ Result<> AlignSections::execute(const SizeVec3& udims) } // ----------------------------------------------------------------------------- -Result<> AlignSections::readDream3dShiftsFile(const std::filesystem::path& file, int64 zDim, std::vector& xShifts, std::vector& yShifts) const +Result<> AlignSections::readDream3dShiftsFile(const std::filesystem::path& file, int64 zDim, std::vector& xShifts, std::vector& yShifts) { std::ifstream inFile; inFile.open(file); @@ -199,7 +199,7 @@ Result<> AlignSections::readDream3dShiftsFile(const std::filesystem::path& file, return MakeErrorResult(-84750, message); } std::istringstream temp(line); - iss.swap(temp); // reset the stream to beginning so we can read in the formatted tokens + iss.swap(temp); // reset the stream to beginning, so we can read in the formatted tokens iss >> slice >> slice2 >> newXShift >> newYShift >> xShift >> yShift; xShifts[iter] = xShifts[iter - 1] + newXShift; yShifts[iter] = yShifts[iter - 1] + newYShift; @@ -209,7 +209,7 @@ Result<> AlignSections::readDream3dShiftsFile(const std::filesystem::path& file, } // ----------------------------------------------------------------------------- -Result<> AlignSections::readUserShiftsFile(const std::filesystem::path& file, int64 zDim, std::vector& xShifts, std::vector& yShifts) const +Result<> AlignSections::readUserShiftsFile(const std::filesystem::path& file, int64 zDim, std::vector& xShifts, std::vector& yShifts) { int64 slice = 0; int64 newXShift = 0, newYShift = 0; @@ -235,7 +235,7 @@ Result<> AlignSections::readUserShiftsFile(const std::filesystem::path& file, in return MakeErrorResult(-84750, message); } std::istringstream temp(line); - iss.swap(temp); // reset the stream to beginning so we can read in the formatted tokens + iss.swap(temp); // reset the stream to beginning, so we can read in the formatted tokens inFile >> slice >> newXShift >> newYShift; xShifts[iter] = xShifts[iter - 1] + newXShift; yShifts[iter] = yShifts[iter - 1] + newYShift; diff --git a/src/simplnx/Utilities/AlignSections.hpp b/src/simplnx/Utilities/AlignSections.hpp index 3a478954e3..467a6e9725 100644 --- a/src/simplnx/Utilities/AlignSections.hpp +++ b/src/simplnx/Utilities/AlignSections.hpp @@ -54,7 +54,7 @@ class SIMPLNX_EXPORT AlignSections * @param yShifts * @return Whether or not the x and y shifts were successfully found */ - Result<> readDream3dShiftsFile(const std::filesystem::path& file, int64 zDim, std::vector& xShifts, std::vector& yShifts) const; + static Result<> readDream3dShiftsFile(const std::filesystem::path& file, int64 zDim, std::vector& xShifts, std::vector& yShifts) ; /** * @brief This will read in a shifts file defined by the user and populate the shifts parameters with the values as int64 numbers. @@ -64,7 +64,7 @@ class SIMPLNX_EXPORT AlignSections * @param yShifts * @return Whether or not the x and y shifts were successfully found */ - Result<> readUserShiftsFile(const std::filesystem::path& file, int64 zDim, std::vector& xShifts, std::vector& yShifts) const; + static Result<> readUserShiftsFile(const std::filesystem::path& file, int64 zDim, std::vector& xShifts, std::vector& yShifts); private: DataStructure& m_DataStructure; diff --git a/src/simplnx/Utilities/ArrayThreshold.cpp b/src/simplnx/Utilities/ArrayThreshold.cpp index 89adf721f0..d6329be91d 100644 --- a/src/simplnx/Utilities/ArrayThreshold.cpp +++ b/src/simplnx/Utilities/ArrayThreshold.cpp @@ -19,20 +19,14 @@ constexpr StringLiteral k_ArrayType = "array"; constexpr StringLiteral k_CollectionType = "collection"; } // namespace -IArrayThreshold::IArrayThreshold() +IArrayThreshold::IArrayThreshold() = default; +IArrayThreshold::IArrayThreshold(const IArrayThreshold& other) = default; -{ -} -IArrayThreshold::IArrayThreshold(const IArrayThreshold& other) +IArrayThreshold::IArrayThreshold(IArrayThreshold&& other) noexcept : m_IsInverted(other.m_IsInverted) , m_UnionType(other.m_UnionType) { } -IArrayThreshold::IArrayThreshold(IArrayThreshold&& other) noexcept -: m_IsInverted(std::move(other.m_IsInverted)) -, m_UnionType(std::move(other.m_UnionType)) -{ -} IArrayThreshold::~IArrayThreshold() = default; bool IArrayThreshold::isInverted() const @@ -68,18 +62,13 @@ ArrayThreshold::ArrayThreshold() { } -ArrayThreshold::ArrayThreshold(const ArrayThreshold& other) -: IArrayThreshold(other) -, m_ArrayPath(other.m_ArrayPath) -, m_Value(other.m_Value) -, m_Comparison(other.m_Comparison) -{ -} +ArrayThreshold::ArrayThreshold(const ArrayThreshold& other) = default; + ArrayThreshold::ArrayThreshold(ArrayThreshold&& other) noexcept : IArrayThreshold(std::move(other)) , m_ArrayPath(std::move(other.m_ArrayPath)) -, m_Value(std::move(other.m_Value)) -, m_Comparison(std::move(other.m_Comparison)) +, m_Value(other.m_Value) +, m_Comparison(other.m_Comparison) { } ArrayThreshold::~ArrayThreshold() = default; @@ -101,8 +90,8 @@ ArrayThreshold& ArrayThreshold::operator=(ArrayThreshold&& other) noexcept setUnionOperator(other.getUnionOperator()); m_ArrayPath = std::move(other.m_ArrayPath); - m_Value = std::move(other.m_Value); - m_Comparison = std::move(other.m_Comparison); + m_Value = other.m_Value; + m_Comparison = other.m_Comparison; return *this; } @@ -139,37 +128,6 @@ std::set ArrayThreshold::getRequiredPaths() const return {getArrayPath()}; } -template -bool checkArrayThreshold(const DataArray* dataArray, ArrayThreshold::ComparisonValue value, ArrayThreshold::ComparisonType comparison, usize tupleId) -{ - const auto dataStore = dataArray->getDataStore(); - const auto numComponents = dataStore->getNumberOfComponents(); - - auto tuplePos = tupleId * numComponents; - T tupleValue = 0; - for(usize i = tuplePos; i < tuplePos + numComponents; i++) - { - // Avoid overflow - tupleValue += dataStore->getValue(i) / static_cast(numComponents); - } - - bool threshold = false; - switch(comparison) - { - case ArrayThreshold::ComparisonType::GreaterThan: - threshold = (tupleValue > value); - break; - case ArrayThreshold::ComparisonType::LessThan: - threshold = (tupleValue < value); - break; - default: - threshold = false; - break; - } - - return threshold; -} - nlohmann::json ArrayThreshold::toJson() const { auto json = IArrayThreshold::toJson(); @@ -213,11 +171,9 @@ ArrayThresholdSet::ArrayThresholdSet() : IArrayThreshold() { } -ArrayThresholdSet::ArrayThresholdSet(const ArrayThresholdSet& other) -: IArrayThreshold(other) -, m_Thresholds(other.m_Thresholds) -{ -} + +ArrayThresholdSet::ArrayThresholdSet(const ArrayThresholdSet& other) = default; + ArrayThresholdSet::ArrayThresholdSet(ArrayThresholdSet&& other) noexcept : IArrayThreshold(std::move(other)) , m_Thresholds(std::move(other.m_Thresholds)) diff --git a/src/simplnx/Utilities/ArrayThreshold.hpp b/src/simplnx/Utilities/ArrayThreshold.hpp index adcd117d36..adcc7b3886 100644 --- a/src/simplnx/Utilities/ArrayThreshold.hpp +++ b/src/simplnx/Utilities/ArrayThreshold.hpp @@ -20,7 +20,6 @@ namespace nx::core class SIMPLNX_EXPORT IArrayThreshold { public: - using MaskValue = bool; enum class UnionOperator : uint8 { And, @@ -32,15 +31,15 @@ class SIMPLNX_EXPORT IArrayThreshold IArrayThreshold(IArrayThreshold&& other) noexcept; virtual ~IArrayThreshold(); - bool isInverted() const; + [[nodiscard]] bool isInverted() const; void setInverted(bool inverted); - UnionOperator getUnionOperator() const; + [[nodiscard]] UnionOperator getUnionOperator() const; void setUnionOperator(UnionOperator unionType); - virtual std::set getRequiredPaths() const = 0; + [[nodiscard]] virtual std::set getRequiredPaths() const = 0; - virtual nlohmann::json toJson() const; + [[nodiscard]] virtual nlohmann::json toJson() const; private: bool m_IsInverted{false}; @@ -70,18 +69,18 @@ class SIMPLNX_EXPORT ArrayThreshold : public IArrayThreshold ArrayThreshold& operator=(const ArrayThreshold& other); ArrayThreshold& operator=(ArrayThreshold&& other) noexcept; - DataPath getArrayPath() const; + [[nodiscard]] DataPath getArrayPath() const; void setArrayPath(const DataPath& path); - ComparisonValue getComparisonValue() const; + [[nodiscard]] ComparisonValue getComparisonValue() const; void setComparisonValue(ComparisonValue value); - ComparisonType getComparisonType() const; + [[nodiscard]] ComparisonType getComparisonType() const; void setComparisonType(ComparisonType comparison); - std::set getRequiredPaths() const override; + [[nodiscard]] std::set getRequiredPaths() const override; - nlohmann::json toJson() const override; + [[nodiscard]] nlohmann::json toJson() const override; static std::shared_ptr FromJson(const nlohmann::json& json); private: @@ -106,12 +105,12 @@ class SIMPLNX_EXPORT ArrayThresholdSet : public IArrayThreshold ArrayThresholdSet& operator=(const ArrayThresholdSet& other); ArrayThresholdSet& operator=(ArrayThresholdSet&& other) noexcept; - CollectionType getArrayThresholds() const; + [[nodiscard]] CollectionType getArrayThresholds() const; void setArrayThresholds(const CollectionType& thresholds); - std::set getRequiredPaths() const override; + [[nodiscard]] std::set getRequiredPaths() const override; - nlohmann::json toJson() const override; + [[nodiscard]] nlohmann::json toJson() const override; static std::shared_ptr FromJson(const nlohmann::json& json); private: diff --git a/src/simplnx/Utilities/DataArrayUtilities.cpp b/src/simplnx/Utilities/DataArrayUtilities.cpp index 3a81501265..ca5ca0c57d 100644 --- a/src/simplnx/Utilities/DataArrayUtilities.cpp +++ b/src/simplnx/Utilities/DataArrayUtilities.cpp @@ -354,6 +354,20 @@ void transferElementData(DataStructure& m_DataStructure, AttributeMatrix& destCe } taskRunner.wait(); // This will spill over if the number of DataArrays to process does not divide evenly by the number of threads. } -} // namespace TransferGeometryElementData +void CreateDataArrayActions(const DataStructure& dataStructure, const AttributeMatrix* sourceAttrMatPtr, const MultiArraySelectionParameter::ValueType& selectedArrayPaths, + const DataPath& reducedGeometryPathAttrMatPath, Result& resultOutputActions) +{ + // Now loop over each array in selectedEdgeArrays and create the corresponding arrays + // in the destination geometry's attribute matrix + for(const auto& dataPath : selectedArrayPaths) + { + const auto& srcArray = dataStructure.getDataRefAs(dataPath); + DataType dataType = srcArray.getDataType(); + IDataStore::ShapeType componentShape = srcArray.getIDataStoreRef().getComponentShape(); + DataPath dataArrayPath = reducedGeometryPathAttrMatPath.createChildPath(srcArray.getName()); + resultOutputActions.value().appendAction(std::make_unique(dataType, sourceAttrMatPtr->getShape(), std::move(componentShape), dataArrayPath)); + } +} +} // namespace TransferGeometryElementData } // namespace nx::core diff --git a/src/simplnx/Utilities/DataArrayUtilities.hpp b/src/simplnx/Utilities/DataArrayUtilities.hpp index fb6ea0d5ff..ce78ab3e6b 100644 --- a/src/simplnx/Utilities/DataArrayUtilities.hpp +++ b/src/simplnx/Utilities/DataArrayUtilities.hpp @@ -787,7 +787,7 @@ Result<> ResizeDataArray(DataStructure& dataStructure, const DataPath& arrayPath arrayPath.toString(), newShape, surfaceFeaturesParent->getShape())); } - // the array's parent is not in an Attribute Matrix so we can safely reshape to the new tuple shape + // the array's parent is not in an Attribute Matrix, so we can safely reshape to the new tuple shape dataArrayPtr->template getIDataStoreRefAs>().resizeTuples(newShape); return {}; } @@ -1106,7 +1106,7 @@ class AppendArray { using NeighborListType = NeighborList; auto* destArrayPtr = dynamic_cast(m_DestCellArray); - // Make sure the destination array is allocated AND each tuple list is initialized so we can use the [] operator to copy over the data + // Make sure the destination array is allocated AND each tuple list is initialized, so we can use the [] operator to copy over the data if(destArrayPtr->getValues().empty() || destArrayPtr->getList(0) == nullptr) { destArrayPtr->addEntry(destArrayPtr->getNumberOfTuples() - 1, 0); @@ -1160,7 +1160,7 @@ class CombineArrays { using NeighborListT = NeighborList; auto* destArray = dynamic_cast(m_DestCellArray); - // Make sure the destination array is allocated AND each tuple list is initialized so we can use the [] operator to copy over the data + // Make sure the destination array is allocated AND each tuple list is initialized, so we can use the [] operator to copy over the data if(destArray->getValues().empty() || destArray->getList(0) == nullptr) { destArray->addEntry(destArray->getNumberOfTuples() - 1, 0); @@ -1223,7 +1223,7 @@ class CopyUsingIndexList { using NeighborListT = NeighborList; auto* destArray = dynamic_cast(m_DestCellArray); - // Make sure the destination array is allocated AND each tuple list is initialized so we can use the [] operator to copy over the data + // Make sure the destination array is allocated AND each tuple list is initialized, so we can use the [] operator to copy over the data destArray->setList(i, typename NeighborListT::SharedVectorType(new typename NeighborListT::VectorType)); if(oldIndexI >= 0) { @@ -1362,7 +1362,7 @@ class MapRectGridDataToImageData { using NeighborListT = NeighborList; auto* destArrayPtr = dynamic_cast(m_DestCellArray); - // Make sure the destination array is allocated AND each tuple list is initialized so we can use the [] operator to copy over the data + // Make sure the destination array is allocated AND each tuple list is initialized, so we can use the [] operator to copy over the data destArrayPtr->setList(imageIndex, typename NeighborListT::SharedVectorType(new typename NeighborListT::VectorType)); if(rectGridIndex >= 0) { @@ -1557,7 +1557,6 @@ void RunParallelMapRectToImage(IArray& destArray, ParallelRunnerT&& runner, Args namespace TransferGeometryElementData { - /** * @brief * @tparam T @@ -1619,21 +1618,7 @@ class CopyCellDataArray SIMPLNX_EXPORT void transferElementData(DataStructure& m_DataStructure, AttributeMatrix& destCellDataAM, const std::vector& sourceDataPaths, const std::vector& newEdgesIndexList, const std::atomic_bool& m_ShouldCancel, const IFilter::MessageHandler& m_MessageHandler); -template -void createDataArrayActions(const DataStructure& dataStructure, const AttributeMatrix* sourceAttrMatPtr, const MultiArraySelectionParameter::ValueType& selectedArrayPaths, - const DataPath& reducedGeometryPathAttrMatPath, Result& resultOutputActions) -{ - // Now loop over each array in selectedEdgeArrays and create the corresponding arrays - // in the destination geometry's attribute matrix - for(const auto& dataPath : selectedArrayPaths) - { - const auto& srcArray = dataStructure.getDataRefAs(dataPath); - DataType dataType = srcArray.getDataType(); - IDataStore::ShapeType componentShape = srcArray.getIDataStoreRef().getComponentShape(); - DataPath dataArrayPath = reducedGeometryPathAttrMatPath.createChildPath(srcArray.getName()); - resultOutputActions.value().appendAction(std::make_unique(dataType, sourceAttrMatPtr->getShape(), std::move(componentShape), dataArrayPath)); - } -} - +SIMPLNX_EXPORT void CreateDataArrayActions(const DataStructure& dataStructure, const AttributeMatrix* sourceAttrMatPtr, const MultiArraySelectionParameter::ValueType& selectedArrayPaths, + const DataPath& reducedGeometryPathAttrMatPath, Result& resultOutputActions); } // namespace TransferGeometryElementData } // namespace nx::core diff --git a/src/simplnx/Utilities/FilePathGenerator.cpp b/src/simplnx/Utilities/FilePathGenerator.cpp index d65abdbc3e..e6b1003f3c 100644 --- a/src/simplnx/Utilities/FilePathGenerator.cpp +++ b/src/simplnx/Utilities/FilePathGenerator.cpp @@ -6,9 +6,7 @@ namespace fs = std::filesystem; -namespace nx::core -{ -namespace FilePathGenerator +namespace nx::core::FilePathGenerator { // ----------------------------------------------------------------------------- std::pair, bool> GenerateAndValidateFileList(int32 start, int32 end, int32 increment, Ordering order, std::string_view inputPath, std::string_view filePrefix, @@ -62,5 +60,4 @@ std::vector GenerateFileList(int32 start, int32 end, int32 incremen return fileList; } -} // namespace FilePathGenerator } // namespace nx::core diff --git a/src/simplnx/Utilities/ImageRotationUtilities.cpp b/src/simplnx/Utilities/ImageRotationUtilities.cpp index fd82f236a8..2a5049aef6 100644 --- a/src/simplnx/Utilities/ImageRotationUtilities.cpp +++ b/src/simplnx/Utilities/ImageRotationUtilities.cpp @@ -53,7 +53,7 @@ float DetermineSpacing(const FloatVec3& spacing, const Eigen::Vector3f& axisNew) const std::array axes = {xAngle, yAngle, zAngle}; - const std::array::const_iterator maxElementIterPtr = std::max_element(axes.cbegin(), axes.cend()); + const auto maxElementIterPtr = std::max_element(axes.cbegin(), axes.cend()); const size_t index = std::distance(axes.cbegin(), maxElementIterPtr); diff --git a/src/simplnx/Utilities/OStreamUtilities.cpp b/src/simplnx/Utilities/OStreamUtilities.cpp index f3929f823c..1fef391315 100644 --- a/src/simplnx/Utilities/OStreamUtilities.cpp +++ b/src/simplnx/Utilities/OStreamUtilities.cpp @@ -128,7 +128,7 @@ struct PrintNeighborList /** * @brief implicit writing of **DataArray**'s elements to outputStrm - * @tparam ScalarType The primitive type attacthed to **DataArray** + * @tparam ScalarType The primitive type attached to **DataArray** * @param outputStrm the ostream to write to * @param inputDataArray The **DataArray** that will have its values translated into strings * @param mesgHandler The message handler to dump progress updates to @@ -142,22 +142,22 @@ struct PrintDataArray Result<> operator()(std::ostream& outputStrm, IDataArray* inputDataArray, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, const std::string& delimiter = ",", int32 componentsPerLine = 0) { - auto& dataArray = *dynamic_cast*>(inputDataArray); + auto& dataStore = inputDataArray->getIDataStoreRefAs>(); auto start = std::chrono::steady_clock::now(); - auto numTuples = dataArray.getNumberOfTuples(); + auto numTuples = dataStore.getNumberOfTuples(); auto maxLine = static_cast(componentsPerLine); if(componentsPerLine == 0) { - maxLine = static_cast(dataArray.getNumberOfComponents()); + maxLine = static_cast(dataStore.getNumberOfComponents()); } - usize numComps = dataArray.getNumberOfComponents(); + usize numComps = dataStore.getNumberOfComponents(); for(size_t tuple = 0; tuple < numTuples; tuple++) { auto now = std::chrono::steady_clock::now(); if(std::chrono::duration_cast(now - start).count() > 1000) { - auto string = fmt::format("Processing {}: {}% completed", dataArray.getName(), static_cast(100 * static_cast(tuple) / static_cast(numTuples))); + auto string = fmt::format("Processing {}: {}% completed", inputDataArray->getName(), static_cast(100 * static_cast(tuple) / static_cast(numTuples))); mesgHandler(IFilter::Message::Type::Info, string); start = now; if(shouldCancel) @@ -169,15 +169,15 @@ struct PrintDataArray { if constexpr(std::is_same_v || std::is_same_v) { - outputStrm << static_cast(dataArray[tuple * numComps + index]); + outputStrm << static_cast(dataStore[tuple * numComps + index]); } else if constexpr(std::is_same_v || std::is_same_v) { - outputStrm << fmt::format("{}", dataArray[tuple * numComps + index]); + outputStrm << fmt::format("{}", dataStore[tuple * numComps + index]); } else { - outputStrm << dataArray[tuple * numComps + index]; + outputStrm << dataStore[tuple * numComps + index]; } if(index != maxLine - 1) { @@ -276,10 +276,11 @@ class TupleWriter : public ITupleWriter public: TupleWriter(const IDataArray& iDataArray, const std::string& delimiter) - : m_DataArray(dynamic_cast&>(iDataArray)) + : m_DataStore(iDataArray.getIDataStoreRefAs>()) + , m_Name(iDataArray.getName()) , m_Delimiter(delimiter) { - m_NumComps = m_DataArray.getNumberOfComponents(); + m_NumComps = m_DataStore.getNumberOfComponents(); } ~TupleWriter() override = default; @@ -289,19 +290,19 @@ class TupleWriter : public ITupleWriter { if constexpr(std::is_same_v || std::is_same_v) { - outputStrm << static_cast(m_DataArray[tupleIndex * m_NumComps + comp]); + outputStrm << static_cast(m_DataStore[tupleIndex * m_NumComps + comp]); } else if constexpr(std::is_same_v) { - outputStrm << std::setprecision(8) << std::noshowpoint << m_DataArray[tupleIndex * m_NumComps + comp]; + outputStrm << std::setprecision(8) << std::noshowpoint << m_DataStore[tupleIndex * m_NumComps + comp]; } else if constexpr(std::is_same_v) { - outputStrm << std::setprecision(16) << std::noshowpoint << m_DataArray[tupleIndex * m_NumComps + comp]; + outputStrm << std::setprecision(16) << std::noshowpoint << m_DataStore[tupleIndex * m_NumComps + comp]; } else { - outputStrm << m_DataArray[tupleIndex * m_NumComps + comp]; + outputStrm << m_DataStore[tupleIndex * m_NumComps + comp]; } if(comp < m_NumComps - 1) { @@ -315,13 +316,13 @@ class TupleWriter : public ITupleWriter // If there is only 1 component then write the name of the array and return if(m_NumComps == 1) { - outputStrm << m_DataArray.getName(); + outputStrm << m_Name; return; } for(size_t index = 0; index < m_NumComps; index++) { - outputStrm << m_DataArray.getName() << "_" << index; + outputStrm << m_Name << "_" << index; if(index < m_NumComps - 1) { @@ -331,7 +332,8 @@ class TupleWriter : public ITupleWriter } private: - const DataArrayType& m_DataArray; + const std::string m_Name; + const AbstractDataStore& m_DataStore; const std::string& m_Delimiter = ","; usize m_NumComps = 1; }; @@ -347,9 +349,7 @@ struct AddTupleWriter }; } // namespace -namespace nx::core -{ -namespace OStreamUtilities +namespace nx::core::OStreamUtilities { /** * @brief turns the enum in this API to respective character as a string @@ -613,5 +613,4 @@ void PrintDataSetsToSingleFile(std::ostream& outputStrm, const std::vector>& faceIds, const std::vector& faceBBs, - const std::vector& points, Int32AbstractDataStore& polyIds, const std::atomic_bool& shouldCancel) - : m_Filter(filter) - , m_Faces(faces) + SampleSurfaceMeshImpl(const TriangleGeom& faces, const std::vector>& faceIds, const std::vector& faceBBs, const std::vector& points, + Int32AbstractDataStore& polyIds, const std::atomic_bool& shouldCancel) + : m_Faces(faces) , m_FaceIds(faceIds) , m_FaceBBs(faceBBs) , m_Points(points) @@ -74,7 +73,6 @@ class SampleSurfaceMeshImpl } private: - SampleSurfaceMesh* m_Filter = nullptr; const TriangleGeom& m_Faces; const std::vector>& m_FaceIds; const std::vector& m_FaceBBs; @@ -289,7 +287,7 @@ Result<> SampleSurfaceMesh::execute(SampleSurfaceMeshInputValues& inputValues) { ParallelDataAlgorithm dataAlg; dataAlg.setRange(0, numFeatures); - dataAlg.execute(SampleSurfaceMeshImpl(this, triangleGeom, faceLists, faceBBs, points, polyIds, m_ShouldCancel)); + dataAlg.execute(SampleSurfaceMeshImpl(triangleGeom, faceLists, faceBBs, points, polyIds, m_ShouldCancel)); } else {