Browse Source

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().
pull/371/head
Vladimír Vondruš 6 years ago
parent
commit
ec02341c84
  1. 6
      doc/changelog-old.dox
  2. 16
      doc/changelog.dox
  3. 18
      doc/snippets/MagnumMeshTools.cpp
  4. 12
      doc/snippets/MagnumShaders.cpp
  5. 8
      src/Magnum/MeshTools/CMakeLists.txt
  6. 4
      src/Magnum/MeshTools/CombineIndexedArrays.cpp
  7. 31
      src/Magnum/MeshTools/CombineIndexedArrays.h
  8. 2
      src/Magnum/MeshTools/CompressIndices.cpp
  9. 14
      src/Magnum/MeshTools/CompressIndices.h
  10. 18
      src/Magnum/MeshTools/Duplicate.h
  11. 2
      src/Magnum/MeshTools/GenerateNormals.cpp
  12. 15
      src/Magnum/MeshTools/RemoveDuplicates.h
  13. 14
      src/Magnum/MeshTools/Subdivide.h
  14. 13
      src/Magnum/MeshTools/Test/CMakeLists.txt
  15. 4
      src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp
  16. 11
      src/Magnum/MeshTools/Test/CompressIndicesTest.cpp
  17. 8
      src/Magnum/MeshTools/Test/DuplicateTest.cpp
  18. 8
      src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp
  19. 12
      src/Magnum/MeshTools/Test/SubdivideTest.cpp

6
doc/changelog-old.dox

@ -343,7 +343,7 @@ for a high-level overview.
- @cpp Buffer::invalidateData() @ce, @cpp Buffer::invalidateSubData() @ce and - @cpp Buffer::invalidateData() @ce, @cpp Buffer::invalidateSubData() @ce and
@cpp Renderer::resetNotificationStrategy() @ce functions are enabled on @cpp Renderer::resetNotificationStrategy() @ce functions are enabled on
OpenGL ES as a no-op 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 for greater runtime-usage flexibility
- @ref Platform::Sdl2Application now defaults to non-resizable window, you - @ref Platform::Sdl2Application now defaults to non-resizable window, you
can change the behavior using @ref Platform::Sdl2Application::Configuration::setWindowFlags() 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 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 they had undesired side-effects in some cases, use the data-returning
versions instead and then configure mesh and buffer manually 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 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(). deprecated, use the function in conjunction with @ref MeshTools::duplicate().
See function documentation for more information. See function documentation for more information.
- Parameter-less @cpp Mesh::draw() @ce and @cpp MeshView::draw() @ce are - Parameter-less @cpp Mesh::draw() @ce and @cpp MeshView::draw() @ce are

16
doc/changelog.dox

@ -429,6 +429,17 @@ See also:
@ref MeshTools::flipFaceWindingInPlace() and @ref MeshTools::tipsifyInPlace() @ref MeshTools::flipFaceWindingInPlace() and @ref MeshTools::tipsifyInPlace()
that accept a @ref Corrade::Containers::StridedArrayView instead of a that accept a @ref Corrade::Containers::StridedArrayView instead of a
@ref std::vector and work with 8- and 16-byte index types as well. @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 @subsection changelog-latest-compatibility Potential compatibility breakages, removed APIs
@ -3214,9 +3225,10 @@ a high-level overview.
- Removed deprecated `*Texture::maxLayers()` functions, use - Removed deprecated `*Texture::maxLayers()` functions, use
@ref GL::Shader::maxCombinedTextureImageUnits() "Shader::maxCombinedTextureImageUnits()" @ref GL::Shader::maxCombinedTextureImageUnits() "Shader::maxCombinedTextureImageUnits()"
instead instead
- Removed deprecated @ref MeshTools::combineIndexedArrays(), - Removed deprecated @cpp MeshTools::combineIndexedArrays() @ce,
@ref MeshTools::compressIndices(), @ref MeshTools::interleave() and @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 - Removed deprecated `Mesh*::set*{Range,Count}()` functions, use
@ref GL::Mesh::setCount() "Mesh*::setCount()" and @ref GL::Mesh::setCount() "Mesh*::setCount()" and
@ref GL::MeshView::setIndexRange() "MeshView::setIndexRange()" instead @ref GL::MeshView::setIndexRange() "MeshView::setIndexRange()" instead

18
doc/snippets/MagnumMeshTools.cpp

@ -25,7 +25,6 @@
#include "Magnum/Math/Color.h" #include "Magnum/Math/Color.h"
#include "Magnum/Math/FunctionsBatch.h" #include "Magnum/Math/FunctionsBatch.h"
#include "Magnum/MeshTools/CombineIndexedArrays.h"
#include "Magnum/MeshTools/CompressIndices.h" #include "Magnum/MeshTools/CompressIndices.h"
#include "Magnum/MeshTools/Duplicate.h" #include "Magnum/MeshTools/Duplicate.h"
#include "Magnum/MeshTools/GenerateNormals.h" #include "Magnum/MeshTools/GenerateNormals.h"
@ -34,12 +33,19 @@
#include "Magnum/MeshTools/Transform.h" #include "Magnum/MeshTools/Transform.h"
#include "Magnum/Trade/MeshData.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;
using namespace Magnum::Math::Literals; using namespace Magnum::Math::Literals;
int main() { int main() {
#ifdef MAGNUM_BUILD_DEPRECATED
{ {
CORRADE_IGNORE_DEPRECATED_PUSH
/* [combineIndexedArrays] */ /* [combineIndexedArrays] */
std::vector<UnsignedInt> vertexIndices; std::vector<UnsignedInt> vertexIndices;
std::vector<Vector3> positions; std::vector<Vector3> positions;
@ -53,7 +59,9 @@ std::vector<UnsignedInt> indices = MeshTools::combineIndexedArrays(
std::make_pair(std::cref(normalTextureIndices), std::ref(textureCoordinates)) std::make_pair(std::cref(normalTextureIndices), std::ref(textureCoordinates))
); );
/* [combineIndexedArrays] */ /* [combineIndexedArrays] */
CORRADE_IGNORE_DEPRECATED_POP
} }
#endif
{ {
/* [compressIndices-offset] */ /* [compressIndices-offset] */
@ -66,13 +74,17 @@ std::pair<Containers::Array<char>, MeshIndexType> result =
/* [compressIndices-offset] */ /* [compressIndices-offset] */
} }
#ifdef MAGNUM_BUILD_DEPRECATED
{ {
CORRADE_IGNORE_DEPRECATED_PUSH
/* [compressIndicesAs] */ /* [compressIndicesAs] */
std::vector<UnsignedInt> indices; std::vector<UnsignedInt> indices;
Containers::Array<UnsignedShort> indexData = Containers::Array<UnsignedShort> indexData =
MeshTools::compressIndicesAs<UnsignedShort>(indices); MeshTools::compressIndicesAs<UnsignedShort>(indices);
/* [compressIndicesAs] */ /* [compressIndicesAs] */
CORRADE_IGNORE_DEPRECATED_POP
} }
#endif
{ {
/* [generateFlatNormals] */ /* [generateFlatNormals] */
@ -143,7 +155,9 @@ data = data.prefix(size);
/* [removeDuplicates] */ /* [removeDuplicates] */
} }
#ifdef MAGNUM_BUILD_DEPRECATED
{ {
CORRADE_IGNORE_DEPRECATED_PUSH
/* [removeDuplicates-multiple] */ /* [removeDuplicates-multiple] */
std::vector<Vector3> positions; std::vector<Vector3> positions;
std::vector<Vector2> texCoords; std::vector<Vector2> texCoords;
@ -156,7 +170,9 @@ std::vector<UnsignedInt> indices = MeshTools::combineIndexedArrays(
std::make_pair(std::cref(texCoordIndices), std::ref(texCoords)) std::make_pair(std::cref(texCoordIndices), std::ref(texCoords))
); );
/* [removeDuplicates-multiple] */ /* [removeDuplicates-multiple] */
CORRADE_IGNORE_DEPRECATED_POP
} }
#endif
{ {
/* [transformVectors] */ /* [transformVectors] */

12
doc/snippets/MagnumShaders.cpp

@ -290,17 +290,11 @@ mesh.addVertexBuffer(vertexIndices, 0, Shaders::MeshVisualizer::VertexIndex{});
{ {
/* [MeshVisualizer-usage-no-geom1] */ /* [MeshVisualizer-usage-no-geom1] */
std::vector<UnsignedInt> indices{ Containers::StridedArrayView1D<const UnsignedInt> indices;
// ... Containers::StridedArrayView1D<const Vector3> indexedPositions;
};
std::vector<Vector3> indexedPositions{
// ...
};
/* De-indexing the position array */ /* De-indexing the position array */
GL::Buffer vertices; GL::Buffer vertices{MeshTools::duplicate(indices, indexedPositions)};
vertices.setData(MeshTools::duplicate(indices, indexedPositions),
GL::BufferUsage::StaticDraw);
GL::Mesh mesh; GL::Mesh mesh;
mesh.addVertexBuffer(vertices, 0, Shaders::MeshVisualizer::Position{}); mesh.addVertexBuffer(vertices, 0, Shaders::MeshVisualizer::Position{});

8
src/Magnum/MeshTools/CMakeLists.txt

@ -30,7 +30,6 @@ set(MagnumMeshTools_SRCS
# Files compiled with different flags for main library and unit test library # Files compiled with different flags for main library and unit test library
set(MagnumMeshTools_GracefulAssert_SRCS set(MagnumMeshTools_GracefulAssert_SRCS
Combine.cpp Combine.cpp
CombineIndexedArrays.cpp
CompressIndices.cpp CompressIndices.cpp
Duplicate.cpp Duplicate.cpp
FlipNormals.cpp FlipNormals.cpp
@ -40,7 +39,6 @@ set(MagnumMeshTools_GracefulAssert_SRCS
set(MagnumMeshTools_HEADERS set(MagnumMeshTools_HEADERS
Combine.h Combine.h
CombineIndexedArrays.h
CompressIndices.h CompressIndices.h
Duplicate.h Duplicate.h
FlipNormals.h FlipNormals.h
@ -57,7 +55,11 @@ set(MagnumMeshTools_INTERNAL_HEADERS
Implementation/Tipsify.h) Implementation/Tipsify.h)
if(BUILD_DEPRECATED) 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() endif()
if(TARGET_GL) if(TARGET_GL)

4
src/Magnum/MeshTools/CombineIndexedArrays.cpp

@ -23,6 +23,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#define _MAGNUM_NO_DEPRECATED_COMBINEINDEXEDARRAYS
#include "CombineIndexedArrays.h" #include "CombineIndexedArrays.h"
#include <cstring> #include <cstring>
@ -56,7 +58,9 @@ std::pair<std::vector<UnsignedInt>, std::vector<UnsignedInt>> interleaveAndCombi
/* Combine them */ /* Combine them */
std::vector<UnsignedInt> combinedIndices; std::vector<UnsignedInt> combinedIndices;
CORRADE_IGNORE_DEPRECATED_PUSH
std::tie(combinedIndices, interleavedArrays) = MeshTools::combineIndexArrays(interleavedArrays, stride); std::tie(combinedIndices, interleavedArrays) = MeshTools::combineIndexArrays(interleavedArrays, stride);
CORRADE_IGNORE_DEPRECATED_POP
return {combinedIndices, interleavedArrays}; return {combinedIndices, interleavedArrays};
} }

31
src/Magnum/MeshTools/CombineIndexedArrays.h

@ -25,18 +25,30 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#ifdef MAGNUM_BUILD_DEPRECATED
/** @file /** @file
* @brief Function @ref Magnum::MeshTools::combineIndexArrays(), @ref Magnum::MeshTools::combineIndexedArrays() * @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 <functional> #include <functional>
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include <Corrade/Utility/Assert.h> #include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Macros.h>
#include "Magnum/Types.h" #include "Magnum/Types.h"
#include "Magnum/MeshTools/visibility.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 { namespace Magnum { namespace MeshTools {
/** /**
@ -44,6 +56,7 @@ namespace Magnum { namespace MeshTools {
@param[in,out] arrays Index arrays to combine. These arrays are updated @param[in,out] arrays Index arrays to combine. These arrays are updated
in-place to contain unique combinations of the original indices. in-place to contain unique combinations of the original indices.
@return Resulting combined index array @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 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 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<UnsignedInt>&, Uns
internally. See also @ref combineIndexedArrays() which does the vertex data internally. See also @ref combineIndexedArrays() which does the vertex data
reordering automatically. reordering automatically.
*/ */
MAGNUM_MESHTOOLS_EXPORT std::vector<UnsignedInt> combineIndexArrays(const std::vector<std::reference_wrapper<std::vector<UnsignedInt>>>& arrays); CORRADE_DEPRECATED("use combineIndexedAttributes() instead") MAGNUM_MESHTOOLS_EXPORT std::vector<UnsignedInt> combineIndexArrays(const std::vector<std::reference_wrapper<std::vector<UnsignedInt>>>& arrays);
/** @overload */ /**
MAGNUM_MESHTOOLS_EXPORT std::vector<UnsignedInt> combineIndexArrays(std::initializer_list<std::reference_wrapper<std::vector<UnsignedInt>>> arrays); @overload
@m_deprecated_since_latest Use @ref combineIndexedAttributes() instead.
*/
CORRADE_DEPRECATED("use combineIndexedAttributes() instead") MAGNUM_MESHTOOLS_EXPORT std::vector<UnsignedInt> combineIndexArrays(std::initializer_list<std::reference_wrapper<std::vector<UnsignedInt>>> arrays);
/** /**
@brief Combine interleaved index 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 Unlike above, this function takes one interleaved array instead of separate
index arrays. Continuing with the above example, you would call this function 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() @see @ref combineIndexedArrays()
*/ */
MAGNUM_MESHTOOLS_EXPORT std::pair<std::vector<UnsignedInt>, std::vector<UnsignedInt>> combineIndexArrays(const std::vector<UnsignedInt>& interleavedArrays, UnsignedInt stride); CORRADE_DEPRECATED("use combineIndexedAttributes() instead") MAGNUM_MESHTOOLS_EXPORT std::pair<std::vector<UnsignedInt>, std::vector<UnsignedInt>> combineIndexArrays(const std::vector<UnsignedInt>& interleavedArrays, UnsignedInt stride);
namespace Implementation { namespace Implementation {
@ -140,6 +157,7 @@ template<class T, class ...U> inline void writeCombinedArrays(UnsignedInt stride
@brief Combine indexed arrays @brief Combine indexed arrays
@param[in,out] indexedArrays Index and attribute arrays @param[in,out] indexedArrays Index and attribute arrays
@return Array with resulting indices @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 Creates new combined index array and reorders original attribute arrays so they
can be indexed with the new single index array. 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 /* 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 parameter is index array and which is attribute array, mainly when both are
of the same type. */ of the same type. */
template<class ...T> std::vector<UnsignedInt> combineIndexedArrays(const std::pair<const std::vector<UnsignedInt>&, std::vector<T>&>&... indexedArrays) { template<class ...T> CORRADE_DEPRECATED("use combineIndexedAttributes() instead") std::vector<UnsignedInt> combineIndexedArrays(const std::pair<const std::vector<UnsignedInt>&, std::vector<T>&>&... indexedArrays) {
/* Interleave and combine index arrays */ /* Interleave and combine index arrays */
std::vector<UnsignedInt> combinedIndices; std::vector<UnsignedInt> combinedIndices;
std::vector<UnsignedInt> interleavedCombinedIndexArrays; std::vector<UnsignedInt> interleavedCombinedIndexArrays;
@ -174,5 +192,8 @@ template<class ...T> std::vector<UnsignedInt> combineIndexedArrays(const std::pa
} }
}} }}
#else
#error use functions in Combine.h instead
#endif
#endif #endif

2
src/Magnum/MeshTools/CompressIndices.cpp

@ -178,7 +178,6 @@ std::tuple<Containers::Array<char>, MeshIndexType, UnsignedInt, UnsignedInt> com
std::tie(data, type) = compressIndices(indices, MeshIndexType::UnsignedByte); std::tie(data, type) = compressIndices(indices, MeshIndexType::UnsignedByte);
return std::make_tuple(std::move(data), type, minmax.first, minmax.second); return std::make_tuple(std::move(data), type, minmax.first, minmax.second);
} }
#endif
template<class T> Containers::Array<T> compressIndicesAs(const std::vector<UnsignedInt>& indices) { template<class T> Containers::Array<T> compressIndicesAs(const std::vector<UnsignedInt>& indices) {
#if !defined(CORRADE_NO_ASSERT) || defined(CORRADE_GRACEFUL_ASSERT) #if !defined(CORRADE_NO_ASSERT) || defined(CORRADE_GRACEFUL_ASSERT)
@ -196,5 +195,6 @@ template<class T> Containers::Array<T> compressIndicesAs(const std::vector<Unsig
template Containers::Array<UnsignedByte> compressIndicesAs(const std::vector<UnsignedInt>&); template Containers::Array<UnsignedByte> compressIndicesAs(const std::vector<UnsignedInt>&);
template Containers::Array<UnsignedShort> compressIndicesAs(const std::vector<UnsignedInt>&); template Containers::Array<UnsignedShort> compressIndicesAs(const std::vector<UnsignedInt>&);
template Containers::Array<UnsignedInt> compressIndicesAs(const std::vector<UnsignedInt>&); template Containers::Array<UnsignedInt> compressIndicesAs(const std::vector<UnsignedInt>&);
#endif
}} }}

14
src/Magnum/MeshTools/CompressIndices.h

@ -26,12 +26,11 @@
*/ */
/** @file /** @file
* @brief Function @ref Magnum::MeshTools::compressIndices(), @ref Magnum::MeshTools::compressIndicesAs() * @brief Function @ref Magnum::MeshTools::compressIndices()
*/ */
#include <utility> #include <utility>
#include <Corrade/Containers/Containers.h> #include <Corrade/Containers/Containers.h>
#include <Corrade/Utility/StlForwardVector.h>
#include "Magnum/Mesh.h" #include "Magnum/Mesh.h"
#include "Magnum/MeshTools/visibility.h" #include "Magnum/MeshTools/visibility.h"
@ -40,6 +39,7 @@
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#include <tuple> #include <tuple>
#include <Corrade/Utility/Macros.h> #include <Corrade/Utility/Macros.h>
#include <Corrade/Utility/StlForwardVector.h>
#endif #endif
namespace Magnum { namespace MeshTools { namespace Magnum { namespace MeshTools {
@ -178,14 +178,13 @@ sufficient.
Example usage: Example usage:
@snippet MagnumMeshTools-gl.cpp compressIndices-stl @snippet MagnumMeshTools-gl.cpp compressIndices-stl
@see @ref compressIndicesAs()
*/ */
CORRADE_DEPRECATED("use compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>&, MeshIndexType, Long) instead") MAGNUM_MESHTOOLS_EXPORT std::tuple<Containers::Array<char>, MeshIndexType, UnsignedInt, UnsignedInt> compressIndices(const std::vector<UnsignedInt>& indices); CORRADE_DEPRECATED("use compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>&, MeshIndexType, Long) instead") MAGNUM_MESHTOOLS_EXPORT std::tuple<Containers::Array<char>, MeshIndexType, UnsignedInt, UnsignedInt> compressIndices(const std::vector<UnsignedInt>& indices);
#endif
/** /**
@brief Compress vertex indices as given type @brief Compress vertex indices as given type
@m_deprecated_since_latest Use @ref compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>&, MeshIndexType, Long)
instead.
The type can be either @ref Magnum::UnsignedByte "UnsignedByte", The type can be either @ref Magnum::UnsignedByte "UnsignedByte",
@ref Magnum::UnsignedShort "UnsignedShort" or @ref Magnum::UnsignedInt "UnsignedInt". @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: Example usage:
@snippet MagnumMeshTools.cpp compressIndicesAs @snippet MagnumMeshTools.cpp compressIndicesAs
@see @ref compressIndices()
*/ */
template<class T> MAGNUM_MESHTOOLS_EXPORT Containers::Array<T> compressIndicesAs(const std::vector<UnsignedInt>& indices); template<class T> CORRADE_DEPRECATED("use compressIndices(const Containers::StridedArrayView1D<const UnsignedInt>&, MeshIndexType, Long) instead") MAGNUM_MESHTOOLS_EXPORT Containers::Array<T> compressIndicesAs(const std::vector<UnsignedInt>& indices);
#if defined(CORRADE_TARGET_WINDOWS) && !defined(__MINGW32__) #if defined(CORRADE_TARGET_WINDOWS) && !defined(__MINGW32__)
extern template MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedByte> compressIndicesAs<UnsignedByte>(const std::vector<UnsignedInt>&); extern template MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedByte> compressIndicesAs<UnsignedByte>(const std::vector<UnsignedInt>&);
extern template MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedShort> compressIndicesAs<UnsignedShort>(const std::vector<UnsignedInt>&); extern template MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedShort> compressIndicesAs<UnsignedShort>(const std::vector<UnsignedInt>&);
extern template MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedInt> compressIndicesAs<UnsignedInt>(const std::vector<UnsignedInt>&); extern template MAGNUM_MESHTOOLS_EXPORT Containers::Array<UnsignedInt> compressIndicesAs<UnsignedInt>(const std::vector<UnsignedInt>&);
#endif #endif
#endif
}} }}

18
src/Magnum/MeshTools/Duplicate.h

@ -29,15 +29,18 @@
* @brief Function @ref Magnum::MeshTools::duplicate(), @ref Magnum::MeshTools::duplicateInto() * @brief Function @ref Magnum::MeshTools::duplicate(), @ref Magnum::MeshTools::duplicateInto()
*/ */
#include <vector>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/MeshTools/visibility.h" #include "Magnum/MeshTools/visibility.h"
#include "Magnum/Trade/Trade.h" #include "Magnum/Trade/Trade.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <vector>
#include <Corrade/Containers/ArrayViewStl.h>
#endif
namespace Magnum { namespace MeshTools { namespace Magnum { namespace MeshTools {
#ifndef DOXYGEN_GENERATING_OUTPUT #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), If you want to fill an existing memory (or, for example a @ref std::vector),
use @ref duplicateInto(). use @ref duplicateInto().
@see @ref removeDuplicates(), @ref combineIndexedArrays() @see @ref removeDuplicatesInPlace(), @ref combineIndexedAttributes()
*/ */
template<class IndexType, class T> Containers::Array<T> duplicate(const Containers::StridedArrayView1D<const IndexType>& indices, const Containers::StridedArrayView1D<const T>& data) { template<class IndexType, class T> Containers::Array<T> duplicate(const Containers::StridedArrayView1D<const IndexType>& indices, const Containers::StridedArrayView1D<const T>& data) {
Containers::Array<T> out{Containers::NoInit, indices.size()}; Containers::Array<T> out{Containers::NoInit, indices.size()};
@ -64,17 +67,18 @@ template<class IndexType, class T> Containers::Array<T> duplicate(const Containe
return out; return out;
} }
#ifdef MAGNUM_BUILD_DEPRECATED
/** /**
@brief Duplicate data using given index array @brief Duplicate data using given index array
@m_deprecated_since_latest Use @ref duplicate(const Containers::StridedArrayView1D<const IndexType>&, const Containers::StridedArrayView1D<const T>&)
Like @ref duplicate(const Containers::StridedArrayView1D<const IndexType>&, const Containers::StridedArrayView1D<const T>&), or @ref duplicateInto() instead.
but putting the result into a @ref std::vector.
*/ */
template<class T> std::vector<T> duplicate(const std::vector<UnsignedInt>& indices, const std::vector<T>& data) { template<class T> CORRADE_DEPRECATED("use duplicate() taking a StridedArrayView instead") std::vector<T> duplicate(const std::vector<UnsignedInt>& indices, const std::vector<T>& data) {
std::vector<T> out(indices.size()); std::vector<T> out(indices.size());
duplicateInto<UnsignedInt, T>(indices, data, out); duplicateInto<UnsignedInt, T>(indices, data, out);
return out; return out;
} }
#endif
/** /**
@brief Duplicate data using an index array into given output array @brief Duplicate data using an index array into given output array

2
src/Magnum/MeshTools/GenerateNormals.cpp

@ -81,7 +81,9 @@ std::pair<std::vector<UnsignedInt>, std::vector<Vector3>> generateFlatNormals(co
} }
/* Remove duplicate normals and return */ /* Remove duplicate normals and return */
CORRADE_IGNORE_DEPRECATED_PUSH
normalIndices = MeshTools::duplicate(normalIndices, MeshTools::removeDuplicates(normals)); normalIndices = MeshTools::duplicate(normalIndices, MeshTools::removeDuplicates(normals));
CORRADE_IGNORE_DEPRECATED_POP
return {std::move(normalIndices), std::move(normals)}; return {std::move(normalIndices), std::move(normals)};
} }
#endif #endif

15
src/Magnum/MeshTools/RemoveDuplicates.h

@ -26,7 +26,7 @@
*/ */
/** @file /** @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 <limits> #include <limits>
@ -133,11 +133,14 @@ instead.
If you want to remove duplicate data from an already indexed array, use If you want to remove duplicate data from an already indexed array, use
@ref removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<IndexType>&, const Containers::StridedArrayView1D<Vector>&, typename Vector::Type) instead. @ref removeDuplicatesIndexedInPlace(const Containers::StridedArrayView1D<IndexType>&, const Containers::StridedArrayView1D<Vector>&, typename Vector::Type) instead.
See also @ref removeDuplicates(std::vector<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<class Vector> std::pair<Containers::Array<UnsignedInt>, std::size_t> removeDuplicatesInPlace(const Containers::StridedArrayView1D<Vector>& data, typename Vector::Type epsilon = Math::TypeTraits<typename Vector::Type>::epsilon()); template<class Vector> std::pair<Containers::Array<UnsignedInt>, std::size_t> removeDuplicatesInPlace(const Containers::StridedArrayView1D<Vector>& data, typename Vector::Type epsilon = Math::TypeTraits<typename Vector::Type>::epsilon());
#ifdef MAGNUM_BUILD_DEPRECATED
/** /**
@brief Remove duplicate floating-point vector data from a STL vector in-place @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 @param[in,out] data Data array, duplicate items will be cut away with order
@ -145,6 +148,7 @@ template<class Vector> std::pair<Containers::Array<UnsignedInt>, std::size_t> re
@param[in] epsilon Epsilon value, vertices closer than this distance will be @param[in] epsilon Epsilon value, vertices closer than this distance will be
melt together melt together
@return Resulting index array @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 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 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 @snippet MagnumMeshTools.cpp removeDuplicates-multiple
*/ */
template<class Vector> std::vector<UnsignedInt> removeDuplicates(std::vector<Vector>& data, typename Vector::Type epsilon = Math::TypeTraits<typename Vector::Type>::epsilon()); template<class Vector> CORRADE_DEPRECATED("use removeDuplicatesInPlace() instead") std::vector<UnsignedInt> removeDuplicates(std::vector<Vector>& data, typename Vector::Type epsilon = Math::TypeTraits<typename Vector::Type>::epsilon());
#endif
/** /**
@brief Remove duplicates from indexed floating-point vector data in-place @brief Remove duplicates from indexed floating-point vector data in-place
@ -245,6 +250,7 @@ template<class Vector> std::pair<Containers::Array<UnsignedInt>, std::size_t> re
return {std::move(indices), size}; return {std::move(indices), size};
} }
#ifdef MAGNUM_BUILD_DEPRECATED
template<class Vector> std::vector<UnsignedInt> removeDuplicates(std::vector<Vector>& data, typename Vector::Type epsilon) { template<class Vector> std::vector<UnsignedInt> removeDuplicates(std::vector<Vector>& data, typename Vector::Type epsilon) {
/* A trivial index array that'll be remapped and returned after */ /* A trivial index array that'll be remapped and returned after */
std::vector<UnsignedInt> indices(data.size()); std::vector<UnsignedInt> indices(data.size());
@ -253,6 +259,7 @@ template<class Vector> std::vector<UnsignedInt> removeDuplicates(std::vector<Vec
data.resize(size); data.resize(size);
return indices; return indices;
} }
#endif
}} }}

14
src/Magnum/MeshTools/Subdivide.h

@ -29,7 +29,6 @@
* @brief Function @ref Magnum::MeshTools::subdivide(), @ref Magnum::MeshTools::subdivideInPlace() * @brief Function @ref Magnum::MeshTools::subdivide(), @ref Magnum::MeshTools::subdivideInPlace()
*/ */
#include <vector>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/ArrayViewStl.h> #include <Corrade/Containers/ArrayViewStl.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
@ -37,6 +36,10 @@
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <vector>
#endif
namespace Magnum { namespace MeshTools { namespace Magnum { namespace MeshTools {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
@ -66,19 +69,20 @@ template<class IndexType, class Vertex, class Interpolator> void subdivide(Conta
subdivideInPlace(Containers::stridedArrayView(indices), Containers::stridedArrayView(vertices), interpolator); subdivideInPlace(Containers::stridedArrayView(indices), Containers::stridedArrayView(vertices), interpolator);
} }
#ifdef MAGNUM_BUILD_DEPRECATED
/** /**
@brief Subdivide a mesh @brief Subdivide a mesh
@m_deprecated_since_latest Use @ref subdivide(Containers::Array<IndexType>&, Containers::Array<Vertex>&vertices, Interpolator)
Same as @ref subdivide(Containers::Array<IndexType>&, Containers::Array<Vertex>&vertices, Interpolator), only or @ref subdivideInPlace() instead.
working on a @ref std::vector.
*/ */
template<class Vertex, class Interpolator> void subdivide(std::vector<UnsignedInt>& indices, std::vector<Vertex>& vertices, Interpolator interpolator) { template<class Vertex, class Interpolator> CORRADE_DEPRECATED("use subdivide(Containers::Array<IndexType>&, Containers::Array<Vertex>&vertices, Interpolator) or subdivideInPlace() instead") void subdivide(std::vector<UnsignedInt>& indices, std::vector<Vertex>& vertices, Interpolator interpolator) {
CORRADE_ASSERT(!(indices.size()%3), "MeshTools::subdivide(): index count is not divisible by 3", ); CORRADE_ASSERT(!(indices.size()%3), "MeshTools::subdivide(): index count is not divisible by 3", );
vertices.resize(vertices.size() + indices.size()); vertices.resize(vertices.size() + indices.size());
indices.resize(indices.size()*4); indices.resize(indices.size()*4);
subdivideInPlace(Containers::stridedArrayView(indices), Containers::stridedArrayView(vertices), interpolator); subdivideInPlace(Containers::stridedArrayView(indices), Containers::stridedArrayView(vertices), interpolator);
} }
#endif
/** /**
@brief Subdivide a mesh in-place @brief Subdivide a mesh in-place

13
src/Magnum/MeshTools/Test/CMakeLists.txt

@ -24,7 +24,6 @@
# #
corrade_add_test(MeshToolsCombineTest CombineTest.cpp LIBRARIES MagnumMeshToolsTestLib) 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(MeshToolsCompressIndicesTest CompressIndicesTest.cpp LIBRARIES MagnumMeshToolsTestLib)
corrade_add_test(MeshToolsDuplicateTest DuplicateTest.cpp LIBRARIES MagnumMeshToolsTestLib) corrade_add_test(MeshToolsDuplicateTest DuplicateTest.cpp LIBRARIES MagnumMeshToolsTestLib)
corrade_add_test(MeshToolsFlipNormalsTest FlipNormalsTest.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 # Graceful assert for testing
set_property(TARGET set_property(TARGET
MeshToolsCombineIndexedArraysTest
MeshToolsDuplicateTest MeshToolsDuplicateTest
MeshToolsInterleaveTest MeshToolsInterleaveTest
MeshToolsRemoveDuplicatesTest MeshToolsRemoveDuplicatesTest
@ -47,7 +45,6 @@ set_property(TARGET
set_target_properties( set_target_properties(
MeshToolsCombineTest MeshToolsCombineTest
MeshToolsCombineIndexedArraysTest
MeshToolsCompressIndicesTest MeshToolsCompressIndicesTest
MeshToolsDuplicateTest MeshToolsDuplicateTest
MeshToolsFlipNormalsTest MeshToolsFlipNormalsTest
@ -60,6 +57,16 @@ set_target_properties(
MeshToolsSubdivideRemov___Benchmark MeshToolsSubdivideRemov___Benchmark
PROPERTIES FOLDER "Magnum/MeshTools/Test") 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) if(BUILD_GL_TESTS)
# Otherwise CMake complains that Corrade::PluginManager is not found # Otherwise CMake complains that Corrade::PluginManager is not found
find_package(Corrade REQUIRED PluginManager) find_package(Corrade REQUIRED PluginManager)

4
src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp

@ -28,6 +28,8 @@
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#define _MAGNUM_NO_DEPRECATED_COMBINEINDEXEDARRAYS
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/MeshTools/CombineIndexedArrays.h" #include "Magnum/MeshTools/CombineIndexedArrays.h"
@ -47,6 +49,7 @@ CombineIndexedArraysTest::CombineIndexedArraysTest() {
&CombineIndexedArraysTest::indexedArrays}); &CombineIndexedArraysTest::indexedArrays});
} }
CORRADE_IGNORE_DEPRECATED_PUSH
void CombineIndexedArraysTest::wrongIndexCount() { void CombineIndexedArraysTest::wrongIndexCount() {
std::stringstream ss; std::stringstream ss;
Error redirectError{&ss}; Error redirectError{&ss};
@ -87,6 +90,7 @@ void CombineIndexedArraysTest::indexedArrays() {
CORRADE_COMPARE(array2, (std::vector<UnsignedInt>{3, 4})); CORRADE_COMPARE(array2, (std::vector<UnsignedInt>{3, 4}));
CORRADE_COMPARE(array3, (std::vector<UnsignedInt>{6, 7})); CORRADE_COMPARE(array3, (std::vector<UnsignedInt>{6, 7}));
} }
CORRADE_IGNORE_DEPRECATED_POP
}}}} }}}}

11
src/Magnum/MeshTools/Test/CompressIndicesTest.cpp

@ -58,7 +58,9 @@ struct CompressIndicesTest: TestSuite::Tester {
void compressMeshDataMove(); void compressMeshDataMove();
void compressMeshDataNonIndexed(); void compressMeshDataNonIndexed();
#ifdef MAGNUM_BUILD_DEPRECATED
void compressAsShort(); void compressAsShort();
#endif
}; };
CompressIndicesTest::CompressIndicesTest() { CompressIndicesTest::CompressIndicesTest() {
@ -85,7 +87,10 @@ CompressIndicesTest::CompressIndicesTest() {
&CompressIndicesTest::compressMeshDataMove, &CompressIndicesTest::compressMeshDataMove,
&CompressIndicesTest::compressMeshDataNonIndexed, &CompressIndicesTest::compressMeshDataNonIndexed,
&CompressIndicesTest::compressAsShort}); #ifdef MAGNUM_BUILD_DEPRECATED
&CompressIndicesTest::compressAsShort
#endif
});
} }
template<class T> void CompressIndicesTest::compressUnsignedByte() { template<class T> void CompressIndicesTest::compressUnsignedByte() {
@ -318,7 +323,9 @@ void CompressIndicesTest::compressMeshDataNonIndexed() {
"MeshTools::compressIndices(): mesh data not indexed\n"); "MeshTools::compressIndices(): mesh data not indexed\n");
} }
#ifdef MAGNUM_BUILD_DEPRECATED
void CompressIndicesTest::compressAsShort() { void CompressIndicesTest::compressAsShort() {
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_COMPARE_AS(MeshTools::compressIndicesAs<UnsignedShort>({123, 456}), CORRADE_COMPARE_AS(MeshTools::compressIndicesAs<UnsignedShort>({123, 456}),
Containers::arrayView<UnsignedShort>({123, 456}), Containers::arrayView<UnsignedShort>({123, 456}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
@ -327,7 +334,9 @@ void CompressIndicesTest::compressAsShort() {
Error redirectError{&out}; Error redirectError{&out};
MeshTools::compressIndicesAs<UnsignedShort>({65536}); MeshTools::compressIndicesAs<UnsignedShort>({65536});
CORRADE_COMPARE(out.str(), "MeshTools::compressIndicesAs(): type too small to represent value 65536\n"); CORRADE_COMPARE(out.str(), "MeshTools::compressIndicesAs(): type too small to represent value 65536\n");
CORRADE_IGNORE_DEPRECATED_POP
} }
#endif
}}}} }}}}

8
src/Magnum/MeshTools/Test/DuplicateTest.cpp

@ -42,7 +42,9 @@ struct DuplicateTest: TestSuite::Tester {
void duplicate(); void duplicate();
void duplicateOutOfBounds(); void duplicateOutOfBounds();
#ifdef MAGNUM_BUILD_DEPRECATED
void duplicateStl(); void duplicateStl();
#endif
void duplicateInto(); void duplicateInto();
void duplicateIntoWrongSize(); void duplicateIntoWrongSize();
@ -67,7 +69,9 @@ struct DuplicateTest: TestSuite::Tester {
DuplicateTest::DuplicateTest() { DuplicateTest::DuplicateTest() {
addTests({&DuplicateTest::duplicate, addTests({&DuplicateTest::duplicate,
&DuplicateTest::duplicateOutOfBounds, &DuplicateTest::duplicateOutOfBounds,
#ifdef MAGNUM_BUILD_DEPRECATED
&DuplicateTest::duplicateStl, &DuplicateTest::duplicateStl,
#endif
&DuplicateTest::duplicateInto, &DuplicateTest::duplicateInto,
&DuplicateTest::duplicateIntoWrongSize, &DuplicateTest::duplicateIntoWrongSize,
@ -116,10 +120,14 @@ void DuplicateTest::duplicateOutOfBounds() {
"MeshTools::duplicateInto(): index 4 out of bounds for 4 elements\n"); "MeshTools::duplicateInto(): index 4 out of bounds for 4 elements\n");
} }
#ifdef MAGNUM_BUILD_DEPRECATED
void DuplicateTest::duplicateStl() { void DuplicateTest::duplicateStl() {
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_COMPARE(MeshTools::duplicate({1, 1, 0, 3, 2, 2}, std::vector<int>{-7, 35, 12, -18}), CORRADE_COMPARE(MeshTools::duplicate({1, 1, 0, 3, 2, 2}, std::vector<int>{-7, 35, 12, -18}),
(std::vector<Int>{35, 35, -7, -18, 12, 12})); (std::vector<Int>{35, 35, -7, -18, 12, 12}));
CORRADE_IGNORE_DEPRECATED_POP
} }
#endif
void DuplicateTest::duplicateInto() { void DuplicateTest::duplicateInto() {
constexpr UnsignedByte indices[]{1, 1, 0, 3, 2, 2}; constexpr UnsignedByte indices[]{1, 1, 0, 3, 2, 2};

8
src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp

@ -45,7 +45,9 @@ struct RemoveDuplicatesTest: TestSuite::Tester {
void removeDuplicatesIndexedInPlaceEmptyIndicesVertices(); void removeDuplicatesIndexedInPlaceEmptyIndicesVertices();
void removeDuplicatesFuzzyInPlace(); void removeDuplicatesFuzzyInPlace();
#ifdef MAGNUM_BUILD_DEPRECATED
void removeDuplicatesFuzzyStl(); void removeDuplicatesFuzzyStl();
#endif
template<class T> void removeDuplicatesFuzzyIndexedInPlace(); template<class T> void removeDuplicatesFuzzyIndexedInPlace();
void removeDuplicatesFuzzyIndexedInPlaceSmallType(); void removeDuplicatesFuzzyIndexedInPlaceSmallType();
void removeDuplicatesFuzzyIndexedInPlaceEmptyIndices(); void removeDuplicatesFuzzyIndexedInPlaceEmptyIndices();
@ -66,7 +68,9 @@ RemoveDuplicatesTest::RemoveDuplicatesTest() {
&RemoveDuplicatesTest::removeDuplicatesIndexedInPlaceEmptyIndicesVertices, &RemoveDuplicatesTest::removeDuplicatesIndexedInPlaceEmptyIndicesVertices,
&RemoveDuplicatesTest::removeDuplicatesFuzzyInPlace, &RemoveDuplicatesTest::removeDuplicatesFuzzyInPlace,
#ifdef MAGNUM_BUILD_DEPRECATED
&RemoveDuplicatesTest::removeDuplicatesFuzzyStl, &RemoveDuplicatesTest::removeDuplicatesFuzzyStl,
#endif
&RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace<UnsignedByte>, &RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace<UnsignedByte>,
&RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace<UnsignedShort>, &RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace<UnsignedShort>,
&RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace<UnsignedInt>, &RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace<UnsignedInt>,
@ -173,6 +177,7 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyInPlace() {
TestSuite::Compare::Container); TestSuite::Compare::Container);
} }
#ifdef MAGNUM_BUILD_DEPRECATED
void RemoveDuplicatesTest::removeDuplicatesFuzzyStl() { void RemoveDuplicatesTest::removeDuplicatesFuzzyStl() {
/* Same but with implicit bloat. HEH HEH */ /* Same but with implicit bloat. HEH HEH */
std::vector<Vector2i> data{ std::vector<Vector2i> data{
@ -182,7 +187,9 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyStl() {
{1, 5} {1, 5}
}; };
CORRADE_IGNORE_DEPRECATED_PUSH
const std::vector<UnsignedInt> indices = MeshTools::removeDuplicates(data, 2); const std::vector<UnsignedInt> indices = MeshTools::removeDuplicates(data, 2);
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE_AS(indices, CORRADE_COMPARE_AS(indices,
(std::vector<UnsignedInt>{0, 0, 1, 1}), (std::vector<UnsignedInt>{0, 0, 1, 1}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
@ -190,6 +197,7 @@ void RemoveDuplicatesTest::removeDuplicatesFuzzyStl() {
(std::vector<Vector2i>{{1, 0}, {0, 4}}), (std::vector<Vector2i>{{1, 0}, {0, 4}}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
} }
#endif
template<class T> void RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace() { template<class T> void RemoveDuplicatesTest::removeDuplicatesFuzzyIndexedInPlace() {
setTestCaseTemplateName(Math::TypeTraits<T>::name()); setTestCaseTemplateName(Math::TypeTraits<T>::name());

12
src/Magnum/MeshTools/Test/SubdivideTest.cpp

@ -37,7 +37,9 @@ struct SubdivideTest: TestSuite::Tester {
explicit SubdivideTest(); explicit SubdivideTest();
void subdivide(); void subdivide();
#ifdef MAGNUM_BUILD_DEPRECATED
void subdivideStl(); void subdivideStl();
#endif
void subdivideWrongIndexCount(); void subdivideWrongIndexCount();
template<class T> void subdivideInPlace(); template<class T> void subdivideInPlace();
void subdivideInPlaceWrongIndexCount(); void subdivideInPlaceWrongIndexCount();
@ -52,7 +54,9 @@ inline Vector1 interpolator(Vector1 a, Vector1 b) { return (a[0]+b[0])/2; }
SubdivideTest::SubdivideTest() { SubdivideTest::SubdivideTest() {
addTests({&SubdivideTest::subdivide, addTests({&SubdivideTest::subdivide,
#ifdef MAGNUM_BUILD_DEPRECATED
&SubdivideTest::subdivideStl, &SubdivideTest::subdivideStl,
#endif
&SubdivideTest::subdivideWrongIndexCount, &SubdivideTest::subdivideWrongIndexCount,
&SubdivideTest::subdivideInPlace<UnsignedByte>, &SubdivideTest::subdivideInPlace<UnsignedByte>,
&SubdivideTest::subdivideInPlace<UnsignedShort>, &SubdivideTest::subdivideInPlace<UnsignedShort>,
@ -74,10 +78,13 @@ void SubdivideTest::subdivide() {
}), TestSuite::Compare::Container); }), TestSuite::Compare::Container);
} }
#ifdef MAGNUM_BUILD_DEPRECATED
void SubdivideTest::subdivideStl() { void SubdivideTest::subdivideStl() {
std::vector<Vector1> positions{0, 2, 6, 8}; std::vector<Vector1> positions{0, 2, 6, 8};
std::vector<UnsignedInt> indices{0, 1, 2, 1, 2, 3}; std::vector<UnsignedInt> indices{0, 1, 2, 1, 2, 3};
CORRADE_IGNORE_DEPRECATED_PUSH
MeshTools::subdivide(indices, positions, interpolator); MeshTools::subdivide(indices, positions, interpolator);
CORRADE_IGNORE_DEPRECATED_POP
CORRADE_COMPARE_AS(indices, CORRADE_COMPARE_AS(indices,
(std::vector<UnsignedInt>{4, 5, 6, 7, 8, 9, 0, 4, 6, 4, 1, 5, 6, 5, 2, 1, 7, 9, 7, 2, 8, 9, 8, 3}), (std::vector<UnsignedInt>{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<Vector1>{0, 2, 6, 8, 1, 4, 3, 4, 7, 5}), (std::vector<Vector1>{0, 2, 6, 8, 1, 4, 3, 4, 7, 5}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
} }
#endif
void SubdivideTest::subdivideWrongIndexCount() { void SubdivideTest::subdivideWrongIndexCount() {
std::stringstream out; std::stringstream out;
Error redirectError{&out}; Error redirectError{&out};
std::vector<Vector1> positions; Containers::Array<Vector1> positions;
std::vector<UnsignedInt> indices{0, 1}; Containers::Array<UnsignedInt> indices{2};
MeshTools::subdivide(indices, positions, interpolator); MeshTools::subdivide(indices, positions, interpolator);
CORRADE_COMPARE(out.str(), "MeshTools::subdivide(): index count is not divisible by 3\n"); CORRADE_COMPARE(out.str(), "MeshTools::subdivide(): index count is not divisible by 3\n");
} }

Loading…
Cancel
Save