Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
unittests_smoother.cc
1
2 #include <gtest/gtest.h>
3 #include <Unittests/unittests_common.hh>
4 #include <OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.hh>
5
6 namespace {
7
8 class OpenMeshSmoother_Poly : public OpenMeshBasePoly {
9
10 protected:
11
12 // This function is called before each test is run
13 virtual void SetUp() {
14
15 // Do some initial stuff with the member data here...
16 }
17
18 // This function is called after all tests are through
19 virtual void TearDown() {
20
21 // Do some final stuff with the member data here...
22 }
23
24 // Member already defined in OpenMeshBase
25 //Mesh mesh_;
26 };
27
28 class OpenMeshSmoother_Triangle : public OpenMeshBase {
29
30 protected:
31
32 // This function is called before each test is run
33 virtual void SetUp() {
34
35 // Do some initial stuff with the member data here...
36 }
37
38 // This function is called after all tests are through
39 virtual void TearDown() {
40
41 // Do some final stuff with the member data here...
42 }
43
44 // Member already defined in OpenMeshBase
45 //Mesh mesh_;
46 };
47
48 /*
49 * ====================================================================
50 * Define tests below
51 * ====================================================================
52 */
53
54 /*
55 */
56 TEST_F(OpenMeshSmoother_Triangle, Smoother_Poly_Laplace) {
57
58 mesh_.clear();
59
60
61 bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off");
62
63 ASSERT_TRUE(ok);
64
65 // Check setup
66 EXPECT_EQ(7526u, mesh_.n_vertices() ) << "Wrong number of vertices";
67 EXPECT_EQ(15048u, mesh_.n_faces() ) << "Wrong number of faces";
68
69
70 // Initialize subdivider
71 OpenMesh::Smoother::JacobiLaplaceSmootherT<Mesh> smoother(mesh_);
72
73 // Just call function to instanciate template
74 smoother.set_absolute_local_error(0.5f);
75
76 // Set an error
77 smoother.set_relative_local_error(0.1f);
78
79 // Run algorithm with 5 steps
80 smoother.smooth(5);
81
82
83 EXPECT_EQ(7526u, mesh_.n_vertices() ) << "Wrong number of vertices after smoothing?";
84 EXPECT_EQ(15048u, mesh_.n_faces() ) << "Wrong number of faces after smoothing?";
85
86 }
87
88 /*
89 * ====================================================================
90 * Define tests below
91 * ====================================================================
92 */
93
94 /*
95 */
96 TEST_F(OpenMeshSmoother_Poly, Smoother_Triangle_Laplace) {
97
98 mesh_.clear();
99
100
101 bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off");
102
103 ASSERT_TRUE(ok);
104
105 // Check setup
106 EXPECT_EQ(7526u, mesh_.n_vertices() ) << "Wrong number of vertices";
107 EXPECT_EQ(15048u, mesh_.n_faces() ) << "Wrong number of faces";
108
109
110 // Initialize subdivider
111 OpenMesh::Smoother::JacobiLaplaceSmootherT<PolyMesh> smoother(mesh_);;
112
113 // Just call function to instantiate template
114 smoother.set_absolute_local_error(0.5);
115
116 // Set an error
117 smoother.set_relative_local_error(0.1);
118
119 // Run algorithm with 5 steps
120 smoother.smooth(5);
121
122
123 EXPECT_EQ(7526u, mesh_.n_vertices() ) << "Wrong number of vertices after smoothing?";
124 EXPECT_EQ(15048u, mesh_.n_faces() ) << "Wrong number of faces after smoothing?";
125
126 }
127
128
129 }
OpenMesh::IO::read_mesh
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Definition: MeshIO.hh:104
OpenMeshBasePoly
Definition: unittests_common.hh:45
OpenMeshBase
Definition: unittests_common.hh:21
OpenMesh::Smoother::JacobiLaplaceSmootherT
Definition: JacobiLaplaceSmootherT.hh:80
JacobiLaplaceSmootherT.hh