MOAB: Mesh Oriented datABase  (version 5.4.1)
SphericalDomainTest Class Reference
+ Inheritance diagram for SphericalDomainTest:
+ Collaboration diagram for SphericalDomainTest:

Public Member Functions

void test_construct ()
void test_fit_vertices ()
void test_snap_to ()
void test_normal_at ()
void test_closest_point ()
void test_domain_DoF ()

Private Member Functions

 CPPUNIT_TEST_SUITE (SphericalDomainTest)
 CPPUNIT_TEST (test_construct)
 CPPUNIT_TEST (test_fit_vertices)
 CPPUNIT_TEST (test_snap_to)
 CPPUNIT_TEST (test_normal_at)
 CPPUNIT_TEST (test_closest_point)
 CPPUNIT_TEST (test_domain_DoF)
 CPPUNIT_TEST_SUITE_END ()
void check_closest_pt (const SphericalDomain &dom, const Vector3D &input_pt, const Vector3D &output_pt)
void check_normal (const SphericalDomain &dom, const Vector3D &point, const Vector3D &normal)

Detailed Description

Definition at line 39 of file SphericalDomainTest.cpp.


Member Function Documentation

void SphericalDomainTest::check_closest_pt ( const SphericalDomain dom,
const Vector3D input_pt,
const Vector3D output_pt 
) [private]
void SphericalDomainTest::check_normal ( const SphericalDomain dom,
const Vector3D point,
const Vector3D normal 
) [private]

Definition at line 177 of file SphericalDomainTest.cpp.

References ASSERT_NO_ERROR, MBMesquite::SphericalDomain::closest_point(), and n.

{
    Vector3D cen( -1, -1, -2 );
    double rad = 1.4;
    SphericalDomain dom( cen, rad );
    MsqPrintError err( std::cout );

    const int num_pts         = 5;
    double points[num_pts][3] = { { 0, 0, 0 }, { 10, 11, 8 }, { 1, 2, 3 }, { -5, 1, 1 }, { -1, 0, -2 } };
    for( int i = 0; i < num_pts; ++i )
    {
        Vector3D p( points[i] ), c, n;
        dom.closest_point( 0, p, c, n, err );
        ASSERT_NO_ERROR( err );
        check_closest_pt( dom, p, c );
        check_normal( dom, p, n );
    }
}

Definition at line 85 of file SphericalDomainTest.cpp.

References MBMesquite::SphericalDomain::center(), CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::SphericalDomain::radius(), and MBMesquite::SphericalDomain::set_sphere().

{
    Vector3D cen( 1, 2, -1 );
    double rad = 3.14159;
    SphericalDomain sph( cen, rad );
    CPPUNIT_ASSERT_VECTORS_EQUAL( cen, sph.center(), 1e-18 );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rad, sph.radius(), 1e-18 );

    cen = Vector3D( 5, 6, 1.14 );
    rad = 1 / rad;
    sph.set_sphere( cen, rad );
    CPPUNIT_ASSERT_VECTORS_EQUAL( cen, sph.center(), 1e-18 );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rad, sph.radius(), 1e-18 );
}

Definition at line 196 of file SphericalDomainTest.cpp.

References MBMesquite::arrptr(), ASSERT_NO_ERROR, CPPUNIT_ASSERT, and dof().

{
    std::vector< Mesh::VertexHandle > junk( 10 );
    std::vector< unsigned short > dof( junk.size() );
    std::vector< unsigned short > expected( dof.size(), 2 );
    SphericalDomain dom;
    MsqPrintError err( std::cout );
    dom.domain_DoF( arrptr( junk ), arrptr( dof ), junk.size(), err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT( expected == dof );
}

Definition at line 109 of file SphericalDomainTest.cpp.

References MBMesquite::arrptr(), ASSERT_NO_ERROR, MBMesquite::SphericalDomain::center(), CPPUNIT_ASSERT_DOUBLES_EQUAL, CPPUNIT_ASSERT_VECTORS_EQUAL, MBMesquite::SphericalDomain::fit_vertices(), fixed, MBMesquite::length(), mesh, MBMesquite::SphericalDomain::radius(), sphere_point(), and MBMesquite::TRIANGLE.

{
    Vector3D cen( 1, 2, 3 );
    double rad = 2.5;

    // point locations on a expected sphere
    const int num_pt = 6;
    double coords[3 * num_pt];
    sphere_point( cen, rad, 0.1, 0.2, coords );
    sphere_point( cen, rad, 2.0, 2.0, coords + 3 );
    sphere_point( cen, rad, -1.0, 0.0, coords + 6 );
    sphere_point( cen, rad, 3.1, -0.5, coords + 9 );
    sphere_point( cen, rad, -1.5, -1.0, coords + 12 );
    sphere_point( cen, rad, 0.2, 0.1, coords + 15 );

    // make sure our setup is valid
    for( int i = 0; i < num_pt; ++i )
    {
        Vector3D pt( coords + 3 * i );
        CPPUNIT_ASSERT_DOUBLES_EQUAL( rad, ( pt - cen ).length(), 1e-6 );
    }

    std::vector< int > fixed( num_pt, 0 );
    ArrayMesh mesh( 3, num_pt, coords, arrptr( fixed ), 0, TRIANGLE, 0 );
    SphericalDomain sph;
    MsqError err;
    sph.fit_vertices( &mesh, err );
    ASSERT_NO_ERROR( err );
    CPPUNIT_ASSERT_VECTORS_EQUAL( cen, sph.center(), 1e-6 );
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rad, sph.radius(), 1e-6 );
}

Definition at line 157 of file SphericalDomainTest.cpp.

References MBMesquite::SphericalDomain::element_normal_at(), and MBMesquite::SphericalDomain::vertex_normal_at().

{
    Vector3D cen( -3.14, 0, 0.91 );
    double rad = 2;
    SphericalDomain dom( cen, rad );

    const int num_pts         = 5;
    double points[num_pts][3] = { { 0, 0, 0 }, { 10, 11, 8 }, { 1, 2, 3 }, { -5, 1, 1 }, { -1, 0, -2 } };
    for( int i = 0; i < num_pts; ++i )
    {
        Vector3D v( points[i] );
        dom.vertex_normal_at( 0, v );
        check_normal( dom, Vector3D( points[i] ), v );

        v = Vector3D( points[i] );
        dom.element_normal_at( 0, v );
        check_normal( dom, Vector3D( points[i] ), v );
    }
}

Definition at line 141 of file SphericalDomainTest.cpp.

References MBMesquite::SphericalDomain::snap_to().

{
    Vector3D cen( 3.14, 15, 0.91 );
    double rad = 6.02;
    SphericalDomain dom( cen, rad );

    const int num_pts         = 5;
    double points[num_pts][3] = { { 0, 0, 0 }, { 10, 11, 8 }, { 1, 2, 3 }, { -5, 1, 1 }, { -1, 0, -2 } };
    for( int i = 0; i < num_pts; ++i )
    {
        Vector3D v( points[i] );
        dom.snap_to( 0, v );
        check_closest_pt( dom, Vector3D( points[i] ), v );
    }
}

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines