From ec02341c84414d4f71912d237c5c0a22a158245f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 2 Mar 2020 09:27:48 +0100 Subject: [PATCH] MeshTools: deprecate remaining STL-ridden APIs. The combineIndexArrays() and combineIndexedArrays() API is replaced with a more generic combineIndexedAttributes(), and thanks to that we also don't need STL-based duplicate() and removeDuplicates(). --- doc/changelog-old.dox | 6 ++-- doc/changelog.dox | 16 ++++++++-- doc/snippets/MagnumMeshTools.cpp | 18 ++++++++++- doc/snippets/MagnumShaders.cpp | 12 ++----- src/Magnum/MeshTools/CMakeLists.txt | 8 +++-- src/Magnum/MeshTools/CombineIndexedArrays.cpp | 4 +++ src/Magnum/MeshTools/CombineIndexedArrays.h | 31 ++++++++++++++++--- src/Magnum/MeshTools/CompressIndices.cpp | 2 +- src/Magnum/MeshTools/CompressIndices.h | 14 ++++----- src/Magnum/MeshTools/Duplicate.h | 18 ++++++----- src/Magnum/MeshTools/GenerateNormals.cpp | 2 ++ src/Magnum/MeshTools/RemoveDuplicates.h | 15 ++++++--- src/Magnum/MeshTools/Subdivide.h | 14 ++++++--- src/Magnum/MeshTools/Test/CMakeLists.txt | 13 ++++++-- .../Test/CombineIndexedArraysTest.cpp | 4 +++ .../MeshTools/Test/CompressIndicesTest.cpp | 11 ++++++- src/Magnum/MeshTools/Test/DuplicateTest.cpp | 8 +++++ .../MeshTools/Test/RemoveDuplicatesTest.cpp | 8 +++++ src/Magnum/MeshTools/Test/SubdivideTest.cpp | 12 +++++-- 19 files changed, 162 insertions(+), 54 deletions(-) diff --git a/doc/changelog-old.dox b/doc/changelog-old.dox index 40a962470..4121ed192 100644 --- a/doc/changelog-old.dox +++ b/doc/changelog-old.dox @@ -343,7 +343,7 @@ for a high-level overview. - @cpp Buffer::invalidateData() @ce, @cpp Buffer::invalidateSubData() @ce and @cpp Renderer::resetNotificationStrategy() @ce functions are enabled on OpenGL ES as a no-op -- Added @ref std::vector overload of @ref MeshTools::combineIndexArrays() +- Added @ref std::vector overload of @cpp MeshTools::combineIndexArrays() @ce for greater runtime-usage flexibility - @ref Platform::Sdl2Application now defaults to non-resizable window, you can change the behavior using @ref Platform::Sdl2Application::Configuration::setWindowFlags() @@ -391,9 +391,9 @@ for a high-level overview. which filled @cpp Mesh @ce and @cpp Buffer @ce directly are deprecated as they had undesired side-effects in some cases, use the data-returning versions instead and then configure mesh and buffer manually -- @ref MeshTools::combineIndexedArrays() taking @ref std::tuple is +- @cpp MeshTools::combineIndexedArrays() @ce taking @ref std::tuple is deprecated, use version taking @ref std::pair instead -- @ref MeshTools::removeDuplicates() taking also list of indices is +- @cpp MeshTools::removeDuplicates() @ce taking also list of indices is deprecated, use the function in conjunction with @ref MeshTools::duplicate(). See function documentation for more information. - Parameter-less @cpp Mesh::draw() @ce and @cpp MeshView::draw() @ce are diff --git a/doc/changelog.dox b/doc/changelog.dox index aa6e4b914..92f9386bb 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -429,6 +429,17 @@ See also: @ref MeshTools::flipFaceWindingInPlace() and @ref MeshTools::tipsifyInPlace() that accept a @ref Corrade::Containers::StridedArrayView instead of a @ref std::vector and work with 8- and 16-byte index types as well. +- `Magnum/MeshTools/CombineIndexedArrays.h`, + @cpp MeshTools::combineIndexArrays() @ce and + @cpp MeshTools::combineIndexedArrays() @ce are deprecated in favor of a more + flexible @ref MeshTools::combineIndexedAttributes() in the + @ref Magnum/MeshTools/Combine.h header +- @cpp MeshTools::compressIndicesAs() @ce, @cpp MeshTools::duplicate() @ce, + @cpp MeshTools::removeDuplicates() @ce and @cpp MeshTools::subdivide() @ce + operating on a @ref std::vector are deprecated, use the STL-free + @ref MeshTools::compressIndices(), @ref MeshTools::duplicate(), + @ref MeshTools::removeDuplicatesInPlace() and @ref MeshTools::subdivide() / + @ref MeshTools::subdivideInPlace() overloads instead @subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs @@ -3214,9 +3225,10 @@ a high-level overview. - Removed deprecated `*Texture::maxLayers()` functions, use @ref GL::Shader::maxCombinedTextureImageUnits() "Shader::maxCombinedTextureImageUnits()" instead -- Removed deprecated @ref MeshTools::combineIndexedArrays(), +- Removed deprecated @cpp MeshTools::combineIndexedArrays() @ce, @ref MeshTools::compressIndices(), @ref MeshTools::interleave() and - @ref MeshTools::removeDuplicates() overloads, use the general ones instead + @cpp MeshTools::removeDuplicates() @ce overloads, use the general ones + instead - Removed deprecated `Mesh*::set*{Range,Count}()` functions, use @ref GL::Mesh::setCount() "Mesh*::setCount()" and @ref GL::MeshView::setIndexRange() "MeshView::setIndexRange()" instead diff --git a/doc/snippets/MagnumMeshTools.cpp b/doc/snippets/MagnumMeshTools.cpp index 824fcf821..bfbab6fc0 100644 --- a/doc/snippets/MagnumMeshTools.cpp +++ b/doc/snippets/MagnumMeshTools.cpp @@ -25,7 +25,6 @@ #include "Magnum/Math/Color.h" #include "Magnum/Math/FunctionsBatch.h" -#include "Magnum/MeshTools/CombineIndexedArrays.h" #include "Magnum/MeshTools/CompressIndices.h" #include "Magnum/MeshTools/Duplicate.h" #include "Magnum/MeshTools/GenerateNormals.h" @@ -34,12 +33,19 @@ #include "Magnum/MeshTools/Transform.h" #include "Magnum/Trade/MeshData.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#define _MAGNUM_NO_DEPRECATED_COMBINEINDEXEDARRAYS +#include "Magnum/MeshTools/CombineIndexedArrays.h" +#endif + using namespace Magnum; using namespace Magnum::Math::Literals; int main() { +#ifdef MAGNUM_BUILD_DEPRECATED { +CORRADE_IGNORE_DEPRECATED_PUSH /* [combineIndexedArrays] */ std::vector vertexIndices; std::vector positions; @@ -53,7 +59,9 @@ std::vector indices = MeshTools::combineIndexedArrays( std::make_pair(std::cref(normalTextureIndices), std::ref(textureCoordinates)) ); /* [combineIndexedArrays] */ +CORRADE_IGNORE_DEPRECATED_POP } +#endif { /* [compressIndices-offset] */ @@ -66,13 +74,17 @@ std::pair, MeshIndexType> result = /* [compressIndices-offset] */ } +#ifdef MAGNUM_BUILD_DEPRECATED { +CORRADE_IGNORE_DEPRECATED_PUSH /* [compressIndicesAs] */ std::vector indices; Containers::Array indexData = MeshTools::compressIndicesAs(indices); /* [compressIndicesAs] */ +CORRADE_IGNORE_DEPRECATED_POP } +#endif { /* [generateFlatNormals] */ @@ -143,7 +155,9 @@ data = data.prefix(size); /* [removeDuplicates] */ } +#ifdef MAGNUM_BUILD_DEPRECATED { +CORRADE_IGNORE_DEPRECATED_PUSH /* [removeDuplicates-multiple] */ std::vector positions; std::vector texCoords; @@ -156,7 +170,9 @@ std::vector indices = MeshTools::combineIndexedArrays( std::make_pair(std::cref(texCoordIndices), std::ref(texCoords)) ); /* [removeDuplicates-multiple] */ +CORRADE_IGNORE_DEPRECATED_POP } +#endif { /* [transformVectors] */ diff --git a/doc/snippets/MagnumShaders.cpp b/doc/snippets/MagnumShaders.cpp index b5e51e8a4..670c68721 100644 --- a/doc/snippets/MagnumShaders.cpp +++ b/doc/snippets/MagnumShaders.cpp @@ -290,17 +290,11 @@ mesh.addVertexBuffer(vertexIndices, 0, Shaders::MeshVisualizer::VertexIndex{}); { /* [MeshVisualizer-usage-no-geom1] */ -std::vector indices{ - // ... -}; -std::vector indexedPositions{ - // ... -}; +Containers::StridedArrayView1D indices; +Containers::StridedArrayView1D indexedPositions; /* De-indexing the position array */ -GL::Buffer vertices; -vertices.setData(MeshTools::duplicate(indices, indexedPositions), - GL::BufferUsage::StaticDraw); +GL::Buffer vertices{MeshTools::duplicate(indices, indexedPositions)}; GL::Mesh mesh; mesh.addVertexBuffer(vertices, 0, Shaders::MeshVisualizer::Position{}); diff --git a/src/Magnum/MeshTools/CMakeLists.txt b/src/Magnum/MeshTools/CMakeLists.txt index ebc59e94f..8c3ca0e9c 100644 --- a/src/Magnum/MeshTools/CMakeLists.txt +++ b/src/Magnum/MeshTools/CMakeLists.txt @@ -30,7 +30,6 @@ set(MagnumMeshTools_SRCS # Files compiled with different flags for main library and unit test library set(MagnumMeshTools_GracefulAssert_SRCS Combine.cpp - CombineIndexedArrays.cpp CompressIndices.cpp Duplicate.cpp FlipNormals.cpp @@ -40,7 +39,6 @@ set(MagnumMeshTools_GracefulAssert_SRCS set(MagnumMeshTools_HEADERS Combine.h - CombineIndexedArrays.h CompressIndices.h Duplicate.h FlipNormals.h @@ -57,7 +55,11 @@ set(MagnumMeshTools_INTERNAL_HEADERS Implementation/Tipsify.h) if(BUILD_DEPRECATED) - list(APPEND MagnumMeshTools_HEADERS GenerateFlatNormals.h) + list(APPEND MagnumMeshTools_GracefulAssert_SRCS + CombineIndexedArrays.cpp) + list(APPEND MagnumMeshTools_HEADERS + CombineIndexedArrays.h + GenerateFlatNormals.h) endif() if(TARGET_GL) diff --git a/src/Magnum/MeshTools/CombineIndexedArrays.cpp b/src/Magnum/MeshTools/CombineIndexedArrays.cpp index b02391816..09d8f367b 100644 --- a/src/Magnum/MeshTools/CombineIndexedArrays.cpp +++ b/src/Magnum/MeshTools/CombineIndexedArrays.cpp @@ -23,6 +23,8 @@ DEALINGS IN THE SOFTWARE. */ +#define _MAGNUM_NO_DEPRECATED_COMBINEINDEXEDARRAYS + #include "CombineIndexedArrays.h" #include @@ -56,7 +58,9 @@ std::pair, std::vector> interleaveAndCombi /* Combine them */ std::vector combinedIndices; + CORRADE_IGNORE_DEPRECATED_PUSH std::tie(combinedIndices, interleavedArrays) = MeshTools::combineIndexArrays(interleavedArrays, stride); + CORRADE_IGNORE_DEPRECATED_POP return {combinedIndices, interleavedArrays}; } diff --git a/src/Magnum/MeshTools/CombineIndexedArrays.h b/src/Magnum/MeshTools/CombineIndexedArrays.h index daa8f122a..d946eea16 100644 --- a/src/Magnum/MeshTools/CombineIndexedArrays.h +++ b/src/Magnum/MeshTools/CombineIndexedArrays.h @@ -25,18 +25,30 @@ DEALINGS IN THE SOFTWARE. */ +#ifdef MAGNUM_BUILD_DEPRECATED /** @file * @brief Function @ref Magnum::MeshTools::combineIndexArrays(), @ref Magnum::MeshTools::combineIndexedArrays() + * @m_deprecated_since_latest Use @ref Magnum/MeshTools/Combine.h and + * @ref Magnum::MeshTools::combineIndexedAttributes() instead. */ +#endif + +#include "Magnum/configure.h" +#ifdef MAGNUM_BUILD_DEPRECATED #include #include #include #include +#include #include "Magnum/Types.h" #include "Magnum/MeshTools/visibility.h" +#ifndef _MAGNUM_NO_DEPRECATED_COMBINEINDEXEDARRAYS +CORRADE_DEPRECATED_FILE("use Magnum/Trade/MeshData.h and combineIndexedAttributes() instead") +#endif + namespace Magnum { namespace MeshTools { /** @@ -44,6 +56,7 @@ namespace Magnum { namespace MeshTools { @param[in,out] arrays Index arrays to combine. These arrays are updated in-place to contain unique combinations of the original indices. @return Resulting combined index array +@m_deprecated_since_latest Use @ref combineIndexedAttributes() instead. Creates new combined index array and updates the original ones with translation to new ones. For example, when you have position and normal array, each indexed @@ -81,13 +94,17 @@ This function calls @ref combineIndexArrays(const std::vector&, Uns internally. See also @ref combineIndexedArrays() which does the vertex data reordering automatically. */ -MAGNUM_MESHTOOLS_EXPORT std::vector combineIndexArrays(const std::vector>>& arrays); +CORRADE_DEPRECATED("use combineIndexedAttributes() instead") MAGNUM_MESHTOOLS_EXPORT std::vector combineIndexArrays(const std::vector>>& arrays); -/** @overload */ -MAGNUM_MESHTOOLS_EXPORT std::vector combineIndexArrays(std::initializer_list>> arrays); +/** +@overload +@m_deprecated_since_latest Use @ref combineIndexedAttributes() instead. +*/ +CORRADE_DEPRECATED("use combineIndexedAttributes() instead") MAGNUM_MESHTOOLS_EXPORT std::vector combineIndexArrays(std::initializer_list>> arrays); /** @brief Combine interleaved index arrays +@m_deprecated_since_latest Use @ref combineIndexedAttributes() instead. Unlike above, this function takes one interleaved array instead of separate index arrays. Continuing with the above example, you would call this function @@ -107,7 +124,7 @@ And second pair value is the cleaned up interleaved array: @see @ref combineIndexedArrays() */ -MAGNUM_MESHTOOLS_EXPORT std::pair, std::vector> combineIndexArrays(const std::vector& interleavedArrays, UnsignedInt stride); +CORRADE_DEPRECATED("use combineIndexedAttributes() instead") MAGNUM_MESHTOOLS_EXPORT std::pair, std::vector> combineIndexArrays(const std::vector& interleavedArrays, UnsignedInt stride); namespace Implementation { @@ -140,6 +157,7 @@ template inline void writeCombinedArrays(UnsignedInt stride @brief Combine indexed arrays @param[in,out] indexedArrays Index and attribute arrays @return Array with resulting indices +@m_deprecated_since_latest Use @ref combineIndexedAttributes() instead. Creates new combined index array and reorders original attribute arrays so they can be indexed with the new single index array. @@ -160,7 +178,7 @@ procedure. /* Implementation note: It's done using tuples because it is more clear which parameter is index array and which is attribute array, mainly when both are of the same type. */ -template std::vector combineIndexedArrays(const std::pair&, std::vector&>&... indexedArrays) { +template CORRADE_DEPRECATED("use combineIndexedAttributes() instead") std::vector combineIndexedArrays(const std::pair&, std::vector&>&... indexedArrays) { /* Interleave and combine index arrays */ std::vector combinedIndices; std::vector interleavedCombinedIndexArrays; @@ -174,5 +192,8 @@ template std::vector combineIndexedArrays(const std::pa } }} +#else +#error use functions in Combine.h instead +#endif #endif diff --git a/src/Magnum/MeshTools/CompressIndices.cpp b/src/Magnum/MeshTools/CompressIndices.cpp index 81ecbd47b..b37342a58 100644 --- a/src/Magnum/MeshTools/CompressIndices.cpp +++ b/src/Magnum/MeshTools/CompressIndices.cpp @@ -178,7 +178,6 @@ std::tuple, MeshIndexType, UnsignedInt, UnsignedInt> com std::tie(data, type) = compressIndices(indices, MeshIndexType::UnsignedByte); return std::make_tuple(std::move(data), type, minmax.first, minmax.second); } -#endif template Containers::Array compressIndicesAs(const std::vector& indices) { #if !defined(CORRADE_NO_ASSERT) || defined(CORRADE_GRACEFUL_ASSERT) @@ -196,5 +195,6 @@ template Containers::Array compressIndicesAs(const std::vector compressIndicesAs(const std::vector&); template Containers::Array compressIndicesAs(const std::vector&); template Containers::Array compressIndicesAs(const std::vector&); +#endif }} diff --git a/src/Magnum/MeshTools/CompressIndices.h b/src/Magnum/MeshTools/CompressIndices.h index 091e83829..0911a3ad0 100644 --- a/src/Magnum/MeshTools/CompressIndices.h +++ b/src/Magnum/MeshTools/CompressIndices.h @@ -26,12 +26,11 @@ */ /** @file - * @brief Function @ref Magnum::MeshTools::compressIndices(), @ref Magnum::MeshTools::compressIndicesAs() + * @brief Function @ref Magnum::MeshTools::compressIndices() */ #include #include -#include #include "Magnum/Mesh.h" #include "Magnum/MeshTools/visibility.h" @@ -40,6 +39,7 @@ #ifdef MAGNUM_BUILD_DEPRECATED #include #include +#include #endif namespace Magnum { namespace MeshTools { @@ -178,14 +178,13 @@ sufficient. Example usage: @snippet MagnumMeshTools-gl.cpp compressIndices-stl - -@see @ref compressIndicesAs() */ CORRADE_DEPRECATED("use compressIndices(const Containers::StridedArrayView1D&, MeshIndexType, Long) instead") MAGNUM_MESHTOOLS_EXPORT std::tuple, MeshIndexType, UnsignedInt, UnsignedInt> compressIndices(const std::vector& indices); -#endif /** @brief Compress vertex indices as given type +@m_deprecated_since_latest Use @ref compressIndices(const Containers::StridedArrayView1D&, MeshIndexType, Long) + instead. The type can be either @ref Magnum::UnsignedByte "UnsignedByte", @ref Magnum::UnsignedShort "UnsignedShort" or @ref Magnum::UnsignedInt "UnsignedInt". @@ -194,16 +193,15 @@ Values in the index array are expected to be representable with given type. Example usage: @snippet MagnumMeshTools.cpp compressIndicesAs - -@see @ref compressIndices() */ -template MAGNUM_MESHTOOLS_EXPORT Containers::Array compressIndicesAs(const std::vector& indices); +template CORRADE_DEPRECATED("use compressIndices(const Containers::StridedArrayView1D&, MeshIndexType, Long) instead") MAGNUM_MESHTOOLS_EXPORT Containers::Array compressIndicesAs(const std::vector& indices); #if defined(CORRADE_TARGET_WINDOWS) && !defined(__MINGW32__) extern template MAGNUM_MESHTOOLS_EXPORT Containers::Array compressIndicesAs(const std::vector&); extern template MAGNUM_MESHTOOLS_EXPORT Containers::Array compressIndicesAs(const std::vector&); extern template MAGNUM_MESHTOOLS_EXPORT Containers::Array compressIndicesAs(const std::vector&); #endif +#endif }} diff --git a/src/Magnum/MeshTools/Duplicate.h b/src/Magnum/MeshTools/Duplicate.h index e5458dfab..577bf81ee 100644 --- a/src/Magnum/MeshTools/Duplicate.h +++ b/src/Magnum/MeshTools/Duplicate.h @@ -29,15 +29,18 @@ * @brief Function @ref Magnum::MeshTools::duplicate(), @ref Magnum::MeshTools::duplicateInto() */ -#include #include -#include #include #include "Magnum/Magnum.h" #include "Magnum/MeshTools/visibility.h" #include "Magnum/Trade/Trade.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#include +#endif + namespace Magnum { namespace MeshTools { #ifndef DOXYGEN_GENERATING_OUTPUT @@ -56,7 +59,7 @@ indices are in range for the @p data array. If you want to fill an existing memory (or, for example a @ref std::vector), use @ref duplicateInto(). -@see @ref removeDuplicates(), @ref combineIndexedArrays() +@see @ref removeDuplicatesInPlace(), @ref combineIndexedAttributes() */ template Containers::Array duplicate(const Containers::StridedArrayView1D& indices, const Containers::StridedArrayView1D& data) { Containers::Array out{Containers::NoInit, indices.size()}; @@ -64,17 +67,18 @@ template Containers::Array duplicate(const Containe return out; } +#ifdef MAGNUM_BUILD_DEPRECATED /** @brief Duplicate data using given index array - -Like @ref duplicate(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&), -but putting the result into a @ref std::vector. +@m_deprecated_since_latest Use @ref duplicate(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) + or @ref duplicateInto() instead. */ -template std::vector duplicate(const std::vector& indices, const std::vector& data) { +template CORRADE_DEPRECATED("use duplicate() taking a StridedArrayView instead") std::vector duplicate(const std::vector& indices, const std::vector& data) { std::vector out(indices.size()); duplicateInto(indices, data, out); return out; } +#endif /** @brief Duplicate data using an index array into given output array diff --git a/src/Magnum/MeshTools/GenerateNormals.cpp b/src/Magnum/MeshTools/GenerateNormals.cpp index 7aacd35ec..ce6e11151 100644 --- a/src/Magnum/MeshTools/GenerateNormals.cpp +++ b/src/Magnum/MeshTools/GenerateNormals.cpp @@ -81,7 +81,9 @@ std::pair, std::vector> generateFlatNormals(co } /* Remove duplicate normals and return */ + CORRADE_IGNORE_DEPRECATED_PUSH normalIndices = MeshTools::duplicate(normalIndices, MeshTools::removeDuplicates(normals)); + CORRADE_IGNORE_DEPRECATED_POP return {std::move(normalIndices), std::move(normals)}; } #endif diff --git a/src/Magnum/MeshTools/RemoveDuplicates.h b/src/Magnum/MeshTools/RemoveDuplicates.h index a259c1e80..512f47838 100644 --- a/src/Magnum/MeshTools/RemoveDuplicates.h +++ b/src/Magnum/MeshTools/RemoveDuplicates.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Function @ref Magnum::MeshTools::removeDuplicatesInPlace(), @ref Magnum::MeshTools::removeDuplicatesIndexedInPlace(), @ref Magnum::MeshTools::removeDuplicates() + * @brief Function @ref Magnum::MeshTools::removeDuplicatesInPlace(), @ref Magnum::MeshTools::removeDuplicatesIndexedInPlace() */ #include @@ -133,11 +133,14 @@ instead. If you want to remove duplicate data from an already indexed array, use @ref removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&, typename Vector::Type) instead. -See also @ref removeDuplicates(std::vector&, typename Vector::Type) for -a variant operating on a STL vector. + +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(). */ template std::pair, std::size_t> removeDuplicatesInPlace(const Containers::StridedArrayView1D& data, typename Vector::Type epsilon = Math::TypeTraits::epsilon()); +#ifdef MAGNUM_BUILD_DEPRECATED /** @brief Remove duplicate floating-point vector data from a STL vector in-place @param[in,out] data Data array, duplicate items will be cut away with order @@ -145,6 +148,7 @@ template std::pair, std::size_t> re @param[in] epsilon Epsilon value, vertices closer than this distance will be melt together @return Resulting index array +@m_deprecated_since_latest Use @ref removeDuplicatesInPlace() instead. Similar to the above, except that it's operating on a @ref std::vector, which gets shrunk as a result (instead of the prefix size being returned). This @@ -155,7 +159,8 @@ array, and reorder the data accordingly: @snippet MagnumMeshTools.cpp removeDuplicates-multiple */ -template std::vector removeDuplicates(std::vector& data, typename Vector::Type epsilon = Math::TypeTraits::epsilon()); +template CORRADE_DEPRECATED("use removeDuplicatesInPlace() instead") std::vector removeDuplicates(std::vector& data, typename Vector::Type epsilon = Math::TypeTraits::epsilon()); +#endif /** @brief Remove duplicates from indexed floating-point vector data in-place @@ -245,6 +250,7 @@ template std::pair, std::size_t> re return {std::move(indices), size}; } +#ifdef MAGNUM_BUILD_DEPRECATED template std::vector removeDuplicates(std::vector& data, typename Vector::Type epsilon) { /* A trivial index array that'll be remapped and returned after */ std::vector indices(data.size()); @@ -253,6 +259,7 @@ template std::vector removeDuplicates(std::vector #include #include #include @@ -37,6 +36,10 @@ #include "Magnum/Magnum.h" +#ifdef MAGNUM_BUILD_DEPRECATED +#include +#endif + namespace Magnum { namespace MeshTools { #ifndef DOXYGEN_GENERATING_OUTPUT @@ -66,19 +69,20 @@ template void subdivide(Conta subdivideInPlace(Containers::stridedArrayView(indices), Containers::stridedArrayView(vertices), interpolator); } +#ifdef MAGNUM_BUILD_DEPRECATED /** @brief Subdivide a mesh - -Same as @ref subdivide(Containers::Array&, Containers::Array&vertices, Interpolator), only -working on a @ref std::vector. +@m_deprecated_since_latest Use @ref subdivide(Containers::Array&, Containers::Array&vertices, Interpolator) + or @ref subdivideInPlace() instead. */ -template void subdivide(std::vector& indices, std::vector& vertices, Interpolator interpolator) { +template CORRADE_DEPRECATED("use subdivide(Containers::Array&, Containers::Array&vertices, Interpolator) or subdivideInPlace() instead") void subdivide(std::vector& indices, std::vector& vertices, Interpolator interpolator) { CORRADE_ASSERT(!(indices.size()%3), "MeshTools::subdivide(): index count is not divisible by 3", ); vertices.resize(vertices.size() + indices.size()); indices.resize(indices.size()*4); subdivideInPlace(Containers::stridedArrayView(indices), Containers::stridedArrayView(vertices), interpolator); } +#endif /** @brief Subdivide a mesh in-place diff --git a/src/Magnum/MeshTools/Test/CMakeLists.txt b/src/Magnum/MeshTools/Test/CMakeLists.txt index 29b84aba4..cc9d558f8 100644 --- a/src/Magnum/MeshTools/Test/CMakeLists.txt +++ b/src/Magnum/MeshTools/Test/CMakeLists.txt @@ -24,7 +24,6 @@ # corrade_add_test(MeshToolsCombineTest CombineTest.cpp LIBRARIES MagnumMeshToolsTestLib) -corrade_add_test(MeshToolsCombineIndexedArraysTest CombineIndexedArraysTest.cpp LIBRARIES MagnumMeshToolsTestLib) corrade_add_test(MeshToolsCompressIndicesTest CompressIndicesTest.cpp LIBRARIES MagnumMeshToolsTestLib) corrade_add_test(MeshToolsDuplicateTest DuplicateTest.cpp LIBRARIES MagnumMeshToolsTestLib) corrade_add_test(MeshToolsFlipNormalsTest FlipNormalsTest.cpp LIBRARIES MagnumMeshToolsTestLib) @@ -38,7 +37,6 @@ corrade_add_test(MeshToolsSubdivideRemov___Benchmark SubdivideRemoveDuplicatesBe # Graceful assert for testing set_property(TARGET - MeshToolsCombineIndexedArraysTest MeshToolsDuplicateTest MeshToolsInterleaveTest MeshToolsRemoveDuplicatesTest @@ -47,7 +45,6 @@ set_property(TARGET set_target_properties( MeshToolsCombineTest - MeshToolsCombineIndexedArraysTest MeshToolsCompressIndicesTest MeshToolsDuplicateTest MeshToolsFlipNormalsTest @@ -60,6 +57,16 @@ set_target_properties( MeshToolsSubdivideRemov___Benchmark PROPERTIES FOLDER "Magnum/MeshTools/Test") +if(BUILD_DEPRECATED) + corrade_add_test(MeshToolsCombineIndexedArraysTest CombineIndexedArraysTest.cpp LIBRARIES MagnumMeshToolsTestLib) + set_property(TARGET + MeshToolsCombineIndexedArraysTest + APPEND PROPERTY COMPILE_DEFINITIONS "CORRADE_GRACEFUL_ASSERT") + set_target_properties( + MeshToolsCombineIndexedArraysTest + PROPERTIES FOLDER "Magnum/MeshTools/Test") +endif() + if(BUILD_GL_TESTS) # Otherwise CMake complains that Corrade::PluginManager is not found find_package(Corrade REQUIRED PluginManager) diff --git a/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp b/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp index 7bd33f0d0..24fe08f98 100644 --- a/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp +++ b/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp @@ -28,6 +28,8 @@ #include #include +#define _MAGNUM_NO_DEPRECATED_COMBINEINDEXEDARRAYS + #include "Magnum/Magnum.h" #include "Magnum/MeshTools/CombineIndexedArrays.h" @@ -47,6 +49,7 @@ CombineIndexedArraysTest::CombineIndexedArraysTest() { &CombineIndexedArraysTest::indexedArrays}); } +CORRADE_IGNORE_DEPRECATED_PUSH void CombineIndexedArraysTest::wrongIndexCount() { std::stringstream ss; Error redirectError{&ss}; @@ -87,6 +90,7 @@ void CombineIndexedArraysTest::indexedArrays() { CORRADE_COMPARE(array2, (std::vector{3, 4})); CORRADE_COMPARE(array3, (std::vector{6, 7})); } +CORRADE_IGNORE_DEPRECATED_POP }}}} diff --git a/src/Magnum/MeshTools/Test/CompressIndicesTest.cpp b/src/Magnum/MeshTools/Test/CompressIndicesTest.cpp index d05320743..476475f89 100644 --- a/src/Magnum/MeshTools/Test/CompressIndicesTest.cpp +++ b/src/Magnum/MeshTools/Test/CompressIndicesTest.cpp @@ -58,7 +58,9 @@ struct CompressIndicesTest: TestSuite::Tester { void compressMeshDataMove(); void compressMeshDataNonIndexed(); + #ifdef MAGNUM_BUILD_DEPRECATED void compressAsShort(); + #endif }; CompressIndicesTest::CompressIndicesTest() { @@ -85,7 +87,10 @@ CompressIndicesTest::CompressIndicesTest() { &CompressIndicesTest::compressMeshDataMove, &CompressIndicesTest::compressMeshDataNonIndexed, - &CompressIndicesTest::compressAsShort}); + #ifdef MAGNUM_BUILD_DEPRECATED + &CompressIndicesTest::compressAsShort + #endif + }); } template void CompressIndicesTest::compressUnsignedByte() { @@ -318,7 +323,9 @@ void CompressIndicesTest::compressMeshDataNonIndexed() { "MeshTools::compressIndices(): mesh data not indexed\n"); } +#ifdef MAGNUM_BUILD_DEPRECATED void CompressIndicesTest::compressAsShort() { + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE_AS(MeshTools::compressIndicesAs({123, 456}), Containers::arrayView({123, 456}), TestSuite::Compare::Container); @@ -327,7 +334,9 @@ void CompressIndicesTest::compressAsShort() { Error redirectError{&out}; MeshTools::compressIndicesAs({65536}); CORRADE_COMPARE(out.str(), "MeshTools::compressIndicesAs(): type too small to represent value 65536\n"); + CORRADE_IGNORE_DEPRECATED_POP } +#endif }}}} diff --git a/src/Magnum/MeshTools/Test/DuplicateTest.cpp b/src/Magnum/MeshTools/Test/DuplicateTest.cpp index c438b6178..058373e05 100644 --- a/src/Magnum/MeshTools/Test/DuplicateTest.cpp +++ b/src/Magnum/MeshTools/Test/DuplicateTest.cpp @@ -42,7 +42,9 @@ struct DuplicateTest: TestSuite::Tester { void duplicate(); void duplicateOutOfBounds(); + #ifdef MAGNUM_BUILD_DEPRECATED void duplicateStl(); + #endif void duplicateInto(); void duplicateIntoWrongSize(); @@ -67,7 +69,9 @@ struct DuplicateTest: TestSuite::Tester { DuplicateTest::DuplicateTest() { addTests({&DuplicateTest::duplicate, &DuplicateTest::duplicateOutOfBounds, + #ifdef MAGNUM_BUILD_DEPRECATED &DuplicateTest::duplicateStl, + #endif &DuplicateTest::duplicateInto, &DuplicateTest::duplicateIntoWrongSize, @@ -116,10 +120,14 @@ void DuplicateTest::duplicateOutOfBounds() { "MeshTools::duplicateInto(): index 4 out of bounds for 4 elements\n"); } +#ifdef MAGNUM_BUILD_DEPRECATED void DuplicateTest::duplicateStl() { + CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_COMPARE(MeshTools::duplicate({1, 1, 0, 3, 2, 2}, std::vector{-7, 35, 12, -18}), (std::vector{35, 35, -7, -18, 12, 12})); + CORRADE_IGNORE_DEPRECATED_POP } +#endif void DuplicateTest::duplicateInto() { constexpr UnsignedByte indices[]{1, 1, 0, 3, 2, 2}; diff --git a/src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp b/src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp index 59109cf7d..5d80a732b 100644 --- a/src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp +++ b/src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp @@ -45,7 +45,9 @@ struct RemoveDuplicatesTest: TestSuite::Tester { void removeDuplicatesIndexedInPlaceEmptyIndicesVertices(); void removeDuplicatesFuzzyInPlace(); + #ifdef MAGNUM_BUILD_DEPRECATED void removeDuplicatesFuzzyStl(); + #endif template void removeDuplicatesFuzzyIndexedInPlace(); void removeDuplicatesFuzzyIndexedInPlaceSmallType(); void removeDuplicatesFuzzyIndexedInPlaceEmptyIndices(); @@ -66,7 +68,9 @@ RemoveDuplicatesTest::RemoveDuplicatesTest() { &RemoveDuplicatesTest::removeDuplicatesIndexedInPlaceEmptyIndicesVertices, &RemoveDuplicatesTest::removeDuplicatesFuzzyInPlace, + #ifdef MAGNUM_BUILD_DEPRECATED &RemoveDuplicatesTest::removeDuplicatesFuzzyStl, + #endif &RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace, &RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace, &RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace, @@ -173,6 +177,7 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyInPlace() { TestSuite::Compare::Container); } +#ifdef MAGNUM_BUILD_DEPRECATED void RemoveDuplicatesTest::removeDuplicatesFuzzyStl() { /* Same but with implicit bloat. HEH HEH */ std::vector data{ @@ -182,7 +187,9 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyStl() { {1, 5} }; + CORRADE_IGNORE_DEPRECATED_PUSH const std::vector indices = MeshTools::removeDuplicates(data, 2); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE_AS(indices, (std::vector{0, 0, 1, 1}), TestSuite::Compare::Container); @@ -190,6 +197,7 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyStl() { (std::vector{{1, 0}, {0, 4}}), TestSuite::Compare::Container); } +#endif template void RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace() { setTestCaseTemplateName(Math::TypeTraits::name()); diff --git a/src/Magnum/MeshTools/Test/SubdivideTest.cpp b/src/Magnum/MeshTools/Test/SubdivideTest.cpp index 865d1299e..f6f804a51 100644 --- a/src/Magnum/MeshTools/Test/SubdivideTest.cpp +++ b/src/Magnum/MeshTools/Test/SubdivideTest.cpp @@ -37,7 +37,9 @@ struct SubdivideTest: TestSuite::Tester { explicit SubdivideTest(); void subdivide(); + #ifdef MAGNUM_BUILD_DEPRECATED void subdivideStl(); + #endif void subdivideWrongIndexCount(); template void subdivideInPlace(); void subdivideInPlaceWrongIndexCount(); @@ -52,7 +54,9 @@ inline Vector1 interpolator(Vector1 a, Vector1 b) { return (a[0]+b[0])/2; } SubdivideTest::SubdivideTest() { addTests({&SubdivideTest::subdivide, + #ifdef MAGNUM_BUILD_DEPRECATED &SubdivideTest::subdivideStl, + #endif &SubdivideTest::subdivideWrongIndexCount, &SubdivideTest::subdivideInPlace, &SubdivideTest::subdivideInPlace, @@ -74,10 +78,13 @@ void SubdivideTest::subdivide() { }), TestSuite::Compare::Container); } +#ifdef MAGNUM_BUILD_DEPRECATED void SubdivideTest::subdivideStl() { std::vector positions{0, 2, 6, 8}; std::vector indices{0, 1, 2, 1, 2, 3}; + CORRADE_IGNORE_DEPRECATED_PUSH MeshTools::subdivide(indices, positions, interpolator); + CORRADE_IGNORE_DEPRECATED_POP CORRADE_COMPARE_AS(indices, (std::vector{4, 5, 6, 7, 8, 9, 0, 4, 6, 4, 1, 5, 6, 5, 2, 1, 7, 9, 7, 2, 8, 9, 8, 3}), @@ -86,13 +93,14 @@ void SubdivideTest::subdivideStl() { (std::vector{0, 2, 6, 8, 1, 4, 3, 4, 7, 5}), TestSuite::Compare::Container); } +#endif void SubdivideTest::subdivideWrongIndexCount() { std::stringstream out; Error redirectError{&out}; - std::vector positions; - std::vector indices{0, 1}; + Containers::Array positions; + Containers::Array indices{2}; MeshTools::subdivide(indices, positions, interpolator); CORRADE_COMPARE(out.str(), "MeshTools::subdivide(): index count is not divisible by 3\n"); }