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 eab5207a2f..7441b32ba0 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; @@ -155,39 +155,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); - // for(usize tuple = faceLabelOffset; tuple < faceLabelOffset + currentGeomNumTriangles; tuple++) - // { - // faceLabels[tuple] = fileIndex; - // } - 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); - // for(usize tuple = vertexLabelOffset; tuple < vertexLabelOffset + currentGeomNumVertices; tuple++) - // { - // vertexLabels[tuple] = fileIndex; - // } - 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..bb7051f1a5 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 @@ -19,7 +18,7 @@ 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,7 +33,7 @@ class GenerateHistogramFromData void operator()() const { - const auto& inputArray = dynamic_cast&>(m_InputArray); + const auto& inputArray = dynamic_cast&>(m_InputArray).getDataStoreRef(); auto end = inputArray.getSize(); // tuple visualization: Histogram = {(bin maximum, count), (bin maximum, count), ... } @@ -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/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];