allow PropertyManagers to be used in smart ranges

This commit is contained in:
Max Lyon
2019-09-27 14:45:20 +02:00
parent aa91a88f7b
commit f71696f294
3 changed files with 67 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
#include <Unittests/unittests_common.hh>
#include <OpenMesh/Core/Mesh/SmartHandles.hh>
#include <OpenMesh/Core/Utils/PropertyManager.hh>
#include <iostream>
#include <chrono>
@@ -192,5 +193,25 @@ TEST_F(OpenMeshSmartRanges, Sum)
}
/* Test if Property Manager can be used in smart ranges
*/
TEST_F(OpenMeshSmartRanges, PropertyManagerAsFunctor)
{
auto myPos = OpenMesh::makeTemporaryProperty<OpenMesh::VertexHandle, Mesh::Point>(mesh_);
for (auto vh : mesh_.vertices())
myPos(vh) = mesh_.point(vh);
Mesh::Point cog(0,0,0);
for (auto vh : mesh_.vertices())
cog += mesh_.point(vh);
cog /= mesh_.n_vertices();
auto cog2 = mesh_.vertices().avg(myPos);
EXPECT_LT(norm(cog - cog2), 0.00001) << "Computed center of gravities are significantly different.";
}
}