diff --git a/HDPS/src/plugins/PointData/src/PointData.h b/HDPS/src/plugins/PointData/src/PointData.h index f0379c1fd..05a940a28 100644 --- a/HDPS/src/plugins/PointData/src/PointData.h +++ b/HDPS/src/plugins/PointData/src/PointData.h @@ -179,6 +179,24 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData } + /// Converts the internal data if the specified `Index` has the same numerical value as the specified `elementTypeSpecifier`. + template + void convertInternalDataIfIndexEqualsElementTypeSpecifier(const ElementTypeSpecifier elementTypeSpecifier) + { + if (static_cast(Index) == elementTypeSpecifier) + { + convertInternalData::value_type>(); + } + } + + /// Converts the internal data as specified by the `elementTypeSpecifier`, using an `std::index_sequence`. + template + void convertInternalDataUsingIndexSequence(const std::index_sequence, const ElementTypeSpecifier elementTypeSpecifier) + { + (convertInternalDataIfIndexEqualsElementTypeSpecifier(elementTypeSpecifier), ...); + } + + template void CheckDimensionIndex(const DimensionIndex& dimensionIndex) const { @@ -373,6 +391,34 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData _numDimensions = static_cast(numDimensions); } + /// Converts the internal data to the specified element data element type, by static_cast. + template + void convertInternalData() + { + if (!std::holds_alternative>(_variantOfVectors)) + { + std::vector convertedData(getSizeOfVector()); + + std::visit([&convertedData](const auto& vec) + { + std::transform(vec.cbegin(), vec.cend(), convertedData.begin(), [](const auto elem) + { + return static_cast(elem); + }); + }, + _variantOfVectors); + + _variantOfVectors = std::move(convertedData); + } + } + + + void convertInternalData(const ElementTypeSpecifier elementTypeSpecifier) + { + convertInternalDataUsingIndexSequence(std::make_index_sequence>{}, elementTypeSpecifier); + } + + /// Copies the specified data into the internal data, sets the number of /// dimensions as specified, and sets the selected internal data type /// according to the specified data type T.