File: EulerMEV.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 (52 lines) | stat: -rw-r--r-- 1,654 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
//! Used to test the function ff::atomic::mev
#include "ff/Edge.h"
#include "ff/EulerOperations.h"
#include "ff/Face.h"
#include "ff/Polyhedron.h"
#include "ff/Topology.h"
#include "test/3rdparty/catch.hpp"

namespace {
ff::Polyhedron cube({{{{0, 1, 2, 3}, false},
                      {{7, 6, 5, 4}, false},
                      {{4, 5, 1, 0}, false},
                      {{5, 6, 2, 1}, false},
                      {{6, 7, 3, 2}, false},
                      {{7, 4, 0, 3}, 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},
                    });
}

//! Tests whether the result of a kill-edge-face operation changes topology correctly.

TEST_CASE("MEV:LeftFace", "")
{
    ff::Polyhedron* p = ff::atomic::mev(cube, 0, 1, {-1, 0, -1});
    CHECK(p->faces()[0].edges().size() == 5);
    CHECK(p->vertices()[p->vertices().size() - 1] == R3(-1, 0, -1));
    CHECK(p->topology().faces[0].vertexIndices == std::vector<int>{0, 8, 1, 2, 3});
}

//! Tests whether mev will throw when the vertex already exists

TEST_CASE("MEV:THROWS:VertexExists", "")
{
    CHECK_THROWS(ff::atomic::mev(cube, 0, 1, {-1, 1, -1}));
    CHECK_THROWS(ff::atomic::mev(cube, 0, 1, {-1, -1, -1}));
}

//! Tests whether mev will throw when the edge does not exist

TEST_CASE("MEV:THROWS:EdgeDoesNotExist", "")
{
    CHECK_THROWS(ff::atomic::mev(cube, 0, 10, {-1, 1, -1}));
}