diff --git a/src/Plugins/OrientationAnalysis/docs/ComputeShapesTriangleGeomFilter.md b/src/Plugins/OrientationAnalysis/docs/ComputeShapesTriangleGeomFilter.md index 19d6bc1e59..9299ef2a4b 100644 --- a/src/Plugins/OrientationAnalysis/docs/ComputeShapesTriangleGeomFilter.md +++ b/src/Plugins/OrientationAnalysis/docs/ComputeShapesTriangleGeomFilter.md @@ -4,7 +4,7 @@ Statistics (Morphological) -## Warning +## Caveats This filter has two caveats. diff --git a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ComputeFeatureNeighborCAxisMisalignments.cpp b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ComputeFeatureNeighborCAxisMisalignments.cpp index a568de8148..47c50b41a2 100644 --- a/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ComputeFeatureNeighborCAxisMisalignments.cpp +++ b/src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ComputeFeatureNeighborCAxisMisalignments.cpp @@ -71,7 +71,7 @@ Result<> ComputeFeatureNeighborCAxisMisalignments::operator()() const usize totalFeatures = featurePhases.getNumberOfTuples(); const usize numQuatComps = featureAvgQuat.getNumberOfComponents(); - std::vector> misalignmentLists(totalFeatures); + std::vector> misalignmentLists(totalFeatures); const Eigen::Vector3d cAxis{0.0, 0.0, 1.0}; usize hexNeighborListSize = 0; @@ -129,7 +129,7 @@ Result<> ComputeFeatureNeighborCAxisMisalignments::operator()() } // Convert the misorientation to Degrees and store the value - currentMisalignmentList[j] = w * Constants::k_180OverPiD; + currentMisalignmentList[j] = static_cast(w * Constants::k_180OverPiD); // If we are finding the average misorientation, then start accumulating those values if(m_InputValues->FindAvgMisals) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp index 0b0c0bda66..91ee62cce7 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp @@ -542,11 +542,11 @@ class MedianByFeatureRangeImpl { if(m_FindMedian) { - values.push_back(m_Source[i]); + values.push_back(static_cast(m_Source[i])); } if(m_FindNumUniqueValues) { - valuesSet.emplace(m_Source[i]); + valuesSet.emplace(static_cast(m_Source[i])); } } } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBoundingBoxStats.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBoundingBoxStats.cpp index 1decce87eb..2a3ebe98d4 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBoundingBoxStats.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBoundingBoxStats.cpp @@ -111,6 +111,10 @@ class ComputeBaseStatsImpl , m_UnifiedBounds(unifiedBounds) , m_StatsVector(statsVector) { + if constexpr(std::is_same_v) + { + throw std::runtime_error("ComputeBoundingBoxStats: Cannot use a boolean Data Array"); + } } ~ComputeBaseStatsImpl() = default; @@ -372,7 +376,14 @@ class ComputeBasicAndFrequencyStatsImpl count++; minValue = std::min(minValue, value); maxValue = std::max(maxValue, value); - summationValue += value; + if constexpr(std::is_same_v) + { + summationValue = value == true ? true : false; + } + else + { + summationValue += value; + } // modes frequencyMap[value]++; @@ -490,7 +501,15 @@ class ComputeStdDevImpl // We are working with primitives here for their trivially copyable nature, this lets us cut accesses to output vector float64 sumOfDiffs = 0.0f; - float32 meanValue = m_StatsVector[targetBoundsIndex].summationValue / static_cast(m_StatsVector[targetBoundsIndex].count); + float32 meanValue = 0.0f; + if constexpr(std::is_same_v) + { + meanValue = (m_StatsVector[targetBoundsIndex].summationValue ? 1.0f : 0.0f) / static_cast(m_StatsVector[targetBoundsIndex].count); + } + else + { + meanValue = m_StatsVector[targetBoundsIndex].summationValue / static_cast(m_StatsVector[targetBoundsIndex].count); + } usize zStride = 0, yStride = 0; for(usize zIndex = voxelIndices[k_MinZIndex]; zIndex < voxelIndices[k_MaxZIndex]; zIndex++) @@ -630,7 +649,8 @@ Result<> FillStatsArrays(const std::vector& statsVector, DataStruct float32 meanValue = 0.0f; if constexpr(std::is_same_v) { - meanValue = static_cast(statsVector[i].summationValue >= (statsVector.size() - statsVector[i].summationValue)); + usize sumValue = statsVector[i].summationValue == true ? 1ULL : 0ULL; + meanValue = static_cast(sumValue >= (statsVector.size() - sumValue)); } else { @@ -739,8 +759,6 @@ Result<> ComputeBoundingBoxStats::operator()() { return ExecuteNeighborFunction(ExecuteBoundsStatsCalculations{}, inputArray.getDataType(), m_DataStructure, m_InputValues, geom, unifiedArray, inputArray); } - else - { - return ExecuteDataFunction(ExecuteBoundsStatsCalculations{}, inputArray.getDataType(), m_DataStructure, m_InputValues, geom, unifiedArray, inputArray); - } + + return ExecuteDataFunction(ExecuteBoundsStatsCalculations{}, inputArray.getDataType(), m_DataStructure, m_InputValues, geom, unifiedArray, inputArray); } diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp index 8c3f061487..8e418887d7 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp @@ -177,7 +177,7 @@ IFilter::PreflightResult CreateDataArrayAdvancedFilter::preflightImpl(const Data usize numComponents = std::accumulate(compDims.begin(), compDims.end(), static_cast(1), std::multiplies<>()); if(numComponents <= 0) { - std::string compDimsStr = std::accumulate(compDims.begin() + 1ULL, compDims.end(), std::to_string(compDims[0]), [](const std::string& a, int b) { return a + " x " + std::to_string(b); }); + std::string compDimsStr = std::accumulate(compDims.begin() + 1ULL, compDims.end(), std::to_string(compDims[0]), [](const std::string& a, usize b) { return a + " x " + std::to_string(b); }); return MakePreflightErrorResult( -78601, fmt::format("The chosen component dimensions ({}) results in 0 total components. Please choose component dimensions that result in a positive number of total components.", compDimsStr)); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SplitDataArrayByTupleFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SplitDataArrayByTupleFilter.cpp index 2645cd38dd..96c2c32509 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SplitDataArrayByTupleFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SplitDataArrayByTupleFilter.cpp @@ -51,7 +51,7 @@ template std::string valuesToString(const std::vector& values, const std::string& token = " x ") { std::vector shapeStrs; - std::transform(values.cbegin(), values.cend(), std::back_inserter(shapeStrs), [](usize val) { return std::to_string(val); }); + std::transform(values.cbegin(), values.cend(), std::back_inserter(shapeStrs), [](T val) { return std::to_string(val); }); std::vector shapeStrViews(shapeStrs.begin(), shapeStrs.end()); return StringUtilities::join(shapeStrViews, token); } @@ -229,8 +229,11 @@ Result<> preflightAttrMatrixOutput(SplitDataArrayByTuple::OutputContainer output fmt::format("Attribute matrix tuple shape contains \"{}\" at Tuple Dim {}. All tuple shape values must be >= 1.", newAttrMatrixTupleShape[j], j))}; } } - - tupleShape = std::vector(newAttrMatrixTupleShape.begin(), newAttrMatrixTupleShape.end()); + tupleShape.resize(newAttrMatrixTupleShape.size()); + for(size_t i = 0; i < newAttrMatrixTupleShape.size(); i++) + { + tupleShape[i] = static_cast(newAttrMatrixTupleShape[i]); + } } else { diff --git a/src/Plugins/SimplnxCore/test/CombineNodeBasedGeometriesTest.cpp b/src/Plugins/SimplnxCore/test/CombineNodeBasedGeometriesTest.cpp index f26f541d5d..9da51e7c84 100644 --- a/src/Plugins/SimplnxCore/test/CombineNodeBasedGeometriesTest.cpp +++ b/src/Plugins/SimplnxCore/test/CombineNodeBasedGeometriesTest.cpp @@ -113,7 +113,7 @@ void AddNeighborList(AttributeMatrix& attrMatrix, DataStructure& dataStructure) for(usize i = 0; i < attrMatrix.getNumTuples(); i++) { typename NeighborList::SharedVectorType inputList(new std::vector(k_NeighborListListSize)); - std::iota(inputList->begin(), inputList->end(), 0); + std::iota(inputList->begin(), inputList->end(), static_cast(0)); nl->setList(i, inputList); } } @@ -175,7 +175,7 @@ template (geom, dataStructure, sharedListName, numElements, getNumPerElement(geom)); - std::iota(arr->begin(), arr->end(), 0); + std::iota(arr->begin(), arr->end(), static_cast(0)); setNodeArray(geom, *arr); } diff --git a/src/Plugins/SimplnxCore/test/CombineTransformationMatricesTest.cpp b/src/Plugins/SimplnxCore/test/CombineTransformationMatricesTest.cpp index e82c5a3020..6455cd55fb 100644 --- a/src/Plugins/SimplnxCore/test/CombineTransformationMatricesTest.cpp +++ b/src/Plugins/SimplnxCore/test/CombineTransformationMatricesTest.cpp @@ -84,8 +84,8 @@ void CreateTestImageGeometry(DataStructure& dataStructure, const std::string& ge geom->setCellData(*am); UInt32Array* testArray = UInt32Array::CreateWithStore(dataStructure, k_CellArrayName, amDims, cDims, am->getId()); - auto numComps = std::accumulate(cDims.begin(), cDims.end(), 1, std::multiplies<>()); - std::generate(testArray->begin(), testArray->end(), [n = 0, numComps]() mutable { return 1 + (n++ / numComps); }); + usize numComps = std::accumulate(cDims.begin(), cDims.end(), 1ULL, std::multiplies<>()); + std::generate(testArray->begin(), testArray->end(), [n = 0, numComps]() mutable { return static_cast(1 + (n++ / numComps)); }); } void CreateTestVertexGeometry(DataStructure& dataStructure, const std::string& geomName) @@ -97,7 +97,7 @@ void CreateTestVertexGeometry(DataStructure& dataStructure, const std::string& g AttributeMatrix* am = AttributeMatrix::Create(dataStructure, VertexGeom::k_VertexAttributeMatrixName, {16}, geom->getId()); geom->setVertexAttributeMatrix(*am); Int64Array* testArray = Int64Array::CreateWithStore(dataStructure, k_CellArrayName, {16}, {2}, am->getId()); - std::iota(testArray->begin(), testArray->end(), 0.0f); + std::iota(testArray->begin(), testArray->end(), static_cast(0)); } void CompareGeometries(const DataStructure& dataStructure, const DataPath& exemplaryGeomPath, const DataPath& resultGeomPath) diff --git a/src/Plugins/SimplnxCore/test/ComputeSurfaceFeaturesTest.cpp b/src/Plugins/SimplnxCore/test/ComputeSurfaceFeaturesTest.cpp index 33e4dde6e6..3b7e0d6f6e 100644 --- a/src/Plugins/SimplnxCore/test/ComputeSurfaceFeaturesTest.cpp +++ b/src/Plugins/SimplnxCore/test/ComputeSurfaceFeaturesTest.cpp @@ -10,6 +10,7 @@ namespace fs = std::filesystem; using namespace nx::core; +using namespace nx::core::UnitTest; namespace { @@ -23,6 +24,18 @@ const DataPath k_SurfaceFeaturesArrayPath = k_CellFeatureAMPath.createChildPath( const std::string k_FeatureIds2DFileName = "FindSurfaceFeaturesTest/FeatureIds_2D.raw"; const std::string k_SurfaceFeatures2DExemplaryFileName = "FindSurfaceFeaturesTest/SurfaceFeatures2D.raw"; +template +std::vector ConvertVectorReverse(const std::vector& input) +{ + std::vector result; + result.reserve(input.size()); + for(auto it = input.rbegin(); it != input.rend(); ++it) + { + result.emplace_back(static_cast(*it)); + } + return result; +} + void test_impl(const std::vector& geometryDims, const std::string& featureIdsFileName, const std::string& exemplaryFileName) { UnitTest::LoadPlugins(); @@ -43,9 +56,9 @@ void test_impl(const std::vector& geometryDims, const std::string& featu ReadRawBinaryFilter rbrFilter; Arguments rbrArgs; rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_InputFile_Key, fs::path(unit_test::k_TestFilesDir.str()).append(featureIdsFileName)); - rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_NumberOfComponents_Key, std::make_any(1)); + rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_NumberOfComponents_Key, std::make_any(1ULL)); rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_ScalarType_Key, NumericType::int32); - rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_TupleDims_Key, DynamicTableParameter::ValueType({std::vector(geometryDims.rbegin(), geometryDims.rend())})); + rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_TupleDims_Key, DynamicTableParameter::ValueType({ConvertVectorReverse(geometryDims)})); rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_CreatedAttributeArrayPath_Key, std::make_any(k_FeatureIDsPath)); result = rbrFilter.execute(dataStructure, rbrArgs); @@ -65,7 +78,7 @@ void test_impl(const std::vector& geometryDims, const std::string& featu rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_InputFile_Key, fs::path(unit_test::k_TestFilesDir.str()).append(exemplaryFileName)); rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_ScalarType_Key, NumericType::int8); - rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_TupleDims_Key, DynamicTableParameter::ValueType({{796}})); + rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_TupleDims_Key, DynamicTableParameter::ValueType({{796.0}})); rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_CreatedAttributeArrayPath_Key, std::make_any(k_SurfaceFeaturesExemplaryPath)); result = rbrFilter.execute(dataStructure, rbrArgs); diff --git a/src/Plugins/SimplnxCore/test/DBSCANTest.cpp b/src/Plugins/SimplnxCore/test/DBSCANTest.cpp index 36aa855cfa..c03ca0bff7 100644 --- a/src/Plugins/SimplnxCore/test/DBSCANTest.cpp +++ b/src/Plugins/SimplnxCore/test/DBSCANTest.cpp @@ -269,7 +269,7 @@ TEST_CASE("SimplnxCore::DBSCAN: 3D Test (LowDensityFirst)", "[SimplnxCore][DBSCA // Create default Parameters for the filter. args.insertOrAssign(DBSCANFilter::k_ParseOrderIndex_Key, std::make_any(to_underlying(DBSCAN::ParseOrder::LowDensityFirst))); - args.insertOrAssign(DBSCANFilter::k_Epsilon_Key, std::make_any(0.0099999998)); + args.insertOrAssign(DBSCANFilter::k_Epsilon_Key, std::make_any(0.0099999998f)); args.insertOrAssign(DBSCANFilter::k_MinPoints_Key, std::make_any(5)); args.insertOrAssign(DBSCANFilter::k_UseMask_Key, std::make_any(false)); args.insertOrAssign(DBSCANFilter::k_SelectedArrayPath_Key, std::make_any(targetPath)); diff --git a/src/Plugins/SimplnxCore/test/WriteNodesAndElementsFilesTest.cpp b/src/Plugins/SimplnxCore/test/WriteNodesAndElementsFilesTest.cpp index d5372e757d..4abdabedf5 100644 --- a/src/Plugins/SimplnxCore/test/WriteNodesAndElementsFilesTest.cpp +++ b/src/Plugins/SimplnxCore/test/WriteNodesAndElementsFilesTest.cpp @@ -51,12 +51,12 @@ void CreateEdgeGeometry(DataStructure& ds) auto vertexAttrMatrix = AttributeMatrix::Create(ds, "Vertex Data", {2}, geom->getId()); geom->setVertexAttributeMatrix(*vertexAttrMatrix); Float32Array* vertices = UnitTest::CreateTestDataArray(ds, "Vertices Store", {2}, {3}, geom->getId()); - std::vector verticesVec = {1, 1.5, 1.75, 2, 3, 4}; + std::vector verticesVec = {1.0f, 1.5f, 1.75f, 2.0f, 3.0f, 4.0f}; std::copy(verticesVec.begin(), verticesVec.end(), vertices->begin()); geom->setVertices(*vertices); DataArray* cells = UnitTest::CreateTestDataArray(ds, "Cells Store", {1}, {2}, geom->getId()); - std::vector cellsVec = {0, 1}; - std::copy(cellsVec.begin(), cellsVec.end(), cells->begin()); + cells->setValue(0, 0ULL); + cells->setValue(1, 1ULL); geom->setEdgeList(*cells); } diff --git a/src/simplnx/DataStructure/IO/HDF5/StringArrayIO.cpp b/src/simplnx/DataStructure/IO/HDF5/StringArrayIO.cpp index 9cbcd036ad..7a5116aabe 100644 --- a/src/simplnx/DataStructure/IO/HDF5/StringArrayIO.cpp +++ b/src/simplnx/DataStructure/IO/HDF5/StringArrayIO.cpp @@ -52,7 +52,7 @@ Result<> StringArrayIO::readData(DataStructureReader& dataStructureReader, const { tupleShape = std::move(tupleShapeResult.value()); } - usize numValues = std::accumulate(tupleShape.cbegin(), tupleShape.cend(), 1, std::multiplies<>()); + usize numValues = std::accumulate(tupleShape.cbegin(), tupleShape.cend(), 1ULL, std::multiplies<>()); std::vector strings = useEmptyDataStore ? std::vector(numValues) : datasetReader.readAsVectorOfStrings(); const auto* data = StringArray::Import(dataStructureReader.getDataStructure(), dataArrayName, tupleShape, importId, std::move(strings), parentId);