Skip to content

Commit f29027b

Browse files
committed
COMP: Fix MSVC template warnings
1 parent 5d22556 commit f29027b

File tree

12 files changed

+69
-32
lines changed

12 files changed

+69
-32
lines changed

src/Plugins/OrientationAnalysis/docs/ComputeShapesTriangleGeomFilter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Statistics (Morphological)
66

7-
## Warning
7+
## Caveats
88

99
This filter has two caveats.
1010

src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ComputeFeatureNeighborCAxisMisalignments.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Result<> ComputeFeatureNeighborCAxisMisalignments::operator()()
7171
const usize totalFeatures = featurePhases.getNumberOfTuples();
7272
const usize numQuatComps = featureAvgQuat.getNumberOfComponents();
7373

74-
std::vector<std::vector<double>> misalignmentLists(totalFeatures);
74+
std::vector<std::vector<float32>> misalignmentLists(totalFeatures);
7575

7676
const Eigen::Vector3d cAxis{0.0, 0.0, 1.0};
7777
usize hexNeighborListSize = 0;
@@ -129,7 +129,7 @@ Result<> ComputeFeatureNeighborCAxisMisalignments::operator()()
129129
}
130130

131131
// Convert the misorientation to Degrees and store the value
132-
currentMisalignmentList[j] = w * Constants::k_180OverPiD;
132+
currentMisalignmentList[j] = static_cast<float32>(w * Constants::k_180OverPiF);
133133

134134
// If we are finding the average misorientation, then start accumulating those values
135135
if(m_InputValues->FindAvgMisals)

src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,12 @@ class MedianByFeatureRangeImpl
526526
{
527527
}
528528

529-
void compute(usize start, usize end) const
529+
void compute(size_t start, size_t end) const
530530
{
531531
m_MessageHelper.sendMessage(fmt::format("Starting Median Array Calculation: Feature/Ensemble [{}-{}]", start, end));
532532

533533
const usize numTuples = m_Source.getNumberOfTuples();
534-
for(usize featureId = start; featureId < end; featureId++)
534+
for(size_t featureId = start; featureId < end; featureId++)
535535
{
536536
const usize truePosition = std::distance(m_FeatureIdsMap.begin(), std::find(m_FeatureIdsMap.begin(), m_FeatureIdsMap.end(), featureId));
537537
std::set<int32> valuesSet = {};
@@ -542,11 +542,11 @@ class MedianByFeatureRangeImpl
542542
{
543543
if(m_FindMedian)
544544
{
545-
values.push_back(m_Source[i]);
545+
values.push_back(static_cast<float>(m_Source[i]));
546546
}
547547
if(m_FindNumUniqueValues)
548548
{
549-
valuesSet.emplace(m_Source[i]);
549+
valuesSet.emplace(static_cast<int32>(m_Source[i]));
550550
}
551551
}
552552
}

src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeBoundingBoxStats.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,14 @@ class ComputeBaseStatsImpl
144144
count++;
145145
minValue = std::min(minValue, value);
146146
maxValue = std::max(maxValue, value);
147-
summationValue += value;
147+
if constexpr(std::is_same_v<T, bool>)
148+
{
149+
summationValue = value == true ? true : false;
150+
}
151+
else
152+
{
153+
summationValue += value;
154+
}
148155
}
149156
}
150157
}
@@ -372,7 +379,14 @@ class ComputeBasicAndFrequencyStatsImpl
372379
count++;
373380
minValue = std::min(minValue, value);
374381
maxValue = std::max(maxValue, value);
375-
summationValue += value;
382+
if constexpr(std::is_same_v<T, bool>)
383+
{
384+
summationValue = value == true ? true : false;
385+
}
386+
else
387+
{
388+
summationValue += value;
389+
}
376390

377391
// modes
378392
frequencyMap[value]++;
@@ -490,7 +504,15 @@ class ComputeStdDevImpl
490504

491505
// We are working with primitives here for their trivially copyable nature, this lets us cut accesses to output vector
492506
float64 sumOfDiffs = 0.0f;
493-
float32 meanValue = m_StatsVector[targetBoundsIndex].summationValue / static_cast<float32>(m_StatsVector[targetBoundsIndex].count);
507+
float32 meanValue = 0.0f;
508+
if constexpr(std::is_same_v<T, bool>)
509+
{
510+
meanValue = (m_StatsVector[targetBoundsIndex].summationValue ? 1.0f : 0.0f) / static_cast<float32>(m_StatsVector[targetBoundsIndex].count);
511+
}
512+
else
513+
{
514+
meanValue = m_StatsVector[targetBoundsIndex].summationValue / static_cast<float32>(m_StatsVector[targetBoundsIndex].count);
515+
}
494516

495517
usize zStride = 0, yStride = 0;
496518
for(usize zIndex = voxelIndices[k_MinZIndex]; zIndex < voxelIndices[k_MaxZIndex]; zIndex++)
@@ -630,7 +652,8 @@ Result<> FillStatsArrays(const std::vector<StatsCacheT>& statsVector, DataStruct
630652
float32 meanValue = 0.0f;
631653
if constexpr(std::is_same_v<T, bool>)
632654
{
633-
meanValue = static_cast<float32>(statsVector[i].summationValue >= (statsVector.size() - statsVector[i].summationValue));
655+
usize sumValue = statsVector[i].summationValue == true ? 1ULL : 0ULL;
656+
meanValue = static_cast<float32>(sumValue >= (statsVector.size() - sumValue));
634657
}
635658
else
636659
{
@@ -739,8 +762,6 @@ Result<> ComputeBoundingBoxStats::operator()()
739762
{
740763
return ExecuteNeighborFunction(ExecuteBoundsStatsCalculations<true>{}, inputArray.getDataType(), m_DataStructure, m_InputValues, geom, unifiedArray, inputArray);
741764
}
742-
else
743-
{
744-
return ExecuteDataFunction(ExecuteBoundsStatsCalculations<false>{}, inputArray.getDataType(), m_DataStructure, m_InputValues, geom, unifiedArray, inputArray);
745-
}
765+
766+
return ExecuteDataFunction(ExecuteBoundsStatsCalculations<false>{}, inputArray.getDataType(), m_DataStructure, m_InputValues, geom, unifiedArray, inputArray);
746767
}

src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ IFilter::PreflightResult CreateDataArrayAdvancedFilter::preflightImpl(const Data
177177
usize numComponents = std::accumulate(compDims.begin(), compDims.end(), static_cast<usize>(1), std::multiplies<>());
178178
if(numComponents <= 0)
179179
{
180-
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); });
180+
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); });
181181
return MakePreflightErrorResult(
182182
-78601,
183183
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));

src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SplitDataArrayByTupleFilter.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ template <typename T>
5151
std::string valuesToString(const std::vector<T>& values, const std::string& token = " x ")
5252
{
5353
std::vector<std::string> shapeStrs;
54-
std::transform(values.cbegin(), values.cend(), std::back_inserter(shapeStrs), [](usize val) { return std::to_string(val); });
54+
std::transform(values.cbegin(), values.cend(), std::back_inserter(shapeStrs), [](T val) { return std::to_string(val); });
5555
std::vector<std::string_view> shapeStrViews(shapeStrs.begin(), shapeStrs.end());
5656
return StringUtilities::join(shapeStrViews, token);
5757
}
@@ -229,8 +229,11 @@ Result<> preflightAttrMatrixOutput(SplitDataArrayByTuple::OutputContainer output
229229
fmt::format("Attribute matrix tuple shape contains \"{}\" at Tuple Dim {}. All tuple shape values must be >= 1.", newAttrMatrixTupleShape[j], j))};
230230
}
231231
}
232-
233-
tupleShape = std::vector<usize>(newAttrMatrixTupleShape.begin(), newAttrMatrixTupleShape.end());
232+
tupleShape.resize(newAttrMatrixTupleShape.size());
233+
for(size_t i = 0; i < newAttrMatrixTupleShape.size(); i++)
234+
{
235+
tupleShape[i] = static_cast<usize>(newAttrMatrixTupleShape[i]);
236+
}
234237
}
235238
else
236239
{

src/Plugins/SimplnxCore/test/CombineNodeBasedGeometriesTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void AddNeighborList(AttributeMatrix& attrMatrix, DataStructure& dataStructure)
113113
for(usize i = 0; i < attrMatrix.getNumTuples(); i++)
114114
{
115115
typename NeighborList<T>::SharedVectorType inputList(new std::vector<T>(k_NeighborListListSize));
116-
std::iota(inputList->begin(), inputList->end(), 0);
116+
std::iota(inputList->begin(), inputList->end(), static_cast<T>(0));
117117
nl->setList(i, inputList);
118118
}
119119
}
@@ -175,7 +175,7 @@ template <typename TGeom, typename TNode, typename TGetNumPerElement, typename T
175175
void CreateNodeArray(TGeom& geom, DataStructure& dataStructure, const std::string& sharedListName, usize numElements, TGetNumPerElement getNumPerElement, TSetNodeArray setNodeArray)
176176
{
177177
auto arr = CreateNodeArray<TNode>(geom, dataStructure, sharedListName, numElements, getNumPerElement(geom));
178-
std::iota(arr->begin(), arr->end(), 0);
178+
std::iota(arr->begin(), arr->end(), static_cast<TNode>(0));
179179
setNodeArray(geom, *arr);
180180
}
181181

src/Plugins/SimplnxCore/test/CombineTransformationMatricesTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ void CreateTestImageGeometry(DataStructure& dataStructure, const std::string& ge
8484
geom->setCellData(*am);
8585
UInt32Array* testArray = UInt32Array::CreateWithStore<UInt32DataStore>(dataStructure, k_CellArrayName, amDims, cDims, am->getId());
8686

87-
auto numComps = std::accumulate(cDims.begin(), cDims.end(), 1, std::multiplies<>());
88-
std::generate(testArray->begin(), testArray->end(), [n = 0, numComps]() mutable { return 1 + (n++ / numComps); });
87+
usize numComps = std::accumulate(cDims.begin(), cDims.end(), 1ULL, std::multiplies<>());
88+
std::generate(testArray->begin(), testArray->end(), [n = 0, numComps]() mutable { return static_cast<uint32>(1 + (n++ / numComps)); });
8989
}
9090

9191
void CreateTestVertexGeometry(DataStructure& dataStructure, const std::string& geomName)
@@ -97,7 +97,7 @@ void CreateTestVertexGeometry(DataStructure& dataStructure, const std::string& g
9797
AttributeMatrix* am = AttributeMatrix::Create(dataStructure, VertexGeom::k_VertexAttributeMatrixName, {16}, geom->getId());
9898
geom->setVertexAttributeMatrix(*am);
9999
Int64Array* testArray = Int64Array::CreateWithStore<Int64DataStore>(dataStructure, k_CellArrayName, {16}, {2}, am->getId());
100-
std::iota(testArray->begin(), testArray->end(), 0.0f);
100+
std::iota(testArray->begin(), testArray->end(), static_cast<int64_t>(0));
101101
}
102102

103103
void CompareGeometries(const DataStructure& dataStructure, const DataPath& exemplaryGeomPath, const DataPath& resultGeomPath)

src/Plugins/SimplnxCore/test/ComputeSurfaceFeaturesTest.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace fs = std::filesystem;
1212
using namespace nx::core;
13+
using namespace nx::core::UnitTest;
1314

1415
namespace
1516
{
@@ -23,6 +24,18 @@ const DataPath k_SurfaceFeaturesArrayPath = k_CellFeatureAMPath.createChildPath(
2324
const std::string k_FeatureIds2DFileName = "FindSurfaceFeaturesTest/FeatureIds_2D.raw";
2425
const std::string k_SurfaceFeatures2DExemplaryFileName = "FindSurfaceFeaturesTest/SurfaceFeatures2D.raw";
2526

27+
template <typename T, typename K>
28+
std::vector<K> ConvertVector(const std::vector<T>& input)
29+
{
30+
std::vector<K> result;
31+
result.reserve(input.size());
32+
for(const auto& v : input)
33+
{
34+
result.emplace_back(static_cast<K>(v));
35+
}
36+
return result;
37+
}
38+
2639
void test_impl(const std::vector<uint64>& geometryDims, const std::string& featureIdsFileName, const std::string& exemplaryFileName)
2740
{
2841
UnitTest::LoadPlugins();
@@ -43,9 +56,9 @@ void test_impl(const std::vector<uint64>& geometryDims, const std::string& featu
4356
ReadRawBinaryFilter rbrFilter;
4457
Arguments rbrArgs;
4558
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_InputFile_Key, fs::path(unit_test::k_TestFilesDir.str()).append(featureIdsFileName));
46-
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_NumberOfComponents_Key, std::make_any<uint64>(1));
59+
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_NumberOfComponents_Key, std::make_any<uint64>(1ULL));
4760
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_ScalarType_Key, NumericType::int32);
48-
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_TupleDims_Key, DynamicTableParameter::ValueType({std::vector<float64>(geometryDims.rbegin(), geometryDims.rend())}));
61+
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_TupleDims_Key, DynamicTableParameter::ValueType({ConvertVector<uint64, double>(geometryDims)}));
4962
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_CreatedAttributeArrayPath_Key, std::make_any<DataPath>(k_FeatureIDsPath));
5063

5164
result = rbrFilter.execute(dataStructure, rbrArgs);
@@ -65,7 +78,7 @@ void test_impl(const std::vector<uint64>& geometryDims, const std::string& featu
6578

6679
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_InputFile_Key, fs::path(unit_test::k_TestFilesDir.str()).append(exemplaryFileName));
6780
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_ScalarType_Key, NumericType::int8);
68-
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_TupleDims_Key, DynamicTableParameter::ValueType({{796}}));
81+
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_TupleDims_Key, DynamicTableParameter::ValueType({{796.0}}));
6982
rbrArgs.insertOrAssign(ReadRawBinaryFilter::k_CreatedAttributeArrayPath_Key, std::make_any<DataPath>(k_SurfaceFeaturesExemplaryPath));
7083

7184
result = rbrFilter.execute(dataStructure, rbrArgs);

src/Plugins/SimplnxCore/test/DBSCANTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ TEST_CASE("SimplnxCore::DBSCAN: 3D Test (LowDensityFirst)", "[SimplnxCore][DBSCA
269269

270270
// Create default Parameters for the filter.
271271
args.insertOrAssign(DBSCANFilter::k_ParseOrderIndex_Key, std::make_any<ChoicesParameter::ValueType>(to_underlying(DBSCAN::ParseOrder::LowDensityFirst)));
272-
args.insertOrAssign(DBSCANFilter::k_Epsilon_Key, std::make_any<float32>(0.0099999998));
272+
args.insertOrAssign(DBSCANFilter::k_Epsilon_Key, std::make_any<float32>(0.0099999998f));
273273
args.insertOrAssign(DBSCANFilter::k_MinPoints_Key, std::make_any<int32>(5));
274274
args.insertOrAssign(DBSCANFilter::k_UseMask_Key, std::make_any<bool>(false));
275275
args.insertOrAssign(DBSCANFilter::k_SelectedArrayPath_Key, std::make_any<DataPath>(targetPath));

0 commit comments

Comments
 (0)