MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / test_create

Function test_create

tests/mesh/test-merge-surface.cpp:41–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39#include <geode/mesh/io/triangulated_surface_output.hpp>
40
41void test_create()
42{
43 std::vector< geode::Point2D > points{ geode::Point2D{ { 0, 0 } },
44 geode::Point2D{ { 0, 1 } }, geode::Point2D{ { 0, 2 } },
45 geode::Point2D{ { 1, 0 } }, geode::Point2D{ { 1, 1 } },
46 geode::Point2D{ { 1, 2 } } };
47
48 auto mesh0 = geode::SurfaceMesh2D::create();
49 auto builder0 = geode::SurfaceMeshBuilder2D::create( *mesh0 );
50 builder0->create_point( points[0] );
51 builder0->create_point( points[1] );
52 builder0->create_point( points[3] );
53 builder0->create_point( points[4] );
54 builder0->create_point( points[5] );
55 builder0->create_polygon( { 0, 1, 3 } );
56 builder0->create_polygon( { 0, 3, 2 } );
57 builder0->create_polygon( { 1, 4, 3 } );
58 builder0->compute_polygon_adjacencies();
59
60 auto mesh1 = geode::SurfaceMesh2D::create();
61 auto builder1 = geode::SurfaceMeshBuilder2D::create( *mesh1 );
62 builder1->create_point( points[1] );
63 builder1->create_point( points[2] );
64 builder1->create_point( points[4] );
65 builder1->create_point( points[5] );
66 builder1->create_point( points[0] );
67 builder1->create_point( points[3] );
68 builder1->create_polygon( { 0, 3, 1 } );
69 builder1->create_polygon( { 0, 2, 3 } );
70 builder1->create_polygon( { 2, 0, 4 } );
71 builder1->create_polygon( { 2, 4, 5 } );
72 builder1->compute_polygon_adjacencies();
73
74 std::vector< std::reference_wrapper< const geode::SurfaceMesh2D > > meshes{
75 *mesh0, *mesh1
76 };
77 geode::detail::SurfaceMeshMerger2D merger{ meshes };
78 const auto merged = merger.merge( geode::GLOBAL_EPSILON );
79 geode::OpenGeodeMeshException::test(
80 merged->nb_vertices() == 6, "Wrong number of vertices" );
81 geode::OpenGeodeMeshException::test(
82 merged->nb_polygons() == 4, "Wrong number of polygons" );
83 for( const auto p : geode::Range{ merged->nb_polygons() } )
84 {
85 for( const auto e : geode::LRange{ 3 } )
86 {
87 const auto adj = merged->polygon_adjacent_edge( { p, e } );
88 geode_unused( adj );
89 }
90 }
91
92 geode::OpenGeodeMeshException::test(
93 merged->polygon_adjacent( { 0, 0 } ) == 1,
94 "Wrong adjacency for { 0, 0 }" );
95 geode::OpenGeodeMeshException::test(
96 merged->polygon_adjacent( { 0, 1 } ) == 2,
97 "Wrong adjacency for { 0, 1 }" );
98 geode::OpenGeodeMeshException::test(

Callers 1

testFunction · 0.85

Calls 10

geode_unusedFunction · 0.85
create_polygonMethod · 0.80
nb_polygonsMethod · 0.80
polygon_adjacent_edgeMethod · 0.80
polygon_adjacentMethod · 0.80
testFunction · 0.70
create_pointMethod · 0.45
mergeMethod · 0.45
nb_verticesMethod · 0.45

Tested by

no test coverage detected