2 #include <gtest/gtest.h> 3 #include <Unittests/unittests_common.hh> 8 class OpenMeshSplitEdgeCopyTriangleMesh :
public OpenMeshBase {
13 virtual void SetUp() {
19 virtual void TearDown() {
33 virtual void SetUp() {
39 virtual void TearDown() {
57 TEST_F(OpenMeshSplitEdgeCopyTriangleMesh, SplitEdgeCopyTriangleMesh) {
60 mesh_.request_edge_status();
71 std::vector<Mesh::VertexHandle> face_vhandles;
73 face_vhandles.push_back(vhandle[2]);
74 face_vhandles.push_back(vhandle[1]);
75 face_vhandles.push_back(vhandle[0]);
77 Mesh::FaceHandle fh = mesh_.add_face(face_vhandles);
78 Mesh::EdgeHandle eh = *mesh_.edges_begin();
89 mesh_.add_property(eprop_int);
90 mesh_.property(eprop_int, eh) = 999;
92 mesh_.status(eh).set_tagged(
true);
98 Mesh::EdgeHandle eh0 = mesh_.edge_handle( mesh_.next_halfedge_handle( mesh_.halfedge_handle(eh, 1) ) );
99 EXPECT_EQ(999, mesh_.property(eprop_int, eh0)) <<
"Different Property value";
100 EXPECT_TRUE(mesh_.status(eh0).tagged()) <<
"Different internal property value";
102 EXPECT_EQ(3u, mesh_.valence(fh)) <<
"Face of TriMesh has valence other than 3";
108 TEST_F(OpenMeshSplitEdgeCopyPolyMesh, SplitEdgeCopyPolymesh) {
111 mesh_.request_edge_status();
123 std::vector<Mesh::VertexHandle> face_vhandles;
125 face_vhandles.push_back(vhandle[0]);
126 face_vhandles.push_back(vhandle[1]);
127 face_vhandles.push_back(vhandle[2]);
128 face_vhandles.push_back(vhandle[3]);
130 mesh_.add_face(face_vhandles);
131 PolyMesh::EdgeHandle eh = *mesh_.edges_begin();
142 mesh_.add_property(eprop_int);
143 mesh_.property(eprop_int, eh) = 999;
145 mesh_.status(eh).set_tagged(
true);
149 mesh_.split_edge_copy(eh, vhandle[4]);
153 Mesh::EdgeHandle eh0 = mesh_.edge_handle( mesh_.next_halfedge_handle( mesh_.halfedge_handle(eh, 1) ) );
154 EXPECT_EQ(999, mesh_.property(eprop_int, eh0)) <<
"Different Property value";
155 EXPECT_TRUE(mesh_.status(eh0).tagged()) <<
"Different internal property value";
162 TEST_F(OpenMeshSplitEdgeCopyTriangleMesh, SplitEdgeCopyFacePropertiesTriangleMesh) {
165 mesh_.request_edge_status();
166 mesh_.request_face_status();
168 static_assert(std::is_same<decltype (mesh_),
Mesh>::value,
"Mesh is not a triangle mesh");
182 std::vector<Mesh::VertexHandle> face_vhandles;
183 face_vhandles.push_back(vhandle[2]);
184 face_vhandles.push_back(vhandle[1]);
185 face_vhandles.push_back(vhandle[0]);
187 Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
189 face_vhandles.clear();
190 face_vhandles.push_back(vhandle[2]);
191 face_vhandles.push_back(vhandle[0]);
192 face_vhandles.push_back(vhandle[3]);
194 Mesh::FaceHandle fh1 = mesh_.add_face(face_vhandles);
196 Mesh::EdgeHandle inner_edge = Mesh::EdgeHandle(2);
198 EXPECT_EQ(mesh_.n_faces(), 2u);
209 mesh_.add_property(fprop_int);
210 mesh_.property(fprop_int, fh0) = 13;
211 mesh_.property(fprop_int, fh1) = 17;
213 mesh_.status(fh0).set_tagged(
true);
218 EXPECT_EQ(mesh_.n_faces(), 4u);
220 for (
auto fh : mesh_.faces())
222 EXPECT_EQ(3u, mesh_.valence(fh));
226 Mesh::HalfedgeHandle heh21 = mesh_.find_halfedge(vhandle[2], vhandle[1]);
227 Mesh::HalfedgeHandle heh10 = mesh_.find_halfedge(vhandle[1], vhandle[0]);
228 Mesh::HalfedgeHandle heh03 = mesh_.find_halfedge(vhandle[0], vhandle[3]);
229 Mesh::HalfedgeHandle heh32 = mesh_.find_halfedge(vhandle[3], vhandle[2]);
231 EXPECT_EQ(13, mesh_.property(fprop_int, mesh_.face_handle(heh21))) <<
"Different Property value";
232 EXPECT_EQ(13, mesh_.property(fprop_int, mesh_.face_handle(heh10))) <<
"Different Property value";
233 EXPECT_EQ(17, mesh_.property(fprop_int, mesh_.face_handle(heh03))) <<
"Different Property value";
234 EXPECT_EQ(17, mesh_.property(fprop_int, mesh_.face_handle(heh32))) <<
"Different Property value";
235 EXPECT_TRUE(mesh_.status(mesh_.face_handle(heh21)).tagged()) <<
"Different internal property value";
236 EXPECT_TRUE(mesh_.status(mesh_.face_handle(heh10)).tagged()) <<
"Different internal property value";
237 EXPECT_FALSE(mesh_.status(mesh_.face_handle(heh03)).tagged()) <<
"Different internal property value";
238 EXPECT_FALSE(mesh_.status(mesh_.face_handle(heh32)).tagged()) <<
"Different internal property value";
241 Mesh::EdgeHandle boundary_edge = mesh_.edge_handle(heh10);
244 mesh_.
split_copy(boundary_edge, boundary_vertex);
246 Mesh::HalfedgeHandle heh1b = mesh_.find_halfedge(vhandle[1], boundary_vertex);
247 Mesh::HalfedgeHandle hehb0 = mesh_.find_halfedge(boundary_vertex, vhandle[0]);
249 EXPECT_EQ(13, mesh_.property(fprop_int, mesh_.face_handle(heh1b))) <<
"Different Property value";
250 EXPECT_EQ(13, mesh_.property(fprop_int, mesh_.face_handle(hehb0))) <<
"Different Property value";
251 EXPECT_TRUE(mesh_.status(mesh_.face_handle(heh1b)).tagged()) <<
"Different internal property value";
252 EXPECT_TRUE(mesh_.status(mesh_.face_handle(hehb0)).tagged()) <<
"Different internal property value";
SmartVertexHandle split_copy(EdgeHandle _eh, const Point &_p)
Edge split (= 2-to-4 split)
Kernel::Point Point
Coordinate type.
SmartVertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.