Browse Source

MeshTools: hint use of vector member slicing in removeDuplicatesFuzzy().

pull/674/head
Vladimír Vondruš 1 year ago
parent
commit
e78323f7d0
  1. 19
      doc/snippets/MeshTools.cpp
  2. 7
      src/Magnum/MeshTools/RemoveDuplicates.h

19
doc/snippets/MeshTools.cpp

@ -181,7 +181,7 @@ Containers::Array<Vector3> positions = mesh.positions3DAsArray();
/* Deduplicate the positions and create a mapping array */ /* Deduplicate the positions and create a mapping array */
Containers::Pair<Containers::Array<UnsignedInt>, std::size_t> out = Containers::Pair<Containers::Array<UnsignedInt>, std::size_t> out =
MeshTools::removeDuplicatesFuzzyInPlace( MeshTools::removeDuplicatesFuzzyInPlace(
Containers::arrayCast<2, Float>(stridedArrayView(positions))); stridedArrayView(positions).slice(&Vector3::data));
Containers::Array<UnsignedInt> indexMapping = std::move(out.first()); Containers::Array<UnsignedInt> indexMapping = std::move(out.first());
arrayResize(positions, out.second()); arrayResize(positions, out.second());
@ -369,15 +369,24 @@ data = data.prefix(unique.second());
{ {
/* [removeDuplicatesFuzzy] */ /* [removeDuplicatesFuzzy] */
Containers::ArrayView<Vector3> positions; Containers::StridedArrayView1D<Float> data;
Containers::Pair<Containers::Array<UnsignedInt>, std::size_t> unique = Containers::Pair<Containers::Array<UnsignedInt>, std::size_t> unique =
MeshTools::removeDuplicatesFuzzyInPlace( MeshTools::removeDuplicatesFuzzyInPlace(data);
Containers::arrayCast<2, Float>(positions)); data = data.prefix(unique.second());
positions = positions.prefix(unique.second());
/* [removeDuplicatesFuzzy] */ /* [removeDuplicatesFuzzy] */
} }
{
/* [removeDuplicatesFuzzy-vector-slice] */
Containers::StridedArrayView1D<Vector3> positions;
Containers::Pair<Containers::Array<UnsignedInt>, std::size_t> unique =
MeshTools::removeDuplicatesFuzzyInPlace(positions.slice(&Vector3::data));
positions = positions.prefix(unique.second());
/* [removeDuplicatesFuzzy-vector-slice] */
}
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
{ {
CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_IGNORE_DEPRECATED_PUSH

7
src/Magnum/MeshTools/RemoveDuplicates.h

@ -225,6 +225,13 @@ use @ref removeDuplicatesFuzzyIndexedInPlace(const Containers::StridedArrayView1
and friends instead. Use @ref removeDuplicatesFuzzyInPlaceInto() to place the and friends instead. Use @ref removeDuplicatesFuzzyInPlaceInto() to place the
indices into existing memory instead of allocating a new array. 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 If you want to remove duplicates in multiple incidental arrays, first remove
duplicates in each array separately and then combine the resulting index arrays duplicates in each array separately and then combine the resulting index arrays
back into a single one using @ref combineIndexedAttributes(). back into a single one using @ref combineIndexedAttributes().

Loading…
Cancel
Save