1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
//! Used to test the method ff::atomic::mef(...)
#include "ff/EulerOperations.h"
#include "ff/Face.h"
#include "ff/Make.h"
#include "ff/Polyhedron.h"
#include "ff/Topology.h"
#include "test/3rdparty/catch.hpp"
namespace {
ff::Polyhedron cube({{
{{0, 1, 2, 3}, false},
{{4, 9, 7, 6, 8, 5}, false},
{{0, 4, 5, 1}, false},
{{1, 5, 6, 2}, false},
{{2, 6, 7, 3}, false},
{{0, 3, 7, 4}, false},
},
false},
{{-1, -1, -1},
{-1, 1, -1},
{1, 1, -1},
{1, -1, -1},
{-1, -1, 1},
{-1, 1, 1},
{1, 1, 1},
{1, -1, 1},
{0, 1, 1},
{0, -1, 1}});
}
//! Tests whether MEF works correctly with indexes in bounds
TEST_CASE("MEF:InsideBounds", "")
{
ff::Polyhedron* p = ff::atomic::mef(cube, 1, 1, 4);
CHECK(p->faces().size() == 7);
CHECK(p->topology().faces[1].vertexIndices == std::vector<int>{9, 7, 6, 8});
CHECK(p->topology().faces[p->topology().faces.size() - 1].vertexIndices
== std::vector<int>{4, 9, 8, 5});
}
//! Tests whether MEF handles index array wrapping correctly
TEST_CASE("MEF:BeginWithWrap", "")
{
ff::Polyhedron* p = ff::atomic::mef(cube, 1, 4, 1);
CHECK(p->faces().size() == 7);
CHECK(p->topology().faces[1].vertexIndices == std::vector<int>{9, 7, 6, 8});
CHECK(p->topology().faces[p->topology().faces.size() - 1].vertexIndices
== std::vector<int>{4, 9, 8, 5});
}
//! Test whether MEF will throw if the vertex indices are neighbors
TEST_CASE("MEF:THROWSWhenNeighbor", "")
{
CHECK_THROWS(ff::atomic::mef(cube, 0, 0, 1));
}
//! Test whether MEF will throw if the vertex indices are neighbors wrapped around the array end
TEST_CASE("MEF:THROWSWhenNeighbor:Wrapped", "")
{
CHECK_THROWS(ff::atomic::mef(cube, 0, 3, 0));
}
|