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

Function test_clone

tests/mesh/test-regular-grid.cpp:354–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352}
353
354void test_clone( const geode::RegularGrid3D& grid )
355{
356 const auto attribute_name = "int_attribute";
357 const auto attribute_name_d = "double_attribute";
358 auto attribute =
359 grid.polyhedron_attribute_manager()
360 .find_or_create_attribute< geode::VariableAttribute, int >(
361 attribute_name, 0 );
362 auto attribute_d =
363 grid.vertex_attribute_manager()
364 .find_or_create_attribute< geode::VariableAttribute, double >(
365 attribute_name_d, 0 );
366 for( const auto c : geode::Range{ grid.nb_polyhedra() } )
367 {
368 attribute->set_value( c, 2 * c );
369 }
370 for( const auto c : geode::Range{ grid.nb_vertices() } )
371 {
372 attribute_d->set_value( c, 2 * c );
373 }
374 const auto clone = grid.clone();
375 geode::OpenGeodeMeshException::test(
376 clone->nb_vertices() == grid.nb_vertices(),
377 "Clone wrong number of vertices" );
378 geode::OpenGeodeMeshException::test(
379 clone->nb_vertices_in_direction( 0 )
380 == grid.nb_vertices_in_direction( 0 ),
381 "Clone wrong number of vertices in direction 0" );
382 geode::OpenGeodeMeshException::test(
383 clone->nb_vertices_in_direction( 1 )
384 == grid.nb_vertices_in_direction( 1 ),
385 "Clone wrong number of vertices in direction 1" );
386 geode::OpenGeodeMeshException::test(
387 clone->nb_vertices_in_direction( 2 )
388 == grid.nb_vertices_in_direction( 2 ),
389 "Clone wrong number of vertices in direction 2" );
390
391 geode::OpenGeodeMeshException::test(
392 clone->nb_cells() == grid.nb_cells(), "Clone wrong number of cells" );
393 geode::OpenGeodeMeshException::test(
394 clone->nb_cells_in_direction( 0 ) == grid.nb_cells_in_direction( 0 ),
395 "Clone wrong number of cells in direction 0" );
396 geode::OpenGeodeMeshException::test(
397 clone->nb_cells_in_direction( 1 ) == grid.nb_cells_in_direction( 1 ),
398 "Clone wrong number of cells in direction 1" );
399 geode::OpenGeodeMeshException::test(
400 clone->nb_cells_in_direction( 2 ) == grid.nb_cells_in_direction( 2 ),
401 "Clone wrong number of cells in direction 2" );
402
403 geode::OpenGeodeMeshException::test(
404 clone->cell_length_in_direction( 0 )
405 == grid.cell_length_in_direction( 0 ),
406 "Clone wrong cell length in direction 0" );
407 geode::OpenGeodeMeshException::test(
408 clone->cell_length_in_direction( 1 )
409 == grid.cell_length_in_direction( 1 ),
410 "Clone wrong cell length in direction 1" );
411 geode::OpenGeodeMeshException::test(

Callers 1

test_gridFunction · 0.70

Calls 11

nb_polyhedraMethod · 0.80
testFunction · 0.70
set_valueMethod · 0.45
nb_verticesMethod · 0.45
cloneMethod · 0.45
nb_cellsMethod · 0.45
nb_cells_in_directionMethod · 0.45
attribute_existsMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected