1 #include <gtest/gtest.h> 2 #include <Unittests/unittests_common.hh> 4 #include <OpenVolumeMesh/Attribs/StatusAttrib.hh> 5 #include <OpenVolumeMesh/Attribs/NormalAttrib.hh> 6 #include <OpenVolumeMesh/Attribs/ColorAttrib.hh> 9 using namespace Geometry;
32 EXPECT_EQ(8u, mesh_.n_vertices()) <<
"The number of vertices is not correct!";
38 std::vector<VertexHandle> fvertices;
40 fvertices.push_back(v3);
41 fvertices.push_back(v2);
42 fvertices.push_back(v1);
43 fvertices.push_back(v0);
49 fvertices.push_back(v4);
50 fvertices.push_back(v5);
51 fvertices.push_back(v6);
52 fvertices.push_back(v7);
58 fvertices.push_back(v0);
59 fvertices.push_back(v4);
60 fvertices.push_back(v7);
61 fvertices.push_back(v3);
67 fvertices.push_back(v1);
68 fvertices.push_back(v2);
69 fvertices.push_back(v6);
70 fvertices.push_back(v5);
76 fvertices.push_back(v7);
77 fvertices.push_back(v6);
78 fvertices.push_back(v2);
79 fvertices.push_back(v3);
85 fvertices.push_back(v0);
86 fvertices.push_back(v1);
87 fvertices.push_back(v5);
88 fvertices.push_back(v4);
92 EXPECT_EQ(12u, mesh_.n_edges()) <<
"The number of edges is not correct!";
93 EXPECT_EQ(6u, mesh_.n_faces()) <<
"The number of faces is not correct!";
99 std::vector<HalfFaceHandle> chfaces;
101 chfaces.push_back(mesh_.halfface_handle(fh0, 0));
102 chfaces.push_back(mesh_.halfface_handle(fh1, 0));
103 chfaces.push_back(mesh_.halfface_handle(fh2, 0));
104 chfaces.push_back(mesh_.halfface_handle(fh3, 0));
105 chfaces.push_back(mesh_.halfface_handle(fh4, 0));
106 chfaces.push_back(mesh_.halfface_handle(fh5, 0));
108 mesh_.add_cell(chfaces);
110 EXPECT_EQ(1u, mesh_.n_cells()) <<
"The number of cells is not correct!";
117 Vec3d p1(0.0, 0.0, 0.0);
118 Vec3d p2(1.0, 0.0, 0.0);
119 Vec3d p3(1.0, 1.0, 0.0);
120 Vec3d p4(0.0, 1.0, 0.0);
122 Vec3d p5(0.0, 0.0, 1.0);
123 Vec3d p6(1.0, 0.0, 1.0);
124 Vec3d p7(1.0, 1.0, 1.0);
125 Vec3d p8(0.0, 1.0, 1.0);
176 EXPECT_EQ(v1, mesh_.halfedge(h1).from_vertex());
177 EXPECT_EQ(v2, mesh_.halfedge(h1).to_vertex());
178 EXPECT_EQ(v2, mesh_.halfedge(h2).from_vertex());
179 EXPECT_EQ(v3, mesh_.halfedge(h2).to_vertex());
180 EXPECT_EQ(v3, mesh_.halfedge(h3).from_vertex());
181 EXPECT_EQ(v4, mesh_.halfedge(h3).to_vertex());
182 EXPECT_EQ(v4, mesh_.halfedge(h4).from_vertex());
183 EXPECT_EQ(v1, mesh_.halfedge(h4).to_vertex());
185 EXPECT_EQ(v5, mesh_.halfedge(h5).from_vertex());
186 EXPECT_EQ(v6, mesh_.halfedge(h5).to_vertex());
187 EXPECT_EQ(v6, mesh_.halfedge(h6).from_vertex());
188 EXPECT_EQ(v7, mesh_.halfedge(h6).to_vertex());
189 EXPECT_EQ(v7, mesh_.halfedge(h7).from_vertex());
190 EXPECT_EQ(v8, mesh_.halfedge(h7).to_vertex());
191 EXPECT_EQ(v8, mesh_.halfedge(h8).from_vertex());
192 EXPECT_EQ(v5, mesh_.halfedge(h8).to_vertex());
195 EXPECT_EQ(v2, mesh_.opposite_halfedge(h1).from_vertex());
196 EXPECT_EQ(v1, mesh_.opposite_halfedge(h1).to_vertex());
197 EXPECT_EQ(v3, mesh_.opposite_halfedge(h2).from_vertex());
198 EXPECT_EQ(v2, mesh_.opposite_halfedge(h2).to_vertex());
199 EXPECT_EQ(v4, mesh_.opposite_halfedge(h3).from_vertex());
200 EXPECT_EQ(v3, mesh_.opposite_halfedge(h3).to_vertex());
201 EXPECT_EQ(v1, mesh_.opposite_halfedge(h4).from_vertex());
202 EXPECT_EQ(v4, mesh_.opposite_halfedge(h4).to_vertex());
204 EXPECT_EQ(v6, mesh_.opposite_halfedge(h5).from_vertex());
205 EXPECT_EQ(v5, mesh_.opposite_halfedge(h5).to_vertex());
206 EXPECT_EQ(v7, mesh_.opposite_halfedge(h6).from_vertex());
207 EXPECT_EQ(v6, mesh_.opposite_halfedge(h6).to_vertex());
208 EXPECT_EQ(v8, mesh_.opposite_halfedge(h7).from_vertex());
209 EXPECT_EQ(v7, mesh_.opposite_halfedge(h7).to_vertex());
210 EXPECT_EQ(v5, mesh_.opposite_halfedge(h8).from_vertex());
211 EXPECT_EQ(v8, mesh_.opposite_halfedge(h8).to_vertex());
214 std::vector<VertexHandle> vertices;
215 vertices.push_back(v2); vertices.push_back(v6);
216 vertices.push_back(v7); vertices.push_back(v3);
222 std::vector<HalfEdgeHandle> halfedges = mesh_.face(f1).halfedges();
224 std::vector<HalfEdgeHandle>::iterator it = halfedges.begin();
226 EXPECT_EQ(8, mesh_.edge_handle(*it)); ++it;
227 EXPECT_EQ(5, mesh_.edge_handle(*it)); ++it;
228 EXPECT_EQ(9, mesh_.edge_handle(*it)); ++it;
229 EXPECT_EQ(1, mesh_.edge_handle(*it));
233 halfedges.push_back(mesh_.halfedge_handle(e1, 0)); halfedges.push_back(mesh_.halfedge_handle(e2, 0));
234 halfedges.push_back(mesh_.halfedge_handle(e7, 0)); halfedges.push_back(mesh_.halfedge_handle(e4, 0));
236 FaceHandle fI = mesh_.add_face(halfedges,
true);
238 EXPECT_EQ(PolyhedralMesh::InvalidFaceHandle, fI);
242 halfedges.push_back(mesh_.halfedge_handle(e1, 0)); halfedges.push_back(mesh_.halfedge_handle(e2, 0));
243 halfedges.push_back(mesh_.halfedge_handle(e3, 0)); halfedges.push_back(mesh_.halfedge_handle(e4, 0));
250 halfedges = mesh_.face(f2).halfedges();
252 for(it = halfedges.begin(); it != halfedges.end(); ++it) {
253 EXPECT_EQ(handle, mesh_.edge_handle(*it)); handle++;
265 std::vector<VertexHandle> vertices;
268 vertices.push_back(v0); vertices.push_back(v1);vertices.push_back(v3);
272 vertices.push_back(v1); vertices.push_back(v2);vertices.push_back(v3);
276 vertices.push_back(v0); vertices.push_back(v1);vertices.push_back(v2);
280 vertices.push_back(v0); vertices.push_back(v3);vertices.push_back(v2);
283 std::vector<HalfFaceHandle> halffaces;
286 halffaces.push_back(mesh_.halfface_handle(f0, 1));
287 halffaces.push_back(mesh_.halfface_handle(f1, 1));
288 halffaces.push_back(mesh_.halfface_handle(f2, 0));
289 halffaces.push_back(mesh_.halfface_handle(f3, 1));
290 EXPECT_NE(PolyhedralMesh::InvalidCellHandle, mesh_.add_cell(halffaces));
301 std::vector<VertexHandle> vertices;
304 vertices.push_back(v0); vertices.push_back(v1);vertices.push_back(v3);
308 vertices.push_back(v1); vertices.push_back(v2);vertices.push_back(v3);
312 vertices.push_back(v0); vertices.push_back(v1);vertices.push_back(v2);
316 vertices.push_back(v0); vertices.push_back(v3);vertices.push_back(v2);
319 std::vector<HalfFaceHandle> halffaces;
322 halffaces.push_back(mesh_.halfface_handle(f0, 1));
323 halffaces.push_back(mesh_.halfface_handle(f1, 1));
324 halffaces.push_back(mesh_.halfface_handle(f2, 0));
325 halffaces.push_back(mesh_.halfface_handle(f3, 0));
326 EXPECT_EQ(PolyhedralMesh::InvalidCellHandle, mesh_.add_cell(halffaces,
true));
340 std::vector<VertexHandle> fvertices;
342 fvertices.push_back(v3);
343 fvertices.push_back(v2);
344 fvertices.push_back(v1);
345 fvertices.push_back(v0);
351 fvertices.push_back(v4);
352 fvertices.push_back(v5);
353 fvertices.push_back(v6);
354 fvertices.push_back(v7);
360 fvertices.push_back(v0);
361 fvertices.push_back(v4);
362 fvertices.push_back(v7);
363 fvertices.push_back(v3);
369 fvertices.push_back(v1);
370 fvertices.push_back(v2);
371 fvertices.push_back(v6);
372 fvertices.push_back(v5);
378 fvertices.push_back(v7);
379 fvertices.push_back(v6);
380 fvertices.push_back(v2);
381 fvertices.push_back(v3);
387 fvertices.push_back(v0);
388 fvertices.push_back(v1);
389 fvertices.push_back(v5);
390 fvertices.push_back(v4);
394 std::vector<HalfFaceHandle> chfaces;
396 chfaces.push_back(mesh_.halfface_handle(fh0, 0));
397 chfaces.push_back(mesh_.halfface_handle(fh1, 0));
398 chfaces.push_back(mesh_.halfface_handle(fh2, 0));
399 chfaces.push_back(mesh_.halfface_handle(fh3, 0));
400 chfaces.push_back(mesh_.halfface_handle(fh4, 0));
401 chfaces.push_back(mesh_.halfface_handle(fh5, 0));
403 EXPECT_NE(HexahedralMesh::InvalidCellHandle, mesh_.add_cell(chfaces,
true));
417 std::vector<VertexHandle> fvertices;
419 fvertices.push_back(v3);
420 fvertices.push_back(v2);
421 fvertices.push_back(v1);
422 fvertices.push_back(v0);
428 fvertices.push_back(v4);
429 fvertices.push_back(v5);
430 fvertices.push_back(v6);
431 fvertices.push_back(v7);
437 fvertices.push_back(v0);
438 fvertices.push_back(v4);
439 fvertices.push_back(v7);
440 fvertices.push_back(v3);
446 fvertices.push_back(v1);
447 fvertices.push_back(v2);
448 fvertices.push_back(v6);
449 fvertices.push_back(v5);
455 fvertices.push_back(v7);
456 fvertices.push_back(v6);
457 fvertices.push_back(v2);
458 fvertices.push_back(v3);
464 fvertices.push_back(v0);
465 fvertices.push_back(v1);
466 fvertices.push_back(v5);
467 fvertices.push_back(v4);
471 std::vector<HalfFaceHandle> chfaces;
473 chfaces.push_back(mesh_.halfface_handle(fh0, 0));
474 chfaces.push_back(mesh_.halfface_handle(fh1, 1));
475 chfaces.push_back(mesh_.halfface_handle(fh2, 0));
476 chfaces.push_back(mesh_.halfface_handle(fh3, 0));
477 chfaces.push_back(mesh_.halfface_handle(fh4, 0));
478 chfaces.push_back(mesh_.halfface_handle(fh5, 0));
480 EXPECT_EQ(HexahedralMesh::InvalidCellHandle, mesh_.add_cell(chfaces,
true));
485 generatePolyhedralMesh(mesh_);
487 EXPECT_EQ(0, mesh_.genus());
492 generatePolyhedralMesh(mesh_);
495 std::vector<HalfFaceHandle> hfaces;
496 hfaces.push_back(1); hfaces.push_back(5);
497 hfaces.push_back(7); hfaces.push_back(9);
498 hfaces.push_back(10); hfaces.push_back(21);
499 CellHandle i_cell = mesh_.add_cell(hfaces,
true);
501 EXPECT_EQ(PolyhedralMesh::InvalidCellHandle, i_cell);
503 EXPECT_EQ(
CellHandle(0), mesh_.incident_cell(1));
504 EXPECT_EQ(
CellHandle(0), mesh_.incident_cell(2));
505 EXPECT_EQ(
CellHandle(0), mesh_.incident_cell(5));
506 EXPECT_EQ(
CellHandle(0), mesh_.incident_cell(7));
507 EXPECT_EQ(
CellHandle(0), mesh_.incident_cell(9));
508 EXPECT_EQ(
CellHandle(0), mesh_.incident_cell(10));
510 EXPECT_EQ(
CellHandle(1), mesh_.incident_cell(3));
511 EXPECT_EQ(
CellHandle(1), mesh_.incident_cell(12));
512 EXPECT_EQ(
CellHandle(1), mesh_.incident_cell(15));
513 EXPECT_EQ(
CellHandle(1), mesh_.incident_cell(17));
514 EXPECT_EQ(
CellHandle(1), mesh_.incident_cell(19));
515 EXPECT_EQ(
CellHandle(1), mesh_.incident_cell(20));
528 EXPECT_EQ(PolyhedralMesh::InvalidHalfFaceHandle, ad_hf3);
536 EXPECT_EQ(PolyhedralMesh::InvalidHalfFaceHandle, ad_hf5);
538 EXPECT_EQ(12u, mesh_.n_vertices());
539 EXPECT_EQ(20u, mesh_.n_edges());
540 EXPECT_EQ(2u, mesh_.n_cells());
541 EXPECT_EQ(11u, mesh_.n_faces());
546 generatePolyhedralMesh(mesh_);
550 Vec3d n_x(1.0, 0.0, 0.0);
551 Vec3d n_y(0.0, 1.0, 0.0);
552 Vec3d n_z(0.0, 0.0, 1.0);
554 normals.update_face_normals();
558 EXPECT_DOUBLE_EQ(n_z[0], n[0]);
559 EXPECT_DOUBLE_EQ(n_z[1], n[1]);
560 EXPECT_DOUBLE_EQ(n_z[2], n[2]);
563 EXPECT_DOUBLE_EQ(-n_z[0], n[0]);
564 EXPECT_DOUBLE_EQ(-n_z[1], n[1]);
565 EXPECT_DOUBLE_EQ(-n_z[2], n[2]);
569 EXPECT_DOUBLE_EQ(-n_x[0], n[0]);
570 EXPECT_DOUBLE_EQ(-n_x[1], n[1]);
571 EXPECT_DOUBLE_EQ(-n_x[2], n[2]);
574 EXPECT_DOUBLE_EQ(-n_x[0], n[0]);
575 EXPECT_DOUBLE_EQ(-n_x[1], n[1]);
576 EXPECT_DOUBLE_EQ(-n_x[2], n[2]);
579 EXPECT_DOUBLE_EQ(n_x[0], n[0]);
580 EXPECT_DOUBLE_EQ(n_x[1], n[1]);
581 EXPECT_DOUBLE_EQ(n_x[2], n[2]);
585 EXPECT_DOUBLE_EQ(-n_y[0], n[0]);
586 EXPECT_DOUBLE_EQ(-n_y[1], n[1]);
587 EXPECT_DOUBLE_EQ(-n_y[2], n[2]);
590 EXPECT_DOUBLE_EQ(n_y[0], n[0]);
591 EXPECT_DOUBLE_EQ(n_y[1], n[1]);
592 EXPECT_DOUBLE_EQ(n_y[2], n[2]);
596 EXPECT_DOUBLE_EQ(-n_y[0], n[0]);
597 EXPECT_DOUBLE_EQ(-n_y[1], n[1]);
598 EXPECT_DOUBLE_EQ(-n_y[2], n[2]);
603 generatePolyhedralMesh(mesh_);
636 generatePolyhedralMesh(mesh_);
643 colors[
VertexHandle(7)] = Vec4f(1.0f, 1.0f, 0.0f, 1.0f);
644 colors[
EdgeHandle(6)] = Vec4f(1.0f, 1.0f, 0.0f, 1.0f);
646 colors[
FaceHandle(4)] = Vec4f(1.0f, 1.0f, 0.0f, 1.0f);
648 colors[
CellHandle(1)] = Vec4f(1.0f, 1.0f, 0.0f, 1.0f);
654 EXPECT_FLOAT_EQ(1.0f, colors[
EdgeHandle(6)][0]);
655 EXPECT_FLOAT_EQ(1.0f, colors[
EdgeHandle(6)][1]);
656 EXPECT_FLOAT_EQ(0.0f, colors[
EdgeHandle(6)][2]);
657 EXPECT_FLOAT_EQ(1.0f, colors[
EdgeHandle(6)][3]);
662 EXPECT_FLOAT_EQ(1.0f, colors[
FaceHandle(4)][0]);
663 EXPECT_FLOAT_EQ(1.0f, colors[
FaceHandle(4)][1]);
664 EXPECT_FLOAT_EQ(0.0f, colors[
FaceHandle(4)][2]);
665 EXPECT_FLOAT_EQ(1.0f, colors[
FaceHandle(4)][3]);
670 EXPECT_FLOAT_EQ(1.0f, colors[
CellHandle(1)][0]);
671 EXPECT_FLOAT_EQ(1.0f, colors[
CellHandle(1)][1]);
672 EXPECT_FLOAT_EQ(0.0f, colors[
CellHandle(1)][2]);
673 EXPECT_FLOAT_EQ(1.0f, colors[
CellHandle(1)][3]);
678 generatePolyhedralMesh(mesh_);
682 EXPECT_TRUE(mesh_.vertex_property_exists<
Vec3d>(
"VProp"));
684 for(
VertexIter v_it = mesh_.v_iter(); v_it.valid(); ++v_it) {
685 vp[v_it->idx()] =
Vec3d(1.0, 0.0, 0.0);
688 for(
VertexIter v_it = mesh_.v_iter(); v_it.valid(); ++v_it) {
691 EXPECT_DOUBLE_EQ(1.0, t[0]);
692 EXPECT_DOUBLE_EQ(0.0, t[1]);
693 EXPECT_DOUBLE_EQ(0.0, t[2]);
697 vp[vh.idx()] =
Vec3d(0.0);
698 Vec3d p = vp[vh.idx()];
699 EXPECT_DOUBLE_EQ(0.0, p[0]);
700 EXPECT_DOUBLE_EQ(0.0, p[1]);
701 EXPECT_DOUBLE_EQ(0.0, p[2]);
705 EXPECT_TRUE(mesh_.edge_property_exists<
unsigned int>(
"EProp"));
708 for(
EdgeIter e_it = mesh_.e_iter(); e_it.valid(); ++e_it) {
709 ep[e_it->idx()] = i++;
713 for(
EdgeIter e_it = mesh_.e_iter(); e_it.valid(); ++e_it) {
714 EXPECT_EQ(i++, ep[e_it->idx()]);
719 EXPECT_TRUE(mesh_.halfface_property_exists<
bool>(
"HFProp"));
722 for(
HalfFaceIter hf_it = mesh_.hf_iter(); hf_it.valid(); ++hf_it) {
723 hfp[hf_it->idx()] = b;
728 for(
HalfFaceIter hf_it = mesh_.hf_iter(); hf_it.valid(); ++hf_it) {
729 EXPECT_EQ(b, hfp[hf_it->idx()]);
736 EXPECT_TRUE(mesh_.cell_property_exists<std::string>(
"CProp"));
738 for(
CellIter c_it = mesh_.c_iter(); c_it.valid(); ++c_it) {
739 cp[c_it->idx()] = std::string(
"MyTestString");
742 for(
CellIter c_it = mesh_.c_iter(); c_it.valid(); ++c_it) {
743 EXPECT_EQ(std::string(
"MyTestString"), cp[c_it->idx()]);
746 EXPECT_FALSE(mesh_.halfedge_property_exists<
unsigned char>(
"HEProp"));
747 EXPECT_FALSE(mesh_.vertex_property_exists<
size_t>(
""));
752 generatePolyhedralMesh(mesh_);
757 std::for_each(mesh_.vertices_begin(), mesh_.vertices_end(), p);
759 std::for_each(mesh_.edges_begin(), mesh_.edges_end(), p);
761 std::for_each(mesh_.halfedges_begin(), mesh_.halfedges_end(), p);
763 std::for_each(mesh_.faces_begin(), mesh_.faces_end(), p);
765 std::for_each(mesh_.halffaces_begin(), mesh_.halffaces_end(), p);
767 std::for_each(mesh_.cells_begin(), mesh_.cells_end(), p);
772 generatePolyhedralMesh(mesh_);
774 std::vector<HalfFaceHandle> hfs = mesh_.cell(
CellHandle(0)).halffaces();
778 for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin(),
779 hf_end = hfs.end(); hf_it != hf_end; ++hf_it) {
780 EXPECT_EQ(PolyhedralMesh::InvalidCellHandle, mesh_.incident_cell(*hf_it));
786 generatePolyhedralMesh(mesh_);
788 std::vector<HalfEdgeHandle> hes = mesh_.face(
FaceHandle(0)).halfedges();
790 std::vector<HalfFaceHandle> ihfs[4];
792 for(
size_t i = 0; i < 4; ++i) {
797 if(mesh_.face_handle(hfh) ==
FaceHandle(0))
continue;
799 hfh.idx((hfh.idx() > mesh_.halfface_handle(
FaceHandle(0), 1) ? hfh.idx() - 2 : hfh.idx()));
801 ihfs[i].push_back(hfh);
807 std::set<HalfFaceHandle> nihfs[4];
808 for(
size_t i = 0; i < 4; ++i) {
810 nihfs[i].insert(*hehf_it);
814 EXPECT_EQ(ihfs[0].size(), nihfs[0].size());
815 EXPECT_EQ(ihfs[1].size(), nihfs[1].size());
816 EXPECT_EQ(ihfs[2].size(), nihfs[2].size());
817 EXPECT_EQ(ihfs[3].size(), nihfs[3].size());
819 for(
size_t i = 0; i < 4; ++i) {
820 for(std::vector<HalfFaceHandle>::const_iterator hf_it = ihfs[i].begin(),
821 hf_end = ihfs[i].end(); hf_it != hf_end; ++hf_it) {
822 EXPECT_GT(nihfs[i].count(*hf_it), 0u);
829 generatePolyhedralMesh(mesh_);
834 std::vector<HalfEdgeHandle> hes0;
836 if(mesh_.edge_handle(*voh_it) ==
EdgeHandle(0))
continue;
837 hes0.push_back(
HalfEdgeHandle(voh_it->idx() > mesh_.halfedge_handle(
EdgeHandle(0), 1) ? voh_it->idx() - 2 : voh_it->idx()));
840 std::vector<HalfEdgeHandle> hes1;
842 if(mesh_.edge_handle(*voh_it) ==
EdgeHandle(0))
continue;
843 hes1.push_back(
HalfEdgeHandle(voh_it->idx() > mesh_.halfedge_handle(
EdgeHandle(0), 1) ? voh_it->idx() - 2 : voh_it->idx()));
848 std::set<HalfEdgeHandle> nhes0;
850 nhes0.insert(*voh_it);
853 std::set<HalfEdgeHandle> nhes1;
855 nhes1.insert(*voh_it);
858 EXPECT_EQ(hes0.size(), nhes0.size());
859 EXPECT_EQ(hes1.size(), nhes1.size());
861 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes0.begin(),
862 he_end = hes0.end(); he_it != he_end; ++he_it) {
863 EXPECT_GT(nhes0.count(*he_it), 0u);
866 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes1.begin(),
867 he_end = hes1.end(); he_it != he_end; ++he_it) {
868 EXPECT_GT(nhes1.count(*he_it), 0u);
874 generatePolyhedralMesh(mesh_);
876 mesh_.enable_bottom_up_incidences(
false);
878 std::vector<HalfFaceHandle> hfs = mesh_.cell(
CellHandle(0)).halffaces();
882 for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin(),
883 hf_end = hfs.end(); hf_it != hf_end; ++hf_it) {
884 EXPECT_EQ(PolyhedralMesh::InvalidCellHandle, mesh_.incident_cell(*hf_it));
890 generatePolyhedralMesh(mesh_);
892 mesh_.enable_bottom_up_incidences(
false);
894 std::vector<HalfEdgeHandle> hes = mesh_.face(
FaceHandle(0)).halfedges();
896 std::vector<HalfFaceHandle> ihfs[4];
898 for(
size_t i = 0; i < 4; ++i) {
899 for(
HalfFaceIter hf_it = mesh_.halffaces_begin(), hf_end = mesh_.halffaces_end(); hf_it != hf_end; ++hf_it) {
901 std::vector<HalfEdgeHandle> t_hes = mesh_.halfface(*hf_it).halfedges();
903 for(std::vector<HalfEdgeHandle>::const_iterator the_it = t_hes.begin(),
904 the_end = t_hes.end(); the_it != the_end; ++the_it) {
905 if(std::find(hes.begin(), hes.end(), *the_it) != hes.end()) {
914 if(mesh_.face_handle(hfh) ==
FaceHandle(0))
continue;
916 hfh.idx((hfh.idx() > mesh_.halfface_handle(
FaceHandle(0), 1) ? hfh.idx() - 2 : hfh.idx()));
918 ihfs[i].push_back(hfh);
924 std::set<HalfFaceHandle> nihfs[4];
925 for(
size_t i = 0; i < 4; ++i) {
926 for(
HalfFaceIter hf_it = mesh_.halffaces_begin(), hf_end = mesh_.halffaces_end(); hf_it != hf_end; ++hf_it) {
928 std::vector<HalfEdgeHandle> t_hes = mesh_.halfface(*hf_it).halfedges();
930 for(std::vector<HalfEdgeHandle>::const_iterator the_it = t_hes.begin(),
931 the_end = t_hes.end(); the_it != the_end; ++the_it) {
932 if(std::find(hes.begin(), hes.end(), *the_it) != hes.end()) {
939 nihfs[i].insert(*hf_it);
943 EXPECT_EQ(ihfs[0].size(), nihfs[0].size());
944 EXPECT_EQ(ihfs[1].size(), nihfs[1].size());
945 EXPECT_EQ(ihfs[2].size(), nihfs[2].size());
946 EXPECT_EQ(ihfs[3].size(), nihfs[3].size());
948 for(
size_t i = 0; i < 4; ++i) {
949 for(std::vector<HalfFaceHandle>::const_iterator hf_it = ihfs[i].begin(),
950 hf_end = ihfs[i].end(); hf_it != hf_end; ++hf_it) {
951 EXPECT_GT(nihfs[i].count(*hf_it), 0u);
958 generatePolyhedralMesh(mesh_);
960 mesh_.enable_bottom_up_incidences(
false);
965 std::vector<HalfEdgeHandle> hes0;
966 for(
HalfEdgeIter he_it = mesh_.halfedges_begin(), he_end = mesh_.halfedges_end(); he_it != he_end; ++he_it) {
968 if(mesh_.halfedge(*he_it).from_vertex() == vh0) {
970 if(mesh_.edge_handle(*he_it) ==
EdgeHandle(0))
continue;
971 hes0.push_back(
HalfEdgeHandle(he_it->idx() > mesh_.halfedge_handle(
EdgeHandle(0), 1) ? he_it->idx() - 2 : he_it->idx()));
975 std::vector<HalfEdgeHandle> hes1;
976 for(
HalfEdgeIter he_it = mesh_.halfedges_begin(), he_end = mesh_.halfedges_end(); he_it != he_end; ++he_it) {
978 if(mesh_.halfedge(*he_it).from_vertex() == vh1) {
980 if(mesh_.edge_handle(*he_it) ==
EdgeHandle(0))
continue;
981 hes1.push_back(
HalfEdgeHandle(he_it->idx() > mesh_.halfedge_handle(
EdgeHandle(0), 1) ? he_it->idx() - 2 : he_it->idx()));
987 std::set<HalfEdgeHandle> nhes0;
988 for(
HalfEdgeIter he_it = mesh_.halfedges_begin(), he_end = mesh_.halfedges_end(); he_it != he_end; ++he_it) {
989 if(mesh_.halfedge(*he_it).from_vertex() == vh0) {
990 nhes0.insert(*he_it);
994 std::set<HalfEdgeHandle> nhes1;
995 for(
HalfEdgeIter he_it = mesh_.halfedges_begin(), he_end = mesh_.halfedges_end(); he_it != he_end; ++he_it) {
996 if(mesh_.halfedge(*he_it).from_vertex() == vh1) {
997 nhes1.insert(*he_it);
1001 EXPECT_EQ(hes0.size(), nhes0.size());
1002 EXPECT_EQ(hes1.size(), nhes1.size());
1004 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes0.begin(),
1005 he_end = hes0.end(); he_it != he_end; ++he_it) {
1006 EXPECT_GT(nhes0.count(*he_it), 0u);
1009 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes1.begin(),
1010 he_end = hes1.end(); he_it != he_end; ++he_it) {
1011 EXPECT_GT(nhes1.count(*he_it), 0u);
1017 generatePolyhedralMesh(mesh_);
1020 he_it != mesh_.halfedges_end(); ++he_it) {
1022 const VertexHandle& fromVertex = mesh_.halfedge(*he_it).from_vertex();
1023 const VertexHandle& toVertex = mesh_.halfedge(*he_it).to_vertex();
1025 EXPECT_LE(fromVertex.idx(), 11);
1026 EXPECT_LE(toVertex.idx(), 11);
1032 he_it != mesh_.halfedges_end(); ++he_it) {
1034 const VertexHandle& fromVertex = mesh_.halfedge(*he_it).from_vertex();
1035 const VertexHandle& toVertex = mesh_.halfedge(*he_it).to_vertex();
1037 EXPECT_LE(fromVertex.idx(), 10);
1038 EXPECT_LE(toVertex.idx(), 10);
1044 generatePolyhedralMesh(mesh_);
1047 f_it != mesh_.halffaces_end(); ++f_it) {
1049 std::vector<HalfEdgeHandle> hes = mesh_.halfface(*f_it).halfedges();
1050 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes.begin();
1051 he_it != hes.end(); ++he_it) {
1052 EXPECT_LE(he_it->idx(), 39);
1059 f_it != mesh_.halffaces_end(); ++f_it) {
1061 std::vector<HalfEdgeHandle> hes = mesh_.halfface(*f_it).halfedges();
1062 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes.begin();
1063 he_it != hes.end(); ++he_it) {
1064 EXPECT_LE(he_it->idx(), 37);
1071 generatePolyhedralMesh(mesh_);
1074 c_it != mesh_.cells_end(); ++c_it) {
1076 std::vector<HalfFaceHandle> hfs = mesh_.cell(*c_it).halffaces();
1077 for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
1078 hf_it != hfs.end(); ++hf_it) {
1079 EXPECT_LE(hf_it->idx(), 21);
1080 EXPECT_LE(mesh_.opposite_halfface_handle(*hf_it).idx(), 21);
1087 c_it != mesh_.cells_end(); ++c_it) {
1089 std::vector<HalfFaceHandle> hfs = mesh_.cell(*c_it).halffaces();
1090 for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
1091 hf_it != hfs.end(); ++hf_it) {
1092 EXPECT_LE(hf_it->idx(), 19);
1093 EXPECT_LE(mesh_.opposite_halfface_handle(*hf_it).idx(), 19);
1100 generatePolyhedralMesh(mesh_);
1102 mesh_.enable_bottom_up_incidences(
false);
1105 he_it != mesh_.halfedges_end(); ++he_it) {
1107 const VertexHandle& fromVertex = mesh_.halfedge(*he_it).from_vertex();
1108 const VertexHandle& toVertex = mesh_.halfedge(*he_it).to_vertex();
1110 EXPECT_LE(fromVertex.idx(), 11);
1111 EXPECT_LE(toVertex.idx(), 11);
1117 he_it != mesh_.halfedges_end(); ++he_it) {
1119 const VertexHandle& fromVertex = mesh_.halfedge(*he_it).from_vertex();
1120 const VertexHandle& toVertex = mesh_.halfedge(*he_it).to_vertex();
1122 EXPECT_LE(fromVertex.idx(), 10);
1123 EXPECT_LE(toVertex.idx(), 10);
1129 generatePolyhedralMesh(mesh_);
1131 mesh_.enable_bottom_up_incidences(
false);
1134 f_it != mesh_.halffaces_end(); ++f_it) {
1136 std::vector<HalfEdgeHandle> hes = mesh_.halfface(*f_it).halfedges();
1137 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes.begin();
1138 he_it != hes.end(); ++he_it) {
1139 EXPECT_LE(he_it->idx(), 39);
1146 f_it != mesh_.halffaces_end(); ++f_it) {
1148 std::vector<HalfEdgeHandle> hes = mesh_.halfface(*f_it).halfedges();
1149 for(std::vector<HalfEdgeHandle>::const_iterator he_it = hes.begin();
1150 he_it != hes.end(); ++he_it) {
1151 EXPECT_LE(he_it->idx(), 37);
1158 generatePolyhedralMesh(mesh_);
1160 mesh_.enable_bottom_up_incidences(
false);
1163 c_it != mesh_.cells_end(); ++c_it) {
1165 std::vector<HalfFaceHandle> hfs = mesh_.cell(*c_it).halffaces();
1166 for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
1167 hf_it != hfs.end(); ++hf_it) {
1168 EXPECT_LE(hf_it->idx(), 21);
1169 EXPECT_LE(mesh_.opposite_halfface_handle(*hf_it).idx(), 21);
1176 c_it != mesh_.cells_end(); ++c_it) {
1178 std::vector<HalfFaceHandle> hfs = mesh_.cell(*c_it).halffaces();
1179 for(std::vector<HalfFaceHandle>::const_iterator hf_it = hfs.begin();
1180 hf_it != hfs.end(); ++hf_it) {
1181 EXPECT_LE(hf_it->idx(), 19);
1182 EXPECT_LE(mesh_.opposite_halfface_handle(*hf_it).idx(), 19);
1193 generateHexahedralMesh(mesh_);
1195 EXPECT_EQ(12u, mesh_.n_vertices());
1196 EXPECT_EQ(20u, mesh_.n_edges());
1197 EXPECT_EQ(11u, mesh_.n_faces());
1198 EXPECT_EQ(2u, mesh_.n_cells());
1200 EXPECT_EQ(1, mesh_.xfront_halfface(
CellHandle(0)));
1201 EXPECT_EQ(2, mesh_.xback_halfface(
CellHandle(0)));
1202 EXPECT_EQ(5, mesh_.yfront_halfface(
CellHandle(0)));
1203 EXPECT_EQ(6, mesh_.yback_halfface(
CellHandle(0)));
1204 EXPECT_EQ(8, mesh_.zfront_halfface(
CellHandle(0)));
1205 EXPECT_EQ(11, mesh_.zback_halfface(
CellHandle(0)));
1207 EXPECT_EQ(12, mesh_.opposite_halfface_handle_in_cell(
1215 HexahedralMesh::CellSheetCellIter csc_it = mesh_.csc_iter(0, HexahedralMesh::YF);
1218 HexahedralMesh::HalfFaceSheetHalfFaceIter hfshf_it = mesh_.hfshf_iter(5);
1220 hfshf_it = mesh_.hfshf_iter(6);
1226 generateHexahedralMesh(mesh_);
1228 EXPECT_EQ(12u, mesh_.n_vertices());
1229 EXPECT_EQ(20u, mesh_.n_edges());
1230 EXPECT_EQ(11u, mesh_.n_faces());
1231 EXPECT_EQ(2u, mesh_.n_cells());
1235 EXPECT_EQ(11u, mesh_.n_vertices());
1236 EXPECT_EQ(17u, mesh_.n_edges());
1237 EXPECT_EQ(8u, mesh_.n_faces());
1238 EXPECT_EQ(1u, mesh_.n_cells());
1242 EXPECT_EQ(3, hv_it->idx()); ++hv_it;
1243 EXPECT_EQ(4, hv_it->idx()); ++hv_it;
1244 EXPECT_EQ(5, hv_it->idx()); ++hv_it;
1245 EXPECT_EQ(6, hv_it->idx()); ++hv_it;
1246 EXPECT_EQ(7, hv_it->idx()); ++hv_it;
1247 EXPECT_EQ(10, hv_it->idx()); ++hv_it;
1248 EXPECT_EQ(9, hv_it->idx()); ++hv_it;
1249 EXPECT_EQ(8, hv_it->idx());
1254 generateHexahedralMesh(mesh_);
1256 EXPECT_EQ(12u, mesh_.n_vertices());
1257 EXPECT_EQ(20u, mesh_.n_edges());
1258 EXPECT_EQ(11u, mesh_.n_faces());
1259 EXPECT_EQ(2u, mesh_.n_cells());
1265 EXPECT_EQ(4, hv_it->idx()); ++hv_it;
1266 EXPECT_EQ(5, hv_it->idx()); ++hv_it;
1267 EXPECT_EQ(6, hv_it->idx()); ++hv_it;
1268 EXPECT_EQ(7, hv_it->idx()); ++hv_it;
1269 EXPECT_EQ(8, hv_it->idx()); ++hv_it;
1270 EXPECT_EQ(11, hv_it->idx()); ++hv_it;
1271 EXPECT_EQ(10, hv_it->idx()); ++hv_it;
1272 EXPECT_EQ(9, hv_it->idx());
1276 status.garbage_collection(
false);
1278 EXPECT_EQ(1u, mesh_.n_cells());
1279 EXPECT_EQ(11u, mesh_.n_vertices());
1280 EXPECT_EQ(17u, mesh_.n_edges());
1281 EXPECT_EQ(8u, mesh_.n_faces());
1285 EXPECT_EQ(3, hv_it->idx()); ++hv_it;
1286 EXPECT_EQ(4, hv_it->idx()); ++hv_it;
1287 EXPECT_EQ(5, hv_it->idx()); ++hv_it;
1288 EXPECT_EQ(6, hv_it->idx()); ++hv_it;
1289 EXPECT_EQ(7, hv_it->idx()); ++hv_it;
1290 EXPECT_EQ(10, hv_it->idx()); ++hv_it;
1291 EXPECT_EQ(9, hv_it->idx()); ++hv_it;
1292 EXPECT_EQ(8, hv_it->idx());
1294 status.garbage_collection(
true);
1296 EXPECT_EQ(1u, mesh_.n_cells());
1297 EXPECT_EQ(8u, mesh_.n_vertices());
1298 EXPECT_EQ(12u, mesh_.n_edges());
1299 EXPECT_EQ(6u, mesh_.n_faces());
1303 EXPECT_EQ(0, hv_it->idx()); ++hv_it;
1304 EXPECT_EQ(1, hv_it->idx()); ++hv_it;
1305 EXPECT_EQ(2, hv_it->idx()); ++hv_it;
1306 EXPECT_EQ(3, hv_it->idx()); ++hv_it;
1307 EXPECT_EQ(4, hv_it->idx()); ++hv_it;
1308 EXPECT_EQ(7, hv_it->idx()); ++hv_it;
1309 EXPECT_EQ(6, hv_it->idx()); ++hv_it;
1310 EXPECT_EQ(5, hv_it->idx());
1315 generateHexahedralMesh(mesh_);
1321 status.garbage_collection(
false);
1323 status.garbage_collection(
false);
1325 EXPECT_EQ(1u, mesh_.n_cells());
1326 EXPECT_EQ(11u, mesh_.n_vertices());
1327 EXPECT_EQ(17u, mesh_.n_edges());
1328 EXPECT_EQ(8u, mesh_.n_faces());
1333 generateHexahedralMesh(mesh_);
1339 status.garbage_collection(
false);
1341 EXPECT_EQ(1u, mesh_.n_cells());
1342 EXPECT_EQ(12u, mesh_.n_vertices());
1343 EXPECT_EQ(19u, mesh_.n_edges());
1344 EXPECT_EQ(9u, mesh_.n_faces());
1349 generateHexahedralMesh(mesh_);
1355 status.garbage_collection(
false);
1357 EXPECT_EQ(0u, mesh_.n_cells());
1358 EXPECT_EQ(12u, mesh_.n_vertices());
1359 EXPECT_EQ(19u, mesh_.n_edges());
1360 EXPECT_EQ(8u, mesh_.n_faces());
1365 generateHexahedralMesh(mesh_);
1373 status.garbage_collection(
true);
1375 EXPECT_EQ(1u, mesh_.n_cells());
1376 EXPECT_EQ(8u, mesh_.n_vertices());
1377 EXPECT_EQ(12u, mesh_.n_edges());
1378 EXPECT_EQ(6u, mesh_.n_faces());
1383 generateHexahedralMesh(mesh_);
1389 status.garbage_collection(
true);
1391 EXPECT_EQ(1u, mesh_.n_cells());
1392 EXPECT_EQ(6u, mesh_.n_faces());
1393 EXPECT_EQ(12u, mesh_.n_edges());
1394 EXPECT_EQ(8u, mesh_.n_vertices());
1399 generateHexahedralMesh(mesh_);
1405 status.garbage_collection(
true);
1407 EXPECT_EQ(1u, mesh_.n_cells());
1408 EXPECT_EQ(6u, mesh_.n_faces());
1409 EXPECT_EQ(12u, mesh_.n_edges());
1410 EXPECT_EQ(8u, mesh_.n_vertices());
1415 generateHexahedralMesh(mesh_);
1421 status.garbage_collection(
true);
1423 EXPECT_EQ(1u, mesh_.n_cells());
1424 EXPECT_EQ(6u, mesh_.n_faces());
1425 EXPECT_EQ(12u, mesh_.n_edges());
1426 EXPECT_EQ(8u, mesh_.n_vertices());
1431 generateHexahedralMesh(mesh_);
1437 status.garbage_collection(
true);
1439 EXPECT_EQ(1u, mesh_.n_cells());
1440 EXPECT_EQ(6u, mesh_.n_faces());
1441 EXPECT_EQ(12u, mesh_.n_edges());
1442 EXPECT_EQ(8u, mesh_.n_vertices());
1447 generateHexahedralMesh(mesh_);
1453 status.garbage_collection(
false);
1455 EXPECT_EQ(0u, mesh_.n_cells());
1456 EXPECT_EQ(8u, mesh_.n_faces());
1457 EXPECT_EQ(19u, mesh_.n_edges());
1458 EXPECT_EQ(12u, mesh_.n_vertices());
1460 status.garbage_collection(
true);
1462 EXPECT_EQ(0u, mesh_.n_cells());
1463 EXPECT_EQ(0u, mesh_.n_faces());
1464 EXPECT_EQ(0u, mesh_.n_edges());
1465 EXPECT_EQ(0u, mesh_.n_vertices());
1470 generateHexahedralMesh(mesh_);
1472 EXPECT_EQ(12u, mesh_.n_vertices());
1473 EXPECT_EQ(20u, mesh_.n_edges());
1474 EXPECT_EQ(11u, mesh_.n_faces());
1475 EXPECT_EQ(2u, mesh_.n_cells());
1481 std::vector<VertexHandle> vhs;
1482 std::vector<VertexHandle*> track_vhs;
1483 std::vector<HalfEdgeHandle*> hh_empty;
1484 std::vector<HalfFaceHandle*> hfh_empty;
1485 std::vector<CellHandle*> ch_empty;
1488 for (; v_it != mesh_.vertices_end(); ++v_it)
1489 vhs.push_back(*v_it);
1491 for (std::vector<VertexHandle>::iterator it = vhs.begin(); it != vhs.end(); ++it)
1492 track_vhs.push_back(&(*it));
1494 status.garbage_collection(track_vhs, hh_empty, hfh_empty, ch_empty,
false);
1496 EXPECT_EQ(vhs[0], -1);
1497 EXPECT_EQ(vhs[11], 10);
1499 EXPECT_EQ(1u, mesh_.n_cells());
1500 EXPECT_EQ(11u, mesh_.n_vertices());
1501 EXPECT_EQ(17u, mesh_.n_edges());
1502 EXPECT_EQ(8u, mesh_.n_faces());
1507 generateHexahedralMesh(mesh_);
1513 std::vector<HalfEdgeHandle> hhs;
1514 std::vector<VertexHandle*> vh_empty;
1515 std::vector<HalfEdgeHandle*> track_hh;
1516 std::vector<HalfFaceHandle*> hfh_empty;
1517 std::vector<CellHandle*> ch_empty;
1520 for (; hh_it != mesh_.halfedges_end(); ++hh_it)
1521 hhs.push_back(*hh_it);
1523 for (std::vector<HalfEdgeHandle>::iterator it = hhs.begin(); it != hhs.end(); ++it)
1524 track_hh.push_back(&(*it));
1526 status.garbage_collection(vh_empty, track_hh, hfh_empty, ch_empty,
false);
1528 EXPECT_EQ(hhs[9], 9);
1529 EXPECT_EQ(hhs[10], -1);
1530 EXPECT_EQ(hhs[11], -1);
1531 EXPECT_EQ(hhs[12], 10);
1532 EXPECT_EQ(hhs[39], 37);
1534 EXPECT_EQ(0u, mesh_.n_cells());
1535 EXPECT_EQ(8u, mesh_.n_faces());
1536 EXPECT_EQ(19u, mesh_.n_edges());
1537 EXPECT_EQ(12u, mesh_.n_vertices());
1539 status.garbage_collection(vh_empty, track_hh, hfh_empty, ch_empty,
true);
1541 for (std::vector<HalfEdgeHandle>::iterator it = hhs.begin(); it != hhs.end(); ++it)
1542 EXPECT_EQ(it->idx(), -1);
1544 EXPECT_EQ(0u, mesh_.n_cells());
1545 EXPECT_EQ(0u, mesh_.n_faces());
1546 EXPECT_EQ(0u, mesh_.n_edges());
1547 EXPECT_EQ(0u, mesh_.n_vertices());
1552 generateHexahedralMesh(mesh_);
1558 std::vector<HalfFaceHandle> hfhs;
1559 std::vector<VertexHandle*> vh_empty;
1560 std::vector<HalfEdgeHandle*> hh_empty;
1561 std::vector<HalfFaceHandle*> track_hfh;
1562 std::vector<CellHandle*> ch_empty;
1565 for (; hfh_it != mesh_.halffaces_end(); ++hfh_it)
1566 hfhs.push_back(*hfh_it);
1568 for (std::vector<HalfFaceHandle>::iterator it = hfhs.begin(); it != hfhs.end(); ++it)
1569 track_hfh.push_back(&(*it));
1571 status.garbage_collection(vh_empty, hh_empty, track_hfh, ch_empty,
true);
1573 EXPECT_EQ(hfhs[0], -1);
1574 EXPECT_EQ(hfhs[1], -1);
1575 EXPECT_EQ(hfhs[2], 0);
1576 EXPECT_EQ(hfhs[3], 1);
1577 EXPECT_EQ(hfhs[21], 11);
1580 EXPECT_EQ(1u, mesh_.n_cells());
1581 EXPECT_EQ(6u, mesh_.n_faces());
1582 EXPECT_EQ(12u, mesh_.n_edges());
1583 EXPECT_EQ(8u, mesh_.n_vertices());
1588 generateHexahedralMesh(mesh_);
1594 std::vector<CellHandle> chs;
1595 std::vector<VertexHandle*> vh_empty;
1596 std::vector<HalfEdgeHandle*> hh_empty;
1597 std::vector<HalfFaceHandle*> hfh_empty;
1598 std::vector<CellHandle*> track_ch;
1601 for (; c_it != mesh_.cells_end(); ++c_it)
1602 chs.push_back(*c_it);
1604 for (std::vector<CellHandle>::iterator it = chs.begin(); it != chs.end(); ++it)
1605 track_ch.push_back(&(*it));
1607 status.garbage_collection(vh_empty, hh_empty, hfh_empty, track_ch,
true);
1609 EXPECT_EQ(chs[0], -1);
1610 EXPECT_EQ(chs[1], 0);
1612 EXPECT_EQ(1u, mesh_.n_cells());
1613 EXPECT_EQ(6u, mesh_.n_faces());
1614 EXPECT_EQ(12u, mesh_.n_edges());
1615 EXPECT_EQ(8u, mesh_.n_vertices());
1620 generateHexahedralMesh(mesh_);
1652 status.garbage_collection(
false);
1654 EXPECT_EQ(1u, mesh_.n_cells());
1655 EXPECT_EQ(11u, mesh_.n_vertices());
1656 EXPECT_EQ(17u, mesh_.n_edges());
1657 EXPECT_EQ(8u, mesh_.n_faces());
1659 std::set<int> fprops_i;
1660 for(
FaceIter f_it = mesh_.f_iter(); f_it.valid(); ++f_it) {
1661 fprops_i.insert(fprop[f_it->idx()]);
1664 EXPECT_EQ(0u, fprops_i.count(11));
1665 EXPECT_EQ(1u, fprops_i.count(10));
1666 EXPECT_EQ(1u, fprops_i.count(9));
1667 EXPECT_EQ(0u, fprops_i.count(8));
1668 EXPECT_EQ(0u, fprops_i.count(7));
1669 EXPECT_EQ(1u, fprops_i.count(6));
1670 EXPECT_EQ(1u, fprops_i.count(5));
1671 EXPECT_EQ(1u, fprops_i.count(4));
1672 EXPECT_EQ(1u, fprops_i.count(3));
1673 EXPECT_EQ(1u, fprops_i.count(2));
1674 EXPECT_EQ(1u, fprops_i.count(1));
1679 generateHexahedralMesh(mesh_);
1711 status.garbage_collection(
false);
1713 EXPECT_EQ(1u, mesh_.n_cells());
1714 EXPECT_EQ(12u, mesh_.n_vertices());
1715 EXPECT_EQ(20u, mesh_.n_edges());
1716 EXPECT_EQ(10u, mesh_.n_faces());
1718 std::set<int> fprops_i;
1719 for(
FaceIter f_it = mesh_.f_iter(); f_it.valid(); ++f_it) {
1720 fprops_i.insert(fprop[f_it->idx()]);
1723 EXPECT_EQ(0u, fprops_i.count(11));
1724 EXPECT_EQ(1u, fprops_i.count(10));
1725 EXPECT_EQ(1u, fprops_i.count(9));
1726 EXPECT_EQ(1u, fprops_i.count(8));
1727 EXPECT_EQ(1u, fprops_i.count(7));
1728 EXPECT_EQ(1u, fprops_i.count(6));
1729 EXPECT_EQ(1u, fprops_i.count(5));
1730 EXPECT_EQ(1u, fprops_i.count(4));
1731 EXPECT_EQ(1u, fprops_i.count(3));
1732 EXPECT_EQ(1u, fprops_i.count(2));
1733 EXPECT_EQ(1u, fprops_i.count(1));
1738 generateHexahedralMesh(mesh_);
1758 EXPECT_EQ(HexahedralMesh::InvalidHalfEdgeHandle, heInv);
1763 generateHexahedralMesh(mesh_);
1769 std::vector<HalfEdgeHandle> hes;
1770 hes.push_back(he0); hes.push_back(he2);
1774 hes.push_back(he0); hes.push_back(he4);
1781 hes.push_back(he16); hes.push_back(he18);
1785 hes.push_back(he0); hes.push_back(he18);
1792 hes.push_back(he17); hes.push_back(he19);
1799 EXPECT_EQ(HexahedralMesh::InvalidHalfFaceHandle, hfInv);
1804 generateHexahedralMesh(mesh_);
1815 std::vector<VertexHandle> vs;
1816 vs.push_back(v0); vs.push_back(v1); vs.push_back(v2);
1819 vs.push_back(v2); vs.push_back(v1); vs.push_back(v0);
1822 vs.push_back(v2); vs.push_back(v1); vs.push_back(v5);
1825 vs.push_back(v6); vs.push_back(v5); vs.push_back(v4);
1828 vs.push_back(v4); vs.push_back(v5); vs.push_back(v6);
1831 vs.push_back(v0); vs.push_back(v1); vs.push_back(v4);
1834 vs.push_back(v0); vs.push_back(v1); vs.push_back(v6);
1842 EXPECT_EQ(HexahedralMesh::InvalidHalfFaceHandle, hfInv0);
1843 EXPECT_EQ(HexahedralMesh::InvalidHalfFaceHandle, hfInv1);
1848 generateHexahedralMesh(mesh_);
1854 status.garbage_collection(
false);
1856 EXPECT_EQ(1u, mesh_.n_cells());
1857 EXPECT_EQ(10u, mesh_.n_faces());
1858 EXPECT_EQ(20u, mesh_.n_edges());
1859 EXPECT_EQ(12u, mesh_.n_vertices());
1861 std::vector<VertexHandle> vs;
1873 EXPECT_NE(HexahedralMesh::InvalidCellHandle, ch);
1875 EXPECT_EQ(2u, mesh_.n_cells());
1876 EXPECT_EQ(11u, mesh_.n_faces());
1877 EXPECT_EQ(20u, mesh_.n_edges());
1878 EXPECT_EQ(12u, mesh_.n_vertices());
1883 generateHexahedralMesh(mesh_);
1889 status.garbage_collection(
true);
1891 EXPECT_EQ(1u, mesh_.n_cells());
1892 EXPECT_EQ(6u, mesh_.n_faces());
1893 EXPECT_EQ(12u, mesh_.n_edges());
1894 EXPECT_EQ(8u, mesh_.n_vertices());
1901 std::vector<VertexHandle> vs;
1913 EXPECT_NE(HexahedralMesh::InvalidCellHandle, ch);
1915 EXPECT_EQ(2u, mesh_.n_cells());
1916 EXPECT_EQ(11u, mesh_.n_faces());
1917 EXPECT_EQ(20u, mesh_.n_edges());
1918 EXPECT_EQ(12u, mesh_.n_vertices());
1925 generatePolyhedralMesh(mesh_);
1927 Vec3d p1(0.0, 0.0, 0.0);
1928 Vec3d p2(1.0, 0.0, 0.0);
1929 Vec3d p3(1.0, 1.0, 0.0);
1930 Vec3d p4(0.0, 1.0, 0.0);
1932 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(0))[0], p1[0]);
1933 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(0))[1], p1[1]);
1934 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(0))[2], p1[2]);
1936 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(1))[0], p2[0]);
1937 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(1))[1], p2[1]);
1938 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(1))[2], p2[2]);
1940 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(2))[0], p3[0]);
1941 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(2))[1], p3[1]);
1942 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(2))[2], p3[2]);
1944 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(3))[0], p4[0]);
1945 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(3))[1], p4[1]);
1946 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(3))[2], p4[2]);
1948 EXPECT_EQ(12u, mesh_.n_vertices());
1950 Vec3d p1n(1.0, 1.0, 1.0);
1951 Vec3d p2n(0.0, 1.0, 2.0);
1952 Vec3d p3n(0.0, 0.0, 3.0);
1953 Vec3d p4n(1.0, 0.0, 4.0);
1958 Vec3d p5(0.0, 0.0, 1.0);
1959 Vec3d p6(1.0, 0.0, 1.0);
1960 Vec3d p7(1.0, 1.0, 1.0);
1961 Vec3d p8(0.0, 1.0, 1.0);
1963 Vec3d p9(0.0, 0.0, 2.0);
1964 Vec3d p10(1.0, 0.0, 2.0);
1965 Vec3d p11(1.0, 1.0, 2.0);
1966 Vec3d p12(0.0, 1.0, 2.0);
1968 std::vector<Vec3d> new_vertices;
1970 new_vertices.push_back(p1n);
1971 new_vertices.push_back(p2n);
1972 new_vertices.push_back(p3n);
1973 new_vertices.push_back(p4n);
1975 new_vertices.push_back(p5);
1976 new_vertices.push_back(p6);
1977 new_vertices.push_back(p7);
1978 new_vertices.push_back(p8);
1979 new_vertices.push_back(p9);
1980 new_vertices.push_back(p10);
1981 new_vertices.push_back(p11);
1982 new_vertices.push_back(p12);
1984 mesh_.swap_vertices(new_vertices);
1986 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(0))[0], p1n[0]);
1987 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(0))[1], p1n[1]);
1988 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(0))[2], p1n[2]);
1990 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(1))[0], p2n[0]);
1991 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(1))[1], p2n[1]);
1992 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(1))[2], p2n[2]);
1994 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(2))[0], p3n[0]);
1995 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(2))[1], p3n[1]);
1996 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(2))[2], p3n[2]);
1998 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(3))[0], p4n[0]);
1999 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(3))[1], p4n[1]);
2000 EXPECT_DOUBLE_EQ(mesh_.vertex(
VertexHandle(3))[2], p4n[2]);
2002 EXPECT_EQ(12u, mesh_.n_vertices());
2009 mesh.collect_garbage();
2014 mesh_.enable_deferred_deletion(
true);
2015 mesh_.enable_fast_deletion(
false);
2016 testDeferredDelete(mesh_);
2019 mesh_.enable_deferred_deletion(
true);
2020 mesh_.enable_fast_deletion(
true);
2021 testDeferredDelete(mesh_);
const VecT & vertex(const VertexHandle &_vh) const
Get point _vh's coordinates.
Property classes for the different entity types.
Iterate over all vertices of a hexahedron in a specific order.
virtual VertexHandle add_vertex()
Override of empty add_vertex function.
VertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).