[go: up one dir, main page]

File: EulerKEF.cpp

package info (click to toggle)
libformfactor 0.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,288 kB
  • sloc: cpp: 17,289; python: 382; makefile: 15
file content (61 lines) | stat: -rw-r--r-- 1,833 bytes parent folder | download
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
//! Used to test function ff::atomic::kef
#include "ff/EulerOperations.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, 8, 5}, false},
                         {{6, 8, 9, 7}, 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}});
}

//! Test whether vertexIndices are correct after the operation

TEST_CASE("KEF:VertexIDOrderLR", "")
{

    ff::Polyhedron* p = ff::atomic::kef(cube, 8, 9);
    CHECK(p->topology().faces[p->topology().faces.size() - 1].vertexIndices
          == std::vector<int>{9, 7, 6, 8, 5, 4});
    delete p;
}

//! Dito but with switching faces

TEST_CASE("KEF:VertexIDOrderRL", "")
{

    ff::Polyhedron* p = ff::atomic::kef(cube, 9, 8);
    CHECK(p->topology().faces[p->topology().faces.size() - 1].vertexIndices
          == std::vector<int>{8, 5, 4, 9, 7, 6});
    delete p;
}

//! Test weather function throws with invalid input

TEST_CASE("KEF:ThrowsInvalidEdge", "")
{
    // valid but not common edge
    CHECK_THROWS(ff::atomic::kef(cube, 1, 3));
    // invalid vertex ids
    CHECK_THROWS(ff::atomic::kef(cube, 20, 21));
    // invalid edge with valid vertex ids
    CHECK_THROWS(ff::atomic::kef(cube, 1, 8));
}