diff --git a/doc/snippets/MeshTools.cpp b/doc/snippets/MeshTools.cpp index ff5757e88..75fca2bf0 100644 --- a/doc/snippets/MeshTools.cpp +++ b/doc/snippets/MeshTools.cpp @@ -181,7 +181,7 @@ Containers::Array positions = mesh.positions3DAsArray(); /* Deduplicate the positions and create a mapping array */ Containers::Pair, std::size_t> out = MeshTools::removeDuplicatesFuzzyInPlace( - Containers::arrayCast<2, Float>(stridedArrayView(positions))); + stridedArrayView(positions).slice(&Vector3::data)); Containers::Array indexMapping = std::move(out.first()); arrayResize(positions, out.second()); @@ -369,15 +369,24 @@ data = data.prefix(unique.second()); { /* [removeDuplicatesFuzzy] */ -Containers::ArrayView positions; +Containers::StridedArrayView1D data; Containers::Pair, std::size_t> unique = - MeshTools::removeDuplicatesFuzzyInPlace( - Containers::arrayCast<2, Float>(positions)); -positions = positions.prefix(unique.second()); + MeshTools::removeDuplicatesFuzzyInPlace(data); +data = data.prefix(unique.second()); /* [removeDuplicatesFuzzy] */ } +{ +/* [removeDuplicatesFuzzy-vector-slice] */ +Containers::StridedArrayView1D positions; + +Containers::Pair, std::size_t> unique = + MeshTools::removeDuplicatesFuzzyInPlace(positions.slice(&Vector3::data)); +positions = positions.prefix(unique.second()); +/* [removeDuplicatesFuzzy-vector-slice] */ +} + #ifdef MAGNUM_BUILD_DEPRECATED { CORRADE_IGNORE_DEPRECATED_PUSH diff --git a/src/Magnum/MeshTools/RemoveDuplicates.h b/src/Magnum/MeshTools/RemoveDuplicates.h index f8046c5de..d68a1a2bf 100644 --- a/src/Magnum/MeshTools/RemoveDuplicates.h +++ b/src/Magnum/MeshTools/RemoveDuplicates.h @@ -225,6 +225,13 @@ use @ref removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1 and friends instead. Use @ref removeDuplicatesFuzzyInPlaceInto() to place the indices into existing memory instead of allocating a new array. +Overloads for vector, matrix and other math types are not provided because +there would be too many variants. Instead you can slice to +@ref Math::Vector::data(), @ref Math::RectangularMatrix::data() etc., which is +then convertible to a 2D view: + +@snippet MeshTools.cpp removeDuplicatesFuzzy-vector-slice + If you want to remove duplicates in multiple incidental arrays, first remove duplicates in each array separately and then combine the resulting index arrays back into a single one using @ref combineIndexedAttributes().