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

Function test_barycenters

tests/mesh/test-polyhedral-solid.cpp:453–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

451}
452
453void test_barycenters()
454{
455 auto polyhedral_solid = geode::PolyhedralSolid3D::create(
456 geode::OpenGeodePolyhedralSolid3D::impl_name_static() );
457 auto builder = geode::PolyhedralSolidBuilder3D::create( *polyhedral_solid );
458 const double o{ 0.0 };
459 const double a{ 0.6 };
460 const double b{ 2.4 };
461 const double c{ 1.8 };
462 builder->create_point( geode::Point3D{ { o, o, o } } );
463 builder->create_point( geode::Point3D{ { a, o, o } } );
464 builder->create_point( geode::Point3D{ { o, o, c } } );
465 builder->create_point( geode::Point3D{ { o, b, o } } );
466 builder->create_point( geode::Point3D{ { a, b, o } } );
467 builder->create_point( geode::Point3D{ { o, b, c } } );
468 builder->create_polyhedron(
469 { 0, 1, 2, 3, 4, 5 }, { { 0, 1, 2 }, { 0, 1, 4, 3 }, { 1, 2, 5, 4 },
470 { 0, 3, 5, 2 }, { 3, 4, 5 } } );
471 const geode::Point3D answer_facet_barycenter{ { a / 3., 0, c / 3. } };
472 geode::OpenGeodeMeshException::test(
473 polyhedral_solid->facet_barycenter(
474 polyhedral_solid->polyhedron_facet_vertices( { 0, 0 } ) )
475 == answer_facet_barycenter,
476 "PolyhedralSolid facet_barycenter is not correct" );
477 const geode::Point3D answer_polyhedron_barycenter{ { a / 3., 0.5 * b,
478 c / 3. } };
479 geode::OpenGeodeMeshException::test(
480 polyhedral_solid->polyhedron_barycenter( 0 )
481 == answer_polyhedron_barycenter,
482 "PolyhedralSolid polyhedron barycenter is not correct" );
483}
484
485void test_normals()
486{

Callers 1

testFunction · 0.70

Calls 7

create_polyhedronMethod · 0.80
facet_barycenterMethod · 0.80
polyhedron_barycenterMethod · 0.80
testFunction · 0.70
impl_name_staticFunction · 0.50
create_pointMethod · 0.45

Tested by

no test coverage detected