DSC
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
test.h
1 //
2 // Deformabel Simplicial Complex (DSC) method
3 // Copyright (C) 2013 Technical University of Denmark
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // See licence.txt for a copy of the GNU General Public License.
16 
17 #pragma once
18 
19 #include "util.h"
20 
21 
22 inline void test_distance_triangle_triangle()
23 {
24  std::cout << "Testing utility functions:";
25  double d = distance_triangle_triangle<double>(vec3(0.), vec3(0., 1., 0.), vec3(1., 0., 0.), vec3(1., 1., -1.), vec3(1.,1.,2.), vec3(4., 2., 4.));
26  assert(abs(d - sqrt(2.)/2) < EPSILON);
27  d = distance_triangle_triangle<double>(vec3(0.), vec3(0., 1., 0.), vec3(1., 0., 0.), vec3(1., 1., 0.), vec3(4.,1.,2.), vec3(4., 2., 4.));
28  assert(abs(d - sqrt(2.)/2) < EPSILON);
29  std::cout << " PASSED" << std::endl;
30 }
31 
32 inline void simplex_set_test()
33 {
34  std::cout << "Testing simplex set class: ";
35  SimplexSet<int> A = {1,3,9,4};
36  SimplexSet<int> B = {1,7,5,3,10};
37 
38  SimplexSet<int> U = {1,3,9,4,7,5,10};
39  assert((A+B) == U);
40 
41  SimplexSet<int> C = {9,4};
42  assert((A-B) == C);
43 
44  SimplexSet<int> I = {1,3};
45  assert((A&B) == I);
46 
47  A -= 3;
48  A += 9;
49  A += 11;
50  SimplexSet<int> E = {1,9,4,11};
51  assert(A == E);
52 
53  std::cout << "PASSED" << std::endl;
54 }
A 3D double vector.
Definition: Vec3d.h:26