diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AddBadDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AddBadDataFilter.cpp index 99a292884f..9f337e00e1 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AddBadDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AddBadDataFilter.cpp @@ -5,7 +5,6 @@ #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/DataStructure/Geometry/ImageGeom.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" -#include "simplnx/Filter/Actions/EmptyAction.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AddBadData.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AddBadData.cpp index 000a522679..0c183f01ab 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AddBadData.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AddBadData.cpp @@ -5,7 +5,6 @@ #include "simplnx/Utilities/DataGroupUtilities.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" -#include #include using namespace nx::core; @@ -17,7 +16,7 @@ struct InitializeTupleToZeroFunctor template void operator()(DataStructure& dataStructure, const DataPath& arrayPath, usize index) { - dataStructure.getDataRefAs>(arrayPath).initializeTuple(index, 0); + dataStructure.getDataAsUnsafe>(arrayPath)->initializeTuple(index, 0); } }; } // namespace @@ -43,19 +42,17 @@ const std::atomic_bool& AddBadData::getCancel() // ----------------------------------------------------------------------------- Result<> AddBadData::operator()() { - std::random_device randomDevice; // Will be used to obtain a seed for the random number engine - std::mt19937 generator(randomDevice()); // Standard mersenne_twister_engine seeded with rd() - generator.seed(m_InputValues->SeedValue); + std::mt19937 generator(m_InputValues->SeedValue); // Standard mersenne_twister_engine seeded std::uniform_real_distribution distribution(0.0F, 1.0F); - auto& imgGeom = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); - auto& GBEuclideanDistances = m_DataStructure.getDataRefAs(m_InputValues->GBEuclideanDistancesArrayPath); + const auto& imgGeom = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); + const auto& GBEuclideanDistances = m_DataStructure.getDataRefAs(m_InputValues->GBEuclideanDistancesArrayPath).getDataStoreRef(); auto childArrayPaths = GetAllChildArrayDataPaths(m_DataStructure, imgGeom.getCellDataPath()); auto voxelArrayPaths = childArrayPaths.has_value() ? childArrayPaths.value() : std::vector{}; float32 random = 0.0f; - size_t totalPoints = GBEuclideanDistances.getSize(); + const size_t totalPoints = GBEuclideanDistances.getSize(); for(size_t i = 0; i < totalPoints; ++i) { if(m_InputValues->BoundaryNoise && GBEuclideanDistances[i] < 1) @@ -65,7 +62,7 @@ Result<> AddBadData::operator()() { for(const auto& voxelArrayPath : voxelArrayPaths) { - ExecuteDataFunction(InitializeTupleToZeroFunctor{}, m_DataStructure.getDataAs(voxelArrayPath)->getDataType(), m_DataStructure, voxelArrayPath, i); + ExecuteDataFunction(InitializeTupleToZeroFunctor{}, m_DataStructure.getDataAsUnsafe(voxelArrayPath)->getDataType(), m_DataStructure, voxelArrayPath, i); } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AlignSectionsList.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AlignSectionsList.cpp index 815a143114..4640e51adf 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AlignSectionsList.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/AlignSectionsList.cpp @@ -53,10 +53,10 @@ std::vector AlignSectionsList::getSelectedDataPaths() const // ----------------------------------------------------------------------------- Result<> AlignSectionsList::findShifts(std::vector& xShifts, std::vector& yShifts) { - auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); + const auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); SizeVec3 udims = imageGeom.getDimensions(); - int64 zDim = static_cast(udims[2]); + auto zDim = static_cast(udims[2]); Result<> results = {}; if(m_InputValues->DREAM3DAlignmentFile) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ApplyTransformationToGeometry.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ApplyTransformationToGeometry.cpp index 61b235f6da..070f2c6c8c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ApplyTransformationToGeometry.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ApplyTransformationToGeometry.cpp @@ -129,7 +129,7 @@ Result<> ApplyTransformationToGeometry::applyImageGeometryTransformation() // ----------------------------------------------------------------------------- Result<> ApplyTransformationToGeometry::applyNodeGeometryTransformation() { - INodeGeometry0D& nodeGeometry0D = m_DataStructure.getDataRefAs(m_InputValues->SelectedGeometryPath); + auto& nodeGeometry0D = m_DataStructure.getDataRefAs(m_InputValues->SelectedGeometryPath); IGeometry::SharedVertexList& vertexList = nodeGeometry0D.getVerticesRef(); @@ -159,7 +159,7 @@ Result<> ApplyTransformationToGeometry::operator()() } case detail::k_PrecomputedTransformationMatrixIdx: // Transformation matrix from array { - const Float32Array& precomputed = m_DataStructure.getDataRefAs(m_InputValues->ComputedTransformationMatrix); + const auto& precomputed = m_DataStructure.getDataAsUnsafe(m_InputValues->ComputedTransformationMatrix)->getDataStoreRef(); m_TransformationMatrix = ImageRotationUtilities::CopyPrecomputedToTransformationMatrix(precomputed); break; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ArrayCalculator.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ArrayCalculator.cpp index 8e98f28b70..a0d4f26642 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ArrayCalculator.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ArrayCalculator.cpp @@ -44,7 +44,7 @@ struct CreateCalculatorArrayFunctor template CalculatorItem::Pointer operator()(DataStructure& dataStructure, bool allocate, const IDataArray* iDataArrayPtr) { - const DataArray* inputDataArray = dynamic_cast*>(iDataArrayPtr); + const auto* inputDataArray = dynamic_cast*>(iDataArrayPtr); CalculatorItem::Pointer itemPtr = CalculatorArray::New(dataStructure, inputDataArray, ICalculatorArray::Array, allocate); return itemPtr; } @@ -55,15 +55,22 @@ struct CopyArrayFunctor template void operator()(DataStructure& dataStructure, const DataPath& calculatedArrayPath, const Float64Array* inputArray) { + const auto& inputDataStore = inputArray->getDataStoreRef(); if(nullptr != inputArray) { - DataArray& convertedArray = dataStructure.getDataRefAs>(calculatedArrayPath); + auto& convertedDataStore = dataStructure.getDataAsUnsafe>(calculatedArrayPath)->getDataStoreRef(); - int count = inputArray->getSize(); - for(int i = 0; i < count; i++) + const usize count = inputDataStore.getSize(); + for(usize i = 0; i < count; i++) { - double val = (*inputArray)[i]; - convertedArray[i] = val; + if constexpr(std::is_same_v) + { + convertedDataStore[i] = inputDataStore[i]; + } + else + { + convertedDataStore[i] = static_cast(inputDataStore[i]); + } } } } @@ -74,11 +81,17 @@ struct InitializeArrayFunctor template void operator()(DataStructure& dataStructure, const DataPath& calculatedArrayPath, const Float64Array* inputArray) { - DataArray& convertedArray = dataStructure.getDataRefAs>(calculatedArrayPath); + auto& convertedDataStore = dataStructure.getDataAsUnsafe>(calculatedArrayPath)->getDataStoreRef(); if(nullptr != inputArray && inputArray->getSize() == 1) { - const T& initializeValue = inputArray->at(0); - convertedArray.fill(initializeValue); + if constexpr(std::is_same_v) + { + convertedDataStore.fill(inputArray->at(0)); + } + else + { + convertedDataStore.fill(static_cast(inputArray->at(0))); + } } } }; @@ -318,14 +331,13 @@ std::vector ArrayCalculatorParser::getRegularExpressionMatches() std::vector itemList; // Match all array names that start with two alphabetical characters and have spaces. Match all numbers, decimal or integer. // Match one letter array names. Match all special character operators. - std::regex regExp("(\"((\\[)?\\d+(\\.\\d+)?(\\])?|(\\[)?\\.\\d+(\\])?|\\w{1,1}((\\w|\\s|\\d)*(\\w|\\d){1,1})?|\\S)\")|(((\\[)?\\d+(\\.\\d+)?(\\])?|(\\[)?\\.\\d+(\\])?|\\w{1,1}((\\w|\\s|\\d)" - "*(\\w|\\d){1,1})?|\\S))"); + std::regex regExp(R"lit(("((\[)?\d+(\.\d+)?(\])?|(\[)?\.\d+(\])?|\w{1,1}((\w|\s|\d)*(\w|\d){1,1})?|\S)")|(((\[)?\d+(\.\d+)?(\])?|(\[)?\.\d+(\])?|\w{1,1}((\w|\s|\d)*(\w|\d){1,1})?|\S)))lit"); auto regExpMatchBegin = std::sregex_iterator(m_InfixEquation.begin(), m_InfixEquation.end(), regExp); auto regExpMatchEnd = std::sregex_iterator(); for(std::sregex_iterator i = regExpMatchBegin; i != regExpMatchEnd; ++i) { - std::smatch match = *i; + const std::smatch& match = *i; itemList.push_back(match.str()); } @@ -436,7 +448,7 @@ Result<> ArrayCalculatorParser::parseCommaOperator(std::string token, std::vecto // For example, if we have root( 4*4, 2*3 ), then we need it to be root( (4*4), (2*3) ) parsedInfix.push_back(RightParenthesisItem::New()); - std::vector::iterator iter = parsedInfix.end(); + auto iter = parsedInfix.end(); iter--; while(iter != parsedInfix.begin()) { @@ -473,7 +485,7 @@ Result<> ArrayCalculatorParser::parseArray(std::string token, std::vector(tokenArrayPath); + const auto* dataArray = m_DataStructure.getDataAs(tokenArrayPath); if(firstArray_NumTuples < 0 && firstArray_Name.empty()) { firstArray_NumTuples = dataArray->getNumberOfTuples(); @@ -491,7 +503,7 @@ Result<> ArrayCalculatorParser::parseArray(std::string token, std::vector ArrayCalculatorParser::checkForAmbiguousArrayName(std::string strItem, std::string warningMsg) +Result<> ArrayCalculatorParser::checkForAmbiguousArrayName(const std::string& strItem, std::string warningMsg) { if(m_IsPreflight && ContainsDataArrayName(m_DataStructure, m_SelectedGroupPath, strItem)) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ArrayCalculator.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ArrayCalculator.hpp index 6b1a9c68c8..32f46372bf 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ArrayCalculator.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ArrayCalculator.hpp @@ -42,7 +42,7 @@ class SIMPLNXCORE_EXPORT ArrayCalculatorParser Result<> parseIndexOperator(std::string token, std::vector& parsedInfix); Result<> parseCommaOperator(std::string token, std::vector& parsedInfix); Result<> parseArray(std::string token, std::vector& parsedInfix); - Result<> checkForAmbiguousArrayName(std::string strItem, std::string warningMsg); + Result<> checkForAmbiguousArrayName(const std::string& strItem, std::string warningMsg); private: const DataStructure& m_DataStructure; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CalculateTriangleGroupCurvatures.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CalculateTriangleGroupCurvatures.cpp index 8938c9c0ef..8da6dc62bb 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CalculateTriangleGroupCurvatures.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CalculateTriangleGroupCurvatures.cpp @@ -45,6 +45,74 @@ namespace nx::core { +namespace +{ +/** + * @brief extractPatchData Extracts out the needed data values from the global arrays + * @param triId The seed triangle Id + * @param triPatch The group of triangles being used + * @param data The data to extract from + * @return Shared pointer to the extracted data + */ +std::shared_ptr extractPatchData(int64_t triId, FindNRingNeighbors::UniqueFaceIds_t& triPatch, Float64AbstractDataStore& data) +{ + IDataStore::ShapeType cDims = {3ULL}; + + for(auto iter = triPatch.begin(); iter != triPatch.end();) + { + int64_t t = *iter; + + if(std::isnan(data[t * 3]) || std::isnan(data[t * 3 + 1]) || std::isnan(data[t * 3 + 2])) + { + iter = triPatch.erase(iter); + if(*iter == triId) + { + triId = *(triPatch.begin()); + } + } + else + { + ++iter; + } + } + + if(triPatch.empty()) + { + return nullptr; + } + + size_t totalTuples = triPatch.size(); + if(triPatch.count(triId) == 0) + { + totalTuples++; + } + + IDataStore::ShapeType tupleShape = {totalTuples}; + std::optional initValue = {}; + std::shared_ptr extractedData = std::make_shared(tupleShape, cDims, initValue); + // This little chunk makes sure the current seed triangles centroid and normal data appear + // first in the returned arrays which makes the next steps a tad easier. + int32_t i = 0; + extractedData->setComponent(i, 0, data[triId * 3]); + extractedData->setComponent(i, 1, data[triId * 3 + 1]); + extractedData->setComponent(i, 2, data[triId * 3 + 2]); + ++i; + triPatch.erase(triId); + + for(int64_t t : triPatch) + { + extractedData->setComponent(i, 0, data[t * 3]); + extractedData->setComponent(i, 1, data[t * 3 + 1]); + extractedData->setComponent(i, 2, data[t * 3 + 2]); + ++i; + } + triPatch.insert(triId); + + extractedData->resizeTuples({triPatch.size()}); // Resize the TriPatch DataArray + return extractedData; +} +} // namespace + // ----------------------------------------------------------------------------- CalculateTriangleGroupCurvatures::CalculateTriangleGroupCurvatures(FeatureFaceCurvature* filter, int64_t nring, std::vector triangleIds, bool useNormalsForCurveFitting, Float64Array* principleCurvature1, Float64Array* principleCurvature2, Float64Array* principleDirection1, @@ -53,7 +121,7 @@ CalculateTriangleGroupCurvatures::CalculateTriangleGroupCurvatures(FeatureFaceCu Float64Array* surfaceMeshTriangleCentroids, const IFilter::MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) : m_Filter(filter) , m_NRing(nring) -, m_TriangleIds(triangleIds) +, m_TriangleIds(std::move(triangleIds)) , m_UseNormalsForCurveFitting(useNormalsForCurveFitting) , m_PrincipleCurvature1(principleCurvature1) , m_PrincipleCurvature2(principleCurvature2) @@ -78,7 +146,6 @@ CalculateTriangleGroupCurvatures::~CalculateTriangleGroupCurvatures() = default; void subtractVector3d(Float64AbstractDataStore& data, double* v) { size_t count = data.getNumberOfTuples(); - // auto& ptr = data.getDataStoreRef(); for(size_t i = 0; i < count; ++i) { const usize offset = i * 3; @@ -91,7 +158,7 @@ void subtractVector3d(Float64AbstractDataStore& data, double* v) // ----------------------------------------------------------------------------- void CalculateTriangleGroupCurvatures::operator()() const { - if(m_TriangleIds.size() == 0) + if(m_TriangleIds.empty()) { return; } @@ -145,7 +212,7 @@ void CalculateTriangleGroupCurvatures::operator()() const throw std::runtime_error("NRingNeighbor returned an error."); } - UniqueFaceIds_t triPatch = nRingNeighborAlg.getNRingTriangles(); + FindNRingNeighbors::UniqueFaceIds_t triPatch = nRingNeighborAlg.getNRingTriangles(); if(triPatch.size() <= 1) { throw std::runtime_error("NRingNeighbor failed to find more than one triangles."); @@ -162,7 +229,6 @@ void CalculateTriangleGroupCurvatures::operator()() const // If something got removed, redo this part again. if(triPatch.size() != beforeSize) { - beforeSize = triPatch.size(); patchNormals = extractPatchData(triId, triPatch, m_SurfaceMeshFaceNormals->getDataStoreRef()); } @@ -184,7 +250,7 @@ void CalculateTriangleGroupCurvatures::operator()() const // Translate the patch to the 0,0,0 origin double sub[3] = {patchCentroids->getComponentValue(0, 0), patchCentroids->getComponentValue(0, 1), patchCentroids->getComponentValue(0, 2)}; - subtractVector3d(*patchCentroids.get(), sub); + subtractVector3d(*patchCentroids, sub); double np[3] = {patchNormals->getComponentValue(0, 0), patchNormals->getComponentValue(0, 1), patchNormals->getComponentValue(0, 2)}; @@ -221,7 +287,7 @@ void CalculateTriangleGroupCurvatures::operator()() const MatrixMath::Multiply3x3with3x1(rot, &patchNormals->data()[m * 3], out); ::memcpy(&patchNormals->data()[m * 3], out, 3 * sizeof(double)); - // We rotate the normals now but we dont use them yet. If we start using part 3 of Goldfeathers paper then we + // We rotate the normals now, but we don't use them yet. If we start using part 3 of Goldfeathers paper then we // will need the normals. } @@ -272,7 +338,7 @@ void CalculateTriangleGroupCurvatures::operator()() const typedef Eigen::Matrix Vector7d; Vector7d sln1 = A.colPivHouseholderQr().solve(b); // Now that we have the A, B, C, D, E, F & G constants we can solve the Eigen value/vector problem - // to get the principal curvatures and pricipal directions. + // to get the principal curvatures and principal directions. M << sln1(0), sln1(1), sln1(1), sln1(2); } @@ -330,64 +396,4 @@ void CalculateTriangleGroupCurvatures::operator()() const // Send some feedback m_Filter->sendThreadSafeProgressMessage(1); } - -// ----------------------------------------------------------------------------- -std::shared_ptr CalculateTriangleGroupCurvatures::extractPatchData(int64_t triId, UniqueFaceIds_t& triPatch, Float64AbstractDataStore& data) const -{ - IDataStore::ShapeType cDims = {3ULL}; - - for(auto iter = triPatch.begin(); iter != triPatch.end();) - { - int64_t t = *iter; - - if(std::isnan(data[t * 3]) || std::isnan(data[t * 3 + 1]) || std::isnan(data[t * 3 + 2])) - { - iter = triPatch.erase(iter); - if(*iter == triId) - { - triId = *(triPatch.begin()); - } - } - else - { - ++iter; - } - } - - if(triPatch.empty()) - { - return nullptr; - } - - size_t totalTuples = triPatch.size(); - if(triPatch.count(triId) == 0) - { - totalTuples++; - } - - IDataStore::ShapeType tupleShape = {totalTuples}; - std::optional initValue = {}; - std::shared_ptr extractedData = std::make_shared(tupleShape, cDims, initValue); - // This little chunk makes sure the current seed triangles centroid and normal data appear - // first in the returned arrays which makes the next steps a tad easier. - int32_t i = 0; - extractedData->setComponent(i, 0, data[triId * 3]); - extractedData->setComponent(i, 1, data[triId * 3 + 1]); - extractedData->setComponent(i, 2, data[triId * 3 + 2]); - ++i; - triPatch.erase(triId); - - for(UniqueFaceIds_t::iterator iter = triPatch.begin(); iter != triPatch.end(); ++iter) - { - int64_t t = *iter; - extractedData->setComponent(i, 0, data[t * 3]); - extractedData->setComponent(i, 1, data[t * 3 + 1]); - extractedData->setComponent(i, 2, data[t * 3 + 2]); - ++i; - } - triPatch.insert(triId); - - extractedData->resizeTuples({triPatch.size()}); // Resize the TriPatch DataArray - return extractedData; -} } // namespace nx::core diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CalculateTriangleGroupCurvatures.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CalculateTriangleGroupCurvatures.hpp index 4ff73f0c34..1e8fd744f9 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CalculateTriangleGroupCurvatures.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CalculateTriangleGroupCurvatures.hpp @@ -65,16 +65,6 @@ class SIMPLNXCORE_EXPORT CalculateTriangleGroupCurvatures using UniqueFaceIds_t = std::set; -protected: - /** - * @brief extractPatchData Extracts out the needed data values from the global arrays - * @param triId The seed triangle Id - * @param triPatch The group of triangles being used - * @param data The data to extract from - * @return Shared pointer to the extracted data - */ - std::shared_ptr extractPatchData(int64_t triId, UniqueFaceIds_t& triPatch, Float64AbstractDataStore& data) const; - private: FeatureFaceCurvature* m_Filter = nullptr; int64_t m_NRing; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CombineAttributeArrays.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CombineAttributeArrays.cpp index 09f695290a..a550a044ac 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CombineAttributeArrays.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CombineAttributeArrays.cpp @@ -16,13 +16,15 @@ struct CombineAttributeArraysImpl { template - Result<> operator()(const CombineAttributeArraysInputValues* inputValues, std::vector& inputArraysVec, DataObject* outputArrayPtr) + Result<> operator()(bool normalize, std::vector& inputArraysVec, DataObject* outputArrayPtr) { using OutputArrayType = DataArray; using InputArrayType = DataArray; + using InputDataStoreType = AbstractDataStore; + using OutputDataStoreType = AbstractDataStore; - auto& outputArray = dynamic_cast(*outputArrayPtr); - int32_t numArrays = inputArraysVec.size(); + OutputDataStoreType& outputDataStore = dynamic_cast(outputArrayPtr)->getDataStoreRef(); + usize numArrays = inputArraysVec.size(); if(numArrays == 0) { return MakeWarningVoidResult(1, "No arrays were selected to combine."); @@ -30,41 +32,41 @@ struct CombineAttributeArraysImpl std::vector inputArrays; - for(size_t i = 0; i < numArrays; i++) + for(usize i = 0; i < numArrays; i++) { inputArrays.push_back(dynamic_cast(inputArraysVec[i])); } - size_t numTuples = inputArrays[0]->getNumberOfTuples(); - size_t stackedDims = outputArray.getNumberOfComponents(); - size_t arrayOffset = 0; - size_t numComps = 0; + usize numTuples = inputArrays[0]->getNumberOfTuples(); + usize stackedDims = outputDataStore.getNumberOfComponents(); + usize arrayOffset = 0; + usize numComps = 0; - if(inputValues->NormalizeData) + if(normalize) { std::vector maxValues(stackedDims, std::numeric_limits::lowest()); std::vector minValues(stackedDims, std::numeric_limits::max()); - for(size_t i = 0; i < numArrays; i++) + for(usize i = 0; i < numArrays; i++) { - InputArrayType& inputArray = *inputArrays[i]; // Get a reference var to the current input array + const InputDataStoreType& inputDataStore = inputArrays[i]->getDataStoreRef(); // Get a reference var to the current input array - numComps = inputArray.getNumberOfComponents(); + numComps = inputDataStore.getNumberOfComponents(); if(i > 0) { arrayOffset += inputArrays[i - 1]->getNumberOfComponents(); } - for(size_t j = 0; j < numTuples; j++) + for(usize j = 0; j < numTuples; j++) { - for(size_t k = 0; k < numComps; k++) + for(usize k = 0; k < numComps; k++) { - if(inputArray[numComps * j + k] > maxValues[arrayOffset + k]) + if(inputDataStore[numComps * j + k] > maxValues[arrayOffset + k]) { - maxValues[arrayOffset + k] = inputArray[numComps * j + k]; + maxValues[arrayOffset + k] = inputDataStore[numComps * j + k]; } - if(inputArray[numComps * j + k] < minValues[arrayOffset + k]) + if(inputDataStore[numComps * j + k] < minValues[arrayOffset + k]) { - minValues[arrayOffset + k] = inputArray[numComps * j + k]; + minValues[arrayOffset + k] = inputDataStore[numComps * j + k]; } } } @@ -72,26 +74,26 @@ struct CombineAttributeArraysImpl arrayOffset = 0; - for(size_t i = 0; i < numTuples; i++) + for(usize i = 0; i < numTuples; i++) { - for(size_t j = 0; j < numArrays; j++) + for(usize j = 0; j < numArrays; j++) { - InputArrayType& inputArray = *inputArrays[j]; // Get a reference var to the current input array + const InputDataStoreType& inputDataStore = inputArrays[j]->getDataStoreRef(); // Get a reference var to the current input array - numComps = inputArray.getNumberOfComponents(); + numComps = inputDataStore.getNumberOfComponents(); if(j > 0) { arrayOffset += inputArrays[j - 1]->getNumberOfComponents(); } - for(size_t k = 0; k < numComps; k++) + for(usize k = 0; k < numComps; k++) { if(maxValues[arrayOffset + k] == minValues[arrayOffset + k]) { - outputArray[stackedDims * i + (arrayOffset) + k] = static_cast(0); + outputDataStore[stackedDims * i + (arrayOffset) + k] = static_cast(0); } else { - outputArray[stackedDims * i + (arrayOffset) + k] = (inputArray[numComps * i + k] - minValues[arrayOffset + k]) / (maxValues[arrayOffset + k] - minValues[arrayOffset + k]); + outputDataStore[stackedDims * i + (arrayOffset) + k] = (inputDataStore[numComps * i + k] - minValues[arrayOffset + k]) / (maxValues[arrayOffset + k] - minValues[arrayOffset + k]); } } } @@ -100,18 +102,18 @@ struct CombineAttributeArraysImpl } else { - size_t outputNumComps = outputArray.getNumberOfComponents(); - size_t compsWritten = 0; + usize outputNumComps = outputDataStore.getNumberOfComponents(); + usize compsWritten = 0; for(const auto* inputArrayPtr : inputArrays) { - const InputArrayType& inputArray = *inputArrayPtr; // Get a reference var to the current input array - size_t numInputComps = inputArray.getNumberOfComponents(); + const InputDataStoreType& inputDataStore = inputArrayPtr->getDataStoreRef(); // Get a reference var to the current input array + usize numInputComps = inputDataStore.getNumberOfComponents(); - for(size_t tupleIndex = 0; tupleIndex < numTuples; tupleIndex++) + for(usize tupleIndex = 0; tupleIndex < numTuples; tupleIndex++) { - for(size_t compIndex = 0; compIndex < numInputComps; compIndex++) + for(usize compIndex = 0; compIndex < numInputComps; compIndex++) { - outputArray[tupleIndex * outputNumComps + compsWritten + compIndex] = inputArray[tupleIndex * numInputComps + compIndex]; + outputDataStore[tupleIndex * outputNumComps + compsWritten + compIndex] = inputDataStore[tupleIndex * numInputComps + compIndex]; } } compsWritten += numInputComps; @@ -157,5 +159,5 @@ Result<> CombineAttributeArrays::operator()() auto& outputArray = m_DataStructure.getDataRefAs(m_InputValues->StackedDataArrayPath); - return ExecuteDataFunction(CombineAttributeArraysImpl{}, outputArray.getDataType(), m_InputValues, inputArrays, m_DataStructure.getData(m_InputValues->StackedDataArrayPath)); + return ExecuteDataFunction(CombineAttributeArraysImpl{}, outputArray.getDataType(), m_InputValues->NormalizeData, inputArrays, m_DataStructure.getData(m_InputValues->StackedDataArrayPath)); } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CombineStlFiles.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CombineStlFiles.cpp index 9b38f1e6b1..f06ee885c8 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CombineStlFiles.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CombineStlFiles.cpp @@ -21,12 +21,12 @@ class CombineStlImpl public: CombineStlImpl(UInt64Array& destTriArray, Float32Array& destVerticesArray, Float64Array& destFaceNormalsArray, const UInt64Array& inputTriArray, const Float32Array& inputVerticesArray, const Float64Array& inputFaceNormalsArray, usize triTupleOffset, usize vertexTupleOffset, usize faceNormalsTupleOffset) - : m_DestTriangles(destTriArray) - , m_DestVertices(destVerticesArray) - , m_DestFaceNormals(destFaceNormalsArray) - , m_InputTriangles(inputTriArray) - , m_InputVertices(inputVerticesArray) - , m_InputFaceNormals(inputFaceNormalsArray) + : m_DestTriangles(destTriArray.getDataStoreRef()) + , m_DestVertices(destVerticesArray.getDataStoreRef()) + , m_DestFaceNormals(destFaceNormalsArray.getDataStoreRef()) + , m_InputTriangles(inputTriArray.getDataStoreRef()) + , m_InputVertices(inputVerticesArray.getDataStoreRef()) + , m_InputFaceNormals(inputFaceNormalsArray.getDataStoreRef()) , m_TriTupleOffset(triTupleOffset) , m_VerticesTupleOffset(vertexTupleOffset) , m_FaceNormalsTupleOffset(faceNormalsTupleOffset) @@ -47,12 +47,12 @@ class CombineStlImpl } private: - UInt64Array& m_DestTriangles; - Float32Array& m_DestVertices; - Float64Array& m_DestFaceNormals; - const UInt64Array& m_InputTriangles; - const Float32Array& m_InputVertices; - const Float64Array& m_InputFaceNormals; + AbstractDataStore& m_DestTriangles; + AbstractDataStore& m_DestVertices; + AbstractDataStore& m_DestFaceNormals; + const AbstractDataStore& m_InputTriangles; + const AbstractDataStore& m_InputVertices; + const AbstractDataStore& m_InputFaceNormals; usize m_TriTupleOffset; usize m_VerticesTupleOffset; usize m_FaceNormalsTupleOffset; @@ -184,31 +184,37 @@ Result<> CombineStlFiles::operator()() INodeGeometry2D::SharedFaceList& currentSharedFaceList = currentGeometry->getFacesRef(); usize currentGeomNumTriangles = currentGeometry->getNumberOfFaces(); usize currentGeomNumVertices = currentGeometry->getNumberOfVertices(); - for(usize triIndex = 0; triIndex < currentGeomNumTriangles; triIndex++) { - currentSharedFaceList[3 * triIndex + 0] += triCounter; - currentSharedFaceList[3 * triIndex + 1] += triCounter; - currentSharedFaceList[3 * triIndex + 2] += triCounter; + auto& currentSFLStore = currentSharedFaceList.getDataStoreRef(); + for(usize triIndex = 0; triIndex < currentGeomNumTriangles; triIndex++) + { + currentSFLStore[3 * triIndex + 0] += triCounter; + currentSFLStore[3 * triIndex + 1] += triCounter; + currentSFLStore[3 * triIndex + 2] += triCounter; + } + triCounter += currentGeomNumVertices; } - triCounter += currentGeomNumVertices; - INodeGeometry0D::SharedVertexList& curVertices = currentGeometry->getVerticesRef(); - auto& curFaceNormals = tempDataStructure.getDataRefAs(currentGeometry->getFaceAttributeMatrixDataPath().createChildPath("Face Normals")); if(m_InputValues->LabelFaces) { - auto& faceLabels = m_DataStructure.getDataRefAs(m_InputValues->FaceFileIndexArrayPath); - std::fill(faceLabels.begin() + faceLabelOffset, faceLabels.begin() + faceLabelOffset + currentGeomNumTriangles, fileIndex); + // Type checked in preflight; Unsafe acceptable; pointer for speed + auto* faceLabelsStore = m_DataStructure.getDataAsUnsafe(m_InputValues->FaceFileIndexArrayPath)->getDataStore(); + std::fill(faceLabelsStore->begin() + faceLabelOffset, faceLabelsStore->begin() + faceLabelOffset + currentGeomNumTriangles, fileIndex); } faceLabelOffset += currentGeomNumTriangles; if(m_InputValues->LabelVertices) { - auto& vertexLabels = m_DataStructure.getDataRefAs(m_InputValues->VertexFileIndexArrayPath); - std::fill(vertexLabels.begin() + vertexLabelOffset, vertexLabels.begin() + vertexLabelOffset + currentGeomNumVertices, fileIndex); + // Type checked in preflight; Unsafe acceptable; pointer for speed + auto* vertexLabels = m_DataStructure.getDataAsUnsafe(m_InputValues->VertexFileIndexArrayPath)->getDataStore(); + std::fill(vertexLabels->begin() + vertexLabelOffset, vertexLabels->begin() + vertexLabelOffset + currentGeomNumVertices, fileIndex); } vertexLabelOffset += currentGeomNumVertices; + INodeGeometry0D::SharedVertexList& curVertices = currentGeometry->getVerticesRef(); + auto& curFaceNormals = tempDataStructure.getDataRefAs(currentGeometry->getFaceAttributeMatrixDataPath().createChildPath("Face Normals")); + taskRunner.execute(CombineStlImpl{triangles, vertices, combinedFaceNormals, currentSharedFaceList, curVertices, curFaceNormals, triOffset, vertexOffset, faceNormalsOffset}); triOffset += currentGeomNumTriangles * 3; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayHistogram.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayHistogram.cpp index a57bf63a3f..94588211b3 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayHistogram.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayHistogram.cpp @@ -7,7 +7,6 @@ #include "simplnx/Utilities/ParallelAlgorithmUtilities.hpp" #include "simplnx/Utilities/ParallelTaskAlgorithm.hpp" -#include #include #include @@ -15,11 +14,11 @@ using namespace nx::core; namespace { -template +template class GenerateHistogramFromData { public: - GenerateHistogramFromData(ComputeArrayHistogram& filter, const int32 numBins, const IDataArray& inputArray, Float64Array& histogram, std::atomic& overflow, + GenerateHistogramFromData(ComputeArrayHistogram& filter, const int32 numBins, const IDataArray& inputArray, AbstractDataStore& histogram, std::atomic& overflow, std::tuple& range, size_t progressIncrement) : m_Filter(filter) , m_NumBins(numBins) @@ -34,8 +33,8 @@ class GenerateHistogramFromData void operator()() const { - const auto& inputArray = dynamic_cast&>(m_InputArray); - auto end = inputArray.getSize(); + const auto& inputStore = m_InputArray.template getIDataStoreRefAs>(); + auto end = inputStore.getSize(); // tuple visualization: Histogram = {(bin maximum, count), (bin maximum, count), ... } float64 min = 0.0; @@ -47,7 +46,7 @@ class GenerateHistogramFromData } else { - auto minMax = std::minmax_element(inputArray.begin(), inputArray.end()); + auto minMax = std::minmax_element(inputStore.begin(), inputStore.end()); min = (static_cast(*minMax.first) - 1); // ensure upper limit encapsulates max value max = (static_cast(*minMax.second) + 1); // ensure lower limit encapsulates min value } @@ -72,7 +71,7 @@ class GenerateHistogramFromData { return; } - const auto bin = std::floor((inputArray[i] - min) / increment); + const auto bin = std::floor((inputStore[i] - min) / increment); if((bin >= 0) && (bin < m_NumBins)) { m_Histogram[bin * 2 + 1]++; @@ -96,7 +95,7 @@ class GenerateHistogramFromData const int32 m_NumBins = 1; std::tuple& m_Range; const IDataArray& m_InputArray; - Float64Array& m_Histogram; + AbstractDataStore& m_Histogram; std::atomic& m_Overflow; size_t m_ProgressIncrement = 100; }; @@ -167,7 +166,7 @@ Result<> ComputeArrayHistogram::operator()() return {}; } const auto& inputData = m_DataStructure.getDataRefAs(selectedArrayPaths[i]); - auto& histogram = m_DataStructure.getDataRefAs>(m_InputValues->CreatedHistogramDataPaths.at(i)); + auto& histogram = m_DataStructure.getDataAs>(m_InputValues->CreatedHistogramDataPaths.at(i))->getDataStoreRef(); ExecuteParallelFunction(inputData.getDataType(), taskRunner, *this, numBins, inputData, histogram, overflow, range, progressIncrement); if(overflow > 0) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp index bd5f19b399..09875f9fea 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp @@ -12,6 +12,30 @@ using namespace nx::core; namespace { +// ----------------------------------------------------------------------------- +bool CheckArraysInMemory(const nx::core::IParallelAlgorithm::AlgorithmArrays& arrays) +{ + if(arrays.empty()) + { + return true; + } + + for(const auto* arrayPtr : arrays) + { + if(arrayPtr == nullptr) + { + continue; + } + + if(!arrayPtr->getIDataStoreRef().getDataFormat().empty()) + { + return false; + } + } + + return true; +} + template class ComputeArrayStatisticsByIndexImpl { @@ -664,7 +688,7 @@ void FindStatistics(const DataArray& source, const Int32Array* featureIds, co indexAlgArrays.push_back(mostPopulatedBinPtr); #ifdef SIMPLNX_ENABLE_MULTICORE - if(IParallelAlgorithm::CheckArraysInMemory(indexAlgArrays)) + if(CheckArraysInMemory(indexAlgArrays)) { const tbb::simple_partitioner simplePartitioner; const size_t grainSize = 500; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBiasedFeatures.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBiasedFeatures.cpp index b86e1e1a75..d206288af8 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBiasedFeatures.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBiasedFeatures.cpp @@ -46,14 +46,14 @@ Result<> ComputeBiasedFeatures::operator()() Result<> ComputeBiasedFeatures::findBoundingBoxFeatures() { const ImageGeom imageGeometry = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); - const auto& centroids = m_DataStructure.getDataRefAs(m_InputValues->CentroidsArrayPath); - Int32Array* phasesPtr = nullptr; + const auto& centroidsStore = m_DataStructure.getDataAs(m_InputValues->CentroidsArrayPath)->getDataStoreRef(); + AbstractDataStore* phasesStorePtr = nullptr; if(m_InputValues->CalcByPhase) { - phasesPtr = m_DataStructure.getDataAs(m_InputValues->PhasesArrayPath); + phasesStorePtr = m_DataStructure.getDataAs(m_InputValues->PhasesArrayPath)->getDataStore(); } - auto& biasedFeatures = m_DataStructure.getDataRefAs(m_InputValues->BiasedFeaturesArrayName); - biasedFeatures.fill(false); + auto& biasedFeaturesStore = m_DataStructure.getDataAsUnsafe(m_InputValues->BiasedFeaturesArrayName)->getDataStoreRef(); + biasedFeaturesStore.fill(false); std::unique_ptr surfaceFeatures = nullptr; try @@ -67,7 +67,7 @@ Result<> ComputeBiasedFeatures::findBoundingBoxFeatures() return MakeErrorResult(-54900, message); } - const usize size = centroids.getNumberOfTuples(); + const usize size = centroidsStore.getNumberOfTuples(); std::vector boundBox = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; std::vector coords = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; @@ -75,13 +75,7 @@ Result<> ComputeBiasedFeatures::findBoundingBoxFeatures() int32 numPhases = 1; if(m_InputValues->CalcByPhase) { - for(usize i = 1; i < size; i++) - { - if((*phasesPtr)[i] > numPhases) - { - numPhases = (*phasesPtr)[i]; - } - } + numPhases = *std::max_element(phasesStorePtr->begin(), phasesStorePtr->end()); } for(int32 iter = 1; iter <= numPhases; iter++) { @@ -103,18 +97,18 @@ Result<> ComputeBiasedFeatures::findBoundingBoxFeatures() for(usize i = 1; i < size; i++) { - if(surfaceFeatures->isTrue(i) && (!m_InputValues->CalcByPhase || (*phasesPtr)[i] == iter)) + if(surfaceFeatures->isTrue(i) && (!m_InputValues->CalcByPhase || (*phasesStorePtr)[i] == iter)) { int32 sideToMove = 0; int32 move = 1; float32 minDist = std::numeric_limits::max(); - coords[0] = centroids[3 * i]; - coords[1] = centroids[3 * i]; - coords[2] = centroids[3 * i + 1]; - coords[3] = centroids[3 * i + 1]; - coords[4] = centroids[3 * i + 2]; - coords[5] = centroids[3 * i + 2]; + coords[0] = centroidsStore[3 * i]; + coords[1] = centroidsStore[3 * i]; + coords[2] = centroidsStore[3 * i + 1]; + coords[3] = centroidsStore[3 * i + 1]; + coords[4] = centroidsStore[3 * i + 2]; + coords[5] = centroidsStore[3 * i + 2]; for(int32 j = 1; j < 7; j++) { float32 dist = std::numeric_limits::max(); @@ -154,31 +148,31 @@ Result<> ComputeBiasedFeatures::findBoundingBoxFeatures() } for(usize j = 1; j < size; j++) { - if(!m_InputValues->CalcByPhase || (*phasesPtr)[j] == iter) + if(!m_InputValues->CalcByPhase || (*phasesStorePtr)[j] == iter) { - if(centroids[3 * j] <= boundBox[0]) + if(centroidsStore[3 * j] <= boundBox[0]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } - if(centroids[3 * j] >= boundBox[1]) + if(centroidsStore[3 * j] >= boundBox[1]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } - if(centroids[3 * j + 1] <= boundBox[2]) + if(centroidsStore[3 * j + 1] <= boundBox[2]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } - if(centroids[3 * j + 1] >= boundBox[3]) + if(centroidsStore[3 * j + 1] >= boundBox[3]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } - if(centroids[3 * j + 2] <= boundBox[4]) + if(centroidsStore[3 * j + 2] <= boundBox[4]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } - if(centroids[3 * j + 2] >= boundBox[5]) + if(centroidsStore[3 * j + 2] >= boundBox[5]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } } } @@ -198,9 +192,9 @@ Result<> ComputeBiasedFeatures::findBoundingBoxFeatures2D() const ImageGeom imageGeometry = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); const SizeVec3 imageDimensions = imageGeometry.getDimensions(); const FloatVec3 imageOrigin = imageGeometry.getOrigin(); - const auto& centroids = m_DataStructure.getDataRefAs(m_InputValues->CentroidsArrayPath); - auto& biasedFeatures = m_DataStructure.getDataRefAs(m_InputValues->BiasedFeaturesArrayName); - biasedFeatures.fill(false); + const auto& centroidsStore = m_DataStructure.getDataAs(m_InputValues->CentroidsArrayPath)->getDataStoreRef(); + auto& biasedFeaturesStore = m_DataStructure.getDataAs(m_InputValues->BiasedFeaturesArrayName)->getDataStoreRef(); + biasedFeaturesStore.fill(false); std::unique_ptr maskCompare = nullptr; try @@ -214,7 +208,7 @@ Result<> ComputeBiasedFeatures::findBoundingBoxFeatures2D() return MakeErrorResult(-54900, message); } - const usize size = centroids.getNumberOfTuples(); + const usize size = centroidsStore.getNumberOfTuples(); std::vector coords = {0.0f, 0.0f, 0.0f, 0.0f}; @@ -267,10 +261,10 @@ Result<> ComputeBiasedFeatures::findBoundingBoxFeatures2D() int32 sideToMove = 0; int32 move = 1; float32 minDist = std::numeric_limits::max(); - coords[0] = centroids[3 * i + centroidShift0]; - coords[1] = centroids[3 * i + centroidShift0]; - coords[2] = centroids[3 * i + centroidShift1]; - coords[3] = centroids[3 * i + centroidShift1]; + coords[0] = centroidsStore[3 * i + centroidShift0]; + coords[1] = centroidsStore[3 * i + centroidShift0]; + coords[2] = centroidsStore[3 * i + centroidShift1]; + coords[3] = centroidsStore[3 * i + centroidShift1]; for(int32 j = 1; j < 5; j++) { float32 dist = std::numeric_limits::max(); @@ -315,21 +309,21 @@ Result<> ComputeBiasedFeatures::findBoundingBoxFeatures2D() } for(usize j = 1; j < size; j++) { - if(centroids[3 * j] <= boundBox[0]) + if(centroidsStore[3 * j] <= boundBox[0]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } - if(centroids[3 * j] >= boundBox[1]) + if(centroidsStore[3 * j] >= boundBox[1]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } - if(centroids[3 * j + 1] <= boundBox[2]) + if(centroidsStore[3 * j + 1] <= boundBox[2]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } - if(centroids[3 * j + 1] >= boundBox[3]) + if(centroidsStore[3 * j + 1] >= boundBox[3]) { - biasedFeatures[j] = true; + biasedFeaturesStore[j] = true; } if(getCancel()) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBoundaryCells.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBoundaryCells.cpp index 9de399ebeb..769289bb4e 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBoundaryCells.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBoundaryCells.cpp @@ -32,8 +32,8 @@ Result<> ComputeBoundaryCells::operator()() const auto yPoints = static_cast(imageDimensions[1]); const auto zPoints = static_cast(imageDimensions[2]); - auto featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); - auto boundaryCells = m_DataStructure.getDataRefAs(m_InputValues->BoundaryCellsArrayName); + auto& featureIdsStore = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); + auto& boundaryCellsStore = m_DataStructure.getDataAs(m_InputValues->BoundaryCellsArrayName)->getDataStoreRef(); const int64 neighPoints[6] = {(-1 * (xPoints * yPoints)), (-1 * (xPoints)), -1, 1, xPoints, (xPoints * yPoints)}; @@ -57,7 +57,7 @@ Result<> ComputeBoundaryCells::operator()() for(int64 k = 0; k < xPoints; k++) { onSurf = 0; - feature = featureIds[zStride + yStride + k]; + feature = featureIdsStore[zStride + yStride + k]; if(feature >= 0) { if(m_InputValues->IncludeVolumeBoundary) @@ -108,13 +108,13 @@ Result<> ComputeBoundaryCells::operator()() { continue; } - if(featureIds[neighbor] != feature && featureIds[neighbor] > ignoreFeatureZeroVal) + if(featureIdsStore[neighbor] != feature && featureIdsStore[neighbor] > ignoreFeatureZeroVal) { onSurf++; } } } - boundaryCells[zStride + yStride + k] = onSurf; + boundaryCellsStore[zStride + yStride + k] = onSurf; } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeEuclideanDistMap.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeEuclideanDistMap.cpp index 00e66e75ff..a5f81bca5e 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeEuclideanDistMap.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeEuclideanDistMap.cpp @@ -45,9 +45,9 @@ class ComputeDistanceMapImpl size_t neighpoint = 0; int64_t nearestneighbor; int64_t neighbors[6] = {0, 0, 0, 0, 0, 0}; - int64_t xpoints = static_cast(udims[0]); - int64_t ypoints = static_cast(udims[1]); - int64_t zpoints = static_cast(udims[2]); + auto xpoints = static_cast(udims[0]); + auto ypoints = static_cast(udims[1]); + auto zpoints = static_cast(udims[2]); FloatVec3 spacing = selectedImageGeom.getSpacing(); neighbors[0] = -xpoints * ypoints; @@ -63,18 +63,18 @@ class ComputeDistanceMapImpl std::vector voxEDist(totalPoints, 0.0); double* voxel_Distance = &(voxEDist.front()); - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues.FeatureIdsArrayPath); + const auto& featureIdsStore = m_DataStructure.getDataAs(m_InputValues.FeatureIdsArrayPath)->getDataStoreRef(); - auto* gbManhattanDistances = m_DataStructure.template getDataAs(m_InputValues.GBDistancesArrayName); - auto* tjManhattanDistances = m_DataStructure.template getDataAs(m_InputValues.TJDistancesArrayName); - auto* qpManhattanDistances = m_DataStructure.template getDataAs(m_InputValues.QPDistancesArrayName); + auto* gbManhattanDistancesStore = m_DataStructure.template getDataAs(m_InputValues.GBDistancesArrayName)->getDataStore(); + auto* tjManhattanDistancesStore = m_DataStructure.template getDataAs(m_InputValues.TJDistancesArrayName)->getDataStore(); + auto* qpManhattanDistancesStore = m_DataStructure.template getDataAs(m_InputValues.QPDistancesArrayName)->getDataStore(); - auto* nearestNeighbors = m_DataStructure.template getDataAs(m_InputValues.NearestNeighborsArrayName); + auto* nearestNeighborsStore = m_DataStructure.getDataAs(m_InputValues.NearestNeighborsArrayName)->getDataStore(); Distance = 0; for(size_t a = 0; a < totalPoints; ++a) { - if((*nearestNeighbors)[a * 3 + static_cast(m_MapType)] >= 0) + if((*nearestNeighborsStore)[a * 3 + static_cast(m_MapType)] >= 0) { voxel_NearestNeighbor[a] = static_cast(a); } // if voxel is boundary voxel, then want to use itself as nearest boundary voxel @@ -84,15 +84,15 @@ class ComputeDistanceMapImpl } if(m_MapType == ComputeEuclideanDistMap::MapType::FeatureBoundary) { - voxel_Distance[a] = static_cast((*gbManhattanDistances)[a]); + voxel_Distance[a] = static_cast((*gbManhattanDistancesStore)[a]); } else if(m_MapType == ComputeEuclideanDistMap::MapType::TripleJunction) { - voxel_Distance[a] = static_cast((*tjManhattanDistances)[a]); + voxel_Distance[a] = static_cast((*tjManhattanDistancesStore)[a]); } else if(m_MapType == ComputeEuclideanDistMap::MapType::QuadPoint) { - voxel_Distance[a] = static_cast((*qpManhattanDistances)[a]); + voxel_Distance[a] = static_cast((*qpManhattanDistancesStore)[a]); } } @@ -148,7 +148,7 @@ class ComputeDistanceMapImpl } i = zStride + yStride + x; - if(voxel_NearestNeighbor[i] == -1 && featureIds[i] > 0) + if(voxel_NearestNeighbor[i] == -1 && featureIdsStore[i] > 0) { count++; for(int32_t j = 0; j < 6; j++) @@ -168,7 +168,7 @@ class ComputeDistanceMapImpl } for(size_t j = 0; j < totalPoints; ++j) { - if(voxel_NearestNeighbor[j] != -1 && voxel_Distance[j] == -1.0 && featureIds[j] > 0) + if(voxel_NearestNeighbor[j] != -1 && voxel_Distance[j] == -1.0 && featureIdsStore[j] > 0) { changed++; voxel_Distance[j] = Distance; @@ -198,9 +198,9 @@ class ComputeDistanceMapImpl nearestneighbor = voxel_NearestNeighbor[zStride + yStride + p]; if(nearestneighbor >= 0) { - x2 = spacing[0] * double(nearestneighbor % xpoints); // find_xcoord(nearestneighbor); - y2 = spacing[1] * double(int64_t(nearestneighbor * oneOverxpoints) % ypoints); // find_ycoord(nearestneighbor); - z2 = spacing[2] * floor(nearestneighbor * oneOverzBlock); // find_zcoord(nearestneighbor); + x2 = spacing[0] * static_cast(nearestneighbor % xpoints); // find_xcoord(nearestneighbor); + y2 = spacing[1] * static_cast(static_cast(nearestneighbor * oneOverxpoints) % ypoints); // find_ycoord(nearestneighbor); + z2 = spacing[2] * floor(nearestneighbor * oneOverzBlock); // find_zcoord(nearestneighbor); dist = ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)) + ((z1 - z2) * (z1 - z2)); dist = sqrt(dist); voxel_Distance[zStride + yStride + p] = dist; @@ -211,18 +211,18 @@ class ComputeDistanceMapImpl } for(size_t a = 0; a < totalPoints; ++a) { - (*nearestNeighbors)[a * 3 + static_cast(m_MapType)] = voxel_NearestNeighbor[a]; + (*nearestNeighborsStore)[a * 3 + static_cast(m_MapType)] = voxel_NearestNeighbor[a]; if(m_MapType == ComputeEuclideanDistMap::MapType::FeatureBoundary) { - (*gbManhattanDistances)[a] = static_cast(voxel_Distance[a]); + (*gbManhattanDistancesStore)[a] = static_cast(voxel_Distance[a]); } else if(m_MapType == ComputeEuclideanDistMap::MapType::TripleJunction) { - (*tjManhattanDistances)[a] = static_cast(voxel_Distance[a]); + (*tjManhattanDistancesStore)[a] = static_cast(voxel_Distance[a]); } else if(m_MapType == ComputeEuclideanDistMap::MapType::QuadPoint) { - (*qpManhattanDistances)[a] = static_cast(voxel_Distance[a]); + (*qpManhattanDistancesStore)[a] = static_cast(voxel_Distance[a]); } } } @@ -248,25 +248,25 @@ void findDistanceMap(DataStructure& dataStructure, const ComputeEuclideanDistMap { using DataArrayType = DataArray; - const auto& featureIds = dataStructure.getDataRefAs(inputValues->FeatureIdsArrayPath); - size_t totalPoints = featureIds.getNumberOfTuples(); + const auto& featureIdsStore = dataStructure.getDataRefAs(inputValues->FeatureIdsArrayPath).getDataStoreRef(); + size_t totalPoints = featureIdsStore.getNumberOfTuples(); - auto* gbManhattanDistances = dataStructure.template getDataAs(inputValues->GBDistancesArrayName); - if(gbManhattanDistances != nullptr) + auto* gbManhattanDistancesStore = dataStructure.template getDataAs(inputValues->GBDistancesArrayName)->getDataStore(); + if(gbManhattanDistancesStore != nullptr) { - gbManhattanDistances->fill(static_cast(-1)); + gbManhattanDistancesStore->fill(static_cast(-1)); } - auto* tjManhattanDistances = dataStructure.template getDataAs(inputValues->TJDistancesArrayName); - if(tjManhattanDistances != nullptr) + auto* tjManhattanDistancesStore = dataStructure.template getDataAs(inputValues->TJDistancesArrayName)->getDataStore(); + if(tjManhattanDistancesStore != nullptr) { - tjManhattanDistances->fill(static_cast(-1)); + tjManhattanDistancesStore->fill(static_cast(-1)); } - auto* qpManhattanDistances = dataStructure.template getDataAs(inputValues->QPDistancesArrayName); - if(qpManhattanDistances != nullptr) + auto* qpManhattanDistancesStore = dataStructure.template getDataAs(inputValues->QPDistancesArrayName)->getDataStore(); + if(qpManhattanDistancesStore != nullptr) { - qpManhattanDistances->fill(static_cast(-1)); + qpManhattanDistancesStore->fill(static_cast(-1)); } auto* nearestNeighbors = dataStructure.template getDataAs(inputValues->NearestNeighborsArrayName); @@ -304,7 +304,7 @@ void findDistanceMap(DataStructure& dataStructure, const ComputeEuclideanDistMap for(size_t a = 0; a < totalPoints; ++a) { - feature = featureIds[a]; + feature = featureIdsStore[a]; if(feature > 0) { column = static_cast(a % xPoints); @@ -338,12 +338,12 @@ void findDistanceMap(DataStructure& dataStructure, const ComputeEuclideanDistMap { good = false; } - if(good && featureIds[neighbor] != feature && featureIds[neighbor] >= 0) + if(good && featureIdsStore[neighbor] != feature && featureIdsStore[neighbor] >= 0) { add = true; for(const auto& coordination_value : coordination) { - if(featureIds[neighbor] == coordination_value) + if(featureIdsStore[neighbor] == coordination_value) { add = false; break; @@ -351,7 +351,7 @@ void findDistanceMap(DataStructure& dataStructure, const ComputeEuclideanDistMap } if(add) { - coordination.push_back(featureIds[neighbor]); + coordination.push_back(featureIdsStore[neighbor]); } } } @@ -363,21 +363,21 @@ void findDistanceMap(DataStructure& dataStructure, const ComputeEuclideanDistMap } if(!coordination.empty() && inputValues->DoBoundaries) { - (*gbManhattanDistances)[a] = 0; + (*gbManhattanDistancesStore)[a] = 0; (*nearestNeighbors)[a * 3 + 0] = coordination[0]; (*nearestNeighbors)[a * 3 + 1] = -1; (*nearestNeighbors)[a * 3 + 2] = -1; } if(coordination.size() >= 2 && inputValues->DoTripleLines) { - (*tjManhattanDistances)[a] = 0; + (*tjManhattanDistancesStore)[a] = 0; (*nearestNeighbors)[a * 3 + 0] = coordination[0]; (*nearestNeighbors)[a * 3 + 1] = coordination[0]; (*nearestNeighbors)[a * 3 + 2] = -1; } if(coordination.size() > 2 && inputValues->DoQuadPoints) { - (*qpManhattanDistances)[a] = 0; + (*qpManhattanDistancesStore)[a] = 0; (*nearestNeighbors)[a * 3 + 0] = coordination[0]; (*nearestNeighbors)[a * 3 + 1] = coordination[0]; (*nearestNeighbors)[a * 3 + 2] = coordination[0]; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureCentroids.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureCentroids.cpp index 5312f86045..554ea7e194 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureCentroids.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureCentroids.cpp @@ -9,23 +9,20 @@ using namespace nx::core; namespace { - class ComputeFeatureCentroidsImpl1 { public: - ComputeFeatureCentroidsImpl1(ComputeFeatureCentroids* filter, double* sum, double* center, size_t* count, std::array dims, const nx::core::ImageGeom& imageGeom, - const Int32Array& featureIds) - : m_Filter(filter) - , m_Sum(sum) + ComputeFeatureCentroidsImpl1(double* sum, double* center, size_t* count, std::array dims, const nx::core::ImageGeom& imageGeom, const Int32AbstractDataStore& featureIds) + : m_Sum(sum) , m_Center(center) , m_Count(count) , m_Dims(dims) , m_ImageGeom(imageGeom) - , m_FeatureIds(featureIds.getDataStoreRef()) + , m_FeatureIds(featureIds) { } ~ComputeFeatureCentroidsImpl1() = default; - void compute(int64_t minFeatureId, int64_t maxFeatureId) const + void compute(usize minFeatureId, usize maxFeatureId) const { for(size_t i = 0; i < m_Dims[2]; i++) { @@ -35,7 +32,7 @@ class ComputeFeatureCentroidsImpl1 size_t yStride = j * m_Dims[0]; for(size_t k = 0; k < m_Dims[0]; k++) { - int32_t featureId = m_FeatureIds[zStride + yStride + k]; // Get the current FeatureId + int32 featureId = m_FeatureIds[zStride + yStride + k]; // Get the current FeatureId if(featureId < minFeatureId || featureId >= maxFeatureId) { continue; @@ -76,11 +73,9 @@ class ComputeFeatureCentroidsImpl1 } private: - ComputeFeatureCentroids* m_Filter = nullptr; double* m_Sum = nullptr; double* m_Center = nullptr; size_t* m_Count = nullptr; - size_t m_TotalFeatures = 0; std::array m_Dims = {0, 0, 0}; const nx::core::ImageGeom& m_ImageGeom; const Int32AbstractDataStore& m_FeatureIds; @@ -111,16 +106,15 @@ const std::atomic_bool& ComputeFeatureCentroids::getCancel() Result<> ComputeFeatureCentroids::operator()() { // Input Cell Data - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + const auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); // Output Feature Data - auto& centroidsArray = m_DataStructure.getDataRefAs(m_InputValues->CentroidsArrayPath); - auto& centroids = centroidsArray.getDataStoreRef(); + auto& centroids = m_DataStructure.getDataAs(m_InputValues->CentroidsArrayPath)->getDataStoreRef(); // Required Geometry const auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); - size_t totalFeatures = centroidsArray.getNumberOfTuples(); + size_t totalFeatures = centroids.getNumberOfTuples(); size_t xPoints = imageGeom.getNumXCells(); size_t yPoints = imageGeom.getNumYCells(); @@ -138,7 +132,7 @@ Result<> ComputeFeatureCentroids::operator()() // by the total number of cores/threads and do a ParallelTask Algorithm instead // we might see some speedup. dataAlg.setParallelizationEnabled(false); - dataAlg.execute(ComputeFeatureCentroidsImpl1(this, sum.data(), center.data(), count.data(), {xPoints, yPoints, zPoints}, imageGeom, featureIds)); + dataAlg.execute(ComputeFeatureCentroidsImpl1(sum.data(), center.data(), count.data(), {xPoints, yPoints, zPoints}, imageGeom, featureIds)); // Here we are only looping over the number of features so let this just go in serial mode. for(size_t featureId = 0; featureId < totalFeatures; featureId++) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureClustering.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureClustering.cpp index f729c4229f..a1647877a4 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureClustering.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureClustering.cpp @@ -5,6 +5,7 @@ #include "simplnx/DataStructure/NeighborList.hpp" #include +#include using namespace nx::core; @@ -34,14 +35,12 @@ std::vector GenerateRandomDistribution(float32 minDistance, float32 max freq.resize(static_cast(currentNumBins + 1)); - std::random_device randomDevice; // Will be used to obtain a seed for the random number engine - std::mt19937_64 generator(randomDevice()); // Standard mersenne_twister_engine seeded with rd() - generator.seed(userSeedValue); + std::mt19937_64 generator(userSeedValue); // Standard mersenne_twister_engine seeded std::uniform_real_distribution distribution(0.0, 1.0); randomCentroids.resize(largeNumber * 3); - // Generating all of the random points and storing their coordinates in randomCentroids + // Generating all the random points and storing their coordinates in randomCentroids for(usize i = 0; i < largeNumber; i++) { const auto featureOwnerIdx = static_cast(distribution(generator) * totalPoints); @@ -61,7 +60,7 @@ std::vector GenerateRandomDistribution(float32 minDistance, float32 max distanceList.resize(largeNumber); - // Calculating all of the distances and storing them in the distance list + // Calculating all the distances and storing them in the distance list for(size_t i = 1; i < largeNumber; i++) { const float32 x = randomCentroids[3 * i]; @@ -132,17 +131,25 @@ const std::atomic_bool& ComputeFeatureClustering::getCancel() Result<> ComputeFeatureClustering::operator()() { const auto& imageGeometry = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); - const auto& equivalentDiameters = m_DataStructure.getDataRefAs(m_InputValues->EquivalentDiametersArrayPath); - const auto& featurePhases = m_DataStructure.getDataRefAs(m_InputValues->FeaturePhasesArrayPath); - const auto& centroids = m_DataStructure.getDataRefAs(m_InputValues->CentroidsArrayPath); + const auto& featurePhasesStore = m_DataStructure.getDataAs(m_InputValues->FeaturePhasesArrayPath)->getDataStoreRef(); + const auto& centroidsStore = m_DataStructure.getDataAs(m_InputValues->CentroidsArrayPath)->getDataStoreRef(); auto& clusteringList = m_DataStructure.getDataRefAs>(m_InputValues->ClusteringListArrayName); - auto& rdf = m_DataStructure.getDataRefAs(m_InputValues->RDFArrayName); - auto& minMaxDistances = m_DataStructure.getDataRefAs(m_InputValues->MaxMinArrayName); - BoolArray* biasedFeatures = nullptr; + auto& rdfStore = m_DataStructure.getDataAs(m_InputValues->RDFArrayName)->getDataStoreRef(); + auto& minMaxDistancesStore = m_DataStructure.getDataAs(m_InputValues->MaxMinArrayName)->getDataStoreRef(); + std::unique_ptr maskCompare; if(m_InputValues->RemoveBiasedFeatures) { - biasedFeatures = m_DataStructure.getDataAs(m_InputValues->BiasedFeaturesArrayPath); + try + { + maskCompare = InstantiateMaskCompare(m_DataStructure, m_InputValues->BiasedFeaturesArrayPath); + } catch(const std::out_of_range& exception) + { + // This really should NOT be happening as the path was verified during preflight BUT we may be calling this from + // somewhere else that is NOT going through the normal nx::core::IFilter API of Preflight and Execute + std::string message = fmt::format("Mask Array DataPath does not exist or is not of the correct type (Bool | UInt8) {}", m_InputValues->BiasedFeaturesArrayPath.toString()); + return MakeErrorResult(-54070, message); + } } float32 x = 0.0f, y = 0.0f, z = 0.0f; @@ -154,13 +161,12 @@ Result<> ComputeFeatureClustering::operator()() int32 totalPptFeatures = 0; float32 min = std::numeric_limits::max(); float32 max = 0.0f; - float32 value = 0.0f; std::vector> clusters; std::vector oldCount(m_InputValues->NumberOfBins); std::vector randomRDF; - const usize totalFeatures = featurePhases.getNumberOfTuples(); + const usize totalFeatures = featurePhasesStore.getNumberOfTuples(); SizeVec3 dims = imageGeometry.getDimensions(); FloatVec3 spacing = imageGeometry.getSpacing(); @@ -175,7 +181,7 @@ Result<> ComputeFeatureClustering::operator()() for(usize i = 1; i < totalFeatures; i++) { - if(featurePhases[i] == m_InputValues->PhaseNumber) + if(featurePhasesStore[i] == m_InputValues->PhaseNumber) { totalPptFeatures++; } @@ -185,24 +191,24 @@ Result<> ComputeFeatureClustering::operator()() for(usize i = 1; i < totalFeatures; i++) { - if(featurePhases[i] == m_InputValues->PhaseNumber) + if(featurePhasesStore[i] == m_InputValues->PhaseNumber) { if(i % 1000 == 0) { m_MessageHandler(IFilter::Message::Type::Info, fmt::format("Working on Feature {} of {}", i, totalPptFeatures)); } - x = centroids[3 * i]; - y = centroids[3 * i + 1]; - z = centroids[3 * i + 2]; + x = centroidsStore[3 * i]; + y = centroidsStore[3 * i + 1]; + z = centroidsStore[3 * i + 2]; for(usize j = i + 1; j < totalFeatures; j++) { - if(featurePhases[i] == featurePhases[j]) + if(featurePhasesStore[i] == featurePhasesStore[j]) { - xn = centroids[3 * j]; - yn = centroids[3 * j + 1]; - zn = centroids[3 * j + 2]; + xn = centroidsStore[3 * j]; + yn = centroidsStore[3 * j + 1]; + zn = centroidsStore[3 * j + 2]; r = sqrtf((x - xn) * (x - xn) + (y - yn) * (y - yn) + (z - zn) * (z - zn)); @@ -215,11 +221,10 @@ Result<> ComputeFeatureClustering::operator()() for(usize i = 1; i < totalFeatures; i++) { - if(featurePhases[i] == m_InputValues->PhaseNumber) + if(featurePhasesStore[i] == m_InputValues->PhaseNumber) { - for(usize j = 0; j < clusters[i].size(); j++) + for(auto value : clusters[i]) { - value = clusters[i][j]; if(value > max) { max = value; @@ -234,27 +239,49 @@ Result<> ComputeFeatureClustering::operator()() const float32 stepSize = (max - min) / m_InputValues->NumberOfBins; - minMaxDistances[(m_InputValues->PhaseNumber * 2)] = max; - minMaxDistances[(m_InputValues->PhaseNumber * 2) + 1] = min; + minMaxDistancesStore[(m_InputValues->PhaseNumber * 2)] = max; + minMaxDistancesStore[(m_InputValues->PhaseNumber * 2) + 1] = min; - for(usize i = 1; i < totalFeatures; i++) + if(m_InputValues->RemoveBiasedFeatures && maskCompare != nullptr) { - if(featurePhases[i] == m_InputValues->PhaseNumber) + for(usize i = 1; i < totalFeatures; i++) { - if(m_InputValues->RemoveBiasedFeatures && (*biasedFeatures)[i]) + if(featurePhasesStore[i] == m_InputValues->PhaseNumber) { - continue; - } + if(maskCompare->isTrue(i)) + { + continue; + } - for(usize j = 0; j < clusters[i].size(); j++) + for(usize j = 0; j < clusters[i].size(); j++) + { + ensemble = featurePhasesStore[i]; + bin = (clusters[i][j] - min) / stepSize; + if(bin >= m_InputValues->NumberOfBins) + { + bin = m_InputValues->NumberOfBins - 1; + } + rdfStore[(m_InputValues->NumberOfBins * ensemble) + bin]++; + } + } + } + } + else + { + for(usize i = 1; i < totalFeatures; i++) + { + if(featurePhasesStore[i] == m_InputValues->PhaseNumber) { - ensemble = featurePhases[i]; - bin = (clusters[i][j] - min) / stepSize; - if(bin >= m_InputValues->NumberOfBins) + for(usize j = 0; j < clusters[i].size(); j++) { - bin = m_InputValues->NumberOfBins - 1; + ensemble = featurePhasesStore[i]; + bin = (clusters[i][j] - min) / stepSize; + if(bin >= m_InputValues->NumberOfBins) + { + bin = m_InputValues->NumberOfBins - 1; + } + rdfStore[(m_InputValues->NumberOfBins * ensemble) + bin]++; } - rdf[(m_InputValues->NumberOfBins * ensemble) + bin]++; } } } @@ -269,15 +296,12 @@ Result<> ComputeFeatureClustering::operator()() // Scale the random distribution by the number of distances in this particular instance const float32 normFactor = totalPptFeatures * (totalPptFeatures - 1); - for(usize i = 0; i < randomRDF.size(); i++) - { - randomRDF[i] *= normFactor; - } + std::transform(randomRDF.begin(), randomRDF.end(), randomRDF.begin(), [normFactor](float32 value) { return value * normFactor; }); for(usize i = 0; i < m_InputValues->NumberOfBins; i++) { - oldCount[i] = rdf[(m_InputValues->NumberOfBins * m_InputValues->PhaseNumber) + i]; - rdf[(m_InputValues->NumberOfBins * m_InputValues->PhaseNumber) + i] = oldCount[i] / randomRDF[i + 1]; + oldCount[i] = rdfStore[(m_InputValues->NumberOfBins * m_InputValues->PhaseNumber) + i]; + rdfStore[(m_InputValues->NumberOfBins * m_InputValues->PhaseNumber) + i] = oldCount[i] / randomRDF[i + 1]; } for(usize i = 1; i < totalFeatures; i++) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureClustering.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureClustering.hpp index c244c6054c..791ef7f6d5 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureClustering.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureClustering.hpp @@ -17,7 +17,6 @@ struct SIMPLNXCORE_EXPORT ComputeFeatureClusteringInputValues int32 PhaseNumber; bool RemoveBiasedFeatures; uint64 SeedValue; - DataPath EquivalentDiametersArrayPath; DataPath FeaturePhasesArrayPath; DataPath CentroidsArrayPath; DataPath BiasedFeaturesArrayPath; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureRect.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureRect.cpp index 4bad48f4ee..48f0f45224 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureRect.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeFeatureRect.cpp @@ -34,21 +34,22 @@ const std::atomic_bool& ComputeFeatureRect::getCancel() // ----------------------------------------------------------------------------- Result<> ComputeFeatureRect::operator()() { - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); - auto& corners = m_DataStructure.getDataRefAs(m_InputValues->FeatureRectArrayPath); - auto& cornersDataStore = corners.getDataStoreRef(); + const auto* featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath); + const auto& featureIdsStore = featureIds->getDataStoreRef(); + auto* corners = m_DataStructure.getDataAs(m_InputValues->FeatureRectArrayPath); + auto& cornersStore = corners->getDataStoreRef(); // Create corners array, which stores pixel coordinates for the top-left and bottom-right coordinates of each feature object - for(usize i = 0; i < corners.getNumberOfTuples(); i++) + for(usize i = 0; i < cornersStore.getNumberOfTuples(); i++) { - cornersDataStore.setComponent(i, 0, std::numeric_limits::max()); - cornersDataStore.setComponent(i, 1, std::numeric_limits::max()); - cornersDataStore.setComponent(i, 2, std::numeric_limits::max()); - cornersDataStore.setComponent(i, 3, std::numeric_limits::min()); - cornersDataStore.setComponent(i, 4, std::numeric_limits::min()); - cornersDataStore.setComponent(i, 5, std::numeric_limits::min()); + cornersStore.setComponent(i, 0, std::numeric_limits::max()); + cornersStore.setComponent(i, 1, std::numeric_limits::max()); + cornersStore.setComponent(i, 2, std::numeric_limits::max()); + cornersStore.setComponent(i, 3, std::numeric_limits::min()); + cornersStore.setComponent(i, 4, std::numeric_limits::min()); + cornersStore.setComponent(i, 5, std::numeric_limits::min()); } - std::vector imageDims = featureIds.getTupleShape(); + std::vector imageDims = featureIdsStore.getTupleShape(); /* * Array dimension ordering is flipped compared to geometry dimension ordering. @@ -75,17 +76,17 @@ Result<> ComputeFeatureRect::operator()() { index = IndexFromCoord(imageDims, x, y, z); // Index into featureIds array - const int32 featureId = featureIds[index]; + const int32 featureId = featureIdsStore[index]; if(featureId == 0) { continue; } - if(featureId >= corners.getNumberOfTuples()) + if(featureId >= cornersStore.getNumberOfTuples()) { const DataPath parentPath = m_InputValues->FeatureRectArrayPath.getParent(); return MakeErrorResult(-31000, fmt::format("The parent data object '{}' of output array '{}' has a smaller tuple count than the maximum feature id in '{}'", parentPath.getTargetName(), - corners.getName(), featureIds.getName())); + corners->getName(), featureIds->getName())); } const uint32 indices[3] = {x, y, z}; // Sequence dependent DO NOT REORDER @@ -94,11 +95,11 @@ Result<> ComputeFeatureRect::operator()() { if(l > 2) { - corners[featureShift + l] = std::max(corners[featureShift + l], indices[l - 3]); + cornersStore[featureShift + l] = std::max(cornersStore[featureShift + l], indices[l - 3]); } else { - corners[featureShift + l] = std::min(corners[featureShift + l], indices[l]); + cornersStore[featureShift + l] = std::min(cornersStore[featureShift + l], indices[l]); } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeKMeans.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeKMeans.cpp index 1b7e9f454d..25fdfb1dc1 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeKMeans.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeKMeans.cpp @@ -15,11 +15,11 @@ template class ComputeKMeansTemplate { public: - ComputeKMeansTemplate(ComputeKMeans* filter, const IDataArray& inputIDataArray, IDataArray& meansIDataArray, const std::unique_ptr& maskDataArray, usize numClusters, Int32Array& fIds, - ClusterUtilities::DistanceMetric distMetric, std::mt19937_64::result_type seed) + ComputeKMeansTemplate(ComputeKMeans* filter, const IDataArray* inputIDataArray, IDataArray* meansIDataArray, const std::unique_ptr& maskDataArray, usize numClusters, + Int32AbstractDataStore& fIds, ClusterUtilities::DistanceMetric distMetric, std::mt19937_64::result_type seed) : m_Filter(filter) - , m_InputArray(dynamic_cast(inputIDataArray)) - , m_Means(dynamic_cast(meansIDataArray)) + , m_InputArray(inputIDataArray->template getIDataStoreRefAs()) + , m_Means(meansIDataArray->template getIDataStoreRefAs()) , m_Mask(maskDataArray) , m_NumClusters(numClusters) , m_FeatureIds(fIds) @@ -100,13 +100,13 @@ class ComputeKMeansTemplate } private: - using DataArrayT = DataArray; + using AbstractDataStoreT = AbstractDataStore; ComputeKMeans* m_Filter; - const DataArrayT& m_InputArray; - DataArrayT& m_Means; + const AbstractDataStoreT& m_InputArray; + AbstractDataStoreT& m_Means; const std::unique_ptr& m_Mask; usize m_NumClusters; - Int32Array& m_FeatureIds; + Int32AbstractDataStore& m_FeatureIds; ClusterUtilities::DistanceMetric m_DistMetric; std::mt19937_64::result_type m_Seed; @@ -207,7 +207,7 @@ const std::atomic_bool& ComputeKMeans::getCancel() // ----------------------------------------------------------------------------- Result<> ComputeKMeans::operator()() { - auto& clusteringArray = m_DataStructure.getDataRefAs(m_InputValues->ClusteringArrayPath); + auto* clusteringArray = m_DataStructure.getDataAs(m_InputValues->ClusteringArrayPath); std::unique_ptr maskCompare; try @@ -221,8 +221,8 @@ Result<> ComputeKMeans::operator()() return MakeErrorResult(-54060, message); } - RunTemplateClass(clusteringArray.getDataType(), this, clusteringArray, m_DataStructure.getDataRefAs(m_InputValues->MeansArrayPath), - maskCompare, m_InputValues->InitClusters, m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath), + RunTemplateClass(clusteringArray->getDataType(), this, clusteringArray, m_DataStructure.getDataAs(m_InputValues->MeansArrayPath), + maskCompare, m_InputValues->InitClusters, m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(), m_InputValues->DistanceMetric, m_InputValues->Seed); return {}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeKMedoids.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeKMedoids.cpp index 25aed0dcf7..591b4343f8 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeKMedoids.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeKMedoids.cpp @@ -15,11 +15,11 @@ template class KMedoidsTemplate { public: - KMedoidsTemplate(ComputeKMedoids* filter, const IDataArray& inputIDataArray, IDataArray& medoidsIDataArray, const std::unique_ptr& maskDataArray, usize numClusters, Int32Array& fIds, - ClusterUtilities::DistanceMetric distMetric, std::mt19937_64::result_type seed) + KMedoidsTemplate(ComputeKMedoids* filter, const IDataArray* inputIDataArray, IDataArray* medoidsIDataArray, const std::unique_ptr& maskDataArray, usize numClusters, + Int32AbstractDataStore& fIds, ClusterUtilities::DistanceMetric distMetric, std::mt19937_64::result_type seed) : m_Filter(filter) - , m_InputArray(dynamic_cast(inputIDataArray)) - , m_Medoids(dynamic_cast(medoidsIDataArray)) + , m_InputArray(inputIDataArray->template getIDataStoreRefAs>()) + , m_Medoids(medoidsIDataArray->template getIDataStoreRefAs>()) , m_Mask(maskDataArray) , m_NumClusters(numClusters) , m_FeatureIds(fIds) @@ -89,12 +89,13 @@ class KMedoidsTemplate private: using DataArrayT = DataArray; + using AbstractDataStoreT = AbstractDataStore; ComputeKMedoids* m_Filter; - const DataArrayT& m_InputArray; - DataArrayT& m_Medoids; + const AbstractDataStoreT& m_InputArray; + AbstractDataStoreT& m_Medoids; const std::unique_ptr& m_Mask; usize m_NumClusters; - Int32Array& m_FeatureIds; + Int32AbstractDataStore& m_FeatureIds; ClusterUtilities::DistanceMetric m_DistMetric; std::mt19937_64::result_type m_Seed; @@ -207,7 +208,7 @@ const std::atomic_bool& ComputeKMedoids::getCancel() // ----------------------------------------------------------------------------- Result<> ComputeKMedoids::operator()() { - auto& clusteringArray = m_DataStructure.getDataRefAs(m_InputValues->ClusteringArrayPath); + auto* clusteringArray = m_DataStructure.getDataAs(m_InputValues->ClusteringArrayPath); std::unique_ptr maskCompare; try { @@ -219,9 +220,9 @@ Result<> ComputeKMedoids::operator()() std::string message = fmt::format("Mask Array DataPath does not exist or is not of the correct type (Bool | UInt8) {}", m_InputValues->MaskArrayPath.toString()); return MakeErrorResult(-54070, message); } - RunTemplateClass(clusteringArray.getDataType(), this, clusteringArray, m_DataStructure.getDataRefAs(m_InputValues->MedoidsArrayPath), maskCompare, - m_InputValues->InitClusters, m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath), m_InputValues->DistanceMetric, - m_InputValues->Seed); + RunTemplateClass(clusteringArray->getDataType(), this, clusteringArray, m_DataStructure.getDataAs(m_InputValues->MedoidsArrayPath), maskCompare, + m_InputValues->InitClusters, m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(), + m_InputValues->DistanceMetric, m_InputValues->Seed); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeLargestCrossSections.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeLargestCrossSections.cpp index cd0e5666ff..827a884f51 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeLargestCrossSections.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeLargestCrossSections.cpp @@ -30,10 +30,11 @@ Result<> ComputeLargestCrossSections::operator()() { const auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); - auto& largestCrossSections = m_DataStructure.getDataRefAs(m_InputValues->LargestCrossSectionsArrayPath); - const usize numFeatures = largestCrossSections.getNumberOfTuples(); + auto& featureIdsStore = featureIds.getDataStoreRef(); + auto& largestCrossSectStore = m_DataStructure.getDataAs(m_InputValues->LargestCrossSectionsArrayPath)->getDataStoreRef(); + const usize numFeatures = largestCrossSectStore.getNumberOfTuples(); - // Validate the largestCrossSections array is the proper size + // Validate the largestCrossSectStore array is the proper size auto validateResults = ValidateNumFeaturesInArray(m_DataStructure, m_InputValues->LargestCrossSectionsArrayPath, featureIds); if(validateResults.invalid()) { @@ -93,16 +94,16 @@ Result<> ComputeLargestCrossSections::operator()() { kStride = k * stride3; point = iStride + jStride + kStride; - gNum = featureIds[point]; + gNum = featureIdsStore[point]; featureCounts[gNum]++; } } for(size_t g = 1; g < numFeatures; g++) { area = featureCounts[g] * resScalar; - if(area > largestCrossSections[g]) + if(area > largestCrossSectStore[g]) { - largestCrossSections[g] = area; + largestCrossSectStore[g] = area; } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeMomentInvariants2D.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeMomentInvariants2D.cpp index a80dc01c42..82a62b1aa5 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeMomentInvariants2D.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeMomentInvariants2D.cpp @@ -7,11 +7,154 @@ using namespace nx::core; +namespace +{ +// ----------------------------------------------------------------------------- +int Factorial(int n) +{ + return (n == 1 || n == 0) ? 1 : Factorial(n - 1) * n; +} + +// ----------------------------------------------------------------------------- +ComputeMomentInvariants2D::DoubleMatrixType Binomial(usize maxOrder) +{ + const int dim = static_cast(maxOrder + 1); + ComputeMomentInvariants2D::DoubleMatrixType bn(dim, dim); + bn.setZero(); + + for(int i = 0; i < dim; i++) + { + for(int j = 0; j <= i; j++) + { + bn(i, j) = (Factorial(i)) / (Factorial(j)) / (Factorial(i - j)); + bn(j, i) = bn(i, j); + } + } + return bn; +} + +// ----------------------------------------------------------------------------- +ComputeMomentInvariants2D::DoubleMatrixType GetBigX(usize maxOrder, usize dim) +{ + const int dRows = static_cast(dim); + const int dCols = static_cast(dim + 1); + + ComputeMomentInvariants2D::DoubleMatrixType xx(1, dCols); + for(int c = 0; c < dCols; c++) + { + xx(0, c) = c - static_cast(dim) / 2.0 - 0.5; + } + + const double fNorm = xx.maxCoeff(); + xx = xx / fNorm; + + ComputeMomentInvariants2D::DoubleMatrixType doubleMatrix(dRows, dCols); + doubleMatrix.setZero(); + + ComputeMomentInvariants2D::IntMatrixType j(1, dRows); + for(int c = 0; c < dRows; c++) + { + j(0, c) = c; + } + + for(int r = 0; r < dRows; r++) + { + doubleMatrix(r, r) = -1.0; + doubleMatrix(r, r + 1) = 1.0; + } + + // Set the Scale Factors + ComputeMomentInvariants2D::DoubleMatrixType sc(1, maxOrder + 1); + const int mop1 = static_cast(maxOrder + 1); + for(int c = 0; c < mop1; c++) + { + sc(0, c) = 1.0 / (c + 1.0); + } + + ComputeMomentInvariants2D::DoubleMatrixType bigX(dim, maxOrder + 1); + bigX.setZero(); + + ComputeMomentInvariants2D::DoubleMatrixType yy; + for(int i = 0; i < mop1; i++) + { + if(i == 0) + { + yy = xx; + } + else + { + yy = yy.cwiseProduct(xx); + } + + ComputeMomentInvariants2D::DoubleMatrixType mm = yy * doubleMatrix.transpose(); + mm = mm * sc(0, i); + bigX.col(i) = mm.row(0); + } + + return bigX; +} + +// ----------------------------------------------------------------------------- +ComputeMomentInvariants2D::DoubleMatrixType ComputeMomentInvariants(const ComputeMomentInvariants2D::DoubleMatrixType& input, const usize* inputDims, usize maxOrder) +{ + assert(inputDims[0] == inputDims[1]); + const usize dim = inputDims[0]; + ComputeMomentInvariants2D::DoubleMatrixType bigX = GetBigX(maxOrder, inputDims[0]); + + const int mDim = static_cast(maxOrder + 1); + const double fNorm = static_cast(dim - 1) / 2.0; + + // precompute the binomial coefficients for central moment conversion; (could be hard-coded for maxOrder = 2) + ComputeMomentInvariants2D::DoubleMatrixType bn = Binomial(maxOrder); + + ComputeMomentInvariants2D::DoubleMatrixType mnk(mDim, mDim); + mnk.setZero(); + + const ComputeMomentInvariants2D::DoubleMatrixType inter = input * bigX; + + mnk = bigX.transpose() * inter; + + for(int c = 0; c < mDim; c++) + { + for(int r = 0; r < mDim; r++) + { + mnk(r, c) *= std::pow(fNorm, (2 + c + r)); + } + } + + // transform the moments to central moments using the binomial theorem + // first get the center of mass coordinates (xc, yc) + const double xc = mnk(1, 0) / mnk(0, 0); // mnk[0,0] is the area of the object in units of pixels + const double yc = mnk(0, 1) / mnk(0, 0); + + // declare an intermediate array to hold the transformed moment values + ComputeMomentInvariants2D::DoubleMatrixType mnkNew(mDim, mDim); + mnkNew.setZero(); + + // apply the binomial theorem + for(int p = 0; p < mDim; p++) + { + for(int q = 0; q < mDim; q++) + { + for(int k = 0; k < p + 1; k++) + { + for(int l = 0; l < q + 1; l++) + { + mnkNew(p, q) += std::pow(-1.0, (p + q - k - l)) * std::pow(xc, (p - k)) * std::pow(yc, (q - l)) * bn(p, k) * bn(q, l) * mnk(k, l); + } + } + } + } + + return mnkNew; +} + class ComputeMomentInvariants2DImpl { public: - ComputeMomentInvariants2DImpl(const Int32Array& featureIds, const UInt32Array& featureRect, Float32Array& omega1, Float32Array& omega2, Float32Array* centralMoments, const SizeVec3& volDims, - const bool normalizeMomentInvariants, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel) + ComputeMomentInvariants2DImpl(const Int32AbstractDataStore& featureIds, const UInt32AbstractDataStore& featureRect, Float32AbstractDataStore& omega1, Float32AbstractDataStore& omega2, + Float32Array* centralMoments, const SizeVec3& volDims, const bool normalizeMomentInvariants, const IFilter::MessageHandler& mesgHandler, + const std::atomic_bool& shouldCancel) : m_FeatureIds(featureIds) , m_FeatureRect(featureRect) , m_Omega1(omega1) @@ -24,11 +167,11 @@ class ComputeMomentInvariants2DImpl { } - void convert(usize start, usize end) const + void convert(usize start, usize end, Float32AbstractDataStore& centralMoments) const { const usize numRectComponents = m_FeatureRect.getNumberOfComponents(); - const auto numFeatures = static_cast(m_FeatureRect.getNumberOfTuples()); - for(int32 featureId = start; featureId < end; featureId++) + const usize numFeatures = m_FeatureRect.getNumberOfTuples(); + for(usize featureId = start; featureId < end; featureId++) { const auto featureIdRectIndex = featureId * numRectComponents; std::array corner = {m_FeatureRect[featureIdRectIndex], m_FeatureRect[featureIdRectIndex + 1], m_FeatureRect[featureIdRectIndex + 2], @@ -48,11 +191,7 @@ class ComputeMomentInvariants2DImpl return; } - usize dim = xDim; // Assume XDim is the largest value - if(yDim > xDim) - { - dim = yDim; // Nope, YDim is largest - } + usize dim = std::max(xDim, yDim); ComputeMomentInvariants2D::DoubleMatrixType input2D(dim, dim); input2D.setZero(); @@ -76,7 +215,7 @@ class ComputeMomentInvariants2DImpl } const usize inputDims[2] = {dim, dim}; - ComputeMomentInvariants2D::DoubleMatrixType m2D = ComputeMomentInvariants2D::ComputeMomentInvariants(input2D, inputDims, maxOrder); + ComputeMomentInvariants2D::DoubleMatrixType m2D = ::ComputeMomentInvariants(input2D, inputDims, maxOrder); // compute the second order moment invariants double omega1 = 2.0 * (m2D(0, 0) * m2D(0, 0)) / (m2D(0, 2) + m2D(2, 0)); double omega2 = std::pow(m2D(0, 0), 4) / (m2D(2, 0) * m2D(0, 2) - std::pow(m2D(1, 1), 2)); @@ -88,18 +227,87 @@ class ComputeMomentInvariants2DImpl omega1 /= circleOmega[0]; omega2 /= circleOmega[1]; } - m_Omega1[featureId] = static_cast(omega1); - m_Omega2[featureId] = static_cast(omega2); + m_Omega1[featureId] = static_cast(omega1); + m_Omega2[featureId] = static_cast(omega2); + + const double* m2DInternal = m2D.array().data(); + for(usize comp = 0; comp < 9; comp++) + { + centralMoments[static_cast(featureId) * 9UL + comp] = static_cast(m2DInternal[comp]); + } + + m_MessageHandler(IFilter::Message::Type::Info, fmt::format("[{}/{}] : Completed", featureId, numFeatures)); + + if(m_ShouldCancel) + { + return; + } + } + } + + void convert(usize start, usize end) const + { + const usize numRectComponents = m_FeatureRect.getNumberOfComponents(); + const usize numFeatures = m_FeatureRect.getNumberOfTuples(); + for(usize featureId = start; featureId < end; featureId++) + { + const auto featureIdRectIndex = featureId * numRectComponents; + std::array corner = {m_FeatureRect[featureIdRectIndex], m_FeatureRect[featureIdRectIndex + 1], m_FeatureRect[featureIdRectIndex + 2], + m_FeatureRect[featureIdRectIndex + 3], m_FeatureRect[featureIdRectIndex + 4], m_FeatureRect[featureIdRectIndex + 5]}; + constexpr usize maxOrder = 2; + + // Figure the largest X || Y dimension so we can create a square matrix + const uint32 xDim = corner[3] - corner[0] + 1; + const uint32 yDim = corner[4] - corner[1] + 1; + const uint32 zDim = corner[5] - corner[2] + 1; + + if(zDim != 1) + { + m_Omega1[featureId] = 0.0f; + m_Omega2[featureId] = 0.0f; + m_MessageHandler(IFilter::Message::Type::Info, fmt::format("[{}/{}] : Feature {} is NOT strictly 2D in the XY plane. Skipping this feature.", featureId, numFeatures, featureId)); + return; + } + + usize dim = std::max(xDim, yDim); + + ComputeMomentInvariants2D::DoubleMatrixType input2D(dim, dim); + input2D.setZero(); - if(m_CentralMoments != nullptr) + uint32 height = 0; + + for(uint32_t y = corner[1]; y <= corner[4]; y++) { - const double* m2DInternal = m2D.array().data(); - for(usize comp = 0; comp < 9; comp++) + for(uint32_t x = corner[0]; x <= corner[3]; x++) { - (*m_CentralMoments)[static_cast(featureId) * 9UL + comp] = static_cast(m2DInternal[comp]); + const usize index = (m_VolDims[1] * m_VolDims[0] * height) + (m_VolDims[0] * y) + x; + if(m_FeatureIds[index] == featureId) + { + input2D(y - corner[1], x - corner[0]) = 1; + } + else + { + input2D(y - corner[1], x - corner[0]) = 0; + } } } + const usize inputDims[2] = {dim, dim}; + ComputeMomentInvariants2D::DoubleMatrixType m2D = ::ComputeMomentInvariants(input2D, inputDims, maxOrder); + // compute the second order moment invariants + double omega1 = 2.0 * (m2D(0, 0) * m2D(0, 0)) / (m2D(0, 2) + m2D(2, 0)); + double omega2 = std::pow(m2D(0, 0), 4) / (m2D(2, 0) * m2D(0, 2) - std::pow(m2D(1, 1), 2)); + + if(m_NormalizeMomentInvariants) + { + // normalize the invariants by those of the circle + constexpr double circleOmega[2] = {4.0 * numbers::pi, 16.0 * numbers::pi * numbers::pi}; + omega1 /= circleOmega[0]; + omega2 /= circleOmega[1]; + } + m_Omega1[featureId] = static_cast(omega1); + m_Omega2[featureId] = static_cast(omega2); + m_MessageHandler(IFilter::Message::Type::Info, fmt::format("[{}/{}] : Completed", featureId, numFeatures)); if(m_ShouldCancel) @@ -111,21 +319,28 @@ class ComputeMomentInvariants2DImpl void operator()(const Range& range) const { - convert(range.min(), range.max()); + if(m_CentralMoments != nullptr) + { + convert(range.min(), range.max(), m_CentralMoments->getDataStoreRef()); + } + else + { + convert(range.min(), range.max()); + } } private: - const Int32Array& m_FeatureIds; - const UInt32Array& m_FeatureRect; - Float32Array& m_Omega1; - Float32Array& m_Omega2; + const Int32AbstractDataStore& m_FeatureIds; + const UInt32AbstractDataStore& m_FeatureRect; + Float32AbstractDataStore& m_Omega1; + Float32AbstractDataStore& m_Omega2; Float32Array* m_CentralMoments = nullptr; const SizeVec3& m_VolDims; const bool m_NormalizeMomentInvariants = true; const std::atomic_bool& m_ShouldCancel; const IFilter::MessageHandler& m_MessageHandler; }; - +} // namespace // ----------------------------------------------------------------------------- ComputeMomentInvariants2D::ComputeMomentInvariants2D(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ComputeMomentInvariants2DInputValues* inputValues) @@ -151,12 +366,11 @@ Result<> ComputeMomentInvariants2D::operator()() const auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); const SizeVec3 volDims = imageGeom.getDimensions(); - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); - const auto& featureRect = m_DataStructure.getDataRefAs(m_InputValues->FeatureRectArrayPath); + const auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); + const auto& featureRect = m_DataStructure.getDataAs(m_InputValues->FeatureRectArrayPath)->getDataStoreRef(); const auto numFeatures = static_cast(featureRect.getNumberOfTuples()); - const usize numRectComponents = featureRect.getNumberOfComponents(); - auto& omega1 = m_DataStructure.getDataRefAs(m_InputValues->Omega1ArrayPath); - auto& omega2 = m_DataStructure.getDataRefAs(m_InputValues->Omega2ArrayPath); + auto& omega1 = m_DataStructure.getDataAs(m_InputValues->Omega1ArrayPath)->getDataStoreRef(); + auto& omega2 = m_DataStructure.getDataAs(m_InputValues->Omega2ArrayPath)->getDataStoreRef(); Float32Array* centralMoments = nullptr; if(m_InputValues->SaveCentralMoments) { @@ -170,143 +384,3 @@ Result<> ComputeMomentInvariants2D::operator()() return {}; } - -// ----------------------------------------------------------------------------- -ComputeMomentInvariants2D::DoubleMatrixType ComputeMomentInvariants2D::ComputeMomentInvariants(const DoubleMatrixType& input, const usize* inputDims, usize maxOrder) -{ - assert(inputDims[0] == inputDims[1]); - const usize dim = inputDims[0]; - DoubleMatrixType bigX = GetBigX(maxOrder, inputDims[0]); - - const int mDim = static_cast(maxOrder + 1); - const double fNorm = static_cast(dim - 1) / 2.0; - - // precompute the binomial coefficients for central moment conversion; (could be hard-coded for maxOrder = 2) - DoubleMatrixType bn = Binomial(maxOrder); - - DoubleMatrixType mnk(mDim, mDim); - mnk.setZero(); - - const DoubleMatrixType inter = input * bigX; - - mnk = bigX.transpose() * inter; - - for(int c = 0; c < mDim; c++) - { - for(int r = 0; r < mDim; r++) - { - mnk(r, c) *= std::pow(fNorm, (2 + c + r)); - } - } - - // transform the moments to central moments using the binomial theorem - // first get the center of mass coordinates (xc, yc) - const double xc = mnk(1, 0) / mnk(0, 0); // mnk[0,0] is the area of the object in units of pixels - const double yc = mnk(0, 1) / mnk(0, 0); - - // declare an intermediate array to hold the transformed moment values - DoubleMatrixType mnkNew(mDim, mDim); - mnkNew.setZero(); - - // apply the binomial theorem - for(int p = 0; p < mDim; p++) - { - for(int q = 0; q < mDim; q++) - { - for(int k = 0; k < p + 1; k++) - { - for(int l = 0; l < q + 1; l++) - { - mnkNew(p, q) += std::pow(-1.0, (p + q - k - l)) * std::pow(xc, (p - k)) * std::pow(yc, (q - l)) * bn(p, k) * bn(q, l) * mnk(k, l); - } - } - } - } - - return mnkNew; -} - -// ----------------------------------------------------------------------------- -int ComputeMomentInvariants2D::Factorial(int n) -{ - return (n == 1 || n == 0) ? 1 : Factorial(n - 1) * n; -} - -// ----------------------------------------------------------------------------- -ComputeMomentInvariants2D::DoubleMatrixType ComputeMomentInvariants2D::Binomial(usize maxOrder) -{ - const int dim = static_cast(maxOrder + 1); - DoubleMatrixType bn(dim, dim); - bn.setZero(); - - for(int i = 0; i < dim; i++) - { - for(int j = 0; j <= i; j++) - { - bn(i, j) = (Factorial(i)) / (Factorial(j)) / (Factorial(i - j)); - bn(j, i) = bn(i, j); - } - } - return bn; -} - -// ----------------------------------------------------------------------------- -ComputeMomentInvariants2D::DoubleMatrixType ComputeMomentInvariants2D::GetBigX(usize maxOrder, usize dim) -{ - const int dRows = static_cast(dim); - const int dCols = static_cast(dim + 1); - - DoubleMatrixType xx(1, dCols); - for(int c = 0; c < dCols; c++) - { - xx(0, c) = c - static_cast(dim) / 2.0 - 0.5; - } - - const double fNorm = xx.maxCoeff(); - xx = xx / fNorm; - - DoubleMatrixType doubleMatrix(dRows, dCols); - doubleMatrix.setZero(); - - IntMatrixType j(1, dRows); - for(int c = 0; c < dRows; c++) - { - j(0, c) = c; - } - - for(int r = 0; r < dRows; r++) - { - doubleMatrix(r, r) = -1.0; - doubleMatrix(r, r + 1) = 1.0; - } - - // Set the Scale Factors - DoubleMatrixType sc(1, maxOrder + 1); - const int mop1 = static_cast(maxOrder + 1); - for(int c = 0; c < mop1; c++) - { - sc(0, c) = 1.0 / (c + 1.0); - } - - DoubleMatrixType bigX(dim, maxOrder + 1); - bigX.setZero(); - - DoubleMatrixType yy; - for(int i = 0; i < mop1; i++) - { - if(i == 0) - { - yy = xx; - } - else - { - yy = yy.cwiseProduct(xx); - } - - DoubleMatrixType mm = yy * doubleMatrix.transpose(); - mm = mm * sc(0, i); - bigX.col(i) = mm.row(0); - } - - return bigX; -} diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeMomentInvariants2D.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeMomentInvariants2D.hpp index 03637a0116..3f863096d0 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeMomentInvariants2D.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeMomentInvariants2D.hpp @@ -10,7 +10,6 @@ namespace nx::core { - struct SIMPLNXCORE_EXPORT ComputeMomentInvariants2DInputValues { DataPath ImageGeometryPath; @@ -47,16 +46,10 @@ class SIMPLNXCORE_EXPORT ComputeMomentInvariants2D const std::atomic_bool& getCancel(); - static DoubleMatrixType ComputeMomentInvariants(const DoubleMatrixType& input, const usize* inputDims, usize maxOrder); - static int Factorial(int n); - static DoubleMatrixType Binomial(usize maxOrder); - static DoubleMatrixType GetBigX(usize maxOrder, usize dim); - private: DataStructure& m_DataStructure; const ComputeMomentInvariants2DInputValues* m_InputValues = nullptr; const std::atomic_bool& m_ShouldCancel; const IFilter::MessageHandler& m_MessageHandler; }; - } // namespace nx::core diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeNeighborhoods.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeNeighborhoods.cpp index f0eb39f3bf..5059ced486 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeNeighborhoods.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeNeighborhoods.cpp @@ -8,7 +8,8 @@ #include using namespace nx::core; - +namespace +{ class ComputeNeighborhoodsImpl { public: @@ -97,6 +98,7 @@ class ComputeNeighborhoodsImpl const std::vector& m_CriticalDistance; const std::atomic_bool& m_ShouldCancel; }; +} // namespace // ----------------------------------------------------------------------------- ComputeNeighborhoods::ComputeNeighborhoods(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ComputeNeighborhoodsInputValues* inputValues) @@ -146,12 +148,11 @@ void ComputeNeighborhoods::updateProgress(float64 counter, const std::chrono::st Result<> ComputeNeighborhoods::operator()() { // m_ProgressCounter initialized to zero on filter creation - std::vector criticalDistance; auto multiplesOfAverage = m_InputValues->MultiplesOfAverage; - const auto& equivalentDiameters = m_DataStructure.getDataRefAs(m_InputValues->EquivalentDiametersArrayPath); - const auto& centroids = m_DataStructure.getDataRefAs(m_InputValues->CentroidsArrayPath); + const auto& equivalentDiameters = m_DataStructure.getDataAs(m_InputValues->EquivalentDiametersArrayPath)->getDataStoreRef(); + const auto& centroids = m_DataStructure.getDataAs(m_InputValues->CentroidsArrayPath)->getDataStoreRef(); m_Neighborhoods = m_DataStructure.getDataAs(m_InputValues->NeighborhoodsArrayName); @@ -192,7 +193,7 @@ Result<> ComputeNeighborhoods::operator()() parallelAlgorithm.execute(ComputeNeighborhoodsImpl(this, totalFeatures, bins, criticalDistance, m_ShouldCancel)); // Output Variables - auto& outputNeighborList = m_DataStructure.getDataRefAs>(m_InputValues->NeighborhoodListArrayName); + auto& outputNeighborList = m_DataStructure.getDataRefAs>(m_InputValues->NeighborhoodListArrayName); // Set the vector for each list into the NeighborList Object for(usize i = 1; i < totalFeatures; i++) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeSurfaceAreaToVolume.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeSurfaceAreaToVolume.cpp index 619cae2bcc..a44d69cb67 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeSurfaceAreaToVolume.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeSurfaceAreaToVolume.cpp @@ -30,13 +30,13 @@ const std::atomic_bool& ComputeSurfaceAreaToVolume::getCancel() Result<> ComputeSurfaceAreaToVolume::operator()() { // Input Cell Data - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + const auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); // Input Feature Data - const auto& numCells = m_DataStructure.getDataRefAs(m_InputValues->NumCellsArrayPath); + const auto& numCells = m_DataStructure.getDataAs(m_InputValues->NumCellsArrayPath)->getDataStoreRef(); // Output Feature Data - auto& surfaceAreaVolumeRatio = m_DataStructure.getDataRefAs(m_InputValues->SurfaceAreaVolumeRatioArrayName); + auto& surfaceAreaVolumeRatio = m_DataStructure.getDataAs(m_InputValues->SurfaceAreaVolumeRatioArrayName)->getDataStoreRef(); // Required Geometry const auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->InputImageGeometry); @@ -45,12 +45,12 @@ Result<> ComputeSurfaceAreaToVolume::operator()() // Feature Id; the filter would not crash otherwise, but the user should // be notified of unanticipated behavior ; this cannot be done in the dataCheck since // we don't have access to the data yet - auto numFeatures = static_cast(numCells.getNumberOfTuples()); + auto numFeatures = static_cast(numCells.getNumberOfTuples()); bool mismatchedFeatures = false; - int32_t largestFeature = 0; - size_t numTuples = featureIds.getNumberOfTuples(); + int32 largestFeature = 0; + usize numTuples = featureIds.getNumberOfTuples(); std::string errorMessage; - for(size_t i = 0; i < numTuples; i++) + for(usize i = 0; i < numTuples; i++) { if(featureIds[i] > largestFeature) { @@ -72,17 +72,17 @@ Result<> ComputeSurfaceAreaToVolume::operator()() SizeVec3 dims = imageGeom.getDimensions(); FloatVec3 spacing = imageGeom.getSpacing(); - int64_t xPoints = static_cast(dims[0]); - int64_t yPoints = static_cast(dims[1]); - int64_t zPoints = static_cast(dims[2]); + auto xPoints = static_cast(dims[0]); + auto yPoints = static_cast(dims[1]); + auto zPoints = static_cast(dims[2]); - float voxelVol = spacing[0] * spacing[1] * spacing[2]; + float32 voxelVol = spacing[0] * spacing[1] * spacing[2]; std::vector featureSurfaceArea(static_cast(numFeatures), 0.0f); // This stores an offset to get to a particular index in the array based on // a normal orthogonal cube - int64_t neighborOffset[6] = {0, 0, 0, 0, 0, 0}; + int64 neighborOffset[6] = {0, 0, 0, 0, 0, 0}; neighborOffset[0] = -xPoints * yPoints; // -Z neighborOffset[1] = -xPoints; // -Y neighborOffset[2] = -1; // -X @@ -91,13 +91,13 @@ Result<> ComputeSurfaceAreaToVolume::operator()() neighborOffset[5] = xPoints * yPoints; // +Z // Start looping over the regular grid data (This could be either an Image Geometry or a Rectilinear Grid geometry (in theory) - for(int64_t zIdx = 0; zIdx < zPoints; zIdx++) + for(int64 zIdx = 0; zIdx < zPoints; zIdx++) { - int64_t zStride = zIdx * xPoints * yPoints; - for(int64_t yIdx = 0; yIdx < yPoints; yIdx++) + int64 zStride = zIdx * xPoints * yPoints; + for(int64 yIdx = 0; yIdx < yPoints; yIdx++) { - int64_t yStride = yIdx * xPoints; - for(int64_t xIdx = 0; xIdx < xPoints; xIdx++) + int64 yStride = yIdx * xPoints; + for(int64 xIdx = 0; xIdx < xPoints; xIdx++) { float onSurface = 0.0f; // Start totalling the surface area int32 currentFeatureId = featureIds[zStride + yStride + xIdx]; @@ -108,7 +108,7 @@ Result<> ComputeSurfaceAreaToVolume::operator()() } // Loop over all 6 face neighbors - for(int32_t neighborOffsetIndex = 0; neighborOffsetIndex < 6; neighborOffsetIndex++) + for(int32 neighborOffsetIndex = 0; neighborOffsetIndex < 6; neighborOffsetIndex++) { if(neighborOffsetIndex == 0 && zIdx == 0) // if we are on the bottom Z Layer, skip { @@ -135,7 +135,7 @@ Result<> ComputeSurfaceAreaToVolume::operator()() continue; } // - int64_t neighborIndex = zStride + yStride + xIdx + neighborOffset[neighborOffsetIndex]; + int64 neighborIndex = zStride + yStride + xIdx + neighborOffset[neighborOffsetIndex]; if(featureIds[neighborIndex] != currentFeatureId) { @@ -159,8 +159,8 @@ Result<> ComputeSurfaceAreaToVolume::operator()() } } - const float thirdRootPi = std::pow(nx::core::Constants::k_PiF, 0.333333f); - for(size_t i = 1; i < static_cast(numFeatures); i++) + const float32 thirdRootPi = std::pow(nx::core::Constants::k_PiF, 0.333333f); + for(usize i = 1; i < numFeatures; i++) { float featureVolume = voxelVol * numCells[i]; surfaceAreaVolumeRatio[i] = featureSurfaceArea[i] / featureVolume; @@ -168,8 +168,8 @@ Result<> ComputeSurfaceAreaToVolume::operator()() if(m_InputValues->CalculateSphericity) // Calc the sphericity if requested { - auto& sphericity = m_DataStructure.getDataRefAs(m_InputValues->SphericityArrayName); - for(size_t i = 1; i < static_cast(numFeatures); i++) + auto& sphericity = m_DataStructure.getDataAs(m_InputValues->SphericityArrayName)->getDataStoreRef(); + for(usize i = 1; i < static_cast(numFeatures); i++) { float featureVolume = voxelVol * numCells[i]; sphericity[i] = (thirdRootPi * std::pow((6.0f * featureVolume), 0.66666f)) / featureSurfaceArea[i]; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomCentroids.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomCentroids.cpp index 7e1e4ba923..60eb2bbf08 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomCentroids.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomCentroids.cpp @@ -30,19 +30,19 @@ const std::atomic_bool& ComputeTriangleGeomCentroids::getCancel() Result<> ComputeTriangleGeomCentroids::operator()() { using MeshIndexType = IGeometry::MeshIndexType; - using SharedVertexListType = IGeometry::SharedVertexList; - using SharedFaceListType = IGeometry::SharedFaceList; + using SharedVertexListType = AbstractDataStore; + using SharedFaceListType = AbstractDataStore; const auto& triangleGeom = m_DataStructure.getDataRefAs(m_InputValues->TriangleGeometryPath); - const SharedVertexListType& vertexCoords = triangleGeom.getVerticesRef(); - const SharedFaceListType& triangles = triangleGeom.getFacesRef(); + const SharedVertexListType& vertexCoords = triangleGeom.getVertices()->getDataStoreRef(); + const SharedFaceListType& triangles = triangleGeom.getFaces()->getDataStoreRef(); IGeometry::MeshIndexType numTriangles = triangleGeom.getNumberOfFaces(); auto& featAttrMat = m_DataStructure.getDataRefAs(m_InputValues->FeatureAttributeMatrixPath); MeshIndexType numFeatures = featAttrMat.getNumTuples(); - auto& centroids = m_DataStructure.getDataRefAs(m_InputValues->CentroidsArrayPath); + auto& centroids = m_DataStructure.getDataAs(m_InputValues->CentroidsArrayPath)->getDataStoreRef(); std::vector> vertexSets(numFeatures); - const Int32Array& faceLabels = m_DataStructure.getDataRefAs(m_InputValues->FaceLabelsArrayPath); + const Int32AbstractDataStore& faceLabels = m_DataStructure.getDataAs(m_InputValues->FaceLabelsArrayPath)->getDataStoreRef(); for(MeshIndexType i = 0; i < numTriangles; i++) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.cpp index 593503f910..6bd871b2d6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeTriangleGeomSizes.cpp @@ -22,7 +22,7 @@ constexpr usize k_22 = 8; // ----------------------------------------------------------------------------- template -T FindTetrahedronVolume(const std::array& vertIds, const DataArray& vertexCoords) +T FindTetrahedronVolume(const std::array& vertIds, const AbstractDataStore& vertexCoords) { // This is a 3x3 matrix laid out in typical "C" order where the columns raster the fastest, then the rows std::array volumeMatrix = { @@ -35,7 +35,6 @@ T FindTetrahedronVolume(const std::array& vertIds, const DataArray& (volumeMatrix[k_02] * (volumeMatrix[k_10] * volumeMatrix[k_21] - volumeMatrix[k_11] * volumeMatrix[k_20])); return determinant / 6.0f; } - } // namespace // ----------------------------------------------------------------------------- @@ -61,12 +60,12 @@ const std::atomic_bool& ComputeTriangleGeomSizes::getCancel() Result<> ComputeTriangleGeomSizes::operator()() { using MeshIndexType = IGeometry::MeshIndexType; - using SharedVertexListType = IGeometry::SharedVertexList; + using SharedVertexListType = AbstractDataStore; const auto& triangleGeom = m_DataStructure.getDataRefAs(m_InputValues->TriangleGeometryPath); IGeometry::MeshIndexType numTriangles = triangleGeom.getNumberOfFaces(); - const SharedVertexListType& vertexCoords = triangleGeom.getVerticesRef(); - const Int32Array& faceLabels = m_DataStructure.getDataRefAs(m_InputValues->FaceLabelsArrayPath); + const SharedVertexListType& vertexCoords = triangleGeom.getVertices()->getDataStoreRef(); + const auto& faceLabels = m_DataStructure.getDataAs(m_InputValues->FaceLabelsArrayPath)->getDataStoreRef(); std::set featureSet; @@ -85,7 +84,7 @@ Result<> ComputeTriangleGeomSizes::operator()() AttributeMatrix::ShapeType tDims = {featureSet.size() + 1}; auto& featAttrMat = m_DataStructure.getDataRefAs(m_InputValues->FeatureAttributeMatrixPath); featAttrMat.resizeTuples(tDims); - auto& volumes = m_DataStructure.getDataRefAs(m_InputValues->VolumesArrayPath); + auto& volumes = m_DataStructure.getDataAs(m_InputValues->VolumesArrayPath)->getDataStoreRef(); std::array faceVertexIndices = {0, 0, 0}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeVectorColors.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeVectorColors.cpp index 1d87f2fb08..cecfec1cf5 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeVectorColors.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeVectorColors.cpp @@ -48,8 +48,8 @@ Result<> ComputeVectorColors::operator()() return MakeErrorResult(-54700, fmt::format("Mask Array DataPath does not exist or is not of the correct type (Bool | UInt8) {}", m_InputValues->MaskArrayPath.toString())); } - auto& vectors = m_DataStructure.getDataRefAs(m_InputValues->VectorsArrayPath); - auto& cellVectorColors = m_DataStructure.getDataRefAs(m_InputValues->CellVectorColorsArrayPath); + auto& vectors = m_DataStructure.getDataAs(m_InputValues->VectorsArrayPath)->getDataStoreRef(); + auto& cellVectorColors = m_DataStructure.getDataAs(m_InputValues->CellVectorColorsArrayPath)->getDataStoreRef(); usize totalPoints = vectors.getNumberOfTuples(); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeVertexToTriangleDistances.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeVertexToTriangleDistances.cpp index 101aec1054..24ad9003ef 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeVertexToTriangleDistances.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeVertexToTriangleDistances.cpp @@ -7,12 +7,13 @@ #include "simplnx/Utilities/ParallelDataAlgorithm.hpp" #include "simplnx/Utilities/RTree.hpp" -using RTreeType = RTree; - using namespace nx::core; namespace { +using RTreeType = RTree; +using SharedTriListT = AbstractDataStore; +using SharedVertexListT = AbstractDataStore; /** * @brief 3x1 Matrix as a row. @@ -185,7 +186,7 @@ class Matrix3X1 * @param vectorB * @return */ - float cosThetaBetweenVectors(const SelfType& vectorB) const + float32 cosThetaBetweenVectors(const SelfType& vectorB) const { float32 norm1 = sqrtf(m_Data[0] * m_Data[0] + m_Data[1] * m_Data[1] + m_Data[2] * m_Data[2]); float32 norm2 = sqrtf(vectorB[0] * vectorB[0] + vectorB[1] * vectorB[1] + vectorB[2] * vectorB[2]); @@ -279,7 +280,7 @@ Vec3fa closestPointTriangle(const Vec3fa& p, const Vec3fa& a, const Vec3fa& b, c return pointInTriangle; } -float32 PointTriangleDistance(const Vec3fa& point, const Vec3fa& vert0, const Vec3fa& vert1, const Vec3fa& vert2, const int64 triangle, const Float64Array& normals) +float32 PointTriangleDistance(const Vec3fa& point, const Vec3fa& vert0, const Vec3fa& vert1, const Vec3fa& vert2, const int64 triangle, const Float64AbstractDataStore& normals) { Vec3fa closestPointInTriangle = closestPointTriangle(point, vert0, vert1, vert2); @@ -303,8 +304,8 @@ float32 PointTriangleDistance(const Vec3fa& point, const Vec3fa& vert0, const Ve class ComputeVertexToTriangleDistancesImpl { public: - ComputeVertexToTriangleDistancesImpl(ComputeVertexToTriangleDistances* filter, const IGeometry::SharedTriList& triangles, const IGeometry::SharedVertexList& vertices, - IGeometry::SharedVertexList& sourcePoints, Float32Array& distances, Int64Array& closestTri, const Float64Array& normals, const RTreeType rtree) + ComputeVertexToTriangleDistancesImpl(ComputeVertexToTriangleDistances* filter, const SharedTriListT& triangles, const SharedVertexListT& vertices, SharedVertexListT& sourcePoints, + Float32AbstractDataStore& distances, Int64AbstractDataStore& closestTri, const Float64AbstractDataStore& normals, const RTreeType rtree) : m_Filter(filter) , m_SharedTriangleList(triangles) , m_TriangleVertices(vertices) @@ -415,14 +416,31 @@ class ComputeVertexToTriangleDistancesImpl private: ComputeVertexToTriangleDistances* m_Filter; - const IGeometry::SharedTriList& m_SharedTriangleList; - const IGeometry::SharedVertexList& m_TriangleVertices; - IGeometry::SharedVertexList& m_SourcePoints; - Float32Array& m_Distances; - Int64Array& m_ClosestTri; - const Float64Array& m_Normals; + const SharedTriListT& m_SharedTriangleList; + const SharedVertexListT& m_TriangleVertices; + SharedVertexListT& m_SourcePoints; + Float32AbstractDataStore& m_Distances; + Int64AbstractDataStore& m_ClosestTri; + const Float64AbstractDataStore& m_Normals; const RTreeType m_RTree; }; + +void GetBoundingBoxAtTri(const SharedTriListT& triList, const SharedVertexListT& vertList, size_t triId, nonstd::span bounds) +{ + size_t v0Index = triList[triId * 3 + 0] * 3; + size_t v1Index = triList[triId * 3 + 1] * 3; + size_t v2Index = triList[triId * 3 + 2] * 3; + + auto xMinMax = std::minmax({vertList[v0Index + 0], vertList[v1Index + 0], vertList[v2Index + 0]}); + auto yMinMax = std::minmax({vertList[v0Index + 1], vertList[v1Index + 1], vertList[v2Index + 1]}); + auto zMinMax = std::minmax({vertList[v0Index + 2], vertList[v1Index + 2], vertList[v2Index + 2]}); + bounds[0] = xMinMax.first; + bounds[1] = yMinMax.first; + bounds[2] = zMinMax.first; + bounds[3] = xMinMax.second; + bounds[4] = yMinMax.second; + bounds[5] = zMinMax.second; +} } // namespace // ----------------------------------------------------------------------------- @@ -452,8 +470,6 @@ void ComputeVertexToTriangleDistances::sendThreadSafeProgressMessage(usize count m_ProgressCounter += counter; auto progressInt = static_cast((static_cast(m_ProgressCounter) / static_cast(m_TotalElements)) * 100.0f); - size_t progIncrement = m_TotalElements / 100; - if(m_ProgressCounter > 1 && m_LastProgressInt != progressInt) { std::string ss = fmt::format("Finding Distances || {}% Completed", progressInt); @@ -463,34 +479,17 @@ void ComputeVertexToTriangleDistances::sendThreadSafeProgressMessage(usize count m_LastProgressInt = progressInt; } -void GetBoundingBoxAtTri(const IGeometry::SharedTriList& triList, const IGeometry::SharedVertexList& vertList, size_t triId, nonstd::span bounds) -{ - size_t v0Index = triList[triId * 3 + 0] * 3; - size_t v1Index = triList[triId * 3 + 1] * 3; - size_t v2Index = triList[triId * 3 + 2] * 3; - - auto xMinMax = std::minmax({vertList[v0Index + 0], vertList[v1Index + 0], vertList[v2Index + 0]}); - auto yMinMax = std::minmax({vertList[v0Index + 1], vertList[v1Index + 1], vertList[v2Index + 1]}); - auto zMinMax = std::minmax({vertList[v0Index + 2], vertList[v1Index + 2], vertList[v2Index + 2]}); - bounds[0] = xMinMax.first; - bounds[1] = yMinMax.first; - bounds[2] = zMinMax.first; - bounds[3] = xMinMax.second; - bounds[4] = yMinMax.second; - bounds[5] = zMinMax.second; -} - // ----------------------------------------------------------------------------- Result<> ComputeVertexToTriangleDistances::operator()() { auto& vertexGeom = m_DataStructure.getDataRefAs(m_InputValues->VertexDataContainer); - IGeometry::SharedVertexList& sourceVertices = vertexGeom.getVerticesRef(); + SharedVertexListT& sourceVertices = vertexGeom.getVertices()->getDataStoreRef(); m_TotalElements = vertexGeom.getNumberOfVertices(); auto& triangleGeom = m_DataStructure.getDataRefAs(m_InputValues->TriangleDataContainer); auto numTris = static_cast(triangleGeom.getNumberOfFaces()); - IGeometry::SharedTriList& triangles = triangleGeom.getFacesRef(); - IGeometry::SharedVertexList& vertices = triangleGeom.getVerticesRef(); + const SharedTriListT& triangles = triangleGeom.getFaces()->getDataStoreRef(); + const SharedVertexListT& vertices = triangleGeom.getVertices()->getDataStoreRef(); RTreeType m_RTree; // Populate the RTree @@ -501,10 +500,10 @@ Result<> ComputeVertexToTriangleDistances::operator()() m_RTree.Insert(triBoundsArray.data() + (6 * triIndex), triBoundsArray.data() + (6 * triIndex) + 3, triIndex); // Note, all values including zero are fine in this version } - const auto& normalsArray = m_DataStructure.getDataRefAs(m_InputValues->TriangleNormalsArrayPath); - auto& distancesArray = m_DataStructure.getDataRefAs(m_InputValues->DistancesArrayPath); + const auto& normalsArray = m_DataStructure.getDataAs(m_InputValues->TriangleNormalsArrayPath)->getDataStoreRef(); + auto& distancesArray = m_DataStructure.getDataAs(m_InputValues->DistancesArrayPath)->getDataStoreRef(); distancesArray.fill(std::numeric_limits::max()); - auto& closestTriangleIdsArray = m_DataStructure.getDataRefAs(m_InputValues->ClosestTriangleIdArrayPath); + auto& closestTriangleIdsArray = m_DataStructure.getDataAs(m_InputValues->ClosestTriangleIdArrayPath)->getDataStoreRef(); closestTriangleIdsArray.fill(-1); // -1 means it never found the closest triangle? // Allow data-based parallelization diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ConvertColorToGrayScale.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ConvertColorToGrayScale.cpp index c37c8f3e10..0647dd5393 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ConvertColorToGrayScale.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ConvertColorToGrayScale.cpp @@ -2,7 +2,6 @@ #include "simplnx/Common/Array.hpp" #include "simplnx/Common/Range.hpp" -#include "simplnx/Core/Application.hpp" #include "simplnx/Core/Preferences.hpp" #include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/DataStructure/DataGroup.hpp" @@ -12,11 +11,11 @@ using namespace nx::core; namespace { - +template class LuminosityImpl { public: - LuminosityImpl(const UInt8Array& data, UInt8Array& outputData, const FloatVec3& colorWeights, size_t numComp) + LuminosityImpl(const UInt8AbstractDataStore& data, UInt8AbstractDataStore& outputData, const FloatVec3& colorWeights, size_t numComp) : m_ImageData(data) , m_FlatImageData(outputData) , m_ColorWeights(colorWeights) @@ -36,9 +35,18 @@ class LuminosityImpl { for(size_t i = start; i < end; i++) { - auto temp = static_cast( - roundf((m_ImageData.at(m_NumComp * i) * m_ColorWeights.getX()) + (m_ImageData.at(m_NumComp * i + 1) * m_ColorWeights.getY()) + (m_ImageData.at(m_NumComp * i + 2) * m_ColorWeights.getZ()))); - m_FlatImageData.setValue(i, static_cast(temp)); + if constexpr(BoundsCheckV) + { + auto temp = static_cast(roundf((m_ImageData.at(m_NumComp * i) * m_ColorWeights.getX()) + (m_ImageData.at(m_NumComp * i + 1) * m_ColorWeights.getY()) + + (m_ImageData.at(m_NumComp * i + 2) * m_ColorWeights.getZ()))); + m_FlatImageData.setValue(i, static_cast(temp)); + } + else + { + auto temp = static_cast( + roundf((m_ImageData[m_NumComp * i] * m_ColorWeights.getX()) + (m_ImageData[m_NumComp * i + 1] * m_ColorWeights.getY()) + (m_ImageData[m_NumComp * i + 2] * m_ColorWeights.getZ()))); + m_FlatImageData.setValue(i, static_cast(temp)); + } } } @@ -48,8 +56,8 @@ class LuminosityImpl } private: - const UInt8Array& m_ImageData; - UInt8Array& m_FlatImageData; + const UInt8AbstractDataStore& m_ImageData; + UInt8AbstractDataStore& m_FlatImageData; const FloatVec3& m_ColorWeights; size_t m_NumComp; }; @@ -57,7 +65,7 @@ class LuminosityImpl class LightnessImpl { public: - LightnessImpl(const UInt8Array& data, UInt8Array& outputData, size_t numComp) + LightnessImpl(const UInt8AbstractDataStore& data, UInt8AbstractDataStore& outputData, size_t numComp) : m_ImageData(data) , m_FlatImageData(outputData) , m_NumComp(numComp) @@ -84,16 +92,16 @@ class LightnessImpl } private: - const UInt8Array& m_ImageData; - UInt8Array& m_FlatImageData; + const UInt8AbstractDataStore& m_ImageData; + UInt8AbstractDataStore& m_FlatImageData; size_t m_NumComp; }; +template class SingleChannelImpl { - public: - SingleChannelImpl(const UInt8Array& data, UInt8Array& outputData, size_t numComp, int32_t channel) + SingleChannelImpl(const UInt8AbstractDataStore& data, UInt8AbstractDataStore& outputData, size_t numComp, int32_t channel) : m_ImageData(data) , m_FlatImageData(outputData) , m_NumComp(numComp) @@ -110,7 +118,14 @@ class SingleChannelImpl { for(size_t i = start; i < end; i++) { - m_FlatImageData.setValue(i, static_cast((m_ImageData.at(m_NumComp * i + static_cast(m_Channel))))); + if constexpr(BoundsCheckV) + { + m_FlatImageData.setValue(i, m_ImageData.at(m_NumComp * i + static_cast(m_Channel))); + } + else + { + m_FlatImageData.setValue(i, m_ImageData[m_NumComp * i + static_cast(m_Channel)]); + } } } @@ -120,8 +135,8 @@ class SingleChannelImpl } private: - const UInt8Array& m_ImageData; - UInt8Array& m_FlatImageData; + const UInt8AbstractDataStore& m_ImageData; + UInt8AbstractDataStore& m_FlatImageData; size_t m_NumComp; int32_t m_Channel; }; @@ -136,11 +151,11 @@ class ParallelWrapper ParallelWrapper& operator=(ParallelWrapper&&) = delete; // Move Assignment Not Implemented template - static void Run(T impl, size_t totalPoints, typename IParallelAlgorithm::AlgorithmArrays algArrays) + static void Run(T impl, size_t totalPoints, const typename IParallelAlgorithm::AlgorithmStores& algStores) { ParallelDataAlgorithm dataAlg; dataAlg.setRange(0, totalPoints); - dataAlg.requireArraysInMemory(algArrays); + dataAlg.requireStoresInMemory(algStores); dataAlg.execute(impl); } @@ -180,32 +195,56 @@ Result<> ConvertColorToGrayScale::operator()() { break; } - const auto& inputColorData = m_DataStructure.getDataRefAs(arrayPath); - auto& outputGrayData = m_DataStructure.getDataRefAs(*outputPathIter); + const auto& inputColorData = m_DataStructure.getDataAs(arrayPath)->getDataStoreRef(); + auto& outputGrayData = m_DataStructure.getDataAs(*outputPathIter)->getDataStoreRef(); auto convType = static_cast(m_InputValues->ConversionAlgorithm); size_t comp = inputColorData.getNumberOfComponents(); size_t totalPoints = inputColorData.getNumberOfTuples(); - typename IParallelAlgorithm::AlgorithmArrays algArrays; - algArrays.push_back(&inputColorData); - algArrays.push_back(&outputGrayData); + typename IParallelAlgorithm::AlgorithmStores algStores; + algStores.push_back(&inputColorData); + algStores.push_back(&outputGrayData); switch(convType) { case ConversionType::Luminosity: - ParallelWrapper::Run(LuminosityImpl(inputColorData, outputGrayData, m_InputValues->ColorWeights, comp), totalPoints, algArrays); + if(comp < 3) // Pre-check bounds to try to avoid `.at()`; algorithm hardcoded a component access size of 3 + { + // Do bounds check + ParallelWrapper::Run>(LuminosityImpl(inputColorData, outputGrayData, m_InputValues->ColorWeights, comp), totalPoints, algStores); + } + else + { + ParallelWrapper::Run>(LuminosityImpl(inputColorData, outputGrayData, m_InputValues->ColorWeights, comp), totalPoints, algStores); + } break; case ConversionType::Average: - ParallelWrapper::Run(LuminosityImpl(inputColorData, outputGrayData, {0.3333f, 0.3333f, 0.3333f}, comp), totalPoints, algArrays); + if(comp < 3) // Pre-check bounds to try to avoid `.at()`; algorithm hardcoded a component access size of 3 + { + // Do bounds check + ParallelWrapper::Run>(LuminosityImpl(inputColorData, outputGrayData, {0.3333f, 0.3333f, 0.3333f}, comp), totalPoints, algStores); + } + else + { + ParallelWrapper::Run>(LuminosityImpl(inputColorData, outputGrayData, {0.3333f, 0.3333f, 0.3333f}, comp), totalPoints, algStores); + } break; case ConversionType::Lightness: { - ParallelWrapper::Run(LightnessImpl(inputColorData, outputGrayData, comp), totalPoints, algArrays); + ParallelWrapper::Run(LightnessImpl(inputColorData, outputGrayData, comp), totalPoints, algStores); break; } case ConversionType::SingleChannel: - ParallelWrapper::Run(SingleChannelImpl(inputColorData, outputGrayData, comp, m_InputValues->ColorChannel), totalPoints, algArrays); + if(comp * (totalPoints - 1) + m_InputValues->ColorChannel < inputColorData.getSize()) // Pre-check bounds to try to avoid `.at()` + { + // Do bounds check + ParallelWrapper::Run>(SingleChannelImpl(inputColorData, outputGrayData, comp, m_InputValues->ColorChannel), totalPoints, algStores); + } + else + { + ParallelWrapper::Run>(SingleChannelImpl(inputColorData, outputGrayData, comp, m_InputValues->ColorChannel), totalPoints, algStores); + } break; } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.cpp index c789392b18..ee4795e840 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.cpp @@ -13,7 +13,7 @@ namespace { std::array ax2om(const std::array& a) { - std::array res; + std::array res = {}; float32 q = 0.0L; float32 c = 0.0L; float32 s = 0.0L; @@ -71,6 +71,59 @@ ImageRotationUtilities::Matrix3fR toGMatrix(std::array om) g(2, 2) = om[8]; return g; } + +// ----------------------------------------------------------------------------- +char determineIntersectCoord(const std::array& p1, const std::array& q1, const std::array& p2, const std::array& q2, float32& coordX) +{ + // assumes p1q1 is the hatch vector and p2q2 is the CAD edge + // also assumes the p1q1 is in x direction only so can just check y coords for potential intersection + float32 x1 = p1[0]; + float32 x2 = q1[0]; + float32 x3 = p2[0]; + float32 x4 = q2[0]; + float32 y1 = p1[1]; + // float32 y2 = q1[1]; + float32 y3 = p2[1]; + float32 y4 = q2[1]; + + if(y3 > y1 && y4 > y1) + { + return 'n'; + } + if(y3 < y1 && y4 < y1) + { + return 'n'; + } + if(y3 == y1 && y4 == y1) + { + return 'n'; + } + if(y3 == y1) + { + coordX = x3; + if(x3 >= x1 && x3 <= x2) + { + return 'c'; + } + return 'n'; + } + if(y4 == y1) + { + coordX = x4; + if(x4 >= x1 && x4 <= x2) + { + return 'd'; + } + return 'n'; + } + float32 frac = (y1 - y3) / (y4 - y3); + coordX = x3 + (frac * (x4 - x3)); + if(coordX >= x1 && coordX <= x2) + { + return 'i'; + } + return 'n'; +} } // namespace // ----------------------------------------------------------------------------- @@ -98,8 +151,8 @@ Result<> CreateAMScanPaths::operator()() auto& CADLayers = m_DataStructure.getDataRefAs(m_InputValues->CADSliceDataContainerName); INodeGeometry1D::SharedEdgeList& CADLayerEdges = CADLayers.getEdgesRef(); INodeGeometry0D::SharedVertexList& CADLayerVerts = CADLayers.getVerticesRef(); - auto& cadSliceIds = m_DataStructure.getDataRefAs(m_InputValues->CADSliceIdsArrayPath); - auto& cadRegionIds = m_DataStructure.getDataRefAs(m_InputValues->CADRegionIdsArrayPath); + auto& cadSliceIds = m_DataStructure.getDataAs(m_InputValues->CADSliceIdsArrayPath)->getDataStoreRef(); + auto& cadRegionIds = m_DataStructure.getDataAs(m_InputValues->CADRegionIdsArrayPath)->getDataStoreRef(); usize numCADLayerEdges = CADLayers.getNumberOfEdges(); usize numCADLayerVerts = CADLayers.getNumberOfVertices(); int32 numCADLayers = 0; @@ -519,19 +572,19 @@ Result<> CreateAMScanPaths::operator()() usize numHatchVerts = 2 * hatchCount; fitHatches.resizeVertexList(numHatchVerts); fitHatches.resizeEdgeList(hatchCount); - INodeGeometry0D::SharedVertexList& hatchVerts = fitHatches.getVerticesRef(); - INodeGeometry1D::SharedEdgeList& hatches = fitHatches.getEdgesRef(); + AbstractDataStore& hatchVerts = fitHatches.getVertices()->getDataStoreRef(); + AbstractDataStore& hatches = fitHatches.getEdges()->getDataStoreRef(); std::vector tDims(1, numHatchVerts); fitHatches.getVertexAttributeMatrix()->resizeTuples(tDims); tDims[0] = hatchCount; fitHatches.getEdgeAttributeMatrix()->resizeTuples(tDims); - auto& times = - m_DataStructure.getDataRefAs(m_InputValues->HatchDataContainerName.createChildPath(m_InputValues->VertexAttributeMatrixName).createChildPath(m_InputValues->TimeArrayName)); + auto& times = m_DataStructure.getDataAs(m_InputValues->HatchDataContainerName.createChildPath(m_InputValues->VertexAttributeMatrixName).createChildPath(m_InputValues->TimeArrayName)) + ->getDataStoreRef(); const DataPath hatchAttributeMatrixPath = m_InputValues->HatchDataContainerName.createChildPath(m_InputValues->HatchAttributeMatrixName); - auto& powers = m_DataStructure.getDataRefAs(hatchAttributeMatrixPath.createChildPath(m_InputValues->PowersArrayName)); - auto& hatchSliceIds = m_DataStructure.getDataRefAs(hatchAttributeMatrixPath.createChildPath(m_InputValues->CADSliceIdsArrayPath.getTargetName())); - auto& hatchRegionIds = m_DataStructure.getDataRefAs(hatchAttributeMatrixPath.createChildPath(m_InputValues->RegionIdsArrayName)); + auto& powers = m_DataStructure.getDataAs(hatchAttributeMatrixPath.createChildPath(m_InputValues->PowersArrayName))->getDataStoreRef(); + auto& hatchSliceIds = m_DataStructure.getDataAs(hatchAttributeMatrixPath.createChildPath(m_InputValues->CADSliceIdsArrayPath.getTargetName()))->getDataStoreRef(); + auto& hatchRegionIds = m_DataStructure.getDataAs(hatchAttributeMatrixPath.createChildPath(m_InputValues->RegionIdsArrayName))->getDataStoreRef(); if(getCancel()) { @@ -608,56 +661,3 @@ Result<> CreateAMScanPaths::operator()() return {}; } - -// ----------------------------------------------------------------------------- -char CreateAMScanPaths::determineIntersectCoord(const std::array& p1, const std::array& q1, const std::array& p2, const std::array& q2, float32& coordX) -{ - // assumes p1q1 is the hatch vector and p2q2 is the CAD edge - // also assumes the p1q1 is in x direction only so can just check y coords for potential intersection - float32 x1 = p1[0]; - float32 x2 = q1[0]; - float32 x3 = p2[0]; - float32 x4 = q2[0]; - float32 y1 = p1[1]; - // float32 y2 = q1[1]; - float32 y3 = p2[1]; - float32 y4 = q2[1]; - - if(y3 > y1 && y4 > y1) - { - return 'n'; - } - if(y3 < y1 && y4 < y1) - { - return 'n'; - } - if(y3 == y1 && y4 == y1) - { - return 'n'; - } - if(y3 == y1) - { - coordX = x3; - if(x3 >= x1 && x3 <= x2) - { - return 'c'; - } - return 'n'; - } - if(y4 == y1) - { - coordX = x4; - if(x4 >= x1 && x4 <= x2) - { - return 'd'; - } - return 'n'; - } - float32 frac = (y1 - y3) / (y4 - y3); - coordX = x3 + (frac * (x4 - x3)); - if(coordX >= x1 && coordX <= x2) - { - return 'i'; - } - return 'n'; -} diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.hpp index a4eef171ec..d2e9100b5d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.hpp @@ -12,7 +12,6 @@ namespace nx::core { - struct SIMPLNXCORE_EXPORT CreateAMScanPathsInputValues { float32 StripeWidth; @@ -50,9 +49,6 @@ class SIMPLNXCORE_EXPORT CreateAMScanPaths const std::atomic_bool& getCancel(); -protected: - char determineIntersectCoord(const std::array& p1, const std::array& q1, const std::array& p2, const std::array& q2, float32& coordX); - private: DataStructure& m_DataStructure; const CreateAMScanPathsInputValues* m_InputValues = nullptr; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateColorMap.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateColorMap.cpp index 6b3019886b..d8fee0b92b 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateColorMap.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateColorMap.cpp @@ -40,33 +40,33 @@ template class CreateColorMapImpl { public: - CreateColorMapImpl(const DataArray& arrayPtr, const std::vector& binPoints, const std::vector& controlPoints, int numControlColors, UInt8Array& colorArray, + CreateColorMapImpl(const AbstractDataStore& arrayStore, const std::vector& binPoints, const std::vector& controlPoints, int numControlColors, UInt8AbstractDataStore& colorStore, const nx::core::IDataArray* goodVoxels, const std::vector& invalidColor) - : m_ArrayPtr(arrayPtr) + : m_ArrayStore(arrayStore) , m_BinPoints(binPoints) , m_NumControlColors(numControlColors) , m_ControlPoints(controlPoints) - , m_ColorArray(colorArray) - , m_ArrayMin(arrayPtr[0]) - , m_ArrayMax(arrayPtr[0]) + , m_ColorStore(colorStore) + , m_ArrayMin(arrayStore[0]) + , m_ArrayMax(arrayStore[0]) , m_GoodVoxels(goodVoxels) , m_InvalidColor(invalidColor) { - for(int i = 1; i < arrayPtr.getNumberOfTuples(); i++) + for(usize i = 1; i < arrayStore.getNumberOfTuples(); i++) { - if(arrayPtr[i] < m_ArrayMin) + if(arrayStore[i] < m_ArrayMin) { - m_ArrayMin = arrayPtr[i]; + m_ArrayMin = arrayStore[i]; } - if(arrayPtr[i] > m_ArrayMax) + if(arrayStore[i] > m_ArrayMax) { - m_ArrayMax = arrayPtr[i]; + m_ArrayMax = arrayStore[i]; } } } template - void convert(size_t start, size_t end) const + void convert(usize start, usize end) const { using MaskArrayType = DataArray; const MaskArrayType* maskArray = nullptr; @@ -74,7 +74,6 @@ class CreateColorMapImpl { maskArray = dynamic_cast(m_GoodVoxels); } - auto& colorArrayDS = m_ColorArray.getDataStoreRef(); for(size_t i = start; i < end; i++) { @@ -83,15 +82,15 @@ class CreateColorMapImpl { if(!(*maskArray)[i]) { - colorArrayDS.setComponent(i, 0, m_InvalidColor[0]); - colorArrayDS.setComponent(i, 1, m_InvalidColor[1]); - colorArrayDS.setComponent(i, 2, m_InvalidColor[2]); + m_ColorStore.setComponent(i, 0, m_InvalidColor[0]); + m_ColorStore.setComponent(i, 1, m_InvalidColor[1]); + m_ColorStore.setComponent(i, 2, m_InvalidColor[2]); continue; } } // Normalize value - const float32 nValue = (static_cast(m_ArrayPtr[i] - m_ArrayMin)) / static_cast((m_ArrayMax - m_ArrayMin)); + const float32 nValue = (static_cast(m_ArrayStore[i] - m_ArrayMin)) / static_cast((m_ArrayMax - m_ArrayMin)); int rightBinIndex = findRightBinIndex(nValue, m_BinPoints); @@ -128,9 +127,9 @@ class CreateColorMapImpl const unsigned char blueVal = (m_ControlPoints[leftBinIndex * k_ControlPointCompSize + 3] * (1.0 - currFraction) + m_ControlPoints[rightBinIndex * k_ControlPointCompSize + 3] * currFraction) * 255; - colorArrayDS.setComponent(i, 0, redVal); - colorArrayDS.setComponent(i, 1, greenVal); - colorArrayDS.setComponent(i, 2, blueVal); + m_ColorStore.setComponent(i, 0, redVal); + m_ColorStore.setComponent(i, 1, greenVal); + m_ColorStore.setComponent(i, 2, blueVal); } } @@ -154,13 +153,13 @@ class CreateColorMapImpl } private: - const DataArray& m_ArrayPtr; + const AbstractDataStore& m_ArrayStore; const std::vector& m_BinPoints; T m_ArrayMin; T m_ArrayMax; int m_NumControlColors; const std::vector& m_ControlPoints; - UInt8Array& m_ColorArray; + UInt8AbstractDataStore& m_ColorStore; const nx::core::IDataArray* m_GoodVoxels = nullptr; const std::vector& m_InvalidColor; }; @@ -189,7 +188,7 @@ struct GenerateColorArrayFunctor binPoint = (binPoint - binMin) / (binMax - binMin); } - auto& colorArray = dataStructure.getDataRefAs(inputValues->RgbArrayPath); + auto& colorArray = dataStructure.getDataAs(inputValues->RgbArrayPath)->getDataStoreRef(); nx::core::IDataArray* goodVoxelsArray = nullptr; if(inputValues->UseMask) @@ -197,10 +196,10 @@ struct GenerateColorArrayFunctor goodVoxelsArray = dataStructure.getDataAs(inputValues->MaskArrayPath); } - const DataArray& arrayRef = dataStructure.getDataRefAs>(inputValues->SelectedDataArrayPath); + const AbstractDataStore& arrayRef = dataStructure.getDataAs>(inputValues->SelectedDataArrayPath)->getDataStoreRef(); if(arrayRef.getNumberOfTuples() <= 0) { - return MakeErrorResult(-34381, fmt::format("Array {} is empty", arrayRef.getName())); + return MakeErrorResult(-34381, fmt::format("Array {} is empty", inputValues->SelectedDataArrayPath.getTargetName())); } ParallelDataAlgorithm dataAlg; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/DBSCAN.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/DBSCAN.cpp index a36303bd4d..7471533f8c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/DBSCAN.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/DBSCAN.cpp @@ -306,22 +306,22 @@ struct DBSCANFunctor { if(useRandom) { - DBSCANTemplate(filter, dynamic_cast&>(inputIDataArray).getDataStoreRef(), maskCompare, fIds.getDataStoreRef(), epsilon, minPoints, distMetric, seed)(); + DBSCANTemplate(filter, inputIDataArray.template getIDataStoreRefAs>(), maskCompare, fIds.getDataStoreRef(), epsilon, minPoints, distMetric, seed)(); } else { - DBSCANTemplate(filter, dynamic_cast&>(inputIDataArray).getDataStoreRef(), maskCompare, fIds.getDataStoreRef(), epsilon, minPoints, distMetric, seed)(); + DBSCANTemplate(filter, inputIDataArray.template getIDataStoreRefAs>(), maskCompare, fIds.getDataStoreRef(), epsilon, minPoints, distMetric, seed)(); } } else { if(useRandom) { - DBSCANTemplate(filter, dynamic_cast&>(inputIDataArray).getDataStoreRef(), maskCompare, fIds.getDataStoreRef(), epsilon, minPoints, distMetric, seed)(); + DBSCANTemplate(filter, inputIDataArray.template getIDataStoreRefAs>(), maskCompare, fIds.getDataStoreRef(), epsilon, minPoints, distMetric, seed)(); } else { - DBSCANTemplate(filter, dynamic_cast&>(inputIDataArray).getDataStoreRef(), maskCompare, fIds.getDataStoreRef(), epsilon, minPoints, distMetric, seed)(); + DBSCANTemplate(filter, inputIDataArray.template getIDataStoreRefAs>(), maskCompare, fIds.getDataStoreRef(), epsilon, minPoints, distMetric, seed)(); } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp index c024810f1e..887ed2394f 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateBadData.cpp @@ -15,8 +15,8 @@ class ErodeDilateBadDataTransferDataImpl ErodeDilateBadDataTransferDataImpl() = delete; ErodeDilateBadDataTransferDataImpl(const ErodeDilateBadDataTransferDataImpl&) = default; - ErodeDilateBadDataTransferDataImpl(ErodeDilateBadData* filterAlg, usize totalPoints, ChoicesParameter::ValueType operation, const Int32Array& featureIds, const std::vector& neighbors, - const std::shared_ptr& dataArrayPtr) + ErodeDilateBadDataTransferDataImpl(ErodeDilateBadData* filterAlg, usize totalPoints, ChoicesParameter::ValueType operation, const Int32AbstractDataStore& featureIds, + const std::vector& neighbors, const std::shared_ptr& dataArrayPtr) : m_FilterAlg(filterAlg) , m_TotalPoints(totalPoints) , m_Operation(operation) @@ -63,7 +63,7 @@ class ErodeDilateBadDataTransferDataImpl ChoicesParameter::ValueType m_Operation = 0; std::vector m_Neighbors; const std::shared_ptr m_DataArrayPtr; - const Int32Array& m_FeatureIds; + const Int32AbstractDataStore& m_FeatureIds; }; } // namespace @@ -94,7 +94,7 @@ void ErodeDilateBadData::updateProgress(const std::string& progMessage) // ----------------------------------------------------------------------------- Result<> ErodeDilateBadData::operator()() { - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + const auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); const usize totalPoints = featureIds.getNumberOfTuples(); std::vector neighbors(totalPoints, -1); @@ -234,6 +234,7 @@ Result<> ErodeDilateBadData::operator()() { continue; } + taskRunner.execute(ErodeDilateBadDataTransferDataImpl(this, totalPoints, m_InputValues->Operation, featureIds, neighbors, voxelArray)); } taskRunner.wait(); // This will spill over if the number of DataArrays to process does not divide evenly by the number of threads. diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateCoordinationNumber.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateCoordinationNumber.cpp index 44702d5514..c11d7f94d8 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateCoordinationNumber.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ErodeDilateCoordinationNumber.cpp @@ -6,7 +6,8 @@ #include "simplnx/Utilities/FilterUtilities.hpp" using namespace nx::core; - +namespace +{ struct DataArrayCopyTupleFunctor { template @@ -17,6 +18,7 @@ struct DataArrayCopyTupleFunctor outputArray.copyTuple(sourceIndex, targetIndex); } }; +} // namespace // ----------------------------------------------------------------------------- ErodeDilateCoordinationNumber::ErodeDilateCoordinationNumber(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, @@ -191,10 +193,10 @@ Result<> ErodeDilateCoordinationNumber::operator()() } for(int64 zIndex = 0; zIndex < dims[2]; zIndex++) { - const int64 zStride = static_cast(dims[0] * dims[1] * zIndex); + const auto zStride = static_cast(dims[0] * dims[1] * zIndex); for(int64 yIndex = 0; yIndex < dims[1]; yIndex++) { - const int64 yStride = static_cast(dims[0] * yIndex); + const auto yStride = static_cast(dims[0] * yIndex); for(int64 xIndex = 0; xIndex < dims[0]; xIndex++) { const int64 voxelIndex = zStride + yStride + xIndex; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractComponentAsArray.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractComponentAsArray.cpp index 3c07cc5c67..f778c33010 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractComponentAsArray.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractComponentAsArray.cpp @@ -10,13 +10,13 @@ namespace struct RemoveComponentsFunctor { template - void operator()(IDataArray& originalArray, IDataArray& resizedArray, usize componentIndexToRemove) // Due to logic structure originalArray cannot be const + void operator()(IDataArray* originalArray, IDataArray* resizedArray, usize componentIndexToRemove) // Due to logic structure originalArray cannot be const { - const auto& originalArrayRef = dynamic_cast&>(originalArray); - auto& resizedArrayRef = dynamic_cast&>(resizedArray); + const auto& originalStoreRef = originalArray->template getIDataStoreRefAs>(); + auto& resizedStoreRef = resizedArray->template getIDataStoreRefAs>(); - const usize originalTupleCount = originalArrayRef.getNumberOfTuples(); - const usize originalCompCount = originalArrayRef.getNumberOfComponents(); + const usize originalTupleCount = originalStoreRef.getNumberOfTuples(); + const usize originalCompCount = originalStoreRef.getNumberOfComponents(); usize distanceToShuffle = 0; for(usize tuple = 0; tuple < originalTupleCount; tuple++) @@ -29,7 +29,7 @@ struct RemoveComponentsFunctor continue; } const usize index = tuple * originalCompCount + comp; - resizedArrayRef[index - distanceToShuffle] = originalArrayRef[index]; + resizedStoreRef[index - distanceToShuffle] = originalStoreRef[index]; } } @@ -40,15 +40,13 @@ struct RemoveComponentsFunctor struct ExtractComponentsFunctor { template - void operator()(IDataArray& inputArray, IDataArray& extractedCompArray, usize componentIndexToExtract) // Due to logic structure inputArray cannot be const + void operator()(IDataArray* inputArray, IDataArray* extractedCompArray, usize componentIndexToExtract) // Due to logic structure inputArray cannot be const { - const auto& inputArrayRef = dynamic_cast&>(inputArray); - auto& extractedArrayRef = dynamic_cast&>(extractedCompArray); + const auto& inputStoreRef = inputArray->template getIDataStoreRefAs>(); + auto& extractedStoreRef = extractedCompArray->template getIDataStoreRefAs>(); - const usize inputTupleCount = inputArrayRef.getNumberOfTuples(); - const usize inputCompCount = inputArrayRef.getNumberOfComponents(); - - const usize extractedCompCount = extractedArrayRef.getNumberOfComponents(); + const usize inputTupleCount = inputStoreRef.getNumberOfTuples(); + const usize inputCompCount = inputStoreRef.getNumberOfComponents(); for(usize tuple = 0; tuple < inputTupleCount; tuple++) { @@ -56,7 +54,7 @@ struct ExtractComponentsFunctor { if(comp == componentIndexToExtract) { - extractedArrayRef[tuple] = inputArrayRef[tuple * inputCompCount + comp]; // extracted array will always have comp count of 1 + extractedStoreRef[tuple] = inputStoreRef[tuple * inputCompCount + comp]; // extracted array will always have comp count of 1 } } } @@ -92,23 +90,23 @@ Result<> ExtractComponentAsArray::operator()() const bool removeComponentsFromArrayBool = m_InputValues->RemoveComponentsFromArray; const auto compToRemoveNum = static_cast(abs(m_InputValues->CompNumber)); // this will be the original array if components are not being removed, else it is resized array - auto& baseArrayRef = m_DataStructure.getDataRefAs(m_InputValues->BaseArrayPath); + auto* baseArrayPtr = m_DataStructure.getDataAs(m_InputValues->BaseArrayPath); if((!removeComponentsFromArrayBool) && moveComponentsToNewArrayBool) { - ExecuteDataFunction(ExtractComponentsFunctor{}, baseArrayRef.getDataType(), baseArrayRef, m_DataStructure.getDataRefAs(m_InputValues->NewArrayPath), compToRemoveNum); + ExecuteDataFunction(ExtractComponentsFunctor{}, baseArrayPtr->getDataType(), baseArrayPtr, m_DataStructure.getDataAs(m_InputValues->NewArrayPath), compToRemoveNum); return {}; } // will not exist if remove components is not occurring, hence the early bailout ^ - auto& tempArrayRef = m_DataStructure.getDataRefAs(m_InputValues->TempArrayPath); // will not exist if remove components is not true, hence the early bailout ^ + auto* tempArrayPtr = m_DataStructure.getDataAs(m_InputValues->TempArrayPath); // will not exist if remove components is not true, hence the early bailout ^ if(moveComponentsToNewArrayBool) { - auto& extractedCompArrayRef = m_DataStructure.getDataRefAs(m_InputValues->NewArrayPath); - ExecuteDataFunction(ExtractComponentsFunctor{}, tempArrayRef.getDataType(), tempArrayRef, extractedCompArrayRef, compToRemoveNum); + auto* extractedCompArrayPtr = m_DataStructure.getDataAs(m_InputValues->NewArrayPath); + ExecuteDataFunction(ExtractComponentsFunctor{}, tempArrayPtr->getDataType(), tempArrayPtr, extractedCompArrayPtr, compToRemoveNum); } // remove by default, because the only case where they weren't removed was covered at start - ExecuteDataFunction(RemoveComponentsFunctor{}, tempArrayRef.getDataType(), tempArrayRef, baseArrayRef, compToRemoveNum); + ExecuteDataFunction(RemoveComponentsFunctor{}, tempArrayPtr->getDataType(), tempArrayPtr, baseArrayPtr, compToRemoveNum); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.cpp index bc13119988..c9f983677a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ExtractVertexGeometry.cpp @@ -13,22 +13,20 @@ namespace struct CopyDataFunctor { template - void copyTuple(const DataArray& srcArray, DataArray& destArray, usize srcTupleIdx, usize destTupleIndex) + void copyTuple(const AbstractDataStore& srcStore, AbstractDataStore& destStore, usize srcTupleIdx, usize destTupleIndex) { - usize numComps = srcArray.getNumberOfComponents(); + usize numComps = srcStore.getNumberOfComponents(); for(usize cIdx = 0; cIdx < numComps; cIdx++) { - destArray[destTupleIndex * numComps + cIdx] = srcArray[srcTupleIdx * numComps + cIdx]; + destStore[destTupleIndex * numComps + cIdx] = srcStore[srcTupleIdx * numComps + cIdx]; } } template - void operator()(const IDataArray& srcIArray, IDataArray& destIArray, const std::vector& maskArray) + void operator()(const IDataArray* srcIArray, IDataArray* destIArray, const std::vector& maskArray) { - using DataArrayType = DataArray; - - const DataArrayType& srcArray = dynamic_cast(srcIArray); - DataArrayType& destArray = dynamic_cast(destIArray); + const auto& srcArray = srcIArray->template getIDataStoreRefAs>(); + auto& destArray = destIArray->template getIDataStoreRefAs>(); bool useMask = !maskArray.empty(); usize destTupleIdx = 0; @@ -71,8 +69,8 @@ const std::atomic_bool& ExtractVertexGeometry::getCancel() // ----------------------------------------------------------------------------- Result<> ExtractVertexGeometry::operator()() { - const IGridGeometry& inputGeometry = m_DataStructure.getDataRefAs(m_InputValues->InputGeometryPath); - VertexGeom& vertexGeometry = m_DataStructure.getDataRefAs(m_InputValues->VertexGeometryPath); + const auto& inputGeometry = m_DataStructure.getDataRefAs(m_InputValues->InputGeometryPath); + auto& vertexGeometry = m_DataStructure.getDataRefAs(m_InputValues->VertexGeometryPath); SizeVec3 dims = inputGeometry.getDimensions(); const usize cellCount = std::accumulate(dims.begin(), dims.end(), static_cast(1), std::multiplies<>()); @@ -157,10 +155,10 @@ Result<> ExtractVertexGeometry::operator()() vertexAttrMatrix.resizeTuples({vertexCount}); for(const auto& dataArrayPath : m_InputValues->IncludedDataArrayPaths) { - const IDataArray& srcIDataArray = m_DataStructure.getDataRefAs(dataArrayPath); - DataPath destDataArrayPath = vertexAttributeMatrixDataPath.createChildPath(srcIDataArray.getName()); - IDataArray& destDataArray = m_DataStructure.getDataRefAs(destDataArrayPath); - ExecuteDataFunction(CopyDataFunctor{}, srcIDataArray.getDataType(), srcIDataArray, destDataArray, maskedPoints); + const auto* srcIDataArray = m_DataStructure.getDataAs(dataArrayPath); + DataPath destDataArrayPath = vertexAttributeMatrixDataPath.createChildPath(srcIDataArray->getName()); + auto* destDataArray = m_DataStructure.getDataAs(destDataArrayPath); + ExecuteDataFunction(CopyDataFunctor{}, srcIDataArray->getDataType(), srcIDataArray, destDataArray, maskedPoints); } } @@ -176,9 +174,9 @@ Result<> ExtractVertexGeometry::operator()() { DataPath srcDataArrayPath = vertexAttributeMatrixDataPath.createChildPath(dataArrayPath.getTargetName()); DataPath destDataArrayPath = vertexAttributeMatrixDataPath.createChildPath(dataArrayPath.getTargetName()); - const IDataArray& srcIDataArray = m_DataStructure.getDataRefAs(srcDataArrayPath); - IDataArray& destDataArray = m_DataStructure.getDataRefAs(destDataArrayPath); - ExecuteDataFunction(CopyDataFunctor{}, srcIDataArray.getDataType(), srcIDataArray, destDataArray, maskedPoints); + const auto* srcIDataArray = m_DataStructure.getDataAs(srcDataArrayPath); + auto* destDataArray = m_DataStructure.getDataAs(destDataArrayPath); + ExecuteDataFunction(CopyDataFunctor{}, srcIDataArray->getDataType(), srcIDataArray, destDataArray, maskedPoints); } AttributeMatrix& vertexAttrMatrix = vertexGeometry.getVertexAttributeMatrixRef(); vertexAttrMatrix.resizeTuples({vertexCount}); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FillBadData.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FillBadData.cpp index f51b7db52a..30e15e25a1 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FillBadData.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FillBadData.cpp @@ -5,74 +5,45 @@ #include "simplnx/DataStructure/Geometry/ImageGeom.hpp" #include "simplnx/Utilities/DataGroupUtilities.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" -#include "simplnx/Utilities/ParallelTaskAlgorithm.hpp" using namespace nx::core; namespace { - -struct FillBadDataUpdateTuplesFunctor +template +void FillBadDataUpdateTuples(const Int32AbstractDataStore& featureIds, AbstractDataStore& outputDataStore, const std::vector& neighbors) { - template - void operator()(const Int32Array& featureIds, IDataArray& outputIDataArray, const std::vector& neighbors) + usize start = 0; + usize stop = outputDataStore.getNumberOfTuples(); + const usize numComponents = outputDataStore.getNumberOfComponents(); + for(usize tupleIndex = start; tupleIndex < stop; tupleIndex++) { - using DataArrayType = DataArray; - - DataArrayType outputArray = dynamic_cast(outputIDataArray); - size_t start = 0; - size_t stop = outputArray.getNumberOfTuples(); - for(size_t tupleIndex = start; tupleIndex < stop; tupleIndex++) + const int32 featureName = featureIds[tupleIndex]; + const int32 neighbor = neighbors[tupleIndex]; + if(neighbor == tupleIndex) { - const int32 featureName = featureIds[tupleIndex]; - const int32 neighbor = neighbors[tupleIndex]; - if(featureName < 0 && neighbor != -1 && featureIds[static_cast(neighbor)] > 0) - { - outputArray.copyTuple(neighbor, tupleIndex); - } + continue; } - } -}; -template -class FillBadDataUpdateTuples -{ -public: - FillBadDataUpdateTuples(const Int32Array& featureIds, DataArray& outputArray, const std::vector& neighbors) - : m_FeatureIds(featureIds) - , m_OutputArray(outputArray) - , m_Neighbors(neighbors) - { - } - ~FillBadDataUpdateTuples() = default; - - FillBadDataUpdateTuples(const FillBadDataUpdateTuples&) = default; // Copy Constructor Not Implemented - FillBadDataUpdateTuples(FillBadDataUpdateTuples&&) = delete; // Move Constructor Not Implemented - FillBadDataUpdateTuples& operator=(const FillBadDataUpdateTuples&) = delete; // Copy Assignment Not Implemented - FillBadDataUpdateTuples& operator=(FillBadDataUpdateTuples&&) = delete; // Move Assignment Not Implemented - - void convert(size_t start, size_t stop) const - { - for(size_t tupleIndex = start; tupleIndex < stop; tupleIndex++) + if(featureName < 0 && neighbor != -1 && featureIds[static_cast(neighbor)] > 0) { - const int32 featureName = m_FeatureIds[tupleIndex]; - const int32 neighbor = m_Neighbors[tupleIndex]; - if(featureName < 0 && neighbor != -1 && m_FeatureIds[static_cast(neighbor)] > 0) + for(usize i = 0; i < numComponents; i++) { - m_OutputArray.copyTuple(neighbor, tupleIndex); + auto value = outputDataStore[neighbor * numComponents + i]; + outputDataStore[tupleIndex * numComponents + i] = value; } } } +} - void operator()() const +struct FillBadDataUpdateTuplesFunctor +{ + template + void operator()(const Int32AbstractDataStore& featureIds, IDataArray* outputIDataArray, const std::vector& neighbors) { - convert(0, m_OutputArray.getNumberOfTuples()); + auto& outputStore = outputIDataArray->template getIDataStoreRefAs>(); + FillBadDataUpdateTuples(featureIds, outputStore, neighbors); } - -private: - const Int32Array& m_FeatureIds; - DataArray& m_OutputArray; - const std::vector& m_Neighbors; }; } // namespace @@ -97,12 +68,12 @@ const std::atomic_bool& FillBadData::getCancel() // ----------------------------------------------------------------------------- Result<> FillBadData::operator()() { - auto& m_FeatureIds = m_DataStructure.getDataRefAs(m_InputValues->featureIdsArrayPath); - const size_t totalPoints = m_FeatureIds.getNumberOfTuples(); + auto& featureIdsStore = m_DataStructure.getDataAs(m_InputValues->featureIdsArrayPath)->getDataStoreRef(); + const size_t totalPoints = featureIdsStore.getNumberOfTuples(); - std::vector m_Neighbors(totalPoints, -1); + std::vector neighbors(totalPoints, -1); - std::vector m_AlreadyChecked(totalPoints, false); + std::vector alreadyChecked(totalPoints, false); const auto& selectedImageGeom = m_DataStructure.getDataRefAs(m_InputValues->inputImageGeometry); @@ -139,7 +110,7 @@ Result<> FillBadData::operator()() for(size_t i = 0; i < totalPoints; i++) { - int32 featureName = m_FeatureIds[i]; + int32 featureName = featureIdsStore[i]; if(featureName > numFeatures) { numFeatures = featureName; @@ -162,16 +133,16 @@ Result<> FillBadData::operator()() for(size_t iter = 0; iter < totalPoints; iter++) { - m_AlreadyChecked[iter] = false; - if(m_FeatureIds[iter] != 0) + alreadyChecked[iter] = false; + if(featureIdsStore[iter] != 0) { - m_AlreadyChecked[iter] = true; + alreadyChecked[iter] = true; } } for(size_t i = 0; i < totalPoints; i++) { - if(!m_AlreadyChecked[i] && m_FeatureIds[i] == 0) + if(!alreadyChecked[i] && featureIdsStore[i] == 0) { currentVisitedList.push_back(static_cast(i)); count = 0; @@ -208,10 +179,10 @@ Result<> FillBadData::operator()() { continue; } - if(m_FeatureIds[neighbor] == 0 && !m_AlreadyChecked[neighbor]) + if(featureIdsStore[neighbor] == 0 && !alreadyChecked[neighbor]) { currentVisitedList.push_back(neighbor); - m_AlreadyChecked[neighbor] = true; + alreadyChecked[neighbor] = true; } } count++; @@ -220,7 +191,7 @@ Result<> FillBadData::operator()() { for(const auto& currentIndex : currentVisitedList) { - m_FeatureIds[currentIndex] = 0; + featureIdsStore[currentIndex] = 0; if(m_InputValues->storeAsNewPhase) { (*cellPhasesPtr)[currentIndex] = static_cast(maxPhase) + 1; @@ -231,7 +202,7 @@ Result<> FillBadData::operator()() { for(const auto& currentIndex : currentVisitedList) { - m_FeatureIds[currentIndex] = -1; + featureIdsStore[currentIndex] = -1; } } currentVisitedList.clear(); @@ -245,15 +216,15 @@ Result<> FillBadData::operator()() count = 0; for(size_t i = 0; i < totalPoints; i++) { - int32 featureName = m_FeatureIds[i]; + int32 featureName = featureIdsStore[i]; if(featureName < 0) { count++; // int32 current = 0; int32 most = 0; - float32 xIndex = static_cast(i % dims[0]); - float32 yIndex = static_cast((i / dims[0]) % dims[1]); - float32 zIndex = static_cast(i / (dims[0] * dims[1])); + auto xIndex = static_cast(i % dims[0]); + auto yIndex = static_cast((i / dims[0]) % dims[1]); + auto zIndex = static_cast(i / (dims[0] * dims[1])); for(int32_t j = 0; j < 6; j++) { auto neighborPoint = static_cast(i + neighborPoints[j]); @@ -282,7 +253,7 @@ Result<> FillBadData::operator()() continue; } - int32 feature = m_FeatureIds[neighborPoint]; + int32 feature = featureIdsStore[neighborPoint]; if(feature > 0) { featureNumber[feature]++; @@ -290,7 +261,7 @@ Result<> FillBadData::operator()() if(current > most) { most = current; - m_Neighbors[i] = static_cast(neighborPoint); + neighbors[i] = static_cast(neighborPoint); } } } @@ -322,7 +293,7 @@ Result<> FillBadData::operator()() continue; } - int32 feature = m_FeatureIds[neighborPoint]; + int32 feature = featureIdsStore[neighborPoint]; if(feature > 0) { featureNumber[feature] = 0; @@ -344,14 +315,13 @@ Result<> FillBadData::operator()() { continue; } - auto& oldCellArray = m_DataStructure.getDataRefAs(cellArrayPath); - const DataType dataType = oldCellArray.getDataType(); + auto* oldCellArray = m_DataStructure.getDataAs(cellArrayPath); - ExecuteDataFunction(FillBadDataUpdateTuplesFunctor{}, dataType, m_FeatureIds, oldCellArray, m_Neighbors); + ExecuteDataFunction(FillBadDataUpdateTuplesFunctor{}, oldCellArray->getDataType(), featureIdsStore, oldCellArray, neighbors); } // We need to update the FeatureIds array _LAST_ since the above operations depend on that values in that array - FillBadDataUpdateTuples(m_FeatureIds, dynamic_cast(m_FeatureIds), m_Neighbors)(); + FillBadDataUpdateTuples(featureIdsStore, featureIdsStore, neighbors); } return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.cpp index a16603dccc..be7e2ce54e 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.cpp @@ -2,10 +2,7 @@ #include "simplnx/DataStructure/Geometry/TriangleGeom.hpp" -#include - #include -#include namespace nx::core { @@ -46,7 +43,6 @@ Result<> FindNRingNeighbors::operator()(const IFilter::MessageHandler& mesgHandl bool check0 = faceLabels[triangleId * 2] == m_InputValues->RegionId0 && faceLabels[triangleId * 2 + 1] == m_InputValues->RegionId1; bool check1 = faceLabels[triangleId * 2 + 1] == m_InputValues->RegionId0 && faceLabels[triangleId * 2] == m_InputValues->RegionId1; -#if 1 if(!check0 && !check1) { std::stringstream ss; @@ -54,7 +50,6 @@ Result<> FindNRingNeighbors::operator()(const IFilter::MessageHandler& mesgHandl ss << "Region Ids are: " << faceLabels[m_InputValues->TriangleId * 2] << " & " << faceLabels[m_InputValues->TriangleId * 2 + 1] << "\n"; return MakeErrorResult(err, ss.str()); } -#endif // Add our seed triangle m_NRingTriangles.insert(triangleId); @@ -66,9 +61,8 @@ Result<> FindNRingNeighbors::operator()(const IFilter::MessageHandler& mesgHandl UniqueFaceIds_t lcvTriangles(m_NRingTriangles); // Now that we have the 1 ring triangles, get the 2 Ring neighbors from that list - for(UniqueFaceIds_t::iterator triIter = lcvTriangles.begin(); triIter != lcvTriangles.end(); ++triIter) + for(auto triangleIdx : lcvTriangles) { - int64_t triangleIdx = *triIter; // For each node, get the triangle ids that the node belongs to for(int32_t i = 0; i < 3; ++i) { @@ -79,7 +73,7 @@ Result<> FindNRingNeighbors::operator()(const IFilter::MessageHandler& mesgHandl // Copy all the triangles into our "2Ring" set which will be the unique set of triangle ids for(uint16_t t = 0; t < tCount; ++t) { - int64_t tid = data[t]; + IGeometry::MeshIndexType tid = data[t]; check0 = faceLabels[tid * 2] == m_InputValues->RegionId0 && faceLabels[tid * 2 + 1] == m_InputValues->RegionId1; check1 = faceLabels[tid * 2 + 1] == m_InputValues->RegionId0 && faceLabels[tid * 2] == m_InputValues->RegionId1; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.hpp index 85e80174d8..4bf2fd5cd0 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FindNRingNeighbors.hpp @@ -5,6 +5,7 @@ #include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/DataStructure/DataStructure.hpp" +#include "simplnx/DataStructure/Geometry/IGeometry.hpp" #include "simplnx/DataStructure/NeighborList.hpp" #include "simplnx/Filter/IFilter.hpp" @@ -29,7 +30,7 @@ struct SIMPLNXCORE_EXPORT FindNRingNeighborsInputValues class SIMPLNXCORE_EXPORT FindNRingNeighbors { public: - using UniqueFaceIds_t = std::set; + using UniqueFaceIds_t = std::set; FindNRingNeighbors(FindNRingNeighborsInputValues* inputValues); ~FindNRingNeighbors() noexcept; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FlyingEdges3D.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FlyingEdges3D.cpp index ee1e550ebf..309244b167 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FlyingEdges3D.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/FlyingEdges3D.cpp @@ -10,9 +10,9 @@ namespace struct ExecuteFlyingEdgesFunctor { template - void operator()(const ImageGeom& image, const IDataArray& iDataArray, float64 isoVal, TriangleGeom& triangleGeom, Float32Array& normals, AttributeMatrix& normAM) + void operator()(const ImageGeom& image, const IDataArray* iDataArray, float64 isoVal, TriangleGeom& triangleGeom, Float32AbstractDataStore& normals, AttributeMatrix& normAM) { - FlyingEdgesAlgorithm flyingEdges = FlyingEdgesAlgorithm(image, iDataArray, static_cast(isoVal), triangleGeom, normals); + FlyingEdgesAlgorithm flyingEdges = FlyingEdgesAlgorithm(image, iDataArray->template getIDataStoreRefAs>(), static_cast(isoVal), triangleGeom, normals); flyingEdges.pass1(); flyingEdges.pass2(); flyingEdges.pass3(); @@ -49,16 +49,16 @@ Result<> FlyingEdges3D::operator()() { const auto& image = m_DataStructure.getDataRefAs(m_InputValues->imageGeomPath); float64 isoVal = m_InputValues->isoVal; - const auto& iDataArray = m_DataStructure.getDataRefAs(m_InputValues->contouringArrayPath); + const auto* iDataArray = m_DataStructure.getDataAs(m_InputValues->contouringArrayPath); auto triangleGeom = m_DataStructure.getDataRefAs(m_InputValues->triangleGeomPath); - auto normals = m_DataStructure.getDataRefAs(m_InputValues->normalsArrayPath); + auto& normalsStore = m_DataStructure.getDataAs(m_InputValues->normalsArrayPath)->getDataStoreRef(); // auto created so must have a parent DataPath normAMPath = m_InputValues->normalsArrayPath.getParent(); auto& normAM = m_DataStructure.getDataRefAs(normAMPath); - ExecuteNeighborFunction(ExecuteFlyingEdgesFunctor{}, iDataArray.getDataType(), image, iDataArray, isoVal, triangleGeom, normals, normAM); + ExecuteNeighborFunction(ExecuteFlyingEdgesFunctor{}, iDataArray->getDataType(), image, iDataArray, isoVal, triangleGeom, normalsStore, normAM); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LabelTriangleGeometry.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LabelTriangleGeometry.cpp index 2a2b6fee65..febe178e40 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LabelTriangleGeometry.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LabelTriangleGeometry.cpp @@ -43,7 +43,7 @@ Result<> LabelTriangleGeometry::operator()() const TriangleGeom::ElementDynamicList* triangleNeighborsPtr = triangle.getElementNeighbors(); - auto& regionIds = m_DataStructure.getDataRefAs(m_InputValues->RegionIdsPath); + auto& regionIdsStore = m_DataStructure.getDataAs(m_InputValues->RegionIdsPath)->getDataStoreRef(); usize chunkSize = 1000; std::vector triList(chunkSize, -1); @@ -51,9 +51,9 @@ Result<> LabelTriangleGeometry::operator()() int32 regionCount = 1; for(usize i = 0; i < numTris; i++) { - if(regionIds[i] == 0) + if(regionIdsStore[i] == 0) { - regionIds[i] = regionCount; + regionIdsStore[i] = regionCount; triangleCounts[regionCount]++; usize size = 0; @@ -68,9 +68,9 @@ Result<> LabelTriangleGeometry::operator()() for(int j = 0; j < tCount; j++) { TriangleGeom::MeshIndexType neighTri = dataPtr[j]; - if(regionIds[neighTri] == 0) + if(regionIdsStore[neighTri] == 0) { - regionIds[neighTri] = regionCount; + regionIdsStore[neighTri] = regionCount; triangleCounts[regionCount]++; triList[size] = static_cast(neighTri); size++; @@ -101,10 +101,10 @@ Result<> LabelTriangleGeometry::operator()() triangle.deleteElementsContainingVert(); // copy triangleCounts into the proper DataArray "NumTriangles" in the Feature Attribute Matrix - auto& numTriangles = m_DataStructure.getDataRefAs(m_InputValues->NumTrianglesPath); - for(usize index = 0; index < numTriangles.getSize(); index++) + auto& numTrianglesStore = m_DataStructure.getDataAs(m_InputValues->NumTrianglesPath)->getDataStoreRef(); + for(usize index = 0; index < numTrianglesStore.getSize(); index++) { - numTriangles[index] = static_cast(triangleCounts[index]); + numTrianglesStore[index] = static_cast(triangleCounts[index]); } return {}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LaplacianSmoothing.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LaplacianSmoothing.cpp index 8f9409b3dd..5dc5d47fcf 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LaplacianSmoothing.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/LaplacianSmoothing.cpp @@ -28,14 +28,9 @@ Result<> LaplacianSmoothing::operator()() // ----------------------------------------------------------------------------- Result<> LaplacianSmoothing::edgeBasedSmoothing() { - int32_t err = 0; - // DataContainer::Pointer sm = getDataContainerArray()->getDataContainer(getSurfaceDataContainerName()); - // IGeometry2D::Pointer surfaceMesh = sm->getGeometryAs(); + auto& surfaceMesh = m_DataStructure.getDataRefAs(m_InputValues->pTriangleGeometryDataPath); - TriangleGeom& surfaceMesh = m_DataStructure.getDataRefAs(m_InputValues->pTriangleGeometryDataPath); - - Float32Array& vertsArray = *(surfaceMesh.getVertices()); - Float32AbstractDataStore& verts = vertsArray.getDataStoreRef(); + Float32AbstractDataStore& verts = surfaceMesh.getVertices()->getDataStoreRef(); IGeometry::MeshIndexType nvert = surfaceMesh.getNumberOfVertices(); @@ -43,17 +38,15 @@ Result<> LaplacianSmoothing::edgeBasedSmoothing() std::vector lambdas = generateLambdaArray(); // Generate the Unique Edges - err = surfaceMesh.findEdges(false); - if(err < 0) + if(surfaceMesh.findEdges(false) < 0) { return MakeErrorResult(-560, "Error retrieving the shared edge list"); } - IGeometry::SharedEdgeList& uedgesArray = *(surfaceMesh.getEdges()); - UInt64AbstractDataStore& uedges = uedgesArray.getDataStoreRef(); - IGeometry::MeshIndexType nedges = uedges.getNumberOfTuples(); + AbstractDataStore& edges = surfaceMesh.getEdges()->getDataStoreRef(); + IGeometry::MeshIndexType numEdges = edges.getNumberOfTuples(); - std::vector numConnections(nvert, 0); + std::vector numConnections(nvert, 0); std::vector deltaArray(nvert * 3); double dlta = 0.0; @@ -66,10 +59,10 @@ Result<> LaplacianSmoothing::edgeBasedSmoothing() } m_MessageHandler(IFilter::Message::Type::Info, fmt::format("Iteration {} of {}", q, m_InputValues->pIterationSteps)); // Compute the Deltas for each point - for(IGeometry::MeshIndexType i = 0; i < nedges; i++) + for(IGeometry::MeshIndexType i = 0; i < numEdges; i++) { - IGeometry::MeshIndexType in1 = uedges[2 * i]; // row of the first vertex - IGeometry::MeshIndexType in2 = uedges[2 * i + 1]; // row the second vertex + IGeometry::MeshIndexType in1 = edges[2 * i]; // row of the first vertex + IGeometry::MeshIndexType in2 = edges[2 * i + 1]; // row the second vertex for(IGeometry::MeshIndexType j = 0; j < 3; j++) { @@ -112,10 +105,10 @@ Result<> LaplacianSmoothing::edgeBasedSmoothing() } m_MessageHandler(IFilter::Message::Type::Info, fmt::format("Iteration {} of {}", q, m_InputValues->pIterationSteps)); // Compute the Delta's - for(IGeometry::MeshIndexType i = 0; i < nedges; i++) + for(IGeometry::MeshIndexType i = 0; i < numEdges; i++) { - IGeometry::MeshIndexType in1 = uedges[2 * i]; // row of the first vertex - IGeometry::MeshIndexType in2 = uedges[2 * i + 1]; // row the second vertex + IGeometry::MeshIndexType in1 = edges[2 * i]; // row of the first vertex + IGeometry::MeshIndexType in2 = edges[2 * i + 1]; // row the second vertex for(int32_t j = 0; j < 3; j++) { @@ -154,10 +147,9 @@ Result<> LaplacianSmoothing::edgeBasedSmoothing() // ----------------------------------------------------------------------------- std::vector LaplacianSmoothing::generateLambdaArray() { - Int8Array& surfaceMeshNodeType = m_DataStructure.getDataRefAs(m_InputValues->pSurfaceMeshNodeTypeArrayPath); - Int8AbstractDataStore& surfaceMeshNode = surfaceMeshNodeType.getDataStoreRef(); + auto& surfaceMeshNode = m_DataStructure.getDataAs(m_InputValues->pSurfaceMeshNodeTypeArrayPath)->getDataStoreRef(); - size_t numNodes = surfaceMeshNodeType.getNumberOfTuples(); + size_t numNodes = surfaceMeshNode.getNumberOfTuples(); std::vector lambdas(numNodes, 0.0f); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/NearestPointFuseRegularGrids.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/NearestPointFuseRegularGrids.cpp index b3db0976ea..40d811b8dd 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/NearestPointFuseRegularGrids.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/NearestPointFuseRegularGrids.cpp @@ -158,7 +158,6 @@ Result<> NearestPointFuseRegularGrids::operator()() { auto& refImageGeom = m_DataStructure.getDataRefAs(m_InputValues->ReferenceGeometryPath); auto& sampleImageGeom = m_DataStructure.getDataRefAs(m_InputValues->SamplingGeometryPath); - auto& refAM = m_DataStructure.getDataRefAs(m_InputValues->ReferenceCellAttributeMatrixPath); auto& sampleAM = m_DataStructure.getDataRefAs(m_InputValues->SamplingCellAttributeMatrixPath); Vec3 sampleRes = sampleImageGeom.getSpacing(); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PartitionGeometry.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PartitionGeometry.cpp index 7a49fb8978..d13ad16792 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PartitionGeometry.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PartitionGeometry.cpp @@ -15,10 +15,10 @@ namespace class PartitionCellBasedGeometryImpl { public: - PartitionCellBasedGeometryImpl(const IGridGeometry& inputGeometry, Int32Array& partitionIds, const ImageGeom& psImageGeom, int startingPartitionId, int outOfBoundsValue, + PartitionCellBasedGeometryImpl(const IGridGeometry& inputGeometry, Int32AbstractDataStore& partitionIdsStore, const ImageGeom& psImageGeom, int startingPartitionId, int outOfBoundsValue, const std::atomic_bool& shouldCancel) : m_InputGeometry(inputGeometry) - , m_PartitionIds(partitionIds) + , m_PartitionIdsStore(partitionIdsStore) , m_PSImageGeom(psImageGeom) , m_StartingPartitionId(startingPartitionId) , m_OutOfBoundsValue(outOfBoundsValue) @@ -29,7 +29,6 @@ class PartitionCellBasedGeometryImpl // ----------------------------------------------------------------------------- void compute(size_t xStart, size_t xEnd, size_t yStart, size_t yEnd, size_t zStart, size_t zEnd) const { - AbstractDataStore& partitionIdsStore = m_PartitionIds.getDataStoreRef(); SizeVec3 dims = m_InputGeometry.getDimensions(); for(usize z = zStart; z < zEnd; z++) @@ -49,13 +48,11 @@ class PartitionCellBasedGeometryImpl auto partitionIndexResult = m_PSImageGeom.getIndex(coord[0], coord[1], coord[2]); if(partitionIndexResult.has_value()) { - partitionIdsStore.setValue(index, static_cast(*partitionIndexResult) + m_StartingPartitionId); - // partitionIdsStore[index] = static_cast(*partitionIndexResult) + m_StartingPartitionId; + m_PartitionIdsStore[index] = static_cast(*partitionIndexResult) + m_StartingPartitionId; } else { - partitionIdsStore.setValue(index, m_OutOfBoundsValue); - // partitionIdsStore[index] = m_OutOfBoundsValue; + m_PartitionIdsStore[index] = m_OutOfBoundsValue; } } } @@ -69,7 +66,7 @@ class PartitionCellBasedGeometryImpl private: const IGridGeometry& m_InputGeometry; - Int32Array& m_PartitionIds; + Int32AbstractDataStore& m_PartitionIdsStore; const ImageGeom& m_PSImageGeom; int m_StartingPartitionId; int m_OutOfBoundsValue; @@ -80,10 +77,10 @@ class PartitionCellBasedGeometryImpl class PartitionNodeBasedGeometryImpl { public: - PartitionNodeBasedGeometryImpl(const IGeometry::SharedVertexList& vertexList, Int32Array& partitionIds, const ImageGeom& psImageGeom, int startingPartitionId, int outOfBoundsValue, - const std::optional& maskArrayOpt, const std::atomic_bool& shouldCancel) - : m_VertexList(vertexList) - , m_PartitionIds(partitionIds) + PartitionNodeBasedGeometryImpl(const PartitionGeometry::VertexStore& verticesStore, Int32AbstractDataStore& partitionIdsStore, const ImageGeom& psImageGeom, int startingPartitionId, + int outOfBoundsValue, const std::optional& maskArrayOpt, const std::atomic_bool& shouldCancel) + : m_VerticesStore(verticesStore) + , m_PartitionIdsStore(partitionIdsStore) , m_PSImageGeom(psImageGeom) , m_StartingPartitionId(startingPartitionId) , m_OutOfBoundsValue(outOfBoundsValue) @@ -95,9 +92,6 @@ class PartitionNodeBasedGeometryImpl // ----------------------------------------------------------------------------- void compute(size_t start, size_t end) const { - AbstractDataStore& partitionIdsStore = m_PartitionIds.getDataStoreRef(); - const AbstractDataStore& verticesStore = m_VertexList.getDataStoreRef(); - for(usize idx = start; idx < end; idx++) { if(m_ShouldCancel) @@ -105,18 +99,18 @@ class PartitionNodeBasedGeometryImpl return; } - const float32 x = verticesStore[idx * 3]; - const float32 y = verticesStore[idx * 3 + 1]; - const float32 z = verticesStore[idx * 3 + 2]; + const float32 x = m_VerticesStore[idx * 3]; + const float32 y = m_VerticesStore[idx * 3 + 1]; + const float32 z = m_VerticesStore[idx * 3 + 2]; auto partitionIndexResult = m_PSImageGeom.getIndex(x, y, z); if((m_MaskArrayOpt.has_value() && !(*m_MaskArrayOpt)[idx]) || !partitionIndexResult.has_value()) { - partitionIdsStore.setValue(idx, m_OutOfBoundsValue); + m_PartitionIdsStore[idx] = m_OutOfBoundsValue; } else { - partitionIdsStore.setValue(idx, static_cast(*partitionIndexResult) + m_StartingPartitionId); + m_PartitionIdsStore[idx] = static_cast(*partitionIndexResult) + m_StartingPartitionId; } } } @@ -127,8 +121,8 @@ class PartitionNodeBasedGeometryImpl } private: - const IGeometry::SharedVertexList& m_VertexList; - Int32Array& m_PartitionIds; + const PartitionGeometry::VertexStore& m_VerticesStore; + Int32AbstractDataStore& m_PartitionIdsStore; const ImageGeom& m_PSImageGeom; int m_StartingPartitionId; int m_OutOfBoundsValue; @@ -170,11 +164,11 @@ Result<> PartitionGeometry::operator()() partitionGridGeomPath = m_InputValues->PartitionGridGeomPath; const DataPath partitionGridFeatureIdsPath = m_InputValues->PartitionGridGeomPath.createChildPath(m_InputValues->PartitionGridCellAMName).createChildPath(m_InputValues->PartitionGridFeatureIDsArrayName); - auto& partitionGridFeatureIds = m_DataStructure.getDataRefAs({partitionGridFeatureIdsPath}); + auto& pgFeatureIdsStore = m_DataStructure.getDataAs(partitionGridFeatureIdsPath)->getDataStoreRef(); - for(usize i = 0; i < partitionGridFeatureIds.getNumberOfTuples(); i++) + for(usize i = 0; i < pgFeatureIdsStore.getNumberOfTuples(); i++) { - partitionGridFeatureIds[i] = static_cast(i) + m_InputValues->StartingFeatureID; + pgFeatureIdsStore[i] = static_cast(i) + m_InputValues->StartingFeatureID; } } @@ -183,24 +177,24 @@ Result<> PartitionGeometry::operator()() std::optional vertexMask = {}; if(m_InputValues->UseVertexMask) { - vertexMask = m_DataStructure.getDataRefAs({m_InputValues->VertexMaskPath}); + vertexMask = m_DataStructure.getDataRefAs(m_InputValues->VertexMaskPath); } const DataPath partitionIdsPath = m_InputValues->InputGeomCellAMPath.createChildPath(m_InputValues->PartitionIdsArrayName); - auto& partitionIds = m_DataStructure.getDataRefAs({partitionIdsPath}); + auto& partitionIdsStore = m_DataStructure.getDataAs(partitionIdsPath)->getDataStoreRef(); - const IGeometry& iGeomToPartition = m_DataStructure.getDataRefAs({m_InputValues->InputGeometryToPartition}); + const IGeometry& iGeomToPartition = m_DataStructure.getDataRefAs(m_InputValues->InputGeometryToPartition); Result<> result; switch(iGeomToPartition.getGeomType()) { case IGeometry::Type::Image: { const ImageGeom& inputGeomToPartition = m_DataStructure.getDataRefAs({m_InputValues->InputGeometryToPartition}); - result = partitionCellBasedGeometry(inputGeomToPartition, partitionIds, partitionGridGeom, m_InputValues->OutOfBoundsFeatureID); + result = partitionCellBasedGeometry(inputGeomToPartition, partitionIdsStore, partitionGridGeom, m_InputValues->OutOfBoundsFeatureID); break; } case IGeometry::Type::RectGrid: { const RectGridGeom& inputGeomToPartition = m_DataStructure.getDataRefAs({m_InputValues->InputGeometryToPartition}); - result = partitionCellBasedGeometry(inputGeomToPartition, partitionIds, partitionGridGeom, m_InputValues->OutOfBoundsFeatureID); + result = partitionCellBasedGeometry(inputGeomToPartition, partitionIdsStore, partitionGridGeom, m_InputValues->OutOfBoundsFeatureID); break; } case IGeometry::Type::Vertex: @@ -210,8 +204,8 @@ Result<> PartitionGeometry::operator()() case IGeometry::Type::Tetrahedral: case IGeometry::Type::Hexahedral: { const INodeGeometry0D& inputGeomToPartition = m_DataStructure.getDataRefAs({m_InputValues->InputGeometryToPartition}); - const IGeometry::SharedVertexList* vertexList = inputGeomToPartition.getVertices(); - result = partitionNodeBasedGeometry(*vertexList, partitionIds, partitionGridGeom, m_InputValues->OutOfBoundsFeatureID, vertexMask); + const AbstractDataStore& vertexListStore = inputGeomToPartition.getVertices()->getDataStoreRef(); + result = partitionNodeBasedGeometry(vertexListStore, partitionIdsStore, partitionGridGeom, m_InputValues->OutOfBoundsFeatureID, vertexMask); break; } default: { @@ -230,17 +224,17 @@ Result<> PartitionGeometry::operator()() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -Result<> PartitionGeometry::partitionCellBasedGeometry(const IGridGeometry& inputGeometry, Int32Array& partitionIds, const ImageGeom& psImageGeom, int outOfBoundsValue) +Result<> PartitionGeometry::partitionCellBasedGeometry(const IGridGeometry& inputGeometry, Int32AbstractDataStore& partitionIdsStore, const ImageGeom& psImageGeom, int outOfBoundsValue) { SizeVec3 dims = inputGeometry.getDimensions(); - IParallelAlgorithm::AlgorithmArrays algArrays; - algArrays.push_back(&partitionIds); + IParallelAlgorithm::AlgorithmStores algStores; + algStores.push_back(&partitionIdsStore); ParallelData3DAlgorithm dataAlg; dataAlg.setRange(dims[0], dims[1], dims[2]); - dataAlg.requireArraysInMemory(algArrays); - dataAlg.execute(PartitionCellBasedGeometryImpl(inputGeometry, partitionIds, psImageGeom, m_InputValues->StartingFeatureID, outOfBoundsValue, m_ShouldCancel)); + dataAlg.requireStoresInMemory(algStores); + dataAlg.execute(PartitionCellBasedGeometryImpl(inputGeometry, partitionIdsStore, psImageGeom, m_InputValues->StartingFeatureID, outOfBoundsValue, m_ShouldCancel)); return {}; } @@ -248,12 +242,14 @@ Result<> PartitionGeometry::partitionCellBasedGeometry(const IGridGeometry& inpu // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -Result<> PartitionGeometry::partitionNodeBasedGeometry(const IGeometry::SharedVertexList& vertexList, Int32Array& partitionIds, const ImageGeom& psImageGeom, int outOfBoundsValue, +Result<> PartitionGeometry::partitionNodeBasedGeometry(const VertexStore& vertexListStore, Int32AbstractDataStore& partitionIdsStore, const ImageGeom& psImageGeom, int outOfBoundsValue, const std::optional& maskArrayOpt) { + IParallelAlgorithm::AlgorithmStores algStores; + algStores.push_back(&vertexListStore); + algStores.push_back(&partitionIdsStore); + IParallelAlgorithm::AlgorithmArrays algArrays; - algArrays.push_back(&vertexList); - algArrays.push_back(&partitionIds); if(maskArrayOpt.has_value()) { algArrays.push_back(&(maskArrayOpt.value())); @@ -261,9 +257,10 @@ Result<> PartitionGeometry::partitionNodeBasedGeometry(const IGeometry::SharedVe // Allow data-based parallelization ParallelDataAlgorithm dataAlg; - dataAlg.setRange(0, vertexList.getNumberOfTuples()); + dataAlg.setRange(0, vertexListStore.getNumberOfTuples()); dataAlg.requireArraysInMemory(algArrays); - dataAlg.execute(PartitionNodeBasedGeometryImpl(vertexList, partitionIds, psImageGeom, m_InputValues->StartingFeatureID, outOfBoundsValue, maskArrayOpt, m_ShouldCancel)); + dataAlg.requireStoresInMemory(algStores); + dataAlg.execute(PartitionNodeBasedGeometryImpl(vertexListStore, partitionIdsStore, psImageGeom, m_InputValues->StartingFeatureID, outOfBoundsValue, maskArrayOpt, m_ShouldCancel)); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PartitionGeometry.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PartitionGeometry.hpp index f43fe2ba64..a11e20d9bf 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PartitionGeometry.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PartitionGeometry.hpp @@ -54,6 +54,8 @@ struct SIMPLNXCORE_EXPORT PartitionGeometryInputValues class SIMPLNXCORE_EXPORT PartitionGeometry { public: + using VertexStore = AbstractDataStore; + PartitionGeometry(DataStructure& dataStructure, const IFilter::MessageHandler& msgHandler, const std::atomic_bool& shouldCancel, PartitionGeometryInputValues* inputValues); ~PartitionGeometry() noexcept; @@ -89,7 +91,7 @@ class SIMPLNXCORE_EXPORT PartitionGeometry * the function will return an invalid Result with an error message. * * @param inputGeometry The cell-based input geometry that is being partitioned. - * @param partitionIds The partition ids array that stores the results. + * @param partitionIdsStore The partition ids array that stores the results. * @param psImageGeom The partitioning scheme image geometry that is used * to partition the cell-based input geometry. * @param outOfBoundsValue Value that out-of-bounds cells will be @@ -97,7 +99,7 @@ class SIMPLNXCORE_EXPORT PartitionGeometry * @return The result of the partitioning algorithm. Valid if successful, invalid * if there was an error. */ - Result<> partitionCellBasedGeometry(const IGridGeometry& inputGeometry, Int32Array& partitionIds, const ImageGeom& psImageGeom, int outOfBoundsValue); + Result<> partitionCellBasedGeometry(const IGridGeometry& inputGeometry, Int32AbstractDataStore& partitionIdsStore, const ImageGeom& psImageGeom, int outOfBoundsValue); /** * @brief Partitions a vertex list (typically from a node-based geometry) according to @@ -108,8 +110,8 @@ class SIMPLNXCORE_EXPORT PartitionGeometry * is provided, the vertex will be labeled with the out of bounds value. Otherwise, * the function will return an invalid Result with an error message. * - * @param vertexList The list of vertices from the node-based geometry - * @param partitionIds The partition ids array that stores the results. + * @param vertexListStore The list of vertices from the node-based geometry + * @param partitionIdsStore The partition ids array that stores the results. * @param psImageGeom The partitioning scheme image geometry that is used * to partition the vertex list. * @param outOfBoundsValue Value that out-of-bounds vertices will be @@ -118,7 +120,7 @@ class SIMPLNXCORE_EXPORT PartitionGeometry * @return The result of the partitioning algorithm. Valid if successful, invalid * if there was an error. */ - Result<> partitionNodeBasedGeometry(const IGeometry::SharedVertexList& vertexList, Int32Array& partitionIds, const ImageGeom& psImageGeom, int outOfBoundsValue, + Result<> partitionNodeBasedGeometry(const VertexStore& vertexListStore, Int32AbstractDataStore& partitionIdsStore, const ImageGeom& psImageGeom, int outOfBoundsValue, const std::optional& maskArrayOpt); }; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PointSampleTriangleGeometry.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PointSampleTriangleGeometry.cpp index e2a92d05dc..e6574dadd1 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PointSampleTriangleGeometry.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/PointSampleTriangleGeometry.cpp @@ -38,8 +38,6 @@ #include "simplnx/DataStructure/Geometry/TriangleGeom.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" -#include - using namespace nx::core; // ----------------------------------------------------------------------------- @@ -57,12 +55,11 @@ PointSampleTriangleGeometry::~PointSampleTriangleGeometry() noexcept = default; Result<> PointSampleTriangleGeometry::operator()() { - DataPath triangleGeometryDataPath = m_Inputs->pTriangleGeometry; - TriangleGeom& triangle = m_DataStructure.getDataRefAs(triangleGeometryDataPath); - int64_t numTris = static_cast(triangle.getNumberOfFaces()); + auto& triangle = m_DataStructure.getDataRefAs(triangleGeometryDataPath); + auto numTris = static_cast(triangle.getNumberOfFaces()); - VertexGeom& vertex = m_DataStructure.getDataRefAs(m_Inputs->pVertexGeometryPath); + auto& vertex = m_DataStructure.getDataRefAs(m_Inputs->pVertexGeometryPath); vertex.resizeVertexList(m_Inputs->pNumberOfSamples); auto tupleShape = {static_cast(m_Inputs->pNumberOfSamples)}; vertex.getVertexAttributeMatrix()->resizeTuples(tupleShape); @@ -70,22 +67,12 @@ Result<> PointSampleTriangleGeometry::operator()() std::mt19937_64 generator(m_Inputs->Seed); std::uniform_real_distribution<> distribution(0.0f, 1.0f); - // Create the Triangle Ids vector and fill it from zero to size-1 incrementally - std::vector triangleIds(numTris); - std::iota(std::begin(triangleIds), std::end(triangleIds), 0); - // Initialize the Triangle Weights with the Triangle Area Values - Float64Array& faceAreas = m_DataStructure.getDataRefAs(m_Inputs->pTriangleAreasArrayPath); - std::vector triangleWeights(numTris); - for(size_t i = 0; i < triangleWeights.size(); i++) - { - triangleWeights[i] = faceAreas[i]; - } + const auto& faceAreasStore = m_DataStructure.getDataAs(m_Inputs->pTriangleAreasArrayPath)->getDataStoreRef(); - // VS2013 does not implement the iterator contructor for std::discrete_distribution<>, which + // VS2013 does not implement the iterator constructor for std::discrete_distribution<>, which // really is a massively idiotic oversight; hack the equivalent using the unary_op constructor - std::discrete_distribution triangle_distribution(triangleWeights.size(), -0.5, -0.5 + static_cast(triangleWeights.size()), - [&triangleWeights](double index) { return triangleWeights[static_cast(index)]; }); + std::discrete_distribution triangle_distribution(numTris, -0.5, -0.5 + static_cast(numTris), [&faceAreasStore](double index) { return faceAreasStore[static_cast(index)]; }); int64_t progIncrement = m_Inputs->pNumberOfSamples / 100; int64_t prog = 1; @@ -100,10 +87,9 @@ Result<> PointSampleTriangleGeometry::operator()() std::unique_ptr maskArray = nullptr; if(m_Inputs->pUseMask) { - std::unique_ptr maskCompare; try { - maskCompare = InstantiateMaskCompare(m_DataStructure, m_Inputs->pMaskArrayPath); + maskArray = InstantiateMaskCompare(m_DataStructure, m_Inputs->pMaskArrayPath); } catch(const std::out_of_range& exception) { // This really should NOT be happening as the path was verified during preflight BUT we may be calling this from @@ -114,7 +100,7 @@ Result<> PointSampleTriangleGeometry::operator()() } // Get a reference to the Vertex List - IGeometry::SharedVertexList* vertices = vertex.getVertices(); + AbstractDataStore& vertices = vertex.getVertices()->getDataStoreRef(); // Create a vector of TupleTransferFunctions for each of the Triangle Face to Vertex Data Arrays std::vector> tupleTransferFunctions; @@ -158,16 +144,16 @@ Result<> PointSampleTriangleGeometry::operator()() triangle.getFaceCoordinates(randomTri, faceVerts); - float r1 = static_cast(distribution(generator)); - float r2 = static_cast(distribution(generator)); + auto r1 = static_cast(distribution(generator)); + auto r2 = static_cast(distribution(generator)); float prefactorA = 1.0f - sqrtf(r1); float prefactorB = sqrtf(r1) * (1 - r2); float prefactorC = sqrtf(r1) * r2; - (*vertices)[curVertex * 3 + 0] = (prefactorA * faceVerts[0][0]) + (prefactorB * faceVerts[1][0]) + (prefactorC * faceVerts[2][0]); - (*vertices)[curVertex * 3 + 1] = (prefactorA * faceVerts[0][1]) + (prefactorB * faceVerts[1][1]) + (prefactorC * faceVerts[2][1]); - (*vertices)[curVertex * 3 + 2] = (prefactorA * faceVerts[0][2]) + (prefactorB * faceVerts[1][2]) + (prefactorC * faceVerts[2][2]); + vertices[curVertex * 3 + 0] = (prefactorA * faceVerts[0][0]) + (prefactorB * faceVerts[1][0]) + (prefactorC * faceVerts[2][0]); + vertices[curVertex * 3 + 1] = (prefactorA * faceVerts[0][1]) + (prefactorB * faceVerts[1][1]) + (prefactorC * faceVerts[2][1]); + vertices[curVertex * 3 + 2] = (prefactorA * faceVerts[0][2]) + (prefactorB * faceVerts[1][2]) + (prefactorC * faceVerts[2][2]); // Transfer the face data to the vertex data for(size_t dataVectorIndex = 0; dataVectorIndex < m_Inputs->pSelectedDataArrayPaths.size(); dataVectorIndex++) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/QuickSurfaceMesh.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/QuickSurfaceMesh.cpp index 0fd83f9555..4319b1891a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/QuickSurfaceMesh.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/QuickSurfaceMesh.cpp @@ -64,7 +64,7 @@ using EdgeMap = std::unordered_map uFeatures; }; +// ----------------------------------------------------------------------------- +void GetGridCoordinates(const IGridGeometry* grid, size_t x, size_t y, size_t z, QuickSurfaceMesh::VertexStore& verts, IGeometry::MeshIndexType nodeIndex) +{ + nx::core::Point3D tmpCoords = grid->getPlaneCoords(x, y, z); + verts[nodeIndex] = static_cast(tmpCoords[0]); + verts[nodeIndex + 1] = static_cast(tmpCoords[1]); + verts[nodeIndex + 2] = static_cast(tmpCoords[2]); +} + +// ----------------------------------------------------------------------------- +void FlipProblemVoxelCase1(Int32AbstractDataStore& featureIds, QuickSurfaceMesh::MeshIndexType v1, QuickSurfaceMesh::MeshIndexType v2, QuickSurfaceMesh::MeshIndexType v3, + QuickSurfaceMesh::MeshIndexType v4, QuickSurfaceMesh::MeshIndexType v5, QuickSurfaceMesh::MeshIndexType v6) +{ + auto val = static_cast(k_Distribution(k_Generator)); // Random remaining position. + + if(val < 0.25f) + { + featureIds[v6] = featureIds[v4]; + } + else if(val < 0.5f) + { + featureIds[v6] = featureIds[v5]; + } + else if(val < 0.75f) + { + featureIds[v1] = featureIds[v2]; + } + else + { + featureIds[v1] = featureIds[v3]; + } +} + +// ----------------------------------------------------------------------------- +void FlipProblemVoxelCase2(Int32AbstractDataStore& featureIds, QuickSurfaceMesh::MeshIndexType v1, QuickSurfaceMesh::MeshIndexType v2, QuickSurfaceMesh::MeshIndexType v3, + QuickSurfaceMesh::MeshIndexType v4) +{ + auto val = static_cast(k_Distribution(k_Generator)); // Random remaining position. + + if(val < 0.125f) + { + featureIds[v1] = featureIds[v2]; + } + else if(val < 0.25f) + { + featureIds[v1] = featureIds[v3]; + } + else if(val < 0.375f) + { + featureIds[v2] = featureIds[v1]; + } + if(val < 0.5f) + { + featureIds[v2] = featureIds[v4]; + } + else if(val < 0.625f) + { + featureIds[v3] = featureIds[v1]; + } + else if(val < 0.75f) + { + featureIds[v3] = featureIds[v4]; + } + else if(val < 0.875f) + { + featureIds[v4] = featureIds[v2]; + } + else + { + featureIds[v4] = featureIds[v3]; + } +} + +// ----------------------------------------------------------------------------- +void FlipProblemVoxelCase3(Int32AbstractDataStore& featureIds, QuickSurfaceMesh::MeshIndexType v1, QuickSurfaceMesh::MeshIndexType v2, QuickSurfaceMesh::MeshIndexType v3) +{ + auto val = static_cast(k_Distribution(k_Generator)); // Random remaining position. + + if(val < 0.5f) + { + featureIds[v2] = featureIds[v1]; + } + else + { + featureIds[v3] = featureIds[v1]; + } +} } // namespace // ----------------------------------------------------------------------------- @@ -245,7 +332,7 @@ Result<> QuickSurfaceMesh::operator()() auto& grid = m_DataStructure.getDataRefAs(m_InputValues->GridGeomDataPath); // Get the Created Triangle Geometry - TriangleGeom& triangleGeom = m_DataStructure.getDataRefAs(m_InputValues->TriangleGeometryPath); + auto& triangleGeom = m_DataStructure.getDataRefAs(m_InputValues->TriangleGeometryPath); SizeVec3 udims = grid.getDimensions(); @@ -356,101 +443,13 @@ Result<> QuickSurfaceMesh::operator()() return {}; } -// ----------------------------------------------------------------------------- -void QuickSurfaceMesh::getGridCoordinates(const IGridGeometry* grid, size_t x, size_t y, size_t z, IGeometry::SharedVertexList& verts, IGeometry::MeshIndexType nodeIndex) -{ - nx::core::Point3D tmpCoords = grid->getPlaneCoords(x, y, z); - verts[nodeIndex] = static_cast(tmpCoords[0]); - verts[nodeIndex + 1] = static_cast(tmpCoords[1]); - verts[nodeIndex + 2] = static_cast(tmpCoords[2]); -} - -// ----------------------------------------------------------------------------- -void QuickSurfaceMesh::flipProblemVoxelCase1(Int32AbstractDataStore& featureIds, MeshIndexType v1, MeshIndexType v2, MeshIndexType v3, MeshIndexType v4, MeshIndexType v5, MeshIndexType v6) const -{ - float val = static_cast(k_Distribution(k_Generator)); // Random remaining position. - - if(val < 0.25f) - { - featureIds[v6] = featureIds[v4]; - } - else if(val < 0.5f) - { - featureIds[v6] = featureIds[v5]; - } - else if(val < 0.75f) - { - featureIds[v1] = featureIds[v2]; - } - else - { - featureIds[v1] = featureIds[v3]; - } -} - -// ----------------------------------------------------------------------------- -void QuickSurfaceMesh::flipProblemVoxelCase2(Int32AbstractDataStore& featureIds, MeshIndexType v1, MeshIndexType v2, MeshIndexType v3, MeshIndexType v4) const -{ - float val = static_cast(k_Distribution(k_Generator)); // Random remaining position. - - if(val < 0.125f) - { - featureIds[v1] = featureIds[v2]; - } - else if(val < 0.25f) - { - featureIds[v1] = featureIds[v3]; - } - else if(val < 0.375f) - { - featureIds[v2] = featureIds[v1]; - } - if(val < 0.5f) - { - featureIds[v2] = featureIds[v4]; - } - else if(val < 0.625f) - { - featureIds[v3] = featureIds[v1]; - } - else if(val < 0.75f) - { - featureIds[v3] = featureIds[v4]; - } - else if(val < 0.875f) - { - featureIds[v4] = featureIds[v2]; - } - else - { - featureIds[v4] = featureIds[v3]; - } -} - -// ----------------------------------------------------------------------------- -void QuickSurfaceMesh::flipProblemVoxelCase3(Int32AbstractDataStore& featureIds, MeshIndexType v1, MeshIndexType v2, MeshIndexType v3) const -{ - float val = static_cast(k_Distribution(k_Generator)); // Random remaining position. - - if(val < 0.5f) - { - featureIds[v2] = featureIds[v1]; - } - else - { - featureIds[v3] = featureIds[v1]; - } -} - // ----------------------------------------------------------------------------- void QuickSurfaceMesh::correctProblemVoxels() { m_MessageHandler(IFilter::Message::Type::Info, "Correcting Problem Voxels"); auto* grid = m_DataStructure.getDataAs(m_InputValues->GridGeomDataPath); - - Int32Array& featureIdsArray = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); - auto& featureIds = featureIdsArray.getDataStoreRef(); + auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); SizeVec3 udims = grid->getDimensions(); @@ -504,102 +503,102 @@ void QuickSurfaceMesh::correctProblemVoxels() if(f1 == f8 && f1 != f2 && f1 != f3 && f1 != f4 && f1 != f5 && f1 != f6 && f1 != f7) { - flipProblemVoxelCase1(featureIds, v1, v2, v3, v6, v7, v8); + ::FlipProblemVoxelCase1(featureIds, v1, v2, v3, v6, v7, v8); count++; } if(f2 == f7 && f2 != f1 && f2 != f3 && f2 != f4 && f2 != f5 && f2 != f6 && f2 != f8) { - flipProblemVoxelCase1(featureIds, v2, v1, v4, v5, v8, v7); + ::FlipProblemVoxelCase1(featureIds, v2, v1, v4, v5, v8, v7); count++; } if(f3 == f6 && f3 != f1 && f3 != f2 && f3 != f4 && f3 != f5 && f3 != f7 && f3 != f8) { - flipProblemVoxelCase1(featureIds, v3, v1, v4, v5, v8, v6); + ::FlipProblemVoxelCase1(featureIds, v3, v1, v4, v5, v8, v6); count++; } if(f4 == f5 && f4 != f1 && f4 != f2 && f4 != f3 && f4 != f6 && f4 != f7 && f4 != f8) { - flipProblemVoxelCase1(featureIds, v4, v2, v3, v6, v7, v5); + ::FlipProblemVoxelCase1(featureIds, v4, v2, v3, v6, v7, v5); count++; } if(f1 == f6 && f1 != f2 && f1 != f5) { - flipProblemVoxelCase2(featureIds, v1, v2, v5, v6); + ::FlipProblemVoxelCase2(featureIds, v1, v2, v5, v6); count++; } if(f2 == f5 && f2 != f1 && f2 != f6) { - flipProblemVoxelCase2(featureIds, v2, v1, v6, v5); + ::FlipProblemVoxelCase2(featureIds, v2, v1, v6, v5); count++; } if(f3 == f8 && f3 != f4 && f3 != f7) { - flipProblemVoxelCase2(featureIds, v3, v4, v7, v8); + ::FlipProblemVoxelCase2(featureIds, v3, v4, v7, v8); count++; } if(f4 == f7 && f4 != f3 && f4 != f8) { - flipProblemVoxelCase2(featureIds, v4, v3, v8, v7); + ::FlipProblemVoxelCase2(featureIds, v4, v3, v8, v7); count++; } if(f1 == f7 && f1 != f3 && f1 != f5) { - flipProblemVoxelCase2(featureIds, v1, v3, v5, v7); + ::FlipProblemVoxelCase2(featureIds, v1, v3, v5, v7); count++; } if(f3 == f5 && f3 != f1 && f3 != f7) { - flipProblemVoxelCase2(featureIds, v3, v1, v7, v5); + ::FlipProblemVoxelCase2(featureIds, v3, v1, v7, v5); count++; } if(f2 == f8 && f2 != f4 && f2 != f6) { - flipProblemVoxelCase2(featureIds, v2, v4, v6, v8); + ::FlipProblemVoxelCase2(featureIds, v2, v4, v6, v8); count++; } if(f4 == f6 && f4 != f2 && f4 != f8) { - flipProblemVoxelCase2(featureIds, v4, v2, v8, v6); + ::FlipProblemVoxelCase2(featureIds, v4, v2, v8, v6); count++; } if(f1 == f4 && f1 != f2 && f1 != f3) { - flipProblemVoxelCase2(featureIds, v1, v2, v3, v4); + ::FlipProblemVoxelCase2(featureIds, v1, v2, v3, v4); count++; } if(f2 == f3 && f2 != f1 && f2 != f4) { - flipProblemVoxelCase2(featureIds, v2, v1, v4, v3); + ::FlipProblemVoxelCase2(featureIds, v2, v1, v4, v3); count++; } if(f5 == f8 && f5 != f6 && f5 != f7) { - flipProblemVoxelCase2(featureIds, v5, v6, v7, v8); + ::FlipProblemVoxelCase2(featureIds, v5, v6, v7, v8); count++; } if(f6 == f7 && f6 != f5 && f6 != f8) { - flipProblemVoxelCase2(featureIds, v6, v5, v8, v7); + ::FlipProblemVoxelCase2(featureIds, v6, v5, v8, v7); count++; } if(f2 == f3 && f2 == f4 && f2 == f5 && f2 == f6 && f2 == f7 && f2 != f1 && f2 != f8) { - flipProblemVoxelCase3(featureIds, v2, v1, v8); + ::FlipProblemVoxelCase3(featureIds, v2, v1, v8); count++; } if(f1 == f3 && f1 == f4 && f1 == f5 && f1 == f7 && f2 == f8 && f1 != f2 && f1 != f7) { - flipProblemVoxelCase3(featureIds, v1, v2, v7); + ::FlipProblemVoxelCase3(featureIds, v1, v2, v7); count++; } if(f1 == f2 && f1 == f4 && f1 == f5 && f1 == f7 && f1 == f8 && f1 != f3 && f1 != f6) { - flipProblemVoxelCase3(featureIds, v1, v3, v6); + ::FlipProblemVoxelCase3(featureIds, v1, v3, v6); count++; } if(f1 == f2 && f1 == f3 && f1 == f6 && f1 == f7 && f1 == f8 && f1 != f4 && f1 != f5) { - flipProblemVoxelCase3(featureIds, v1, v4, v5); + ::FlipProblemVoxelCase3(featureIds, v1, v4, v5); count++; } } @@ -617,9 +616,7 @@ void QuickSurfaceMesh::determineActiveNodes(std::vector& nodeIds, m_MessageHandler(IFilter::Message::Type::Info, "Determining active Nodes"); auto* grid = m_DataStructure.getDataAs(m_InputValues->GridGeomDataPath); - - Int32Array& featureIdsArray = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); - Int32AbstractDataStore& featureIds = featureIdsArray.getDataStoreRef(); + Int32AbstractDataStore& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); SizeVec3 udims = grid->getDimensions(); @@ -917,11 +914,10 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod { m_MessageHandler(IFilter::Message::Type::Info, "Creating mesh"); - Int32Array& featureIdsArray = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); - auto& featureIds = featureIdsArray.getDataStoreRef(); + auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); size_t numFeatures = 0; - size_t numTuples = featureIdsArray.getNumberOfTuples(); + size_t numTuples = featureIds.getNumberOfTuples(); for(size_t i = 0; i < numTuples; i++) // for(const auto& featureId : featureIds) { @@ -960,14 +956,14 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangleGeom->getFaceAttributeMatrix()->resizeTuples({triangleCount}); triangleGeom->getVertexAttributeMatrix()->resizeTuples(tDims); - auto& faceLabels = m_DataStructure.getDataRefAs(m_InputValues->FaceLabelsDataPath); + auto& faceLabelsStore = m_DataStructure.getDataAs(m_InputValues->FaceLabelsDataPath)->getDataStoreRef(); // Resize the NodeTypes array - auto& nodeTypes = m_DataStructure.getDataRefAs(m_InputValues->NodeTypesDataPath); + auto& nodeTypes = m_DataStructure.getDataAs(m_InputValues->NodeTypesDataPath)->getDataStoreRef(); nodeTypes.resizeTuples({nodeCount}); - IGeometry::SharedVertexList& vertex = *(triangleGeom->getVertices()); - IGeometry::SharedTriList& triangle = *(triangleGeom->getFaces()); + QuickSurfaceMesh::VertexStore& vertex = triangleGeom->getVertices()->getDataStoreRef(); + QuickSurfaceMesh::TriStore& triangle = triangleGeom->getFaces()->getDataStoreRef(); ownerLists.resize(nodeCount); @@ -996,26 +992,26 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod if(i == 0) { nodeId1 = (k * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + i; - getGridCoordinates(grid, i, j, k, vertex, (m_NodeIds[nodeId1] * 3)); + ::GetGridCoordinates(grid, i, j, k, vertex, (m_NodeIds[nodeId1] * 3)); nodeId2 = (k * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + i; - getGridCoordinates(grid, i, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); + ::GetGridCoordinates(grid, i, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); nodeId3 = ((k + 1) * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + i; - getGridCoordinates(grid, i, j, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); + ::GetGridCoordinates(grid, i, j, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); nodeId4 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + i; - getGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId1]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId2]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1023,12 +1019,12 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId4]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1045,26 +1041,26 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod if(j == 0) { nodeId1 = (k * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + i; - getGridCoordinates(grid, i, j, k, vertex, (m_NodeIds[nodeId1] * 3)); + ::GetGridCoordinates(grid, i, j, k, vertex, (m_NodeIds[nodeId1] * 3)); nodeId2 = (k * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j, k, vertex, (m_NodeIds[nodeId2] * 3)); + ::GetGridCoordinates(grid, i + 1, j, k, vertex, (m_NodeIds[nodeId2] * 3)); nodeId3 = ((k + 1) * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + i; - getGridCoordinates(grid, i, j, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); + ::GetGridCoordinates(grid, i, j, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); nodeId4 = ((k + 1) * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); + ::GetGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId1]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1072,12 +1068,12 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId4]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1094,26 +1090,26 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod if(k == 0) { nodeId1 = (k * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + i; - getGridCoordinates(grid, i, j, k, vertex, (m_NodeIds[nodeId1] * 3)); + ::GetGridCoordinates(grid, i, j, k, vertex, (m_NodeIds[nodeId1] * 3)); nodeId2 = (k * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j, k, vertex, (m_NodeIds[nodeId2] * 3)); + ::GetGridCoordinates(grid, i + 1, j, k, vertex, (m_NodeIds[nodeId2] * 3)); nodeId3 = (k * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + i; - getGridCoordinates(grid, i, j + 1, k, vertex, (m_NodeIds[nodeId3] * 3)); + ::GetGridCoordinates(grid, i, j + 1, k, vertex, (m_NodeIds[nodeId3] * 3)); nodeId4 = (k * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId4] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId4] * 3)); triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId1]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId2]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1121,12 +1117,12 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId4]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1143,26 +1139,26 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod if(i == (xP - 1)) // Takes care of the end of a Row... { nodeId1 = (k * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j, k, vertex, (m_NodeIds[nodeId1] * 3)); + ::GetGridCoordinates(grid, i + 1, j, k, vertex, (m_NodeIds[nodeId1] * 3)); nodeId2 = (k * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); nodeId3 = ((k + 1) * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); + ::GetGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); nodeId4 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId1]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1170,12 +1166,12 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId4]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1192,34 +1188,34 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod else if(featureIds[point] != featureIds[neigh1]) { nodeId1 = (k * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j, k, vertex, (m_NodeIds[nodeId1] * 3)); + ::GetGridCoordinates(grid, i + 1, j, k, vertex, (m_NodeIds[nodeId1] * 3)); nodeId2 = (k * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); nodeId3 = ((k + 1) * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); + ::GetGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); nodeId4 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId1]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = featureIds[neigh1]; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = featureIds[neigh1]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; if(featureIds[point] < featureIds[neigh1]) { triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId2]; - faceLabels[triangleIndex * 2] = featureIds[point]; - faceLabels[triangleIndex * 2 + 1] = featureIds[neigh1]; + faceLabelsStore[triangleIndex * 2] = featureIds[point]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[neigh1]; } for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh1, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh1, point, faceLabelsStore); } triangleIndex++; @@ -1227,19 +1223,19 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId4]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = featureIds[neigh1]; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = featureIds[neigh1]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; if(featureIds[point] < featureIds[neigh1]) { triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId4]; - faceLabels[triangleIndex * 2] = featureIds[point]; - faceLabels[triangleIndex * 2 + 1] = featureIds[neigh1]; + faceLabelsStore[triangleIndex * 2] = featureIds[point]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[neigh1]; } for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh1, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh1, point, faceLabelsStore); } triangleIndex++; @@ -1256,26 +1252,26 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod if(j == (yP - 1)) // Takes care of the end of a column { nodeId1 = (k * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId1] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId1] * 3)); nodeId2 = (k * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + i; - getGridCoordinates(grid, i, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); + ::GetGridCoordinates(grid, i, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); nodeId3 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); nodeId4 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + i; - getGridCoordinates(grid, i, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); + ::GetGridCoordinates(grid, i, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId1]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1283,12 +1279,12 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId4]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1305,33 +1301,33 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod else if(featureIds[point] != featureIds[neigh2]) { nodeId1 = (k * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId1] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k, vertex, (m_NodeIds[nodeId1] * 3)); nodeId2 = (k * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + i; - getGridCoordinates(grid, i, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); + ::GetGridCoordinates(grid, i, j + 1, k, vertex, (m_NodeIds[nodeId2] * 3)); nodeId3 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); nodeId4 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + i; - getGridCoordinates(grid, i, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); + ::GetGridCoordinates(grid, i, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId1]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId2]; - faceLabels[triangleIndex * 2] = featureIds[neigh2]; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = featureIds[neigh2]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; if(featureIds[point] < featureIds[neigh2]) { triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = featureIds[point]; - faceLabels[triangleIndex * 2 + 1] = featureIds[neigh2]; + faceLabelsStore[triangleIndex * 2] = featureIds[point]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[neigh2]; } for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh2, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh2, point, faceLabelsStore); } triangleIndex++; @@ -1339,19 +1335,19 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId4]; - faceLabels[triangleIndex * 2] = featureIds[neigh2]; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = featureIds[neigh2]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; if(featureIds[point] < featureIds[neigh2]) { triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId4]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = featureIds[point]; - faceLabels[triangleIndex * 2 + 1] = featureIds[neigh2]; + faceLabelsStore[triangleIndex * 2] = featureIds[point]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[neigh2]; } for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh2, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh2, point, faceLabelsStore); } triangleIndex++; @@ -1368,26 +1364,26 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod if(k == (zP - 1)) // Takes care of the end of a Pillar { nodeId1 = ((k + 1) * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId1] * 3)); + ::GetGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId1] * 3)); nodeId2 = ((k + 1) * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + i; - getGridCoordinates(grid, i, j, k + 1, vertex, (m_NodeIds[nodeId2] * 3)); + ::GetGridCoordinates(grid, i, j, k + 1, vertex, (m_NodeIds[nodeId2] * 3)); nodeId3 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); nodeId4 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + i; - getGridCoordinates(grid, i, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); + ::GetGridCoordinates(grid, i, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId1]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId2]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1395,12 +1391,12 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId4]; - faceLabels[triangleIndex * 2] = -1; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = -1; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, point, point, faceLabelsStore); } triangleIndex++; @@ -1417,33 +1413,33 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod else if(featureIds[point] != featureIds[neigh3]) { nodeId1 = ((k + 1) * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId1] * 3)); + ::GetGridCoordinates(grid, i + 1, j, k + 1, vertex, (m_NodeIds[nodeId1] * 3)); nodeId2 = ((k + 1) * (xP + 1) * (yP + 1)) + (j * (xP + 1)) + i; - getGridCoordinates(grid, i, j, k + 1, vertex, (m_NodeIds[nodeId2] * 3)); + ::GetGridCoordinates(grid, i, j, k + 1, vertex, (m_NodeIds[nodeId2] * 3)); nodeId3 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + (i + 1); - getGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); + ::GetGridCoordinates(grid, i + 1, j + 1, k + 1, vertex, (m_NodeIds[nodeId3] * 3)); nodeId4 = ((k + 1) * (xP + 1) * (yP + 1)) + ((j + 1) * (xP + 1)) + i; - getGridCoordinates(grid, i, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); + ::GetGridCoordinates(grid, i, j + 1, k + 1, vertex, (m_NodeIds[nodeId4] * 3)); triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId1]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = featureIds[neigh3]; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = featureIds[neigh3]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; if(featureIds[point] < featureIds[neigh3]) { triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId2]; - faceLabels[triangleIndex * 2] = featureIds[point]; - faceLabels[triangleIndex * 2 + 1] = featureIds[neigh3]; + faceLabelsStore[triangleIndex * 2] = featureIds[point]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[neigh3]; } for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh3, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh3, point, faceLabelsStore); } triangleIndex++; @@ -1451,19 +1447,19 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod triangle[triangleIndex * 3 + 0] = m_NodeIds[nodeId2]; triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId4]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId3]; - faceLabels[triangleIndex * 2] = featureIds[neigh3]; - faceLabels[triangleIndex * 2 + 1] = featureIds[point]; + faceLabelsStore[triangleIndex * 2] = featureIds[neigh3]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[point]; if(featureIds[point] < featureIds[neigh3]) { triangle[triangleIndex * 3 + 1] = m_NodeIds[nodeId3]; triangle[triangleIndex * 3 + 2] = m_NodeIds[nodeId4]; - faceLabels[triangleIndex * 2] = featureIds[point]; - faceLabels[triangleIndex * 2 + 1] = featureIds[neigh3]; + faceLabelsStore[triangleIndex * 2] = featureIds[point]; + faceLabelsStore[triangleIndex * 2 + 1] = featureIds[neigh3]; } for(size_t dataVectorIndex = 0; dataVectorIndex < m_InputValues->SelectedDataArrayPaths.size(); dataVectorIndex++) { - tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh3, point, faceLabels); + tupleTransferFunctions[dataVectorIndex]->transfer(triangleIndex, neigh3, point, faceLabelsStore); } triangleIndex++; @@ -1481,8 +1477,7 @@ void QuickSurfaceMesh::createNodesAndTriangles(std::vector& m_Nod } } - Int8Array& m_NodeTypesArray = m_DataStructure.getDataRefAs(m_InputValues->NodeTypesDataPath); - Int8AbstractDataStore& m_NodeTypes = m_NodeTypesArray.getDataStoreRef(); + Int8AbstractDataStore& m_NodeTypes = m_DataStructure.getDataAs(m_InputValues->NodeTypesDataPath)->getDataStoreRef(); for(size_t i = 0; i < nodeCount; i++) { @@ -1519,11 +1514,10 @@ void QuickSurfaceMesh::generateTripleLines() // DataContainer* sm = getDataContainerArray()->getDataContainer(getSurfaceDataContainerName()); // // AttributeMatrix* featAttrMat = sm->getAttributeMatrix(m_FeatureAttributeMatrixName); - Int32Array& featureIdsArray = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); - Int32AbstractDataStore& featureIds = featureIdsArray.getDataStoreRef(); + Int32AbstractDataStore& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); int32_t numFeatures = 0; - size_t numTuples = featureIdsArray.getNumberOfTuples(); + size_t numTuples = featureIds.getNumberOfTuples(); for(size_t i = 0; i < numTuples; i++) { if(featureIds[i] > numFeatures) @@ -1534,7 +1528,7 @@ void QuickSurfaceMesh::generateTripleLines() std::vector featDims = {static_cast(numFeatures) + 1}; - ImageGeom* imageGeom = m_DataStructure.getDataAs(m_InputValues->GridGeomDataPath); + auto* imageGeom = m_DataStructure.getDataAs(m_InputValues->GridGeomDataPath); SizeVec3 udims = imageGeom->getDimensions(); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/QuickSurfaceMesh.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/QuickSurfaceMesh.hpp index af82a1448f..a4089d2305 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/QuickSurfaceMesh.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/QuickSurfaceMesh.hpp @@ -32,8 +32,11 @@ struct SIMPLNXCORE_EXPORT QuickSurfaceMeshInputValues class SIMPLNXCORE_EXPORT QuickSurfaceMesh { - public: + using VertexStore = AbstractDataStore; + using TriStore = AbstractDataStore; + using MeshIndexType = IGeometry::MeshIndexType; + QuickSurfaceMesh(DataStructure& dataStructure, QuickSurfaceMeshInputValues* inputValues, const std::atomic_bool& shouldCancel, const IFilter::MessageHandler& mesgHandler); ~QuickSurfaceMesh() noexcept; @@ -42,50 +45,8 @@ class SIMPLNXCORE_EXPORT QuickSurfaceMesh QuickSurfaceMesh& operator=(const QuickSurfaceMesh&) = delete; QuickSurfaceMesh& operator=(QuickSurfaceMesh&&) noexcept = delete; - using MeshIndexType = IGeometry::MeshIndexType; - Result<> operator()(); - /** - * - * @param grid - * @param x - * @param y - * @param z - * @param verts - * @param nodeIndex - */ - void getGridCoordinates(const IGridGeometry* grid, size_t x, size_t y, size_t z, IGeometry::SharedVertexList& verts, IGeometry::MeshIndexType nodeIndex); - - /** - * - * @param featureIds - * @param v1 - * @param v2 - * @param v3 - * @param v4 - * @param v5 - * @param v6 - */ - void flipProblemVoxelCase1(Int32AbstractDataStore& featureIds, MeshIndexType v1, MeshIndexType v2, MeshIndexType v3, MeshIndexType v4, MeshIndexType v5, MeshIndexType v6) const; - - /** - * @brief flipProblemVoxelCase2 - * @param v1 - * @param v2 - * @param v3 - * @param v4 - */ - void flipProblemVoxelCase2(Int32AbstractDataStore& featureIds, MeshIndexType v1, MeshIndexType v2, MeshIndexType v3, MeshIndexType v4) const; - - /** - * @brief flipProblemVoxelCase3 - * @param v1 - * @param v2 - * @param v3 - */ - void flipProblemVoxelCase3(Int32AbstractDataStore& featureIds, MeshIndexType v1, MeshIndexType v2, MeshIndexType v3) const; - /** * @brief */ @@ -107,11 +68,6 @@ class SIMPLNXCORE_EXPORT QuickSurfaceMesh */ void createNodesAndTriangles(std::vector& m_NodeIds, MeshIndexType nodeCount, MeshIndexType triangleCount); - /** - * @brief - */ - void copyCellDataToTriangleFaceArray(); - /** * @brief generateTripleLines */ @@ -124,5 +80,4 @@ class SIMPLNXCORE_EXPORT QuickSurfaceMesh const IFilter::MessageHandler& m_MessageHandler; bool m_GenerateTripleLines = false; }; - } // namespace nx::core diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadBinaryCTNorthstar.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadBinaryCTNorthstar.cpp index b38a515c7b..b28527f591 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadBinaryCTNorthstar.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadBinaryCTNorthstar.cpp @@ -32,7 +32,7 @@ Result<> ReadBinaryCTFiles(DataStructure& dataStructure, const IFilter::MessageH auto& geom = dataStructure.getDataRefAs(inputValues->ImageGeometryPath); geom.setUnits(static_cast(inputValues->LengthUnit)); - auto& density = dataStructure.getDataRefAs(inputValues->DensityArrayPath); + auto& density = dataStructure.getDataAs(inputValues->DensityArrayPath)->getDataStoreRef(); density.fill(0xABCDEF); usize deltaX = inputValues->EndVoxelCoord[0] - inputValues->StartVoxelCoord[0] + 1; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadDeformKeyFileV12.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadDeformKeyFileV12.cpp index f0eacb2e44..2efdc82501 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadDeformKeyFileV12.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadDeformKeyFileV12.cpp @@ -2,7 +2,6 @@ #include "simplnx/DataStructure/AttributeMatrix.hpp" #include "simplnx/DataStructure/Geometry/IGeometry.hpp" -#include "simplnx/DataStructure/Geometry/INodeGeometry0D.hpp" #include "simplnx/DataStructure/Geometry/QuadGeom.hpp" #include "simplnx/Utilities/StringUtilities.hpp" @@ -207,13 +206,13 @@ class IOHandler } for(usize comp = 0; comp < numComp; comp++) { - float32 value = 0.0f; + float32 value; try { value = std::stof(tokens[comp]); } catch(const std::exception& e) { - std::string msg = fmt::format("Error at line {}: Unable to convert data array {}'s string value \"{}\" to float. Threw standard exception with text: \"{}\"", m_LineCount, data.getName(), + std::string msg = fmt::format(R"(Error at line {}: Unable to convert data array {}'s string value "{}" to float. Threw standard exception with text: "{}")", m_LineCount, data.getName(), tokens[comp], e.what()); return MakeErrorResult(-2008, msg); } @@ -229,7 +228,7 @@ class IOHandler value = std::stoull(token); } catch(const std::exception& e) { - std::string msg = fmt::format("Error at line {}: Unable to convert string value \"{}\" to unsigned long long. Threw standard exception with text: \"{}\"", StringUtilities::number(m_LineCount), + std::string msg = fmt::format(R"(Error at line {}: Unable to convert string value "{}" to unsigned long long. Threw standard exception with text: "{}")", StringUtilities::number(m_LineCount), token, e.what()); return MakeErrorResult(-2000, msg); } @@ -445,13 +444,13 @@ class IOHandler { for(usize i = 0; i < m_UserDefinedVariables.size(); i++) { - auto data = m_DataStructure.getDataRefAs(m_UserDefinedArrays[i]); + auto& data = m_DataStructure.getDataRefAs(m_UserDefinedArrays[i]); setResult = setTuple(0, data, tokens); } } else { - auto data = m_DataStructure.getDataRefAs(parentPath.createChildPath(dataArrayName)); + auto& data = m_DataStructure.getDataRefAs(parentPath.createChildPath(dataArrayName)); setResult = setTuple(0, data, tokens); } if(setResult.invalid()) @@ -502,13 +501,13 @@ class IOHandler { for(usize i = 0; i < m_UserDefinedVariables.size(); i++) { - auto data = m_DataStructure.getDataRefAs(m_UserDefinedArrays[i]); + auto& data = m_DataStructure.getDataRefAs(m_UserDefinedArrays[i]); setResult = setTuple(0, data, tokens); } } else { - auto data = m_DataStructure.getDataRefAs(parentPath.createChildPath(dataArrayName)); + auto& data = m_DataStructure.getDataRefAs(parentPath.createChildPath(dataArrayName)); setResult = setTuple(tupleIndex, data, tokens); } if(setResult.invalid()) @@ -520,7 +519,7 @@ class IOHandler return {}; } - Result<> readVertexCoordinates(IGeometry::SharedVertexList* vertex, usize numVerts) + Result<> readVertexCoordinates(AbstractDataStore& vertex, usize numVerts) { std::string buf; std::vector tokens; /* vector to store the split data */ @@ -537,31 +536,31 @@ class IOHandler try { - vertex->operator[](3 * i) = std::stof(tokens[1]); + vertex[3 * i] = std::stof(tokens[1]); } catch(const std::exception& e) { - std::string msg = fmt::format("Error at line {}: Unable to convert vertex coordinate {}'s 1st string value \"{}\" to float. Threw standard exception with text: \"{}\"", + std::string msg = fmt::format(R"(Error at line {}: Unable to convert vertex coordinate {}'s 1st string value "{}" to float. Threw standard exception with text: "{}")", StringUtilities::number(m_LineCount), StringUtilities::number(i + 1), tokens[1], e.what()); return MakeErrorResult(-2001, std::move(msg)); } try { - vertex->operator[](3 * i + 1) = std::stof(tokens[2]); + vertex[3 * i + 1] = std::stof(tokens[2]); } catch(const std::exception& e) { - std::string msg = fmt::format("Error at line {}: Unable to convert vertex coordinate {}'s 2nd string value \"{}\" to float. Threw standard exception with text: \"{}\"", + std::string msg = fmt::format(R"(Error at line {}: Unable to convert vertex coordinate {}'s 2nd string value "{}" to float. Threw standard exception with text: "{}")", StringUtilities::number(m_LineCount), StringUtilities::number(i + 1), tokens[2], e.what()); return MakeErrorResult(-2002, std::move(msg)); } - vertex->operator[](3 * i + 2) = 0.0f; + vertex[3 * i + 2] = 0.0f; } return {}; } - Result<> readQuadGeometry(IGeometry::MeshIndexArrayType& quads, usize numCells) + Result<> readQuadGeometry(AbstractDataStore& quads, usize numCells) { std::string buf; std::vector tokens; /* vector to store the split data */ @@ -582,7 +581,7 @@ class IOHandler } catch(const std::exception& e) { std::string msg = - fmt::format("Error at line {}: Unable to convert quad {}'s 1st string value \"{}\" to integer. Threw standard exception with text: \"{}\"", m_LineCount, (i + 1), tokens[1], e.what()); + fmt::format(R"(Error at line {}: Unable to convert quad {}'s 1st string value "{}" to integer. Threw standard exception with text: "{}")", m_LineCount, (i + 1), tokens[1], e.what()); return MakeErrorResult(-2004, msg); } @@ -592,7 +591,7 @@ class IOHandler } catch(const std::exception& e) { std::string msg = - fmt::format("Error at line {}: Unable to convert quad {}'s 2nd string value \"{}\" to integer. Threw standard exception with text: \"{}\"", m_LineCount, (i + 1), tokens[2], e.what()); + fmt::format(R"(Error at line {}: Unable to convert quad {}'s 2nd string value "{}" to integer. Threw standard exception with text: "{}")", m_LineCount, (i + 1), tokens[2], e.what()); return MakeErrorResult(-2005, msg); } @@ -602,7 +601,7 @@ class IOHandler } catch(const std::exception& e) { std::string msg = - fmt::format("Error at line {}: Unable to convert quad {}'s 3rd string value \"{}\" to integer. Threw standard exception with text: \"{}\"", m_LineCount, (i + 1), tokens[3], e.what()); + fmt::format(R"(Error at line {}: Unable to convert quad {}'s 3rd string value "{}" to integer. Threw standard exception with text: "{}")", m_LineCount, (i + 1), tokens[3], e.what()); return MakeErrorResult(-2006, msg); } @@ -612,7 +611,7 @@ class IOHandler } catch(const std::exception& e) { std::string msg = - fmt::format("Error at line {}: Unable to convert quad {}'s 4th string value \"{}\" to integer. Threw standard exception with text: \"{}\"", m_LineCount, (i + 1), tokens[4], e.what()); + fmt::format(R"(Error at line {}: Unable to convert quad {}'s 4th string value "{}" to integer. Threw standard exception with text: "{}")", m_LineCount, (i + 1), tokens[4], e.what()); return MakeErrorResult(-2007, msg); } } @@ -631,7 +630,7 @@ class IOHandler { return {}; } - bool isWord = false; + bool isWord; std::vector tokens; // Read the line. This line _Should_ be the start of "section" of data. { @@ -679,7 +678,7 @@ class IOHandler if(m_Allocate) { // Grab vertex list from quad geom - IGeometry::SharedVertexList* vertex = m_DataStructure.getDataAs(m_QuadGeomPath)->getVertices(); + AbstractDataStore& vertex = m_DataStructure.getDataAs(m_QuadGeomPath)->getVertices()->getDataStoreRef(); auto vertexResult = readVertexCoordinates(vertex, numVerts); if(vertexResult.invalid()) @@ -707,7 +706,7 @@ class IOHandler { auto& quadGeom = m_DataStructure.getDataRefAs(m_QuadGeomPath); quadGeom.setSpatialDimensionality(2); - IGeometry::MeshIndexArrayType& quads = quadGeom.getFacesRef(); + AbstractDataStore& quads = quadGeom.getFaces()->getDataStoreRef(); auto quadResult = readQuadGeometry(quads, numCells); if(quadResult.invalid()) { @@ -746,18 +745,21 @@ class IOHandler // for either vertex or cell arrays. // This data is not able to be read. Display a status message that explains why, based on what information we have available. - if(!vertHit && quadHit) + if(vertHit != quadHit) { - std::string msg = fmt::format( - "Unable to read data: {}. Its tuple size ({}) doesn't match the correct number of tuples to be a cell array ({}), and the vertex tuple count has not been read yet. Skipping...", - dataArrayName, tupleCount, m_Cache.cellAttrMatTupleCount); - m_Filter->updateProgress(msg); - } - else if(vertHit && !quadHit) - { - std::string msg = fmt::format( - "Unable to read data: {}. Its tuple size ({}) doesn't match the correct number of tuples to be a vertex array ({}), and the cell tuple count has not been read yet. Skipping...", - dataArrayName, tupleCount, m_Cache.vertexAttrMatTupleCount); + std::string msg; + if(vertHit) + { + msg = fmt::format( + "Unable to read data: {}. Its tuple size ({}) doesn't match the correct number of tuples to be a vertex array ({}), and the cell tuple count has not been read yet. Skipping...", + dataArrayName, tupleCount, m_Cache.vertexAttrMatTupleCount); + } + else // quadHit == true + { + msg = fmt::format( + "Unable to read data: {}. Its tuple size ({}) doesn't match the correct number of tuples to be a cell array ({}), and the vertex tuple count has not been read yet. Skipping...", + dataArrayName, tupleCount, m_Cache.cellAttrMatTupleCount); + } m_Filter->updateProgress(msg); } else diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadRawBinary.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadRawBinary.cpp index 15d7ddff16..0846323f9b 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadRawBinary.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadRawBinary.cpp @@ -47,9 +47,7 @@ using namespace nx::core; namespace { -constexpr int32 k_RbrFileNotOpen = -1000; constexpr int32 k_RbrFileTooSmall = -1010; -constexpr int32 k_RbrFileTooBig = -1020; // ----------------------------------------------------------------------------- int32 SanityCheckFileSizeVersusAllocatedSize(usize allocatedBytes, usize fileSize, usize skipHeaderBytes) @@ -62,20 +60,20 @@ int32 SanityCheckFileSizeVersusAllocatedSize(usize allocatedBytes, usize fileSiz { return 1; } - // File Size and Allocated Size are equal so we are good to go + // File Size and Allocated Size are equal, so we are good to go return 0; } // ----------------------------------------------------------------------------- template -Result<> ReadBinaryFile(IDataArray& dataArrayPtr, const std::string& filename, uint64 skipHeaderBytes, ChoicesParameter::ValueType endian) +Result<> ReadBinaryFile(IDataArray* dataArrayPtr, const std::string& filename, uint64 skipHeaderBytes, ChoicesParameter::ValueType endian) { - constexpr usize k_DefaultBlocksize = 1000000; + constexpr usize k_DefaultBlockSize = 1000000; - auto& dataArray = dynamic_cast&>(dataArrayPtr); + auto* dataArray = dynamic_cast*>(dataArrayPtr); const usize fileSize = fs::file_size(filename); - const usize numBytesToRead = dataArray.getSize() * sizeof(T); + const usize numBytesToRead = dataArray->getSize() * sizeof(T); const int32 err = SanityCheckFileSizeVersusAllocatedSize(numBytesToRead, fileSize, skipHeaderBytes); if(err < 0) @@ -83,7 +81,7 @@ Result<> ReadBinaryFile(IDataArray& dataArrayPtr, const std::string& filename, u return MakeErrorResult(k_RbrFileTooSmall, "The file size is smaller than the allocated size"); } - Result<> result = ImportFromBinaryFile(fs::path(filename), dataArray, skipHeaderBytes, k_DefaultBlocksize); + Result<> result = ImportFromBinaryFile(fs::path(filename), dataArray->getDataStoreRef(), skipHeaderBytes, k_DefaultBlockSize); if(result.invalid()) { return result; @@ -91,7 +89,7 @@ Result<> ReadBinaryFile(IDataArray& dataArrayPtr, const std::string& filename, u if(endian != static_cast(nx::core::endian::native)) { - dataArray.byteSwapElements(); + dataArray->byteSwapElements(); } return result; @@ -118,9 +116,9 @@ Result<> ReadRawBinary::operator()() // ----------------------------------------------------------------------------- Result<> ReadRawBinary::execute() { - IDataArray& binaryIDataArray = m_DataStructure.getDataRefAs(m_InputValues.createdAttributeArrayPathValue); + auto* binaryIDataArray = m_DataStructure.getDataAs(m_InputValues.createdAttributeArrayPathValue); - if(binaryIDataArray.getNumberOfComponents() != static_cast(m_InputValues.numberOfComponentsValue)) + if(binaryIDataArray->getNumberOfComponents() != static_cast(m_InputValues.numberOfComponentsValue)) { // This was already validated in preflight, so something more fundamental has gone wrong throw std::runtime_error(fmt::format("Failed to acquire DataArray from path '{}' with the correct number of components.", m_InputValues.createdAttributeArrayPathValue.toString())); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadStlFile.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadStlFile.cpp index d154bdb196..153aa0c6c3 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadStlFile.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadStlFile.cpp @@ -8,7 +8,6 @@ #include "simplnx/DataStructure/Geometry/TriangleGeom.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" #include "simplnx/Utilities/GeometryUtilities.hpp" -#include "simplnx/Utilities/ParallelDataAlgorithm.hpp" #include "simplnx/Utilities/StringUtilities.hpp" #include @@ -21,7 +20,7 @@ namespace class StlFileSentinel { public: - StlFileSentinel(FILE* file) + explicit StlFileSentinel(FILE* file) : m_File(file) { } @@ -42,8 +41,8 @@ bool IsMagicsFile(const std::string& stlHeaderStr) { // Look for the tell-tale signs that the file was written from Magics Materialise // If the file was written by Magics as a "Color STL" file then the 2byte int - // values between each triangle will be NON Zero which will screw up the reading. - // These NON Zero value do NOT indicate a length but is some sort of color + // values between each triangle will be NON-Zero which will screw up the reading. + // These NON-Zero value do NOT indicate a length but is some sort of color // value encoded into the file. Instead of being normal like everyone else and // using the STL spec they went off and did their own thing. @@ -59,7 +58,7 @@ bool IsMagicsFile(const std::string& stlHeaderStr) bool IsVxElementsFile(const std::string& stlHeader) { // Look for the tell-tale signs that the file was written from VxElements Creaform - // Creaform STL files do not honor the last 2 bytes of the 50 byte Triangle struct + // STL files do not honor the last 2 bytes of the 50 byte Triangle struct // as specified in the STL Binary File specification. If we detect this, then we // ignore the 2 bytes are anything meaningful. return nx::core::StringUtilities::contains(stlHeader, "VXelements"); @@ -105,8 +104,8 @@ Result<> ReadStlFile::operator()() // Look for the tell-tale signs that the file was written from Magics Materialise // If the file was written by Magics as a "Color STL" file then the 2byte int - // values between each triangle will be NON Zero which will screw up the reading. - // This NON Zero value does NOT indicate a length but is some sort of color + // values between each triangle will be NON-Zero which will screw up the reading. + // This NON-Zero value does NOT indicate a length but is some sort of color // value encoded into the file. Instead of being normal like everyone else and // using the STL spec they went off and did their own thing. std::string stlHeaderStr(stlHeader.data(), nx::core::StlConstants::k_STL_HEADER_LENGTH); @@ -119,18 +118,18 @@ Result<> ReadStlFile::operator()() return MakeErrorResult(nx::core::StlConstants::k_TriangleCountParseError, "Error reading number of triangles from file. This is bad."); } - TriangleGeom& triangleGeom = m_DataStructure.getDataRefAs(m_GeometryDataPath); + auto& triangleGeom = m_DataStructure.getDataRefAs(m_GeometryDataPath); triangleGeom.resizeFaceList(triCount); triangleGeom.resizeVertexList(triCount * 3); - using SharedTriList = IGeometry::MeshIndexArrayType; - using SharedVertList = IGeometry::SharedVertexList; + using SharedTriList = AbstractDataStore; + using SharedVertList = AbstractDataStore; - SharedTriList& triangles = *(triangleGeom.getFaces()); - SharedVertList& nodes = *(triangleGeom.getVertices()); + SharedTriList& triangles = triangleGeom.getFaces()->getDataStoreRef(); + SharedVertList& nodes = triangleGeom.getVertices()->getDataStoreRef(); - Float64Array& faceNormals = m_DataStructure.getDataRefAs(m_FaceNormalsDataPath); + auto& faceNormalsStore = m_DataStructure.getDataAs(m_FaceNormalsDataPath)->getDataStoreRef(); // Read the triangles constexpr size_t k_StlElementCount = 12; @@ -184,7 +183,7 @@ Result<> ReadStlFile::operator()() std::string msg = fmt::format("Error reading Triangle '{}'. Object Count was {} and should have been {}", t, objsRead, k_StlElementCount); return MakeErrorResult(nx::core::StlConstants::k_TriangleParseError, msg); } - // Read the Uint16 value that is supposed to represent the number of bytes following that are file/vendor specific meta data + // Read the Uint16 value that is supposed to represent the number of bytes following that are file/vendor specific metadata // Lots of writers/vendors do NOT set this properly which can cause problems. objsRead = std::fread(&attr, sizeof(uint16_t), 1, f); // Read the Triangle Attribute Data length if(objsRead != 1) @@ -196,13 +195,13 @@ Result<> ReadStlFile::operator()() // we detected known Vendors that do not write proper STL Files. if(attr > 0 && !ignoreMetaSizeValue) { - std::ignore = std::fseek(f, static_cast(attr), SEEK_CUR); // Skip past the Triangle Attribute data since we don't know how to read it anyways + std::ignore = std::fseek(f, static_cast(attr), SEEK_CUR); // Skip past the Triangle Attribute data since we don't know how to read it anyway } // Write the data into the actual geometry - faceNormals[3 * t + 0] = static_cast(fileVert[0]); - faceNormals[3 * t + 1] = static_cast(fileVert[1]); - faceNormals[3 * t + 2] = static_cast(fileVert[2]); + faceNormalsStore[3 * t + 0] = static_cast(fileVert[0]); + faceNormalsStore[3 * t + 1] = static_cast(fileVert[1]); + faceNormalsStore[3 * t + 2] = static_cast(fileVert[2]); nodes[3 * (3 * t + 0) + 0] = fileVert[3]; nodes[3 * (3 * t + 0) + 1] = fileVert[4]; nodes[3 * (3 * t + 0) + 2] = fileVert[5]; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadVolumeGraphicsFile.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadVolumeGraphicsFile.cpp index 6371101173..5530dc2fe4 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadVolumeGraphicsFile.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReadVolumeGraphicsFile.cpp @@ -35,7 +35,7 @@ const std::atomic_bool& ReadVolumeGraphicsFile::getCancel() Result<> ReadVolumeGraphicsFile::operator()() { const DataPath densityArrayPath = m_InputValues->ImageGeometryPath.createChildPath(m_InputValues->CellAttributeMatrixName).createChildPath(m_InputValues->DensityArrayName); - auto& density = m_DataStructure.getDataRefAs(densityArrayPath); + auto& density = m_DataStructure.getDataAs(densityArrayPath)->getDataStoreRef(); auto filesize = static_cast(fs::file_size(m_InputValues->VGDataFile)); const usize allocatedBytes = density.getSize() * sizeof(float32); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/RemoveFlaggedFeatures.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/RemoveFlaggedFeatures.cpp index 0878f261df..f560c6e042 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/RemoveFlaggedFeatures.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/RemoveFlaggedFeatures.cpp @@ -14,9 +14,8 @@ using namespace nx::core; namespace { -bool IdentifyNeighbors(ImageGeom& imageGeom, Int32Array& featureIds, std::vector& storageArray, const std::atomic_bool& shouldCancel, RemoveFlaggedFeatures* filter) +bool IdentifyNeighbors(ImageGeom& imageGeom, Int32AbstractDataStore& featureIds, std::vector& storageArray, const std::atomic_bool& shouldCancel, RemoveFlaggedFeatures* filter) { - const usize totalPoints = featureIds.getNumberOfTuples(); SizeVec3 uDims = imageGeom.getDimensions(); int64 dims[3] = {static_cast(uDims[0]), static_cast(uDims[1]), static_cast(uDims[2])}; @@ -28,7 +27,7 @@ bool IdentifyNeighbors(ImageGeom& imageGeom, Int32Array& featureIds, std::vector auto progressIncrement = dims[2] / 100; usize progressCounter = 0; int32 featureName; - int64 kStride = 0, jStride = 0; + int64 kStride, jStride; for(int64 k = 0; k < dims[2]; k++) { if(shouldCancel) @@ -56,8 +55,7 @@ bool IdentifyNeighbors(ImageGeom& imageGeom, Int32Array& featureIds, std::vector continue; } shouldLoop = true; - int32 neighbor; - int32 current = 0; + int32 current; int32 most = 0; std::vector numHits(6, 0); std::vector discoveredFeatures = {}; @@ -121,7 +119,7 @@ bool IdentifyNeighbors(ImageGeom& imageGeom, Int32Array& featureIds, std::vector return shouldLoop; } -std::vector FlagFeatures(Int32Array& featureIds, std::unique_ptr& flaggedFeatures, const bool fillRemovedFeatures) +std::vector FlagFeatures(Int32AbstractDataStore& featureIds, std::unique_ptr& flaggedFeatures, const bool fillRemovedFeatures) { bool good = false; usize totalPoints = featureIds.getNumberOfTuples(); @@ -161,7 +159,7 @@ std::vector FlagFeatures(Int32Array& featureIds, std::unique_ptr& neighbors, std::vector>& voxelArrays, const std::atomic_bool& shouldCancel) +void FindVoxelArrays(const Int32AbstractDataStore& featureIds, const std::vector& neighbors, std::vector>& voxelArrays, const std::atomic_bool& shouldCancel) { const usize totalPoints = featureIds.getNumberOfTuples(); @@ -287,7 +285,7 @@ void RemoveFlaggedFeatures::sendThreadSafeProgressMessage(size_t counter) // ----------------------------------------------------------------------------- Result<> RemoveFlaggedFeatures::operator()() { - auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); auto function = static_cast(m_InputValues->ExtractFeatures); @@ -402,7 +400,7 @@ Result<> RemoveFlaggedFeatures::operator()() if(m_InputValues->FillRemovedFeatures) { - bool shouldLoop = false; + bool shouldLoop; usize count = 0; do { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReplaceElementAttributesWithNeighborValues.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReplaceElementAttributesWithNeighborValues.cpp index 0bdc0fca6d..6f79878376 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReplaceElementAttributesWithNeighborValues.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ReplaceElementAttributesWithNeighborValues.cpp @@ -23,9 +23,9 @@ class IComparisonFunctor IComparisonFunctor& operator=(const IComparisonFunctor&) = delete; // Copy Assignment Not Implemented IComparisonFunctor& operator=(IComparisonFunctor&&) = delete; // Move Assignment Not Implemented - virtual bool compare(T left, T right) const = 0; - virtual bool compare1(T left, T right) const = 0; - virtual bool compare2(T left, T right) const = 0; + [[nodiscard]] virtual bool compare(T left, T right) const = 0; + [[nodiscard]] virtual bool compare1(T left, T right) const = 0; + [[nodiscard]] virtual bool compare2(T left, T right) const = 0; }; template @@ -40,15 +40,15 @@ class LessThanComparison : public IComparisonFunctor LessThanComparison& operator=(const LessThanComparison&) = delete; // Copy Assignment Not Implemented LessThanComparison& operator=(LessThanComparison&&) = delete; // Move Assignment Not Implemented - bool compare(T left, T right) const override + [[nodiscard]] bool compare(T left, T right) const override { return left < right; } - bool compare1(T left, T right) const override + [[nodiscard]] bool compare1(T left, T right) const override { return left >= right; } - bool compare2(T left, T right) const override + [[nodiscard]] bool compare2(T left, T right) const override { return left > right; } @@ -65,15 +65,15 @@ class GreaterThanComparison : public IComparisonFunctor GreaterThanComparison& operator=(const GreaterThanComparison&) = delete; // Copy Assignment Not Implemented GreaterThanComparison& operator=(GreaterThanComparison&&) = delete; // Move Assignment Not Implemented - bool compare(T left, T right) const override + [[nodiscard]] bool compare(T left, T right) const override { return left > right; } - bool compare1(T left, T right) const override + [[nodiscard]] bool compare1(T left, T right) const override { return left <= right; } - bool compare2(T left, T right) const override + [[nodiscard]] bool compare2(T left, T right) const override { return left < right; } @@ -82,8 +82,8 @@ class GreaterThanComparison : public IComparisonFunctor struct ExecuteTemplate { template - void CompareValues(std::shared_ptr>& comparator, const DataArray& inputArray, int64 neighbor, float thresholdValue, float32& best, std::vector& bestNeighbor, - size_t i) const + void CompareValues(std::shared_ptr>& comparator, const AbstractDataStore& inputArray, int64 neighbor, float thresholdValue, float32& best, + std::vector& bestNeighbor, size_t i) const { if(comparator->compare1(inputArray[neighbor], thresholdValue) && comparator->compare2(inputArray[neighbor], best)) { @@ -93,14 +93,12 @@ struct ExecuteTemplate } template - void operator()(const ImageGeom& imageGeom, IDataArray& inputIDataArray, int32 comparisonAlgorithm, float thresholdValue, bool loopUntilDone, const std::atomic_bool& shouldCancel, + void operator()(const ImageGeom& imageGeom, IDataArray* inputIDataArray, int32 comparisonAlgorithm, float thresholdValue, bool loopUntilDone, const std::atomic_bool& shouldCancel, const IFilter::MessageHandler& messageHandler) { - using DataArrayType = DataArray; + const auto& inputStore = inputIDataArray->template getIDataStoreRefAs>(); - const auto& inputArray = dynamic_cast(inputIDataArray); - - const size_t totalPoints = inputArray.getNumberOfTuples(); + const size_t totalPoints = inputStore.getNumberOfTuples(); Vec3 udims = imageGeom.getDimensions(); std::array dims = { @@ -140,48 +138,48 @@ struct ExecuteTemplate break; } - int64 progIncrement = static_cast(totalPoints / 50); + auto progIncrement = static_cast(totalPoints / 50); int64 prog = 1; int64 progressInt = 0; for(size_t i = 0; i < totalPoints; i++) { - if(comparator->compare(inputArray[i], thresholdValue)) + if(comparator->compare(inputStore[i], thresholdValue)) { column = i % dims[0]; row = (i / dims[0]) % dims[1]; plane = i / (dims[0] * dims[1]); count++; - float32 best = inputArray[i]; + float32 best = inputStore[i]; neighbor = static_cast(i) + neighborPoints[0]; if(plane != 0) { - CompareValues(comparator, inputArray, neighbor, thresholdValue, best, bestNeighbor, i); + CompareValues(comparator, inputStore, neighbor, thresholdValue, best, bestNeighbor, i); } neighbor = static_cast(i) + neighborPoints[1]; if(row != 0) { - CompareValues(comparator, inputArray, neighbor, thresholdValue, best, bestNeighbor, i); + CompareValues(comparator, inputStore, neighbor, thresholdValue, best, bestNeighbor, i); } neighbor = static_cast(i) + neighborPoints[2]; if(column != 0) { - CompareValues(comparator, inputArray, neighbor, thresholdValue, best, bestNeighbor, i); + CompareValues(comparator, inputStore, neighbor, thresholdValue, best, bestNeighbor, i); } neighbor = static_cast(i) + neighborPoints[3]; if(column != (dims[0] - 1)) { - CompareValues(comparator, inputArray, neighbor, thresholdValue, best, bestNeighbor, i); + CompareValues(comparator, inputStore, neighbor, thresholdValue, best, bestNeighbor, i); } neighbor = static_cast(i) + neighborPoints[4]; if(row != (dims[1] - 1)) { - CompareValues(comparator, inputArray, neighbor, thresholdValue, best, bestNeighbor, i); + CompareValues(comparator, inputStore, neighbor, thresholdValue, best, bestNeighbor, i); } neighbor = static_cast(i) + neighborPoints[5]; if(plane != (dims[2] - 1)) { - CompareValues(comparator, inputArray, neighbor, thresholdValue, best, bestNeighbor, i); + CompareValues(comparator, inputStore, neighbor, thresholdValue, best, bestNeighbor, i); } } if(int64_t(i) > prog) @@ -254,10 +252,10 @@ const std::atomic_bool& ReplaceElementAttributesWithNeighborValues::getCancel() Result<> ReplaceElementAttributesWithNeighborValues::operator()() { - auto& srcIDataArray = m_DataStructure.getDataRefAs(m_InputValues->InputArrayPath); + auto* srcIDataArray = m_DataStructure.getDataAs(m_InputValues->InputArrayPath); const auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->SelectedImageGeometryPath); - ExecuteDataFunction(ExecuteTemplate{}, srcIDataArray.getDataType(), imageGeom, srcIDataArray, m_InputValues->SelectedComparison, m_InputValues->MinConfidence, m_InputValues->Loop, m_ShouldCancel, + ExecuteDataFunction(ExecuteTemplate{}, srcIDataArray->getDataType(), imageGeom, srcIDataArray, m_InputValues->SelectedComparison, m_InputValues->MinConfidence, m_InputValues->Loop, m_ShouldCancel, m_MessageHandler); return {}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ResampleImageGeom.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ResampleImageGeom.cpp index 40cf3d4680..f825ef2f85 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ResampleImageGeom.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ResampleImageGeom.cpp @@ -9,7 +9,6 @@ #include "simplnx/Utilities/ParallelDataAlgorithm.hpp" #include "simplnx/Utilities/ParallelTaskAlgorithm.hpp" #include "simplnx/Utilities/SamplingUtils.hpp" -#include "simplnx/Utilities/StringUtilities.hpp" using namespace nx::core; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ScalarSegmentFeatures.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ScalarSegmentFeatures.cpp index 1e94c4154b..1e8638807c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ScalarSegmentFeatures.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ScalarSegmentFeatures.cpp @@ -1,5 +1,7 @@ #include "ScalarSegmentFeatures.hpp" +#include + #include "simplnx/DataStructure/DataStore.hpp" #include "simplnx/DataStructure/Geometry/IGridGeometry.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" @@ -14,9 +16,6 @@ using namespace nx::core; namespace { - -constexpr StringLiteral k_CompareFunctKey = "Compare Function"; - constexpr int64 k_IncorrectInputArray = -600; constexpr int64 k_MissingInputArray = -601; constexpr int64 k_MissingOrIncorrectGoodVoxelsArray = -602; @@ -30,12 +29,13 @@ class TSpecificCompareFunctorBool : public SegmentFeatures::CompareFunctor using DataArrayType = BoolArray; CX_DEFAULT_CONSTRUCTORS(TSpecificCompareFunctorBool) - TSpecificCompareFunctorBool(IDataArray* data, int64 length, bool tolerance, AbstractDataStore* featureIds) + TSpecificCompareFunctorBool(IDataArray* data, int64 length, AbstractDataStore* featureIds) : m_Length(length) , m_FeatureIdsArray(featureIds) , m_Data(dynamic_cast(data)) { } + TSpecificCompareFunctorBool() = default; ~TSpecificCompareFunctorBool() override = default; bool operator()(int64 referencePoint, int64 neighborPoint, int32 gnum) override @@ -54,9 +54,6 @@ class TSpecificCompareFunctorBool : public SegmentFeatures::CompareFunctor return false; } -protected: - TSpecificCompareFunctorBool() = default; - private: int64 m_Length = 0; // Length of the Data Array AbstractDataStore* m_FeatureIdsArray = nullptr; // The Feature Ids @@ -79,9 +76,10 @@ class TSpecificCompareFunctor : public SegmentFeatures::CompareFunctor : m_Length(length) , m_Tolerance(tolerance) , m_FeatureIdsArray(featureIds) - , m_Data(dynamic_cast(data)->getDataStoreRef()) + , m_Data(data->template getIDataStoreRefAs()) { } + TSpecificCompareFunctor() = default; ~TSpecificCompareFunctor() override = default; bool operator()(int64 referencePoint, int64 neighborPoint, int32 gnum) override @@ -111,9 +109,6 @@ class TSpecificCompareFunctor : public SegmentFeatures::CompareFunctor return false; } -protected: - TSpecificCompareFunctor() = default; - private: int64 m_Length = 0; // Length of the Data Array T m_Tolerance = static_cast(0); // The tolerance of the comparison @@ -153,7 +148,7 @@ Result<> ScalarSegmentFeatures::operator()() m_FeatureIdsArray = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath); m_FeatureIdsArray->fill(0); // initialize the output array with zeros - IDataArray* inputDataArray = m_DataStructure.getDataAs(m_InputValues->InputDataPath); + auto* inputDataArray = m_DataStructure.getDataAs(m_InputValues->InputDataPath); size_t inDataPoints = inputDataArray->getNumberOfTuples(); nx::core::DataType dataType = inputDataArray->getDataType(); @@ -170,7 +165,7 @@ Result<> ScalarSegmentFeatures::operator()() break; } case nx::core::DataType::boolean: { - m_CompareFunctor = std::make_shared(inputDataArray, inDataPoints, static_cast(m_InputValues->ScalarTolerance), featureIds); + m_CompareFunctor = std::make_shared(inputDataArray, inDataPoints, featureIds); break; } case nx::core::DataType::int16: { @@ -210,7 +205,7 @@ Result<> ScalarSegmentFeatures::operator()() } if(inputDataArray->getNumberOfComponents() != 1) { - m_CompareFunctor = std::shared_ptr(new SegmentFeatures::CompareFunctor()); // The default CompareFunctor which ALWAYS returns false for the comparison + m_CompareFunctor = std::make_shared(); // The default CompareFunctor which ALWAYS returns false for the comparison } // Run the segmentation algorithm @@ -227,9 +222,9 @@ Result<> ScalarSegmentFeatures::operator()() cellFeaturesAM.resizeTuples(tDims); // This will resize the active array // make sure all values are initialized and "re-reserve" index 0 - auto* activeArray = m_DataStructure.getDataAs(m_InputValues->ActiveArrayPath); - activeArray->getDataStore()->fill(1); - (*activeArray)[0] = 0; + auto& activeStore = m_DataStructure.getDataAs(m_InputValues->ActiveArrayPath)->getDataStoreRef(); + activeStore.fill(1); + activeStore[0] = 0; // Randomize the feature Ids for purely visual clarify. Having random Feature Ids // allows users visualizing the data to better discern each grain otherwise the coloring @@ -250,23 +245,23 @@ int64_t ScalarSegmentFeatures::getSeed(int32 gnum, int64 nextSeed) const int64 seed = -1; // start with the next voxel after the last seed - auto randpoint = static_cast(nextSeed); - while(seed == -1 && randpoint < totalPoints) + auto randPoint = static_cast(nextSeed); + while(seed == -1 && randPoint < totalPoints) { - if(featureIds->getValue(randpoint) == 0) // If the GrainId of the voxel is ZERO then we can use this as a seed point + if(featureIds->getValue(randPoint) == 0) // If the GrainId of the voxel is ZERO then we can use this as a seed point { - if(!m_InputValues->UseMask || m_GoodVoxels->isTrue(randpoint)) + if(!m_InputValues->UseMask || m_GoodVoxels->isTrue(randPoint)) { - seed = randpoint; + seed = randPoint; } else { - randpoint += 1; + randPoint += 1; } } else { - randpoint += 1; + randPoint += 1; } } if(seed >= 0) @@ -279,7 +274,7 @@ int64_t ScalarSegmentFeatures::getSeed(int32 gnum, int64 nextSeed) const // ----------------------------------------------------------------------------- bool ScalarSegmentFeatures::determineGrouping(int64 referencepoint, int64 neighborpoint, int32 gnum) const { - auto featureIds = m_FeatureIdsArray->getDataStore(); + auto* featureIds = m_FeatureIdsArray->getDataStore(); if(featureIds->getValue(neighborpoint) == 0 && (!m_InputValues->UseMask || m_GoodVoxels->isTrue(neighborpoint))) { CompareFunctor* func = m_CompareFunctor.get(); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SharedFeatureFace.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SharedFeatureFace.cpp index f9184b4e2e..eb63e9c1c6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SharedFeatureFace.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SharedFeatureFace.cpp @@ -1,7 +1,6 @@ #include "SharedFeatureFace.hpp" #include "simplnx/DataStructure/DataArray.hpp" -#include "simplnx/DataStructure/DataGroup.hpp" #include "simplnx/DataStructure/Geometry/TriangleGeom.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" #include "simplnx/Utilities/ParallelDataAlgorithm.hpp" @@ -24,7 +23,7 @@ uint64 ConvertToUInt64(uint32 highWord, uint32 lowWord) class SharedFeatureFaceImpl { public: - SharedFeatureFaceImpl(const std::vector>& faceLabelVector, Int32Array& surfaceMeshFeatureFaceLabels, Int32Array& surfaceMeshFeatureFaceNumTriangles, + SharedFeatureFaceImpl(const std::vector>& faceLabelVector, Int32AbstractDataStore& surfaceMeshFeatureFaceLabels, Int32AbstractDataStore& surfaceMeshFeatureFaceNumTriangles, std::map& faceSizeMap, const std::atomic_bool& shouldCancel) : m_FaceLabelVector(faceLabelVector) , m_SurfaceMeshFeatureFaceLabels(surfaceMeshFeatureFaceLabels) @@ -56,8 +55,8 @@ class SharedFeatureFaceImpl private: const std::vector>& m_FaceLabelVector; - Int32Array& m_SurfaceMeshFeatureFaceLabels; - Int32Array& m_SurfaceMeshFeatureFaceNumTriangles; + Int32AbstractDataStore& m_SurfaceMeshFeatureFaceLabels; + Int32AbstractDataStore& m_SurfaceMeshFeatureFaceNumTriangles; std::map& m_FaceSizeMap; const std::atomic_bool& m_ShouldCancel; }; @@ -67,8 +66,7 @@ using Int64Distribution = std::uniform_int_distribution; // ----------------------------------------------------------------------------- SeedGenerator initializeStaticVoxelSeedGenerator(Int64Distribution& distribution, const int64 rangeMin, const int64 rangeMax) { - SeedGenerator generator; - generator.seed(SeedGenerator::default_seed); + SeedGenerator generator(SeedGenerator::default_seed); distribution = std::uniform_int_distribution(rangeMin, rangeMax); return generator; @@ -83,8 +81,8 @@ void RandomizeFaceIds(nx::core::Int32Array& featureIds, uint64 totalFeatures, In auto generator = initializeStaticVoxelSeedGenerator(distribution, rangeMin, rangeMax); DataStructure tmpStructure; - auto rndNumbers = Int64Array::CreateWithStore>(tmpStructure, std::string("_INTERNAL_USE_ONLY_NewFeatureIds"), std::vector{totalFeatures}, std::vector{1}); - auto rndStore = rndNumbers->getDataStore(); + auto* rndNumbers = Int64Array::CreateWithStore>(tmpStructure, std::string("_INTERNAL_USE_ONLY_NewFeatureIds"), std::vector{totalFeatures}, std::vector{1}); + auto* rndStore = rndNumbers->getDataStore(); for(int64 i = 0; i < totalFeatures; ++i) { @@ -107,7 +105,7 @@ void RandomizeFaceIds(nx::core::Int32Array& featureIds, uint64 totalFeatures, In rndStore->setValue(r, temp); } - // Now adjust all the Grain Id values for each Voxel + // Now adjust all the GrainId values for each Voxel auto featureIdsStore = featureIds.getDataStore(); uint64 totalPoints = featureIds.getNumberOfTuples(); for(int64 i = 0; i < totalPoints; ++i) @@ -152,7 +150,7 @@ Result<> SharedFeatureFace::operator()() int32 index = 1; std::vector> faceLabelVector; - faceLabelVector.emplace_back(std::pair(0, 0)); + faceLabelVector.emplace_back(0, 0); // Loop through all the Triangles and figure out how many triangles we have in each one. for(usize t = 0; t < totalPoints; ++t) @@ -177,7 +175,7 @@ Result<> SharedFeatureFace::operator()() faceSizeMap[faceId64] = 1; faceIdMap[faceId64] = index; surfaceMeshFeatureFaceIds[t] = index; - faceLabelVector.emplace_back(std::pair(high, low)); + faceLabelVector.emplace_back(high, low); ++index; } else @@ -196,10 +194,10 @@ Result<> SharedFeatureFace::operator()() std::vector tDims = {static_cast(index)}; faceFeatureAttrMat.resizeTuples(tDims); - auto& surfaceMeshFeatureFaceLabels = m_DataStructure.getDataRefAs(m_InputValues->FeatureFaceLabelsArrayPath); - auto& surfaceMeshFeatureFaceNumTriangles = m_DataStructure.getDataRefAs(m_InputValues->FeatureFaceNumTrianglesArrayPath); - surfaceMeshFeatureFaceLabels.getDataStore()->resizeTuples(tDims); - surfaceMeshFeatureFaceNumTriangles.getDataStore()->resizeTuples(tDims); + auto& surfaceMeshFeatureFaceLabels = m_DataStructure.getDataAs(m_InputValues->FeatureFaceLabelsArrayPath)->getDataStoreRef(); + auto& surfaceMeshFeatureFaceNumTriangles = m_DataStructure.getDataAs(m_InputValues->FeatureFaceNumTrianglesArrayPath)->getDataStoreRef(); + surfaceMeshFeatureFaceLabels.resizeTuples(tDims); + surfaceMeshFeatureFaceNumTriangles.resizeTuples(tDims); // For smaller data sets having data parallelization ON actually runs slower due to // all the overhead of the threads. We are just going to turn this off for @@ -213,7 +211,7 @@ Result<> SharedFeatureFace::operator()() if(m_InputValues->ShouldRandomizeFeatureIds) { const int64 rangeMin = 0; - const int64 rangeMax = static_cast(surfaceMeshFeatureFaceNumTriangles.getNumberOfTuples() - 1); + const auto rangeMax = static_cast(surfaceMeshFeatureFaceNumTriangles.getNumberOfTuples() - 1); Int64Distribution distribution; initializeStaticVoxelSeedGenerator(distribution, rangeMin, rangeMax); ::RandomizeFaceIds(surfaceMeshFeatureFaceIds, index, distribution); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/Silhouette.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/Silhouette.cpp index 03b1806d1d..cf652236a4 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/Silhouette.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/Silhouette.cpp @@ -26,9 +26,9 @@ class SilhouetteTemplate return Pointer(static_cast(nullptr)); } - SilhouetteTemplate(const IDataArray& inputIDataArray, Float64Array& outputDataArray, const std::unique_ptr& maskDataArray, usize numClusters, const Int32Array& featureIds, - ClusterUtilities::DistanceMetric distMetric) - : m_InputData(dynamic_cast(inputIDataArray)) + SilhouetteTemplate(const IDataArray& inputIDataArray, Float64AbstractDataStore& outputDataArray, const std::unique_ptr& maskDataArray, usize numClusters, + const Int32AbstractDataStore& featureIds, ClusterUtilities::DistanceMetric distMetric) + : m_InputData(inputIDataArray.template getIDataStoreRefAs()) , m_OutputData(outputDataArray) , m_Mask(maskDataArray) , m_NumClusters(numClusters) @@ -121,10 +121,10 @@ class SilhouetteTemplate } private: - using DataArrayT = DataArray; - const DataArrayT& m_InputData; - Float64Array& m_OutputData; - const Int32Array& m_FeatureIds; + using AbstractDataStoreT = AbstractDataStore; + const AbstractDataStoreT& m_InputData; + Float64AbstractDataStore& m_OutputData; + const Int32AbstractDataStore& m_FeatureIds; const std::unique_ptr& m_Mask; usize m_NumClusters; ClusterUtilities::DistanceMetric m_DistMetric; @@ -158,7 +158,7 @@ const std::atomic_bool& Silhouette::getCancel() // ----------------------------------------------------------------------------- Result<> Silhouette::operator()() { - auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); std::unordered_set uniqueIds; usize numTuples = featureIds.getNumberOfTuples(); @@ -179,7 +179,8 @@ Result<> Silhouette::operator()() std::string message = fmt::format("Mask Array DataPath does not exist or is not of the correct type (Bool | UInt8) {}", m_InputValues->MaskArrayPath.toString()); return MakeErrorResult(-54080, message); } - RunTemplateClass(clusteringArray.getDataType(), clusteringArray, m_DataStructure.getDataRefAs(m_InputValues->SilhouetteArrayPath), - maskCompare, uniqueIds.size(), featureIds, m_InputValues->DistanceMetric); + RunTemplateClass(clusteringArray.getDataType(), clusteringArray, + m_DataStructure.getDataAs(m_InputValues->SilhouetteArrayPath)->getDataStoreRef(), maskCompare, uniqueIds.size(), featureIds, + m_InputValues->DistanceMetric); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.cpp index 03c5adc380..49e7b7e9f0 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.cpp @@ -7,6 +7,35 @@ using namespace nx::core; +namespace +{ +// ----------------------------------------------------------------------------- +char RayIntersectsPlane(const float32 d, const std::array& q, const std::array& r, std::array& p) +{ + const float64 rqDelZ = r[2] - q[2]; + const float64 dqDelZ = d - q[2]; + const float64 t = dqDelZ / rqDelZ; + for(int i = 0; i < 3; i++) + { + p[i] = q[i] + (t * (r[i] - q[i])); + } + if(t > 0.0 && t < 1.0) + { + return '1'; + } + if(t == 0.0) + { + return 'q'; + } + if(t == 1.0) + { + return 'r'; + } + + return '0'; +} +} // namespace + // ----------------------------------------------------------------------------- SliceTriangleGeometry::SliceTriangleGeometry(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, SliceTriangleGeometryInputValues* inputValues) @@ -39,8 +68,8 @@ Result<> SliceTriangleGeometry::operator()() return MakeErrorResult(-62101, "Error retrieving the shared edge list"); } - INodeGeometry2D::SharedFaceList& tris = triangle.getFacesRef(); - INodeGeometry0D::SharedVertexList& triVerts = triangle.getVerticesRef(); + TriStore& tris = triangle.getFaces()->getDataStoreRef(); + VertsStore& triVerts = triangle.getVertices()->getDataStoreRef(); usize numTris = triangle.getNumberOfFaces(); usize numTriVerts = triangle.getNumberOfVertices(); @@ -65,23 +94,23 @@ Result<> SliceTriangleGeometry::operator()() std::vector regionIds; // Get an object reference to the pointer - const auto* triRegionId = m_DataStructure.getDataAs(m_InputValues->RegionIdArrayPath); + const auto& triRegionId = m_DataStructure.getDataAs(m_InputValues->RegionIdArrayPath)->getDataStoreRef(); int32 edgeCounter = 0; for(usize i = 0; i < numTris; i++) { int32 regionId = 0; - // get region Id of this triangle (if they are available) + // get regionId of this triangle (if they are available) if(m_InputValues->HaveRegionIds) { - regionId = (*triRegionId)[i]; + regionId = triRegionId[i]; } // determine which slices would hit the triangle auto minTriDim = std::numeric_limits::max(); float32 maxTriDim = -minTriDim; for(usize j = 0; j < 3; j++) { - int64 vert = tris[3 * i + j]; + TriStore::value_type vert = tris[3 * i + j]; if(minTriDim > triVerts[3 * vert + 2]) { minTriDim = triVerts[3 * vert + 2]; @@ -140,11 +169,11 @@ Result<> SliceTriangleGeometry::operator()() r[2] = triVerts[3 * tris[3 * i + 1] + 2]; if(q[2] > r[2]) { - val = rayIntersectsPlane(d, r, q, p); + val = RayIntersectsPlane(d, r, q, p); } else { - val = rayIntersectsPlane(d, q, r, p); + val = RayIntersectsPlane(d, q, r, p); } if(val == '1') { @@ -165,11 +194,11 @@ Result<> SliceTriangleGeometry::operator()() r[2] = triVerts[3 * tris[3 * i + 2] + 2]; if(q[2] > r[2]) { - val = rayIntersectsPlane(d, r, q, p); + val = RayIntersectsPlane(d, r, q, p); } else { - val = rayIntersectsPlane(d, q, r, p); + val = RayIntersectsPlane(d, q, r, p); } if(val == '1') { @@ -190,11 +219,11 @@ Result<> SliceTriangleGeometry::operator()() q[2] = triVerts[3 * tris[3 * i + 1] + 2]; if(q[2] > r[2]) { - val = rayIntersectsPlane(d, r, q, p); + val = RayIntersectsPlane(d, r, q, p); } else { - val = rayIntersectsPlane(d, q, r, p); + val = RayIntersectsPlane(d, q, r, p); } if(val == '1') { @@ -314,33 +343,7 @@ Result<> SliceTriangleGeometry::operator()() } // ----------------------------------------------------------------------------- -char SliceTriangleGeometry::rayIntersectsPlane(const float d, const std::array& q, const std::array& r, std::array& p) -{ - const float64 rqDelZ = r[2] - q[2]; - const float64 dqDelZ = d - q[2]; - const float64 t = dqDelZ / rqDelZ; - for(int i = 0; i < 3; i++) - { - p[i] = q[i] + (t * (r[i] - q[i])); - } - if(t > 0.0 && t < 1.0) - { - return '1'; - } - if(t == 0.0) - { - return 'q'; - } - if(t == 1.0) - { - return 'r'; - } - - return '0'; -} - -// ----------------------------------------------------------------------------- -usize SliceTriangleGeometry::determineBoundsAndNumSlices(float32& minDim, float32& maxDim, usize numTris, INodeGeometry2D::SharedFaceList& tris, INodeGeometry0D::SharedVertexList& triVerts) +usize SliceTriangleGeometry::determineBoundsAndNumSlices(float32& minDim, float32& maxDim, usize numTris, TriStore& tris, VertsStore& triVerts) { for(usize i = 0; i < numTris; i++) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.hpp index 88ace92f7f..43e385952c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SliceTriangleGeometry.hpp @@ -51,8 +51,9 @@ class SIMPLNXCORE_EXPORT SliceTriangleGeometry const std::atomic_bool& getCancel(); protected: - char rayIntersectsPlane(float32 d, const std::array& q, const std::array& r, std::array& p); - usize determineBoundsAndNumSlices(float32& minDim, float32& maxDim, usize numTris, INodeGeometry2D::SharedFaceList& tris, INodeGeometry0D::SharedVertexList& triVerts); + using TriStore = AbstractDataStore; + using VertsStore = AbstractDataStore; + usize determineBoundsAndNumSlices(float32& minDim, float32& maxDim, usize numTris, TriStore& tris, VertsStore& triVerts); private: DataStructure& m_DataStructure; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SplitAttributeArray.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SplitAttributeArray.cpp index c8ad3c06b4..8aab40214b 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SplitAttributeArray.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SplitAttributeArray.cpp @@ -11,20 +11,20 @@ namespace struct SplitArraysFunctor { template - void operator()(DataStructure& dataStructure, const SplitAttributeArrayInputValues* inputValues) + void operator()(DataStructure& dataStructure, const IDataArray* inputIDataArray, const SplitAttributeArrayInputValues* inputValues) { - auto& inputArray = dataStructure.getDataRefAs>(inputValues->InputArrayPath); - usize numTuples = inputArray.getNumberOfTuples(); - usize numComponents = inputArray.getNumberOfComponents(); + const auto& inputStore = inputIDataArray->template getIDataStoreRefAs>(); + usize numTuples = inputStore.getNumberOfTuples(); + usize numComponents = inputStore.getNumberOfComponents(); for(const auto& j : inputValues->ExtractComponents) { std::string arrayName = inputValues->InputArrayPath.getTargetName() + inputValues->SplitArraysSuffix + StringUtilities::number(j); DataPath splitArrayPath = inputValues->InputArrayPath.replaceName(arrayName); - auto& splitArray = dataStructure.getDataRefAs>(splitArrayPath); + auto& splitStore = dataStructure.getDataAs>(splitArrayPath)->getDataStoreRef(); for(usize i = 0; i < numTuples; i++) { - splitArray[i] = inputArray[numComponents * i + j]; + splitStore[i] = inputStore[numComponents * i + j]; } } } @@ -52,9 +52,9 @@ const std::atomic_bool& SplitAttributeArray::getCancel() // ----------------------------------------------------------------------------- Result<> SplitAttributeArray::operator()() { - auto& inputArray = m_DataStructure.getDataRefAs(m_InputValues->InputArrayPath); + auto* inputArray = m_DataStructure.getDataAs(m_InputValues->InputArrayPath); - ExecuteDataFunction(SplitArraysFunctor{}, inputArray.getDataType(), m_DataStructure, m_InputValues); + ExecuteDataFunction(SplitArraysFunctor{}, inputArray->getDataType(), m_DataStructure, inputArray, m_InputValues); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.cpp index 4a96461b1e..81beb435e0 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/SurfaceNets.cpp @@ -16,37 +16,6 @@ using namespace nx::core; namespace { -// -// Private data class for storing quad data during OBJ data generation -// -class MMQuad -{ -public: - MMQuad() - : m_VertexIndices{-1, -1, -1, -1} - , m_Labels{0, 0} - { - } - MMQuad(std::array vi, std::array labels) - : m_VertexIndices{vi[0], vi[1], vi[2], vi[3]} - , m_Labels{labels[0], labels[1]} - { - } - - void getVertexIndices(std::array& vertexIndices) - { - std::copy(m_VertexIndices.begin(), m_VertexIndices.end(), vertexIndices.begin()); - } - void getLabels(std::array& labels) - { - std::copy(m_Labels.begin(), m_Labels.end(), labels.begin()); - } - -private: - std::array m_VertexIndices; - std::array m_Labels; -}; - struct VertexData { int VertexId; @@ -102,43 +71,6 @@ void getQuadTriangleIDs(std::array& vData, bool isQuadFrontFacing triangleVtxIDs[4] = vData[2].VertexId; triangleVtxIDs[5] = vData[3].VertexId; } - -void exportObjFiles(MMSurfaceNet* m_surfaceNet) -{ - if(m_surfaceNet == nullptr) - { - return; - } - std::shared_ptr const geometry = std::make_shared(m_surfaceNet); - - // Export an OBJ file for each material to the specified path - std::vector const materials = geometry->labels(); - for(const auto& itMatIdx : materials) - { - if(itMatIdx > 20 && itMatIdx < 65530) - { - continue; - } - const std::string filename = fmt::format("surface_mash_test_{}.obj", itMatIdx); - std::cout << "Export file Obj file: " << filename << "\n"; - std::ofstream stream(filename, std::ios_base::binary); - if(stream.is_open()) - { - const MMGeometryOBJ::OBJData data = geometry->objData(itMatIdx); - stream << "# vertices for feature id " << itMatIdx << "\n"; - for(const auto& vertex : data.vertexPositions) - { - stream << "v " << (vertex)[0] << ' ' << (vertex)[1] << ' ' << (vertex)[2] << "\n"; - } - stream << "# triangles for feature id " << itMatIdx << "\n"; - for(const auto& face : data.triangles) - { - stream << "f " << (face)[0] << ' ' << (face)[1] << ' ' << (face)[2] << "\n"; - } - } - } -} - } // namespace // ----------------------------------------------------------------------------- SurfaceNets::SurfaceNets(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, SurfaceNetsInputValues* inputValues) @@ -165,7 +97,7 @@ Result<> SurfaceNets::operator()() auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->GridGeomDataPath); // Get the Created Triangle Geometry - TriangleGeom& triangleGeom = m_DataStructure.getDataRefAs(m_InputValues->TriangleGeometryPath); + auto& triangleGeom = m_DataStructure.getDataRefAs(m_InputValues->TriangleGeometryPath); auto gridDimensions = imageGeom.getDimensions(); auto voxelSize = imageGeom.getSpacing(); @@ -173,7 +105,7 @@ Result<> SurfaceNets::operator()() IntVec3 arraySize(static_cast(gridDimensions[0]), static_cast(gridDimensions[1]), static_cast(gridDimensions[2])); - Int32Array& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); using LabelType = int32; std::vector labels(featureIds.getNumberOfTuples()); @@ -205,7 +137,7 @@ Result<> SurfaceNets::operator()() triangleGeom.getVertexAttributeMatrix()->resizeTuples({static_cast(nodeCount)}); // Remove and then insert a properly sized int8 for the NodeTypes - Int8Array& nodeTypes = m_DataStructure.getDataRefAs(m_InputValues->NodeTypesDataPath); + auto& nodeTypes = m_DataStructure.getDataAs(m_InputValues->NodeTypesDataPath)->getDataStoreRef(); nodeTypes.resizeTuples({static_cast(nodeCount)}); Point3Df position = {0.0f, 0.0f, 0.0f}; @@ -287,7 +219,7 @@ Result<> SurfaceNets::operator()() triangleGeom.getFaceAttributeMatrix()->resizeTuples({triangleCount}); // Resize the face labels Int32Array - Int32Array& faceLabels = m_DataStructure.getDataRefAs(m_InputValues->FaceLabelsDataPath); + auto& faceLabels = m_DataStructure.getDataAs(m_InputValues->FaceLabelsDataPath)->getDataStoreRef(); faceLabels.resizeTuples({triangleCount}); // Create a vector of TupleTransferFunctions for each of the Triangle Face to VertexType Data Arrays diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TriangleCentroid.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TriangleCentroid.cpp index 0a668fcf73..d738b941a9 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TriangleCentroid.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TriangleCentroid.cpp @@ -1,7 +1,6 @@ #include "TriangleCentroid.hpp" #include "simplnx/DataStructure/DataArray.hpp" -#include "simplnx/DataStructure/DataGroup.hpp" #include "simplnx/DataStructure/Geometry/IGeometry.hpp" #include "simplnx/DataStructure/Geometry/TriangleGeom.hpp" #include "simplnx/Utilities/Math/MatrixMath.hpp" @@ -19,7 +18,7 @@ namespace class CalculateCentroidsImpl { public: - CalculateCentroidsImpl(const TriangleGeom* triangleGeom, Float64Array* centroids, const std::atomic_bool& shouldCancel) + CalculateCentroidsImpl(const TriangleGeom* triangleGeom, Float64AbstractDataStore& centroids, const std::atomic_bool& shouldCancel) : m_TriangleGeom(triangleGeom) , m_Centroids(centroids) , m_ShouldCancel(shouldCancel) @@ -39,9 +38,9 @@ class CalculateCentroidsImpl std::array vertCoords; m_TriangleGeom->getFaceCoordinates(triangleIndex, vertCoords); - (*m_Centroids)[triangleIndex * 3] = (vertCoords[0].getX() + vertCoords[1].getX() + vertCoords[2].getX()) / 3.0F; - (*m_Centroids)[triangleIndex * 3 + 1] = (vertCoords[0].getY() + vertCoords[1].getY() + vertCoords[2].getY()) / 3.0F; - (*m_Centroids)[triangleIndex * 3 + 2] = (vertCoords[0].getZ() + vertCoords[1].getZ() + vertCoords[2].getZ()) / 3.0F; + m_Centroids[triangleIndex * 3] = (vertCoords[0].getX() + vertCoords[1].getX() + vertCoords[2].getX()) / 3.0F; + m_Centroids[triangleIndex * 3 + 1] = (vertCoords[0].getY() + vertCoords[1].getY() + vertCoords[2].getY()) / 3.0F; + m_Centroids[triangleIndex * 3 + 2] = (vertCoords[0].getZ() + vertCoords[1].getZ() + vertCoords[2].getZ()) / 3.0F; } } @@ -52,7 +51,7 @@ class CalculateCentroidsImpl private: const TriangleGeom* m_TriangleGeom = nullptr; - Float64Array* m_Centroids = nullptr; + Float64AbstractDataStore& m_Centroids; const std::atomic_bool& m_ShouldCancel; }; } // namespace @@ -83,12 +82,12 @@ Result<> TriangleCentroid::operator()() const AttributeMatrix& faceAttributeMatrix = triangleGeom->getFaceAttributeMatrixRef(); const DataPath pCentroidsPath = m_InputValues->TriangleGeometryDataPath.createChildPath(faceAttributeMatrix.getName()).createChildPath(m_InputValues->CentroidsArrayName); - auto* centroidsArray = m_DataStructure.getDataAs(pCentroidsPath); + auto& centroidsStore = m_DataStructure.getDataAs(pCentroidsPath)->getDataStoreRef(); // Parallel algorithm to calculate the centroids ParallelDataAlgorithm dataAlg; dataAlg.setRange(0ULL, static_cast(triangleGeom->getNumberOfFaces())); - dataAlg.execute(CalculateCentroidsImpl(triangleGeom, centroidsArray, m_ShouldCancel)); + dataAlg.execute(CalculateCentroidsImpl(triangleGeom, centroidsStore, m_ShouldCancel)); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.cpp index 364811a48d..b99a4f062b 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.cpp @@ -2,55 +2,57 @@ namespace nx::core { - void AddTupleTransferInstance(DataStructure& dataStructure, const DataPath& selectedDataPath, const DataPath& createdDataPath, std::vector>& tupleTransferFunctions) { auto* inputDataArray = dataStructure.getDataAs(selectedDataPath); - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) + switch(inputDataArray->getDataType()) { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::int8: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::uint8: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::int16: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::uint16: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::int32: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::uint32: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::int64: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::uint64: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::float32: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { - tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + case DataType::float64: { + tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; } - if(TemplateHelpers::CanDynamicCast()(inputDataArray)) - { + case DataType::boolean: { tupleTransferFunctions.push_back(std::make_shared>(dataStructure, selectedDataPath, createdDataPath)); + break; + } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.hpp index 505b243bfd..700be14986 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/TupleTransfer.hpp @@ -35,7 +35,7 @@ class SIMPLNXCORE_EXPORT AbstractTupleTransfer virtual void transfer(size_t faceIndex, size_t firstcIndex) = 0; - virtual void transfer(size_t faceIndex, size_t firstcIndex, size_t secondcIndex, DataArray& faceLabels) = 0; + virtual void transfer(size_t faceIndex, size_t firstcIndex, size_t secondcIndex, AbstractDataStore& faceLabels) = 0; protected: AbstractTupleTransfer() = default; @@ -106,7 +106,7 @@ class TransferTuple : public AbstractTupleTransfer } } - void transfer(size_t faceIndex, size_t firstcIndex, size_t secondcIndex, DataArray& faceLabels) override + void transfer(size_t faceIndex, size_t firstcIndex, size_t secondcIndex, AbstractDataStore& faceLabels) override { // Only copy the data if the FaceLabel is NOT -1, indicating that the data is NOT on the exterior if(faceLabels[faceIndex * 2] != -1) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.cpp index 073ba9d6a3..83773119cd 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/UncertainRegularGridSampleSurfaceMesh.cpp @@ -36,9 +36,7 @@ void UncertainRegularGridSampleSurfaceMesh::generatePoints(std::vector points.reserve(dims[0] * dims[1] * dims[2]); - std::random_device randomDevice; // Will be used to obtain a seed for the random number engine - std::mt19937 generator(randomDevice()); // Standard mersenne_twister_engine seeded with rd() - generator.seed(m_InputValues->SeedValue); + std::mt19937 generator(m_InputValues->SeedValue); // Standard mersenne_twister_engine seeded std::uniform_real_distribution distribution(0.0F, 1.0F); for(usize k = 0; k < dims[2]; k++) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAbaqusHexahedron.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAbaqusHexahedron.cpp index d7a43d5214..b978029e3e 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAbaqusHexahedron.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAbaqusHexahedron.cpp @@ -187,7 +187,7 @@ int32 writeElems(WriteAbaqusHexahedron* filter, const std::string& fileName, con return err; } -int32 writeElset(WriteAbaqusHexahedron* filter, const std::string& fileName, size_t totalPoints, const Int32Array& featureIds, const std::atomic_bool& shouldCancel) +int32 writeElset(WriteAbaqusHexahedron* filter, const std::string& fileName, size_t totalPoints, const Int32AbstractDataStore& featureIds, const std::atomic_bool& shouldCancel) { int32 err = 0; FILE* f = fopen(fileName.c_str(), "wb"); @@ -217,7 +217,7 @@ int32 writeElset(WriteAbaqusHexahedron* filter, const std::string& fileName, siz usize elementPerLine = 0; fprintf(f, "\n*Elset, elset=Grain%d_set\n", voxelId); - for(usize i = 0; i < featureIds.size(); i++) + for(usize i = 0; i < featureIds.getSize(); i++) { if(featureIds[i] == voxelId) { @@ -290,7 +290,7 @@ int32 writeMaster(const std::string& file, const std::string& jobName, const std return err; } -int32 writeSects(const std::string& file, const Int32Array& featureIds, int32 hourglassStiffness) +int32 writeSects(const std::string& file, const Int32AbstractDataStore& featureIds, int32 hourglassStiffness) { int32 err = 0; FILE* f = fopen(file.c_str(), "wb"); @@ -361,7 +361,7 @@ void WriteAbaqusHexahedron::sendMessage(const std::string& message) Result<> WriteAbaqusHexahedron::operator()() { auto& imageGeom = m_DataStructure.getDataRefAs(m_InputValues->ImageGeometryPath); - auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); Vec3 cDims = imageGeom.getDimensions(); usize pDims[3] = {cDims[0] + 1, cDims[1] + 1, cDims[2] + 1}; Vec3 origin = imageGeom.getOrigin(); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoRectilinearCoordinate.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoRectilinearCoordinate.cpp index b8c88b3db9..366a5c72b7 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoRectilinearCoordinate.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoRectilinearCoordinate.cpp @@ -84,12 +84,12 @@ Result<> WriteAvizoRectilinearCoordinate::writeData(FILE* outputFile) const fprintf(outputFile, "@1 # FeatureIds in z, y, x with X moving fastest, then Y, then Z\n"); - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + const auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->template getIDataStoreRefAs>(); const usize totalPoints = featureIds.getNumberOfTuples(); if(m_InputValues->WriteBinaryFile) { - fwrite(featureIds.getIDataStoreAs()->data(), sizeof(int32_t), totalPoints, outputFile); + fwrite(featureIds.data(), sizeof(int32_t), totalPoints, outputFile); } else { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoUniformCoordinate.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoUniformCoordinate.cpp index 263d2091e5..53918e309a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoUniformCoordinate.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteAvizoUniformCoordinate.cpp @@ -87,12 +87,12 @@ Result<> WriteAvizoUniformCoordinate::writeData(FILE* outputFile) const { fprintf(outputFile, "@1\n"); - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + const auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->template getIDataStoreRefAs>(); const usize totalPoints = featureIds.getNumberOfTuples(); if(m_InputValues->WriteBinaryFile) { - fwrite(featureIds.getIDataStoreAs()->data(), sizeof(int32), totalPoints, outputFile); + fwrite(featureIds.data(), sizeof(int32), totalPoints, outputFile); } else { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteLosAlamosFFT.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteLosAlamosFFT.cpp index 93b6b12e06..ed4865c1a9 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteLosAlamosFFT.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteLosAlamosFFT.cpp @@ -56,9 +56,9 @@ Result<> WriteLosAlamosFFT::operator()() SizeVec3 dims = m_DataStructure.getDataAs(m_InputValues->ImageGeomPath)->getDimensions(); - auto& cellEulerAngles = m_DataStructure.getDataRefAs(m_InputValues->CellEulerAnglesArrayPath); - auto& cellPhases = m_DataStructure.getDataRefAs(m_InputValues->CellPhasesArrayPath); - auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsArrayPath); + auto& cellEulerAngles = m_DataStructure.getDataAs(m_InputValues->CellEulerAnglesArrayPath)->getDataStoreRef(); + auto& cellPhases = m_DataStructure.getDataAs(m_InputValues->CellPhasesArrayPath)->getDataStoreRef(); + auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsArrayPath)->getDataStoreRef(); float phi1 = 0.0f, phi = 0.0f, phi2 = 0.0f; @@ -69,9 +69,9 @@ Result<> WriteLosAlamosFFT::operator()() for(usize x = 0; x < dims[0]; ++x) { usize index = (z * dims[0] * dims[1]) + (dims[0] * y) + x; - phi1 = cellEulerAngles[index * 3] * 180.0 * Constants::k_1OverPiD; - phi = cellEulerAngles[index * 3 + 1] * 180.0 * Constants::k_1OverPiD; - phi2 = cellEulerAngles[index * 3 + 2] * 180.0 * Constants::k_1OverPiD; + phi1 = cellEulerAngles[index * 3] * 180.0f * Constants::k_1OverPiF; + phi = cellEulerAngles[index * 3 + 1] * 180.0f * Constants::k_1OverPiF; + phi2 = cellEulerAngles[index * 3 + 2] * 180.0f * Constants::k_1OverPiF; file << fmt::format("{:.3f} {:.3f} {:.3f} {} {} {} {} {}\n", phi1, phi, phi2, static_cast<::ull>(x + 1), static_cast<::ull>(y + 1), static_cast<::ull>(z + 1), featureIds[index], cellPhases[index]); } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteStlFile.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteStlFile.cpp index efe418a18c..79c0f6e9d1 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteStlFile.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteStlFile.cpp @@ -19,7 +19,10 @@ using namespace nx::core; namespace { -Result<> SingleWriteOutStl(const fs::path& path, const IGeometry::MeshIndexType numTriangles, const std::string&& header, const IGeometry::MeshIndexArrayType& triangles, const Float32Array& vertices) +using TriStore = AbstractDataStore; +using VertexStore = AbstractDataStore; + +Result<> SingleWriteOutStl(const fs::path& path, const IGeometry::MeshIndexType numTriangles, const std::string&& header, const TriStore& triangles, const VertexStore& vertices) { Result<> result; @@ -119,142 +122,14 @@ Result<> SingleWriteOutStl(const fs::path& path, const IGeometry::MeshIndexType return result; } -/** - * @brief - * @param path - * @param numTriangles - * @param header - * @param triangles - * @param vertices - * @param featureIds - * @param featureId - * @return - */ -Result<> MultiWriteOutStl(const fs::path& path, const IGeometry::MeshIndexType numTriangles, const std::string&& header, const IGeometry::MeshIndexArrayType& triangles, const Float32Array& vertices, - const Int32Array& featureIds, const int32 featureId) -{ - Result<> result; - // Create output file writer in binary write out mode to ensure cross-compatibility - FILE* filePtr = fopen(path.string().c_str(), "wb"); - - if(filePtr == nullptr) - { - fclose(filePtr); - return {MakeWarningVoidResult(-27876, fmt::format("Error Opening STL File. Unable to create temp file at path '{}' for original file '{}'", path.string(), path.filename().string()))}; - } - - int32 triCount = 0; - - { // Scope header output processing to keep overhead low and increase readability - if(header.size() >= 80) - { - result = MakeWarningVoidResult(-27874, - fmt::format("Warning: Writing STL File '{}'. Header was over the 80 characters supported by STL. Length of header: {}. Only the first 80 bytes will be written.", - path.filename().string(), header.length())); - } - - std::array stlFileHeader = {}; - stlFileHeader.fill(0); - size_t headLength = 80; - if(header.length() < 80) - { - headLength = static_cast(header.length()); - } - - // std::string c_str = header; - memcpy(stlFileHeader.data(), header.data(), headLength); - // Return the number of bytes written - which should be 80 - fwrite(stlFileHeader.data(), 1, 80, filePtr); - } - - fwrite(&triCount, 1, 4, filePtr); - triCount = 0; // Reset this to Zero. Increment for every triangle written - - size_t totalWritten = 0; - std::array vecA = {0.0f, 0.0f, 0.0f}; - std::array vecB = {0.0f, 0.0f, 0.0f}; - - std::array data = {}; - nonstd::span normalPtr(reinterpret_cast(data.data()), 3); - nonstd::span vert1Ptr(reinterpret_cast(data.data() + 12), 3); - nonstd::span vert2Ptr(reinterpret_cast(data.data() + 24), 3); - nonstd::span vert3Ptr(reinterpret_cast(data.data() + 36), 3); - nonstd::span attrByteCountPtr(reinterpret_cast(data.data() + 48), 2); - attrByteCountPtr[0] = 0; - - const usize numComps = featureIds.getNumberOfComponents(); - // Loop over all the triangles for this spin - for(IGeometry::MeshIndexType triangle = 0; triangle < numTriangles; ++triangle) - { - // Get the true indices of the 3 nodes - IGeometry::MeshIndexType nId0 = triangles[triangle * 3]; - IGeometry::MeshIndexType nId1 = triangles[triangle * 3 + 1]; - IGeometry::MeshIndexType nId2 = triangles[triangle * 3 + 2]; - - if(featureIds[triangle * numComps] == featureId) - { - // winding = 0; // 0 = Write it using forward spin - } - else if(numComps > 1 && featureIds[triangle * numComps + 1] == featureId) - { - // Switch the 2 node indices - IGeometry::MeshIndexType temp = nId1; - nId1 = nId2; - nId2 = temp; - } - else - { - continue; // We do not match either spin so move to the next triangle - } - - vert1Ptr[0] = static_cast(vertices[nId0 * 3]); - vert1Ptr[1] = static_cast(vertices[nId0 * 3 + 1]); - vert1Ptr[2] = static_cast(vertices[nId0 * 3 + 2]); - - vert2Ptr[0] = static_cast(vertices[nId1 * 3]); - vert2Ptr[1] = static_cast(vertices[nId1 * 3 + 1]); - vert2Ptr[2] = static_cast(vertices[nId1 * 3 + 2]); - - vert3Ptr[0] = static_cast(vertices[nId2 * 3]); - vert3Ptr[1] = static_cast(vertices[nId2 * 3 + 1]); - vert3Ptr[2] = static_cast(vertices[nId2 * 3 + 2]); - - // Compute the normal - vecA[0] = vert2Ptr[0] - vert1Ptr[0]; - vecA[1] = vert2Ptr[1] - vert1Ptr[1]; - vecA[2] = vert2Ptr[2] - vert1Ptr[2]; - - vecB[0] = vert3Ptr[0] - vert1Ptr[0]; - vecB[1] = vert3Ptr[1] - vert1Ptr[1]; - vecB[2] = vert3Ptr[2] - vert1Ptr[2]; - - MatrixMath::CrossProduct(vecA.data(), vecB.data(), normalPtr.data()); - MatrixMath::Normalize3x1(normalPtr.data()); - - totalWritten = fwrite(data.data(), 1, 50, filePtr); - if(totalWritten != 50) - { - fclose(filePtr); - return {MakeWarningVoidResult( - -27873, fmt::format("Error Writing STL File '{}': Not enough bytes written for triangle {}. Only {} bytes written of 50 bytes", path.filename().string(), triCount, totalWritten))}; - } - triCount++; - } - - fseek(filePtr, 80L, SEEK_SET); - fwrite(reinterpret_cast(&triCount), 1, 4, filePtr); - fclose(filePtr); - return result; -} - /** * @brief This class provides an interface to write the STL Files in parallel */ class MultiWriteStlFileImpl { public: - MultiWriteStlFileImpl(WriteStlFile* filter, const fs::path path, const IGeometry::MeshIndexType numTriangles, const std::string header, const IGeometry::MeshIndexArrayType& triangles, - const Float32Array& vertices, const Int32Array& featureIds, const int32 featureId) + MultiWriteStlFileImpl(WriteStlFile* filter, const fs::path path, const IGeometry::MeshIndexType numTriangles, const std::string header, const TriStore& triangles, const VertexStore& vertices, + const Int32AbstractDataStore& featureIds, const int32 featureId) : m_Filter(filter) , m_Path(path) , m_NumTriangles(numTriangles) @@ -389,9 +264,9 @@ class MultiWriteStlFileImpl const fs::path m_Path; const IGeometry::MeshIndexType m_NumTriangles; const std::string m_Header; - const IGeometry::MeshIndexArrayType& m_Triangles; - const Float32Array& m_Vertices; - const Int32Array& m_FeatureIds; + const TriStore& m_Triangles; + const VertexStore& m_Vertices; + const Int32AbstractDataStore& m_FeatureIds; const int32 m_FeatureId; }; } // namespace @@ -418,8 +293,8 @@ const std::atomic_bool& WriteStlFile::getCancel() Result<> WriteStlFile::operator()() { const auto& triangleGeom = m_DataStructure.getDataRefAs(m_InputValues->TriangleGeomPath); - const Float32Array& vertices = triangleGeom.getVerticesRef(); - const IGeometry::MeshIndexArrayType& triangles = triangleGeom.getFacesRef(); + const ::VertexStore& vertices = triangleGeom.getVertices()->getDataStoreRef(); + const ::TriStore& triangles = triangleGeom.getFaces()->getDataStoreRef(); const IGeometry::MeshIndexType nTriangles = triangleGeom.getNumberOfFaces(); auto groupingType = static_cast(m_InputValues->GroupingType); @@ -477,7 +352,7 @@ Result<> WriteStlFile::operator()() if(groupingType == GroupingType::Features) { - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsPath); + const auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsPath)->getDataStoreRef(); // Faster and more memory efficient since we don't need phases std::unordered_set uniqueGrainIds(featureIds.cbegin(), featureIds.cend()); @@ -507,7 +382,7 @@ Result<> WriteStlFile::operator()() if(groupingType == GroupingType::FeaturesAndPhases) { - const auto& featureIds = m_DataStructure.getDataRefAs(m_InputValues->FeatureIdsPath); + const auto& featureIds = m_DataStructure.getDataAs(m_InputValues->FeatureIdsPath)->getDataStoreRef(); std::map uniqueGrainIdToPhase; @@ -545,7 +420,7 @@ Result<> WriteStlFile::operator()() // Group Triangles by Part Number which is a single component Int32 Array if(groupingType == GroupingType::PartNumber) { - const auto& partNumbers = m_DataStructure.getDataRefAs(m_InputValues->PartNumberPath); + const auto& partNumbers = m_DataStructure.getDataAs(m_InputValues->PartNumberPath)->getDataStoreRef(); // Faster and more memory efficient since we don't need phases // Build up a list of the unique Part Numbers std::unordered_set uniquePartNumbers(partNumbers.cbegin(), partNumbers.cend()); @@ -587,7 +462,7 @@ Result<> WriteStlFile::operator()() } // ----------------------------------------------------------------------------- -void WriteStlFile::sendThreadSafeProgressMessage(Result<> result) +void WriteStlFile::sendThreadSafeProgressMessage(Result<>&& result) { std::lock_guard guard(m_ProgressMessage_Mutex); if(result.invalid()) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteStlFile.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteStlFile.hpp index b99aec26c2..da08384724 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteStlFile.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteStlFile.hpp @@ -51,7 +51,7 @@ class SIMPLNXCORE_EXPORT WriteStlFile const std::atomic_bool& getCancel(); - void sendThreadSafeProgressMessage(Result<> result); + void sendThreadSafeProgressMessage(Result<>&& result); private: DataStructure& m_DataStructure; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkRectilinearGrid.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkRectilinearGrid.cpp index 9779444ce3..3bccbbf4f3 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkRectilinearGrid.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkRectilinearGrid.cpp @@ -7,14 +7,8 @@ #include "SimplnxCore/utils/VtkUtilities.hpp" -#include - using namespace nx::core; -namespace -{ -} // namespace - // ----------------------------------------------------------------------------- WriteVtkRectilinearGrid::WriteVtkRectilinearGrid(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, WriteVtkRectilinearGridInputValues* inputValues) @@ -42,7 +36,6 @@ Result<> WriteVtkRectilinearGrid::operator()() FloatVec3 res = imageGeom.getSpacing(); FloatVec3 origin = imageGeom.getOrigin(); - int err = 0; FILE* outputFile = nullptr; outputFile = fopen(m_InputValues->OutputFile.string().c_str(), "wb"); if(nullptr == outputFile) @@ -54,17 +47,17 @@ Result<> WriteVtkRectilinearGrid::operator()() writeVtkHeader(outputFile); // Write the Coordinate Points - Result<> writeCoordsResults = writeCoords(outputFile, "X_COORDINATES", "float", dims[0] + 1, origin[0] - res[0] * 0.5f, (float)(dims[0] + 1 * res[0]), res[0]); + Result<> writeCoordsResults = writeCoords(outputFile, "X_COORDINATES", "float", dims[0] + 1, origin[0] - res[0] * 0.5f, res[0]); if(writeCoordsResults.invalid()) { return MergeResults(writeCoordsResults, MakeErrorResult(-2075, fmt::format("Error writing X Coordinates in vtk file {}'\n ", m_InputValues->OutputFile.string()))); } - writeCoordsResults = writeCoords(outputFile, "Y_COORDINATES", "float", dims[1] + 1, origin[1] - res[1] * 0.5f, (float)(dims[1] + 1 * res[1]), res[1]); + writeCoordsResults = writeCoords(outputFile, "Y_COORDINATES", "float", dims[1] + 1, origin[1] - res[1] * 0.5f, res[1]); if(writeCoordsResults.invalid()) { return MergeResults(writeCoordsResults, MakeErrorResult(-2076, fmt::format("Error writing Y Coordinates in vtk file %s'\n ", m_InputValues->OutputFile.string()))); } - writeCoordsResults = writeCoords(outputFile, "Z_COORDINATES", "float", dims[2] + 1, origin[2] - res[2] * 0.5f, (float)(dims[2] + 1 * res[2]), res[2]); + writeCoordsResults = writeCoords(outputFile, "Z_COORDINATES", "float", dims[2] + 1, origin[2] - res[2] * 0.5f, res[2]); if(writeCoordsResults.invalid()) { return MergeResults(writeCoordsResults, MakeErrorResult(-2077, fmt::format("Error writing Z Coordinates in vtk file %s'\n ", m_InputValues->OutputFile.string()))); @@ -110,7 +103,7 @@ void WriteVtkRectilinearGrid::writeVtkHeader(FILE* outputFile) const // ----------------------------------------------------------------------------- template -Result<> WriteVtkRectilinearGrid::writeCoords(FILE* outputFile, const std::string& axis, const std::string& type, int64 nPoints, T min, T max, T step) +Result<> WriteVtkRectilinearGrid::writeCoords(FILE* outputFile, const std::string& axis, const std::string& type, int64 nPoints, T min, T step) { fprintf(outputFile, "%s %lld %s\n", axis.c_str(), static_cast(nPoints), type.c_str()); if(m_InputValues->WriteBinaryFile) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkRectilinearGrid.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkRectilinearGrid.hpp index 1d8ffeed6f..2ac2a4f08a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkRectilinearGrid.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkRectilinearGrid.hpp @@ -56,7 +56,7 @@ class SIMPLNXCORE_EXPORT WriteVtkRectilinearGrid * @param binary Whether or not to write the vtk file data in binary */ template - Result<> writeCoords(FILE* outputFile, const std::string& axis, const std::string& type, int64 nPoints, T min, T max, T step); + Result<> writeCoords(FILE* outputFile, const std::string& axis, const std::string& type, int64 nPoints, T min, T step); private: DataStructure& m_DataStructure; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkStructuredPoints.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkStructuredPoints.cpp index b6fa2bdaef..d3d4e37a47 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkStructuredPoints.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/WriteVtkStructuredPoints.cpp @@ -9,11 +9,6 @@ using namespace nx::core; -namespace -{ - -} // namespace - // ----------------------------------------------------------------------------- WriteVtkStructuredPoints::WriteVtkStructuredPoints(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, WriteVtkStructuredPointsInputValues* inputValues) @@ -65,49 +60,13 @@ Result<> WriteVtkStructuredPoints::operator()() outStrm << fmt::format("ORIGIN {} {} {}\n", origin[0], origin[1], origin[2]); outStrm << fmt::format("CELL_DATA {}\n", dims[0] * dims[1] * dims[2]); - Result<> result; + Result<> result; for(const auto& arrayPath : m_InputValues->SelectedDataArrayPaths) { m_MessageHandler({nx::core::IFilter::Message::Type::Info, fmt::format("Writing {}", arrayPath.toString())}); - IDataArray& dataArray = m_DataStructure.getDataRefAs(arrayPath); - auto dataType = dataArray.getDataType(); - - switch(dataType) - { - case DataType::int8: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - case DataType::uint8: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - case DataType::int16: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - case DataType::uint16: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - case DataType::int32: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - case DataType::uint32: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - case DataType::int64: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - case DataType::uint64: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - case DataType::float32: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - case DataType::float64: - MergeResults(result, writeVtkData(outStrm, m_DataStructure, arrayPath, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); - break; - default: - MergeResults(result, MakeErrorResult(-666666, "The chosen scalar type is not supported by this filter.")); - } + auto& dataArray = m_DataStructure.getDataRefAs(arrayPath); + result = MergeResults(result, ExecuteNeighborFunction(WriteVtkDataFunctor{}, dataArray.getDataType(), outStrm, dataArray, m_InputValues->WriteBinaryFile, m_MessageHandler, m_ShouldCancel)); } return result; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignGeometriesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignGeometriesFilter.cpp index e3b963e949..480fa1de83 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignGeometriesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignGeometriesFilter.cpp @@ -56,7 +56,6 @@ FloatVec3 extractOrigin(const IGeometry& geometry) } return origin; } - break; case IGeometry::Type::Vertex: { auto& vertex = dynamic_cast(geometry); const auto& vertices = vertex.getVertices()->getDataStoreRef(); @@ -74,7 +73,6 @@ FloatVec3 extractOrigin(const IGeometry& geometry) } return origin; } - break; case IGeometry::Type::Edge: { const auto& edge = dynamic_cast(geometry); const auto& vertices = edge.getVertices()->getDataStoreRef(); @@ -92,7 +90,6 @@ FloatVec3 extractOrigin(const IGeometry& geometry) } return origin; } - break; // 2D case IGeometry::Type::Triangle: [[fallthrough]]; @@ -425,13 +422,8 @@ IFilter::UniquePointer AlignGeometriesFilter::clone() const IFilter::PreflightResult AlignGeometriesFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto movingGeometryPath = filterArgs.value(k_MovingGeometry_Key); - auto targetGeometryPath = filterArgs.value(k_TargetGeometry_Key); auto alignmentType = filterArgs.value(k_AlignmentType_Key); - auto* movingGeometry = dataStructure.getDataAs(movingGeometryPath); - auto* targetGeometry = dataStructure.getDataAs(targetGeometryPath); - if(alignmentType != 0 && alignmentType != 1) { std::string ss = fmt::format("Invalid selection for alignment type"); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignSectionsListFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignSectionsListFilter.cpp index bd14aa19fe..af56aa7647 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignSectionsListFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignSectionsListFilter.cpp @@ -76,14 +76,13 @@ IFilter::PreflightResult AlignSectionsListFilter::preflightImpl(const DataStruct const std::atomic_bool& shouldCancel) const { auto pInputFileValue = filterArgs.value(k_InputFile_Key); - auto pDREAM3DAlignmentFileValue = filterArgs.value(k_DREAM3DAlignmentFile_Key); auto pSelectedImageGeometryPathValue = filterArgs.value(k_SelectedImageGeometryPath_Key); PreflightResult preflightResult; nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; - const ImageGeom& imageGeom = dataStructure.getDataRefAs(pSelectedImageGeometryPathValue); + const auto& imageGeom = dataStructure.getDataRefAs(pSelectedImageGeometryPathValue); if(imageGeom.getCellData() == nullptr) { return {MakeErrorResult(-8940, fmt::format("Cannot find cell data Attribute Matrix in the selected Image geometry '{}'", pSelectedImageGeometryPathValue.toString()))}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AppendImageGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AppendImageGeometryFilter.cpp index c31ed444f6..f017e24343 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AppendImageGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AppendImageGeometryFilter.cpp @@ -1,6 +1,5 @@ #include "AppendImageGeometryFilter.hpp" -#include "ComputeArrayStatisticsFilter.hpp" #include "SimplnxCore/Filters/Algorithms/AppendImageGeometry.hpp" #include "simplnx/DataStructure/DataArray.hpp" @@ -15,11 +14,8 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataGroupCreationParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" -#include "simplnx/Utilities/DataGroupUtilities.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Utilities/GeometryHelpers.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -94,7 +90,6 @@ IFilter::PreflightResult AppendImageGeometryFilter::preflightImpl(const DataStru auto pCheckResolutionValue = filterArgs.value(k_CheckResolution_Key); auto pSaveAsNewGeometry = filterArgs.value(k_SaveAsNewGeometry_Key); - PreflightResult preflightResult; Result resultOutputActions; std::vector preflightUpdatedValues; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ApproximatePointCloudHullFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ApproximatePointCloudHullFilter.cpp index a7b7fcdd51..fc8332db57 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ApproximatePointCloudHullFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ApproximatePointCloudHullFilter.cpp @@ -16,7 +16,7 @@ namespace nx::core { namespace { -bool validNeighbor(const SizeVec3& dims, int64 neighborhood[78], usize index, int64 x, int64 y, int64 z) +bool validNeighbor(const SizeVec3& dims, const int64 neighborhood[78], usize index, int64 x, int64 y, int64 z) { int64 modX = x + neighborhood[3 * index + 0]; int64 modY = y + neighborhood[3 * index + 1]; @@ -84,7 +84,6 @@ IFilter::PreflightResult ApproximatePointCloudHullFilter::preflightImpl(const Da const std::atomic_bool& shouldCancel) const { auto gridResolution = args.value>(k_GridResolution_Key); - auto numberOfEmptyNeighbors = args.value(k_MinEmptyNeighbors_Key); auto vertexGeomPath = args.value(k_VertexGeomPath_Key); auto hullVertexGeomPath = args.value(k_HullVertexGeomPath_Key); @@ -94,15 +93,9 @@ IFilter::PreflightResult ApproximatePointCloudHullFilter::preflightImpl(const Da return {nonstd::make_unexpected(std::vector{Error{-11001, ss}})}; } - if(numberOfEmptyNeighbors < 0) - { - std::string ss = fmt::format("Minimum number of empty neighbors must be positive"); - return {nonstd::make_unexpected(std::vector{Error{-11001, ss}})}; - } - auto vertexGeom = dataStructure.getDataAs(vertexGeomPath); - int64 numVertices = vertexGeom->getNumberOfVertices(); + usize numVertices = vertexGeom->getNumberOfVertices(); auto action = std::make_unique(hullVertexGeomPath, numVertices, INodeGeometry0D::k_VertexDataName, CreateVertexGeometryAction::k_SharedVertexListName); OutputActions actions; @@ -129,8 +122,8 @@ Result<> ApproximatePointCloudHullFilter::executeImpl(DataStructure& dataStructu auto* samplingGrid = ImageGeom::Create(temp, "Image Geometry"); samplingGrid->setSpacing(gridResolution[0], gridResolution[1], gridResolution[2]); - int64 numVerts = source->getNumberOfVertices(); - auto* vertex = source->getVertices(); + usize numVerts = source->getNumberOfVertices(); + auto& vertex = source->getVertices()->getDataStoreRef(); std::vector meshMaxExtents; std::vector meshMinExtents; @@ -143,29 +136,29 @@ Result<> ApproximatePointCloudHullFilter::executeImpl(DataStructure& dataStructu for(int64 i = 0; i < numVerts; i++) { - if((*vertex)[3 * i] > meshMaxExtents[0]) + if(vertex[3 * i] > meshMaxExtents[0]) { - meshMaxExtents[0] = (*vertex)[3 * i]; + meshMaxExtents[0] = vertex[3 * i]; } - if((*vertex)[3 * i + 1] > meshMaxExtents[1]) + if(vertex[3 * i + 1] > meshMaxExtents[1]) { - meshMaxExtents[1] = (*vertex)[3 * i + 1]; + meshMaxExtents[1] = vertex[3 * i + 1]; } - if((*vertex)[3 * i + 2] > meshMaxExtents[2]) + if(vertex[3 * i + 2] > meshMaxExtents[2]) { - meshMaxExtents[2] = (*vertex)[3 * i + 2]; + meshMaxExtents[2] = vertex[3 * i + 2]; } - if((*vertex)[3 * i] < meshMinExtents[0]) + if(vertex[3 * i] < meshMinExtents[0]) { - meshMinExtents[0] = (*vertex)[3 * i]; + meshMinExtents[0] = vertex[3 * i]; } - if((*vertex)[3 * i + 1] < meshMinExtents[1]) + if(vertex[3 * i + 1] < meshMinExtents[1]) { - meshMinExtents[1] = (*vertex)[3 * i + 1]; + meshMinExtents[1] = vertex[3 * i + 1]; } - if((*vertex)[3 * i + 2] < meshMinExtents[2]) + if(vertex[3 * i + 2] < meshMinExtents[2]) { - meshMinExtents[2] = (*vertex)[3 * i + 2]; + meshMinExtents[2] = vertex[3 * i + 2]; } } @@ -186,9 +179,9 @@ Result<> ApproximatePointCloudHullFilter::executeImpl(DataStructure& dataStructu bboxMax[1] = static_cast(std::floor(meshMaxExtents[1] * inverseResolution[1])); bboxMax[2] = static_cast(std::floor(meshMaxExtents[2] * inverseResolution[2])); - usize dims1 = static_cast(bboxMax[0] - bboxMin[0] + 1); - usize dims2 = static_cast(bboxMax[1] - bboxMin[1] + 1); - usize dims3 = static_cast(bboxMax[2] - bboxMin[2] + 1); + auto dims1 = static_cast(bboxMax[0] - bboxMin[0] + 1); + auto dims2 = static_cast(bboxMax[1] - bboxMin[1] + 1); + auto dims3 = static_cast(bboxMax[2] - bboxMin[2] + 1); SizeVec3 dims(std::vector{dims1, dims2, dims3}); samplingGrid->setDimensions(dims); @@ -201,9 +194,9 @@ Result<> ApproximatePointCloudHullFilter::executeImpl(DataStructure& dataStructu for(int64 v = 0; v < numVerts; v++) { - int64 i = static_cast(std::floor((*verts)[3 * v + 0] * inverseResolution[0]) - static_cast(bboxMin[0])); - int64 j = static_cast(std::floor((*verts)[3 * v + 1] * inverseResolution[1]) - static_cast(bboxMin[1])); - int64 k = static_cast(std::floor((*verts)[3 * v + 2] * inverseResolution[2]) - static_cast(bboxMin[2])); + auto i = static_cast(std::floor((*verts)[3 * v + 0] * inverseResolution[0]) - static_cast(bboxMin[0])); + auto j = static_cast(std::floor((*verts)[3 * v + 1] * inverseResolution[1]) - static_cast(bboxMin[1])); + auto k = static_cast(std::floor((*verts)[3 * v + 2] * inverseResolution[2]) - static_cast(bboxMin[2])); int64 index = i * multiplier[0] + j * multiplier[1] + k * multiplier[2]; vertsInVoxels[index].push_back(v); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ArrayCalculatorFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ArrayCalculatorFilter.cpp index c94f9f7bb5..76657c0dd2 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ArrayCalculatorFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ArrayCalculatorFilter.cpp @@ -4,7 +4,6 @@ #include "SimplnxCore/utils/ICalculatorArray.hpp" #include "simplnx/Common/TypesUtility.hpp" -#include "simplnx/DataStructure/BaseGroup.hpp" #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Parameters/ArrayCreationParameter.hpp" diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ChangeAngleRepresentationFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ChangeAngleRepresentationFilter.cpp index 485e7f557a..44cb508eeb 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ChangeAngleRepresentationFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ChangeAngleRepresentationFilter.cpp @@ -27,7 +27,7 @@ constexpr uint64 RadiansToDegrees = 1; class ChangeAngleRepresentationImpl { public: - ChangeAngleRepresentationImpl(Float32Array& angles, float factor) + ChangeAngleRepresentationImpl(Float32AbstractDataStore& angles, float factor) : m_Angles(angles) , m_ConvFactor(factor) { @@ -48,8 +48,8 @@ class ChangeAngleRepresentationImpl } private: - Float32Array& m_Angles; - float m_ConvFactor = 0.0F; + Float32AbstractDataStore& m_Angles; + float32 m_ConvFactor = 0.0F; }; } // namespace @@ -129,7 +129,7 @@ Result<> ChangeAngleRepresentationFilter::executeImpl(DataStructure& dataStructu auto pConversionTypeValue = filterArgs.value(k_ConversionType_Key); auto pAnglesDataPathValue = filterArgs.value(k_AnglesArrayPath_Key); - Float32Array& angles = dataStructure.getDataRefAs(pAnglesDataPathValue); + auto& angles = dataStructure.getDataAs(pAnglesDataPathValue)->getDataStoreRef(); float conversionFactor = 1.0f; if(pConversionTypeValue == EulerAngleConversionType::DegreesToRadians) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CombineStlFilesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CombineStlFilesFilter.cpp index 0c3de7c2e5..a1acfa1282 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CombineStlFilesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CombineStlFilesFilter.cpp @@ -8,7 +8,6 @@ #include "simplnx/Filter/Actions/CreateAttributeMatrixAction.hpp" #include "simplnx/Filter/Actions/CreateGeometry2DAction.hpp" #include "simplnx/Filter/Actions/CreateStringArrayAction.hpp" -#include "simplnx/Parameters/ArrayCreationParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataGroupCreationParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeArrayHistogramFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeArrayHistogramFilter.cpp index fe5489ff98..9fd0177462 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeArrayHistogramFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeArrayHistogramFilter.cpp @@ -89,9 +89,6 @@ IFilter::PreflightResult ComputeArrayHistogramFilter::preflightImpl(const DataSt const std::atomic_bool& shouldCancel) const { auto pNumberOfBinsValue = filterArgs.value(k_NumberOfBins_Key); - auto pUserDefinedRangeValue = filterArgs.value(k_UserDefinedRange_Key); // verify and calculate range values here if false - auto pMinRangeValue = filterArgs.value(k_MinRange_Key); - auto pMaxRangeValue = filterArgs.value(k_MaxRange_Key); auto pNewDataGroupValue = filterArgs.value(k_CreateNewDataGroup_Key); auto pDataGroupNameValue = filterArgs.value(k_DataGroupPath_Key); auto pSelectedArrayPathsValue = filterArgs.value(k_SelectedArrayPaths_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeArrayStatisticsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeArrayStatisticsFilter.cpp index 781407c593..7f139e2e95 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeArrayStatisticsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeArrayStatisticsFilter.cpp @@ -325,7 +325,7 @@ IFilter::PreflightResult ComputeArrayStatisticsFilter::preflightImpl(const DataS { return {MakeErrorResult(-57201, "Value entered for number of bins must be a non-zero, positive value."), {}}; } - usize numBins = static_cast(pNumBinsValue); + auto numBins = static_cast(pNumBinsValue); std::vector inputDataArrayPaths; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeDifferencesMapFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeDifferencesMapFilter.cpp index b9fa0d58a3..698a0a0d2d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeDifferencesMapFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeDifferencesMapFilter.cpp @@ -76,59 +76,31 @@ WarningCollection warnOnUnsignedTypes(const DataStructure& dataStructure, const return results; } -/** - * @brief The FindDifferenceMapImpl class implements a threaded algorithm that computes the difference map - * between two arrays - */ -template -class FindDifferenceMapImpl +struct ExecuteFindDifferenceMapFunctor { - using store_type = AbstractDataStore; - -public: - FindDifferenceMapImpl(IDataArray* firstArray, IDataArray* secondArray, IDataArray* differenceMap) - : m_FirstArray(firstArray) - , m_SecondArray(secondArray) - , m_DifferenceMap(differenceMap) + template + void operator()(IDataArray* firstArrayPtr, IDataArray* secondArrayPtr, IDataArray* differenceMapPtr) { - } - virtual ~FindDifferenceMapImpl() = default; + using store_type = AbstractDataStore; - void generate(size_t start, size_t end) const - { - auto firstArray = dynamic_cast(m_FirstArray->getIDataStore()); - auto secondArray = dynamic_cast(m_SecondArray->getIDataStore()); - auto differenceMap = dynamic_cast(m_DifferenceMap->getIDataStore()); + auto& firstArray = firstArrayPtr->template getIDataStoreRefAs(); + auto& secondArray = secondArrayPtr->template getIDataStoreRefAs(); + auto& differenceMap = differenceMapPtr->template getIDataStoreRefAs(); - int32 numComps = firstArray->getNumberOfComponents(); + usize numTuples = firstArray.getNumberOfTuples(); + int32 numComps = firstArray.getNumberOfComponents(); - for(usize i = start; i < end; i++) + for(usize i = 0; i < numTuples; i++) { for(int32 j = 0; j < numComps; j++) { - auto firstVal = firstArray->getValue(numComps * i + j); - auto secondVal = secondArray->getValue(numComps * i + j); + auto firstVal = firstArray[numComps * i + j]; + auto secondVal = secondArray[numComps * i + j]; auto diffVal = firstVal > secondVal ? firstVal - secondVal : secondVal - firstVal; - differenceMap->setValue(numComps * i + j, diffVal); + differenceMap[numComps * i + j] = diffVal; } } } - -private: - IDataArray* m_FirstArray; - IDataArray* m_SecondArray; - IDataArray* m_DifferenceMap; -}; - -struct ExecuteFindDifferenceMapFunctor -{ - template - void operator()(IDataArray* firstArrayPtr, IDataArray* secondArrayPtr, IDataArray* differenceMapPtr) - { - size_t numTuples = firstArrayPtr->getNumberOfTuples(); - FindDifferenceMapImpl serial(firstArrayPtr, secondArrayPtr, differenceMapPtr); - serial.generate(0, numTuples); - } }; } // namespace @@ -255,12 +227,11 @@ IFilter::PreflightResult ComputeDifferencesMapFilter::preflightImpl(const DataSt Result<> ComputeDifferencesMapFilter::executeImpl(DataStructure& dataStructure, const Arguments& args, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto firstInputArray = dataStructure.getDataAs(args.value(k_FirstInputArrayPath_Key)); - auto secondInputArray = dataStructure.getDataAs(args.value(k_SecondInputArrayPath_Key)); - auto differenceMapArray = dataStructure.getDataAs(args.value(k_DifferenceMapArrayPath_Key)); + auto* firstInputArray = dataStructure.getDataAs(args.value(k_FirstInputArrayPath_Key)); + auto* secondInputArray = dataStructure.getDataAs(args.value(k_SecondInputArrayPath_Key)); + auto* differenceMapArray = dataStructure.getDataAs(args.value(k_DifferenceMapArrayPath_Key)); - auto dataType = firstInputArray->getDataType(); - ExecuteDataFunction(ExecuteFindDifferenceMapFunctor{}, dataType, firstInputArray, secondInputArray, differenceMapArray); + ExecuteDataFunction(ExecuteFindDifferenceMapFunctor{}, firstInputArray->getDataType(), firstInputArray, secondInputArray, differenceMapArray); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeEuclideanDistMapFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeEuclideanDistMapFilter.cpp index bb1b37511a..bc0f1f0bd7 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeEuclideanDistMapFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeEuclideanDistMapFilter.cpp @@ -103,9 +103,6 @@ IFilter::PreflightResult ComputeEuclideanDistMapFilter::preflightImpl(const Data const std::atomic_bool& shouldCancel) const { auto pCalcManhattanDistValue = filterArgs.value(k_CalcManhattanDist_Key); - auto pDoBoundariesValue = filterArgs.value(k_DoBoundaries_Key); - auto pDoTripleLinesValue = filterArgs.value(k_DoTripleLines_Key); - auto pDoQuadPointsValue = filterArgs.value(k_DoQuadPoints_Key); auto pSaveNearestNeighborsValue = filterArgs.value(k_SaveNearestNeighbors_Key); auto pFeatureIdsArrayPathValue = filterArgs.value(k_CellFeatureIdsArrayPath_Key); @@ -122,7 +119,7 @@ IFilter::PreflightResult ComputeEuclideanDistMapFilter::preflightImpl(const Data nx::core::Result resultOutputActions; - // Get the Cell Data Array so we get the tuple shape correct + // Get the Cell Data Array, so we get the tuple shape correct const auto* cellDataArray = dataStructure.getDataAs(pFeatureIdsArrayPathValue); if(nullptr == cellDataArray) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureClusteringFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureClusteringFilter.cpp index a18effc39d..4d90e3aecb 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureClusteringFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureClusteringFilter.cpp @@ -71,15 +71,13 @@ Parameters ComputeFeatureClusteringFilter::parameters() const params.insert(std::make_unique(k_SeedArrayName_Key, "Stored Seed Value Array Name", "Name of array holding the seed value", "ComputeFeatureClustering SeedValue")); params.insertSeparator(Parameters::Separator{"Input Feature Data"}); - params.insert(std::make_unique(k_EquivalentDiametersArrayPath_Key, "Equivalent Diameters", "Diameter of a sphere with the same volume as the Feature", DataPath{}, - ArraySelectionParameter::AllowedTypes{DataType::float32}, ArraySelectionParameter::AllowedComponentShapes{{1}})); params.insert(std::make_unique(k_FeaturePhasesArrayPath_Key, "Phases", "Specifies to which Ensemble each Feature belongs", DataPath{}, ArraySelectionParameter::AllowedTypes{DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{1}})); params.insert(std::make_unique(k_CentroidsArrayPath_Key, "Centroids", "X, Y, Z coordinates of Feature center of mass", DataPath{}, ArraySelectionParameter::AllowedTypes{DataType::float32}, ArraySelectionParameter::AllowedComponentShapes{{3}})); params.insert(std::make_unique(k_BiasedFeaturesArrayPath_Key, "Biased Features", - "Specifies which features are biased and therefor should be removed if the Remove Biased Features option is on", DataPath{}, - ArraySelectionParameter::AllowedTypes{DataType::boolean}, ArraySelectionParameter::AllowedComponentShapes{{1}})); + "Specifies which features are biased and therefor should be removed if the Remove Biased Features option is on; True values removed", + DataPath{}, ArraySelectionParameter::AllowedTypes{DataType::boolean, DataType::uint8}, ArraySelectionParameter::AllowedComponentShapes{{1}})); params.insertSeparator(Parameters::Separator{"Input Ensemble Data"}); 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{})); @@ -108,7 +106,6 @@ IFilter::PreflightResult ComputeFeatureClusteringFilter::preflightImpl(const Dat { auto pNumberOfBinsValue = filterArgs.value(k_NumberOfBins_Key); auto pRemoveBiasedFeaturesValue = filterArgs.value(k_RemoveBiasedFeatures_Key); - auto pEquivalentDiametersArrayPathValue = filterArgs.value(k_EquivalentDiametersArrayPath_Key); auto pFeaturePhasesArrayPathValue = filterArgs.value(k_FeaturePhasesArrayPath_Key); auto pCentroidsArrayPathValue = filterArgs.value(k_CentroidsArrayPath_Key); auto pCellEnsembleAttributeMatrixNameValue = filterArgs.value(k_CellEnsembleAttributeMatrixPath_Key); @@ -123,7 +120,7 @@ IFilter::PreflightResult ComputeFeatureClusteringFilter::preflightImpl(const Dat nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; - std::vector featureDataArrays = {pEquivalentDiametersArrayPathValue, pFeaturePhasesArrayPathValue, pCentroidsArrayPathValue}; + std::vector featureDataArrays = {pFeaturePhasesArrayPathValue, pCentroidsArrayPathValue}; if(pRemoveBiasedFeaturesValue) { featureDataArrays.push_back(filterArgs.value(k_BiasedFeaturesArrayPath_Key)); @@ -181,7 +178,6 @@ Result<> ComputeFeatureClusteringFilter::executeImpl(DataStructure& dataStructur inputValues.PhaseNumber = filterArgs.value(k_PhaseNumber_Key); inputValues.RemoveBiasedFeatures = filterArgs.value(k_RemoveBiasedFeatures_Key); inputValues.SeedValue = seed; - inputValues.EquivalentDiametersArrayPath = filterArgs.value(k_EquivalentDiametersArrayPath_Key); inputValues.FeaturePhasesArrayPath = filterArgs.value(k_FeaturePhasesArrayPath_Key); inputValues.CentroidsArrayPath = filterArgs.value(k_CentroidsArrayPath_Key); inputValues.BiasedFeaturesArrayPath = filterArgs.value(k_BiasedFeaturesArrayPath_Key); @@ -226,8 +222,6 @@ Result ComputeFeatureClusteringFilter::FromSIMPLJson(const nlohmann:: results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_RandomSeedValueKey, k_SeedValue_Key)); results.push_back( SIMPLConversion::ConvertParameter(args, json, SIMPL::k_EquivalentDiametersArrayPathKey, k_SelectedImageGeometryPath_Key)); - results.push_back( - SIMPLConversion::ConvertParameter(args, json, SIMPL::k_EquivalentDiametersArrayPathKey, k_EquivalentDiametersArrayPath_Key)); results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_FeaturePhasesArrayPathKey, k_FeaturePhasesArrayPath_Key)); results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_CentroidsArrayPathKey, k_CentroidsArrayPath_Key)); results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_BiasedFeaturesArrayPathKey, k_BiasedFeaturesArrayPath_Key)); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureClusteringFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureClusteringFilter.hpp index 18794c8a51..b82f5718fa 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureClusteringFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureClusteringFilter.hpp @@ -31,7 +31,6 @@ class SIMPLNXCORE_EXPORT ComputeFeatureClusteringFilter : public IFilter static inline constexpr StringLiteral k_SetRandomSeed_Key = "set_random_seed"; static inline constexpr StringLiteral k_SeedValue_Key = "seed_value"; static inline constexpr StringLiteral k_SeedArrayName_Key = "seed_array_name"; - static inline constexpr StringLiteral k_EquivalentDiametersArrayPath_Key = "equivalent_diameters_array_path"; static inline constexpr StringLiteral k_FeaturePhasesArrayPath_Key = "feature_phases_array_path"; static inline constexpr StringLiteral k_CentroidsArrayPath_Key = "centroids_array_path"; static inline constexpr StringLiteral k_BiasedFeaturesArrayPath_Key = "biased_features_array_path"; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureNeighborsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureNeighborsFilter.cpp index 0f0265b4aa..e9afb1f456 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureNeighborsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureNeighborsFilter.cpp @@ -186,41 +186,39 @@ Result<> ComputeFeatureNeighborsFilter::executeImpl(DataStructure& dataStructure DataPath sharedSurfaceAreaPath = featureAttrMatrixPath.createChildPath(sharedSurfaceAreaName); DataPath surfaceFeaturesPath = featureAttrMatrixPath.createChildPath(surfaceFeaturesName); - auto& featureIdsArray = dataStructure.getDataRefAs(featureIdsPath); - auto& numNeighborsArray = dataStructure.getDataRefAs(numNeighborsPath); + auto& featureIds = dataStructure.getDataAs(featureIdsPath)->getDataStoreRef(); + auto& numNeighbors = dataStructure.getDataAs(numNeighborsPath)->getDataStoreRef(); + auto& neighborList = dataStructure.getDataRefAs(neighborListPath); auto& sharedSurfaceAreaList = dataStructure.getDataRefAs(sharedSurfaceAreaPath); - auto* boundaryCellsArray = dataStructure.getDataAs(boundaryCellsPath); - auto* surfaceFeaturesArray = dataStructure.getDataAs(surfaceFeaturesPath); + auto* boundaryCells = storeBoundaryCells ? dataStructure.getDataAs(boundaryCellsPath)->getDataStore() : nullptr; + auto* surfaceFeatures = storeSurfaceFeatures ? dataStructure.getDataAs(surfaceFeaturesPath)->getDataStore() : nullptr; - auto& featureIds = featureIdsArray.getDataStoreRef(); - auto& numNeighbors = numNeighborsArray.getDataStoreRef(); - - usize totalPoints = featureIdsArray.getNumberOfTuples(); - usize totalFeatures = numNeighborsArray.getNumberOfTuples(); + usize totalPoints = featureIds.getNumberOfTuples(); + usize totalFeatures = numNeighbors.getNumberOfTuples(); /* Ensure that we will be able to work with the user selected featureId Array */ - const auto [minFeatureId, maxFeatureId] = std::minmax_element(featureIdsArray.begin(), featureIdsArray.end()); + const auto [minFeatureId, maxFeatureId] = std::minmax_element(featureIds.begin(), featureIds.end()); if(static_cast(*maxFeatureId) >= totalFeatures) { std::stringstream out; - out << "Data Array " << featureIdsArray.getName() << " has a maximum value of " << *maxFeatureId << " which is greater than the " - << " number of features from array " << numNeighborsArray.getName() << " which has " << totalFeatures << ". Did you select the " + out << "Data Array " << featureIdsPath.getTargetName() << " has a maximum value of " << *maxFeatureId << " which is greater than the " + << " number of features from array " << numNeighborsPath.getTargetName() << " which has " << totalFeatures << ". Did you select the " << " incorrect array for the 'FeatureIds' array?"; return MakeErrorResult(-24500, out.str()); } auto& imageGeom = dataStructure.getDataRefAs(imageGeomPath); - SizeVec3 udims = imageGeom.getDimensions(); + SizeVec3 uDims = imageGeom.getDimensions(); const auto imageGeomNumX = imageGeom.getNumXCells(); const auto imageGeomNumY = imageGeom.getNumYCells(); const auto imageGeomNumZ = imageGeom.getNumZCells(); std::array dims = { - static_cast(udims[0]), - static_cast(udims[1]), - static_cast(udims[2]), + static_cast(uDims[0]), + static_cast(uDims[1]), + static_cast(uDims[2]), }; std::array neighPoints = {-dims[0] * dims[1], -dims[0], -1, 1, dims[0], dims[0] * dims[1]}; @@ -262,10 +260,9 @@ Result<> ComputeFeatureNeighborsFilter::executeImpl(DataStructure& dataStructure numNeighbors[i] = 0; neighborlist[i].resize(nListSize); neighborsurfacearealist[i].assign(nListSize, -1.0f); - if(storeSurfaceFeatures) + if(storeSurfaceFeatures && surfaceFeatures != nullptr) { - auto& surfaceFeatures = surfaceFeaturesArray->getDataStoreRef(); - surfaceFeatures[i] = 0; + surfaceFeatures->setValue(i, false); } } @@ -296,19 +293,17 @@ Result<> ComputeFeatureNeighborsFilter::executeImpl(DataStructure& dataStructure column = static_cast(j % imageGeomNumX); row = static_cast((j / imageGeomNumX) % imageGeomNumY); plane = static_cast(j / (imageGeomNumX * imageGeomNumY)); - if(storeSurfaceFeatures) + if(storeSurfaceFeatures && surfaceFeatures != nullptr) { - auto& surfaceFeatures = surfaceFeaturesArray->getDataStoreRef(); - if((column == 0 || column == static_cast((imageGeomNumX - 1)) || row == 0 || row == static_cast((imageGeomNumY)-1) || plane == 0 || plane == static_cast((imageGeomNumZ - 1))) && imageGeomNumZ != 1) { - surfaceFeatures[feature] = 1; + surfaceFeatures->setValue(feature, true); } if((column == 0 || column == static_cast((imageGeomNumX - 1)) || row == 0 || row == static_cast((imageGeomNumY - 1))) && imageGeomNumZ == 1) { - surfaceFeatures[feature] = 1; + surfaceFeatures->setValue(feature, true); } } for(size_t k = 0; k < 6; k++) @@ -349,10 +344,9 @@ Result<> ComputeFeatureNeighborsFilter::executeImpl(DataStructure& dataStructure } } } - if(storeBoundaryCells) + if(storeBoundaryCells && boundaryCells != nullptr) { - auto& boundaryCells = boundaryCellsArray->getDataStoreRef(); - boundaryCells[j] = static_cast(onsurf); + boundaryCells->setValue(j, static_cast(onsurf)); } } @@ -386,7 +380,7 @@ Result<> ComputeFeatureNeighborsFilter::executeImpl(DataStructure& dataStructure neighToCount[neighborlist[i][j]]++; } - std::map::iterator neighborIter = neighToCount.find(0); + auto neighborIter = neighToCount.find(0); neighToCount.erase(neighborIter); neighborIter = neighToCount.find(-1); if(neighborIter != neighToCount.end()) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeaturePhasesBinaryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeaturePhasesBinaryFilter.cpp index 2bda37ecf5..6071bd3b11 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeaturePhasesBinaryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeaturePhasesBinaryFilter.cpp @@ -99,8 +99,9 @@ IFilter::PreflightResult ComputeFeaturePhasesBinaryFilter::preflightImpl(const D Result<> ComputeFeaturePhasesBinaryFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto featureIdsArray = dataStructure.getDataRefAs(filterArgs.value(k_FeatureIdsArrayPath_Key)); - auto featurePhasesArray = dataStructure.getDataRefAs(filterArgs.value(k_CellDataAMPath_Key).createChildPath(filterArgs.value(k_FeaturePhasesArrayName_Key))); + auto& featureIdsArray = dataStructure.getDataAs(filterArgs.value(k_FeatureIdsArrayPath_Key))->getDataStoreRef(); + auto& featurePhasesArray = + dataStructure.getDataAs(filterArgs.value(k_CellDataAMPath_Key).createChildPath(filterArgs.value(k_FeaturePhasesArrayName_Key)))->getDataStoreRef(); std::unique_ptr goodVoxelsMask; try diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeaturePhasesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeaturePhasesFilter.cpp index 346ba3af47..840b6ac806 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeaturePhasesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeaturePhasesFilter.cpp @@ -113,12 +113,13 @@ Result<> ComputeFeaturePhasesFilter::executeImpl(DataStructure& dataStructure, c auto pCellFeatureAMPathValue = filterArgs.value(k_CellFeaturesAttributeMatrixPath_Key); auto pFeaturePhasesArrayPathValue = pCellFeatureAMPathValue.createChildPath(filterArgs.value(k_FeaturePhasesArrayName_Key)); - const Int32Array& cellPhases = dataStructure.getDataRefAs(pCellPhasesArrayPathValue); - const Int32Array& featureIds = dataStructure.getDataRefAs(pFeatureIdsArrayPathValue); - Int32Array& featurePhases = dataStructure.getDataRefAs(pFeaturePhasesArrayPathValue); + const auto& cellPhases = dataStructure.getDataAs(pCellPhasesArrayPathValue)->getDataStoreRef(); + const auto& featureIdsArray = dataStructure.getDataRefAs(pFeatureIdsArrayPathValue); + const auto& featureIds = featureIdsArray.getDataStoreRef(); + auto& featurePhases = dataStructure.getDataAs(pFeaturePhasesArrayPathValue)->getDataStoreRef(); // Validate the featurePhases array is the proper size - auto validateResults = ValidateNumFeaturesInArray(dataStructure, pFeaturePhasesArrayPathValue, featureIds); + auto validateResults = ValidateNumFeaturesInArray(dataStructure, pFeaturePhasesArrayPathValue, featureIdsArray); if(validateResults.invalid()) { return validateResults; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureSizesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureSizesFilter.cpp index c8b7be5961..26ae326251 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureSizesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeFeatureSizesFilter.cpp @@ -138,11 +138,10 @@ Result<> ComputeFeatureSizesFilter::executeImpl(DataStructure& dataStructure, co const std::atomic_bool& shouldCancel) const { auto saveElementSizes = args.value(k_SaveElementSizes_Key); - auto featureIdsPath = args.value(k_CellFeatureIdsArrayPath_Key); - const auto& featureIdsArray = dataStructure.getDataRefAs(featureIdsPath); - const auto& featureIds = featureIdsArray.getDataStoreRef(); - usize totalPoints = featureIdsArray.getNumberOfTuples(); + const auto& featureIds = dataStructure.getDataRefAs(args.value(k_CellFeatureIdsArrayPath_Key)).getDataStoreRef(); + + usize totalPoints = featureIds.getNumberOfTuples(); auto geomPath = args.value(k_GeometryPath_Key); auto* geom = dataStructure.getDataAs(geomPath); @@ -152,16 +151,10 @@ Result<> ComputeFeatureSizesFilter::executeImpl(DataStructure& dataStructure, co if(nullptr != imageGeom) { auto featureAttributeMatrixPath = args.value(k_CellFeatureAttributeMatrixPath_Key); - auto volumesName = args.value(k_VolumesName_Key); - auto equivalentDiametersName = args.value(k_EquivalentDiametersName_Key); - auto numElementsName = args.value(k_NumElementsName_Key); - DataPath volumesPath = featureAttributeMatrixPath.createChildPath(volumesName); - DataPath equivalentDiametersPath = featureAttributeMatrixPath.createChildPath(equivalentDiametersName); - DataPath numElementsPath = featureAttributeMatrixPath.createChildPath(numElementsName); - auto& volumes = dataStructure.getDataRefAs(volumesPath); - auto& equivalentDiameters = dataStructure.getDataRefAs(equivalentDiametersPath); - auto& numElements = dataStructure.getDataRefAs(numElementsPath); + auto& volumes = dataStructure.getDataAs(featureAttributeMatrixPath.createChildPath(args.value(k_VolumesName_Key)))->getDataStoreRef(); + auto& equivalentDiameters = dataStructure.getDataAs(featureAttributeMatrixPath.createChildPath(args.value(k_EquivalentDiametersName_Key)))->getDataStoreRef(); + auto& numElements = dataStructure.getDataAs(featureAttributeMatrixPath.createChildPath(args.value(k_NumElementsName_Key)))->getDataStoreRef(); usize featureIdsMaxIdx = std::distance(featureIds.begin(), std::max_element(featureIds.cbegin(), featureIds.cend())); usize maxValue = featureIds[featureIdsMaxIdx]; @@ -202,7 +195,7 @@ Result<> ComputeFeatureSizesFilter::executeImpl(DataStructure& dataStructure, co std::string ss = fmt::format("Number of voxels belonging to feature {} ({}) is greater than 9007199254740992", i, featureCounts[i]); return {nonstd::make_unexpected(std::vector{Error{k_BadFeatureCount, ss}})}; } - volumes[i] = static_cast(featureCounts[i]) * static_cast(res_scalar); + volumes[i] = static_cast(featureCounts[i]) * static_cast(res_scalar); float32 rad = volumes[i] / k_PI; float32 diameter = (2 * sqrtf(rad)); @@ -222,7 +215,7 @@ Result<> ComputeFeatureSizesFilter::executeImpl(DataStructure& dataStructure, co return {nonstd::make_unexpected(std::vector{Error{k_BadFeatureCount, ss}})}; } - volumes[i] = static_cast(featureCounts[i]) * static_cast(res_scalar); + volumes[i] = static_cast(featureCounts[i]) * static_cast(res_scalar); float32 rad = volumes[i] / vol_term; float32 diameter = 2.0f * powf(rad, 0.3333333333f); @@ -242,15 +235,11 @@ Result<> ComputeFeatureSizesFilter::executeImpl(DataStructure& dataStructure, co } else { - auto volumesPath = args.value(k_VolumesName_Key); - auto equivalentDiametersPath = args.value(k_EquivalentDiametersName_Key); - auto numElementsPath = args.value(k_NumElementsName_Key); - - auto& volumes = dataStructure.getDataRefAs(volumesPath); - auto& equivalentDiameters = dataStructure.getDataRefAs(equivalentDiametersPath); - auto& numElements = dataStructure.getDataRefAs(numElementsPath); + auto& volumes = dataStructure.getDataAs(args.value(k_VolumesName_Key))->getDataStoreRef(); + auto& equivalentDiameters = dataStructure.getDataAs(args.value(k_EquivalentDiametersName_Key))->getDataStoreRef(); + auto& numElements = dataStructure.getDataAs(args.value(k_NumElementsName_Key))->getDataStoreRef(); - usize numfeatures = volumes.getNumberOfTuples(); + usize numFeatures = volumes.getNumberOfTuples(); int32_t err = geom->findElementSizes(false); if(err < 0) @@ -261,7 +250,7 @@ Result<> ComputeFeatureSizesFilter::executeImpl(DataStructure& dataStructure, co const Float32Array* elemSizes = geom->getElementSizes(); - std::vector featureCounts(numfeatures, 1); + std::vector featureCounts(numFeatures, 1); for(size_t j = 0; j < totalPoints; j++) { @@ -272,7 +261,7 @@ Result<> ComputeFeatureSizesFilter::executeImpl(DataStructure& dataStructure, co volumes[gnum] = temp2 + (*elemSizes)[j]; } float vol_term = (4.0f / 3.0f) * k_PI; - for(size_t i = 1; i < numfeatures; i++) + for(size_t i = 1; i < numFeatures; i++) { numElements[i] = static_cast(featureCounts[i]); float rad = volumes[i] / vol_term; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeLargestCrossSectionsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeLargestCrossSectionsFilter.cpp index 78d2bfbcca..3eb5f4b646 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeLargestCrossSectionsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeLargestCrossSectionsFilter.cpp @@ -80,7 +80,6 @@ IFilter::UniquePointer ComputeLargestCrossSectionsFilter::clone() const IFilter::PreflightResult ComputeLargestCrossSectionsFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pPlaneValue = filterArgs.value(k_Plane_Key); auto pFeatureIdsArrayPathValue = filterArgs.value(k_FeatureIdsArrayPath_Key); auto pImageGeometryPath = filterArgs.value(k_ImageGeometryPath_Key); auto pCellFeatureAttributeMatrixPath = filterArgs.value(k_CellFeatureAttributeMatrixPath_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeMomentInvariants2DFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeMomentInvariants2DFilter.cpp index 765dc6a1cf..8b0e99c10e 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeMomentInvariants2DFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeMomentInvariants2DFilter.cpp @@ -5,7 +5,6 @@ #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/DataStructure/Geometry/ImageGeom.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" -#include "simplnx/Parameters/ArrayCreationParameter.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/AttributeMatrixSelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborListStatisticsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborListStatisticsFilter.cpp index 3f5f563062..9f1fdac1de 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborListStatisticsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborListStatisticsFilter.cpp @@ -54,44 +54,45 @@ class ComputeNeighborListStatisticsImpl } using DataArrayType = DataArray; + using StoreType = AbstractDataStore; - auto* array0 = dynamic_cast*>(m_Arrays[0]); + auto* array0 = m_Length ? m_Arrays[0]->template getIDataStoreAs>() : nullptr; if(m_Length && array0 == nullptr) { throw std::invalid_argument("ComputeNeighborListStatisticsFilter::compute() could not dynamic_cast 'Length' array to needed type. Check input array selection."); } - auto* array1 = dynamic_cast(m_Arrays[1]); + auto* array1 = m_Min ? m_Arrays[1]->template getIDataStoreAs() : nullptr; if(m_Min && array1 == nullptr) { throw std::invalid_argument("ComputeNeighborListStatisticsFilter::compute() could not dynamic_cast 'Min' array to needed type. Check input array selection."); } - auto* array2 = dynamic_cast(m_Arrays[2]); + auto* array2 = m_Max ? m_Arrays[2]->template getIDataStoreAs() : nullptr; if(m_Max && array2 == nullptr) { throw std::invalid_argument("ComputeNeighborListStatisticsFilter::compute() could not dynamic_cast 'Max' array to needed type. Check input array selection."); } - auto* array3 = dynamic_cast(m_Arrays[3]); + auto* array3 = m_Mean ? m_Arrays[3]->template getIDataStoreAs>() : nullptr; if(m_Mean && array3 == nullptr) { throw std::invalid_argument("ComputeNeighborListStatisticsFilter::compute() could not dynamic_cast 'Mean' array to needed type. Check input array selection."); } - auto* array4 = dynamic_cast(m_Arrays[4]); + auto* array4 = m_Median ? m_Arrays[4]->template getIDataStoreAs>() : nullptr; if(m_Median && array4 == nullptr) { throw std::invalid_argument("ComputeNeighborListStatisticsFilter::compute() could not dynamic_cast 'Median' array to needed type. Check input array selection."); } - auto* array5 = dynamic_cast(m_Arrays[5]); + auto* array5 = m_StdDeviation ? m_Arrays[5]->template getIDataStoreAs>() : nullptr; if(m_StdDeviation && array5 == nullptr) { throw std::invalid_argument("ComputeNeighborListStatisticsFilter::compute() could not dynamic_cast 'StdDev' array to needed type. Check input array selection."); } - auto* array6 = dynamic_cast(m_Arrays[6]); + auto* array6 = m_Summation ? m_Arrays[6]->template getIDataStoreAs>() : nullptr; if(m_Summation && array6 == nullptr) { throw std::invalid_argument("ComputeNeighborListStatisticsFilter::compute() could not dynamic_cast 'Summation' array to needed type. Check input array selection."); } - NeighborListType& sourceList = dynamic_cast(m_Source); + auto& sourceList = dynamic_cast(m_Source); for(usize i = start; i < end; i++) { @@ -99,38 +100,38 @@ class ComputeNeighborListStatisticsImpl if(m_Length) { - int64_t val = static_cast(tmpList.size()); - array0->initializeTuple(i, val); + auto val = static_cast(tmpList.size()); + array0->setValue(i, val); } if(m_Min) { T val = StatisticsCalculations::findMin(tmpList); - array1->initializeTuple(i, val); + array1->setValue(i, val); } if(m_Max) { T val = StatisticsCalculations::findMax(tmpList); - array2->initializeTuple(i, val); + array2->setValue(i, val); } if(m_Mean) { float val = StatisticsCalculations::findMean(tmpList); - array3->initializeTuple(i, val); + array3->setValue(i, val); } if(m_Median) { float val = StatisticsCalculations::findMedian(tmpList); - array4->initializeTuple(i, val); + array4->setValue(i, val); } if(m_StdDeviation) { float val = StatisticsCalculations::findStdDeviation(tmpList); - array5->initializeTuple(i, val); + array5->setValue(i, val); } if(m_Summation) { float val = StatisticsCalculations::findSummation(tmpList); - array6->initializeTuple(i, val); + array6->setValue(i, val); } } } @@ -153,20 +154,19 @@ class ComputeNeighborListStatisticsImpl std::vector& m_Arrays; }; -} // namespace //------------------------------------------------------------------------------ -OutputActions ComputeNeighborListStatisticsFilter::createCompatibleArrays(const DataStructure& dataStructure, const Arguments& args) const +OutputActions CreateCompatibleArrays(const DataStructure& dataStructure, const Arguments& args) { - auto findLength = args.value(k_FindLength_Key); - auto findMin = args.value(k_FindMinimum_Key); - auto findMax = args.value(k_FindMaximum_Key); - auto findMean = args.value(k_FindMean_Key); - auto findMedian = args.value(k_FindMedian_Key); - auto findStdDeviation = args.value(k_FindStandardDeviation_Key); - auto findSummation = args.value(k_FindSummation_Key); - - auto inputArrayPath = args.value(k_InputNeighborListPath_Key); + auto findLength = args.value(ComputeNeighborListStatisticsFilter::k_FindLength_Key); + auto findMin = args.value(ComputeNeighborListStatisticsFilter::k_FindMinimum_Key); + auto findMax = args.value(ComputeNeighborListStatisticsFilter::k_FindMaximum_Key); + auto findMean = args.value(ComputeNeighborListStatisticsFilter::k_FindMean_Key); + auto findMedian = args.value(ComputeNeighborListStatisticsFilter::k_FindMedian_Key); + auto findStdDeviation = args.value(ComputeNeighborListStatisticsFilter::k_FindStandardDeviation_Key); + auto findSummation = args.value(ComputeNeighborListStatisticsFilter::k_FindSummation_Key); + + auto inputArrayPath = args.value(ComputeNeighborListStatisticsFilter::k_InputNeighborListPath_Key); auto* inputArray = dataStructure.getDataAs(inputArrayPath); std::vector tupleDims{inputArray->getNumberOfTuples()}; DataType dataType = inputArray->getDataType(); @@ -175,49 +175,50 @@ OutputActions ComputeNeighborListStatisticsFilter::createCompatibleArrays(const OutputActions actions; if(findLength) { - auto arrayPath = outputGroupPath.createChildPath(args.value(k_LengthName_Key)); + auto arrayPath = outputGroupPath.createChildPath(args.value(ComputeNeighborListStatisticsFilter::k_LengthName_Key)); auto action = std::make_unique(DataType::uint64, tupleDims, std::vector{1}, arrayPath); actions.appendAction(std::move(action)); } if(findMin) { - auto arrayPath = outputGroupPath.createChildPath(args.value(k_MinimumName_Key)); + auto arrayPath = outputGroupPath.createChildPath(args.value(ComputeNeighborListStatisticsFilter::k_MinimumName_Key)); auto action = std::make_unique(dataType, tupleDims, std::vector{1}, arrayPath); actions.appendAction(std::move(action)); } if(findMax) { - auto arrayPath = outputGroupPath.createChildPath(args.value(k_MaximumName_Key)); + auto arrayPath = outputGroupPath.createChildPath(args.value(ComputeNeighborListStatisticsFilter::k_MaximumName_Key)); auto action = std::make_unique(dataType, tupleDims, std::vector{1}, arrayPath); actions.appendAction(std::move(action)); } if(findMean) { - auto arrayPath = outputGroupPath.createChildPath(args.value(k_MeanName_Key)); + auto arrayPath = outputGroupPath.createChildPath(args.value(ComputeNeighborListStatisticsFilter::k_MeanName_Key)); auto action = std::make_unique(DataType::float32, tupleDims, std::vector{1}, arrayPath); actions.appendAction(std::move(action)); } if(findMedian) { - auto arrayPath = outputGroupPath.createChildPath(args.value(k_MedianName_Key)); + auto arrayPath = outputGroupPath.createChildPath(args.value(ComputeNeighborListStatisticsFilter::k_MedianName_Key)); auto action = std::make_unique(DataType::float32, tupleDims, std::vector{1}, arrayPath); actions.appendAction(std::move(action)); } if(findStdDeviation) { - auto arrayPath = outputGroupPath.createChildPath(args.value(k_StandardDeviationName_Key)); + auto arrayPath = outputGroupPath.createChildPath(args.value(ComputeNeighborListStatisticsFilter::k_StandardDeviationName_Key)); auto action = std::make_unique(DataType::float32, tupleDims, std::vector{1}, arrayPath); actions.appendAction(std::move(action)); } if(findSummation) { - auto arrayPath = outputGroupPath.createChildPath(args.value(k_SummationName_Key)); + auto arrayPath = outputGroupPath.createChildPath(args.value(ComputeNeighborListStatisticsFilter::k_SummationName_Key)); auto action = std::make_unique(DataType::float32, tupleDims, std::vector{1}, arrayPath); actions.appendAction(std::move(action)); } return std::move(actions); } +} // namespace //------------------------------------------------------------------------------ std::string ComputeNeighborListStatisticsFilter::name() const @@ -317,7 +318,7 @@ IFilter::PreflightResult ComputeNeighborListStatisticsFilter::preflightImpl(cons dataArrayPaths.push_back(inputArrayPath); - return {std::move(createCompatibleArrays(dataStructure, args))}; + return {std::move(CreateCompatibleArrays(dataStructure, args))}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborListStatisticsFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborListStatisticsFilter.hpp index 0393ffa375..0e3eb20aff 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborListStatisticsFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborListStatisticsFilter.hpp @@ -91,8 +91,6 @@ class SIMPLNXCORE_EXPORT ComputeNeighborListStatisticsFilter : public IFilter UniquePointer clone() const override; protected: - OutputActions createCompatibleArrays(const DataStructure& data, const Arguments& args) const; - /** * @brief * @param data diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborhoodsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborhoodsFilter.cpp index 84ad1157bf..0224ffb311 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborhoodsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNeighborhoodsFilter.cpp @@ -92,7 +92,6 @@ IFilter::UniquePointer ComputeNeighborhoodsFilter::clone() const IFilter::PreflightResult ComputeNeighborhoodsFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pMultiplesOfAverageValue = filterArgs.value(k_MultiplesOfAverage_Key); auto pEquivalentDiametersArrayPathValue = filterArgs.value(k_EquivalentDiametersArrayPath_Key); auto pFeaturePhasesArrayPathValue = filterArgs.value(k_FeaturePhasesArrayPath_Key); auto pCentroidsArrayPathValue = filterArgs.value(k_CentroidsArrayPath_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNumFeaturesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNumFeaturesFilter.cpp index f7dc055d78..5699f8fd77 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNumFeaturesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeNumFeaturesFilter.cpp @@ -103,12 +103,12 @@ Result<> ComputeNumFeaturesFilter::executeImpl(DataStructure& dataStructure, con auto pEnsembleDataPathValue = filterArgs.value(k_EnsembleAttributeMatrixPath_Key); auto pNumFeaturesArrayPathValue = pEnsembleDataPathValue.createChildPath(filterArgs.value(k_NumFeaturesArrayName_Key)); - const auto& featurePhasesArrayRef = dataStructure.getDataRefAs(pFeaturePhasesArrayPathValue); - auto& numFeaturesArrayRef = dataStructure.getDataRefAs(pNumFeaturesArrayPathValue); + const auto& featurePhasesStore = dataStructure.getDataAs(pFeaturePhasesArrayPathValue)->getDataStoreRef(); + auto& numFeaturesStore = dataStructure.getDataAs(pNumFeaturesArrayPathValue)->getDataStoreRef(); - for(usize index = 1; index < featurePhasesArrayRef.getNumberOfTuples(); index++) + for(usize index = 1; index < featurePhasesStore.getNumberOfTuples(); index++) { - numFeaturesArrayRef[featurePhasesArrayRef[index]]++; + numFeaturesStore[featurePhasesStore[index]]++; } return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeSurfaceAreaToVolumeFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeSurfaceAreaToVolumeFilter.cpp index 42be081203..ff8fc59923 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeSurfaceAreaToVolumeFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeSurfaceAreaToVolumeFilter.cpp @@ -94,7 +94,7 @@ IFilter::PreflightResult ComputeSurfaceAreaToVolumeFilter::preflightImpl(const D nx::core::Result resultOutputActions; - // Get the Cell Data Array so we get the tuple shape correct + // Get the Cell Data Array, so we get the tuple shape correct const auto* featureDataArray = dataStructure.getDataAs(pNumCellsArrayPathValue); if(nullptr == featureDataArray) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeSurfaceFeaturesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeSurfaceFeaturesFilter.cpp index 4ce694378a..c12b8b987a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeSurfaceFeaturesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeSurfaceFeaturesFilter.cpp @@ -2,7 +2,6 @@ #include "simplnx/Common/Array.hpp" #include "simplnx/DataStructure/DataPath.hpp" -#include "simplnx/DataStructure/DataStore.hpp" #include "simplnx/DataStructure/Geometry/ImageGeom.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" @@ -19,7 +18,7 @@ using namespace nx::core; namespace { -bool IsPointASurfaceFeature(const Point2D& point, usize xPoints, usize yPoints, bool markFeature0Neighbors, const Int32Array& featureIds) +bool IsPointASurfaceFeature(const Point2D& point, usize xPoints, usize yPoints, bool markFeature0Neighbors, const Int32AbstractDataStore& featureIds) { const usize yStride = point.getY() * xPoints; @@ -55,7 +54,7 @@ bool IsPointASurfaceFeature(const Point2D& point, usize xPoints, usize yP return false; } -bool IsPointASurfaceFeature(const Point3D& point, usize xPoints, usize yPoints, usize zPoints, bool markFeature0Neighbors, const Int32Array& featureIds) +bool IsPointASurfaceFeature(const Point3D& point, usize xPoints, usize yPoints, usize zPoints, bool markFeature0Neighbors, const Int32AbstractDataStore& featureIds) { usize yStride = point.getY() * xPoints; usize zStride = point.getZ() * xPoints * yPoints; @@ -108,8 +107,8 @@ void findSurfaceFeatures3D(DataStructure& dataStructure, const DataPath& feature bool markFeature0Neighbors, const std::atomic_bool& shouldCancel) { const auto& featureGeometry = dataStructure.getDataRefAs(featureGeometryPathValue); - const auto& featureIds = dataStructure.getDataRefAs(featureIdsArrayPathValue); - auto& surfaceFeatures = dataStructure.getDataRefAs(surfaceFeaturesArrayPathValue); + const auto& featureIds = dataStructure.getDataAs(featureIdsArrayPathValue)->getDataStoreRef(); + auto& surfaceFeatures = dataStructure.getDataAs(surfaceFeaturesArrayPathValue)->getDataStoreRef(); const usize xPoints = featureGeometry.getNumXCells(); const usize yPoints = featureGeometry.getNumYCells(); @@ -145,8 +144,8 @@ void findSurfaceFeatures2D(DataStructure& dataStructure, const DataPath& feature bool markFeature0Neighbors, const std::atomic_bool& shouldCancel) { const auto& featureGeometry = dataStructure.getDataRefAs(featureGeometryPathValue); - const auto& featureIds = dataStructure.getDataRefAs(featureIdsArrayPathValue); - auto& surfaceFeatures = dataStructure.getDataRefAs(surfaceFeaturesArrayPathValue); + const auto& featureIds = dataStructure.getDataAs(featureIdsArrayPathValue)->getDataStoreRef(); + auto& surfaceFeatures = dataStructure.getDataAs(surfaceFeaturesArrayPathValue)->getDataStoreRef(); usize xPoints = 0; usize yPoints = 0; @@ -297,9 +296,8 @@ Result<> ComputeSurfaceFeaturesFilter::executeImpl(DataStructure& dataStructure, const auto pSurfaceFeaturesArrayPathValue = pCellFeaturesAttributeMatrixPathValue.createChildPath(filterArgs.value(k_SurfaceFeaturesArrayName_Key)); // Resize the surface features array to the proper size - const Int32Array& featureIds = dataStructure.getDataRefAs(pFeatureIdsArrayPathValue); - auto& surfaceFeatures = dataStructure.getDataRefAs(pSurfaceFeaturesArrayPathValue); - auto& surfaceFeaturesStore = surfaceFeatures.getDataStoreRef(); + const auto& featureIds = dataStructure.getDataAs(pFeatureIdsArrayPathValue)->getDataStoreRef(); + auto& surfaceFeatures = dataStructure.getDataAs(pSurfaceFeaturesArrayPathValue)->getDataStoreRef(); const usize featureIdsMaxIdx = std::distance(featureIds.begin(), std::max_element(featureIds.cbegin(), featureIds.cend())); const usize maxFeature = featureIds[featureIdsMaxIdx]; @@ -310,7 +308,7 @@ Result<> ComputeSurfaceFeaturesFilter::executeImpl(DataStructure& dataStructure, { return resizeResults; } - surfaceFeaturesStore.fill(0); + surfaceFeatures.fill(0); // Find surface features const auto& featureGeometry = dataStructure.getDataRefAs(pFeatureGeometryPathValue); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleAreasFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleAreasFilter.cpp index 046a02fbb8..6fddad2aa2 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleAreasFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeTriangleAreasFilter.cpp @@ -26,7 +26,7 @@ constexpr nx::core::int32 k_MissingFeatureAttributeMatrix = -75769; class CalculateAreasImpl { public: - CalculateAreasImpl(const TriangleGeom* triangleGeom, Float64Array& areas, const std::atomic_bool& shouldCancel) + CalculateAreasImpl(const TriangleGeom* triangleGeom, Float64AbstractDataStore& areas, const std::atomic_bool& shouldCancel) : m_TriangleGeom(triangleGeom) , m_Areas(areas) , m_ShouldCancel(shouldCancel) @@ -62,7 +62,7 @@ class CalculateAreasImpl private: const TriangleGeom* m_TriangleGeom = nullptr; - Float64Array& m_Areas; + Float64AbstractDataStore& m_Areas; const std::atomic_bool& m_ShouldCancel; }; } // namespace @@ -132,7 +132,7 @@ IFilter::PreflightResult ComputeTriangleAreasFilter::preflightImpl(const DataStr nx::core::Result resultOutputActions; // The parameter will have validated that the Triangle Geometry exists and is the correct type - const TriangleGeom* triangleGeom = dataStructure.getDataAs(pTriangleGeometryDataPath); + const auto* triangleGeom = dataStructure.getDataAs(pTriangleGeometryDataPath); // Get the Face AttributeMatrix from the Geometry (It should have been set at construction of the Triangle Geometry) const AttributeMatrix* faceAttributeMatrix = triangleGeom->getFaceAttributeMatrix(); @@ -164,7 +164,7 @@ Result<> ComputeTriangleAreasFilter::executeImpl(DataStructure& dataStructure, c const AttributeMatrix* faceAttributeMatrix = triangleGeom->getFaceAttributeMatrix(); DataPath pCalculatedAreasDataPath = pTriangleGeometryDataPath.createChildPath(faceAttributeMatrix->getName()).createChildPath(pCalculatedAreasName); - auto& faceAreas = dataStructure.getDataRefAs(pCalculatedAreasDataPath); + auto& faceAreas = dataStructure.getDataAs(pCalculatedAreasDataPath)->getDataStoreRef(); // Parallel algorithm to find duplicate nodes ParallelDataAlgorithm dataAlg; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeVolumeFractionsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeVolumeFractionsFilter.cpp index 78093612ea..eafa1c9408 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeVolumeFractionsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ComputeVolumeFractionsFilter.cpp @@ -75,12 +75,10 @@ IFilter::UniquePointer ComputeVolumeFractionsFilter::clone() const IFilter::PreflightResult ComputeVolumeFractionsFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pCellPhasesArrayPathValue = filterArgs.value(k_CellPhasesArrayPath_Key); auto pCellEnsembleAttributeMatrixPathValue = filterArgs.value(k_CellEnsembleAttributeMatrixPath_Key); auto pVolFractionsArrayNameValue = filterArgs.value(k_VolFractionsArrayName_Key); const DataPath volFractionsArrayPath = pCellEnsembleAttributeMatrixPathValue.createChildPath(pVolFractionsArrayNameValue); - const auto& cellPhasesArray = dataStructure.getDataRefAs(pCellPhasesArrayPathValue); PreflightResult preflightResult; nx::core::Result resultOutputActions; @@ -105,22 +103,22 @@ Result<> ComputeVolumeFractionsFilter::executeImpl(DataStructure& dataStructure, auto pCellEnsembleAttributeMatrixPathValue = filterArgs.value(k_CellEnsembleAttributeMatrixPath_Key); auto pVolFractionsArrayNameValue = filterArgs.value(k_VolFractionsArrayName_Key); - auto& cellPhasesArrayRef = dataStructure.getDataRefAs(filterArgs.value(k_CellPhasesArrayPath_Key)); - auto& volFractionsArrayRef = dataStructure.getDataRefAs(pCellEnsembleAttributeMatrixPathValue.createChildPath(pVolFractionsArrayNameValue)); + const auto& cellPhases = dataStructure.getDataAs(filterArgs.value(k_CellPhasesArrayPath_Key))->getDataStoreRef(); + auto& volFractions = dataStructure.getDataAs(pCellEnsembleAttributeMatrixPathValue.createChildPath(pVolFractionsArrayNameValue))->getDataStoreRef(); - usize totalPoints = cellPhasesArrayRef.getNumberOfTuples(); - usize totalEnsembles = volFractionsArrayRef.getNumberOfTuples(); + usize totalPoints = cellPhases.getNumberOfTuples(); + usize totalEnsembles = volFractions.getNumberOfTuples(); std::vector ensembleElements(totalEnsembles, 0); // Calculate the total number of elements in each Ensemble for(usize index = 0; index < totalPoints; index++) { - ensembleElements[cellPhasesArrayRef[index]]++; + ensembleElements[cellPhases[index]]++; } // Calculate the Volume Fraction for(usize index = 0; index < totalEnsembles; index++) { - volFractionsArrayRef[index] = static_cast(ensembleElements[index]) / static_cast(totalPoints); + volFractions[index] = static_cast(ensembleElements[index]) / static_cast(totalPoints); } return {}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConditionalSetValueFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConditionalSetValueFilter.cpp index 641fd5c7ec..b32b95b865 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConditionalSetValueFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConditionalSetValueFilter.cpp @@ -6,12 +6,8 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/StringParameter.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -39,18 +35,18 @@ struct ReplaceValueInArrayFunctor template void operator()(IDataArray& workingArray, const std::string& removeValue, const std::string& replaceValue) { - auto& dataArray = dynamic_cast&>(workingArray); + auto& dataStore = workingArray.template getIDataStoreRefAs>(); auto removeVal = convertFromStringToType(removeValue); auto replaceVal = convertFromStringToType(replaceValue); - const auto size = dataArray.getNumberOfTuples() * dataArray.getNumberOfComponents(); + const auto size = dataStore.getNumberOfTuples() * dataStore.getNumberOfComponents(); for(usize index = 0; index < size; index++) { - if(dataArray[index] == removeVal) + if(dataStore[index] == removeVal) { - dataArray[index] = replaceVal; + dataStore[index] = replaceVal; } } } @@ -124,7 +120,6 @@ IFilter::PreflightResult ConditionalSetValueFilter::preflightImpl(const DataStru auto replaceValueString = filterArgs.value(k_ReplaceValue_Key); auto selectedArrayPath = filterArgs.value(k_SelectedArrayPath_Key); auto pConditionalPath = filterArgs.value(k_ConditionalArrayPath_Key); - auto pInvertMask = filterArgs.value(k_InvertMask_Key); const DataObject& inputDataObject = dataStructure.getDataRef(selectedArrayPath); @@ -140,7 +135,7 @@ IFilter::PreflightResult ConditionalSetValueFilter::preflightImpl(const DataStru if(useConditionalValue) { // Validate that the Conditional Array is of the correct type - const IDataArray* dataObject = dataStructure.getDataAs(pConditionalPath); + const auto* dataObject = dataStructure.getDataAs(pConditionalPath); if(dataObject->getDataType() != nx::core::DataType::boolean && dataObject->getDataType() != nx::core::DataType::uint8 && dataObject->getDataType() != nx::core::DataType::int8) { @@ -191,9 +186,9 @@ Result<> ConditionalSetValueFilter::executeImpl(DataStructure& dataStructure, co else { auto& inputDataArray = dataStructure.getDataRefAs(selectedArrayPath); - auto removeValueString = filterArgs.value(k_RemoveValue_Key); - ExecuteDataFunction(ReplaceValueInArrayFunctor{}, inputDataArray.getDataType(), inputDataArray, removeValueString, replaceValueString); + ExecuteDataFunction(ReplaceValueInArrayFunctor{}, inputDataArray.getDataType(), inputDataArray, filterArgs.value(k_RemoveValue_Key), replaceValueString); } + return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConvertColorToGrayScaleFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConvertColorToGrayScaleFilter.cpp index 312d0a4d95..f4a865c18e 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConvertColorToGrayScaleFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConvertColorToGrayScaleFilter.cpp @@ -5,8 +5,6 @@ #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/DataStructure/IDataArray.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" -#include "simplnx/Filter/Actions/CreateAttributeMatrixAction.hpp" -#include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/ChoicesParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" @@ -184,8 +182,6 @@ constexpr StringLiteral k_ConversionAlgorithmKey = "ConversionAlgorithm"; constexpr StringLiteral k_ColorWeightsKey = "ColorWeights"; constexpr StringLiteral k_ColorChannelKey = "ColorChannel"; constexpr StringLiteral k_InputDataArrayVectorKey = "InputDataArrayVector"; -constexpr StringLiteral k_CreateNewAttributeMatrixKey = "CreateNewAttributeMatrix"; -constexpr StringLiteral k_OutputAttributeMatrixNameKey = "OutputAttributeMatrixName"; constexpr StringLiteral k_OutputArrayPrefixKey = "OutputArrayPrefix"; } // namespace SIMPL } // namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConvertDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConvertDataFilter.cpp index 8b002074a9..3de8c55af1 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConvertDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ConvertDataFilter.cpp @@ -112,7 +112,7 @@ Result<> ConvertDataFilter::executeImpl(DataStructure& dataStructure, const Argu const std::atomic_bool& shouldCancel) const { ConvertDataInputValues inputValues; - uint64 scalarTypeIndex = filterArgs.value(k_ScalarType_Key); + auto scalarTypeIndex = filterArgs.value(k_ScalarType_Key); inputValues.ScalarType = StringToDataType(GetAllDataTypesAsStrings()[scalarTypeIndex]); inputValues.SelectedArrayPath = filterArgs.value(k_ArrayToConvertPath_Key); auto pConvertedArrayName = filterArgs.value(k_ConvertedArrayName_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CopyFeatureArrayToElementArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CopyFeatureArrayToElementArrayFilter.cpp index f7b233bb9e..b96a8797da 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CopyFeatureArrayToElementArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CopyFeatureArrayToElementArrayFilter.cpp @@ -17,26 +17,23 @@ using namespace nx::core; namespace { - template class CopyFeatureArrayToElementArrayImpl { public: - CopyFeatureArrayToElementArrayImpl(DataStructure& dataStructure, const DataPath& selectedFeatureArrayPath, const Int32Array& featureIdsArray, const DataPath& createdArrayPath, - const std::atomic_bool& shouldCancel) - : m_DataStructure(dataStructure) - , m_SelectedFeatureArrayPath(selectedFeatureArrayPath) - , m_FeatureIdsArray(featureIdsArray) - , m_CreatedArrayPath(createdArrayPath) + using StoreType = AbstractDataStore; + + CopyFeatureArrayToElementArrayImpl(const IDataArray* selectedFeatureArray, const Int32AbstractDataStore& featureIdsStore, IDataArray* createdArray, const std::atomic_bool& shouldCancel) + : m_SelectedFeature(selectedFeatureArray->template getIDataStoreRefAs()) + , m_FeatureIdsStore(featureIdsStore) + , m_CreatedStore(createdArray->template getIDataStoreRefAs()) , m_ShouldCancel(shouldCancel) { } void operator()(const Range& range) const { - const DataArray& selectedFeatureArray = m_DataStructure.getDataRefAs>(m_SelectedFeatureArrayPath); - auto& createdArray = m_DataStructure.getDataRefAs>(m_CreatedArrayPath); - const usize totalFeatureArrayComponents = selectedFeatureArray.getNumberOfComponents(); + const usize totalFeatureArrayComponents = m_SelectedFeature.getNumberOfComponents(); for(usize i = range.min(); i < range.max(); ++i) { @@ -45,21 +42,18 @@ class CopyFeatureArrayToElementArrayImpl return; } - // Get the feature identifier (or what ever the user has selected as their "Feature" identifier - const int32 featureIdx = m_FeatureIdsArray[i]; - for(usize faComp = 0; faComp < totalFeatureArrayComponents; faComp++) { - createdArray[totalFeatureArrayComponents * i + faComp] = selectedFeatureArray[totalFeatureArrayComponents * featureIdx + faComp]; + // Get the feature identifier (or what ever the user has selected as their "Feature" identifier + m_CreatedStore[totalFeatureArrayComponents * i + faComp] = m_SelectedFeature[totalFeatureArrayComponents * m_FeatureIdsStore[i] + faComp]; } } } private: - DataStructure& m_DataStructure; - const DataPath& m_SelectedFeatureArrayPath; - const Int32Array& m_FeatureIdsArray; - const DataPath& m_CreatedArrayPath; + const StoreType& m_SelectedFeature; + const Int32AbstractDataStore& m_FeatureIdsStore; + StoreType& m_CreatedStore; const std::atomic_bool& m_ShouldCancel; }; } // namespace @@ -169,11 +163,11 @@ Result<> CopyFeatureArrayToElementArrayFilter::executeImpl(DataStructure& dataSt const auto pFeatureIdsArrayPathValue = filterArgs.value(k_CellFeatureIdsArrayPath_Key); const auto createdArraySuffix = filterArgs.value(k_CreatedArraySuffix_Key); - const Int32Array& featureIds = dataStructure.getDataRefAs(pFeatureIdsArrayPathValue); + const auto& featureIds = dataStructure.getDataRefAs(pFeatureIdsArrayPathValue); for(const auto& selectedFeatureArrayPath : pSelectedFeatureArrayPathsValue) { DataPath createdArrayPath = pFeatureIdsArrayPathValue.replaceName(selectedFeatureArrayPath.getTargetName() + createdArraySuffix); - const IDataArray& selectedFeatureArray = dataStructure.getDataRefAs(selectedFeatureArrayPath); + const auto* selectedFeatureArray = dataStructure.getDataAs(selectedFeatureArrayPath); messageHandler(IFilter::ProgressMessage{IFilter::ProgressMessage::Type::Info, fmt::format("Validating number of featureIds in input array '{}'...", selectedFeatureArrayPath.toString())}); auto results = ValidateNumFeaturesInArray(dataStructure, selectedFeatureArrayPath, featureIds); @@ -185,7 +179,8 @@ Result<> CopyFeatureArrayToElementArrayFilter::executeImpl(DataStructure& dataSt messageHandler(IFilter::ProgressMessage{IFilter::ProgressMessage::Type::Info, fmt::format("Copying data into target array '{}'...", createdArrayPath.toString())}); ParallelDataAlgorithm dataAlg; dataAlg.setRange(0, featureIds.getNumberOfTuples()); - ExecuteParallelFunction<::CopyFeatureArrayToElementArrayImpl>(selectedFeatureArray.getDataType(), dataAlg, dataStructure, selectedFeatureArrayPath, featureIds, createdArrayPath, shouldCancel); + ExecuteParallelFunction<::CopyFeatureArrayToElementArrayImpl>(selectedFeatureArray->getDataType(), dataAlg, selectedFeatureArray, featureIds.getDataStoreRef(), + dataStructure.getDataAs(createdArrayPath), shouldCancel); } return {}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateAttributeMatrixFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateAttributeMatrixFilter.cpp index becdfb520b..ed58927e8b 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateAttributeMatrixFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateAttributeMatrixFilter.cpp @@ -58,7 +58,7 @@ IFilter::UniquePointer CreateAttributeMatrixFilter::clone() const IFilter::PreflightResult CreateAttributeMatrixFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& args, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - DataPath dataObjectPath = args.value(k_DataObjectPath); + auto dataObjectPath = args.value(k_DataObjectPath); auto tableData = args.value(k_TupleDims_Key); const auto& rowData = tableData.at(0); @@ -87,7 +87,6 @@ namespace { namespace SIMPL { -constexpr StringLiteral k_AttributeMatrixTypeKey = "AttributeMatrixType"; constexpr StringLiteral k_TupleDimensionsKey = "TupleDimensions"; constexpr StringLiteral k_CreatedAttributeMatrixKey = "CreatedAttributeMatrix"; } // namespace SIMPL diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateColorMapFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateColorMapFilter.cpp index 4aea698b3e..8b80663b42 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateColorMapFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateColorMapFilter.cpp @@ -2,7 +2,6 @@ #include "Algorithms/CreateColorMap.hpp" -#include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/DataStructure/IDataArray.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" @@ -19,9 +18,6 @@ using namespace nx::core; namespace { - -using GoodVoxelsArrayType = BoolArray; - constexpr int32 k_MissingGeomError = -72440; constexpr int32 k_IncorrectInputArray = -72441; constexpr int32 k_MissingInputArray = -72442; @@ -167,7 +163,6 @@ namespace namespace SIMPL { constexpr StringLiteral k_SelectedPresetNameKey = "SelectedPresetName"; -constexpr StringLiteral k_SelectedPresetControlPointsKey = "SelectedPresetControlPoints"; constexpr StringLiteral k_SelectedDataArrayPathKey = "SelectedDataArrayPath"; constexpr StringLiteral k_RgbArrayNameKey = "RgbArrayName"; } // namespace SIMPL diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp index 8296858c18..b93e305e5c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayFilter.cpp @@ -10,6 +10,7 @@ #include "simplnx/Parameters/NumericTypeParameter.hpp" #include "simplnx/Parameters/StringParameter.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" +#include "simplnx/Utilities/FilterUtilities.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -20,15 +21,17 @@ namespace { constexpr int32 k_EmptyParameterError = -123; -template -void CreateAndInitArray(DataStructure& dataStructure, const DataPath& path, const std::string& initValue) +struct CreateAndInitArrayFunctor { - Result result = ConvertTo::convert(initValue); - T value = result.value(); - auto& dataArray = dataStructure.getDataRefAs>(path); - auto& dataStore = dataArray.getDataStoreRef(); - dataStore.fill(value); -} + template + void operator()(IDataArray* iDataArray, const std::string& initValue) + { + Result result = ConvertTo::convert(initValue); + + auto* dataStore = iDataArray->template getIDataStoreAs>(); + dataStore->fill(result.value()); + } +}; } // namespace namespace nx::core @@ -175,55 +178,10 @@ IFilter::PreflightResult CreateDataArrayFilter::preflightImpl(const DataStructur Result<> CreateDataArrayFilter::executeImpl(DataStructure& dataStructure, const Arguments& args, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto numericType = args.value(k_NumericType_Key); auto path = args.value(k_DataPath_Key); auto initValue = args.value(k_InitializationValue_Key); - switch(numericType) - { - case NumericType::int8: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - case NumericType::uint8: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - case NumericType::int16: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - case NumericType::uint16: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - case NumericType::int32: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - case NumericType::uint32: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - case NumericType::int64: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - case NumericType::uint64: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - case NumericType::float32: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - case NumericType::float64: { - CreateAndInitArray(dataStructure, path, initValue); - break; - } - default: - throw std::runtime_error("Invalid NumericType used"); - } + ExecuteNeighborFunction(CreateAndInitArrayFunctor{}, ConvertNumericTypeToDataType(args.value(k_NumericType_Key)), dataStructure.getDataAs(path), initValue); return {}; } @@ -234,10 +192,7 @@ namespace SIMPL { constexpr StringLiteral k_ScalarTypeKey = "ScalarType"; constexpr StringLiteral k_NumberOfComponentsKey = "NumberOfComponents"; -constexpr StringLiteral k_InitializationTypeKey = "InitializationType"; constexpr StringLiteral k_InitializationValueKey = "InitializationValue"; -constexpr StringLiteral k_InitializationRangeKey = "InitializationRange"; -constexpr StringLiteral k_StartingIndexValueKey = "StartingIndexValue"; constexpr StringLiteral k_NewArrayKey = "NewArray"; } // namespace SIMPL } // namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateFeatureArrayFromElementArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateFeatureArrayFromElementArrayFilter.cpp index c3e0f1d0d0..772bca6c06 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateFeatureArrayFromElementArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateFeatureArrayFromElementArrayFilter.cpp @@ -8,10 +8,8 @@ #include "simplnx/Parameters/DataGroupSelectionParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Utilities/DataObjectUtilities.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -20,25 +18,20 @@ namespace struct CopyCellDataFunctor { template - Result<> operator()(DataStructure& dataStructure, const DataPath& selectedCellArrayPathValue, const DataPath& featureIdsArrayPathValue, const DataPath& createdArrayNameValue, - const std::atomic_bool& shouldCancel) + Result<> operator()(const IDataArray* selectedCellArray, const Int32AbstractDataStore& featureIds, IDataArray* createdArray, const std::atomic_bool& shouldCancel) { - const DataArray& selectedCellArray = dataStructure.getDataRefAs>(selectedCellArrayPathValue); - const auto& selectedCellArrayStore = selectedCellArray.getDataStoreRef(); - const Int32Array& featureIdsArray = dataStructure.getDataRefAs(featureIdsArrayPathValue); - const Int32AbstractDataStore& featureIds = featureIdsArray.getDataStoreRef(); - auto& createdArray = dataStructure.getDataRefAs>(createdArrayNameValue); - auto& createdDataStore = createdArray.getDataStoreRef(); + const auto& selectedCellStore = selectedCellArray->template getIDataStoreRefAs>(); + auto& createdDataStore = createdArray->template getIDataStoreRefAs>(); // Initialize the output array with a default value - createdArray.fill(0); + createdDataStore.fill(0); - usize totalCellArrayComponents = selectedCellArray.getNumberOfComponents(); + usize totalCellArrayComponents = selectedCellStore.getNumberOfComponents(); std::map featureMap; Result<> result; - usize totalCellArrayTuples = selectedCellArray.getNumberOfTuples(); + usize totalCellArrayTuples = selectedCellStore.getNumberOfTuples(); for(usize cellTupleIdx = 0; cellTupleIdx < totalCellArrayTuples; cellTupleIdx++) { if(shouldCancel) @@ -59,8 +52,8 @@ struct CopyCellDataFunctor usize firstInstanceCellTupleIdx = featureMap[featureIdx]; for(usize cellCompIdx = 0; cellCompIdx < totalCellArrayComponents; cellCompIdx++) { - T firstInstanceCellVal = selectedCellArrayStore[firstInstanceCellTupleIdx + cellCompIdx]; - T currentCellVal = selectedCellArrayStore[totalCellArrayComponents * cellTupleIdx + cellCompIdx]; + T firstInstanceCellVal = selectedCellStore[firstInstanceCellTupleIdx + cellCompIdx]; + T currentCellVal = selectedCellStore[totalCellArrayComponents * cellTupleIdx + cellCompIdx]; if(currentCellVal != firstInstanceCellVal && result.warnings().empty()) { // The values are inconsistent with the first values for this feature identifier, so throw a warning @@ -68,7 +61,7 @@ struct CopyCellDataFunctor Warning{-1000, fmt::format("Elements from Feature {} do not all have the same value. The last value copied into Feature {} will be used", featureIdx, featureIdx)}); } - createdDataStore[totalCellArrayComponents * featureIdx + cellCompIdx] = selectedCellArrayStore[totalCellArrayComponents * cellTupleIdx + cellCompIdx]; + createdDataStore[totalCellArrayComponents * featureIdx + cellCompIdx] = selectedCellStore[totalCellArrayComponents * cellTupleIdx + cellCompIdx]; } } @@ -181,21 +174,20 @@ Result<> CreateFeatureArrayFromElementArrayFilter::executeImpl(DataStructure& da auto pCreatedArrayNameValue = filterArgs.value(k_CreatedArrayName_Key); const DataPath createdArrayPath = pCellFeatureAttributeMatrixPathValue.createChildPath(pCreatedArrayNameValue); - const IDataArray& selectedCellArray = dataStructure.getDataRefAs(pSelectedCellArrayPathValue); - const Int32Array& featureIdsArray = dataStructure.getDataRefAs(pFeatureIdsArrayPathValue); - const Int32AbstractDataStore& featureIds = featureIdsArray.getDataStoreRef(); - auto& createdArray = dataStructure.getDataRefAs(createdArrayPath); + const auto* selectedCellArray = dataStructure.getDataAs(pSelectedCellArrayPathValue); + const auto& featureIds = dataStructure.getDataAs(pFeatureIdsArrayPathValue)->getDataStoreRef(); + auto* createdArray = dataStructure.getDataAs(createdArrayPath); // Resize the created array to the proper size usize featureIdsMaxIdx = std::distance(featureIds.begin(), std::max_element(featureIds.cbegin(), featureIds.cend())); usize maxValue = featureIds[featureIdsMaxIdx]; auto& cellFeatureAttrMat = dataStructure.getDataRefAs(pCellFeatureAttributeMatrixPathValue); - auto& createdArrayStore = createdArray.getIDataStoreRefAs(); - createdArrayStore.resizeTuples(std::vector{maxValue + 1}); + auto* createdArrayStore = createdArray->template getIDataStoreAs(); + createdArrayStore->resizeTuples(std::vector{maxValue + 1}); cellFeatureAttrMat.resizeTuples(std::vector{maxValue + 1}); - return ExecuteDataFunction(CopyCellDataFunctor{}, selectedCellArray.getDataType(), dataStructure, pSelectedCellArrayPathValue, pFeatureIdsArrayPathValue, createdArrayPath, shouldCancel); + return ExecuteDataFunction(CopyCellDataFunctor{}, selectedCellArray->getDataType(), selectedCellArray, featureIds, createdArray, shouldCancel); } namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateGeometryFilter.cpp index da848107ca..21e6827583 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateGeometryFilter.cpp @@ -27,10 +27,9 @@ using namespace nx::core; namespace nx::core { - namespace { -Result<> checkGeometryArraysCompatible(const Float32Array& vertices, const UInt64Array& cells, bool treatWarningsAsErrors, const std::string& cellType) +Result<> checkGeometryArraysCompatible(const Float32AbstractDataStore& vertices, const UInt64AbstractDataStore& cells, bool treatWarningsAsErrors, const std::string& cellType) { Result<> warningResults; usize numVertices = vertices.getNumberOfTuples(); @@ -52,11 +51,11 @@ Result<> checkGeometryArraysCompatible(const Float32Array& vertices, const UInt6 return warningResults; } -Result<> checkGridBoundsResolution(const Float32Array& bounds, bool treatWarningsAsErrors, const std::string& boundType) +Result<> checkGridBoundsResolution(const Float32AbstractDataStore& bounds, bool treatWarningsAsErrors, const std::string& boundType) { Result<> warningResults; - float val = bounds[0]; - for(size_t i = 1; i < bounds.getNumberOfTuples(); i++) + float32 val = bounds[0]; + for(usize i = 1; i < bounds.getNumberOfTuples(); i++) { if(val > bounds[i]) { @@ -312,7 +311,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure { auto pEdgeListPath = filterArgs.value(k_EdgeListPath_Key); auto pEdgeAMName = filterArgs.value(k_EdgeAttributeMatrixName_Key); - if(const auto edgeList = dataStructure.getDataAs(pEdgeListPath); edgeList == nullptr) + if(const auto* edgeList = dataStructure.getDataAs(pEdgeListPath); edgeList == nullptr) { return {nonstd::make_unexpected(std::vector{Error{-9845, fmt::format("Cannot find selected edge list at path '{}'", pEdgeListPath.toString())}})}; } @@ -323,7 +322,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure if(pGeometryType == k_TriangleGeometry) // TriangleGeom { auto pTriangleListPath = filterArgs.value(k_TriangleListPath_Key); - if(const auto triangleList = dataStructure.getDataAs(pTriangleListPath); triangleList == nullptr) + if(const auto* triangleList = dataStructure.getDataAs(pTriangleListPath); triangleList == nullptr) { return {nonstd::make_unexpected(std::vector{Error{-9846, fmt::format("Cannot find selected triangle list at path '{}'", pTriangleListPath.toString())}})}; } @@ -334,7 +333,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure if(pGeometryType == k_QuadGeometry) // QuadGeom { auto pQuadListPath = filterArgs.value(k_QuadrilateralListPath_Key); - if(const auto quadList = dataStructure.getDataAs(pQuadListPath); quadList == nullptr) + if(const auto* quadList = dataStructure.getDataAs(pQuadListPath); quadList == nullptr) { return {nonstd::make_unexpected(std::vector{Error{-9847, fmt::format("Cannot find selected quadrilateral list at path '{}'", pQuadListPath.toString())}})}; } @@ -345,7 +344,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure if(pGeometryType == k_TetGeometry) // TetrahedralGeom { auto pTetListPath = filterArgs.value(k_TetrahedralListPath_Key); - if(const auto tetList = dataStructure.getDataAs(pTetListPath); tetList == nullptr) + if(const auto* tetList = dataStructure.getDataAs(pTetListPath); tetList == nullptr) { return {nonstd::make_unexpected(std::vector{Error{-9848, fmt::format("Cannot find selected quadrilateral list at path '{}'", pTetListPath.toString())}})}; } @@ -356,7 +355,7 @@ IFilter::PreflightResult CreateGeometryFilter::preflightImpl(const DataStructure if(pGeometryType == k_HexGeometry) // HexahedralGeom { auto pHexListPath = filterArgs.value(k_HexahedralListPath_Key); - if(const auto hexList = dataStructure.getDataAs(pHexListPath); hexList == nullptr) + if(const auto* hexList = dataStructure.getDataAs(pHexListPath); hexList == nullptr) { return {nonstd::make_unexpected(std::vector{Error{-9849, fmt::format("Cannot find selected quadrilateral list at path '{}'", pHexListPath.toString())}})}; } @@ -376,9 +375,8 @@ 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 iGeometry = dataStructure.getDataAs(geometryPath); + auto* iGeometry = dataStructure.getDataAs(geometryPath); auto lengthUnit = static_cast(filterArgs.value(k_LengthUnitType_Key)); iGeometry->setUnits(lengthUnit); @@ -414,8 +412,8 @@ Result<> CreateGeometryFilter::executeImpl(DataStructure& dataStructure, const A { auto sharedEdgeListArrayPath = filterArgs.value(k_EdgeListPath_Key); const DataPath destEdgeListPath = geometryPath.createChildPath(sharedEdgeListArrayPath.getTargetName()); - const auto& edgesList = dataStructure.getDataRefAs(destEdgeListPath); - const auto& vertexList = dataStructure.getDataRefAs(geometryPath.createChildPath(sharedVertexListArrayPath.getTargetName())); + const auto& edgesList = dataStructure.getDataAs(destEdgeListPath)->getDataStoreRef(); + const auto& vertexList = dataStructure.getDataAs(geometryPath.createChildPath(sharedVertexListArrayPath.getTargetName()))->getDataStoreRef(); auto results = checkGeometryArraysCompatible(vertexList, edgesList, treatWarningsAsErrors, "edge"); if(results.invalid()) { @@ -426,8 +424,8 @@ Result<> CreateGeometryFilter::executeImpl(DataStructure& dataStructure, const A if(geometryType == k_TriangleGeometry || geometryType == k_QuadGeometry) { const DataPath destFaceListPath = geometryPath.createChildPath(sharedFaceListArrayPath.getTargetName()); - const auto& faceList = dataStructure.getDataRefAs(destFaceListPath); - const auto& vertexList = dataStructure.getDataRefAs(geometryPath.createChildPath(sharedVertexListArrayPath.getTargetName())); + const auto& faceList = dataStructure.getDataAs(destFaceListPath)->getDataStoreRef(); + const auto& vertexList = dataStructure.getDataAs(geometryPath.createChildPath(sharedVertexListArrayPath.getTargetName()))->getDataStoreRef(); auto results = checkGeometryArraysCompatible(vertexList, faceList, treatWarningsAsErrors, (geometryType == 4 ? "triangle" : "quadrilateral")); if(results.invalid()) { @@ -438,8 +436,8 @@ Result<> CreateGeometryFilter::executeImpl(DataStructure& dataStructure, const A if(geometryType == k_TetGeometry || geometryType == k_HexGeometry) { const DataPath destCellListPath = geometryPath.createChildPath(sharedCellListArrayPath.getTargetName()); - const auto& cellList = dataStructure.getDataRefAs(destCellListPath); - const auto& vertexList = dataStructure.getDataRefAs(geometryPath.createChildPath(sharedVertexListArrayPath.getTargetName())); + const auto& cellList = dataStructure.getDataAs(destCellListPath)->getDataStoreRef(); + const auto& vertexList = dataStructure.getDataAs(geometryPath.createChildPath(sharedVertexListArrayPath.getTargetName()))->getDataStoreRef(); auto results = checkGeometryArraysCompatible(vertexList, cellList, treatWarningsAsErrors, (geometryType == 6 ? "tetrahedral" : "hexahedral")); if(results.invalid()) { @@ -452,9 +450,9 @@ Result<> CreateGeometryFilter::executeImpl(DataStructure& dataStructure, const A auto xBoundsArrayPath = filterArgs.value(k_XBoundsPath_Key); auto yBoundsArrayPath = filterArgs.value(k_YBoundsPath_Key); auto zBoundsArrayPath = filterArgs.value(k_ZBoundsPath_Key); - const auto& srcXBounds = dataStructure.getDataRefAs(geometryPath.createChildPath(xBoundsArrayPath.getTargetName())); - const auto& srcYBounds = dataStructure.getDataRefAs(geometryPath.createChildPath(yBoundsArrayPath.getTargetName())); - const auto& srcZBounds = dataStructure.getDataRefAs(geometryPath.createChildPath(zBoundsArrayPath.getTargetName())); + const auto& srcXBounds = dataStructure.getDataAs(geometryPath.createChildPath(xBoundsArrayPath.getTargetName()))->getDataStoreRef(); + const auto& srcYBounds = dataStructure.getDataAs(geometryPath.createChildPath(yBoundsArrayPath.getTargetName()))->getDataStoreRef(); + const auto& srcZBounds = dataStructure.getDataAs(geometryPath.createChildPath(zBoundsArrayPath.getTargetName()))->getDataStoreRef(); auto xResults = checkGridBoundsResolution(srcXBounds, treatWarningsAsErrors, "X"); auto yResults = checkGridBoundsResolution(srcYBounds, treatWarningsAsErrors, "Y"); auto zResults = checkGridBoundsResolution(srcZBounds, treatWarningsAsErrors, "Z"); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateImageGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateImageGeometryFilter.cpp index 66f787c6cc..26d0b05b58 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateImageGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateImageGeometryFilter.cpp @@ -6,11 +6,9 @@ #include "simplnx/Parameters/DataGroupCreationParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/VectorParameter.hpp" - -#include - #include "simplnx/Utilities/SIMPLConversion.hpp" +#include #include using namespace std::string_literals; @@ -129,17 +127,6 @@ IFilter::PreflightResult CreateImageGeometryFilter::preflightImpl(const DataStru Result<> CreateImageGeometryFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - /**************************************************************************** - * Extract the actual input values from the 'filterArgs' object - ***************************************************************************/ - auto pImageGeometryPath = filterArgs.value(k_GeometryDataPath_Key); - auto pDimensionsValue = filterArgs.value(k_Dimensions_Key); - auto pOriginValue = filterArgs.value(k_Origin_Key); - auto pSpacingValue = filterArgs.value(k_Spacing_Key); - - /**************************************************************************** - * Write your algorithm implementation in this function - ***************************************************************************/ return {}; } } // namespace nx::core @@ -152,7 +139,6 @@ constexpr StringLiteral k_SelectedDataContainerKey = "SelectedDataContainer"; constexpr StringLiteral k_DimensionsKey = "Dimensions"; constexpr StringLiteral k_OriginKey = "Origin"; constexpr StringLiteral k_SpacingKey = "Spacing"; -constexpr StringLiteral k_BoxDimensionsKey = "BoxDimensions"; } // namespace SIMPL } // namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreatePythonSkeletonFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreatePythonSkeletonFilter.cpp index 59adf0166d..26648136e4 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreatePythonSkeletonFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreatePythonSkeletonFilter.cpp @@ -4,12 +4,10 @@ #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" +#include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" #include "simplnx/Utilities/StringUtilities.hpp" -#include "simplnx/Parameters/BoolParameter.hpp" -#include "simplnx/Parameters/DataObjectNameParameter.hpp" - #include namespace fs = std::filesystem; @@ -29,7 +27,7 @@ std::string CreatePythonSkeletonFilter::className() const return FilterTraits::className; } -//-----------------------------------------------------------------------p------- +//------------------------------------------------------------------------------ Uuid CreatePythonSkeletonFilter::uuid() const { return FilterTraits::uuid; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropImageGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropImageGeometryFilter.cpp index 33af0058ac..b4b47b87e9 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropImageGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropImageGeometryFilter.cpp @@ -18,7 +18,6 @@ #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" @@ -72,8 +71,8 @@ class CropImageGeomDataArray { public: CropImageGeomDataArray(const IDataArray& oldCellArray, IDataArray& newCellArray, const ImageGeom& srcImageGeom, std::array bounds, const std::atomic_bool& shouldCancel) - : m_OldCellArray(dynamic_cast&>(oldCellArray)) - , m_NewCellArray(dynamic_cast&>(newCellArray)) + : m_OldCellStore(oldCellArray.template getIDataStoreRefAs>()) + , m_NewCellStore(newCellArray.template getIDataStoreRefAs>()) , m_SrcImageGeom(srcImageGeom) , m_Bounds(bounds) , m_ShouldCancel(shouldCancel) @@ -95,11 +94,9 @@ class CropImageGeomDataArray protected: void convert() const { - size_t numComps = m_OldCellArray.getNumberOfComponents(); - const auto& oldCellData = m_OldCellArray.getDataStoreRef(); + size_t numComps = m_OldCellStore.getNumberOfComponents(); - auto& dataStore = m_NewCellArray.getDataStoreRef(); - std::fill(dataStore.begin(), dataStore.end(), static_cast(-1)); + m_NewCellStore.fill(static_cast(-1)); auto srcDims = m_SrcImageGeom.getDimensions(); @@ -117,7 +114,7 @@ class CropImageGeomDataArray uint64 srcIndex = (srcDims[0] * srcDims[1] * zIndex) + (srcDims[0] * yIndex) + xIndex; for(size_t compIndex = 0; compIndex < numComps; compIndex++) { - dataStore.setValue(destTupleIndex * numComps + compIndex, oldCellData.getValue(srcIndex * numComps + compIndex)); + m_NewCellStore.setValue(destTupleIndex * numComps + compIndex, m_OldCellStore.getValue(srcIndex * numComps + compIndex)); } destTupleIndex++; } @@ -126,8 +123,8 @@ class CropImageGeomDataArray } private: - const DataArray& m_OldCellArray; - DataArray& m_NewCellArray; + const AbstractDataStore& m_OldCellStore; + AbstractDataStore& m_NewCellStore; const ImageGeom& m_SrcImageGeom; std::array m_Bounds; const std::atomic_bool& m_ShouldCancel; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropVertexGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropVertexGeometryFilter.cpp index 5601ab7d16..95ad1c725d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropVertexGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CropVertexGeometryFilter.cpp @@ -9,10 +9,8 @@ #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" #include "simplnx/Parameters/VectorParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" namespace nx::core { @@ -21,14 +19,12 @@ namespace struct CopyDataToCroppedGeometryFunctor { template - void operator()(const IDataArray& inDataRef, IDataArray& outDataRef, const std::vector& croppedPoints) + void operator()(const IDataArray* inDataRef, IDataArray* outDataRef, const std::vector& croppedPoints) { - const DataArray& inputDataArray = dynamic_cast&>(inDataRef); - const auto& inputData = inputDataArray.getDataStoreRef(); - DataArray& croppedDataArray = dynamic_cast&>(outDataRef); - auto& croppedData = croppedDataArray.getDataStoreRef(); + const auto& inputData = inDataRef->template getIDataStoreRefAs>(); + auto& croppedData = outDataRef->template getIDataStoreRefAs>(); - usize nComps = inDataRef.getNumberOfComponents(); + usize nComps = inDataRef->getNumberOfComponents(); for(std::vector::size_type i = 0; i < croppedPoints.size(); i++) { @@ -214,7 +210,7 @@ Result<> CropVertexGeometryFilter::executeImpl(DataStructure& dataStructure, con auto zMax = posMax[2]; auto& vertices = dataStructure.getDataRefAs(vertexGeomPath); - int64 numVerts = static_cast(vertices.getNumberOfVertices()); + auto numVerts = static_cast(vertices.getNumberOfVertices()); auto* verticesPtr = vertices.getVertices(); auto& allVerts = verticesPtr->getDataStoreRef(); std::vector croppedPoints; @@ -257,10 +253,10 @@ Result<> CropVertexGeometryFilter::executeImpl(DataStructure& dataStructure, con { DataPath destArrayPath(croppedVertexDataPath.createChildPath(targetArrayPath.getTargetName())); - const auto& srcArray = dataStructure.getDataRefAs(targetArrayPath); - auto& destArray = dataStructure.getDataRefAs(destArrayPath); + const auto* srcArray = dataStructure.getDataAs(targetArrayPath); + auto* destArray = dataStructure.getDataAs(destArrayPath); - ExecuteDataFunction(CopyDataToCroppedGeometryFunctor{}, srcArray.getDataType(), srcArray, destArray, croppedPoints); + ExecuteDataFunction(CopyDataToCroppedGeometryFunctor{}, srcArray->getDataType(), srcArray, destArray, croppedPoints); } return {}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DBSCANFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DBSCANFilter.cpp index 84d1219ddf..351dd1ede5 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DBSCANFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DBSCANFilter.cpp @@ -115,8 +115,6 @@ IFilter::UniquePointer DBSCANFilter::clone() const //------------------------------------------------------------------------------ IFilter::PreflightResult DBSCANFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pEpsilonValue = filterArgs.value(k_Epsilon_Key); - auto pMinPointsValue = filterArgs.value(k_MinPoints_Key); auto pUseMaskValue = filterArgs.value(k_UseMask_Key); auto pSelectedArrayPathValue = filterArgs.value(k_SelectedArrayPath_Key); auto pMaskArrayPathValue = filterArgs.value(k_MaskArrayPath_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DeleteDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DeleteDataFilter.cpp index 0c6b8bc6b8..e89bc91577 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DeleteDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DeleteDataFilter.cpp @@ -1,7 +1,6 @@ #include "DeleteDataFilter.hpp" #include "simplnx/DataStructure/BaseGroup.hpp" -#include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/Filter/Actions/DeleteDataAction.hpp" #include "simplnx/Parameters/ChoicesParameter.hpp" @@ -11,7 +10,7 @@ /**The commented out code in this filter and the header is set up to offer deeper control * of the dataStructure. The current state of the dataStructure abstracts the underlying data graph - * into a heirarchical structure, thus the advanced handling and data management is not necessary. + * into a hierarchical structure, thus the advanced handling and data management is not necessary. * Should the code be uncommented one should review the test cases and round out the development. * The DeleteDataAction also implements code that has been commented out so it will need review as * well. @@ -85,7 +84,7 @@ IFilter::PreflightResult DeleteDataFilter::preflightImpl(const DataStructure& da // // original // // Remove Singular Node // // Rules: - // // - If multiparented, throw warning of effects and recommend DataPath removal instead + // // - If multi-parented, throw warning of effects and recommend DataPath removal instead // // - Edges that point to node will all be deleted // // - Node will be deleted // - IN CURRENT STATE BEHAVES MORE LIKE REMOVE START NODE AND ALL CHILDREN @@ -93,7 +92,7 @@ IFilter::PreflightResult DeleteDataFilter::preflightImpl(const DataStructure& da if(dataObject->getParentIds().size() > 1) { return {ConvertResultTo( - MakeWarningVoidResult(-61501, fmt::format("The object is multiparented, deleting this data could affect other unintended nodes. Consider using the Delete DataPath instead.")), {})}; + MakeWarningVoidResult(-61501, fmt::format("The object is multi-parented, deleting this data could affect other unintended nodes. Consider using the Delete DataPath instead.")), {})}; } auto action = std::make_unique(dataObjectPath, DeleteDataAction::DeleteType::JustObject); @@ -108,7 +107,7 @@ IFilter::PreflightResult DeleteDataFilter::preflightImpl(const DataStructure& da // // - Neither of the nodes (parent or child) should be deleted // // - The edge between the nodes should be removed from both the respective parent and child list - // // check parent that its not a top level path [ie no parent] (can't be removed) + // // check parent that it's not a top level path [ie no parent] (can't be removed) // if(dataObjectPath.getLength() < 2) // { // return {MakeErrorResult( @@ -124,15 +123,15 @@ IFilter::PreflightResult DeleteDataFilter::preflightImpl(const DataStructure& da // case DeletionType::DeleteUnsharedChildren: { // // Remove Start Node and Children Recursively (Independent Removal Only) // // Rules: - // // - If multiparented, any node and all children of that node will are kept + // // - If multi-parented, any node and all children of that node will are kept // // - Edges that point to deleted nodes wil be removed - // // - If start object is multiparented recommend edge removal instead + // // - If start object is multi-parented recommend edge removal instead // // check parent count (Base Case) // if(dataObject->getParentIds().size() > 1) // { // return { - // ConvertResultTo(MakeWarningVoidResult(-61503, fmt::format("The object cannot be processed because it is multiparented. Consider using the Delete DataPath instead.")), + // ConvertResultTo(MakeWarningVoidResult(-61503, fmt::format("The object cannot be processed because it is multi-parented. Consider using the Delete DataPath instead.")), // {})}; // } // else @@ -166,7 +165,7 @@ IFilter::PreflightResult DeleteDataFilter::preflightImpl(const DataStructure& da // // - Warn of absolute deletion of data and effects // // This needs to be implemented down the line - // // ConvertResultTo(MakeWarningVoidResult(-61505, fmt::format("This action will remove the underlying data which could affect other structures if it is multiparented")), {}); + // // ConvertResultTo(MakeWarningVoidResult(-61505, fmt::format("This action will remove the underlying data which could affect other structures if it is multi-parented")), {}); // const auto* baseGroup = dynamic_cast(dataObject); // if(baseGroup == nullptr) // Object is the lowest level in its path diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateBadDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateBadDataFilter.cpp index df518e3018..1c579695ad 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateBadDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateBadDataFilter.cpp @@ -13,7 +13,6 @@ #include "simplnx/Utilities/SIMPLConversion.hpp" #include "simplnx/Parameters/NumberParameter.hpp" -#include "simplnx/Utilities/DataGroupUtilities.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" using namespace nx::core; @@ -89,10 +88,6 @@ IFilter::PreflightResult ErodeDilateBadDataFilter::preflightImpl(const DataStruc const std::atomic_bool& shouldCancel) const { auto pOperationValue = filterArgs.value(k_Operation_Key); - auto pNumIterationsValue = filterArgs.value(k_NumIterations_Key); - auto pXDirOnValue = filterArgs.value(k_XDirOn_Key); - auto pYDirOnValue = filterArgs.value(k_YDirOn_Key); - auto pZDirOnValue = filterArgs.value(k_ZDirOn_Key); auto pFeatureIdsArrayPathValue = filterArgs.value(k_CellFeatureIdsArrayPath_Key); auto pIgnoredDataArrayPathsValue = filterArgs.value(k_IgnoredDataArrayPaths_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateCoordinationNumberFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateCoordinationNumberFilter.cpp index 3b117f9c1d..357332327f 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateCoordinationNumberFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateCoordinationNumberFilter.cpp @@ -8,10 +8,8 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/NumberParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -81,7 +79,6 @@ IFilter::PreflightResult ErodeDilateCoordinationNumberFilter::preflightImpl(cons const std::atomic_bool& shouldCancel) const { auto pCoordinationNumberValue = filterArgs.value(k_CoordinationNumber_Key); - auto pLoopValue = filterArgs.value(k_Loop_Key); auto pFeatureIdsArrayPathValue = filterArgs.value(k_CellFeatureIdsArrayPath_Key); auto pIgnoredDataArrayPathsValue = filterArgs.value(k_IgnoredDataArrayPaths_Key); @@ -90,10 +87,7 @@ IFilter::PreflightResult ErodeDilateCoordinationNumberFilter::preflightImpl(cons MakeErrorResult(-16800, fmt::format("Coordination Number must be between 0 and 6. Current Value: {}", pCoordinationNumberValue)); } - PreflightResult preflightResult; - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; // Return both the resultOutputActions and the preflightUpdatedValues via std::move() diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateMaskFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateMaskFilter.cpp index 1d20e0a55f..0d8d272a87 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateMaskFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ErodeDilateMaskFilter.cpp @@ -3,15 +3,12 @@ #include "SimplnxCore/Filters/Algorithms/ErodeDilateMask.hpp" #include "simplnx/DataStructure/DataPath.hpp" -#include "simplnx/Filter/Actions/EmptyAction.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/ChoicesParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/NumberParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -80,21 +77,7 @@ IFilter::UniquePointer ErodeDilateMaskFilter::clone() const IFilter::PreflightResult ErodeDilateMaskFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pOperationValue = filterArgs.value(k_Operation_Key); - auto pNumIterationsValue = filterArgs.value(k_NumIterations_Key); - auto pXDirOnValue = filterArgs.value(k_XDirOn_Key); - auto pYDirOnValue = filterArgs.value(k_YDirOn_Key); - auto pZDirOnValue = filterArgs.value(k_ZDirOn_Key); - auto pMaskArrayPathValue = filterArgs.value(k_MaskArrayPath_Key); - - PreflightResult preflightResult; - - nx::core::Result resultOutputActions; - - std::vector preflightUpdatedValues; - - // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExecuteProcessFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExecuteProcessFilter.cpp index bc2dbc000c..dd46486632 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExecuteProcessFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExecuteProcessFilter.cpp @@ -7,10 +7,8 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/StringParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -75,12 +73,6 @@ IFilter::PreflightResult ExecuteProcessFilter::preflightImpl(const DataStructure const std::atomic_bool& shouldCancel) const { auto pArgumentsValue = filterArgs.value(k_Arguments_Key); - auto pBlockingValue = filterArgs.value(k_Blocking_Key); - auto pTimeoutValue = filterArgs.value(k_Timeout_Key); - - PreflightResult preflightResult; - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; std::vector arguments = ExecuteProcess::splitArgumentsString(pArgumentsValue); if(arguments.empty()) @@ -88,7 +80,7 @@ IFilter::PreflightResult ExecuteProcessFilter::preflightImpl(const DataStructure return MakePreflightErrorResult(-4001, "No command line arguments have been specified."); } - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractComponentAsArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractComponentAsArrayFilter.cpp index 31d5268015..04ba703de7 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractComponentAsArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractComponentAsArrayFilter.cpp @@ -10,10 +10,8 @@ #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/NumberParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -90,7 +88,6 @@ IFilter::PreflightResult ExtractComponentAsArrayFilter::preflightImpl(const Data auto pSelectedArrayPathValue = filterArgs.value(k_SelectedArrayPath_Key); auto pNewArrayPathValue = pSelectedArrayPathValue.replaceName(filterArgs.value(k_NewArrayName_Key)); - PreflightResult preflightResult; nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; @@ -151,7 +148,7 @@ Result<> ExtractComponentAsArrayFilter::executeImpl(DataStructure& dataStructure inputValues.CompNumber = filterArgs.value(k_CompNumber_Key); // This is the original array if remove components is true OR move components is false inputValues.TempArrayPath = DataPath::FromString(filterArgs.value(k_SelectedArrayPath_Key).toString() + "Temp", '/').value(); - // This is the array on the original array path whether its removed or not + // This is the array on the original array path whether it's removed or not inputValues.BaseArrayPath = filterArgs.value(k_SelectedArrayPath_Key); // If move components to new array is true this is a valid path inputValues.NewArrayPath = inputValues.BaseArrayPath.replaceName(filterArgs.value(k_NewArrayName_Key)); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractInternalSurfacesFromTriangleGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractInternalSurfacesFromTriangleGeometryFilter.cpp index cd3739a6a1..e90f0ebca9 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractInternalSurfacesFromTriangleGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractInternalSurfacesFromTriangleGeometryFilter.cpp @@ -9,13 +9,11 @@ #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" #include #include - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include using namespace nx::core; @@ -38,15 +36,13 @@ void hashCombine(usize& seed, const T& obj) struct CopyDataFunctor { template - void operator()(IDataArray& inDataPtr, IDataArray& outDataPtr, std::unordered_map& elementMap) const + void operator()(IDataArray* inDataPtr, IDataArray* outDataPtr, std::unordered_map& elementMap) const { - auto& inputDataPtr = dynamic_cast&>(inDataPtr); - AbstractDataStore& inputData = inputDataPtr.getDataStoreRef(); - auto croppedDataPtr = dynamic_cast&>(outDataPtr); - AbstractDataStore& outputData = croppedDataPtr.getDataStoreRef(); + auto& inputData = inDataPtr->template getIDataStoreRefAs>(); + auto& outputData = outDataPtr->template getIDataStoreRefAs>(); - usize nTuples = outDataPtr.getNumberOfTuples(); - usize nComps = inDataPtr.getNumberOfComponents(); + usize nTuples = outDataPtr->getNumberOfTuples(); + usize nComps = inDataPtr->getNumberOfComponents(); usize tmpIndex = 0; usize ptrIndex = 0; @@ -66,10 +62,10 @@ struct RemoveFlaggedVerticesFunctor { // copy data to masked geometry template - void operator()(IDataArray& inputDataPtr, IDataArray& outputDataArray, const std::vector& indexMapping) const + void operator()(IDataArray* inputDataPtr, IDataArray* outputDataArray, const std::vector& indexMapping) const { - auto& inputData = dynamic_cast&>(inputDataPtr); - auto& outputData = dynamic_cast&>(outputDataArray); + auto& inputData = inputDataPtr->template getIDataStoreRefAs>(); + auto& outputData = outputDataArray->template getIDataStoreRefAs>(); usize nComps = inputData.getNumberOfComponents(); IGeometry::MeshIndexType notSeen = std::numeric_limits::max(); @@ -297,7 +293,7 @@ Result<> ExtractInternalSurfacesFromTriangleGeometryFilter::executeImpl(DataStru MeshIndexType currentNewTriIndex = 0; MeshIndexType currentNewVertIndex = 0; - // Loop over all of the triangles mapping the triangle and the vertices to the new array locations + // Loop over all the triangles mapping the triangle and the vertices to the new array locations for(MeshIndexType triIndex = 0; triIndex < numTris; triIndex++) { MeshIndexType v0Index = triangles[3 * triIndex + 0]; @@ -385,20 +381,20 @@ Result<> ExtractInternalSurfacesFromTriangleGeometryFilter::executeImpl(DataStru for(const auto& targetArrayPath : copyVertexPaths) { DataPath destinationPath = internalTrianglesPath.createChildPath(vertexDataName).createChildPath(targetArrayPath.getTargetName()); - auto& src = dataStructure.getDataRefAs(targetArrayPath); - auto& dest = dataStructure.getDataRefAs(destinationPath); + auto* src = dataStructure.getDataAs(targetArrayPath); + auto* dest = dataStructure.getDataAs(destinationPath); - ExecuteDataFunction(RemoveFlaggedVerticesFunctor{}, src.getDataType(), src, dest, vertNewIndex); + ExecuteDataFunction(RemoveFlaggedVerticesFunctor{}, src->getDataType(), src, dest, vertNewIndex); } for(const auto& targetArrayPath : copyTrianglePaths) { DataPath destinationPath = internalTrianglesPath.createChildPath(faceDataName).createChildPath(targetArrayPath.getTargetName()); - auto& src = dataStructure.getDataRefAs(targetArrayPath); - auto& dest = dataStructure.getDataRefAs(destinationPath); - dest.getIDataStore()->resizeTuples({currentNewTriIndex}); + auto* src = dataStructure.getDataAs(targetArrayPath); + auto* dest = dataStructure.getDataAs(destinationPath); + dest->resizeTuples({currentNewTriIndex}); - ExecuteDataFunction(RemoveFlaggedVerticesFunctor{}, src.getDataType(), src, dest, triNewIndex); + ExecuteDataFunction(RemoveFlaggedVerticesFunctor{}, src->getDataType(), src, dest, triNewIndex); } return {}; @@ -410,7 +406,6 @@ namespace SIMPL { constexpr StringLiteral k_TriangleDataContainerNameKey = "TriangleDataContainerName"; constexpr StringLiteral k_NodeTypesArrayPathKey = "NodeTypesArrayPath"; -constexpr StringLiteral k_InternalTrianglesNameKey = "InternalTrianglesName"; } // namespace SIMPL } // namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractPipelineToFileFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractPipelineToFileFilter.cpp index 5f6e4f488d..33a6eba36f 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractPipelineToFileFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractPipelineToFileFilter.cpp @@ -13,11 +13,6 @@ namespace fs = std::filesystem; -namespace -{ -constexpr nx::core::StringLiteral k_ImportedPipeline = "Imported Pipeline"; -} // namespace - namespace nx::core { //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractVertexGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractVertexGeometryFilter.cpp index 1eb7302a89..09238f6d1d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractVertexGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ExtractVertexGeometryFilter.cpp @@ -11,7 +11,6 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/ChoicesParameter.hpp" #include "simplnx/Parameters/DataGroupCreationParameter.hpp" -#include "simplnx/Parameters/DataGroupSelectionParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" @@ -19,10 +18,6 @@ using namespace nx::core; namespace { - -using FeatureIdsArrayType = Int32Array; -using GoodVoxelsArrayType = BoolArray; - constexpr int32 k_MissingGeomError = -72440; constexpr int32 k_IncorrectInputArray = -72441; constexpr int32 k_MissingInputArray = -72442; @@ -118,7 +113,7 @@ IFilter::PreflightResult ExtractVertexGeometryFilter::preflightImpl(const DataSt nx::core::Result resultOutputActions; - const IGridGeometry& geometry = dataStructure.getDataRefAs({pInputGeometryPathValue}); + const auto& geometry = dataStructure.getDataRefAs({pInputGeometryPathValue}); SizeVec3 dims = geometry.getDimensions(); usize geomElementCount = dims[0] * dims[1] * dims[2]; @@ -131,7 +126,7 @@ IFilter::PreflightResult ExtractVertexGeometryFilter::preflightImpl(const DataSt // Validate the GoodVoxels/Mask Array combination if(pUseGoodVoxelsValue) { - const nx::core::IDataArray* goodVoxelsArray = dataStructure.getDataAs(pMaskArrayPathValue); + const auto* goodVoxelsArray = dataStructure.getDataAs(pMaskArrayPathValue); if(nullptr == goodVoxelsArray) { return {nonstd::make_unexpected(std::vector{Error{k_MissingOrIncorrectGoodVoxelsArray, fmt::format("Mask array is not located at path: '{}'", pMaskArrayPathValue.toString())}})}; @@ -156,7 +151,7 @@ IFilter::PreflightResult ExtractVertexGeometryFilter::preflightImpl(const DataSt // as the output Vertex Geometry if(!dataPaths.empty()) { - const IDataArray& dataArray = dataStructure.getDataRefAs(dataPaths.front()); + const auto& dataArray = dataStructure.getDataRefAs(dataPaths.front()); if(dataArray.getNumberOfTuples() != geomElementCount) { return {MakeErrorResult(-2006, fmt::format("The selected DataArrays do not have the correct number of tuples. The Input Geometry ({}) has {} tuples but the " @@ -169,7 +164,7 @@ IFilter::PreflightResult ExtractVertexGeometryFilter::preflightImpl(const DataSt const DataPath vertexAttrMatrixPath = pVertexGeometryPathValue.createChildPath(pVertexAttrMatrixNameValue); for(const DataPath& dataPath : pIncludedDataArrayPathsValue) { - const IDataArray& dataArray = dataStructure.getDataRefAs(dataPath); + const auto& dataArray = dataStructure.getDataRefAs(dataPath); if(pArrayHandlingValue == to_underlying(ArrayHandlingType::Copy)) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FeatureFaceCurvatureFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FeatureFaceCurvatureFilter.cpp index c6329b0d4e..61bd2fcd4e 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FeatureFaceCurvatureFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FeatureFaceCurvatureFilter.cpp @@ -117,7 +117,6 @@ IFilter::PreflightResult FeatureFaceCurvatureFilter::preflightImpl(const DataStr auto surfaceMeshFaceNormalsPath = filterArgs.value(k_FaceNormalsPath_Key); auto surfaceMeshTriangleCentroidsPath = filterArgs.value(k_FaceCentroidsPath_Key); - auto computePrincipalCurvature = filterArgs.value(k_ComputePrincipalDirection_Key); auto computePrincipalDirection = filterArgs.value(k_ComputePrincipalDirection_Key); auto computeGaussianCurvature = filterArgs.value(k_ComputeGaussianCurvature_Key); auto computeMeanCurvature = filterArgs.value(k_ComputeMeanCurvaturePath_Key); @@ -133,9 +132,9 @@ IFilter::PreflightResult FeatureFaceCurvatureFilter::preflightImpl(const DataStr std::vector dataArrays; - const TriangleGeom* triangles = dataStructure.getDataAs(triangleGeomPath); + const auto* triangles = dataStructure.getDataAs(triangleGeomPath); const DataPath triangleMatrixPath = triangles->getFaceAttributeMatrixDataPath(); - const AttributeMatrix* triangleMatrix = dataStructure.getDataAs(triangleMatrixPath); + const auto* triangleMatrix = dataStructure.getDataAs(triangleMatrixPath); { dataArrays.push_back(surfaceMeshPrincipalCurvature1Path); @@ -203,7 +202,6 @@ IFilter::PreflightResult FeatureFaceCurvatureFilter::preflightImpl(const DataStr Result<> FeatureFaceCurvatureFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - FeatureFaceCurvatureInputValues inputValues; inputValues.NRingCount = filterArgs.value(k_NeighborhoodRing_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FillBadDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FillBadDataFilter.cpp index 0f750d41b2..5bcb39540c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FillBadDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FillBadDataFilter.cpp @@ -9,10 +9,8 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/NumberParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -61,7 +59,6 @@ Parameters FillBadDataFilter::parameters() const params.insertSeparator(Parameters::Separator{"Input Data Objects"}); params.insert(std::make_unique(k_SelectedImageGeometryPath_Key, "Selected Image Geometry", "The target geometry", DataPath{}, GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Image})); - // params.insert(std::make_unique(k_SelectedCellDataGroup_Key, "Cell Data Attribute Matrix", "Cell data Attribute Matrix", DataPath{})); params.insert(std::make_unique(k_CellFeatureIdsArrayPath_Key, "Cell Feature Ids", "Specifies to which Feature each Element belongs", DataPath({"Cell Data", "FeatureIds"}), ArraySelectionParameter::AllowedTypes{DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{1}})); @@ -88,11 +85,8 @@ IFilter::PreflightResult FillBadDataFilter::preflightImpl(const DataStructure& d const std::atomic_bool& shouldCancel) const { auto pMinAllowedDefectSizeValue = filterArgs.value(k_MinAllowedDefectSize_Key); - // auto cellDataGroupPath = filterArgs.value(k_SelectedCellDataGroup_Key); auto cellPhasesArrayPath = filterArgs.value(k_CellPhasesArrayPath_Key); - PreflightResult preflightResult; - if(pMinAllowedDefectSizeValue < 1) { MakeErrorResult(-16500, fmt::format("Minimum Allowed Defect Size must be at least 1. Value given was {}", pMinAllowedDefectSizeValue)); @@ -112,7 +106,7 @@ IFilter::PreflightResult FillBadDataFilter::preflightImpl(const DataStructure& d const auto* cellPhases = dataStructure.getDataAs(cellPhasesArrayPath); if(storeAsNewPhase && nullptr == cellPhases) { - return {nonstd::make_unexpected(std::vector{Error{-12801, "Cell Phases Data Array is not of the correct type or was not found at the given path"}})}; + return MakePreflightErrorResult(-12801, "Cell Phases Data Array is not of the correct type or was not found at the given path"); } return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FlyingEdges3DFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FlyingEdges3DFilter.cpp index 04fc38157e..178343e095 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FlyingEdges3DFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/FlyingEdges3DFilter.cpp @@ -85,7 +85,6 @@ IFilter::PreflightResult FlyingEdges3DFilter::preflightImpl(const DataStructure& auto pImageGeomPath = filterArgs.value(k_SelectedImageGeometryPath_Key); auto pTriangleGeomName = filterArgs.value(k_CreatedTriangleGeometryPath_Key); - PreflightResult preflightResult; nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/IdentifySampleFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/IdentifySampleFilter.cpp index 32d1c605e7..a3d0190df5 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/IdentifySampleFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/IdentifySampleFilter.cpp @@ -5,29 +5,20 @@ #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" namespace nx::core { namespace { -constexpr int64 k_MISSING_GEOM_ERR = -650; - struct IdentifySampleFunctor { template - void operator()(DataStructure& dataStructure, const DataPath& imageGeomPath, const DataPath& goodVoxelsArrayPath, bool fillHoles) + void operator()(const ImageGeom* imageGeom, IDataArray* goodVoxelsPtr, bool fillHoles) { - using ArrayType = DataArray; - - const auto* imageGeom = dataStructure.getDataAs(imageGeomPath); - std::vector cDims = {1}; - auto* goodVoxelsPtr = dataStructure.getDataAs(goodVoxelsArrayPath); - auto& goodVoxels = goodVoxelsPtr->getDataStoreRef(); + auto& goodVoxels = goodVoxelsPtr->template getIDataStoreRefAs>(); const auto totalPoints = static_cast(goodVoxelsPtr->getNumberOfTuples()); @@ -143,8 +134,8 @@ struct IdentifySampleFunctor sample.clear(); checked.assign(totalPoints, false); - // In this loop we are going to 'close' all of the 'holes' inside of the region already identified as the 'sample' if the user chose to do so. - // This is done by flipping all 'bad' voxel features that do not touch the outside of the sample (i.e. they are fully contained inside of the 'sample'. + // In this loop we are going to 'close' all the 'holes' inside the region already identified as the 'sample' if the user chose to do so. + // This is done by flipping all 'bad' voxel features that do not touch the outside of the sample (i.e. they are fully contained inside the 'sample'). threshold = 0.0F; if(fillHoles) { @@ -306,10 +297,10 @@ Result<> IdentifySampleFilter::executeImpl(DataStructure& dataStructure, const A const auto imageGeomPath = args.value(k_SelectedImageGeometryPath_Key); const auto goodVoxelsArrayPath = args.value(k_MaskArrayPath_Key); - const auto& inputData = dataStructure.getDataRefAs(goodVoxelsArrayPath); - const DataType arrayType = inputData.getDataType(); + auto* inputData = dataStructure.getDataAs(goodVoxelsArrayPath); + const auto* imageGeom = dataStructure.getDataAs(imageGeomPath); - ExecuteDataFunction(IdentifySampleFunctor{}, arrayType, dataStructure, imageGeomPath, goodVoxelsArrayPath, fillHoles); + ExecuteDataFunction(IdentifySampleFunctor{}, inputData->getDataType(), imageGeom, inputData, fillHoles); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp index 872bce3c80..c7867427a1 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeDataFilter.cpp @@ -66,9 +66,9 @@ using AdditionT = IncrementalOptions; using SubtractionT = IncrementalOptions; template -void ValueFill(DataArray& dataArray, const std::vector& stringValues) +void ValueFill(AbstractDataStore& dataStore, const std::vector& stringValues) { - usize numComp = dataArray.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free + usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free if(numComp > 1) { @@ -79,13 +79,13 @@ void ValueFill(DataArray& dataArray, const std::vector& stringVa values.emplace_back(ConvertTo::convert(str).value()); } - usize numTup = dataArray.getNumberOfTuples(); + usize numTup = dataStore.getNumberOfTuples(); for(usize tup = 0; tup < numTup; tup++) { for(usize comp = 0; comp < numComp; comp++) { - dataArray[tup * numComp + comp] = values[comp]; + dataStore[tup * numComp + comp] = values[comp]; } } } @@ -93,14 +93,14 @@ void ValueFill(DataArray& dataArray, const std::vector& stringVa { Result result = ConvertTo::convert(stringValues[0]); T value = result.value(); - dataArray.fill(value); + dataStore.fill(value); } } template -void IncrementalFill(DataArray& dataArray, const std::vector& startValues, const std::vector& stepValues) +void IncrementalFill(AbstractDataStore& dataStore, const std::vector& startValues, const std::vector& stepValues) { - usize numComp = dataArray.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free + usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free std::vector values(numComp); std::vector steps(numComp); @@ -116,13 +116,13 @@ void IncrementalFill(DataArray& dataArray, const std::vector& st } } - usize numTup = dataArray.getNumberOfTuples(); + usize numTup = dataStore.getNumberOfTuples(); if constexpr(std::is_same_v) { for(usize comp = 0; comp < numComp; comp++) { - dataArray[comp] = values[comp]; + dataStore[comp] = values[comp]; if constexpr(IncrementalOptions::UsingAddition) { @@ -138,7 +138,7 @@ void IncrementalFill(DataArray& dataArray, const std::vector& st { for(usize comp = 0; comp < numComp; comp++) { - dataArray[tup * numComp + comp] = values[comp]; + dataStore[tup * numComp + comp] = values[comp]; } } } @@ -149,7 +149,7 @@ void IncrementalFill(DataArray& dataArray, const std::vector& st { for(usize comp = 0; comp < numComp; comp++) { - dataArray[tup * numComp + comp] = values[comp]; + dataStore[tup * numComp + comp] = values[comp]; if constexpr(IncrementalOptions::UsingAddition) { @@ -165,9 +165,9 @@ void IncrementalFill(DataArray& dataArray, const std::vector& st } template -void RandomFill(std::vector& dist, DataArray& dataArray, const uint64 seed, const bool standardizeSeed) +void RandomFill(std::vector& dist, AbstractDataStore& dataStore, const uint64 seed, const bool standardizeSeed) { - usize numComp = dataArray.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free + usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free std::vector generators(numComp, std::mt19937_64{}); @@ -176,7 +176,7 @@ void RandomFill(std::vector& dist, DataArray& dataArray, const generators[comp].seed((standardizeSeed ? seed : seed + comp)); // If standardizing seed all generators use the same else, use modified seeds } - usize numTup = dataArray.getNumberOfTuples(); + usize numTup = dataStore.getNumberOfTuples(); for(usize tup = 0; tup < numTup; tup++) { @@ -186,23 +186,23 @@ void RandomFill(std::vector& dist, DataArray& dataArray, const { if constexpr(Ranged) { - dataArray[tup * numComp + comp] = static_cast(dist[comp](generators[comp])); + dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp])); } if constexpr(!Ranged) { if constexpr(std::is_signed_v) { - dataArray[tup * numComp + comp] = static_cast(dist[comp](generators[comp]) * (std::numeric_limits::max() - 1) * (((rand() & 1) == 0) ? 1 : -1)); + dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp]) * (std::numeric_limits::max() - 1) * (((rand() & 1) == 0) ? 1 : -1)); } if constexpr(!std::is_signed_v) { - dataArray[tup * numComp + comp] = static_cast(dist[comp](generators[comp]) * std::numeric_limits::max()); + dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp]) * std::numeric_limits::max()); } } } if constexpr(!std::is_floating_point_v) { - dataArray[tup * numComp + comp] = static_cast(dist[comp](generators[comp])); + dataStore[tup * numComp + comp] = static_cast(dist[comp](generators[comp])); } } } @@ -292,16 +292,16 @@ struct FillArrayFunctor template void operator()(IDataArray& iDataArray, const InitializeDataInputValues& inputValues) { - auto& dataArray = dynamic_cast&>(iDataArray); - usize numComp = dataArray.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free + auto& dataStore = iDataArray.template getIDataStoreRefAs>(); + usize numComp = dataStore.getNumberOfComponents(); // We checked that the values string is greater than max comps size so proceed check free switch(inputValues.initType) { case InitializeType::FillValue: { - return ::ValueFill(dataArray, standardizeMultiComponent(numComp, inputValues.stringValues)); + return ::ValueFill(dataStore, standardizeMultiComponent(numComp, inputValues.stringValues)); } case InitializeType::Incremental: { - return ::FillIncForwarder(inputValues.stepType, dataArray, standardizeMultiComponent(numComp, inputValues.startValues), standardizeMultiComponent(numComp, inputValues.stepValues)); + return ::FillIncForwarder(inputValues.stepType, dataStore, standardizeMultiComponent(numComp, inputValues.startValues), standardizeMultiComponent(numComp, inputValues.stepValues)); } case InitializeType::Random: { std::vector range; @@ -321,7 +321,7 @@ struct FillArrayFunctor range.push_back(true); } } - return ::FillRandomForwarder(range, numComp, dataArray, inputValues.seed, inputValues.standardizeSeed); + return ::FillRandomForwarder(range, numComp, dataStore, inputValues.seed, inputValues.standardizeSeed); } case InitializeType::RangedRandom: { auto randBegin = standardizeMultiComponent(numComp, inputValues.randBegin); @@ -335,7 +335,7 @@ struct FillArrayFunctor result = ConvertTo::convert(randEnd[comp]); range.push_back(result.value()); } - return ::FillRandomForwarder(range, numComp, dataArray, inputValues.seed, inputValues.standardizeSeed); + return ::FillRandomForwarder(range, numComp, dataStore, inputValues.seed, inputValues.standardizeSeed); } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeImageGeomCellDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeImageGeomCellDataFilter.cpp index 3701f46401..4704026470 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeImageGeomCellDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InitializeImageGeomCellDataFilter.cpp @@ -50,10 +50,8 @@ InitializeImageGeomCellDataFilter::InitType ConvertIndexToInitType(uint64 index) struct CheckInitializationFunctor { template - std::optional operator()(const IDataArray& dataArray, InitializeImageGeomCellDataFilter::InitType initType, float64 initValue, const std::pair& initRange) + std::optional operator()(const std::string& arrayName, InitializeImageGeomCellDataFilter::InitType initType, float64 initValue, const std::pair& initRange) { - std::string arrayName = dataArray.getName(); - if(initType == InitializeImageGeomCellDataFilter::InitType::Manual) { if(initValue < static_cast(std::numeric_limits().lowest()) || initValue > static_cast(std::numeric_limits().max())) @@ -121,7 +119,7 @@ struct InitializeArrayFunctor rangeMax = std::numeric_limits().max(); } - auto& dataStore = dataArray.getIDataStoreRefAs>(); + auto& dataStore = dataArray.template getIDataStoreRefAs>(); auto&& [distribution, generator] = CreateRandomGenerator(rangeMin, rangeMax, seed); @@ -298,7 +296,7 @@ IFilter::PreflightResult InitializeImageGeomCellDataFilter::preflightImpl(const continue; } - std::optional maybeError = ExecuteNeighborFunction(CheckInitializationFunctor{}, dataArray.getDataType(), dataArray, initType, initValue, initRange); // NO BOOL + std::optional maybeError = ExecuteNeighborFunction(CheckInitializationFunctor{}, dataArray.getDataType(), dataArray.getName(), initType, initValue, initRange); // NO BOOL if(maybeError.has_value()) { errors.push_back(std::move(*maybeError)); @@ -352,7 +350,7 @@ Result<> InitializeImageGeomCellDataFilter::executeImpl(DataStructure& dataStruc InitType initType = ConvertIndexToInitType(initTypeIndex); RangeType initRange = {initRangeVec.at(0), initRangeVec.at(1)}; - const ImageGeom& imageGeom = dataStructure.getDataRefAs(imageGeomPath); + const auto& imageGeom = dataStructure.getDataRefAs(imageGeomPath); std::array dims = imageGeom.getDimensions().toArray(); @@ -383,7 +381,6 @@ constexpr StringLiteral k_ZMaxKey = "ZMax"; constexpr StringLiteral k_InitTypeKey = "InitType"; constexpr StringLiteral k_InitValueKey = "InitValue"; constexpr StringLiteral k_InitRangeKey = "InitRange"; -constexpr StringLiteral k_InvertDataKey = "InvertData"; } // namespace SIMPL } // namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InterpolatePointCloudToRegularGridFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InterpolatePointCloudToRegularGridFilter.cpp index 595f26c115..e01d00b559 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InterpolatePointCloudToRegularGridFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/InterpolatePointCloudToRegularGridFilter.cpp @@ -30,8 +30,7 @@ struct MapPointCloudDataByKernelFunctor template void operator()(IDataArray* source, INeighborList* dynamic, std::vector& kernelVals, const int64 kernel[3], const usize dims[3], usize curX, usize curY, usize curZ, usize vertIdx) { - auto* inputDataArray = dynamic_cast*>(source); - auto& inputData = inputDataArray->getDataStoreRef(); + auto& inputData = source->template getIDataStoreRefAs>(); auto* interpolatedDataPtr = dynamic_cast*>(dynamic); usize index = 0; @@ -90,7 +89,7 @@ void determineKernel(uint64 interpolationTechnique, const FloatVec3& sigmas, std } } -void determineKernelDistances(std::vector& kernelValDistances, int64 kernelNumVoxels[3], FloatVec3 res) +void determineKernelDistances(std::vector& kernelValDistances, const int64 kernelNumVoxels[3], FloatVec3 res) { usize counter = 0; @@ -108,10 +107,10 @@ void determineKernelDistances(std::vector& kernelValDistances, int64 ke } } -void mapKernelDistances(NeighborList* kernelDistances, std::vector& kernelValDistances, std::vector& kernel, int64 kernelNumVoxels[3], usize dims[3], usize curX, usize curY, - usize curZ) +void mapKernelDistances(NeighborList* kernelDistances, std::vector& kernelValDistances, std::vector& kernel, const int64 kernelNumVoxels[3], const usize dims[3], usize curX, + usize curY, usize curZ) { - usize index = 0; + usize index; int64 startKernel[3] = {0, 0, 0}; int64 endKernel[3] = {0, 0, 0}; usize counter = 0; @@ -375,7 +374,7 @@ Result<> InterpolatePointCloudToRegularGridFilter::executeImpl(DataStructure& da auto& voxelIndices = dataStructure.getDataRefAs(voxelIndicesPath); - // Make sure the NeighborList's outer most vector is resized to the number of tuples and initialized to non null values (empty vectors) + // Make sure the NeighborList's outermost vector is resized to the number of tuples and initialized to non-null values (empty vectors) for(const auto& interpolatedDataPath : interpolatedDataPaths) { InitializeNeighborList(dataStructure, interpolatedGroupPath.createChildPath(interpolatedDataPath.getTargetName())); @@ -405,14 +404,12 @@ Result<> InterpolatePointCloudToRegularGridFilter::executeImpl(DataStructure& da } int64 tmpKernelSize[3] = {1, 1, 1}; - int64 totalKernel = 0; - for(usize i = 0; i < 3; i++) { tmpKernelSize[i] *= (kernelNumVoxels[i] * 2) + 1; } - totalKernel = tmpKernelSize[0] * tmpKernelSize[1] * tmpKernelSize[2]; + int64 totalKernel = tmpKernelSize[0] * tmpKernelSize[1] * tmpKernelSize[2]; kernel.resize(totalKernel); std::fill(kernel.begin(), kernel.end(), 0.0f); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/IterativeClosestPointFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/IterativeClosestPointFilter.cpp index b439fb7403..6cb6467d94 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/IterativeClosestPointFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/IterativeClosestPointFilter.cpp @@ -9,7 +9,6 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataPathSelectionParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -28,7 +27,7 @@ template struct VertexGeomAdaptor { const Derived& obj; - Float32Array* verts; + AbstractDataStore* verts; size_t m_NumComponents = 0; size_t m_NumTuples = 0; @@ -36,25 +35,25 @@ struct VertexGeomAdaptor : obj(obj_) { // These values never change for the lifetime of this object so cache them now. - verts = derived()->getVertices(); + verts = derived()->getVertices()->getDataStore(); m_NumComponents = verts->getNumberOfComponents(); m_NumTuples = verts->getNumberOfTuples(); } - const Derived& derived() const + [[nodiscard]] const Derived& derived() const { return obj; } - usize kdtree_get_point_count() const + [[nodiscard]] usize kdtree_get_point_count() const { return m_NumTuples; } - float kdtree_get_pt(const usize idx, const usize dim) const + [[nodiscard]] float kdtree_get_pt(const usize idx, const usize dim) const { auto offset = idx * m_NumComponents; - return (*verts)[offset + dim]; + return verts->getValue(offset + dim); } template @@ -169,40 +168,34 @@ Result<> IterativeClosestPointFilter::executeImpl(DataStructure& dataStructure, if(movingVertexGeom == nullptr) { - auto ss = fmt::format("Moving Vertex Geometry not found at path '{}'", movingVertexPath.toString()); - return {nonstd::make_unexpected(std::vector{Error{k_MissingVertices, ss}})}; + return MakeErrorResult(k_MissingVertices, fmt::format("Moving Vertex Geometry not found at path '{}'", movingVertexPath.toString())); } if(targetVertexGeom == nullptr) { - auto ss = fmt::format("Target Vertex Geometry not found at path '{}'", targetVertexPath.toString()); - return {nonstd::make_unexpected(std::vector{Error{k_MissingVertices, ss}})}; + return MakeErrorResult(k_MissingVertices, fmt::format("Target Vertex Geometry not found at path '{}'", targetVertexPath.toString())); } if(movingVertexGeom->getVertices() == nullptr) { - auto ss = fmt::format("Moving Vertex Geometry does not contain a vertex array"); - return {nonstd::make_unexpected(std::vector{Error{k_MissingVertices, ss}})}; + return MakeErrorResult(k_MissingVertices, fmt::format("Moving Vertex Geometry does not contain a vertex array")); } if(targetVertexGeom->getVertices() == nullptr) { - auto ss = fmt::format("Target Vertex Geometry does not contain a vertex array"); - return {nonstd::make_unexpected(std::vector{Error{k_MissingVertices, ss}})}; + return MakeErrorResult(k_MissingVertices, fmt::format("Target Vertex Geometry does not contain a vertex array")); } - Float32Array& movingVerticesRef = *(movingVertexGeom->getVertices()); - if(movingVerticesRef.empty()) + Float32AbstractDataStore& movingStore = movingVertexGeom->getVertices()->getDataStoreRef(); + if(movingStore.getNumberOfTuples() == 0) { - auto ss = fmt::format("Moving Vertex Geometry does not contain any vertices"); - return {nonstd::make_unexpected(std::vector{Error{k_EmptyVertices, ss}})}; + return MakeErrorResult(k_EmptyVertices, fmt::format("Moving Vertex Geometry does not contain any vertices")); } - Float32Array& targetVerticesRef = *(targetVertexGeom->getVertices()); - if(targetVerticesRef.empty()) + Float32AbstractDataStore& targetStore = targetVertexGeom->getVertices()->getDataStoreRef(); + if(targetStore.getNumberOfTuples() == 0) { - auto ss = fmt::format("Target Vertex Geometry does not contain any vertices"); - return {nonstd::make_unexpected(std::vector{Error{k_EmptyVertices, ss}})}; + return MakeErrorResult(k_EmptyVertices, fmt::format("Target Vertex Geometry does not contain any vertices")); } - auto* movingStore = movingVerticesRef.getDataStore(); - std::vector movingVector(movingStore->begin(), movingStore->end()); + + std::vector movingVector(movingStore.begin(), movingStore.end()); float32* movingCopyPtr = movingVector.data(); DataStructure tmp; @@ -247,9 +240,9 @@ Result<> IterativeClosestPointFilter::executeImpl(DataStructure& dataStructure, nanoflann::KNNResultSet results(nn); results.init(&identifier, &dist); index.findNeighbors(results, movingCopyPtr + (3 * j), nanoflann::SearchParams()); - dynTargetPtr[3 * j + 0] = targetVerticesRef[3 * identifier + 0]; - dynTargetPtr[3 * j + 1] = targetVerticesRef[3 * identifier + 1]; - dynTargetPtr[3 * j + 2] = targetVerticesRef[3 * identifier + 2]; + dynTargetPtr[3 * j + 0] = targetStore[3 * identifier + 0]; + dynTargetPtr[3 * j + 1] = targetStore[3 * identifier + 1]; + dynTargetPtr[3 * j + 2] = targetStore[3 * identifier + 2]; } Eigen::Map moving_(movingCopyPtr, 3, numMovingVerts); @@ -276,17 +269,17 @@ Result<> IterativeClosestPointFilter::executeImpl(DataStructure& dataStructure, counter++; } - auto* transformPtr = dataStructure.getDataAs(transformArrayPath)->getDataStore(); + auto& transformStore = dataStructure.getDataAs(transformArrayPath)->getDataStoreRef(); if(applyTransformation) { for(usize j = 0; j < numMovingVerts; j++) { - Eigen::Vector4f position(movingVerticesRef[3 * j + 0], movingVerticesRef[3 * j + 1], movingVerticesRef[3 * j + 2], 1); + Eigen::Vector4f position(movingStore[3 * j + 0], movingStore[3 * j + 1], movingStore[3 * j + 2], 1); Eigen::Vector4f transformedPosition = globalTransform * position; for(usize k = 0; k < 3; k++) { - movingVerticesRef[3 * j + k] = transformedPosition.data()[k]; + movingStore[3 * j + k] = transformedPosition.data()[k]; } } } @@ -294,7 +287,7 @@ Result<> IterativeClosestPointFilter::executeImpl(DataStructure& dataStructure, globalTransform.transposeInPlace(); for(usize j = 0; j < 16; j++) { - (*transformPtr)[j] = globalTransform.data()[j]; + transformStore[j] = globalTransform.data()[j]; } return {}; @@ -308,7 +301,6 @@ constexpr StringLiteral k_MovingVertexGeometryKey = "MovingVertexGeometry"; constexpr StringLiteral k_TargetVertexGeometryKey = "TargetVertexGeometry"; constexpr StringLiteral k_IterationsKey = "Iterations"; constexpr StringLiteral k_ApplyTransformKey = "ApplyTransform"; -constexpr StringLiteral k_TransformAttributeMatrixNameKey = "TransformAttributeMatrixName"; constexpr StringLiteral k_TransformArrayNameKey = "TransformArrayName"; } // namespace SIMPL } // namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/LaplacianSmoothingFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/LaplacianSmoothingFilter.cpp index 38312a3e78..5c08f5e698 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/LaplacianSmoothingFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/LaplacianSmoothingFilter.cpp @@ -7,10 +7,8 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataPathSelectionParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/NumberParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -92,28 +90,7 @@ IFilter::UniquePointer LaplacianSmoothingFilter::clone() const IFilter::PreflightResult LaplacianSmoothingFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - /** - * These are the values that were gathered from the UI or the pipeline file or - * otherwise passed into the filter. These are here for your convenience. If you - * do not need some of them remove them. - */ - auto pIterationStepsValue = filterArgs.value(k_IterationSteps_Key); - auto pLambdaValue = filterArgs.value(k_Lambda_Key); - auto pUseTaubinSmoothingValue = filterArgs.value(k_UseTaubinSmoothing_Key); - auto pMuFactorValue = filterArgs.value(k_MuFactor_Key); - auto pTripleLineLambdaValue = filterArgs.value(k_TripleLineLambda_Key); - auto pQuadPointLambdaValue = filterArgs.value(k_QuadPointLambda_Key); - auto pSurfacePointLambdaValue = filterArgs.value(k_SurfacePointLambda_Key); - auto pSurfaceTripleLineLambdaValue = filterArgs.value(k_SurfaceTripleLineLambda_Key); - auto pSurfaceQuadPointLambdaValue = filterArgs.value(k_SurfaceQuadPointLambda_Key); - auto pSurfaceMeshNodeTypeArrayPathValue = filterArgs.value(k_SurfaceMeshNodeTypeArrayPath_Key); - - nx::core::Result resultOutputActions; - - std::vector preflightUpdatedValues; - - // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MapPointCloudToRegularGridFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MapPointCloudToRegularGridFilter.cpp index abdd3a422f..e6c27afff4 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MapPointCloudToRegularGridFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MapPointCloudToRegularGridFilter.cpp @@ -12,7 +12,6 @@ #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/VectorParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -21,31 +20,36 @@ namespace nx::core { namespace { -constexpr int64 k_MissingVertexGeom = -2600; constexpr int64 k_BadGridDimensions = -2601; constexpr int64 k_InvalidVertexGeometry = -2602; constexpr int64 k_IncompatibleMaskVoxelArrays = -2603; +constexpr int64 k_MaskSelectedArrayInvalid = -2604; -void createRegularGrid(DataStructure& dataStructure, const Arguments& args) +Result<> CreateRegularGrid(DataStructure& dataStructure, const Arguments& args) { const auto samplingGridType = args.value(MapPointCloudToRegularGridFilter::k_SamplingGridType_Key); - const auto vertexGeomPath = args.value(MapPointCloudToRegularGridFilter::k_SelectedVertexGeometryPath_Key); - const auto newImageGeomPath = args.value(MapPointCloudToRegularGridFilter::k_CreatedImageGeometryPath_Key); - const auto useMask = args.value(MapPointCloudToRegularGridFilter::k_UseMask_Key); - const auto maskArrayPath = args.value(MapPointCloudToRegularGridFilter::k_InputMaskPath_Key); if(samplingGridType == 1) { - return; + return {}; } + const auto vertexGeomPath = args.value(MapPointCloudToRegularGridFilter::k_SelectedVertexGeometryPath_Key); + const auto newImageGeomPath = args.value(MapPointCloudToRegularGridFilter::k_CreatedImageGeometryPath_Key); + const auto useMask = args.value(MapPointCloudToRegularGridFilter::k_UseMask_Key); + const auto maskArrayPath = args.value(MapPointCloudToRegularGridFilter::k_InputMaskPath_Key); + const auto* pointCloud = dataStructure.getDataAs(vertexGeomPath); auto* image = dataStructure.getDataAs(newImageGeomPath); - int64 numVerts = pointCloud->getNumberOfVertices(); - auto* vertex = pointCloud->getVertices(); + usize numVerts = pointCloud->getNumberOfVertices(); + auto& vertex = pointCloud->getVertices()->getDataStoreRef(); - const auto* mask = dataStructure.getDataAs(maskArrayPath); + const auto* mask = useMask ? dataStructure.getDataAs(maskArrayPath)->getDataStore() : nullptr; + if(useMask && mask == nullptr) + { + return MakeErrorResult(k_MaskSelectedArrayInvalid, "Use Mask was selected but mask array doesn't exist."); + } // Find the largest/smallest (x,y,z) dimensions of the incoming data to be used to define the maximum dimensions for the regular grid std::vector meshMaxExtents; @@ -58,31 +62,31 @@ void createRegularGrid(DataStructure& dataStructure, const Arguments& args) for(int64_t i = 0; i < numVerts; i++) { - if(!useMask || (useMask && (*mask)[i])) + if(!useMask || mask->getValue(i)) { - if((*vertex)[3 * i] > meshMaxExtents[0]) + if(vertex[3 * i] > meshMaxExtents[0]) { - meshMaxExtents[0] = (*vertex)[3 * i]; + meshMaxExtents[0] = vertex[3 * i]; } - if((*vertex)[3 * i + 1] > meshMaxExtents[1]) + if(vertex[3 * i + 1] > meshMaxExtents[1]) { - meshMaxExtents[1] = (*vertex)[3 * i + 1]; + meshMaxExtents[1] = vertex[3 * i + 1]; } - if((*vertex)[3 * i + 2] > meshMaxExtents[2]) + if(vertex[3 * i + 2] > meshMaxExtents[2]) { - meshMaxExtents[2] = (*vertex)[3 * i + 2]; + meshMaxExtents[2] = vertex[3 * i + 2]; } - if((*vertex)[3 * i] < meshMinExtents[0]) + if(vertex[3 * i] < meshMinExtents[0]) { - meshMinExtents[0] = (*vertex)[3 * i]; + meshMinExtents[0] = vertex[3 * i]; } - if((*vertex)[3 * i + 1] < meshMinExtents[1]) + if(vertex[3 * i + 1] < meshMinExtents[1]) { - meshMinExtents[1] = (*vertex)[3 * i + 1]; + meshMinExtents[1] = vertex[3 * i + 1]; } - if((*vertex)[3 * i + 2] < meshMinExtents[2]) + if(vertex[3 * i + 2] < meshMinExtents[2]) { - meshMinExtents[2] = (*vertex)[3 * i + 2]; + meshMinExtents[2] = vertex[3 * i + 2]; } } } @@ -180,6 +184,8 @@ void createRegularGrid(DataStructure& dataStructure, const Arguments& args) image->setSpacing(iRes[0], iRes[1], iRes[2]); image->setOrigin(iOrigin[0], iOrigin[1], iOrigin[2]); image->getCellData()->resizeTuples({iDims[2], iDims[1], iDims[0]}); + + return {}; } } // namespace @@ -329,7 +335,11 @@ Result<> MapPointCloudToRegularGridFilter::executeImpl(DataStructure& dataStruct { // Create the regular grid messageHandler("Creating Regular Grid"); - createRegularGrid(dataStructure, args); + auto result = CreateRegularGrid(dataStructure, args); + if(result.invalid()) + { + return result; + } image = dataStructure.getDataAs(args.value(k_CreatedImageGeometryPath_Key)); } else if(samplingGridType == 1) @@ -339,10 +349,14 @@ Result<> MapPointCloudToRegularGridFilter::executeImpl(DataStructure& dataStruct const auto& vertices = dataStructure.getDataRefAs(vertexGeomPath); const DataPath voxelIndicesPath = vertexGeomPath.createChildPath(vertices.getVertexAttributeMatrix()->getName()).createChildPath(voxelIndicesName); - auto& voxelIndices = dataStructure.getDataRefAs(voxelIndicesPath); - const auto* mask = dataStructure.getDataAs(maskArrayPath); + auto& voxelIndices = dataStructure.getDataAs(voxelIndicesPath)->getDataStoreRef(); + const auto* mask = useMask ? dataStructure.getDataAs(maskArrayPath)->getDataStore() : nullptr; + if(useMask && mask == nullptr) + { + return MakeErrorResult(k_MaskSelectedArrayInvalid, "Use Mask was selected but mask array doesn't exist."); + } - int64 numVerts = vertices.getNumberOfVertices(); + usize numVerts = vertices.getNumberOfVertices(); SizeVec3 dims = image->getDimensions(); FloatVec3 res = image->getSpacing(); FloatVec3 origin = image->getOrigin(); @@ -353,7 +367,7 @@ Result<> MapPointCloudToRegularGridFilter::executeImpl(DataStructure& dataStruct for(int64 i = 0; i < numVerts; i++) { - if(!useMask || (useMask && (*mask)[i])) + if(!useMask || mask->getValue(i)) { auto coords = vertices.getVertexCoordinate(i); const auto indexResult = image->getIndex(coords[0], coords[1], coords[2]); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MoveDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MoveDataFilter.cpp index 4762ceca83..e2f55e68f3 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MoveDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MoveDataFilter.cpp @@ -4,10 +4,8 @@ #include "simplnx/DataStructure/BaseGroup.hpp" #include "simplnx/Filter/Actions/MoveDataAction.hpp" #include "simplnx/Parameters/DataGroupSelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/MultiPathSelectionParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" namespace nx::core { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MultiThresholdObjectsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MultiThresholdObjectsFilter.cpp index b4cf48507b..1cc704a041 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MultiThresholdObjectsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/MultiThresholdObjectsFilter.cpp @@ -10,7 +10,6 @@ #include "simplnx/Parameters/NumberParameter.hpp" #include "simplnx/Utilities/ArrayThreshold.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -36,7 +35,7 @@ class ThresholdFilterHelper * @brief */ template - void filterDataLessThan(const DataArray& m_Input, T trueValue, T falseValue) + void filterDataLessThan(const AbstractDataStore& m_Input, T trueValue, T falseValue) { size_t m_NumValues = m_Input.getNumberOfTuples(); T value = static_cast(m_ComparisonValue); @@ -50,7 +49,7 @@ class ThresholdFilterHelper * @brief */ template - void filterDataGreaterThan(const DataArray& m_Input, T trueValue, T falseValue) + void filterDataGreaterThan(const AbstractDataStore& m_Input, T trueValue, T falseValue) { size_t m_NumValues = m_Input.getNumberOfTuples(); T value = static_cast(m_ComparisonValue); @@ -64,7 +63,7 @@ class ThresholdFilterHelper * @brief */ template - void filterDataEqualTo(const DataArray& m_Input, T trueValue, T falseValue) + void filterDataEqualTo(const AbstractDataStore& m_Input, T trueValue, T falseValue) { size_t m_NumValues = m_Input.getNumberOfTuples(); T value = static_cast(m_ComparisonValue); @@ -78,7 +77,7 @@ class ThresholdFilterHelper * @brief */ template - void filterDataNotEqualTo(const DataArray& m_Input, T trueValue, T falseValue) + void filterDataNotEqualTo(const AbstractDataStore& m_Input, T trueValue, T falseValue) { size_t m_NumValues = m_Input.getNumberOfTuples(); T value = static_cast(m_ComparisonValue); @@ -89,7 +88,7 @@ class ThresholdFilterHelper } template - void filterData(const DataArray& input, Type trueValue, Type falseValue) + void filterData(const AbstractDataStore& input, Type trueValue, Type falseValue) { if(m_ComparisonOperator == ArrayThreshold::ComparisonType::LessThan) { @@ -129,10 +128,10 @@ class ThresholdFilterHelper struct ExecuteThresholdHelper { template - void operator()(ThresholdFilterHelper& helper, const IDataArray& iDataArray, Type trueValue, Type falseValue) + void operator()(ThresholdFilterHelper& helper, const IDataArray* iDataArray, Type trueValue, Type falseValue) { - const auto& dataArray = dynamic_cast&>(iDataArray); - helper.template filterData(dataArray, trueValue, falseValue); + const auto& dataStore = iDataArray->template getIDataStoreRefAs>(); + helper.template filterData(dataStore, trueValue, falseValue); } }; @@ -145,7 +144,7 @@ struct ExecuteThresholdHelper * @param inverse */ template -void InsertThreshold(usize numItems, DataArray& currentArray, nx::core::IArrayThreshold::UnionOperator unionOperator, std::vector& newArrayPtr, bool inverse, T trueValue, T falseValue) +void InsertThreshold(usize numItems, AbstractDataStore& currentStore, nx::core::IArrayThreshold::UnionOperator unionOperator, std::vector& newArrayPtr, bool inverse, T trueValue, T falseValue) { for(usize i = 0; i < numItems; i++) { @@ -157,30 +156,27 @@ void InsertThreshold(usize numItems, DataArray& currentArray, nx::core::IArra if(nx::core::IArrayThreshold::UnionOperator::Or == unionOperator) { - currentArray[i] = (currentArray[i] == trueValue || newArrayPtr[i] == trueValue) ? trueValue : falseValue; + currentStore[i] = (currentStore[i] == trueValue || newArrayPtr[i] == trueValue) ? trueValue : falseValue; } - else if(currentArray[i] == falseValue || newArrayPtr[i] == falseValue) + else if(currentStore[i] == falseValue || newArrayPtr[i] == falseValue) { - currentArray[i] = falseValue; + currentStore[i] = falseValue; } } } template -void ThresholdValue(std::shared_ptr& comparisonValue, DataStructure& dataStructure, DataPath& outputResultArrayPath, int32_t& err, bool replaceInput, bool inverse, T trueValue, - T falseValue) +void ThresholdValue(std::shared_ptr& comparisonValue, const DataStructure& dataStructure, AbstractDataStore& outputResultStore, int32_t& err, bool replaceInput, bool inverse, + T trueValue, T falseValue) { if(nullptr == comparisonValue) { err = -1; return; } - // Traditionally we would do a check to ensure we get a valid pointer, I'm forgoing that check because it - // was essentially done in the preflight part. - auto& outputResultArray = dataStructure.getDataRefAs>(outputResultArrayPath); // Get the total number of tuples, create and initialize an array with FALSE to use for these results - size_t totalTuples = outputResultArray.getNumberOfTuples(); + size_t totalTuples = outputResultStore.getNumberOfTuples(); std::vector tempResultVector(totalTuples, falseValue); nx::core::ArrayThreshold::ComparisonType compOperator = comparisonValue->getComparisonType(); @@ -191,9 +187,9 @@ void ThresholdValue(std::shared_ptr& comparisonValue, DataStruct ThresholdFilterHelper helper(compOperator, compValue, tempResultVector); - const auto& iDataArray = dataStructure.getDataRefAs(inputDataArrayPath); + const auto* iDataArray = dataStructure.getDataAs(inputDataArrayPath); - ExecuteDataFunction(ExecuteThresholdHelper{}, iDataArray.getDataType(), helper, iDataArray, trueValue, falseValue); + ExecuteDataFunction(ExecuteThresholdHelper{}, iDataArray->getDataType(), helper, iDataArray, trueValue, falseValue); if(replaceInput) { @@ -204,72 +200,39 @@ void ThresholdValue(std::shared_ptr& comparisonValue, DataStruct // copy the temp uint8 vector to the final uint8 result array for(size_t i = 0; i < totalTuples; i++) { - outputResultArray[i] = tempResultVector[i]; + outputResultStore[i] = tempResultVector[i]; } } else { // insert into current threshold - InsertThreshold(totalTuples, outputResultArray, unionOperator, tempResultVector, inverse, trueValue, falseValue); + InsertThreshold(totalTuples, outputResultStore, unionOperator, tempResultVector, inverse, trueValue, falseValue); } } -/** - * @brief thresholdValue - * @param comparisonValue - * @param dataStructure - * @param outputResultArrayPath - * @param err - * @param replaceInput - * @param inverse - */ -void ThresholdValue(std::shared_ptr& comparisonValue, DataStructure& dataStructure, DataPath& outputResultArrayPath, DataType maskArrayType, int32_t& err, bool replaceInput, - bool inverse, float64 trueValue, float64 falseValue) +struct ThresholdValueFunctor { - switch(maskArrayType) + template + void operator()(std::shared_ptr& comparisonValue, const DataStructure& dataStructure, IDataArray* outputResultArray, int32_t& err, bool replaceInput, bool inverse, T trueValue, + T falseValue) { - case DataType::int8: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::int16: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::int32: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::int64: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::uint8: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::uint16: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::uint32: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::uint64: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::float32: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::float64: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::boolean: - [[fallthrough]]; - default: - return ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); + // Traditionally we would do a check to ensure we get a valid pointer, I'm forgoing that check because it + // was essentially done in the preflight part. + ThresholdValue(comparisonValue, dataStructure, outputResultArray->template getIDataStoreRefAs>(), err, replaceInput, inverse, trueValue, falseValue); } -} +}; template -void ThresholdSet(std::shared_ptr& inputComparisonSet, DataStructure& dataStructure, DataPath& outputResultArrayPath, int32_t& err, bool replaceInput, bool inverse, T trueValue, - T falseValue) +void ThresholdSet(std::shared_ptr& inputComparisonSet, const DataStructure& dataStructure, AbstractDataStore& outputResultStore, int32_t& err, bool replaceInput, bool inverse, + T trueValue, T falseValue) { if(nullptr == inputComparisonSet) { return; } - // Traditionally we would do a check to ensure we get a valid pointer, I'm forgoing that check because it - // was essentially done in the preflight part. - auto& outputResultArray = dataStructure.getDataRefAs>(outputResultArrayPath); - // Get the total number of tuples, create and initialize an array with FALSE to use for these results - size_t totalTuples = outputResultArray.getNumberOfTuples(); + size_t totalTuples = outputResultStore.getNumberOfTuples(); std::vector tempResultVector(totalTuples, falseValue); T firstValueFound = 0; @@ -280,13 +243,14 @@ void ThresholdSet(std::shared_ptr& inputComparisonSet, DataSt if(std::dynamic_pointer_cast(threshold)) { std::shared_ptr comparisonSet = std::dynamic_pointer_cast(threshold); - ThresholdSet(comparisonSet, dataStructure, outputResultArrayPath, err, !firstValueFound, false, trueValue, falseValue); + ThresholdSet(comparisonSet, dataStructure, outputResultStore, err, !firstValueFound, false, trueValue, falseValue); firstValueFound = true; } else if(std::dynamic_pointer_cast(threshold)) { std::shared_ptr comparisonValue = std::dynamic_pointer_cast(threshold); - ThresholdValue(comparisonValue, dataStructure, outputResultArrayPath, err, !firstValueFound, false, trueValue, falseValue); + + ThresholdValue(comparisonValue, dataStructure, outputResultStore, err, !firstValueFound, false, trueValue, falseValue); firstValueFound = true; } } @@ -300,47 +264,32 @@ void ThresholdSet(std::shared_ptr& inputComparisonSet, DataSt // copy the temp uint8 vector to the final uint8 result array for(size_t i = 0; i < totalTuples; i++) { - outputResultArray[i] = tempResultVector[i]; + outputResultStore[i] = tempResultVector[i]; } } else { // insert into current threshold - InsertThreshold(totalTuples, outputResultArray, inputComparisonSet->getUnionOperator(), tempResultVector, inverse, trueValue, falseValue); + InsertThreshold(totalTuples, outputResultStore, inputComparisonSet->getUnionOperator(), tempResultVector, inverse, trueValue, falseValue); } } -void ThresholdSet(std::shared_ptr& inputComparisonSet, DataStructure& dataStructure, DataPath& outputResultArrayPath, DataType maskArrayType, int32_t& err, bool replaceInput, - bool inverse, float64 trueValue, float64 falseValue) +struct ThresholdSetFunctor { - switch(maskArrayType) + template + void operator()(std::shared_ptr& inputComparisonSet, const DataStructure& dataStructure, IDataArray* outputResultArray, int32_t& err, bool replaceInput, bool inverse, T trueValue, + T falseValue) { - case DataType::int8: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::int16: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::int32: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::int64: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::uint8: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::uint16: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::uint32: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::uint64: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::float32: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::float64: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); - case DataType::boolean: - [[fallthrough]]; - default: - return ThresholdSet(inputComparisonSet, dataStructure, outputResultArrayPath, err, replaceInput, inverse, trueValue, falseValue); + if(outputResultArray == nullptr) + { + return; + } + + // Traditionally we would do a check to ensure we get a valid pointer, I'm forgoing that check because it + // was essentially done in the preflight part. + ThresholdSet(inputComparisonSet, dataStructure, outputResultArray->template getIDataStoreRefAs>(), err, replaceInput, inverse, trueValue, falseValue); } -} +}; struct CheckCustomValueInBounds { @@ -370,7 +319,6 @@ struct CheckCustomValueInBounds return {}; } }; - } // namespace // ----------------------------------------------------------------------------- @@ -552,13 +500,15 @@ Result<> MultiThresholdObjectsFilter::executeImpl(DataStructure& dataStructure, if(std::dynamic_pointer_cast(threshold)) { std::shared_ptr comparisonSet = std::dynamic_pointer_cast(threshold); - ThresholdSet(comparisonSet, dataStructure, maskArrayPath, maskArrayType, err, !firstValueFound, thresholdsObject.isInverted(), trueValue, falseValue); + ExecuteDataFunction(ThresholdSetFunctor{}, maskArrayType, comparisonSet, dataStructure, dataStructure.getDataAs(maskArrayPath), err, !firstValueFound, thresholdsObject.isInverted(), + trueValue, falseValue); firstValueFound = true; } else if(std::dynamic_pointer_cast(threshold)) { std::shared_ptr comparisonValue = std::dynamic_pointer_cast(threshold); - ThresholdValue(comparisonValue, dataStructure, maskArrayPath, maskArrayType, err, !firstValueFound, thresholdsObject.isInverted(), trueValue, falseValue); + ExecuteDataFunction(ThresholdValueFunctor{}, maskArrayType, comparisonValue, dataStructure, dataStructure.getDataAs(maskArrayPath), err, !firstValueFound, + thresholdsObject.isInverted(), trueValue, falseValue); firstValueFound = true; } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/NearestPointFuseRegularGridsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/NearestPointFuseRegularGridsFilter.cpp index 949ab403d2..e548a0e995 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/NearestPointFuseRegularGridsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/NearestPointFuseRegularGridsFilter.cpp @@ -7,15 +7,12 @@ #include "simplnx/DataStructure/INeighborList.hpp" #include "simplnx/DataStructure/StringArray.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" -#include "simplnx/Filter/Actions/CreateNeighborListAction.hpp" #include "simplnx/Filter/Actions/CreateStringArrayAction.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataGroupSelectionParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/NumberParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -95,7 +92,6 @@ IFilter::PreflightResult NearestPointFuseRegularGridsFilter::preflightImpl(const auto pSamplingCellAttributeMatrixPathValue = filterArgs.value(k_SamplingCellAttributeMatrixPath_Key); auto pReferenceCellAttributeMatrixPathValue = filterArgs.value(k_ReferenceCellAttributeMatrixPath_Key); - PreflightResult preflightResult; nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/PointSampleTriangleGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/PointSampleTriangleGeometryFilter.cpp index f92bd16bbc..63c986bb45 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/PointSampleTriangleGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/PointSampleTriangleGeometryFilter.cpp @@ -12,10 +12,8 @@ #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/DataPathSelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/NumberParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -58,9 +56,7 @@ Parameters PointSampleTriangleGeometryFilter::parameters() const params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); // Create the parameter descriptors that are needed for this filter - // params.insertLinkableParameter(std::make_unique(k_SamplesNumberType_Key, "Source for Number of Samples", "", 0, ChoicesParameter::Choices{"Manual", "Other Geometry"})); params.insert(std::make_unique(k_NumberOfSamples_Key, "Number of Sample Points", "The number of sample points to use", 1000)); - // params.insert(std::make_unique(k_ParentGeometry_Key, "Source Geometry for Number of Sample Points", "", DataPath{}, true)); 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)); @@ -85,8 +81,6 @@ Parameters PointSampleTriangleGeometryFilter::parameters() const nx::core::GetAllDataTypes())); params.insertSeparator(Parameters::Separator{"Output Vertex Geometry"}); - // params.insert(std::make_unique(k_VertexParentGroup_Key, "Created Vertex Geometry Parent [Data Group]", "", DataPath{}, - // DataGroupSelectionParameter::AllowedTypes{BaseGroup::GroupType::DataGroup})); params.insert(std::make_unique(k_VertexGeometryPath_Key, "Vertex Geometry Name", "The complete path to the DataGroup holding the Vertex Geometry that represents the sampling points", DataPath({"[Vertex Geometry]"}))); params.insertSeparator(Parameters::Separator{"Output Vertex Attribute Matrix"}); @@ -94,8 +88,6 @@ Parameters PointSampleTriangleGeometryFilter::parameters() const std::make_unique(k_VertexDataGroupName_Key, "Vertex Data", "The complete path to the vertex data arrays for the Vertex Geometry", INodeGeometry0D::k_VertexDataName)); // Associate the Linkable Parameter(s) to the children parameters that they control - // params.linkParameters(k_SamplesNumberType_Key, k_NumberOfSamples_Key, 0); - // params.linkParameters(k_SamplesNumberType_Key, k_ParentGeometry_Key, 1); params.linkParameters(k_UseMask_Key, k_MaskArrayPath_Key, true); params.linkParameters(k_UseSeed_Key, k_SeedValue_Key, true); @@ -122,8 +114,6 @@ IFilter::PreflightResult PointSampleTriangleGeometryFilter::preflightImpl(const DataPath pVertexGroupDataPath = pVertexGeometryDataPath.createChildPath(pVertexGroupDataName); auto pSeedArrayNameValue = filterArgs.value(k_SeedArrayName_Key); - PreflightResult preflightResult; - nx::core::Result resultOutputActions = {}; std::vector preflightUpdatedValues; @@ -217,11 +207,9 @@ namespace { namespace SIMPL { -constexpr StringLiteral k_SamplesNumberTypeKey = "SamplesNumberType"; constexpr StringLiteral k_NumberOfSamplesKey = "NumberOfSamples"; constexpr StringLiteral k_UseMaskKey = "UseMask"; constexpr StringLiteral k_TriangleGeometryKey = "TriangleGeometry"; -constexpr StringLiteral k_ParentGeometryKey = "ParentGeometry"; constexpr StringLiteral k_TriangleAreasArrayPathKey = "TriangleAreasArrayPath"; constexpr StringLiteral k_MaskArrayPathKey = "MaskArrayPath"; constexpr StringLiteral k_SelectedDataArrayPathsKey = "SelectedDataArrayPaths"; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/QuickSurfaceMeshFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/QuickSurfaceMeshFilter.cpp index 1a01d68859..4db0e1bb9d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/QuickSurfaceMeshFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/QuickSurfaceMeshFilter.cpp @@ -7,16 +7,13 @@ #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Filter/Actions/CreateAttributeMatrixAction.hpp" #include "simplnx/Filter/Actions/CreateGeometry2DAction.hpp" -#include "simplnx/Parameters/ArrayCreationParameter.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataGroupCreationParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -49,7 +46,7 @@ std::string QuickSurfaceMeshFilter::humanName() const //------------------------------------------------------------------------------ std::vector QuickSurfaceMeshFilter::defaultTags() const { - return {className(), "Surface Meshing", "Generation", "Create", "Triangle", "Geoemtry"}; + return {className(), "Surface Meshing", "Generation", "Create", "Triangle", "Geometry"}; } //------------------------------------------------------------------------------ @@ -104,8 +101,6 @@ IFilter::UniquePointer QuickSurfaceMeshFilter::clone() const IFilter::PreflightResult QuickSurfaceMeshFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pGenerateTripleLines = filterArgs.value(k_GenerateTripleLines_Key); - auto pFixProblemVoxelsValue = filterArgs.value(k_FixProblemVoxels_Key); auto pGridGeomDataPath = filterArgs.value(k_GridGeometryDataPath_Key); auto pFeatureIdsArrayPathValue = filterArgs.value(k_CellFeatureIdsArrayPath_Key); auto pSelectedDataArrayPaths = filterArgs.value(k_SelectedDataArrayPaths_Key); @@ -119,7 +114,6 @@ IFilter::PreflightResult QuickSurfaceMeshFilter::preflightImpl(const DataStructu DataPath pVertexGroupDataPath = pTriangleGeometryPath.createChildPath(pVertexGroupDataName); DataPath pFaceGroupDataPath = pTriangleGeometryPath.createChildPath(pFaceGroupDataName); - PreflightResult preflightResult; nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadBinaryCTNorthstarFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadBinaryCTNorthstarFilter.cpp index 5f1aaa7b97..23ede1b515 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadBinaryCTNorthstarFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadBinaryCTNorthstarFilter.cpp @@ -12,9 +12,8 @@ #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/VectorParameter.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" -#include "simplnx/Utilities/StringUtilities.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" +#include "simplnx/Utilities/StringUtilities.hpp" #include diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadCSVFileFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadCSVFileFilter.cpp index 58b74b8127..61dc99c403 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadCSVFileFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadCSVFileFilter.cpp @@ -19,7 +19,6 @@ #include "simplnx/Utilities/SIMPLConversion.hpp" #include "simplnx/Utilities/StringUtilities.hpp" -#include #include using namespace nx::core; @@ -69,9 +68,8 @@ enum class IssueCodes StringVector RemoveIllegalCharacters(StringVector& headers) { - for(int i = 0; i < headers.size(); i++) + for(auto& headerName : headers) { - auto& headerName = headers[i]; // Replace all illegal characters with '_' character. The header names become array names which is the issue. // This should have been taken care of in the GUI, but if someone is trying this from Python they will not have done that // or if they are just reading it in through nxrunner. @@ -91,7 +89,7 @@ Result validateExistingGroup(const DataPath& groupPath, const Dat return {MakeErrorResult(to_underlying(IssueCodes::EMPTY_EXISTING_DG), "'Existing Attribute Matrix' - Data path is empty.")}; } - const BaseGroup& selectedGroup = dataStructure.getDataRefAs(groupPath); + const auto& selectedGroup = dataStructure.getDataRefAs(groupPath); const auto arrays = selectedGroup.findAllChildrenOfType(); for(const std::shared_ptr& array : arrays) { @@ -148,57 +146,57 @@ Result createParsers(const DataTypeVector& dataTypes, const std:: switch(dataType) { case nx::core::DataType::int8: { - Int8Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::uint8: { - UInt8Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::int16: { - Int16Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::uint16: { - UInt16Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::int32: { - Int32Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::uint32: { - UInt32Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::int64: { - Int64Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::uint64: { - UInt64Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::float32: { - Float32Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::float64: { - Float64Array& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } case nx::core::DataType::boolean: { - BoolArray& data = dataStructure.getDataRefAs(arrayPath); + auto& data = dataStructure.getDataRefAs(arrayPath); dataParsers[i] = std::make_unique(data, name, i); break; } @@ -410,10 +408,10 @@ IFilter::UniquePointer ReadCSVFileFilter::clone() const IFilter::PreflightResult ReadCSVFileFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - ReadCSVData readCSVData = filterArgs.value(k_ReadCSVData_Key); - bool useExistingAM = filterArgs.value(k_UseExistingGroup_Key); - DataPath selectedAM = filterArgs.value(k_SelectedAttributeMatrixPath_Key); - DataPath createdDataAM = filterArgs.value(k_CreatedDataGroup_Key); + auto readCSVData = filterArgs.value(k_ReadCSVData_Key); + auto useExistingAM = filterArgs.value(k_UseExistingGroup_Key); + auto selectedAM = filterArgs.value(k_SelectedAttributeMatrixPath_Key); + auto createdDataAM = filterArgs.value(k_CreatedDataGroup_Key); std::string inputFilePath = readCSVData.inputFilePath; ReadCSVData::HeaderMode headerMode = readCSVData.headerMode; @@ -560,7 +558,7 @@ IFilter::PreflightResult ReadCSVFileFilter::preflightImpl(const DataStructure& d if(StringUtilities::contains(headerName, '&') || StringUtilities::contains(headerName, ':') || StringUtilities::contains(headerName, '/') || StringUtilities::contains(headerName, '\\')) { return {MakeErrorResult(to_underlying(IssueCodes::ILLEGAL_NAMES), - fmt::format("The header name \"{}\" contains a character that will cause problems. Do Not use '&',':', '/' or '\\' in the header names.", headerName))}; + fmt::format(R"(The header name "{}" contains a character that will cause problems. Do Not use '&',':', '/' or '\' in the header names.)", headerName))}; } for(int j = 0; j < headers.size(); j++) @@ -577,7 +575,7 @@ IFilter::PreflightResult ReadCSVFileFilter::preflightImpl(const DataStructure& d // Check that we have a valid tuple count usize totalImportedLines = totalLines - readCSVData.startImportRow + 1; - usize tupleTotal = std::accumulate(readCSVData.tupleDims.begin(), readCSVData.tupleDims.end(), static_cast(1), std::multiplies()); + usize tupleTotal = std::accumulate(readCSVData.tupleDims.begin(), readCSVData.tupleDims.end(), static_cast(1), std::multiplies<>()); if(tupleTotal == 0) { std::string tupleDimsStr = tupleDimsToString(readCSVData.tupleDims); @@ -619,7 +617,7 @@ IFilter::PreflightResult ReadCSVFileFilter::preflightImpl(const DataStructure& d std::transform(readCSVData.tupleDims.begin(), readCSVData.tupleDims.end(), tupleDims.begin(), [](usize d) { return d; }); if(useExistingAM) { - const AttributeMatrix& am = dataStructure.getDataRefAs(groupPath); + const auto& am = dataStructure.getDataRefAs(groupPath); tupleDims = am.getShape(); auto totalLinesRead = std::accumulate(tupleDims.begin(), tupleDims.end(), static_cast(1), std::multiplies<>()); @@ -652,10 +650,10 @@ IFilter::PreflightResult ReadCSVFileFilter::preflightImpl(const DataStructure& d Result<> ReadCSVFileFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - ReadCSVData readCSVData = filterArgs.value(k_ReadCSVData_Key); - bool useExistingGroup = filterArgs.value(k_UseExistingGroup_Key); - DataPath selectedDataGroup = filterArgs.value(k_SelectedAttributeMatrixPath_Key); - DataPath createdDataGroup = filterArgs.value(k_CreatedDataGroup_Key); + auto readCSVData = filterArgs.value(k_ReadCSVData_Key); + auto useExistingGroup = filterArgs.value(k_UseExistingGroup_Key); + auto selectedDataGroup = filterArgs.value(k_SelectedAttributeMatrixPath_Key); + auto createdDataGroup = filterArgs.value(k_CreatedDataGroup_Key); std::string inputFilePath = readCSVData.inputFilePath; StringVector headers = StringUtilities::split(s_HeaderCache[s_InstanceId].Headers, readCSVData.delimiters, readCSVData.consecutiveDelimiters); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadDREAM3DFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadDREAM3DFilter.cpp index 19f449a232..4c7c61ebd9 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadDREAM3DFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadDREAM3DFilter.cpp @@ -1,12 +1,9 @@ #include "ReadDREAM3DFilter.hpp" #include "simplnx/Common/StringLiteral.hpp" -#include "simplnx/DataStructure/DataGroup.hpp" #include "simplnx/Filter/Actions/ImportH5ObjectPathsAction.hpp" #include "simplnx/Parameters/Dream3dImportParameter.hpp" #include "simplnx/Parameters/StringParameter.hpp" -#include "simplnx/Pipeline/Pipeline.hpp" -#include "simplnx/Utilities/Parsing/DREAM3D/Dream3dIO.hpp" #include "simplnx/Utilities/Parsing/HDF5/Readers/FileReader.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" @@ -15,7 +12,6 @@ namespace { -constexpr nx::core::StringLiteral k_ImportedPipeline = "Imported Pipeline"; constexpr nx::core::int32 k_NoImportPathError = -1; constexpr nx::core::int32 k_FailedOpenFileReaderError = -25; } // namespace @@ -113,15 +109,6 @@ nlohmann::json ReadDREAM3DFilter::toJson(const Arguments& args) const return json; } -namespace -{ -namespace SIMPL -{ -constexpr StringLiteral k_OverwriteExistingDataContainersKey = "OverwriteExistingDataContainers"; -constexpr StringLiteral k_InputFileDataContainerArrayProxyKey = "InputFileDataContainerArrayProxy"; -} // namespace SIMPL -} // namespace - Result ReadDREAM3DFilter::FromSIMPLJson(const nlohmann::json& json) { Arguments args = ReadDREAM3DFilter().getDefaultArguments(); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadDeformKeyFileV12Filter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadDeformKeyFileV12Filter.cpp index 0e40b891ed..ce3eae15f6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadDeformKeyFileV12Filter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadDeformKeyFileV12Filter.cpp @@ -7,7 +7,6 @@ #include "simplnx/Parameters/DataGroupCreationParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/FileSystemPathParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -95,13 +94,10 @@ IFilter::PreflightResult ReadDeformKeyFileV12Filter::preflightImpl(const DataStr const std::atomic_bool& shouldCancel) const { auto pInputFilePathValue = filterArgs.value(k_InputFilePath_Key); - auto pQuadGeomPathValue = filterArgs.value(k_QuadGeomPath_Key); auto pVertexAMNameValue = filterArgs.value(k_VertexAMName_Key); auto pCellAMNameValue = filterArgs.value(k_CellAMName_Key); - // Declare the preflightResult variable - PreflightResult preflightResult; nx::core::Result resultOutputActions; std::vector preflightUpdatedValues; @@ -189,7 +185,6 @@ namespace namespace SIMPL { constexpr StringLiteral k_DEFORMInputFileKey = "DEFORMInputFile"; -constexpr StringLiteral k_VerboseOutputKey = "VerboseOutput"; constexpr StringLiteral k_DataContainerNameKey = "DataContainerName"; constexpr StringLiteral k_VertexAttributeMatrixNameKey = "VertexAttributeMatrixName"; constexpr StringLiteral k_CellAttributeMatrixNameKey = "CellAttributeMatrixName"; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadHDF5DatasetFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadHDF5DatasetFilter.cpp index 1d33cb4665..8ac7eae86c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadHDF5DatasetFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadHDF5DatasetFilter.cpp @@ -9,11 +9,10 @@ #include "simplnx/Utilities/Parsing/HDF5/H5.hpp" #include "simplnx/Utilities/Parsing/HDF5/H5Support.hpp" #include "simplnx/Utilities/Parsing/HDF5/Readers/FileReader.hpp" -#include "simplnx/Utilities/StringUtilities.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" +#include "simplnx/Utilities/StringUtilities.hpp" -#include +#include using namespace nx::core; namespace fs = std::filesystem; @@ -44,59 +43,6 @@ std::vector createDimensionVector(const std::string& cDimsStr) return cDims; } - -template -Result<> fillDataStore(DataArray& dataArray, const DataPath& dataArrayPath, const nx::core::HDF5::DatasetReader& datasetReader) -{ - using StoreType = DataStore; - StoreType& dataStore = dataArray.template getIDataStoreRefAs(); - if(!datasetReader.readIntoSpan(dataStore.createSpan())) - { - return {MakeErrorResult(-21002, fmt::format("Error reading dataset '{}' with '{}' total elements into data store for data array '{}' with '{}' total elements ('{}' tuples and '{}' components)", - dataArrayPath.getTargetName(), datasetReader.getNumElements(), dataArrayPath.toString(), dataArray.getSize(), dataArray.getNumberOfTuples(), - dataArray.getNumberOfComponents()))}; - } - - return {}; -} - -template -Result<> fillOocDataStore(DataArray& dataArray, const DataPath& dataArrayPath, const nx::core::HDF5::DatasetReader& datasetReader) -{ - uint64 installedMemory = Memory::GetTotalMemory(); - if(installedMemory <= dataArray.getSize() * sizeof(T)) - { - return MakeErrorResult(-21004, fmt::format("Error reading dataset '{}' with '{}' total elements. Not enough memory to import data. Installed memory is {} bytes", dataArray.getName(), - datasetReader.getNumElements(), installedMemory)); - } - - auto& absDataStore = dataArray.getDataStoreRef(); - std::vector data(absDataStore.getSize()); - nonstd::span span{data.data(), data.size()}; - if(!datasetReader.readIntoSpan(span)) - { - return {MakeErrorResult(-21003, fmt::format("Error reading dataset '{}' with '{}' total elements into data store for data array '{}' with '{}' total elements ('{}' tuples and '{}' components)", - dataArrayPath.getTargetName(), datasetReader.getNumElements(), dataArrayPath.toString(), dataArray.getSize(), dataArray.getNumberOfTuples(), - dataArray.getNumberOfComponents()))}; - } - std::copy(data.begin(), data.end(), absDataStore.begin()); - - return {}; -} - -template -Result<> fillDataArray(DataStructure& dataStructure, const DataPath& dataArrayPath, const nx::core::HDF5::DatasetReader& datasetReader) -{ - auto& dataArray = dataStructure.getDataRefAs>(dataArrayPath); - if(dataArray.getDataFormat().empty()) - { - return fillDataStore(dataArray, dataArrayPath, datasetReader); - } - else - { - return fillOocDataStore(dataArray, dataArrayPath, datasetReader); - } -} } // namespace namespace nx::core @@ -162,7 +108,7 @@ IFilter::PreflightResult ReadHDF5DatasetFilter::preflightImpl(const DataStructur if(inputFile.empty()) { - return {nonstd::make_unexpected(std::vector{Error{-20001, "The HDF5 file path is empty. Please select an HDF5 file."}})}; + return MakePreflightErrorResult(-20001, "The HDF5 file path is empty. Please select an HDF5 file."); } fs::path inputFilePath(inputFile); @@ -170,20 +116,20 @@ IFilter::PreflightResult ReadHDF5DatasetFilter::preflightImpl(const DataStructur if(!fs::exists(inputFilePath)) { - return {nonstd::make_unexpected(std::vector{Error{-20003, fmt::format("The selected file '{}' does not exist.", inputFilePath.filename().string())}})}; + return MakePreflightErrorResult(-20003, fmt::format("The selected file '{}' does not exist.", inputFilePath.filename().string())); } if(datasetImportInfoList.empty()) { - return {nonstd::make_unexpected(std::vector{Error{-20004, "No dataset has been checked. Please check a dataset."}})}; + return MakePreflightErrorResult(-20004, "No dataset has been checked. Please check a dataset."); } if(pSelectedAttributeMatrixValue.has_value()) { if(dataStructure.getDataAs(pSelectedAttributeMatrixValue.value()) == nullptr && dataStructure.getDataAs(pSelectedAttributeMatrixValue.value()) == nullptr) { - return {nonstd::make_unexpected(std::vector{ - Error{-20005, fmt::format("The selected data path '{}' does not exist. Make sure you are selecting a DataGroup or AttributeMatrix.", pSelectedAttributeMatrixValue.value().toString())}})}; + return MakePreflightErrorResult( + -20005, fmt::format("The selected data path '{}' does not exist. Make sure you are selecting a DataGroup or AttributeMatrix.", pSelectedAttributeMatrixValue.value().toString())); } } @@ -194,7 +140,7 @@ IFilter::PreflightResult ReadHDF5DatasetFilter::preflightImpl(const DataStructur hid_t fileId = h5FileReader.getId(); if(fileId < 0) { - return {nonstd::make_unexpected(std::vector{Error{-20006, fmt::format("Error Reading HDF5 file: '{}'", inputFile)}})}; + return MakePreflightErrorResult(-20006, fmt::format("Error Reading HDF5 file: '{}'", inputFile)); } for(const auto& datasetImportInfo : datasetImportInfoList) @@ -202,7 +148,7 @@ IFilter::PreflightResult ReadHDF5DatasetFilter::preflightImpl(const DataStructur std::string datasetPath = datasetImportInfo.dataSetPath; if(datasetPath.empty()) { - return {nonstd::make_unexpected(std::vector{Error{-20007, "Cannot import an empty dataset path"}})}; + return MakePreflightErrorResult(-20007, "Cannot import an empty dataset path"); } // Read dataset into DREAM.3D structure @@ -212,22 +158,22 @@ IFilter::PreflightResult ReadHDF5DatasetFilter::preflightImpl(const DataStructur if(dims.empty()) { - return {nonstd::make_unexpected(std::vector{Error{-20008, fmt::format("Error reading dimensions from dataset with path '{}'", datasetPath)}})}; + return MakePreflightErrorResult(-20008, fmt::format("Error reading dimensions from dataset with path '{}'", datasetPath)); } std::string cDimsStr = datasetImportInfo.componentDimensions; if(cDimsStr.empty()) { - return {nonstd::make_unexpected(std::vector{ - Error{-20009, fmt::format("The component dimensions are empty for dataset with path '{}'. Please enter the component dimensions, using comma-separated values (ex: 4x2 would be '4, 2').", - datasetPath)}})}; + return MakePreflightErrorResult( + -20009, + fmt::format("The component dimensions are empty for dataset with path '{}'. Please enter the component dimensions, using comma-separated values (ex: 4x2 would be '4, 2').", datasetPath)); } std::vector cDims = createDimensionVector(cDimsStr); if(cDims.empty()) { - return {nonstd::make_unexpected(std::vector{ - Error{-20010, fmt::format("Component Dimensions are not in the right format for dataset with path '{}'. Use comma-separated values (ex: 4x2 would be '4, 2').", datasetPath)}})}; + return MakePreflightErrorResult(-20010, + fmt::format("Component Dimensions are not in the right format for dataset with path '{}'. Use comma-separated values (ex: 4x2 would be '4, 2').", datasetPath)); } std::vector tDims; @@ -236,16 +182,15 @@ IFilter::PreflightResult ReadHDF5DatasetFilter::preflightImpl(const DataStructur std::string tDimsStr = datasetImportInfo.tupleDimensions; if(tDimsStr.empty()) { - return {nonstd::make_unexpected(std::vector{ - Error{-20011, fmt::format("The tuple dimensions are empty for dataset with path '{}'. Please enter the tuple dimensions, using comma-separated values (ex: 4x2 would be '4, 2').", - datasetPath)}})}; + return MakePreflightErrorResult( + -20011, fmt::format("The tuple dimensions are empty for dataset with path '{}'. Please enter the tuple dimensions, using comma-separated values (ex: 4x2 would be '4, 2').", datasetPath)); } tDims = createDimensionVector(tDimsStr); if(tDims.empty()) { - return {nonstd::make_unexpected(std::vector{ - Error{-20012, fmt::format("Tuple Dimensions are not in the right format for dataset with path '{}'. Use comma-separated values (ex: 4x2 would be '4, 2').", datasetPath)}})}; + return MakePreflightErrorResult(-20012, + fmt::format("Tuple Dimensions are not in the right format for dataset with path '{}'. Use comma-separated values (ex: 4x2 would be '4, 2').", datasetPath)); } } else @@ -323,7 +268,7 @@ IFilter::PreflightResult ReadHDF5DatasetFilter::preflightImpl(const DataStructur "'{}' =/= '{}'", datasetPath, StringUtilities::number(numOfTuples), StringUtilities::number(totalComponents), StringUtilities::number(numOfTuples * totalComponents), StringUtilities::number(hdf5TotalElements), StringUtilities::number(numOfTuples * totalComponents), StringUtilities::number(hdf5TotalElements)); - return {nonstd::make_unexpected(std::vector{Error{-20013, stream.str()}})}; + return MakePreflightErrorResult(-20013, stream.str()); } DataPath dataArrayPath = pSelectedAttributeMatrixValue.has_value() ? pSelectedAttributeMatrixValue.value().createChildPath(objectName) : DataPath::FromString(objectName).value(); @@ -332,16 +277,15 @@ IFilter::PreflightResult ReadHDF5DatasetFilter::preflightImpl(const DataStructur { stream.clear(); stream << "The selected dataset '" << pSelectedAttributeMatrixValue.value().toString() << "/" << objectName << "' already exists."; - return {nonstd::make_unexpected(std::vector{Error{-20014, stream.str()}})}; + return MakePreflightErrorResult(-20014, stream.str()); } else { Result type = datasetReader.getDataType(); if(type.invalid()) { - return { - nonstd::make_unexpected(std::vector{Error{-20015, fmt::format("The selected datatset '{}' with type '{}' is not a supported type for importing. Please select a different data set", - datasetPath, fmt::underlying(datasetReader.getType()))}})}; + return MakePreflightErrorResult(-20015, fmt::format("The selected dataset '{}' with type '{}' is not a supported type for importing. Please select a different data set", datasetPath, + fmt::underlying(datasetReader.getType()))); } DataType dataType = nx::core::HDF5::toCommonType(type.value()).value(); auto action = std::make_unique(dataType, tDims, cDims, dataArrayPath); @@ -366,7 +310,7 @@ Result<> ReadHDF5DatasetFilter::executeImpl(DataStructure& dataStructure, const hid_t fileId = h5FileReader.getId(); if(fileId < 0) { - return {MakeErrorResult(-21000, fmt::format("Error Reading HDF5 file: '{}'", inputFile))}; + return MakeErrorResult(-21000, fmt::format("Error Reading HDF5 file: '{}'", inputFile)); } std::map openedParentPathsMap; @@ -423,15 +367,15 @@ Result<> ReadHDF5DatasetFilter::executeImpl(DataStructure& dataStructure, const break; } default: { - return {MakeErrorResult(-21001, - fmt::format("The selected dataset '{}' with type '{}' is not a supported type for importing. Please select a different data set", datasetPath, fmt::underlying(type)))}; + return MakeErrorResult(-21001, + fmt::format("The selected dataset '{}' with type '{}' is not a supported type for importing. Please select a different data set", datasetPath, fmt::underlying(type))); } } if(fillArrayResults.invalid()) { return fillArrayResults; } - } // End For Loop over dataset imoprt info list + } // End For Loop over dataset import info list return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadRawBinaryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadRawBinaryFilter.cpp index 3a3ac5c23b..12c7059c87 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadRawBinaryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadRawBinaryFilter.cpp @@ -156,7 +156,7 @@ IFilter::PreflightResult ReadRawBinaryFilter::preflightImpl(const DataStructure& } usize numTuples = totalElements / pNumberOfComponentsValue; - size_t tupleCountFromTable = std::accumulate(tupleDims.begin(), tupleDims.end(), static_cast(1), std::multiplies()); + size_t tupleCountFromTable = std::accumulate(tupleDims.begin(), tupleDims.end(), static_cast(1), std::multiplies<>()); if(numTuples != tupleCountFromTable) { const std::string warningMessage = fmt::format("Total Tuples based on file '{}' does not match total tuples entered. '{}'. Reading a subsection of the file.", numTuples, tupleCountFromTable); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadStlFileFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadStlFileFilter.cpp index 56ad8a8199..48bb7aa1dc 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadStlFileFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadStlFileFilter.cpp @@ -11,12 +11,9 @@ #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" -#include "simplnx/Parameters/StringParameter.hpp" - -#include - #include "simplnx/Utilities/SIMPLConversion.hpp" +#include #include namespace fs = std::filesystem; @@ -82,11 +79,6 @@ Parameters ReadStlFileFilter::parameters() const "The name of the AttributeMatrix where the Face Data of the Triangle Geometry will be created", INodeGeometry2D::k_FaceDataName)); params.insert(std::make_unique(k_FaceNormalsName_Key, "Face Labels", "The name of the triangle normals data array", "Face Normals")); - // params.insert(std::make_unique(k_SharedVertexMatrix_Key, "Shared Vertex Matrix Name", "Name of the created Shared Vertex Attribute Matrix", - // CreateTriangleGeometryAction::k_DefaultVerticesName)); - // params.insert( - // std::make_unique(k_SharedFaceMatrix_Key, "Shared Face Matrix Name", "Name of the created Shared Face Attribute Matrix", CreateTriangleGeometryAction::k_DefaultFacesName)); - return params; } @@ -106,34 +98,30 @@ IFilter::PreflightResult ReadStlFileFilter::preflightImpl(const DataStructure& d auto faceMatrixName = filterArgs.value(k_FaceAttributeMatrixName_Key); auto faceNormalsName = filterArgs.value(k_FaceNormalsName_Key); - PreflightResult preflightResult; - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - // Validate that the STL File is binary and readable. StlConstants::StlFileType stlFileType = StlUtilities::DetermineStlFileType(pStlFilePathValue); if(stlFileType == StlConstants::StlFileType::ASCI) { - return {MakeErrorResult( + return MakePreflightErrorResult( StlConstants::k_UnsupportedFileType, - fmt::format("The Input STL File is ASCII which is not currently supported. Please convert it to a binary STL file using another program.", pStlFilePathValue.string()))}; + fmt::format("The Input STL File is ASCII which is not currently supported. Please convert it to a binary STL file using another program.", pStlFilePathValue.string())); } if(stlFileType == StlConstants::StlFileType::FileOpenError) { - return {MakeErrorResult(StlConstants::k_ErrorOpeningFile, fmt::format("Error opening the STL file.", pStlFilePathValue.string()))}; + return MakePreflightErrorResult(StlConstants::k_ErrorOpeningFile, fmt::format("Error opening the STL file.", pStlFilePathValue.string())); } if(stlFileType == StlConstants::StlFileType::HeaderParseError) { - return {MakeErrorResult(StlConstants::k_ErrorOpeningFile, fmt::format("Error reading the header from STL file.", pStlFilePathValue.string()))}; + return MakePreflightErrorResult(StlConstants::k_ErrorOpeningFile, fmt::format("Error reading the header from STL file.", pStlFilePathValue.string())); } // Now get the number of Triangles according to the STL Header int32_t numTriangles = StlUtilities::NumFacesFromHeader(pStlFilePathValue); if(numTriangles < 0) { - return {MakeErrorResult(numTriangles, fmt::format("Error extracting the number of triangles from the STL file.", pStlFilePathValue.string()))}; + return MakePreflightErrorResult(numTriangles, fmt::format("Error extracting the number of triangles from the STL file.", pStlFilePathValue.string())); } // This can happen in a LOT of STL files. Just means the writer didn't go back and update the header. @@ -161,7 +149,7 @@ IFilter::PreflightResult ReadStlFileFilter::preflightImpl(const DataStructure& d // the appropriate methods. (None to store for this filter... yet) // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadTextDataArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadTextDataArrayFilter.cpp index a50c64880f..5c5f0be9e3 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadTextDataArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadTextDataArrayFilter.cpp @@ -1,7 +1,6 @@ #include "ReadTextDataArrayFilter.hpp" #include "simplnx/Common/StringLiteral.hpp" -#include "simplnx/Common/TypeTraits.hpp" #include "simplnx/Common/TypesUtility.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Parameters/ArrayCreationParameter.hpp" @@ -13,8 +12,8 @@ #include "simplnx/Parameters/NumberParameter.hpp" #include "simplnx/Parameters/NumericTypeParameter.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" +#include "simplnx/Utilities/FilterUtilities.hpp" #include "simplnx/Utilities/Parsing/Text/CsvParser.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -22,6 +21,19 @@ namespace fs = std::filesystem; using namespace nx::core; +namespace +{ +struct CSVReadFileFunctor +{ + template + Result<> operator()(IDataArray* inputIDataArray, const fs::path& inputFilePath, uint64 skipLines, char delimiter) + { + auto& store = inputIDataArray->template getIDataStoreRefAs>(); + return CsvParser::ReadFile(inputFilePath, store, skipLines, delimiter); + } +}; +} // namespace + namespace nx::core { std::string ReadTextDataArrayFilter::name() const @@ -149,58 +161,14 @@ Result<> ReadTextDataArrayFilter::executeImpl(DataStructure& dataStructure, cons const std::atomic_bool& shouldCancel) const { auto inputFilePath = args.value(k_InputFile_Key); - auto numericType = args.value(k_ScalarType_Key); auto skipLines = args.value(k_NSkipLines_Key); auto choiceIndex = args.value(k_DelimiterChoice_Key); auto path = args.value(k_DataArrayPath_Key); char delimiter = nx::core::CsvParser::IndexToDelimiter(choiceIndex); - switch(numericType) - { - case NumericType::int8: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - case NumericType::uint8: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - case NumericType::int16: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - case NumericType::uint16: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - case NumericType::int32: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - case NumericType::uint32: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - case NumericType::int64: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - case NumericType::uint64: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - case NumericType::float32: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - case NumericType::float64: { - auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - return CsvParser::ReadFile(inputFilePath, *dataArray, skipLines, delimiter); - } - default: - return MakeErrorResult(-1001, fmt::format("ReadTextDataArrayFilter: Parameter NumericType which has a value of '{}' does not match any in simplnx.", to_underlying(numericType))); - } + auto* iDataArray = dataStructure.getDataAs(path); + return ExecuteDataFunction(CSVReadFileFunctor{}, iDataArray->getDataType(), iDataArray, inputFilePath, skipLines, delimiter); } namespace @@ -213,7 +181,6 @@ constexpr StringLiteral k_NumberOfComponentsKey = "NumberOfComponents"; constexpr StringLiteral k_SkipHeaderLinesKey = "SkipHeaderLines"; constexpr StringLiteral k_DelimiterKey = "Delimiter"; constexpr StringLiteral k_CreatedAttributeArrayPathKey = "CreatedAttributeArrayPath"; -constexpr StringLiteral k_FirstLineKey = "FirstLine"; } // namespace SIMPL } // namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVolumeGraphicsFileFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVolumeGraphicsFileFilter.cpp index 7e9243d39e..5af7f0b619 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVolumeGraphicsFileFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVolumeGraphicsFileFilter.cpp @@ -445,7 +445,7 @@ IFilter::PreflightResult ReadVolumeGraphicsFileFilter::preflightImpl(const DataS std::make_unique(DataType::float32, std::vector{metadata.Dimensions[0], metadata.Dimensions[1], metadata.Dimensions[2]}, std::vector{1}, dap); resultOutputActions.value().appendAction(std::move(createArrayAction)); - return {std::move(resultOutputActions), {}}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVtkStructuredPointsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVtkStructuredPointsFilter.cpp index 298b2d614e..afc3721a4c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVtkStructuredPointsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReadVtkStructuredPointsFilter.cpp @@ -4,8 +4,6 @@ #include "simplnx/DataStructure/DataPath.hpp" #include "simplnx/Filter/Actions/CreateDataGroupAction.hpp" -#include "simplnx/Filter/Actions/EmptyAction.hpp" -#include "simplnx/Parameters/ArrayCreationParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataGroupCreationParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" @@ -107,15 +105,12 @@ IFilter::PreflightResult ReadVtkStructuredPointsFilter::preflightImpl(const Data const std::atomic_bool& shouldCancel) const { auto pInputFileValue = filterArgs.value(k_InputFile_Key); - auto pReadPointDataValue = filterArgs.value(k_ReadPointData_Key); - auto pReadCellDataValue = filterArgs.value(k_ReadCellData_Key); auto pVertexGeometryPath = filterArgs.value(k_CreatedVertexGeometryPath_Key); auto pImageGeometryPath = filterArgs.value(k_CreatedImageGeometryPath_Key); auto pVertexAttributeMatrixNameValue = filterArgs.value(k_VertexAttributeMatrixName_Key); auto pCellAttributeMatrixNameValue = filterArgs.value(k_CellAttributeMatrixName_Key); nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; nx::core::StopWatch sw; sw.start(); @@ -137,7 +132,7 @@ IFilter::PreflightResult ReadVtkStructuredPointsFilter::preflightImpl(const Data std::cout << "\n"; // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RegularGridSampleSurfaceMeshFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RegularGridSampleSurfaceMeshFilter.cpp index 5cb8391328..b6571d1b82 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RegularGridSampleSurfaceMeshFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RegularGridSampleSurfaceMeshFilter.cpp @@ -11,7 +11,6 @@ #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/VectorParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -101,7 +100,6 @@ IFilter::PreflightResult RegularGridSampleSurfaceMeshFilter::preflightImpl(const auto pCellAMNameValue = filterArgs.value(k_CellAMName_Key); auto pFeatureIdsArrayNameValue = filterArgs.value(k_FeatureIdsArrayName_Key); - PreflightResult preflightResult; nx::core::Result resultOutputActions; std::vector tupleDims = {static_cast(pDimensionsValue[0]), static_cast(pDimensionsValue[1]), static_cast(pDimensionsValue[2])}; @@ -168,7 +166,6 @@ constexpr StringLiteral k_DimensionsKey = "Dimensions"; constexpr StringLiteral k_SpacingKey = "Spacing"; constexpr StringLiteral k_OriginKey = "Origin"; constexpr StringLiteral k_LengthUnitKey = "LengthUnit"; -constexpr StringLiteral k_BoxDimensionsKey = "BoxDimensions"; constexpr StringLiteral k_DataContainerNameKey = "DataContainerName"; constexpr StringLiteral k_CellAttributeMatrixNameKey = "CellAttributeMatrixName"; constexpr StringLiteral k_FeatureIdsArrayNameKey = "FeatureIdsArrayName"; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedEdgesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedEdgesFilter.cpp index ce392fc44f..b1f0df224f 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedEdgesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedEdgesFilter.cpp @@ -15,11 +15,6 @@ using namespace nx::core; -namespace -{ - -} // namespace - namespace nx::core { //------------------------------------------------------------------------------ @@ -109,14 +104,11 @@ IFilter::PreflightResult RemoveFlaggedEdgesFilter::preflightImpl(const DataStruc auto pEdgeArrayHandling = filterArgs.value(k_EdgeDataHandling_Key); auto selectedEdgeArrays = filterArgs.value(k_EdgeDataSelectedArrays_Key); auto selectedEdgeAttrMatPath = filterArgs.value(k_EdgeDataSelectedAttributeMatrix_Key); - auto pVertexArrayHandling = filterArgs.value(k_VertexDataHandling_Key); auto selectedVertexArrays = filterArgs.value(k_VertexDataSelectedArrays_Key); auto selectedVertexAttrMatPath = filterArgs.value(k_VertexDataSelectedAttributeMatrix_Key); - PreflightResult preflightResult; Result resultOutputActions; - std::vector preflightUpdatedValues; const auto* initialGeomPtr = dataStructure.getDataAs(pInitialGeometryPathValue); @@ -148,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) { @@ -162,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); } } } @@ -178,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) { @@ -192,13 +184,13 @@ 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); } } } // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedFeaturesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedFeaturesFilter.cpp index 9105df555b..b3e0d962a1 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedFeaturesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedFeaturesFilter.cpp @@ -111,11 +111,8 @@ IFilter::PreflightResult RemoveFlaggedFeaturesFilter::preflightImpl(const DataSt auto pFeatureIdsArrayPathValue = filterArgs.value(k_CellFeatureIdsArrayPath_Key); auto pFlaggedFeaturesArrayPathValue = filterArgs.value(k_FlaggedFeaturesArrayPath_Key); auto operationType = filterArgs.value(k_Functionality_Key); - auto fillGaps = filterArgs.value(k_FillRemovedFeatures_Key); - PreflightResult preflightResult; nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; auto* featureIdsPtr = dataStructure.getDataAs(pFeatureIdsArrayPathValue); if(featureIdsPtr == nullptr) @@ -178,7 +175,7 @@ IFilter::PreflightResult RemoveFlaggedFeaturesFilter::preflightImpl(const DataSt } } - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedTrianglesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedTrianglesFilter.cpp index 77fb399b34..ff4dcc3cbe 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedTrianglesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedTrianglesFilter.cpp @@ -108,9 +108,7 @@ IFilter::PreflightResult RemoveFlaggedTrianglesFilter::preflightImpl(const DataS auto selectedVertexArrays = filterArgs.value(k_VertexDataSelectedArrays_Key); auto selectedVertexAttrMatPath = filterArgs.value(k_VertexDataSelectedAttributeMatrix_Key); - PreflightResult preflightResult; Result resultOutputActions; - std::vector preflightUpdatedValues; const auto* initialGeomPtr = dataStructure.getDataAs(pInitialGeometryPathValue); @@ -150,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) { @@ -164,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); } } } @@ -180,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) { @@ -194,13 +192,13 @@ 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); } } } // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedVerticesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedVerticesFilter.cpp index 6b94adc0c0..54df4afc59 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedVerticesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RemoveFlaggedVerticesFilter.cpp @@ -32,13 +32,12 @@ struct RemoveFlaggedVerticesFunctor template void operator()(const IDataArray& sourceIDataArray, IDataArray& destIDataArray, const std::unique_ptr& maskCompare, size_t numVerticesToKeep) const { - using DataArrayType = DataArray; - const auto& sourceDataArray = dynamic_cast(sourceIDataArray); - auto& destinationDataArray = dynamic_cast(destIDataArray); - destinationDataArray.getDataStore()->resizeTuples({numVerticesToKeep}); + const auto& sourceDataStore = sourceIDataArray.template getIDataStoreRefAs>(); + auto& destinationDataStore = destIDataArray.template getIDataStoreRefAs>(); + destinationDataStore.resizeTuples({numVerticesToKeep}); - const usize numInputTuples = sourceDataArray.getNumberOfTuples(); - const usize nComps = sourceDataArray.getNumberOfComponents(); + const usize numInputTuples = sourceDataStore.getNumberOfTuples(); + const usize nComps = sourceDataStore.getNumberOfComponents(); usize destTupleIndex = 0; for(usize inputIndex = 0; inputIndex < numInputTuples; inputIndex++) { @@ -48,7 +47,7 @@ struct RemoveFlaggedVerticesFunctor { const usize sourceIndex = (nComps * inputIndex) + compIdx; const usize destinationIndex = (nComps * destTupleIndex) + compIdx; - destinationDataArray[destinationIndex] = sourceDataArray[sourceIndex]; + destinationDataStore[destinationIndex] = sourceDataStore[sourceIndex]; } destTupleIndex++; } @@ -114,7 +113,6 @@ IFilter::PreflightResult RemoveFlaggedVerticesFilter::preflightImpl(const DataSt auto reducedVertexPath = filterArgs.value(k_CreatedVertexGeometryPath_Key); nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; std::vector dataArrayPaths; @@ -204,7 +202,7 @@ IFilter::PreflightResult RemoveFlaggedVerticesFilter::preflightImpl(const DataSt } // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } Result<> RemoveFlaggedVerticesFilter::executeImpl(DataStructure& dataStructure, const Arguments& args, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RenameDataObjectFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RenameDataObjectFilter.cpp index 2d415e6d09..40ce929216 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RenameDataObjectFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RenameDataObjectFilter.cpp @@ -4,7 +4,6 @@ #include "simplnx/Filter/Actions/RenameDataAction.hpp" #include "simplnx/Parameters/DataPathSelectionParameter.hpp" #include "simplnx/Parameters/StringParameter.hpp" -#include "simplnx/Utilities/DataArrayUtilities.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReplaceElementAttributesWithNeighborValuesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReplaceElementAttributesWithNeighborValuesFilter.cpp index 2a5097d9ea..ba49d87383 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReplaceElementAttributesWithNeighborValuesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReplaceElementAttributesWithNeighborValuesFilter.cpp @@ -8,11 +8,9 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/ChoicesParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/NumberParameter.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -82,20 +80,17 @@ IFilter::PreflightResult ReplaceElementAttributesWithNeighborValuesFilter::prefl nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - // Inform users that the following arrays are going to be modified in place // Cell Data is going to be modified nx::core::AppendDataObjectModifications(dataStructure, resultOutputActions.value().modifiedActions, pComparisonDataPath.getParent(), {}); - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ Result<> ReplaceElementAttributesWithNeighborValuesFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - ReplaceElementAttributesWithNeighborValuesInputValues inputValues; inputValues.MinConfidence = filterArgs.value(k_MinConfidence_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RequireMinNumNeighborsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RequireMinNumNeighborsFilter.cpp index 147eb34e81..1569ccd041 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RequireMinNumNeighborsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RequireMinNumNeighborsFilter.cpp @@ -4,7 +4,6 @@ #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" @@ -17,10 +16,8 @@ namespace nx::core { namespace { -constexpr int64 k_TupleCountInvalidError = -250; constexpr int64 k_MissingFeaturePhasesError = -251; constexpr int32 k_InconsistentTupleCount = -252; -constexpr int32 k_FetchChildArrayError = -5559; Result<> assignBadPoints(DataStructure& dataStructure, const Arguments& args, const IFilter::MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) { @@ -30,19 +27,10 @@ Result<> assignBadPoints(DataStructure& dataStructure, const Arguments& args, co auto ignoredVoxelArrayPaths = args.value>(RequireMinNumNeighborsFilter::k_IgnoredVoxelArrays_Key); auto cellDataAttrMatrix = featureIdsPath.getParent(); - auto& featureIdsArray = dataStructure.getDataRefAs(featureIdsPath); - auto& numNeighborsArray = dataStructure.getDataRefAs(numNeighborsPath); - auto& featureIds = featureIdsArray.getDataStoreRef(); + auto& featureIds = dataStructure.getDataAs(featureIdsPath)->getDataStoreRef(); + auto& numNeighbors = dataStructure.getDataAs(numNeighborsPath)->getDataStoreRef(); - auto applyToSinglePhase = args.value(RequireMinNumNeighborsFilter::k_ApplyToSinglePhase_Key); - Int32Array* featurePhasesArray = nullptr; - if(applyToSinglePhase) - { - auto featurePhasesPath = args.value(RequireMinNumNeighborsFilter::k_FeaturePhasesPath_Key); - featurePhasesArray = dataStructure.getDataAs(featurePhasesPath); - } - - usize totalPoints = featureIdsArray.getNumberOfTuples(); + usize totalPoints = featureIds.getNumberOfTuples(); SizeVec3 udims = dataStructure.getDataRefAs(imageGeomPath).getDimensions(); // This was checked up in the execute function (which is called before this function) @@ -62,7 +50,7 @@ Result<> assignBadPoints(DataStructure& dataStructure, const Arguments& args, co int32 current = 0; int32 most = 0; int64 neighborPoint = 0; - usize numFeatures = numNeighborsArray.getNumberOfTuples(); + usize numFeatures = numNeighbors.getNumberOfTuples(); int64 neighborPointIdx[6] = {0, 0, 0, 0, 0, 0}; neighborPointIdx[0] = -dims[0] * dims[1]; @@ -250,31 +238,24 @@ nonstd::expected, Error> mergeContainedFeatures(DataStructure& auto phaseNumber = args.value(RequireMinNumNeighborsFilter::k_PhaseNumber_Key); - auto& featureIdsArray = dataStructure.getDataRefAs(featureIdsPath); - auto& numNeighborsArray = dataStructure.getDataRefAs(numNeighborsPath); - - auto& featureIds = featureIdsArray.getDataStoreRef(); - auto& numNeighbors = numNeighborsArray.getDataStoreRef(); + auto& featureIds = dataStructure.getDataAs(featureIdsPath)->getDataStoreRef(); + auto& numNeighbors = dataStructure.getDataAs(numNeighborsPath)->getDataStoreRef(); auto applyToSinglePhase = args.value(RequireMinNumNeighborsFilter::k_ApplyToSinglePhase_Key); - Int32Array* featurePhasesArray = nullptr; - if(applyToSinglePhase) - { - auto featurePhasesPath = args.value(RequireMinNumNeighborsFilter::k_FeaturePhasesPath_Key); - featurePhasesArray = dataStructure.getDataAs(featurePhasesPath); - } + Int32AbstractDataStore* featurePhases = + applyToSinglePhase ? dataStructure.getDataAs(args.value(RequireMinNumNeighborsFilter::k_FeaturePhasesPath_Key))->getDataStore() : nullptr; bool good = false; usize totalPoints = dataStructure.getDataRefAs(imageGeomPath).getNumberOfCells(); - usize totalFeatures = numNeighborsArray.getNumberOfTuples(); + usize totalFeatures = numNeighbors.getNumberOfTuples(); std::vector activeObjects(totalFeatures, true); for(usize i = 1; i < totalFeatures; i++) { - if(!applyToSinglePhase) + if(applyToSinglePhase && featurePhases != nullptr) { - if(numNeighbors[i] >= minNumNeighbors) + if(numNeighbors[i] >= minNumNeighbors || featurePhases->getValue(i) != phaseNumber) { good = true; } @@ -285,7 +266,7 @@ nonstd::expected, Error> mergeContainedFeatures(DataStructure& } else { - if(numNeighbors[i] >= minNumNeighbors || (*featurePhasesArray)[i] != phaseNumber) + if(numNeighbors[i] >= minNumNeighbors) { good = true; } @@ -407,7 +388,7 @@ IFilter::PreflightResult RequireMinNumNeighborsFilter::preflightImpl(const DataS std::vector dataArrayPaths; std::vector cDims = {1}; - auto& featureIdsArray = dataStructure.getDataRefAs(featureIdsPath); + auto& featureIds = dataStructure.getDataRefAs(featureIdsPath); auto& numNeighborsArray = dataStructure.getDataRefAs(numNeighborsPath); dataArrayPaths.push_back(numNeighborsPath); @@ -427,8 +408,7 @@ IFilter::PreflightResult RequireMinNumNeighborsFilter::preflightImpl(const DataS auto tupleValidityCheck = dataStructure.validateNumberOfTuples(dataArrayPaths); if(!tupleValidityCheck) { - return {MakeErrorResult(k_InconsistentTupleCount, - fmt::format("The following DataArrays all must have equal number of tuples but this was not satisfied.\n{}", tupleValidityCheck.error()))}; + return MakePreflightErrorResult(k_InconsistentTupleCount, fmt::format("The following DataArrays all must have equal number of tuples but this was not satisfied.\n{}", tupleValidityCheck.error())); } // Inform users that the following arrays are going to be modified in place @@ -462,10 +442,9 @@ Result<> RequireMinNumNeighborsFilter::executeImpl(DataStructure& dataStructure, // we don't have access to the data yet if(applyToSinglePhase) { - auto& featurePhasesArray = dataStructure.getDataRefAs(featurePhasesPath); - auto& featurePhases = featurePhasesArray.getDataStoreRef(); + auto& featurePhases = dataStructure.getDataAs(featurePhasesPath)->getDataStoreRef(); - usize numFeatures = featurePhasesArray.getNumberOfTuples(); + usize numFeatures = featurePhases.getNumberOfTuples(); bool unavailablePhase = true; for(usize i = 0; i < numFeatures; i++) { @@ -506,13 +485,13 @@ Result<> RequireMinNumNeighborsFilter::executeImpl(DataStructure& dataStructure, return assignBadPointsResult; } - auto& featureIdsArray = dataStructure.getDataRefAs(featureIdsPath); + auto& featureIdsStore = dataStructure.getDataAs(featureIdsPath)->getDataStoreRef(); auto numNeighborsPath = args.value(RequireMinNumNeighborsFilter::k_NumNeighborsPath_Key); - auto& numNeighborsArray = dataStructure.getDataRefAs(numNeighborsPath); + auto* numNeighborsArray = dataStructure.getDataAs(numNeighborsPath); DataPath cellFeatureGroupPath = numNeighborsPath.getParent(); - size_t currentFeatureCount = numNeighborsArray.getNumberOfTuples(); + size_t currentFeatureCount = numNeighborsArray->getNumberOfTuples(); auto activeObjects = activeObjectsResult.value(); int32 count = 0; @@ -523,7 +502,7 @@ Result<> RequireMinNumNeighborsFilter::executeImpl(DataStructure& dataStructure, 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, featureIdsArray, currentFeatureCount, messageHandler, shouldCancel); + nx::core::RemoveInactiveObjects(dataStructure, cellFeatureGroupPath, activeObjects, featureIdsStore, currentFeatureCount, messageHandler, shouldCancel); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RequireMinimumSizeFeaturesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RequireMinimumSizeFeaturesFilter.cpp index cae48b7e63..90b1ba1363 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RequireMinimumSizeFeaturesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RequireMinimumSizeFeaturesFilter.cpp @@ -5,16 +5,13 @@ #include "simplnx/Filter/Actions/DeleteDataAction.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" -#include "simplnx/Parameters/DataPathSelectionParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" #include "simplnx/Utilities/DataGroupUtilities.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" - -#include - #include "simplnx/Utilities/SIMPLConversion.hpp" +#include #include namespace nx::core @@ -29,15 +26,11 @@ namespace constexpr int32 k_BadMinAllowedFeatureSize = -5555; constexpr int32 k_BadNumCellsPath = -5556; constexpr int32 k_ParentlessPathError = -5557; -constexpr int32 k_NeighborListRemoval = -5558; -constexpr int32 k_FetchChildArrayError = -5559; -void assign_badpoints(DataStructure& dataStructure, const DataPath& featureIdsPath, SizeVec3 dimensions, const NumCellsArrayType& numCellsArrayRef) +void assign_badpoints(DataStructure& dataStructure, const DataPath& featureIdsPath, SizeVec3 dimensions, const NumCellsArrayType::store_type& numCellsStoreRef) { - FeatureIdsArrayType* featureIdsPtr = dataStructure.getDataAs(featureIdsPath); - - usize totalPoints = featureIdsPtr->getNumberOfTuples(); - FeatureIdsArrayType::store_type* featureIds = featureIdsPtr->getDataStore(); + FeatureIdsArrayType::store_type* featureIds = dataStructure.getDataAs(featureIdsPath)->getDataStore(); + usize totalPoints = featureIds->getNumberOfTuples(); std::array dims = { static_cast(dimensions[0]), @@ -45,7 +38,7 @@ void assign_badpoints(DataStructure& dataStructure, const DataPath& featureIdsPa static_cast(dimensions[2]), }; - std::vector neighbors(totalPoints * featureIdsPtr->getNumberOfComponents(), -1); + std::vector neighbors(totalPoints * featureIds->getNumberOfComponents(), -1); int32 good = 1; int32 current = 0; @@ -61,7 +54,7 @@ void assign_badpoints(DataStructure& dataStructure, const DataPath& featureIdsPa int32 featurename = 0; int32 feature = 0; int32 neighbor = 0; - std::vector n(numCellsArrayRef.getNumberOfTuples(), 0); + std::vector n(numCellsStoreRef.getNumberOfTuples(), 0); while(counter != 0) { @@ -165,7 +158,7 @@ void assign_badpoints(DataStructure& dataStructure, const DataPath& featureIdsPa } } DataPath attrMatPath = featureIdsPath.getParent(); - BaseGroup* parentGroup = dataStructure.getDataAs(attrMatPath); + auto* parentGroup = dataStructure.getDataAs(attrMatPath); std::vector voxelArrayNames; for(const auto& [identifier, sharedChild] : *parentGroup) { @@ -187,7 +180,7 @@ void assign_badpoints(DataStructure& dataStructure, const DataPath& featureIdsPa for(auto& voxelArrayName : voxelArrayNames) { auto arrayPath = attrMatPath.createChildPath(voxelArrayName); - IDataArray* arr = dataStructure.getDataAs(arrayPath); + auto* arr = dataStructure.getDataAs(arrayPath); arr->copyTuple(neighbor, j); } } @@ -197,23 +190,15 @@ void assign_badpoints(DataStructure& dataStructure, const DataPath& featureIdsPa } // ----------------------------------------------------------------------------- -std::vector remove_smallfeatures(FeatureIdsArrayType& featureIdsArrayRef, const NumCellsArrayType& numCellsArrayRef, const PhasesArrayType* featurePhaseArrayPtr, int32_t phaseNumber, - bool applyToSinglePhase, int64 minAllowedFeatureSize, Error& errorReturn) +std::vector remove_smallfeatures(FeatureIdsArrayType::store_type& featureIdsStoreRef, const NumCellsArrayType::store_type& numCells, const PhasesArrayType::store_type* featurePhases, + int32_t phaseNumber, bool applyToSinglePhase, int64 minAllowedFeatureSize, Error& errorReturn) { - size_t totalPoints = featureIdsArrayRef.getNumberOfTuples(); - FeatureIdsArrayType::store_type& featureIdsStoreRef = featureIdsArrayRef.getDataStoreRef(); + size_t totalPoints = featureIdsStoreRef.getNumberOfTuples(); bool good = false; int32 gnum; - size_t totalFeatures = numCellsArrayRef.getNumberOfTuples(); - const NumCellsArrayType::store_type& numCells = numCellsArrayRef.getDataStoreRef(); - - const PhasesArrayType::store_type* featurePhases = nullptr; - if(applyToSinglePhase) - { - featurePhases = featurePhaseArrayPtr->getDataStore(); - } + size_t totalFeatures = numCells.getNumberOfTuples(); std::vector activeObjects(totalFeatures, true); @@ -336,12 +321,12 @@ IFilter::PreflightResult RequireMinimumSizeFeaturesFilter::preflightImpl(const D return {nonstd::make_unexpected(std::vector{Error{-k_BadMinAllowedFeatureSize, ss}})}; } - const FeatureIdsArrayType* featureIdsPtr = dataStructure.getDataAs(featureIdsPath); + const auto* 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 = dataStructure.getDataAs(numCellsPath); + const auto* 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,7 +335,7 @@ IFilter::PreflightResult RequireMinimumSizeFeaturesFilter::preflightImpl(const D if(applyToSinglePhase) { - const PhasesArrayType* featurePhasesPtr = dataStructure.getDataAs(featurePhasesPath); + const auto* featurePhasesPtr = dataStructure.getDataAs(featurePhasesPath); if(featurePhasesPtr != nullptr) { dataArrayPaths.push_back(featurePhasesPath); @@ -360,7 +345,7 @@ IFilter::PreflightResult RequireMinimumSizeFeaturesFilter::preflightImpl(const D dataStructure.validateNumberOfTuples(dataArrayPaths); DataPath featureGroupDataPath = numCellsPath.getParent(); - const BaseGroup* featureDataGroup = dataStructure.getDataAs(featureGroupDataPath); + const auto* 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."}})}; @@ -397,18 +382,16 @@ Result<> RequireMinimumSizeFeaturesFilter::executeImpl(DataStructure& dataStruct auto minAllowedFeatureSize = args.value(k_MinAllowedFeaturesSize_Key); auto phaseNumber = args.value(k_PhaseNumber_Key); - PhasesArrayType* featurePhasesArray = applyToSinglePhase ? dataStructure.getDataAs(featurePhasesPath) : nullptr; + PhasesArrayType::store_type* featurePhases = applyToSinglePhase ? dataStructure.getDataAs(featurePhasesPath)->getDataStore() : nullptr; - FeatureIdsArrayType& featureIdsArrayRef = dataStructure.getDataRefAs(featureIdsPath); - FeatureIdsArrayType::store_type& featureIdsStoreRef = featureIdsArrayRef.getDataStoreRef(); + FeatureIdsArrayType::store_type& featureIdsStoreRef = dataStructure.getDataAs(featureIdsPath)->getDataStoreRef(); - NumCellsArrayType& numCellsArrayRef = dataStructure.getDataRefAs(numCellsPath); + auto& numCellsArrayRef = dataStructure.getDataRefAs(numCellsPath); NumCellsArrayType::store_type& numCellsStoreRef = numCellsArrayRef.getDataStoreRef(); - if(applyToSinglePhase) + if(applyToSinglePhase && featurePhases != nullptr) { - usize numFeatures = featurePhasesArray->getNumberOfTuples(); - auto featurePhases = featurePhasesArray->getDataStore(); + usize numFeatures = featurePhases->getNumberOfTuples(); bool unavailablePhase = true; for(size_t i = 0; i < numFeatures; i++) @@ -428,14 +411,14 @@ Result<> RequireMinimumSizeFeaturesFilter::executeImpl(DataStructure& dataStruct } Error errorReturn; - std::vector activeObjects = remove_smallfeatures(featureIdsArrayRef, numCellsArrayRef, featurePhasesArray, phaseNumber, applyToSinglePhase, minAllowedFeatureSize, errorReturn); + std::vector activeObjects = remove_smallfeatures(featureIdsStoreRef, numCellsStoreRef, featurePhases, phaseNumber, applyToSinglePhase, minAllowedFeatureSize, errorReturn); if(errorReturn.code < 0) { return {nonstd::make_unexpected(std::vector{errorReturn})}; } - ImageGeom& imageGeom = dataStructure.getDataRefAs(imageGeomPath); - assign_badpoints(dataStructure, featureIdsPath, imageGeom.getDimensions(), numCellsArrayRef); + auto& imageGeom = dataStructure.getDataRefAs(imageGeomPath); + assign_badpoints(dataStructure, featureIdsPath, imageGeom.getDimensions(), numCellsStoreRef); DataPath cellFeatureGroupPath = numCellsPath.getParent(); size_t currentFeatureCount = numCellsStoreRef.getNumberOfTuples(); @@ -451,7 +434,7 @@ Result<> RequireMinimumSizeFeaturesFilter::executeImpl(DataStructure& dataStruct 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, messageHandler, shouldCancel); + nx::core::RemoveInactiveObjects(dataStructure, cellFeatureGroupPath, activeObjects, featureIdsStoreRef, currentFeatureCount, messageHandler, shouldCancel); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleImageGeomFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleImageGeomFilter.cpp index aa2489b8ff..0e45c23637 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleImageGeomFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleImageGeomFilter.cpp @@ -21,9 +21,7 @@ #include "simplnx/Utilities/DataGroupUtilities.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" #include "simplnx/Utilities/GeometryHelpers.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Utilities/StringUtilities.hpp" using namespace nx::core; @@ -154,7 +152,7 @@ IFilter::PreflightResult ResampleImageGeomFilter::preflightImpl(const DataStruct { // Percentage has a non-positive value const std::string errMsg = fmt::format("Scaling Factor has a non-positive value. {}, {}, {}", pScalingFactorValue[0], pScalingFactorValue[1], pScalingFactorValue[2]); - return {MakeErrorResult(-11500, errMsg)}; + return MakePreflightErrorResult(-11500, errMsg); } const auto& imageGeom = dataStructure.getDataRefAs(srcImagePath); @@ -176,7 +174,7 @@ IFilter::PreflightResult ResampleImageGeomFilter::preflightImpl(const DataStruct { // Spacing has a negative value const std::string errMsg = fmt::format("Input Spacing has a negative value. {}, {}, {}", pSpacingValue[0], pSpacingValue[1], pSpacingValue[2]); - return {MakeErrorResult(-11502, errMsg)}; + return MakePreflightErrorResult(-11502, errMsg); } const auto* srcImageGeom = dataStructure.getDataAs(srcImagePath); @@ -235,7 +233,7 @@ IFilter::PreflightResult ResampleImageGeomFilter::preflightImpl(const DataStruct const AttributeMatrix* selectedCellData = srcImageGeom->getCellData(); if(selectedCellData == nullptr) { - return {MakeErrorResult(-5851, fmt::format("'{}' must have cell data attribute matrix", srcImagePath.toString()))}; + return MakePreflightErrorResult(-5851, fmt::format("'{}' must have cell data attribute matrix", srcImagePath.toString())); } std::string cellDataName = selectedCellData->getName(); ignorePaths.push_back(srcImagePath.createChildPath(cellDataName)); @@ -270,7 +268,7 @@ IFilter::PreflightResult ResampleImageGeomFilter::preflightImpl(const DataStruct const auto* srcCellFeatureData = dataStructure.getDataAs(cellFeatureAmPath); if(nullptr == srcCellFeatureData) { - return {MakeErrorResult(-55502, fmt::format("Could not find the selected Attribute Matrix '{}'", cellFeatureAmPath.toString()))}; + return MakePreflightErrorResult(-55502, fmt::format("Could not find the selected Attribute Matrix '{}'", cellFeatureAmPath.toString())); } std::string warningMsg; DataPath destCellFeatureAmPath = destImagePath.createChildPath(cellFeatureAmPath.getTargetName()); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleRectGridToImageGeomFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleRectGridToImageGeomFilter.cpp index 49432ed666..17415bf838 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleRectGridToImageGeomFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ResampleRectGridToImageGeomFilter.cpp @@ -6,7 +6,6 @@ #include "simplnx/DataStructure/Geometry/ImageGeom.hpp" #include "simplnx/DataStructure/Geometry/RectGridGeom.hpp" #include "simplnx/DataStructure/INeighborList.hpp" -#include "simplnx/DataStructure/StringArray.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Filter/Actions/CreateImageGeometryAction.hpp" #include "simplnx/Filter/Actions/CreateNeighborListAction.hpp" @@ -16,11 +15,8 @@ #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" #include "simplnx/Parameters/VectorParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" -#include "simplnx/Utilities/GeometryHelpers.hpp" - using namespace nx::core; namespace nx::core @@ -93,7 +89,6 @@ IFilter::PreflightResult ResampleRectGridToImageGeomFilter::preflightImpl(const auto pImageGeometryPathValue = filterArgs.value(k_ImageGeometryPath_Key); auto pImageGeomCellAttributeMatrixNameValue = filterArgs.value(k_ImageGeomCellAttributeMatrixName_Key); - PreflightResult preflightResult; Result resultOutputActions; std::vector preflightUpdatedValues; @@ -219,9 +214,7 @@ namespace SIMPL { constexpr StringLiteral k_RectilinearGridPathKey = "RectilinearGridPath"; constexpr StringLiteral k_SelectedDataArrayPathsKey = "SelectedDataArrayPaths"; -constexpr StringLiteral k_RectGridGeometryDescKey = "RectGridGeometryDesc"; constexpr StringLiteral k_DimensionsKey = "Dimensions"; -constexpr StringLiteral k_CreatedGeometryDescriptionKey = "CreatedGeometryDescription"; constexpr StringLiteral k_ImageGeometryPathKey = "ImageGeometryPath"; constexpr StringLiteral k_ImageGeomCellAttributeMatrixKey = "ImageGeomCellAttributeMatrix"; } // namespace SIMPL diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReverseTriangleWindingFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReverseTriangleWindingFilter.cpp index 7af50ff6ab..1818084c94 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReverseTriangleWindingFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ReverseTriangleWindingFilter.cpp @@ -19,7 +19,8 @@ namespace class ReverseWindingImpl { public: - explicit ReverseWindingImpl(TriangleGeom::SharedFaceList& triangles) + using TriStore = AbstractDataStore; + explicit ReverseWindingImpl(TriStore& triangles) : m_Triangles(triangles) { } @@ -45,7 +46,7 @@ class ReverseWindingImpl } private: - TriangleGeom::SharedFaceList& m_Triangles; + TriStore& m_Triangles; }; } // namespace @@ -104,11 +105,7 @@ IFilter::UniquePointer ReverseTriangleWindingFilter::clone() const IFilter::PreflightResult ReverseTriangleWindingFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - - // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ @@ -119,7 +116,7 @@ Result<> ReverseTriangleWindingFilter::executeImpl(DataStructure& dataStructure, ParallelDataAlgorithm dataAlg; dataAlg.setRange(0, triangleGeom.getNumberOfFaces()); - dataAlg.execute(ReverseWindingImpl(triangleGeom.getFacesRef())); + dataAlg.execute(ReverseWindingImpl(triangleGeom.getFaces()->getDataStoreRef())); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RobustAutomaticThresholdFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RobustAutomaticThresholdFilter.cpp index 0a7ae21c83..99227fa5f2 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RobustAutomaticThresholdFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RobustAutomaticThresholdFilter.cpp @@ -5,10 +5,9 @@ #include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/DataObjectNameParameter.hpp" +#include "simplnx/Utilities/FilterUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" namespace fs = std::filesystem; using namespace nx::core; @@ -18,83 +17,37 @@ namespace constexpr int32 k_IncorrectInputArrayType = -2363; constexpr int32 k_InconsistentTupleCount = -2364; -template -void FindThreshold(const DataArray& inputArray, const Float32Array& gradMagnitudeArray, BoolArray& maskArray) +struct FindThresholdFunctor { - const AbstractDataStore& inputData = inputArray.getDataStoreRef(); - const AbstractDataStore& gradMag = gradMagnitudeArray.getDataStoreRef(); - AbstractDataStore& maskStore = maskArray.getDataStoreRef(); - - usize numTuples = inputArray.getNumberOfTuples(); - float numerator = 0; - float denominator = 0; - - for(usize i = 0; i < numTuples; i++) + template + void operator()(const IDataArray* inputObject, const Float32AbstractDataStore& gradMag, BoolAbstractDataStore& maskStore) { - numerator += (inputData.getValue(i) * gradMag.getValue(i)); - denominator += gradMag.getValue(i); - } - - float threshold = numerator / denominator; + const auto& inputData = inputObject->template getIDataStoreRefAs>(); + usize numTuples = inputData.getNumberOfTuples(); + float numerator = 0; + float denominator = 0; - for(usize i = 0; i < numTuples; i++) - { - if(inputData.getValue(i) < threshold) + for(usize i = 0; i < numTuples; i++) { - maskStore.setValue(i, 0); + numerator += (inputData.getValue(i) * gradMag.getValue(i)); + denominator += gradMag.getValue(i); } - else - { - maskStore.setValue(i, 1); - } - } -} - -void FindThreshold(const IDataArray& inputObject, const Float32Array& gradMagnitudeArray, BoolArray& maskArray) -{ - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); - } - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); - } - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); - } - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); - } - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); - } - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); - } - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); - } - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); - } + float threshold = numerator / denominator; - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); - } - if(auto inputArray = dynamic_cast(&inputObject); inputArray != nullptr) - { - FindThreshold(*inputArray, gradMagnitudeArray, maskArray); + for(usize i = 0; i < numTuples; i++) + { + if(inputData.getValue(i) < threshold) + { + maskStore.setValue(i, false); + } + else + { + maskStore.setValue(i, true); + } + } } -} +}; } // namespace namespace nx::core @@ -197,11 +150,11 @@ Result<> RobustAutomaticThresholdFilter::executeImpl(DataStructure& dataStructur auto gradientArrayPath = args.value(k_GradientMagnitudePath_Key); auto createdMaskName = args.value(k_ArrayCreationName_Key); - const auto& inputArray = dataStructure.getDataRefAs(inputArrayPath); - const auto& gradientArray = dataStructure.getDataRefAs(gradientArrayPath); - auto& maskArray = dataStructure.getDataRefAs(inputArrayPath.replaceName(createdMaskName)); + const auto* inputArray = dataStructure.getDataAs(inputArrayPath); + const auto& gradientStore = dataStructure.getDataAs(gradientArrayPath)->getDataStoreRef(); + auto& maskStore = dataStructure.getDataAs(inputArrayPath.replaceName(createdMaskName))->getDataStoreRef(); - FindThreshold(inputArray, gradientArray, maskArray); + ExecuteNeighborFunction(FindThresholdFunctor{}, inputArray->getDataType(), inputArray, gradientStore, maskStore); return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RotateSampleRefFrameFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RotateSampleRefFrameFilter.cpp index 469d734bef..d7e665bee7 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RotateSampleRefFrameFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/RotateSampleRefFrameFilter.cpp @@ -1,9 +1,6 @@ #include "RotateSampleRefFrameFilter.hpp" -#include "simplnx/Common/Constants.hpp" -#include "simplnx/Common/Numbers.hpp" #include "simplnx/Common/Range.hpp" -#include "simplnx/Common/Range3D.hpp" #include "simplnx/Common/TypeTraits.hpp" #include "simplnx/DataStructure/Geometry/ImageGeom.hpp" #include "simplnx/DataStructure/INeighborList.hpp" @@ -21,12 +18,9 @@ #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/ImageRotationUtilities.hpp" -#include "simplnx/Utilities/Math/MatrixMath.hpp" #include "simplnx/Utilities/ParallelAlgorithmUtilities.hpp" -#include "simplnx/Utilities/ParallelData3DAlgorithm.hpp" #include "simplnx/Utilities/ParallelTaskAlgorithm.hpp" #include "simplnx/Utilities/StringUtilities.hpp" @@ -34,12 +28,8 @@ #include -#include - #include #include -#include -#include #include "simplnx/Utilities/SIMPLConversion.hpp" @@ -545,7 +535,6 @@ Result<> RotateSampleRefFrameFilter::executeImpl(DataStructure& dataStructure, c const auto& srcCellDataAM = srcImageGeom.getCellDataRef(); const DataPath destCellDataAMPath = destImageGeom.getCellDataPath(); - auto& destCellDataAM = destImageGeom.getCellDataRef(); for(const auto& [dataId, srcDataObject] : srcCellDataAM) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ScalarSegmentFeaturesFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ScalarSegmentFeaturesFilter.cpp index 61a8d30811..c4a54e32ea 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ScalarSegmentFeaturesFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/ScalarSegmentFeaturesFilter.cpp @@ -9,10 +9,8 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/NumberParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -24,14 +22,10 @@ using namespace nx::core; namespace { -using FeatureIdsArrayType = Int32Array; -using GoodVoxelsArrayType = BoolArray; - constexpr int64 k_IncorrectInputArray = -600; constexpr int64 k_MissingInputArray = -601; constexpr int64 k_MissingOrIncorrectGoodVoxelsArray = -602; constexpr int32 k_MissingGeomError = -440; - } // namespace namespace nx::core @@ -102,7 +96,6 @@ IFilter::PreflightResult ScalarSegmentFeaturesFilter::preflightImpl(const DataSt const std::atomic_bool& shouldCancel) const { auto inputDataPath = args.value(k_InputArrayPathKey); - int scalarTolerance = args.value(k_ScalarToleranceKey); auto featureIdsName = args.value(k_FeatureIdsName_Key); auto cellFeaturesName = args.value(k_CellFeatureName_Key); auto activeArrayName = args.value(k_ActiveArrayName_Key); @@ -172,13 +165,12 @@ IFilter::PreflightResult ScalarSegmentFeaturesFilter::preflightImpl(const DataSt auto createActiveAction = std::make_unique(DataType::uint8, std::vector{1}, std::vector{1}, activeArrayPath, createdArrayFormat); nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; resultOutputActions.value().appendAction(std::move(createFeatureGroupAction)); resultOutputActions.value().appendAction(std::move(createActiveAction)); resultOutputActions.value().appendAction(std::move(createFeatureIdsAction)); - return {resultOutputActions, preflightUpdatedValues}; + return {std::move(resultOutputActions)}; } // ----------------------------------------------------------------------------- diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SetImageGeomOriginScalingFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SetImageGeomOriginScalingFilter.cpp index f824e1ce4e..f741588220 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SetImageGeomOriginScalingFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SetImageGeomOriginScalingFilter.cpp @@ -6,16 +6,14 @@ #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/VectorParameter.hpp" #include "simplnx/Utilities/GeometryHelpers.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" #include -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include namespace nx::core { - //------------------------------------------------------------------------------ std::string SetImageGeomOriginScalingFilter::name() const { @@ -56,11 +54,11 @@ Parameters SetImageGeomOriginScalingFilter::parameters() const params.insertLinkableParameter(std::make_unique(k_ChangeOrigin_Key, "Set Origin", "Specifies if the origin should be changed", true)); params.insert( std::make_unique(k_CenterOrigin_Key, "Put Input Origin at the Center of Geometry", "Specifies if the origin should be aligned with the corner (false) or center (true)", false)); - params.insert(std::make_unique(k_Origin_Key, "Origin (Physical Units)", "Specifies the new origin values in physical units.", std::vector{0.0, 0.0, 0.0}, + params.insert(std::make_unique(k_Origin_Key, "Origin (Physical Units)", "Specifies the new origin values in physical units.", std::vector{0.0f, 0.0f, 0.0f}, std::vector{"X", "Y", "Z"})); params.insertLinkableParameter(std::make_unique(k_ChangeSpacing_Key, "Set Spacing", "Specifies if the spacing should be changed", true)); - params.insert(std::make_unique(k_Spacing_Key, "Spacing (Physical Units)", "Specifies the new spacing values in physical units.", std::vector{1, 1, 1}, + params.insert(std::make_unique(k_Spacing_Key, "Spacing (Physical Units)", "Specifies the new spacing values in physical units.", std::vector{1.0f, 1.0f, 1.0f}, std::vector{"X", "Y", "Z"})); params.linkParameters(k_ChangeOrigin_Key, k_Origin_Key, std::make_any(true)); @@ -83,8 +81,8 @@ IFilter::PreflightResult SetImageGeomOriginScalingFilter::preflightImpl(const Da auto shouldChangeOrigin = filterArgs.value(k_ChangeOrigin_Key); auto shouldCenterOrigin = filterArgs.value(k_CenterOrigin_Key); auto shouldChangeSpacing = filterArgs.value(k_ChangeSpacing_Key); - auto origin = filterArgs.value>(k_Origin_Key); - auto spacing = filterArgs.value>(k_Spacing_Key); + auto origin = filterArgs.value>(k_Origin_Key); + auto spacing = filterArgs.value>(k_Spacing_Key); std::optional optOrigin; std::optional optSpacing; @@ -150,9 +148,9 @@ Result SetImageGeomOriginScalingFilter::FromSIMPLJson(const nlohmann: results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_DataContainerNameKey, k_SelectedImageGeometryPath_Key)); results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_ChangeOriginKey, k_ChangeOrigin_Key)); - results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_OriginKey, k_Origin_Key)); + results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_OriginKey, k_Origin_Key)); results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_ChangeResolutionKey, k_ChangeSpacing_Key)); - results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_SpacingKey, k_Spacing_Key)); + results.push_back(SIMPLConversion::ConvertParameter(args, json, SIMPL::k_SpacingKey, k_Spacing_Key)); Result<> conversionResult = MergeResults(std::move(results)); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SharedFeatureFaceFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SharedFeatureFaceFilter.cpp index 34160f32ac..5ef61577b0 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SharedFeatureFaceFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SharedFeatureFaceFilter.cpp @@ -84,13 +84,11 @@ IFilter::PreflightResult SharedFeatureFaceFilter::preflightImpl(const DataStruct { auto triangleGeometryPath = filterArgs.value(k_TriGeometryDataPath_Key); auto pFaceLabelsArrayPathValue = filterArgs.value(k_FaceLabelsArrayPath_Key); - auto featureFaceIdsArrayName = filterArgs.value(k_FeatureFaceIdsArrayName_Key); auto grainBoundaryAttributeMatrixName = filterArgs.value(k_GrainBoundaryAttributeMatrixName_Key); auto featureNumTrianglesArrayName = filterArgs.value(k_FeatureNumTrianglesArrayName_Key); auto featureFaceLabelsArrayName = filterArgs.value(k_FeatureFaceLabelsArrayName_Key); - PreflightResult preflightResult; const std::vector tDims = {1}; nx::core::Result resultOutputActions; @@ -132,11 +130,8 @@ IFilter::PreflightResult SharedFeatureFaceFilter::preflightImpl(const DataStruct resultOutputActions.value().appendAction(std::move(createArrayAction)); } - // No preflight updated values are generated in this filter - std::vector preflightUpdatedValues; - // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SilhouetteFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SilhouetteFilter.cpp index b200b6bacf..a0b143c0e6 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SilhouetteFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SilhouetteFilter.cpp @@ -12,10 +12,8 @@ #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/ChoicesParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Utilities/ClusteringUtilities.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -102,9 +100,7 @@ IFilter::PreflightResult SilhouetteFilter::preflightImpl(const DataStructure& da auto pFeatureIdsArrayPathValue = filterArgs.value(k_FeatureIdsArrayPath_Key); auto pSilhouetteArrayPathValue = filterArgs.value(k_SilhouetteArrayPath_Key); - PreflightResult preflightResult; nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; auto clusterArray = dataStructure.getDataAs(pSelectedArrayPathValue); auto clusterIds = dataStructure.getDataAs(pFeatureIdsArrayPathValue); @@ -131,7 +127,7 @@ IFilter::PreflightResult SilhouetteFilter::preflightImpl(const DataStructure& da } // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SliceTriangleGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SliceTriangleGeometryFilter.cpp index 0860416eff..4532866d9d 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SliceTriangleGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SliceTriangleGeometryFilter.cpp @@ -18,7 +18,6 @@ using namespace nx::core; namespace { -constexpr ChoicesParameter::ValueType k_FullRange = 0; constexpr ChoicesParameter::ValueType k_UserDefinedRange = 1; } // namespace @@ -61,15 +60,13 @@ Parameters SliceTriangleGeometryFilter::parameters() const // Create the parameter descriptors that are needed for this filter params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); - // params.insert(std::make_unique(k_SliceDirection_Key, "Slice Direction (ijk)", "Direction on which to slice the Triangle Geometry", std::vector{0.0F, 0.0F, 1.0F}, - // std::vector{"i", "j", "k"})); params.insertLinkableParameter(std::make_unique(k_SliceRange_Key, "Slice Range", "Type of slice range to use, either Full Range or User Defined Range", 0, ChoicesParameter::Choices{"Full Range", "User Defined Range"})); params.insert(std::make_unique(k_Zstart_Key, "Slicing Start", "The z axis start value", 0.0f)); params.insert(std::make_unique(k_Zend_Key, "Slicing End", "The z axis stop value", 0.0)); params.insert(std::make_unique(k_SliceResolution_Key, "Slice Spacing", "The spacing between slices", 1.0f)); - params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); + params.insertSeparator(Parameters::Separator{"Input Geometry"}); params.insert(std::make_unique(k_TriangleGeometryDataPath_Key, "Triangle Geometry", "The input triangle geometry to be sliced", DataPath{}, GeometrySelectionParameter::AllowedTypes{IGeometry::Type::Triangle})); @@ -105,7 +102,6 @@ IFilter::UniquePointer SliceTriangleGeometryFilter::clone() const IFilter::PreflightResult SliceTriangleGeometryFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - // auto pSliceDirectionValue = filterArgs.value(k_SliceDirection_Key); auto pSliceRangeValue = filterArgs.value(k_SliceRange_Key); auto pZStartValue = filterArgs.value(k_Zstart_Key); auto pZEndValue = filterArgs.value(k_Zend_Key); @@ -117,9 +113,7 @@ IFilter::PreflightResult SliceTriangleGeometryFilter::preflightImpl(const DataSt auto pSliceIdArrayNameValue = filterArgs.value(k_SliceIdArrayName_Key); auto pSliceAttributeMatrixNameValue = filterArgs.value(k_SliceAttributeMatrixName_Key); - PreflightResult preflightResult; Result resultOutputActions; - std::vector preflightUpdatedValues; if(pSliceRangeValue == k_UserDefinedRange) { @@ -158,7 +152,7 @@ IFilter::PreflightResult SliceTriangleGeometryFilter::preflightImpl(const DataSt } // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ @@ -167,7 +161,6 @@ Result<> SliceTriangleGeometryFilter::executeImpl(DataStructure& dataStructure, { SliceTriangleGeometryInputValues inputValues; - // inputValues.SliceDirection = filterArgs.value(k_SliceDirection_Key); inputValues.SliceRange = filterArgs.value(k_SliceRange_Key); inputValues.Zstart = filterArgs.value(k_Zstart_Key); inputValues.Zend = filterArgs.value(k_Zend_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SplitAttributeArrayFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SplitAttributeArrayFilter.cpp index 0e87450b53..3058359dbd 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SplitAttributeArrayFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SplitAttributeArrayFilter.cpp @@ -10,9 +10,7 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DynamicTableParameter.hpp" #include "simplnx/Parameters/StringParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Utilities/StringUtilities.hpp" using namespace nx::core; @@ -108,7 +106,7 @@ IFilter::PreflightResult SplitAttributeArrayFilter::preflightImpl(const DataStru auto pExtractComponents = filterArgs.value(k_ComponentsToExtract_Key)[0]; for(const auto& comp : pExtractComponents) { - usize compIndex = static_cast(comp); + auto compIndex = static_cast(comp); if(comp >= numComponents || comp < 0) { return {nonstd::make_unexpected(std::vector{Error{ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SurfaceNetsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SurfaceNetsFilter.cpp index 78b98dab8d..627ae9d82f 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SurfaceNetsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SurfaceNetsFilter.cpp @@ -7,7 +7,6 @@ #include "simplnx/DataStructure/Geometry/INodeGeometry0D.hpp" #include "simplnx/DataStructure/Geometry/INodeGeometry1D.hpp" #include "simplnx/DataStructure/Geometry/INodeGeometry2D.hpp" -#include "simplnx/Filter/Actions/CopyArrayInstanceAction.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Filter/Actions/CreateAttributeMatrixAction.hpp" #include "simplnx/Filter/Actions/CreateGeometry2DAction.hpp" @@ -15,7 +14,6 @@ #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/DataGroupCreationParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" -#include "simplnx/Parameters/DataPathSelectionParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" @@ -124,9 +122,7 @@ IFilter::PreflightResult SurfaceNetsFilter::preflightImpl(const DataStructure& d DataPath pVertexGroupDataPath = pTriangleGeometryPath.createChildPath(pVertexGroupDataName); DataPath pFaceGroupDataPath = pTriangleGeometryPath.createChildPath(pFaceGroupDataName); - PreflightResult preflightResult; nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; const auto* gridGeom = dataStructure.getDataAs(pGridGeomDataPath); if(gridGeom == nullptr) @@ -177,7 +173,7 @@ IFilter::PreflightResult SurfaceNetsFilter::preflightImpl(const DataStructure& d resultOutputActions.value().appendAction(std::move(createFeatureGroupAction)); } - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleCentroidFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleCentroidFilter.cpp index b3c86d958a..39671a22af 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleCentroidFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleCentroidFilter.cpp @@ -6,10 +6,8 @@ #include "simplnx/DataStructure/Geometry/TriangleGeom.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/GeometrySelectionParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; namespace @@ -75,12 +73,9 @@ IFilter::UniquePointer TriangleCentroidFilter::clone() const IFilter::PreflightResult TriangleCentroidFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pTriangleGeometryDataPath = filterArgs.value(k_TriGeometryDataPath_Key); auto pCentroidsArrayName = filterArgs.value(k_CentroidsArrayName_Key); - std::vector preflightUpdatedValues; - nx::core::Result resultOutputActions; const auto* triangleGeom = dataStructure.getDataAs(pTriangleGeometryDataPath); @@ -100,14 +95,13 @@ IFilter::PreflightResult TriangleCentroidFilter::preflightImpl(const DataStructu } // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ Result<> TriangleCentroidFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - TriangleCentroidInputValues inputValues; inputValues.TriangleGeometryDataPath = filterArgs.value(k_TriGeometryDataPath_Key); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleDihedralAngleFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleDihedralAngleFilter.cpp index 181ff810a0..53712375ea 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleDihedralAngleFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleDihedralAngleFilter.cpp @@ -10,7 +10,6 @@ #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Utilities/Math/MatrixMath.hpp" #include "simplnx/Utilities/ParallelDataAlgorithm.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -29,7 +28,7 @@ constexpr nx::core::int32 k_MissingFeatureAttributeMatrix = -76970; class CalculateDihedralAnglesImpl { public: - CalculateDihedralAnglesImpl(const TriangleGeom* triangleGeom, Float64Array& dihedralAngles, const std::atomic_bool& shouldCancel) + CalculateDihedralAnglesImpl(const TriangleGeom* triangleGeom, Float64AbstractDataStore& dihedralAngles, const std::atomic_bool& shouldCancel) : m_TriangleGeom(triangleGeom) , m_DihedralAngles(dihedralAngles) , m_ShouldCancel(shouldCancel) @@ -39,11 +38,6 @@ class CalculateDihedralAnglesImpl void generate(size_t start, size_t end) const { - - const IGeometry::SharedVertexList* mNodes = m_TriangleGeom->getVertices(); - const IGeometry::SharedTriList* mTriangles = m_TriangleGeom->getFaces(); - - IGeometry::MeshIndexType nIdx0 = 0, nIdx1 = 0, nIdx2 = 0; // std::array vectorEx = {x, y, z}; // coordinate example std::array vecAB = {0.0f, 0.0f, 0.0f}; std::array vecAC = {0.0f, 0.0f, 0.0f}; @@ -99,7 +93,7 @@ class CalculateDihedralAnglesImpl private: const TriangleGeom* m_TriangleGeom = nullptr; - Float64Array& m_DihedralAngles; + Float64AbstractDataStore& m_DihedralAngles; const std::atomic_bool& m_ShouldCancel; }; } // namespace @@ -167,8 +161,6 @@ IFilter::PreflightResult TriangleDihedralAngleFilter::preflightImpl(const DataSt nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - const auto* triangleGeom = dataStructure.getDataAs(pTriangleGeometryDataPath); if(triangleGeom == nullptr) { @@ -190,7 +182,7 @@ IFilter::PreflightResult TriangleDihedralAngleFilter::preflightImpl(const DataSt } // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ @@ -203,7 +195,7 @@ Result<> TriangleDihedralAngleFilter::executeImpl(DataStructure& dataStructure, const TriangleGeom* triangleGeom = dataStructure.getDataAs(pTriangleGeometryDataPath); const AttributeMatrix* faceAttributeMatrix = triangleGeom->getFaceAttributeMatrix(); const DataPath dihedralAnglesArrayPath = pTriangleGeometryDataPath.createChildPath(faceAttributeMatrix->getName()).createChildPath(pMinDihedralAnglesName); - auto& dihedralAngles = dataStructure.getDataRefAs(dihedralAnglesArrayPath); + auto& dihedralAngles = dataStructure.getDataAs(dihedralAnglesArrayPath)->getDataStoreRef(); ParallelDataAlgorithm dataAlg; dataAlg.setRange(0ULL, static_cast(triangleGeom->getNumberOfFaces())); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleNormalFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleNormalFilter.cpp index 4c0016f919..abcfef75ff 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleNormalFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/TriangleNormalFilter.cpp @@ -8,7 +8,6 @@ #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Utilities/Math/MatrixMath.hpp" #include "simplnx/Utilities/ParallelDataAlgorithm.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" using namespace nx::core; @@ -25,7 +24,7 @@ constexpr nx::core::int32 k_MissingFeatureAttributeMatrix = -75969; class CalculateNormalsImpl { public: - CalculateNormalsImpl(const TriangleGeom* triangleGeom, Float64Array& normals, const std::atomic_bool& shouldCancel) + CalculateNormalsImpl(const TriangleGeom* triangleGeom, Float64AbstractDataStore& normals, const std::atomic_bool& shouldCancel) : m_TriangleGeom(triangleGeom) , m_Normals(normals) , m_ShouldCancel(shouldCancel) @@ -65,7 +64,7 @@ class CalculateNormalsImpl private: const TriangleGeom* m_TriangleGeom = nullptr; - Float64Array& m_Normals; + Float64AbstractDataStore& m_Normals; const std::atomic_bool& m_ShouldCancel; }; } // namespace @@ -131,8 +130,6 @@ IFilter::PreflightResult TriangleNormalFilter::preflightImpl(const DataStructure auto pTriangleGeometryDataPath = filterArgs.value(k_TriGeometryDataPath_Key); auto pNormalsArrayName = filterArgs.value(k_SurfaceMeshTriangleNormalsArrayName_Key); - std::vector preflightUpdatedValues; - nx::core::Result resultOutputActions; const auto* triangleGeom = dataStructure.getDataAs(pTriangleGeometryDataPath); @@ -152,7 +149,7 @@ IFilter::PreflightResult TriangleNormalFilter::preflightImpl(const DataStructure } // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ @@ -166,7 +163,7 @@ Result<> TriangleNormalFilter::executeImpl(DataStructure& dataStructure, const A const AttributeMatrix* faceAttributeMatrix = triangleGeom->getFaceAttributeMatrix(); DataPath pNormalsArrayPath = pTriangleGeometryDataPath.createChildPath(faceAttributeMatrix->getName()).createChildPath(pNormalsName); - auto& normals = dataStructure.getDataRefAs(pNormalsArrayPath); + auto& normals = dataStructure.getDataAs(pNormalsArrayPath)->getDataStoreRef(); // Parallel algorithm to find duplicate nodes ParallelDataAlgorithm dataAlg; diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp index adf62a611e..06bdc677ed 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/UncertainRegularGridSampleSurfaceMeshFilter.cpp @@ -13,7 +13,6 @@ #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" #include "simplnx/Parameters/VectorParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -113,9 +112,7 @@ IFilter::PreflightResult UncertainRegularGridSampleSurfaceMeshFilter::preflightI auto pFeatureIdsArrayNameValue = filterArgs.value(k_FeatureIdsArrayName_Key); auto pSeedArrayNameValue = filterArgs.value(k_SeedArrayName_Key); - PreflightResult preflightResult; nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; std::vector tupleDims = {static_cast(pDimensionsValue[0]), static_cast(pDimensionsValue[1]), static_cast(pDimensionsValue[2])}; @@ -141,7 +138,7 @@ IFilter::PreflightResult UncertainRegularGridSampleSurfaceMeshFilter::preflightI } // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteASCIIDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteASCIIDataFilter.cpp index 846f8c339a..cc0172b76a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteASCIIDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteASCIIDataFilter.cpp @@ -10,11 +10,9 @@ #include "simplnx/Utilities/DataArrayUtilities.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" #include "simplnx/Utilities/OStreamUtilities.hpp" - -#include - #include "simplnx/Utilities/SIMPLConversion.hpp" +#include #include namespace fs = std::filesystem; @@ -107,13 +105,6 @@ IFilter::PreflightResult WriteASCIIDataFilter::preflightImpl(const DataStructure { auto pOutputStyleValue = filterArgs.value(k_OutputStyle_Key); - // Declare the preflightResult variable - PreflightResult preflightResult; - - nx::core::Result resultOutputActions; - - std::vector preflightUpdatedValues; - ///////////////////////////////////////////////////////////////////////////// // VALIDATE THAT ALL DATA ARRAYS HAVE THE SAME NUMBER OF TUPLES. if(static_cast(pOutputStyleValue) == WriteASCIIDataFilter::OutputStyle::SingleFile) @@ -130,8 +121,7 @@ IFilter::PreflightResult WriteASCIIDataFilter::preflightImpl(const DataStructure } } - // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAbaqusHexahedronFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAbaqusHexahedronFilter.cpp index f224f6eec3..402996df34 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAbaqusHexahedronFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAbaqusHexahedronFilter.cpp @@ -8,10 +8,8 @@ #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" - -#include "simplnx/Utilities/SIMPLConversion.hpp" - #include "simplnx/Parameters/StringParameter.hpp" +#include "simplnx/Utilities/SIMPLConversion.hpp" namespace fs = std::filesystem; using namespace nx::core; @@ -81,16 +79,7 @@ IFilter::UniquePointer WriteAbaqusHexahedronFilter::clone() const IFilter::PreflightResult WriteAbaqusHexahedronFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pHourglassStiffnessValue = filterArgs.value(k_HourglassStiffness_Key); - auto pJobNameValue = filterArgs.value(k_JobName_Key); auto pOutputPathValue = filterArgs.value(k_OutputPath_Key); - auto pFilePrefixValue = filterArgs.value(k_FilePrefix_Key); - auto pFeatureIdsArrayPathValue = filterArgs.value(k_FeatureIdsArrayPath_Key); - auto pHexahedralGeometryPathValue = filterArgs.value(k_ImageGeometryPath_Key); - - PreflightResult preflightResult; - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; // Check Output Path if(!fs::exists(pOutputPathValue)) @@ -105,8 +94,7 @@ IFilter::PreflightResult WriteAbaqusHexahedronFilter::preflightImpl(const DataSt } } - // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAvizoRectilinearCoordinateFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAvizoRectilinearCoordinateFilter.cpp index a0483ba383..827f88ca96 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAvizoRectilinearCoordinateFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAvizoRectilinearCoordinateFilter.cpp @@ -10,7 +10,6 @@ #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/StringParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -79,16 +78,7 @@ IFilter::UniquePointer WriteAvizoRectilinearCoordinateFilter::clone() const IFilter::PreflightResult WriteAvizoRectilinearCoordinateFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pOutputFileValue = filterArgs.value(k_OutputFile_Key); - auto pWriteBinaryFileValue = filterArgs.value(k_WriteBinaryFile_Key); - auto pFeatureIdsArrayPathValue = filterArgs.value(k_FeatureIdsArrayPath_Key); - auto pUnitsValue = filterArgs.value(k_Units_Key); - - PreflightResult preflightResult; - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAvizoUniformCoordinateFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAvizoUniformCoordinateFilter.cpp index 0bb515b589..de040f705c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAvizoUniformCoordinateFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteAvizoUniformCoordinateFilter.cpp @@ -10,7 +10,6 @@ #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/StringParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -79,16 +78,7 @@ IFilter::UniquePointer WriteAvizoUniformCoordinateFilter::clone() const IFilter::PreflightResult WriteAvizoUniformCoordinateFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pOutputFileValue = filterArgs.value(k_OutputFile_Key); - auto pWriteBinaryFileValue = filterArgs.value(k_WriteBinaryFile_Key); - auto pFeatureIdsArrayPathValue = filterArgs.value(k_FeatureIdsArrayPath_Key); - auto pUnitsValue = filterArgs.value(k_Units_Key); - - PreflightResult preflightResult; - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteBinaryDataFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteBinaryDataFilter.cpp index 243356a3f6..28c9a5c679 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteBinaryDataFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteBinaryDataFilter.cpp @@ -96,18 +96,7 @@ IFilter::UniquePointer WriteBinaryDataFilter::clone() const IFilter::PreflightResult WriteBinaryDataFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pEndianessValue = filterArgs.value(k_Endianess_Key); - auto pOutputPathValue = filterArgs.value(k_OutputPath_Key); - auto pFileExtensionValue = filterArgs.value(k_FileExtension_Key); - auto pSelectedDataArrayPathsValue = filterArgs.value(k_SelectedDataArrayPaths_Key); - - PreflightResult preflightResult; - - nx::core::Result resultOutputActions; - - std::vector preflightUpdatedValues; - - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ @@ -129,7 +118,7 @@ Result<> WriteBinaryDataFilter::executeImpl(DataStructure& dataStructure, const } } - fs::path dirPath(filterArgs.value(k_OutputPath_Key)); + auto dirPath = filterArgs.value(k_OutputPath_Key); // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path Result<> createDirectoriesResult = nx::core::CreateOutputDirectories(dirPath); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteDREAM3DFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteDREAM3DFilter.cpp index d514eebbfb..f52da2c126 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteDREAM3DFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteDREAM3DFilter.cpp @@ -7,7 +7,6 @@ #include "simplnx/Pipeline/Pipeline.hpp" #include "simplnx/Pipeline/PipelineFilter.hpp" #include "simplnx/Utilities/Parsing/DREAM3D/Dream3dIO.hpp" -#include "simplnx/Utilities/Parsing/HDF5/Writers/FileWriter.hpp" #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -75,7 +74,7 @@ IFilter::PreflightResult WriteDREAM3DFilter::preflightImpl(const DataStructure& auto exportFilePath = args.value(k_ExportFilePath); if(exportFilePath.empty()) { - return {nonstd::make_unexpected(std::vector{Error{k_NoExportPathError, "Export file path not provided."}})}; + return MakePreflightErrorResult(k_NoExportPathError, "Export file path not provided."); } return {}; } @@ -101,7 +100,7 @@ Result<> WriteDREAM3DFilter::executeImpl(DataStructure& dataStructure, const Arg auto pipelinePtr = pipelineNode->getPrecedingPipeline(); if(pipelinePtr == nullptr) { - return {nonstd::make_unexpected(std::vector{Error{k_FailedFindPipelineError, "Failed to retrieve pipeline."}})}; + return MakeErrorResult(k_FailedFindPipelineError, "Failed to retrieve pipeline."); } pipeline = *pipelinePtr; @@ -136,7 +135,6 @@ namespace SIMPL { constexpr StringLiteral k_OutputFileKey = "OutputFile"; constexpr StringLiteral k_WriteXdmfFileKey = "WriteXdmfFile"; -constexpr StringLiteral k_WriteTimeSeriesKey = "WriteTimeSeries"; } // namespace SIMPL } // namespace diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteFeatureDataCSVFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteFeatureDataCSVFilter.cpp index 555ee7e544..baf0fa595a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteFeatureDataCSVFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteFeatureDataCSVFilter.cpp @@ -10,11 +10,9 @@ #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Utilities/DataGroupUtilities.hpp" #include "simplnx/Utilities/OStreamUtilities.hpp" - -#include - #include "simplnx/Utilities/SIMPLConversion.hpp" +#include #include namespace fs = std::filesystem; @@ -82,13 +80,7 @@ IFilter::UniquePointer WriteFeatureDataCSVFilter::clone() const IFilter::PreflightResult WriteFeatureDataCSVFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - PreflightResult preflightResult; - - nx::core::Result resultOutputActions; - - std::vector preflightUpdatedValues; - - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ @@ -103,15 +95,12 @@ Result<> WriteFeatureDataCSVFilter::executeImpl(DataStructure& dataStructure, co AtomicFile atomicFile = std::move(atomicFileResult.value()); auto pOutputFilePath = atomicFile.tempFilePath(); - auto pWriteNeighborListDataValue = filterArgs.value(k_WriteNeighborListData_Key); auto pWriteNumFeaturesLineValue = filterArgs.value(k_WriteNumFeaturesLine_Key); auto pDelimiterChoiceIntValue = filterArgs.value(k_DelimiterChoiceInt_Key); auto pCellFeatureAttributeMatrixPathValue = filterArgs.value(k_CellFeatureAttributeMatrixPath_Key); const std::string delimiter = OStreamUtilities::DelimiterToString(pDelimiterChoiceIntValue); - auto& cellFeatureAttributeMatrix = dataStructure.getDataRefAs(pCellFeatureAttributeMatrixPathValue); - // Ensure the complete path to the output file exists or can be created auto parentPath = pOutputFilePath.parent_path(); if(!std::filesystem::exists(parentPath)) @@ -165,6 +154,7 @@ Result<> WriteFeatureDataCSVFilter::executeImpl(DataStructure& dataStructure, co { return commitResult; } + return {}; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteLosAlamosFFTFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteLosAlamosFFTFilter.cpp index 87a7e732e6..56070f708a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteLosAlamosFFTFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteLosAlamosFFTFilter.cpp @@ -8,7 +8,6 @@ #include "simplnx/Parameters/ArraySelectionParameter.hpp" #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -82,15 +81,10 @@ IFilter::UniquePointer WriteLosAlamosFFTFilter::clone() const IFilter::PreflightResult WriteLosAlamosFFTFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) const { - auto pOutputFileValue = filterArgs.value(k_OutputFile_Key); auto pFeatureIdsArrayPathValue = filterArgs.value(k_FeatureIdsArrayPath_Key); auto pCellEulerAnglesArrayPathValue = filterArgs.value(k_CellEulerAnglesArrayPath_Key); auto pCellPhasesArrayPathValue = filterArgs.value(k_CellPhasesArrayPath_Key); - PreflightResult preflightResult; - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - usize fIdsTupCount = dataStructure.getDataAs(pFeatureIdsArrayPathValue)->getNumberOfTuples(); usize eulersTupCount = dataStructure.getDataAs(pCellEulerAnglesArrayPathValue)->getNumberOfTuples(); usize phasesTupCount = dataStructure.getDataAs(pCellPhasesArrayPathValue)->getNumberOfTuples(); @@ -100,8 +94,7 @@ IFilter::PreflightResult WriteLosAlamosFFTFilter::preflightImpl(const DataStruct return MakePreflightErrorResult(-73460, fmt::format("Tuple Dimensions don't match: Feature Ids - {} || Euler Angles - {} || Phases - {}", fIdsTupCount, eulersTupCount, phasesTupCount)); } - // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ @@ -132,6 +125,7 @@ Result<> WriteLosAlamosFFTFilter::executeImpl(DataStructure& dataStructure, cons return commitResult; } } + return result; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteStlFileFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteStlFileFilter.cpp index f4ad6934ef..1d08912796 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteStlFileFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteStlFileFilter.cpp @@ -10,7 +10,6 @@ #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/StringParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -116,9 +115,7 @@ IFilter::PreflightResult WriteStlFileFilter::preflightImpl(const DataStructure& auto pFeaturePhasesPathValue = filterArgs.value(k_FeaturePhasesPath_Key); auto pPartNumberPathValue = filterArgs.value(k_PartNumberPath_Key); - PreflightResult preflightResult; nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; auto* triangleGeom = dataStructure.getDataAs(pTriangleGeomPathValue); if(triangleGeom == nullptr) @@ -155,8 +152,9 @@ IFilter::PreflightResult WriteStlFileFilter::preflightImpl(const DataStructure& return MakePreflightErrorResult(-27874, fmt::format("Part Number Array doesn't exist at: {}", pPartNumberPathValue.toString())); } } - // Return both the resultOutputActions and the preflightUpdatedValues via std::move() - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + + // Return both the resultOutputActions via std::move() + return {std::move(resultOutputActions)}; } //------------------------------------------------------------------------------ @@ -173,6 +171,7 @@ Result<> WriteStlFileFilter::executeImpl(DataStructure& dataStructure, const Arg inputValues.FeaturePhasesPath = filterArgs.value(k_FeaturePhasesPath_Key); inputValues.TriangleGeomPath = filterArgs.value(k_TriangleGeomPath_Key); inputValues.PartNumberPath = filterArgs.value(k_PartNumberPath_Key); + return WriteStlFile(dataStructure, messageHandler, shouldCancel, &inputValues)(); } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteVtkRectilinearGridFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteVtkRectilinearGridFilter.cpp index 21785a4f6a..8a0e74f265 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteVtkRectilinearGridFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteVtkRectilinearGridFilter.cpp @@ -9,7 +9,6 @@ #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -77,14 +76,9 @@ IFilter::PreflightResult WriteVtkRectilinearGridFilter::preflightImpl(const Data const std::atomic_bool& shouldCancel) const { auto pOutputFileValue = filterArgs.value(k_OutputFile_Key); - auto pWriteBinaryFileValue = filterArgs.value(k_WriteBinaryFile_Key); auto pImageGeometryPathValue = filterArgs.value(k_ImageGeometryPath_Key); auto pSelectedDataArrayPathsValue = filterArgs.value(k_SelectedDataArrayPaths_Key); - PreflightResult preflightResult; - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - if(pSelectedDataArrayPathsValue.empty()) { return MakePreflightErrorResult(-2070, "No cell data arrays are selected. You must select at least one array."); @@ -93,7 +87,7 @@ IFilter::PreflightResult WriteVtkRectilinearGridFilter::preflightImpl(const Data auto tupleValidityCheck = dataStructure.validateNumberOfTuples(pSelectedDataArrayPathsValue); if(!tupleValidityCheck) { - return {MakeErrorResult(-2071, fmt::format("The following DataArrays all must have equal number of tuples but this was not satisfied.\n{}", tupleValidityCheck.error()))}; + return MakePreflightErrorResult(-2071, fmt::format("The following DataArrays all must have equal number of tuples but this was not satisfied.\n{}", tupleValidityCheck.error())); } usize numTuples = dataStructure.getDataRefAs(pSelectedDataArrayPathsValue[0]).getNumberOfTuples(); @@ -106,7 +100,7 @@ IFilter::PreflightResult WriteVtkRectilinearGridFilter::preflightImpl(const Data pImageGeometryPathValue.toString())); } - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ @@ -136,6 +130,7 @@ Result<> WriteVtkRectilinearGridFilter::executeImpl(DataStructure& dataStructure return commitResult; } } + return result; } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteVtkStructuredPointsFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteVtkStructuredPointsFilter.cpp index 6b2588c891..6b4d371d1c 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteVtkStructuredPointsFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteVtkStructuredPointsFilter.cpp @@ -9,7 +9,6 @@ #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/GeometrySelectionParameter.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" - #include "simplnx/Utilities/SIMPLConversion.hpp" #include @@ -77,14 +76,9 @@ IFilter::PreflightResult WriteVtkStructuredPointsFilter::preflightImpl(const Dat const std::atomic_bool& shouldCancel) const { auto pOutputFileValue = filterArgs.value(k_OutputFile_Key); - auto pWriteBinaryFileValue = filterArgs.value(k_WriteBinaryFile_Key); auto pImageGeometryPathValue = filterArgs.value(k_ImageGeometryPath_Key); auto pSelectedDataArrayPathsValue = filterArgs.value(k_SelectedDataArrayPaths_Key); - PreflightResult preflightResult; - nx::core::Result resultOutputActions; - std::vector preflightUpdatedValues; - if(pSelectedDataArrayPathsValue.empty()) { return MakePreflightErrorResult(-2070, "No cell data arrays are selected. You must select at least one array."); @@ -106,7 +100,7 @@ IFilter::PreflightResult WriteVtkStructuredPointsFilter::preflightImpl(const Dat pImageGeometryPathValue.toString())); } - return {std::move(resultOutputActions), std::move(preflightUpdatedValues)}; + return {}; } //------------------------------------------------------------------------------ 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/Plugins/SimplnxCore/src/SimplnxCore/utils/VtkUtilities.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/VtkUtilities.hpp index 4134739be4..3a68099737 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/utils/VtkUtilities.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/VtkUtilities.hpp @@ -9,7 +9,7 @@ static constexpr usize k_BufferDumpVal = 1000000; // ----------------------------------------------------------------------------- template -std::string TypeForPrimitive(T value, const IFilter::MessageHandler& messageHandler) +std::string TypeForPrimitive(const IFilter::MessageHandler& messageHandler) { if constexpr(std::is_same_v) { @@ -122,14 +122,14 @@ std::string TypeForPrimitive(T value, const IFilter::MessageHandler& messageHand return "char"; } - messageHandler(IFilter::Message::Type::Info, fmt::format("Error: TypeForPrimitive - Unknown Type: ", typeid(value).name())); - if(const char* name = typeid(value).name(); nullptr != name && name[0] == 'l') + messageHandler(IFilter::Message::Type::Info, fmt::format("Error: TypeForPrimitive - Unknown Type: ", typeid(T).name())); + if(const char* name = typeid(T).name(); nullptr != name && name[0] == 'l') { messageHandler( IFilter::Message::Type::Info, fmt::format( "You are using 'long int' as a type which is not 32/64 bit safe. It is suggested you use one of the H5SupportTypes defined in such as int32_t or uint32_t.", - typeid(value).name())); + typeid(T).name())); } return ""; } @@ -140,16 +140,17 @@ struct WriteVtkDataArrayFunctor template void operator()(FILE* outputFile, bool binary, DataStructure& dataStructure, const DataPath& arrayPath, const IFilter::MessageHandler& messageHandler) { - auto& dataArray = dataStructure.getDataRefAs>(arrayPath); + auto* dataArray = dataStructure.getDataAs>(arrayPath); + auto& dataStore = dataArray->template getIDataStoreRefAs>(); - messageHandler(IFilter::Message::Type::Info, fmt::format("Writing Cell Data {}", dataArray.getName())); + messageHandler(IFilter::Message::Type::Info, fmt::format("Writing Cell Data {}", arrayPath.getTargetName())); - const usize totalElements = dataArray.getSize(); - const int numComps = static_cast(dataArray.getNumberOfComponents()); - std::string dName = dataArray.getName(); + const usize totalElements = dataStore.getSize(); + const int numComps = static_cast(dataStore.getNumberOfComponents()); + std::string dName = arrayPath.getTargetName(); dName = StringUtilities::replace(dName, " ", "_"); - const std::string vtkTypeString = TypeForPrimitive(dataArray[0], messageHandler); + const std::string vtkTypeString = TypeForPrimitive(messageHandler); bool useIntCast = false; if(vtkTypeString == "unsigned_char" || vtkTypeString == "char") { @@ -162,13 +163,13 @@ struct WriteVtkDataArrayFunctor { if constexpr(endian::little == endian::native) { - dataArray.byteSwapElements(); + dataArray->byteSwapElements(); } - fwrite(dataArray.template getIDataStoreAs>()->data(), sizeof(T), totalElements, outputFile); + fwrite(dataStore.data(), sizeof(T), totalElements, outputFile); fprintf(outputFile, "\n"); if constexpr(endian::little == endian::native) { - dataArray.byteSwapElements(); + dataArray->byteSwapElements(); } } else @@ -183,19 +184,15 @@ struct WriteVtkDataArrayFunctor } if(useIntCast) { - buffer.append(fmt::format(" {:d}", static_cast(dataArray[i]))); + buffer.append(fmt::format(" {:d}", static_cast(dataStore[i]))); } - else if constexpr(std::is_same_v) + else if constexpr(std::is_floating_point_v) { - buffer.append(fmt::format(" {:f}", dataArray[i])); - } - else if constexpr(std::is_same_v) - { - buffer.append(fmt::format(" {:f}", dataArray[i])); + buffer.append(fmt::format(" {:f}", dataStore[i])); } else { - buffer.append(fmt::format(" {}", dataArray[i])); + buffer.append(fmt::format(" {}", dataStore[i])); } // If the buffer is within 32 bytes of the reserved size, then dump // the contents to the file. @@ -215,7 +212,7 @@ struct WriteVtkDataArrayFunctor template inline std::string ConvertDataTypeToVtkDataType() noexcept { - if constexpr(std::is_same_v) + if constexpr(std::is_same_v || std::is_same_v) { return "char"; } @@ -255,98 +252,94 @@ inline std::string ConvertDataTypeToVtkDataType() noexcept { return "double"; } - else if constexpr(std::is_same_v) - { - return "char"; - } else { static_assert(dependent_false, "ConvertDataTypeToVtkDataType: Unsupported type"); } } -template -Result<> writeVtkData(std::ofstream& outStrm, DataStructure& dataStructure, const DataPath& dataPath, bool binary, const nx::core::IFilter::MessageHandler& messageHandler, - const std::atomic_bool& shouldCancel) +struct WriteVtkDataFunctor { - using DataArrayType = DataArray; - using DataStoreType = typename DataArrayType::store_type; - - auto& dataArrayRef = dataStructure.getDataRefAs(dataPath); - - auto& dataStoreRef = dataArrayRef.getIDataStoreRef(); - - std::string name = StringUtilities::replace(dataArrayRef.getName(), " ", "_"); - - outStrm << "SCALARS " << name << " " << ConvertDataTypeToVtkDataType() << " " << dataArrayRef.getNumberOfComponents() << "\n"; - outStrm << "LOOKUP_TABLE default\n"; - - if(binary) + template + Result<> operator()(std::ofstream& outStrm, IDataArray& iDataArray, bool binary, const nx::core::IFilter::MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) { - // Swap to big Endian... because - if constexpr(endian::little == endian::native) - { - dataArrayRef.byteSwapElements(); - } + using DataArrayType = DataArray; + using DataStoreType = typename DataArrayType::store_type; - auto result = dataStoreRef.writeBinaryFile(outStrm); - if(result.first != 0) - { - } + auto& dataArrayRef = dynamic_cast(iDataArray); + const auto& dataStoreRef = dataArrayRef.getDataStoreRef(); - // Swap back to little endian - if constexpr(endian::little == endian::native) - { - dataArrayRef.byteSwapElements(); - } - } - else - { - const size_t k_DefaultElementsPerLine = 10; - auto start = std::chrono::steady_clock::now(); - auto numTuples = dataStoreRef.getSize(); - size_t currentItemCount = 0; + std::string name = StringUtilities::replace(dataArrayRef.getName(), " ", "_"); + + outStrm << "SCALARS " << name << " " << ConvertDataTypeToVtkDataType() << " " << dataArrayRef.getNumberOfComponents() << "\n"; + outStrm << "LOOKUP_TABLE default\n"; - for(size_t idx = 0; idx < numTuples; idx++) + if(binary) { - auto now = std::chrono::steady_clock::now(); - if(std::chrono::duration_cast(now - start).count() > 1000) + // Swap to big Endian... because + if constexpr(endian::little == endian::native) { - auto string = fmt::format("Processing {}: {}% completed", dataArrayRef.getName(), static_cast(100 * static_cast(idx) / static_cast(numTuples))); - messageHandler(IFilter::Message::Type::Info, string); - start = now; - if(shouldCancel) - { - return {}; - } + dataArrayRef.byteSwapElements(); } - if constexpr(std::is_same_v || std::is_same_v) + auto result = dataStoreRef.writeBinaryFile(outStrm); + if(result.first != 0) { - outStrm << static_cast(dataArrayRef[idx]); } - else if constexpr(std::is_same_v || std::is_same_v) - { - outStrm << fmt::format("{}", dataArrayRef[idx]); - } - else - { - outStrm << dataArrayRef[idx]; - } - if(currentItemCount < k_DefaultElementsPerLine - 1) + + // Swap back to little endian + if constexpr(endian::little == endian::native) { - outStrm << ' '; - currentItemCount++; + dataArrayRef.byteSwapElements(); } - else + } + else + { + const size_t k_DefaultElementsPerLine = 10; + auto start = std::chrono::steady_clock::now(); + auto numTuples = dataStoreRef.getSize(); + size_t currentItemCount = 0; + + for(size_t idx = 0; idx < numTuples; idx++) { - outStrm << "\n"; - currentItemCount = 0; + auto now = std::chrono::steady_clock::now(); + if(std::chrono::duration_cast(now - start).count() > 1000) + { + auto string = fmt::format("Processing {}: {}% completed", dataArrayRef.getName(), static_cast(100 * static_cast(idx) / static_cast(numTuples))); + messageHandler(IFilter::Message::Type::Info, string); + start = now; + if(shouldCancel) + { + return {}; + } + } + + if constexpr(std::is_same_v || std::is_same_v) + { + outStrm << static_cast(dataArrayRef[idx]); + } + else if constexpr(std::is_same_v || std::is_same_v) + { + outStrm << fmt::format("{}", dataArrayRef[idx]); + } + else + { + outStrm << dataArrayRef[idx]; + } + if(currentItemCount < k_DefaultElementsPerLine - 1) + { + outStrm << ' '; + currentItemCount++; + } + else + { + outStrm << "\n"; + currentItemCount = 0; + } } } + outStrm << "\n"; // Always end with a new line for binary data + return {}; } - outStrm << "\n"; // Always end with a new line for binary data - return {}; -} - +}; } // namespace nx::core diff --git a/src/Plugins/SimplnxCore/test/ComputeFeatureClusteringTest.cpp b/src/Plugins/SimplnxCore/test/ComputeFeatureClusteringTest.cpp index d44fccf620..7026df85b4 100644 --- a/src/Plugins/SimplnxCore/test/ComputeFeatureClusteringTest.cpp +++ b/src/Plugins/SimplnxCore/test/ComputeFeatureClusteringTest.cpp @@ -11,7 +11,6 @@ using namespace nx::core::UnitTest; namespace { -const std::string k_EquivalentDiameters = "EquivalentDiameters"; const std::string k_ExemplarClusteringList = "ClusteringList"; const std::string k_ExemplarRDF = "RDF"; const std::string k_ExemplarMinMaxDistances = "RDFMaxMinDistances"; @@ -39,7 +38,6 @@ TEST_CASE("SimplnxCore::ComputeFeatureClusteringFilter: Valid Filter Execution", args.insertOrAssign(ComputeFeatureClusteringFilter::k_RemoveBiasedFeatures_Key, std::make_any(false)); args.insertOrAssign(ComputeFeatureClusteringFilter::k_SetRandomSeed_Key, std::make_any(true)); args.insertOrAssign(ComputeFeatureClusteringFilter::k_SeedValue_Key, std::make_any(5489)); - args.insertOrAssign(ComputeFeatureClusteringFilter::k_EquivalentDiametersArrayPath_Key, std::make_any(k_CellFeatureDataPath.createChildPath(k_EquivalentDiameters))); args.insertOrAssign(ComputeFeatureClusteringFilter::k_FeaturePhasesArrayPath_Key, std::make_any(k_CellFeatureDataPath.createChildPath(k_Phases))); args.insertOrAssign(ComputeFeatureClusteringFilter::k_CentroidsArrayPath_Key, std::make_any(k_CellFeatureDataPath.createChildPath(k_Centroids))); args.insertOrAssign(ComputeFeatureClusteringFilter::k_BiasedFeaturesArrayPath_Key, std::make_any(DataPath{})); @@ -81,7 +79,6 @@ TEST_CASE("SimplnxCore::ComputeFeatureClusteringFilter: InValid Filter Execution args.insertOrAssign(ComputeFeatureClusteringFilter::k_RemoveBiasedFeatures_Key, std::make_any(false)); args.insertOrAssign(ComputeFeatureClusteringFilter::k_SetRandomSeed_Key, std::make_any(true)); args.insertOrAssign(ComputeFeatureClusteringFilter::k_SeedValue_Key, std::make_any(5489)); - args.insertOrAssign(ComputeFeatureClusteringFilter::k_EquivalentDiametersArrayPath_Key, std::make_any(k_CellFeatureDataPath.createChildPath(k_EquivalentDiameters))); args.insertOrAssign(ComputeFeatureClusteringFilter::k_FeaturePhasesArrayPath_Key, std::make_any(k_DataContainerPath.createChildPath(k_Cell_Data).createChildPath(k_Phases))); args.insertOrAssign(ComputeFeatureClusteringFilter::k_CentroidsArrayPath_Key, std::make_any(k_CellFeatureDataPath.createChildPath(k_Centroids))); args.insertOrAssign(ComputeFeatureClusteringFilter::k_BiasedFeaturesArrayPath_Key, std::make_any(DataPath{})); diff --git a/src/Plugins/SimplnxCore/test/ComputeMomentInvariants2DTest.cpp b/src/Plugins/SimplnxCore/test/ComputeMomentInvariants2DTest.cpp index e68e6ddf84..ec1081a42a 100644 --- a/src/Plugins/SimplnxCore/test/ComputeMomentInvariants2DTest.cpp +++ b/src/Plugins/SimplnxCore/test/ComputeMomentInvariants2DTest.cpp @@ -13,79 +13,6 @@ using namespace nx::core::Constants; namespace { -// ----------------------------------------------------------------------------- -void TestBinomial() -{ - size_t maxOrder = 2; - - ComputeMomentInvariants2D::DoubleMatrixType binomial = ComputeMomentInvariants2D::Binomial(maxOrder); - - REQUIRE(binomial(0, 0) == 1.0); - REQUIRE(binomial(0, 1) == 1.0); - REQUIRE(binomial(0, 2) == 1.0); - - REQUIRE(binomial(1, 0) == 1.0); - REQUIRE(binomial(1, 1) == 1.0); - REQUIRE(binomial(1, 2) == 2.0); - - REQUIRE(binomial(2, 0) == 1.0); - REQUIRE(binomial(2, 1) == 2.0); - REQUIRE(binomial(2, 2) == 1.0); -} - -// ----------------------------------------------------------------------------- -void TestBigX() -{ - constexpr size_t maxOrder = 2; - constexpr size_t dim = 16; - const ComputeMomentInvariants2D::DoubleMatrixType bigX = ComputeMomentInvariants2D::GetBigX(maxOrder, dim); - - ComputeMomentInvariants2D::DoubleMatrixType ideal(16, 3); - ideal << 0.133333, -0.142222, 0.151901, 0.133333, -0.124444, 0.116346, 0.133333, -0.106667, 0.0855309, 0.133333, -0.0888889, 0.0594568, 0.133333, -0.0711111, 0.0381235, 0.133333, -0.0533333, - 0.0215309, 0.133333, -0.0355556, 0.00967901, 0.133333, -0.0177778, 0.0025679, 0.133333, 0.0000000, 0.000197531, 0.133333, 0.0177778, 0.0025679, 0.133333, 0.0355556, 0.00967901, 0.133333, - 0.0533333, 0.0215309, 0.133333, 0.0711111, 0.0381235, 0.133333, 0.0888889, 0.0594568, 0.133333, 0.106667, 0.0855309, 0.133333, 0.124444, 0.116346; - - const ComputeMomentInvariants2D::DoubleMatrixType diff = bigX - ideal; - - REQUIRE(diff.maxCoeff() < 0.000001); -} - -// ----------------------------------------------------------------------------- -void TestComputeMoments2D() -{ - size_t maxOrder = 2; - size_t imageDim = 5; // The algorithm takes a square image - size_t inputDims[2] = {imageDim, imageDim}; - - ComputeMomentInvariants2D::DoubleMatrixType input2D(5, 5); - input2D << 0, 0, 0, 0, 0, - /*Row*/ 0, 1, 1, 1, 0, - /*Row*/ 0, 1, 1, 1, 0, - /*Row*/ 0, 1, 1, 1, 0, - /*Row*/ 0, 0, 0, 0, 0; - ComputeMomentInvariants2D::DoubleMatrixType centralMoments = ComputeMomentInvariants2D::ComputeMomentInvariants(input2D, inputDims, maxOrder); - - // compute the second order moment invariants - ComputeMomentInvariants2D::DoubleMatrixType idealCentralMoments(3, 3); - idealCentralMoments << 9.0, 0.0, 6.75, 0.0, 0.0, 0.0, 6.75, 0.0, 5.0625; - ComputeMomentInvariants2D::DoubleMatrixType diff = centralMoments - idealCentralMoments; - REQUIRE(diff.maxCoeff() < 0.000001); - - double omega1 = 2.0 * (centralMoments(0, 0) * centralMoments(0, 0)) / (centralMoments(0, 2) + centralMoments(2, 0)); - double omega2 = std::pow(centralMoments(0, 0), 4) / (centralMoments(2, 0) * centralMoments(0, 2) - std::pow(centralMoments(1, 1), 2)); - - REQUIRE(omega1 == 12.0); - REQUIRE(omega2 == 144.0); - - // normalize the invariants by those of the circle - double circleOmega[2] = {4.0 * numbers::pi, 16.0 * numbers::pi * numbers::pi}; - omega1 /= circleOmega[0]; - omega2 /= circleOmega[1]; - - REQUIRE(std::abs(omega1 - 0.95493) < 0.00001); - REQUIRE(std::abs(omega2 - 0.911891) < 0.00001); -} - // ----------------------------------------------------------------------------- DataStructure CreateInvalidTestData() { @@ -196,10 +123,6 @@ const DataPath k_Omega2Path({k_ImageGeometry, k_FeatureData, k_Omega2}); TEST_CASE("SimplnxCore::ComputeMomentInvariants2DFilter: Valid Filter Execution", "[SimplnxCore][ComputeMomentInvariants2DFilter]") { - TestBinomial(); - TestBigX(); - TestComputeMoments2D(); - // Instantiate the filter, a DataStructure object and an Arguments Object ComputeMomentInvariants2DFilter filter; DataStructure ds = CreateTestData(); diff --git a/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp b/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp index ccc85b2d05..87fdc875e0 100644 --- a/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp +++ b/src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp @@ -329,7 +329,7 @@ TEST_CASE("DREAM3DFileTest:Import/Export DREAM3D Filter Test") REQUIRE(importDataStructure.getData(DataPath({DataNames::k_Group1Name})) != nullptr); auto* dataArray = importDataStructure.getDataAs>(DataPath({DataNames::k_ArrayName})); REQUIRE(dataArray != nullptr); - REQUIRE(dataArray->getIDataStoreAs>() != nullptr); + REQUIRE(dataArray->template getIDataStoreAs>() != nullptr); } { auto importPipeline = CreateImportPipeline(); @@ -340,7 +340,7 @@ TEST_CASE("DREAM3DFileTest:Import/Export DREAM3D Filter Test") REQUIRE(importDataStructure.getData(DataPath({DataNames::k_Group1Name})) != nullptr); auto* dataArray = importDataStructure.getDataAs>(DataPath({DataNames::k_ArrayName})); REQUIRE(dataArray != nullptr); - REQUIRE(dataArray->getIDataStoreAs>() != nullptr); + REQUIRE(dataArray->template getIDataStoreAs>() != nullptr); } } diff --git a/src/Plugins/SimplnxCore/test/SetImageGeomOriginScalingFilterTest.cpp b/src/Plugins/SimplnxCore/test/SetImageGeomOriginScalingFilterTest.cpp index 8ef1c7c45d..dadaa95f20 100644 --- a/src/Plugins/SimplnxCore/test/SetImageGeomOriginScalingFilterTest.cpp +++ b/src/Plugins/SimplnxCore/test/SetImageGeomOriginScalingFilterTest.cpp @@ -12,8 +12,8 @@ TEST_CASE("SimplnxCore::SetImageGeomOriginScalingFilter(Instantiate)", "[Simplnx DataPath k_ImageGeomPath({Constants::k_SmallIN100, Constants::k_EbsdScanData, Constants::k_ImageGeometry}); bool k_ChangeOrigin = false; bool k_ChangeResolution = false; - std::vector k_Origin{0, 0, 0}; - std::vector k_Spacing{1, 1, 1}; + std::vector k_Origin{0, 0, 0}; + std::vector k_Spacing{1, 1, 1}; SetImageGeomOriginScalingFilter filter; DataStructure dataStructure = UnitTest::CreateDataStructure(); @@ -22,8 +22,8 @@ TEST_CASE("SimplnxCore::SetImageGeomOriginScalingFilter(Instantiate)", "[Simplnx args.insert(SetImageGeomOriginScalingFilter::k_SelectedImageGeometryPath_Key, std::make_any(k_ImageGeomPath)); args.insert(SetImageGeomOriginScalingFilter::k_ChangeOrigin_Key, std::make_any(k_ChangeOrigin)); args.insert(SetImageGeomOriginScalingFilter::k_ChangeSpacing_Key, std::make_any(k_ChangeResolution)); - args.insert(SetImageGeomOriginScalingFilter::k_Origin_Key, std::make_any>(k_Origin)); - args.insert(SetImageGeomOriginScalingFilter::k_Spacing_Key, std::make_any>(k_Spacing)); + args.insert(SetImageGeomOriginScalingFilter::k_Origin_Key, std::make_any>(k_Origin)); + args.insert(SetImageGeomOriginScalingFilter::k_Spacing_Key, std::make_any>(k_Spacing)); auto result = filter.preflight(dataStructure, args); SIMPLNX_RESULT_REQUIRE_VALID(result.outputActions); @@ -34,8 +34,8 @@ TEST_CASE("SimplnxCore::SetImageGeomOriginScalingFilter: Valid Execution", "[Sim DataPath k_ImageGeomPath({Constants::k_SmallIN100, Constants::k_EbsdScanData, Constants::k_ImageGeometry}); bool k_ChangeOrigin = true; bool k_ChangeResolution = true; - std::vector k_Origin{7, 6, 5}; - std::vector k_Spacing{2, 2, 2}; + std::vector k_Origin{7, 6, 5}; + std::vector k_Spacing{2, 2, 2}; SetImageGeomOriginScalingFilter filter; DataStructure dataStructure = UnitTest::CreateDataStructure(); @@ -44,8 +44,8 @@ TEST_CASE("SimplnxCore::SetImageGeomOriginScalingFilter: Valid Execution", "[Sim args.insert(SetImageGeomOriginScalingFilter::k_SelectedImageGeometryPath_Key, std::make_any(k_ImageGeomPath)); args.insert(SetImageGeomOriginScalingFilter::k_ChangeOrigin_Key, std::make_any(k_ChangeOrigin)); args.insert(SetImageGeomOriginScalingFilter::k_ChangeSpacing_Key, std::make_any(k_ChangeResolution)); - args.insert(SetImageGeomOriginScalingFilter::k_Origin_Key, std::make_any>(k_Origin)); - args.insert(SetImageGeomOriginScalingFilter::k_Spacing_Key, std::make_any>(k_Spacing)); + args.insert(SetImageGeomOriginScalingFilter::k_Origin_Key, std::make_any>(k_Origin)); + args.insert(SetImageGeomOriginScalingFilter::k_Spacing_Key, std::make_any>(k_Spacing)); auto preflightResult = filter.preflight(dataStructure, args); SIMPLNX_RESULT_REQUIRE_VALID(preflightResult.outputActions); @@ -63,8 +63,8 @@ TEST_CASE("SimplnxCore::SetImageGeomOriginScalingFilter: 0,0,0 Central Origin", DataPath k_ImageGeomPath({Constants::k_SmallIN100, Constants::k_EbsdScanData, Constants::k_ImageGeometry}); bool k_ChangeOrigin = true; bool k_ChangeResolution = true; - std::vector k_Origin{0.0, 0.0, 0.0}; - std::vector k_Spacing{2, 2, 2}; + std::vector k_Origin{0.0, 0.0, 0.0}; + std::vector k_Spacing{2, 2, 2}; SetImageGeomOriginScalingFilter filter; DataStructure dataStructure = UnitTest::CreateDataStructure(); @@ -74,8 +74,8 @@ TEST_CASE("SimplnxCore::SetImageGeomOriginScalingFilter: 0,0,0 Central Origin", args.insert(SetImageGeomOriginScalingFilter::k_ChangeOrigin_Key, std::make_any(k_ChangeOrigin)); args.insert(SetImageGeomOriginScalingFilter::k_CenterOrigin_Key, std::make_any(true)); args.insert(SetImageGeomOriginScalingFilter::k_ChangeSpacing_Key, std::make_any(k_ChangeResolution)); - args.insert(SetImageGeomOriginScalingFilter::k_Origin_Key, std::make_any>(k_Origin)); - args.insert(SetImageGeomOriginScalingFilter::k_Spacing_Key, std::make_any>(k_Spacing)); + args.insert(SetImageGeomOriginScalingFilter::k_Origin_Key, std::make_any>(k_Origin)); + args.insert(SetImageGeomOriginScalingFilter::k_Spacing_Key, std::make_any>(k_Spacing)); auto preflightResult = filter.preflight(dataStructure, args); SIMPLNX_RESULT_REQUIRE_VALID(preflightResult.outputActions); @@ -93,8 +93,8 @@ TEST_CASE("SimplnxCore::SetImageGeomOriginScalingFilter: Custom Central Origin", DataPath k_ImageGeomPath({Constants::k_SmallIN100, Constants::k_EbsdScanData, Constants::k_ImageGeometry}); bool k_ChangeOrigin = true; bool k_ChangeResolution = true; - std::vector k_Origin{7.0, 6.0, 5.0}; - std::vector k_Spacing{2, 2, 2}; + std::vector k_Origin{7.0, 6.0, 5.0}; + std::vector k_Spacing{2, 2, 2}; SetImageGeomOriginScalingFilter filter; DataStructure dataStructure = UnitTest::CreateDataStructure(); @@ -104,8 +104,8 @@ TEST_CASE("SimplnxCore::SetImageGeomOriginScalingFilter: Custom Central Origin", args.insert(SetImageGeomOriginScalingFilter::k_ChangeOrigin_Key, std::make_any(k_ChangeOrigin)); args.insert(SetImageGeomOriginScalingFilter::k_CenterOrigin_Key, std::make_any(true)); args.insert(SetImageGeomOriginScalingFilter::k_ChangeSpacing_Key, std::make_any(k_ChangeResolution)); - args.insert(SetImageGeomOriginScalingFilter::k_Origin_Key, std::make_any>(k_Origin)); - args.insert(SetImageGeomOriginScalingFilter::k_Spacing_Key, std::make_any>(k_Spacing)); + args.insert(SetImageGeomOriginScalingFilter::k_Origin_Key, std::make_any>(k_Origin)); + args.insert(SetImageGeomOriginScalingFilter::k_Spacing_Key, std::make_any>(k_Spacing)); auto preflightResult = filter.preflight(dataStructure, args); SIMPLNX_RESULT_REQUIRE_VALID(preflightResult.outputActions); diff --git a/src/simplnx/DataStructure/Geometry/INodeGeometry0D.cpp b/src/simplnx/DataStructure/Geometry/INodeGeometry0D.cpp index 8e53afba2c..eb2eaaa30d 100644 --- a/src/simplnx/DataStructure/Geometry/INodeGeometry0D.cpp +++ b/src/simplnx/DataStructure/Geometry/INodeGeometry0D.cpp @@ -101,7 +101,7 @@ BoundingBox3Df INodeGeometry0D::getBoundingBox() const try { - auto& vertexListStore = vertexList.getIDataStoreRefAs>(); + auto& vertexListStore = vertexList.template getIDataStoreRefAs>(); for(size_t tuple = 0; tuple < vertexListStore.getNumberOfTuples(); tuple++) { @@ -130,7 +130,7 @@ Result INodeGeometry0D::isPlane(usize dimensionIndex) const try { const IGeometry::SharedVertexList& vertexList = getVerticesRef(); - auto& vertexListStore = vertexList.getIDataStoreRefAs>(); + auto& vertexListStore = vertexList.template getIDataStoreRefAs>(); std::set pointSet; for(usize tuple = 0; tuple < vertexListStore.getNumberOfTuples(); tuple++) diff --git a/src/simplnx/Utilities/AlignSections.cpp b/src/simplnx/Utilities/AlignSections.cpp index a7549d2dc4..3db2b85c68 100644 --- a/src/simplnx/Utilities/AlignSections.cpp +++ b/src/simplnx/Utilities/AlignSections.cpp @@ -158,7 +158,6 @@ Result<> AlignSections::execute(const SizeVec3& udims) m_MessageHandler(fmt::format("Updating DataArray '{}'", cellArrayPath.toString())); auto& cellArray = m_DataStructure.getDataRefAs(cellArrayPath); - ExecuteParallelFunction(cellArray.getDataType(), taskRunner, this, udims, xShifts, yShifts, cellArray); } // This will spill over if the number of DataArrays to process does not divide evenly by the number of threads. @@ -168,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); @@ -200,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; @@ -210,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; @@ -236,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..8e5761c248 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 331a2f9569..ca5ca0c57d 100644 --- a/src/simplnx/Utilities/DataArrayUtilities.cpp +++ b/src/simplnx/Utilities/DataArrayUtilities.cpp @@ -245,7 +245,9 @@ Result<> ValidateNumFeaturesInArray(const DataStructure& dataStructure, const Da Result<> results = {}; const usize numFeatures = featureArrayPtr->getNumberOfTuples(); - for(const int32& featureId : featureIds) + auto& featureIdsStore = featureIds.getDataStoreRef(); + + for(const int32& featureId : featureIdsStore) { if(featureId < 0) { @@ -352,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 567f5142fe..7eaa901db8 100644 --- a/src/simplnx/Utilities/DataArrayUtilities.hpp +++ b/src/simplnx/Utilities/DataArrayUtilities.hpp @@ -601,7 +601,7 @@ DataArray& ArrayRefFromPath(DataStructure& dataStructure, const DataPath& pat * @return A Result<> type that contains any warnings or errors that occurred. */ template -Result<> ImportFromBinaryFile(const fs::path& binaryFilePath, DataArray& outputDataArray, usize startByte = 0, usize defaultBufferSize = 1000000) +Result<> ImportFromBinaryFile(const fs::path& binaryFilePath, AbstractDataStore& outputDataArray, usize startByte = 0, usize defaultBufferSize = 1000000) { FILE* inputFilePtr = std::fopen(binaryFilePath.string().c_str(), "rb"); if(inputFilePtr == nullptr) @@ -681,7 +681,7 @@ DataArray* ImportFromBinaryFile(const std::string& filename, const std::strin return nullptr; } - Result<> result = ImportFromBinaryFile(fs::path(filename), *dataArrayPtr); + Result<> result = ImportFromBinaryFile(fs::path(filename), dataArrayPtr->getDataStoreRef()); if(result.invalid()) { return nullptr; @@ -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 {}; } @@ -977,8 +977,8 @@ class CopyTupleUsingIndexList void convert(usize start, usize end) const { - const auto& oldDataStore = m_OldCellArray.getIDataStoreRefAs>(); - auto& newDataStore = m_NewCellArray.getIDataStoreRefAs>(); + const auto& oldDataStore = m_OldCellArray.template getIDataStoreRefAs>(); + auto& newDataStore = m_NewCellArray.template getIDataStoreRefAs>(); for(usize i = start; i < end; i++) { @@ -1265,7 +1265,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); @@ -1336,7 +1336,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); @@ -1409,7 +1409,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) { @@ -1548,7 +1548,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) { @@ -1673,7 +1673,7 @@ void RunParallelAppend(IArray& destArray, ParallelRunnerT&& runner, ArgsT&&... a dataType = dynamic_cast(&destArray)->getDataType(); if(dataType == DataType::boolean) { - RunAppendBoolAppend(destArray, std::forward(args)...); + return RunAppendBoolAppend(destArray, std::forward(args)...); } } @@ -1750,7 +1750,6 @@ void RunParallelMapRectToImage(IArray& destArray, ParallelRunnerT&& runner, Args namespace TransferGeometryElementData { - /** * @brief * @tparam T @@ -1812,21 +1811,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/DataGroupUtilities.cpp b/src/simplnx/Utilities/DataGroupUtilities.cpp index 7c800200dd..a4051f2f25 100644 --- a/src/simplnx/Utilities/DataGroupUtilities.cpp +++ b/src/simplnx/Utilities/DataGroupUtilities.cpp @@ -5,11 +5,9 @@ namespace nx::core { -bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& featureDataGroupPath, const std::vector& activeObjects, Int32Array& cellFeatureIds, size_t currentFeatureCount, - const IFilter::MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) +bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& featureDataGroupPath, const std::vector& activeObjects, Int32AbstractDataStore& cellFeatureIds, + size_t currentFeatureCount, const IFilter::MessageHandler& messageHandler, const std::atomic_bool& shouldCancel) { - bool acceptableMatrix = true; - // Get the DataGroup that holds all the feature Data const auto* featureLevelBaseGroup = dataStructure.getDataAs(featureDataGroupPath); @@ -36,7 +34,7 @@ bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& feature } } size_t totalTuples = currentFeatureCount; - if(activeObjects.size() == totalTuples && acceptableMatrix) + if(activeObjects.size() == totalTuples) { size_t goodCount = 1; std::vector newNames(totalTuples, 0); @@ -83,13 +81,12 @@ bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& feature // Loop over all the points and correct all the feature names size_t totalPoints = cellFeatureIds.getNumberOfTuples(); - auto& featureIds = cellFeatureIds.getDataStoreRef(); bool featureIdsChanged = false; for(size_t i = 0; i < totalPoints; i++) { - if(featureIds[i] >= 0 && featureIds[i] < newNames.size()) + if(cellFeatureIds[i] >= 0 && cellFeatureIds[i] < newNames.size()) { - featureIds[i] = static_cast(newNames[featureIds[i]]); + cellFeatureIds[i] = static_cast(newNames[cellFeatureIds[i]]); featureIdsChanged = true; } if(shouldCancel) diff --git a/src/simplnx/Utilities/DataGroupUtilities.hpp b/src/simplnx/Utilities/DataGroupUtilities.hpp index 63364ac0a0..ee34db2ea3 100644 --- a/src/simplnx/Utilities/DataGroupUtilities.hpp +++ b/src/simplnx/Utilities/DataGroupUtilities.hpp @@ -12,7 +12,6 @@ namespace nx::core { - /** * @brief RemoveInactiveObjects This assumes a single Dimension TupleShape, i.e., a Linear array, (1D) * @@ -26,7 +25,7 @@ namespace nx::core * @param shouldCancel * @return */ -SIMPLNX_EXPORT bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& featureDataGroupPath, const std::vector& activeObjects, Int32Array& cellFeatureIds, +SIMPLNX_EXPORT bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& featureDataGroupPath, const std::vector& activeObjects, Int32AbstractDataStore& cellFeatureIds, size_t currentFeatureCount, const IFilter::MessageHandler& messageHandler, const std::atomic_bool& shouldCancel); /** diff --git a/src/simplnx/Utilities/FilePathGenerator.cpp b/src/simplnx/Utilities/FilePathGenerator.cpp index d65abdbc3e..d5465e1172 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 +} // namespace nx::core::FilePathGenerator diff --git a/src/simplnx/Utilities/FlyingEdges.hpp b/src/simplnx/Utilities/FlyingEdges.hpp index 3267114b22..88cc0f1689 100644 --- a/src/simplnx/Utilities/FlyingEdges.hpp +++ b/src/simplnx/Utilities/FlyingEdges.hpp @@ -611,9 +611,9 @@ class FlyingEdgesAlgorithm using TCube = std::array; public: - FlyingEdgesAlgorithm(const ImageGeom& image, const IDataArray& iDataArray, const T isoVal, TriangleGeom& triangleGeom, Float32Array& normals) + FlyingEdgesAlgorithm(const ImageGeom& image, const AbstractDataStore& dataStore, const T isoVal, TriangleGeom& triangleGeom, Float32AbstractDataStore& normals) : m_Image(image) - , m_DataArray(dynamic_cast&>(iDataArray)) + , m_DataStore(dataStore) , m_IsoVal(isoVal) , m_TriangleGeom(triangleGeom) , m_NX(image.getDimensions()[0]) @@ -623,9 +623,9 @@ class FlyingEdgesAlgorithm , m_TriCounter((m_NY - 1) * (m_NZ - 1)) , m_EdgeCases((m_NX - 1) * m_NY * m_NZ) , m_CubeCases((m_NX - 1) * (m_NY - 1) * (m_NZ - 1)) - , m_Tris(m_TriangleGeom.getFacesRef()) - , m_Points(m_TriangleGeom.getVerticesRef()) - , m_Normals(normals) + , m_TrisStore(m_TriangleGeom.getFaces()->getDataStoreRef()) + , m_PointsStore(m_TriangleGeom.getVertices()->getDataStoreRef()) + , m_NormalsStore(normals) { } @@ -645,13 +645,13 @@ class FlyingEdgesAlgorithm for(usize j = 0; j != m_NY; ++j) { auto curEdgeCases = m_EdgeCases.begin() + (m_NX - 1) * (k * m_NY + j); - T curPointValue = m_DataArray[m_NX * (k * m_NY + j)]; + T curPointValue = m_DataStore[m_NX * (k * m_NY + j)]; std::array isGE = {}; isGE[0] = (curPointValue >= m_IsoVal); for(int i = 1; i != m_NX; ++i) { - isGE[i % 2] = (m_DataArray[(m_NX * (k * m_NY + j)) + i] >= m_IsoVal); + isGE[i % 2] = (m_DataStore[(m_NX * (k * m_NY + j)) + i] >= m_IsoVal); curEdgeCases[i - 1] = calcCaseEdge(isGE[(i + 1) % 2], isGE[i % 2]); } @@ -887,7 +887,7 @@ class FlyingEdgesAlgorithm m_TriangleGeom.resizeFaceList(triAccum); m_TriangleGeom.resizeVertexList(pointAccum); - m_Normals.getIDataStoreRef().resizeTuples({pointAccum}); + m_NormalsStore.resizeTuples({pointAccum}); } /////////////////////////////////////////////////////////////////////////////// @@ -1097,9 +1097,9 @@ class FlyingEdgesAlgorithm const char* caseTri = util::caseTriangles[caseId]; // size 16 for(int idx = 0; caseTri[idx] != -1; idx += 3) { - m_Tris[triIdx * 3] = globalIdxs[caseTri[idx]]; - m_Tris[triIdx * 3 + 1] = globalIdxs[caseTri[idx + 1]]; - m_Tris[triIdx * 3 + 2] = globalIdxs[caseTri[idx + 2]]; + m_TrisStore[triIdx * 3] = globalIdxs[caseTri[idx]]; + m_TrisStore[triIdx * 3 + 1] = globalIdxs[caseTri[idx + 1]]; + m_TrisStore[triIdx * 3 + 2] = globalIdxs[caseTri[idx + 2]]; triIdx++; } } @@ -1134,7 +1134,7 @@ class FlyingEdgesAlgorithm }; const ImageGeom& m_Image; - const DataArray& m_DataArray; + const AbstractDataStore& m_DataStore; const T m_IsoVal; TriangleGeom& m_TriangleGeom; @@ -1148,9 +1148,9 @@ class FlyingEdgesAlgorithm std::vector m_EdgeCases; // size (m_NX-1)*m_NY*m_NZ std::vector m_CubeCases; // size (m_NX-1)*(m_NY-1)*(m_NZ-1) - IGeometry::SharedVertexList& m_Points; // - IGeometry::SharedTriList& m_Tris; // - Float32Array& m_Normals; // The output + AbstractDataStore& m_PointsStore; // + AbstractDataStore& m_TrisStore; // + Float32AbstractDataStore& m_NormalsStore; // The output ///////////////////////////////////////////////////////////// @@ -1162,18 +1162,18 @@ class FlyingEdgesAlgorithm { auto pointsArray = interpolateOnCube(pointCube, isoValCube, edgeNum); - m_Points[idx] = pointsArray[0]; - m_Points[idx + 1] = pointsArray[1]; - m_Points[idx + 2] = pointsArray[2]; + m_PointsStore[idx] = pointsArray[0]; + m_PointsStore[idx + 1] = pointsArray[1]; + m_PointsStore[idx + 2] = pointsArray[2]; auto normalsArray = interpolateOnCube(gradCube, isoValCube, edgeNum); - m_Normals[idx] = normalsArray[0]; - m_Normals[idx + 1] = normalsArray[1]; - m_Normals[idx + 2] = normalsArray[2]; + m_NormalsStore[idx] = normalsArray[0]; + m_NormalsStore[idx + 1] = normalsArray[1]; + m_NormalsStore[idx + 2] = normalsArray[2]; } - bool isCutEdge(usize const& i, usize const& j, usize const& k) const + [[nodiscard]] bool isCutEdge(usize const& i, usize const& j, usize const& k) const { // Assuming m_EdgeCases are all set usize edgeCaseIdx = k * (m_NX - 1) * m_NY + j * (m_NX - 1) + i; @@ -1213,7 +1213,7 @@ class FlyingEdgesAlgorithm return false; } - inline uint8 calcCaseEdge(bool const& prevEdge, bool const& currEdge) const + [[nodiscard]] inline uint8 calcCaseEdge(bool const& prevEdge, bool const& currEdge) const { // o -- is greater than or equal to // case 0: (i-1) o-----o (i) | (_,j,k) @@ -1230,7 +1230,7 @@ class FlyingEdgesAlgorithm return 3; } - inline uint8 calcCubeCase(uint8 const& ec0, uint8 const& ec1, uint8 const& ec2, uint8 const& ec3) const + [[nodiscard]] inline uint8 calcCubeCase(uint8 const& ec0, uint8 const& ec1, uint8 const& ec2, uint8 const& ec3) const { // ec0 | (_,j,k) // ec1 | (_,j+1,k) @@ -1305,7 +1305,7 @@ class FlyingEdgesAlgorithm return vals; } - cube getPosCube(usize i, usize j, usize k) const + [[nodiscard]] cube getPosCube(usize i, usize j, usize k) const { cube pos; const FloatVec3 zeroPos = m_Image.getOrigin(); @@ -1350,7 +1350,7 @@ class FlyingEdgesAlgorithm return pos; } - cube getGradCube(usize i, usize j, usize k) const + [[nodiscard]] cube getGradCube(usize i, usize j, usize k) const { cube grad; @@ -1368,10 +1368,10 @@ class FlyingEdgesAlgorithm inline T getData(usize i, usize j, usize k) const { - return m_DataArray[k * m_NX * m_NY + j * m_NX + i]; + return m_DataStore[k * m_NX * m_NY + j * m_NX + i]; } - std::array computeGradient(usize i, usize j, usize k) const + [[nodiscard]] std::array computeGradient(usize i, usize j, usize k) const { std::array, 3> x = {}; std::array run = {}; @@ -1381,58 +1381,58 @@ class FlyingEdgesAlgorithm if(i == 0) { - x[0][0] = m_DataArray[dataIdx + 1]; - x[0][1] = m_DataArray[dataIdx]; + x[0][0] = m_DataStore[dataIdx + 1]; + x[0][1] = m_DataStore[dataIdx]; run[0] = spacing[0]; } else if(i == (m_NX - 1)) { - x[0][0] = m_DataArray[dataIdx]; - x[0][1] = m_DataArray[dataIdx - 1]; + x[0][0] = m_DataStore[dataIdx]; + x[0][1] = m_DataStore[dataIdx - 1]; run[0] = spacing[0]; } else { - x[0][0] = m_DataArray[dataIdx + 1]; - x[0][1] = m_DataArray[dataIdx - 1]; + x[0][0] = m_DataStore[dataIdx + 1]; + x[0][1] = m_DataStore[dataIdx - 1]; run[0] = 2 * spacing[0]; } if(j == 0) { - x[1][0] = m_DataArray[dataIdx + m_NX]; - x[1][1] = m_DataArray[dataIdx]; + x[1][0] = m_DataStore[dataIdx + m_NX]; + x[1][1] = m_DataStore[dataIdx]; run[1] = spacing[1]; } else if(j == (m_NY - 1)) { - x[1][0] = m_DataArray[dataIdx]; - x[1][1] = m_DataArray[dataIdx - m_NX]; + x[1][0] = m_DataStore[dataIdx]; + x[1][1] = m_DataStore[dataIdx - m_NX]; run[1] = spacing[1]; } else { - x[1][0] = m_DataArray[dataIdx + m_NX]; - x[1][1] = m_DataArray[dataIdx - m_NX]; + x[1][0] = m_DataStore[dataIdx + m_NX]; + x[1][1] = m_DataStore[dataIdx - m_NX]; run[1] = 2 * spacing[1]; } if(k == 0) { - x[2][0] = m_DataArray[dataIdx + m_NX * m_NY]; - x[2][1] = m_DataArray[dataIdx]; + x[2][0] = m_DataStore[dataIdx + m_NX * m_NY]; + x[2][1] = m_DataStore[dataIdx]; run[2] = spacing[2]; } else if(k == (m_NZ - 1)) { - x[2][0] = m_DataArray[dataIdx]; - x[2][1] = m_DataArray[dataIdx - m_NX * m_NY]; + x[2][0] = m_DataStore[dataIdx]; + x[2][1] = m_DataStore[dataIdx - m_NX * m_NY]; run[2] = spacing[2]; } else { - x[2][0] = m_DataArray[dataIdx + m_NX * m_NY]; - x[2][1] = m_DataArray[dataIdx - m_NX * m_NY]; + x[2][0] = m_DataStore[dataIdx + m_NX * m_NY]; + x[2][1] = m_DataStore[dataIdx - m_NX * m_NY]; run[2] = 2 * spacing[2]; } diff --git a/src/simplnx/Utilities/GeometryUtilities.cpp b/src/simplnx/Utilities/GeometryUtilities.cpp index dd2e8cc873..400231ef3c 100644 --- a/src/simplnx/Utilities/GeometryUtilities.cpp +++ b/src/simplnx/Utilities/GeometryUtilities.cpp @@ -11,8 +11,8 @@ constexpr float32 k_PartitionEdgePadding = 0.000001; const Point3Df k_Padding(k_PartitionEdgePadding, k_PartitionEdgePadding, k_PartitionEdgePadding); } // namespace -GeometryUtilities::FindUniqueIdsImpl::FindUniqueIdsImpl(nx::core::IGeometry::SharedVertexList& vertex, const std::vector>& nodesInBin, nx::core::Int64DataStore& uniqueIds) -: m_Vertex(vertex) +GeometryUtilities::FindUniqueIdsImpl::FindUniqueIdsImpl(VertexStore& vertexStore, const std::vector>& nodesInBin, nx::core::Int64DataStore& uniqueIds) +: m_VertexStore(vertexStore) , m_NodesInBin(nodesInBin) , m_UniqueIds(uniqueIds) { @@ -21,8 +21,6 @@ GeometryUtilities::FindUniqueIdsImpl::FindUniqueIdsImpl(nx::core::IGeometry::Sha // ----------------------------------------------------------------------------- void GeometryUtilities::FindUniqueIdsImpl::convert(size_t start, size_t end) const { - auto& vertexDataStore = m_Vertex.getIDataStoreRefAs>(); - const float32* verticesPtr = vertexDataStore.data(); int64* uniqueIdsPtr = m_UniqueIds.data(); for(size_t i = start; i < end; i++) { @@ -34,7 +32,7 @@ void GeometryUtilities::FindUniqueIdsImpl::convert(size_t start, size_t end) con for(size_t k = j + 1; k < m_NodesInBin[i].size(); k++) { size_t node2 = m_NodesInBin[i][k]; - if(verticesPtr[node1 * 3] == verticesPtr[node2 * 3] && verticesPtr[node1 * 3 + 1] == verticesPtr[node2 * 3 + 1] && verticesPtr[node1 * 3 + 2] == verticesPtr[node2 * 3 + 2]) + if(m_VertexStore[node1 * 3] == m_VertexStore[node2 * 3] && m_VertexStore[node1 * 3 + 1] == m_VertexStore[node2 * 3 + 1] && m_VertexStore[node1 * 3 + 2] == m_VertexStore[node2 * 3 + 2]) { uniqueIdsPtr[node2] = node1; } diff --git a/src/simplnx/Utilities/GeometryUtilities.hpp b/src/simplnx/Utilities/GeometryUtilities.hpp index d0bf74e5f0..8fcb789100 100644 --- a/src/simplnx/Utilities/GeometryUtilities.hpp +++ b/src/simplnx/Utilities/GeometryUtilities.hpp @@ -17,13 +17,14 @@ namespace nx::core::GeometryUtilities class SIMPLNX_EXPORT FindUniqueIdsImpl { public: - FindUniqueIdsImpl(nx::core::IGeometry::SharedVertexList& vertex, const std::vector>& nodesInBin, nx::core::Int64DataStore& uniqueIds); + using VertexStore = nx::core::AbstractDataStore; + FindUniqueIdsImpl(VertexStore& vertexStore, const std::vector>& nodesInBin, nx::core::Int64DataStore& uniqueIds); void convert(size_t start, size_t end) const; void operator()(const Range& range) const; private: - const IGeometry::SharedVertexList& m_Vertex; + const VertexStore& m_VertexStore; const std::vector>& m_NodesInBin; nx::core::Int64DataStore& m_UniqueIds; }; @@ -85,10 +86,9 @@ Result<> EliminateDuplicateNodes(GeometryType& geom, std::optional scal usize numYBins = 100; usize numZBins = 100; - using SharedFaceList = IGeometry::MeshIndexArrayType; - using SharedVertList = IGeometry::SharedVertexList; + using SharedVertList = AbstractDataStore; - SharedVertList& vertices = *(geom.getVertices()); + SharedVertList& vertices = geom.getVertices()->getDataStoreRef(); INodeGeometry1D::MeshIndexArrayType* cells = nullptr; if constexpr(std::is_base_of::value) @@ -108,7 +108,7 @@ Result<> EliminateDuplicateNodes(GeometryType& geom, std::optional scal { return MakeErrorResult(-56800, "EliminateDuplicateNodes Error: Geometry Type was not 1D, 2D or 3D? Did you pass in a vertex geometry?"); } - INodeGeometry1D::MeshIndexArrayType& cellsRef = *(cells); + AbstractDataStore& cellsRef = cells->getDataStoreRef(); IGeometry::MeshIndexType nNodesAll = geom.getNumberOfVertices(); size_t nNodes = 0; @@ -138,7 +138,7 @@ Result<> EliminateDuplicateNodes(GeometryType& geom, std::optional scal { yBin = static_cast((vertices[i * 3 + 1] - minPoint.getY()) / stepY); } - if(zBin != 0) + if(stepZ != 0) { zBin = static_cast((vertices[i * 3 + 2] - minPoint.getZ()) / stepZ); } @@ -192,7 +192,7 @@ Result<> EliminateDuplicateNodes(GeometryType& geom, std::optional scal scaleFactorValue = scaleFactor.value(); } - // Move nodes to unique Id and then resize nodes array and apply optional scaling + // Move nodes to uniqueIds and then resize nodes array and apply optional scaling for(size_t i = 0; i < nNodes; i++) { vertices[uniqueIds[i] * 3] = vertices[i * 3] * scaleFactorValue; diff --git a/src/simplnx/Utilities/IParallelAlgorithm.cpp b/src/simplnx/Utilities/IParallelAlgorithm.cpp index ebc0aceb80..dc04752a06 100644 --- a/src/simplnx/Utilities/IParallelAlgorithm.cpp +++ b/src/simplnx/Utilities/IParallelAlgorithm.cpp @@ -2,10 +2,34 @@ #include "simplnx/Core/Application.hpp" -namespace nx::core +namespace +{ +// ----------------------------------------------------------------------------- +bool CheckStoresInMemory(const nx::core::IParallelAlgorithm::AlgorithmStores& stores) { + if(stores.empty()) + { + return true; + } + + for(const auto* storePtr : stores) + { + if(storePtr == nullptr) + { + continue; + } + + if(!storePtr->getDataFormat().empty()) + { + return false; + } + } + + return true; +} + // ----------------------------------------------------------------------------- -bool IParallelAlgorithm::CheckArraysInMemory(const AlgorithmArrays& arrays) +bool CheckArraysInMemory(const nx::core::IParallelAlgorithm::AlgorithmArrays& arrays) { if(arrays.empty()) { @@ -27,7 +51,10 @@ bool IParallelAlgorithm::CheckArraysInMemory(const AlgorithmArrays& arrays) return true; } +} // namespace +namespace nx::core +{ // ----------------------------------------------------------------------------- IParallelAlgorithm::IParallelAlgorithm() { @@ -58,4 +85,10 @@ void IParallelAlgorithm::requireArraysInMemory(const AlgorithmArrays& arrays) { setParallelizationEnabled(CheckArraysInMemory(arrays)); } + +// ----------------------------------------------------------------------------- +void IParallelAlgorithm::requireStoresInMemory(const AlgorithmStores& stores) +{ + setParallelizationEnabled(::CheckStoresInMemory(stores)); +} } // namespace nx::core diff --git a/src/simplnx/Utilities/IParallelAlgorithm.hpp b/src/simplnx/Utilities/IParallelAlgorithm.hpp index 3a1e5aee21..1ec99a1dde 100644 --- a/src/simplnx/Utilities/IParallelAlgorithm.hpp +++ b/src/simplnx/Utilities/IParallelAlgorithm.hpp @@ -2,6 +2,7 @@ #include "simplnx/Common/Types.hpp" #include "simplnx/DataStructure/IDataArray.hpp" +#include "simplnx/DataStructure/IDataStore.hpp" #include "simplnx/simplnx_export.hpp" #include @@ -12,8 +13,7 @@ class SIMPLNX_EXPORT IParallelAlgorithm { public: using AlgorithmArrays = std::vector; - - static bool CheckArraysInMemory(const AlgorithmArrays& arrays); + using AlgorithmStores = std::vector; IParallelAlgorithm(const IParallelAlgorithm&) = default; IParallelAlgorithm(IParallelAlgorithm&&) noexcept = default; @@ -24,7 +24,7 @@ class SIMPLNX_EXPORT IParallelAlgorithm * @brief Returns true if parallelization is enabled. Returns false otherwise. * @return */ - bool getParallelizationEnabled() const; + [[nodiscard]] bool getParallelizationEnabled() const; /** * @brief Sets whether parallelization is enabled. @@ -34,6 +34,8 @@ class SIMPLNX_EXPORT IParallelAlgorithm void requireArraysInMemory(const AlgorithmArrays& arrays); + void requireStoresInMemory(const AlgorithmStores& arrays); + protected: IParallelAlgorithm(); ~IParallelAlgorithm(); diff --git a/src/simplnx/Utilities/ImageRotationUtilities.cpp b/src/simplnx/Utilities/ImageRotationUtilities.cpp index aad749340c..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); @@ -140,7 +140,7 @@ std::string GenerateTransformationMatrixDescription(const ImageRotationUtilities } //------------------------------------------------------------------------------ -ImageRotationUtilities::Matrix4fR CopyPrecomputedToTransformationMatrix(const Float32Array& precomputed) +ImageRotationUtilities::Matrix4fR CopyPrecomputedToTransformationMatrix(const AbstractDataStore& precomputed) { ImageRotationUtilities::Matrix4fR transformationMatrix; transformationMatrix.fill(0.0F); diff --git a/src/simplnx/Utilities/ImageRotationUtilities.hpp b/src/simplnx/Utilities/ImageRotationUtilities.hpp index 82d9169ffe..3553c3c127 100644 --- a/src/simplnx/Utilities/ImageRotationUtilities.hpp +++ b/src/simplnx/Utilities/ImageRotationUtilities.hpp @@ -69,7 +69,7 @@ SIMPLNX_EXPORT std::string GenerateTransformationMatrixDescription(const ImageRo * @param precomputed * @return */ -SIMPLNX_EXPORT Matrix4fR CopyPrecomputedToTransformationMatrix(const Float32Array& precomputed); +SIMPLNX_EXPORT Matrix4fR CopyPrecomputedToTransformationMatrix(const AbstractDataStore& precomputed); /** * @brief @@ -401,7 +401,7 @@ class RotateImageGeometryWithTrilinearInterpolation m_FilterCallback->sendThreadSafeProgressMessage(fmt::format("{}: Transform Starting", sourceArray.getName())); - auto& newDataStore = m_TargetArray->getIDataStoreRefAs>(); + auto& newDataStore = m_TargetArray->template getIDataStoreRefAs>(); DataStructure tempDataStructure; ImageGeom* origImageGeomPtr = ImageGeom::Create(tempDataStructure, "Temp"); @@ -517,8 +517,8 @@ class RotateImageGeometryWithNearestNeighbor destImageGeomPtr->setSpacing(m_Params.TransformedSpacing); destImageGeomPtr->setOrigin(m_Params.TransformedOrigin); - const auto& oldDataStore = m_SourceArray->getIDataStoreRefAs>(); - auto& newDataStore = m_TargetArray->getIDataStoreRefAs>(); + const auto& oldDataStore = m_SourceArray->template getIDataStoreRefAs>(); + auto& newDataStore = m_TargetArray->template getIDataStoreRefAs>(); Matrix4fR inverseTransform = m_TransformationMatrix.inverse(); for(int64 k = 0; k < m_Params.zpNew; k++) diff --git a/src/simplnx/Utilities/Math/GeometryMath.cpp b/src/simplnx/Utilities/Math/GeometryMath.cpp index 23a330a0d1..519e89983d 100644 --- a/src/simplnx/Utilities/Math/GeometryMath.cpp +++ b/src/simplnx/Utilities/Math/GeometryMath.cpp @@ -34,7 +34,7 @@ BoundingBox3Df nx::core::GeometryMath::FindBoundingBoxOfVertices(INodeGeometry0D return {ll, ur}; // will be invalid } - auto& vertexListStore = vertexList.getIDataStoreRefAs>(); + auto& vertexListStore = vertexList.template getIDataStoreRefAs>(); for(size_t tuple = 0; tuple < vertexListStore.getNumberOfTuples(); tuple++) { diff --git a/src/simplnx/Utilities/OStreamUtilities.cpp b/src/simplnx/Utilities/OStreamUtilities.cpp index f3929f823c..6ccc78078e 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->template 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.template 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 ParseVertices(const std::string& inputFile, const std::string& delimiter, bool headerLine) -{ - std::fstream in(inputFile, std::ios_base::in); - if(!in.is_open()) - { - std::cout << "Could not open input file: " << inputFile << std::endl; - return {}; - } - - std::vector data; - char delim = delimiter.at(0); - std::string buf; - // Scan the file to figure out about how many values will be in the file - size_t lineCount = 1; - if(headerLine) - { - std::getline(in, buf); - } - while(!in.eof()) - { - std::getline(in, buf); - lineCount++; - } - // Put the input stream back to the start - in.clear(); // clear fail and eof bits - in.seekg(0, std::ios::beg); // back to the start! - if(headerLine) - { - std::getline(in, buf); - } - data.reserve(lineCount * 3); // Just reserve the worst case possible. - while(!in.eof()) - { - std::getline(in, buf); - if(buf.empty()) - { - continue; - } - std::vector tokens = nx::core::StringUtilities::split(buf, delim); - float value = static_cast(std::atof(tokens[0].c_str())); - data.push_back(value); - value = static_cast(std::atof(tokens[1].c_str())); - data.push_back(value); - value = static_cast(std::atof(tokens[2].c_str())); - data.push_back(value); - } - in.close(); - - return data; -} - } // namespace CsvParser } // namespace nx::core diff --git a/src/simplnx/Utilities/Parsing/Text/CsvParser.hpp b/src/simplnx/Utilities/Parsing/Text/CsvParser.hpp index d5a1f4a456..abf5a33aa7 100644 --- a/src/simplnx/Utilities/Parsing/Text/CsvParser.hpp +++ b/src/simplnx/Utilities/Parsing/Text/CsvParser.hpp @@ -18,15 +18,11 @@ namespace fs = std::filesystem; -namespace nx::core -{ -namespace CsvParser +namespace nx::core::CsvParser { constexpr int32_t k_RBR_NO_ERROR = 0; constexpr int32_t k_RBR_FILE_NOT_OPEN = -1000; -constexpr int32_t k_RBR_FILE_TOO_SMALL = -1010; -constexpr int32_t k_RBR_FILE_TOO_BIG = -1020; constexpr int32_t k_RBR_READ_EOF = -1030; constexpr int32_t k_RBR_READ_FAIL = -1035; constexpr int32_t k_RBR_READ_ERROR = 1040; @@ -37,10 +33,10 @@ constexpr size_t k_BufferSize = 1024; class DelimiterType : public std::ctype { - std::ctype::mask my_table[std::ctype::table_size]; + std::ctype::mask my_table[std::ctype::table_size] = {}; public: - DelimiterType(char delimiter, size_t refs = 0) + explicit DelimiterType(char delimiter, size_t refs = 0) : std::ctype(&my_table[0], false, refs) { std::copy_n(std::ctype::classic_table(), table_size, my_table); @@ -90,9 +86,9 @@ SIMPLNX_EXPORT int32_t ReadLine(std::istream& in, char* buffer, size_t length); * @return Result<> with any errors or warnings that were encountered. */ template -Result<> ReadFile(const fs::path& filename, DataArray& data, uint64_t skipHeaderLines, char delimiter, bool inputIsBool = false) +Result<> ReadFile(const fs::path& filename, AbstractDataStore& data, uint64_t skipHeaderLines, char delimiter, bool inputIsBool = false) { - int32_t err = k_RBR_NO_ERROR; + int32 err; if(!fs::exists(filename)) { return MakeErrorResult(k_RBR_FILE_NOT_EXIST, fmt::format("Input file does not exist: {}", filename.string())); @@ -129,7 +125,7 @@ Result<> ReadFile(const fs::path& filename, DataArray& data, uint64_t skipHea if(inputIsBool) { double value = 0.0; - int64_t* si64Ptr = reinterpret_cast(&value); + auto* si64Ptr = reinterpret_cast(&value); for(size_t i = 0; i < totalSize; ++i) { in >> value; @@ -184,9 +180,9 @@ Result<> ReadFile(const fs::path& filename, DataArray& data, uint64_t skipHea * @return Result<> with any errors or warnings that were encountered. */ template -Result<> ReadFile(const fs::path& filename, DataArray& data, uint64_t skipHeaderLines, char delimiter) +Result<> ReadFile(const fs::path& filename, AbstractDataStore& data, uint64_t skipHeaderLines, char delimiter) { - int32_t err = k_RBR_NO_ERROR; + int32 err; if(!fs::exists(filename)) { return MakeErrorResult(k_RBR_FILE_NOT_EXIST, fmt::format("Input file does not exist: {}", filename.string())); @@ -243,8 +239,4 @@ Result<> ReadFile(const fs::path& filename, DataArray& data, uint64_t skipHea return {}; } - -SIMPLNX_EXPORT std::vector ParseVertices(const std::string& inputFile, const std::string& delimiter, bool headerLine); - -} // namespace CsvParser -} // namespace nx::core +} // namespace nx::core::CsvParser diff --git a/src/simplnx/Utilities/SampleSurfaceMesh.cpp b/src/simplnx/Utilities/SampleSurfaceMesh.cpp index 7672edb20b..03916cb407 100644 --- a/src/simplnx/Utilities/SampleSurfaceMesh.cpp +++ b/src/simplnx/Utilities/SampleSurfaceMesh.cpp @@ -17,10 +17,9 @@ namespace class SampleSurfaceMeshImpl { public: - SampleSurfaceMeshImpl(SampleSurfaceMesh* filter, const TriangleGeom& faces, const std::vector>& faceIds, const std::vector& faceBBs, - const std::vector& points, Int32Array& 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,12 +73,11 @@ class SampleSurfaceMeshImpl } private: - SampleSurfaceMesh* m_Filter = nullptr; const TriangleGeom& m_Faces; const std::vector>& m_FaceIds; const std::vector& m_FaceBBs; const std::vector& m_Points; - Int32Array& m_PolyIds; + Int32AbstractDataStore& m_PolyIds; const std::atomic_bool& m_ShouldCancel; }; @@ -88,7 +86,7 @@ class SampleSurfaceMeshImplByPoints { public: SampleSurfaceMeshImplByPoints(SampleSurfaceMesh* filter, const TriangleGeom& faces, const std::vector& faceIds, const std::vector& faceBBs, - const std::vector& points, const usize featureId, Int32Array& polyIds, const std::atomic_bool& shouldCancel) + const std::vector& points, const usize featureId, Int32AbstractDataStore& polyIds, const std::atomic_bool& shouldCancel) : m_Filter(filter) , m_Faces(faces) , m_FaceIds(faceIds) @@ -148,7 +146,7 @@ class SampleSurfaceMeshImplByPoints const std::vector& m_FaceIds; const std::vector& m_FaceBBs; const std::vector& m_Points; - Int32Array& m_PolyIds; + Int32AbstractDataStore& m_PolyIds; const usize m_FeatureId = 0; const std::atomic_bool& m_ShouldCancel; }; @@ -175,7 +173,7 @@ void SampleSurfaceMesh::updateProgress(const std::string& progMessage) Result<> SampleSurfaceMesh::execute(SampleSurfaceMeshInputValues& inputValues) { auto& triangleGeom = m_DataStructure.getDataRefAs(inputValues.TriangleGeometryPath); - auto& faceLabelsSM = m_DataStructure.getDataRefAs(inputValues.SurfaceMeshFaceLabelsArrayPath); + auto& faceLabelsSM = m_DataStructure.getDataAs(inputValues.SurfaceMeshFaceLabelsArrayPath)->getDataStoreRef(); // pull down faces usize numFaces = faceLabelsSM.getNumberOfTuples(); @@ -277,7 +275,7 @@ Result<> SampleSurfaceMesh::execute(SampleSurfaceMeshInputValues& inputValues) generatePoints(points); // create array to hold which polyhedron (feature) each point falls in - auto& polyIds = m_DataStructure.getDataRefAs(inputValues.FeatureIdsArrayPath); + auto& polyIds = m_DataStructure.getDataAs(inputValues.FeatureIdsArrayPath)->getDataStoreRef(); updateProgress("Sampling triangle geometry ..."); @@ -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 { diff --git a/src/simplnx/Utilities/SamplingUtils.hpp b/src/simplnx/Utilities/SamplingUtils.hpp index 493eb99e15..3b9d4d37d3 100644 --- a/src/simplnx/Utilities/SamplingUtils.hpp +++ b/src/simplnx/Utilities/SamplingUtils.hpp @@ -7,9 +7,7 @@ #include "simplnx/Filter/IFilter.hpp" #include "simplnx/Utilities/DataGroupUtilities.hpp" -namespace nx::core -{ -namespace Sampling +namespace nx::core::Sampling { inline Result<> RenumberFeatures(DataStructure& dataStructure, const DataPath& newGeomPath, const DataPath& destCellFeatAttributeMatrixPath, const DataPath& featureIdsArrayPath, const DataPath& destFeatureIdsArrayPath, const IFilter::MessageHandler& messageHandler, const std::atomic_bool& shouldCancel = false) @@ -28,9 +26,7 @@ inline Result<> RenumberFeatures(DataStructure& dataStructure, const DataPath& n return MakeErrorResult(-600, "The number of Features is 0 and should be greater than 0"); } - auto& destFeatureIdsRef = dataStructure.getDataRefAs(destFeatureIdsArrayPath); - - auto& featureIds = destFeatureIdsRef.getDataStoreRef(); + auto& destFeatureIds = dataStructure.getDataAs(destFeatureIdsArrayPath)->getDataStoreRef(); // Find the unique set of feature ids for(usize i = 0; i < totalPoints; ++i) { @@ -39,7 +35,7 @@ inline Result<> RenumberFeatures(DataStructure& dataStructure, const DataPath& n break; } - int32 currentFeatureId = featureIds[i]; + int32 currentFeatureId = destFeatureIds[i]; if(currentFeatureId < 0) { std::string ss = fmt::format("FeatureIds values MUST be >= ZERO. Negative FeatureId found at index {} into the resampled feature ids array", i); @@ -58,12 +54,11 @@ inline Result<> RenumberFeatures(DataStructure& dataStructure, const DataPath& n } } - if(!RemoveInactiveObjects(dataStructure, destCellFeatAttributeMatrixPath, activeObjects, destFeatureIdsRef, totalFeatures, messageHandler, shouldCancel)) + if(!RemoveInactiveObjects(dataStructure, destCellFeatAttributeMatrixPath, activeObjects, destFeatureIds, totalFeatures, messageHandler, shouldCancel)) { std::string ss = fmt::format("An error occurred while trying to remove the inactive objects from Attribute Matrix '{}'", destCellFeatAttributeMatrixPath.toString()); return MakeErrorResult(-606, ss); } return {}; } -} // namespace Sampling -} // namespace nx::core +} // namespace nx::core::Sampling diff --git a/test/H5Test.cpp b/test/H5Test.cpp index 2101c48d49..fad1eed55d 100644 --- a/test/H5Test.cpp +++ b/test/H5Test.cpp @@ -184,7 +184,7 @@ void CreateVertexGeometry(DataStructure& dataStructure) nx::core::Result result = nx::core::CreateArray(dataStructure, {vertexCount}, {3}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto vertexArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *vertexArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, vertexArray->getDataStoreRef(), skipLines, delimiter); vertexGeometry->setVertices(*vertexArray); REQUIRE(vertexGeometry->getNumberOfVertices() == 144); @@ -221,7 +221,7 @@ void CreateTriangleGeometry(DataStructure& dataStructure) nx::core::Result result = nx::core::CreateArray(dataStructure, {faceCount}, {3}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *dataArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, dataArray->getDataStoreRef(), skipLines, delimiter); triangleGeom->setFaceList(*dataArray); // Create the Vertex Array with a component size of 3 @@ -232,7 +232,7 @@ void CreateTriangleGeometry(DataStructure& dataStructure) result = nx::core::CreateArray(dataStructure, {vertexCount}, {3}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto vertexArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *vertexArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, vertexArray->getDataStoreRef(), skipLines, delimiter); triangleGeom->setVertices(*vertexArray); } @@ -255,7 +255,7 @@ void CreateQuadGeometry(DataStructure& dataStructure) nx::core::Result result = nx::core::CreateArray(dataStructure, {faceCount}, {4}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *dataArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, dataArray->getDataStoreRef(), skipLines, delimiter); geometry->setFaceList(*dataArray); // Create the Vertex Array with a component size of 3 @@ -266,7 +266,7 @@ void CreateQuadGeometry(DataStructure& dataStructure) result = nx::core::CreateArray(dataStructure, {vertexCount}, {3}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto vertexArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *vertexArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, vertexArray->getDataStoreRef(), skipLines, delimiter); geometry->setVertices(*vertexArray); } @@ -289,7 +289,7 @@ void CreateEdgeGeometry(DataStructure& dataStructure) nx::core::Result result = nx::core::CreateArray(dataStructure, {faceCount}, {2}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *dataArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, dataArray->getDataStoreRef(), skipLines, delimiter); geometry->setEdgeList(*dataArray); // Create the Vertex Array with a component size of 3 @@ -300,7 +300,7 @@ void CreateEdgeGeometry(DataStructure& dataStructure) result = nx::core::CreateArray(dataStructure, {vertexCount}, {3}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto vertexArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *vertexArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, vertexArray->getDataStoreRef(), skipLines, delimiter); geometry->setVertices(*vertexArray); } @@ -323,7 +323,7 @@ void CreateTetrahedralGeometry(DataStructure& dataStructure) nx::core::Result result = nx::core::CreateArray(dataStructure, {faceCount}, {4}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *dataArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, dataArray->getDataStoreRef(), skipLines, delimiter); geometry->setPolyhedraList(*dataArray); // Create the Vertex Array with a component size of 3 @@ -334,7 +334,7 @@ void CreateTetrahedralGeometry(DataStructure& dataStructure) result = nx::core::CreateArray(dataStructure, {vertexCount}, {3}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto vertexArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *vertexArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, vertexArray->getDataStoreRef(), skipLines, delimiter); geometry->setVertices(*vertexArray); } @@ -357,7 +357,7 @@ void CreateHexahedralGeometry(DataStructure& dataStructure) nx::core::Result result = nx::core::CreateArray(dataStructure, {faceCount}, {8}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto dataArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *dataArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, dataArray->getDataStoreRef(), skipLines, delimiter); geometry->setPolyhedraList(*dataArray); // Create the Vertex Array with a component size of 3 @@ -368,7 +368,7 @@ void CreateHexahedralGeometry(DataStructure& dataStructure) result = nx::core::CreateArray(dataStructure, {vertexCount}, {3}, path, IDataAction::Mode::Execute); REQUIRE(result.valid()); auto vertexArray = nx::core::ArrayFromPath(dataStructure, path); - CsvParser::ReadFile(inputFile, *vertexArray, skipLines, delimiter); + CsvParser::ReadFile(inputFile, vertexArray->getDataStoreRef(), skipLines, delimiter); geometry->setVertices(*vertexArray); } diff --git a/test/UnitTestCommon/include/simplnx/UnitTest/UnitTestCommon.hpp b/test/UnitTestCommon/include/simplnx/UnitTest/UnitTestCommon.hpp index 27b03cecd1..a3576cc674 100644 --- a/test/UnitTestCommon/include/simplnx/UnitTest/UnitTestCommon.hpp +++ b/test/UnitTestCommon/include/simplnx/UnitTest/UnitTestCommon.hpp @@ -452,8 +452,8 @@ inline void CompareMontage(const AbstractMontage& exemplar, const AbstractMontag template void CompareDataArrays(const IDataArray& left, const IDataArray& right, usize start = 0) { - const auto& oldDataStore = left.getIDataStoreRefAs>(); - const auto& newDataStore = right.getIDataStoreRefAs>(); + const auto& oldDataStore = left.template getIDataStoreRefAs>(); + const auto& newDataStore = right.template getIDataStoreRefAs>(); usize end = oldDataStore.getSize(); INFO(fmt::format("Input Data Array:'{}' Output DataArray: '{}' bad comparison", left.getName(), right.getName())); T oldVal;