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

Function convert_grid_to_surface

tests/mesh/test-convert-surface.cpp:84–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void convert_grid_to_surface()
85{
86 geode::LightRegularGrid2D grid{ geode::Point2D{ { 1, 2 } }, { 5, 6 },
87 { 1, 1 } };
88 const auto converted_grid2d =
89 geode::convert_grid_into_triangulated_surface( grid );
90 const std::array< geode::index_t, 4 > cells_to_densify{ 5, 11, 12, 13 };
91 const auto converted_grid2d_densified =
92 geode::convert_grid_into_densified_triangulated_surface(
93 grid, cells_to_densify );
94 geode::OpenGeodeMeshException::test(
95 converted_grid2d->nb_polygons() == grid.nb_cells() * 2,
96 "Number of polygons in TriangulatedSurface2D from grid is not "
97 "correct." );
98 geode::OpenGeodeMeshException::test(
99 converted_grid2d_densified->nb_polygons()
100 == grid.nb_cells() * 2 + 2 * cells_to_densify.size(),
101 "Number of polygons in TriangulatedSurface2D from grid is not "
102 "correct." );
103
104 geode::Logger::debug( "Triangulated surface from created RegularGrid" );
105 auto mesh_grid = geode::RegularGrid2D::create();
106 auto builder = geode::RegularGridBuilder2D::create( *mesh_grid );
107 builder->initialize_grid( geode::Point2D{ { 1, 1.5 } }, { 5, 5 }, 5 );
108 const auto tri_surf_from_mesh_grid_1 =
109 geode::convert_surface_mesh_into_triangulated_surface( *mesh_grid );
110 const auto tri_surf_from_mesh_grid_2 =
111 geode::convert_grid_into_triangulated_surface( *mesh_grid );
112
113 geode::Logger::debug( "Triangulated surface from old RegularGrid" );
114 const auto old_regular_grid = geode::load_regular_grid< 2 >(
115 absl::StrCat( geode::DATA_PATH, "old_regular_grid.og_rgd2d" ) );
116 const auto old_regular_grid_surface =
117 geode::convert_grid_into_triangulated_surface( *old_regular_grid );
118 auto test_attribute =
119 old_regular_grid_surface->vertex_attribute_manager()
120 .find_or_create_attribute< geode::VariableAttribute,
121 geode::Point2D >( "test", geode::Point2D{ { 0., 0. } } );
122 auto pt_attribute = old_regular_grid_surface->vertex_attribute_manager()
123 .find_attribute< geode::Point2D >( "points" );
124 const auto old_regular_grid_surface2 =
125 geode::convert_surface_mesh_into_triangulated_surface(
126 *old_regular_grid )
127 .value();
128 auto test_attribute2 =
129 old_regular_grid_surface2->vertex_attribute_manager()
130 .find_or_create_attribute< geode::VariableAttribute,
131 geode::Point2D >( "test", geode::Point2D{ { 0., 0. } } );
132 auto pt_attribute2 = old_regular_grid_surface2->vertex_attribute_manager()
133 .find_attribute< geode::Point2D >( "points" );
134}
135
136void triangulate_surface()
137{

Callers 1

testFunction · 0.85

Calls 10

debugFunction · 0.85
nb_polygonsMethod · 0.80
testFunction · 0.70
nb_cellsMethod · 0.45
sizeMethod · 0.45
initialize_gridMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected