@@ -179,6 +179,24 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData
179179 }
180180
181181
182+ // / Converts the internal data if the specified `Index` has the same numerical value as the specified `elementTypeSpecifier`.
183+ template <std::size_t Index>
184+ void convertInternalDataIfIndexEqualsElementTypeSpecifier (const ElementTypeSpecifier elementTypeSpecifier)
185+ {
186+ if (static_cast <ElementTypeSpecifier>(Index) == elementTypeSpecifier)
187+ {
188+ convertInternalData<typename std::variant_alternative_t <Index, VariantOfVectors>::value_type>();
189+ }
190+ }
191+
192+ // / Converts the internal data as specified by the `elementTypeSpecifier`, using an `std::index_sequence`.
193+ template <std::size_t ... Indices>
194+ void convertInternalDataUsingIndexSequence (const std::index_sequence<Indices...>, const ElementTypeSpecifier elementTypeSpecifier)
195+ {
196+ (convertInternalDataIfIndexEqualsElementTypeSpecifier<Indices>(elementTypeSpecifier), ...);
197+ }
198+
199+
182200 template <typename DimensionIndex>
183201 void CheckDimensionIndex (const DimensionIndex& dimensionIndex) const
184202 {
@@ -373,6 +391,31 @@ class POINTDATA_EXPORT PointData : public mv::plugin::RawData
373391 _numDimensions = static_cast <std::uint32_t >(numDimensions);
374392 }
375393
394+ // / Converts the internal data to the specified element data element type, by static_cast.
395+ template <typename T>
396+ void convertInternalData ()
397+ {
398+ std::vector<T> convertedData (getSizeOfVector ());
399+
400+ std::visit ([&convertedData](const auto & vec)
401+ {
402+ std::transform (vec.cbegin (), vec.cend (), convertedData.begin (), [](const auto elem)
403+ {
404+ return static_cast <T>(elem);
405+ });
406+ },
407+ _variantOfVectors);
408+
409+ _variantOfVectors = std::move (convertedData);
410+ }
411+
412+
413+ void convertInternalData (const ElementTypeSpecifier elementTypeSpecifier)
414+ {
415+ convertInternalDataUsingIndexSequence (std::make_index_sequence<std::variant_size_v<VariantOfVectors>>{}, elementTypeSpecifier);
416+ }
417+
418+
376419 // / Copies the specified data into the internal data, sets the number of
377420 // / dimensions as specified, and sets the selected internal data type
378421 // / according to the specified data type T.
0 commit comments