OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
unittests_trimesh_others.hh
1 #ifndef INCLUDE_UNITTESTS_TRIMESH_OTHERS_HH
2 #define INCLUDE_UNITTESTS_TRIMESH_OTHERS_HH
3 
4 #include <gtest/gtest.h>
5 #include <Unittests/unittests_common.hh>
6 
7 #include <iostream>
8 
9 class OpenMeshOthers : public OpenMeshBase {
10 
11  protected:
12 
13  // This function is called before each test is run
14  virtual void SetUp() {
15  }
16 
17  // This function is called after all tests are through
18  virtual void TearDown() {
19 
20  // Do some final stuff with the member data here...
21  }
22 
23  // Member already defined in OpenMeshBase
24  //Mesh mesh_;
25 };
26 
27 /*
28  * ====================================================================
29  * Define tests below
30  * ====================================================================
31  */
32 
33 /*
34  * Checking for feature edges based on angle
35  */
36 TEST_F(OpenMeshOthers, IsEstimatedFeatureEdge) {
37 
38  mesh_.clear();
39 
40  // Add some vertices
41  Mesh::VertexHandle vhandle[4];
42 
43  vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 0, 0));
44  vhandle[1] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
45  vhandle[2] = mesh_.add_vertex(Mesh::Point(1, 1, 0));
46  vhandle[3] = mesh_.add_vertex(Mesh::Point(0, 0, 1));
47 
48  // Add four faces
49  std::vector<Mesh::VertexHandle> face_vhandles;
50 
51  face_vhandles.push_back(vhandle[0]);
52  face_vhandles.push_back(vhandle[1]);
53  face_vhandles.push_back(vhandle[2]);
54  mesh_.add_face(face_vhandles);
55 
56  face_vhandles.clear();
57 
58  face_vhandles.push_back(vhandle[0]);
59  face_vhandles.push_back(vhandle[2]);
60  face_vhandles.push_back(vhandle[3]);
61  mesh_.add_face(face_vhandles);
62 
63  face_vhandles.clear();
64 
65  face_vhandles.push_back(vhandle[2]);
66  face_vhandles.push_back(vhandle[1]);
67  face_vhandles.push_back(vhandle[3]);
68  mesh_.add_face(face_vhandles);
69 
70  face_vhandles.clear();
71 
72  face_vhandles.push_back(vhandle[3]);
73  face_vhandles.push_back(vhandle[1]);
74  face_vhandles.push_back(vhandle[0]);
75  mesh_.add_face(face_vhandles);
76 
77  // ===============================================
78  // Setup complete
79  // ===============================================
80 
81 
82  // Check one Request only vertex normals
83  // Face normals are required for vertex and halfedge normals, so
84  // that prevent access to non existing properties are in place
85 
86  mesh_.request_vertex_normals();
87  mesh_.request_halfedge_normals();
88  mesh_.request_face_normals();
89 
90  // Automatically compute all normals
91  // As only vertex normals are requested and no face normals, this will compute nothing.
92  mesh_.update_normals();
93 
94  Mesh::HalfedgeIter he_it = mesh_.halfedges_begin();
95 
96  EXPECT_TRUE(mesh_.is_estimated_feature_edge(he_it,0.0)) << "Wrong feature edge detection 0.0";
97 
98  EXPECT_TRUE(mesh_.is_estimated_feature_edge(he_it,0.125 * M_PI)) << "Wrong feature edge detection 0.125";
99 
100  EXPECT_TRUE(mesh_.is_estimated_feature_edge(he_it,0.25 * M_PI)) << "Wrong feature edge detection 0.25";
101 
102  EXPECT_TRUE(mesh_.is_estimated_feature_edge(he_it,0.375 * M_PI)) << "Wrong feature edge detection 0.375";
103 
104  EXPECT_TRUE(mesh_.is_estimated_feature_edge(he_it,0.5 * M_PI)) << "Wrong feature edge detection 0.5";
105 
106  EXPECT_FALSE(mesh_.is_estimated_feature_edge(he_it,0.625 * M_PI))<< "Wrong feature edge detection 0.625";
107 
108  EXPECT_FALSE(mesh_.is_estimated_feature_edge(he_it,0.75 * M_PI)) << "Wrong feature edge detection 0.75";
109 
110  EXPECT_FALSE(mesh_.is_estimated_feature_edge(he_it,0.875 * M_PI))<< "Wrong feature edge detection 0.875";
111 
112  EXPECT_FALSE(mesh_.is_estimated_feature_edge(he_it,1.0 * M_PI)) << "Wrong feature edge detection 1.0";
113 
114 }
115 
116 #endif // INCLUDE GUARD

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .