1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
8 class OpenMeshTrimeshCirculatorHalfedgeLoop :
public OpenMeshBase {
13 virtual void SetUp() {
17 virtual void TearDown() {
36 TEST_F(OpenMeshTrimeshCirculatorHalfedgeLoop, HalfedgeLoopWithFace) {
51 std::vector<Mesh::VertexHandle> face_vhandles;
53 face_vhandles.push_back(vhandle[0]);
54 face_vhandles.push_back(vhandle[1]);
55 face_vhandles.push_back(vhandle[2]);
56 mesh_.add_face(face_vhandles);
58 face_vhandles.clear();
60 face_vhandles.push_back(vhandle[2]);
61 face_vhandles.push_back(vhandle[1]);
62 face_vhandles.push_back(vhandle[3]);
63 mesh_.add_face(face_vhandles);
65 face_vhandles.clear();
67 face_vhandles.push_back(vhandle[2]);
68 face_vhandles.push_back(vhandle[3]);
69 face_vhandles.push_back(vhandle[4]);
70 mesh_.add_face(face_vhandles);
72 face_vhandles.clear();
74 face_vhandles.push_back(vhandle[1]);
75 face_vhandles.push_back(vhandle[5]);
76 face_vhandles.push_back(vhandle[3]);
77 mesh_.add_face(face_vhandles);
97 Mesh::HalfedgeLoopIter hl_it = mesh_.hl_begin(mesh_.halfedge_handle(3));
98 Mesh::HalfedgeLoopIter hl_end = mesh_.hl_end(mesh_.halfedge_handle(3));
100 EXPECT_EQ(3, hl_it->idx() ) <<
"Index wrong in HalfedgeLoopIter at initialization";
101 EXPECT_TRUE(hl_it.is_valid()) <<
"Iterator invalid in HalfedgeLoopIter at initialization";
103 EXPECT_EQ(6, hl_it->idx() ) <<
"Index wrong in HalfedgeLoopIter at step 1";
104 EXPECT_TRUE(hl_it.is_valid()) <<
"Iterator invalid in HalfedgeLoopIter at step 1";
106 EXPECT_EQ(8, hl_it->idx() ) <<
"Index wrong in HalfedgeLoopIter at step 2";
107 EXPECT_TRUE(hl_it.is_valid()) <<
"Iterator invalid in HalfedgeLoopIter at step 2";
109 EXPECT_EQ(3, hl_it->idx() ) <<
"Index wrong in HalfedgeLoopIter at step 3";
110 EXPECT_FALSE( hl_it.is_valid() ) <<
"Iterator invalid in HalfedgeLoopIter at end";
111 EXPECT_TRUE( hl_it == hl_end ) <<
"End iterator for HalfedgeLoopIter not matching";
115 Mesh::HalfedgeLoopIter chl_it = mesh_.chl_begin(mesh_.halfedge_handle(3));
116 Mesh::HalfedgeLoopIter chl_end = mesh_.chl_end(mesh_.halfedge_handle(3));
118 EXPECT_EQ(3, chl_it->idx() ) <<
"Index wrong in ConstHalfedgeLoopIter at initialization";
119 EXPECT_TRUE(chl_it.is_valid()) <<
"Iterator invalid in ConstHalfedgeLoopIter at initialization";
121 EXPECT_EQ(6, chl_it->idx() ) <<
"Index wrong in ConstHalfedgeLoopIter at step 1";
122 EXPECT_TRUE(chl_it.is_valid()) <<
"Iterator invalid in ConstHalfedgeLoopIter at step 1";
124 EXPECT_EQ(8, chl_it->idx() ) <<
"Index wrong in ConstHalfedgeLoopIter at step 2";
125 EXPECT_TRUE(chl_it.is_valid()) <<
"Iterator invalid in ConstHalfedgeLoopIter at step 2";
127 EXPECT_EQ(3, chl_it->idx() ) <<
"Index wrong in ConstHalfedgeLoopIter at step 3";
128 EXPECT_FALSE( chl_it.is_valid() ) <<
"Iterator invalid in ConstHalfedgeLoopIter at end";
129 EXPECT_TRUE( chl_it == chl_end ) <<
"End iterator for ConstHalfedgeLoopIter not matching";
137 TEST_F(OpenMeshTrimeshCirculatorHalfedgeLoop, HalfedgeLoopWithoutFace) {
152 std::vector<Mesh::VertexHandle> face_vhandles;
154 face_vhandles.push_back(vhandle[0]);
155 face_vhandles.push_back(vhandle[1]);
156 face_vhandles.push_back(vhandle[2]);
157 mesh_.add_face(face_vhandles);
159 face_vhandles.clear();
162 face_vhandles.push_back(vhandle[2]);
163 face_vhandles.push_back(vhandle[3]);
164 face_vhandles.push_back(vhandle[4]);
165 mesh_.add_face(face_vhandles);
167 face_vhandles.clear();
169 face_vhandles.push_back(vhandle[1]);
170 face_vhandles.push_back(vhandle[5]);
171 face_vhandles.push_back(vhandle[3]);
172 mesh_.add_face(face_vhandles);
193 Mesh::HalfedgeLoopIter hl_it = mesh_.hl_begin(mesh_.halfedge_handle(3));
194 Mesh::HalfedgeLoopIter hl_end = mesh_.hl_end(mesh_.halfedge_handle(3));
196 EXPECT_EQ(3, hl_it->idx() ) <<
"Index wrong in HalfedgeLoopIter at initialization";
197 EXPECT_TRUE(hl_it.is_valid()) <<
"Iterator invalid in HalfedgeLoopIter at initialization";
199 EXPECT_EQ(17, hl_it->idx() ) <<
"Index wrong in HalfedgeLoopIter at step 1";
200 EXPECT_TRUE(hl_it.is_valid()) <<
"Iterator invalid in HalfedgeLoopIter at step 1";
202 EXPECT_EQ(7, hl_it->idx() ) <<
"Index wrong in HalfedgeLoopIter at step 2";
203 EXPECT_TRUE(hl_it.is_valid()) <<
"Iterator invalid in HalfedgeLoopIter at step 2";
205 EXPECT_EQ(3, hl_it->idx() ) <<
"Index wrong in HalfedgeLoopIter at step 3";
206 EXPECT_FALSE( hl_it.is_valid() ) <<
"Iterator invalid in HalfedgeLoopIter at end";
207 EXPECT_TRUE( hl_it == hl_end ) <<
"End iterator for HalfedgeLoopIter not matching";
211 Mesh::HalfedgeLoopIter chl_it = mesh_.chl_begin(mesh_.halfedge_handle(3));
212 Mesh::HalfedgeLoopIter chl_end = mesh_.chl_end(mesh_.halfedge_handle(3));
214 EXPECT_EQ(3, chl_it->idx() ) <<
"Index wrong in ConstHalfedgeLoopIter at initialization";
215 EXPECT_TRUE(chl_it.is_valid()) <<
"Iterator invalid in ConstHalfedgeLoopIter at initialization";
217 EXPECT_EQ(17, chl_it->idx() ) <<
"Index wrong in ConstHalfedgeLoopIter at step 1";
218 EXPECT_TRUE(chl_it.is_valid()) <<
"Iterator invalid in ConstHalfedgeLoopIter at step 1";
220 EXPECT_EQ(7, chl_it->idx() ) <<
"Index wrong in ConstHalfedgeLoopIter at step 2";
221 EXPECT_TRUE(chl_it.is_valid()) <<
"Iterator invalid in ConstHalfedgeLoopIter at step 2";
223 EXPECT_EQ(3, chl_it->idx() ) <<
"Index wrong in ConstHalfedgeLoopIter at step 3";
224 EXPECT_FALSE( chl_it.is_valid() ) <<
"Iterator invalid in ConstHalfedgeLoopIter at end";
225 EXPECT_TRUE( chl_it == chl_end ) <<
"End iterator for ConstHalfedgeLoopIter not matching";
232 TEST_F(OpenMeshTrimeshCirculatorHalfedgeLoop, CWAndCCWCheck) {
247 std::vector<Mesh::VertexHandle> face_vhandles;
249 face_vhandles.push_back(vhandle[0]);
250 face_vhandles.push_back(vhandle[1]);
251 face_vhandles.push_back(vhandle[2]);
252 mesh_.add_face(face_vhandles);
254 face_vhandles.clear();
256 face_vhandles.push_back(vhandle[2]);
257 face_vhandles.push_back(vhandle[1]);
258 face_vhandles.push_back(vhandle[3]);
259 mesh_.add_face(face_vhandles);
261 face_vhandles.clear();
263 face_vhandles.push_back(vhandle[2]);
264 face_vhandles.push_back(vhandle[3]);
265 face_vhandles.push_back(vhandle[4]);
266 mesh_.add_face(face_vhandles);
268 face_vhandles.clear();
270 face_vhandles.push_back(vhandle[1]);
271 face_vhandles.push_back(vhandle[5]);
272 face_vhandles.push_back(vhandle[3]);
273 mesh_.add_face(face_vhandles);
290 int indices[4] = {3, 8, 6, 3};
292 std::reverse_copy(indices,indices+4,rev_indices);
295 Mesh::HalfedgeLoopCCWIter hl_ccwit = mesh_.hl_ccwbegin(mesh_.halfedge_handle(3));
296 Mesh::HalfedgeLoopCCWIter hl_ccwend = mesh_.hl_ccwend(mesh_.halfedge_handle(3));
298 for (;hl_ccwit != hl_ccwend; ++hl_ccwit, ++i)
300 EXPECT_EQ(indices[i], hl_ccwit->idx()) <<
"Index wrong in HalfedgeLoopCCWIter";
303 EXPECT_FALSE(hl_ccwit.is_valid()) <<
"Iterator invalid in HalfedgeLoopCCWIter at end";
304 EXPECT_TRUE( hl_ccwit == hl_ccwend ) <<
"End iterator for HalfedgeLoopCCWIter not matching";
307 Mesh::ConstHalfedgeLoopCCWIter chl_ccwit = mesh_.chl_ccwbegin(mesh_.halfedge_handle(3));
308 Mesh::ConstHalfedgeLoopCCWIter chl_ccwend = mesh_.chl_ccwend(mesh_.halfedge_handle(3));
310 for (;chl_ccwit != chl_ccwend; ++chl_ccwit, ++i)
312 EXPECT_EQ(indices[i], chl_ccwit->idx()) <<
"Index wrong in ConstHalfedgeLoopCCWIter";
315 EXPECT_FALSE(chl_ccwit.is_valid()) <<
"Iterator invalid in ConstHalfedgeLoopCCWIter at end";
316 EXPECT_TRUE( chl_ccwit == chl_ccwend ) <<
"End iterator for ConstHalfedgeLoopCCWIter not matching";
319 Mesh::HalfedgeLoopCWIter hl_cwit = mesh_.hl_cwbegin(mesh_.halfedge_handle(3));
320 Mesh::HalfedgeLoopCWIter hl_cwend = mesh_.hl_cwend(mesh_.halfedge_handle(3));
322 for (;hl_cwit != hl_cwend; ++hl_cwit, ++i)
324 EXPECT_EQ(rev_indices[i], hl_cwit->idx()) <<
"Index wrong in HalfedgeLoopCWIter";
326 EXPECT_FALSE(hl_cwit.is_valid()) <<
"Iterator invalid in HalfedgeLoopCWIter at end";
327 EXPECT_TRUE( hl_cwit == hl_cwend ) <<
"End iterator for HalfedgeLoopCWIter not matching";
330 Mesh::ConstHalfedgeLoopCWIter chl_cwit = mesh_.chl_cwbegin(mesh_.halfedge_handle(3));
331 Mesh::ConstHalfedgeLoopCWIter chl_cwend = mesh_.chl_cwend(mesh_.halfedge_handle(3));
333 for (;chl_cwit != chl_cwend; ++chl_cwit, ++i)
335 EXPECT_EQ(rev_indices[i], chl_cwit->idx()) <<
"Index wrong in ConstHalfedgeLoopCWIter";
337 EXPECT_FALSE(chl_cwit.is_valid()) <<
"Iterator invalid in ConstHalfedgeLoopCWIter at end";
338 EXPECT_TRUE( chl_cwit == chl_cwend ) <<
"End iterator for ConstHalfedgeLoopCWIter not matching";
347 Mesh::HalfedgeLoopCWIter hl_cwIter = mesh_.hl_cwbegin(mesh_.halfedge_handle(3));
349 EXPECT_TRUE( hl_cwIter == Mesh::HalfedgeLoopCWIter(mesh_.hl_ccwbegin(mesh_.halfedge_handle(3))) ) <<
"ccw to cw conversion failed";
350 EXPECT_TRUE( Mesh::HalfedgeLoopCCWIter(hl_cwIter) == mesh_.hl_ccwbegin(mesh_.halfedge_handle(3)) ) <<
"cw to ccw conversion failed";
352 EXPECT_EQ( hl_cwIter->idx(), Mesh::HalfedgeLoopCCWIter(hl_cwIter)->idx()) <<
"iterators doesnt point on the same element";
355 hl_ccwend = mesh_.hl_ccwend(mesh_.halfedge_handle(3));
357 EXPECT_EQ(hl_cwIter->idx(),hl_ccwend->idx()) <<
"iteratoes are not equal after inc/dec";
359 hl_ccwend = Mesh::HalfedgeLoopCCWIter(hl_cwIter);
360 EXPECT_EQ(hl_cwIter->idx(),hl_ccwend->idx())<<
"iterators doesnt point on the same element";
362 hl_cwIter = Mesh::HalfedgeLoopCWIter(mesh_.hl_ccwend(mesh_.halfedge_handle(3)));
363 EXPECT_FALSE(hl_cwIter.is_valid()) <<
"end iterator is not invalid";
364 EXPECT_TRUE(Mesh::HalfedgeLoopCCWIter(mesh_.hl_cwend(mesh_.halfedge_handle(3))) == mesh_.hl_ccwend(mesh_.halfedge_handle(3))) <<
"end iterators are not equal";
Kernel::Point Point
Coordinate type.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.