MOAB: Mesh Oriented datABase  (version 5.2.1)
MBMesquite::SphericalDomain Class Reference

#include <SphericalDomain.hpp>

+ Inheritance diagram for MBMesquite::SphericalDomain:
+ Collaboration diagram for MBMesquite::SphericalDomain:

Public Member Functions

 SphericalDomain (const Vector3D &p_center, double p_radius)
 SphericalDomain ()
virtual ~SphericalDomain ()
void set_sphere (const Vector3D &p_center, double p_radius)
void fit_vertices (Mesh *mesh, MsqError &err, double epsilon=0.0)
void fit_vertices (Mesh *mesh, const Mesh::VertexHandle *vertex_array, size_t vertex_array_length, MsqError &err, double epsilon=0.0)
virtual void snap_to (Mesh::VertexHandle entity_handle, Vector3D &coordinate) const
virtual void vertex_normal_at (Mesh::VertexHandle entity_handle, Vector3D &coordinate) const
virtual void element_normal_at (Mesh::ElementHandle entity_handle, Vector3D &coordinate) const
virtual void vertex_normal_at (const Mesh::VertexHandle *handle, Vector3D coords[], unsigned count, MsqError &err) const
 evaluate surface normals
virtual void closest_point (Mesh::VertexHandle handle, const Vector3D &position, Vector3D &closest, Vector3D &normal, MsqError &err) const
 evaluate closest point and normal
virtual void domain_DoF (const Mesh::VertexHandle *handle_array, unsigned short *dof_array, size_t num_vertices, MsqError &err) const
Vector3D center () const
double radius () const

Private Attributes

Vector3D mCenter
double mRadius

Detailed Description

This is a template for a spherical domain. It will provide the normal information necessary for surface mesh optimization.

Definition at line 48 of file SphericalDomain.hpp.


Constructor & Destructor Documentation

MBMesquite::SphericalDomain::SphericalDomain ( const Vector3D p_center,
double  p_radius 
) [inline]

Definition at line 51 of file SphericalDomain.hpp.

: mCenter( p_center ), mRadius( p_radius ) {}

Definition at line 53 of file SphericalDomain.hpp.

{}

Definition at line 43 of file SphericalDomain.cpp.

{}

Member Function Documentation

void MBMesquite::SphericalDomain::closest_point ( Mesh::VertexHandle  handle,
const Vector3D position,
Vector3D closest,
Vector3D normal,
MsqError err 
) const [virtual]

evaluate closest point and normal

Given a position in space, return the closest position in the domain and the domain normal at that point.

Parameters:
entity_handleEvaluate the subset of the domain contianing this entity
positionInput position for which to evaluate
closestClosest position in the domain.
normalDomain normal at the location of 'closest'

Implements MBMesquite::MeshDomain.

Definition at line 84 of file SphericalDomain.cpp.

References moab::Util::is_finite(), MBMesquite::Vector3D::normalize(), MBMesquite::Vector3D::set(), and MBMesquite::Vector3D::x().

Referenced by SphericalDomainTest::test_closest_point().

{
    normal = position - mCenter;
    normal.normalize();
    if( !moab::Util::is_finite( normal.x() ) ) normal.set( 1.0, 0.0, 0.0 );
    closest = mCenter + mRadius * normal;
}
void MBMesquite::SphericalDomain::domain_DoF ( const Mesh::VertexHandle handle_array,
unsigned short *  dof_array,
size_t  num_vertices,
MsqError err 
) const [virtual]

Definition at line 94 of file SphericalDomain.cpp.

{
    std::fill( dof_array, dof_array + num_vertices, 2 );
}
void MBMesquite::SphericalDomain::element_normal_at ( Mesh::ElementHandle  entity_handle,
Vector3D coordinate 
) const [virtual]

Implements MBMesquite::MeshDomain.

Definition at line 71 of file SphericalDomain.cpp.

References vertex_normal_at().

Referenced by SphericalDomainTest::test_normal_at().

{
    SphericalDomain::vertex_normal_at( h, coordinate );
}
void MBMesquite::SphericalDomain::fit_vertices ( Mesh mesh,
MsqError err,
double  epsilon = 0.0 
)

Definition at line 100 of file SphericalDomain.cpp.

References MBMesquite::arrptr(), epsilon, MBMesquite::Mesh::get_all_vertices(), and MSQ_CHKERR.

Referenced by SphericalDomainTest::test_fit_vertices().

{
    std::vector< Mesh::VertexHandle > verts;
    mesh->get_all_vertices( verts, err );
    if( !MSQ_CHKERR( err ) ) fit_vertices( mesh, arrptr( verts ), verts.size(), err, epsilon );
}
void MBMesquite::SphericalDomain::fit_vertices ( Mesh mesh,
const Mesh::VertexHandle vertex_array,
size_t  vertex_array_length,
MsqError err,
double  epsilon = 0.0 
)

Definition at line 107 of file SphericalDomain.cpp.

References MBMesquite::arrptr(), MBMesquite::DomainUtil::default_tolerance(), MBMesquite::det(), MBMesquite::MsqError::INVALID_MESH, MSQ_ERRRTN, MSQ_SETERR, MBMesquite::DomainUtil::non_coplanar_vertices(), and MBMesquite::Mesh::vertices_get_coordinates().

{
    std::vector< MsqVertex > coords( num_verts );
    mesh->vertices_get_coordinates( verts, arrptr( coords ), num_verts, err );MSQ_ERRRTN( err );

    if( epsilon <= 0.0 ) epsilon = DomainUtil::default_tolerance( arrptr( coords ), num_verts );

    Vector3D pts[4];
    if( !DomainUtil::non_coplanar_vertices( arrptr( coords ), num_verts, pts, epsilon ) )
    {
        MSQ_SETERR( err )( "All vertices are co-planar", MsqError::INVALID_MESH );
        return;
    }

    // solve deterinant form of four-point sphere

    // Define the bottom 4 rows of a 5x5 matrix.  The top
    // row contains the variables we are solving for, so just
    // fill it with ones.
    const double M_vals[25] = { 1,
                                1,
                                1,
                                1,
                                1,
                                pts[0] % pts[0],
                                pts[0][0],
                                pts[0][1],
                                pts[0][2],
                                1,
                                pts[1] % pts[1],
                                pts[1][0],
                                pts[1][1],
                                pts[1][2],
                                1,
                                pts[2] % pts[2],
                                pts[2][0],
                                pts[2][1],
                                pts[2][2],
                                1,
                                pts[3] % pts[3],
                                pts[3][0],
                                pts[3][1],
                                pts[3][2],
                                1 };
    MsqMatrix< 5, 5 > M( M_vals );
    double M11 = det( MsqMatrix< 4, 4 >( M, 0, 0 ) );
    double M12 = det( MsqMatrix< 4, 4 >( M, 0, 1 ) );
    double M13 = det( MsqMatrix< 4, 4 >( M, 0, 2 ) );
    double M14 = det( MsqMatrix< 4, 4 >( M, 0, 3 ) );
    double M15 = det( MsqMatrix< 4, 4 >( M, 0, 4 ) );

    // define the sphere
    Vector3D cent( 0.5 * M12 / M11, -0.5 * M13 / M11, 0.5 * M14 / M11 );
    this->set_sphere( cent, sqrt( cent % cent - M15 / M11 ) );
}
void MBMesquite::SphericalDomain::set_sphere ( const Vector3D p_center,
double  p_radius 
) [inline]

Definition at line 57 of file SphericalDomain.hpp.

Referenced by SphericalDomainTest::test_construct().

    {
        mCenter = p_center;
        mRadius = p_radius;
    }
void MBMesquite::SphericalDomain::snap_to ( Mesh::VertexHandle  entity_handle,
Vector3D coordinate 
) const [virtual]

Modifies "coordinate" so that it lies on the domain to which "entity_handle" is constrained. The handle determines the domain. The coordinate is the proposed new position on that domain.

Implements MBMesquite::MeshDomain.

Definition at line 45 of file SphericalDomain.cpp.

References moab::Util::is_finite(), MBMesquite::Vector3D::length(), MBMesquite::Vector3D::set(), and MBMesquite::Vector3D::x().

Referenced by SphericalDomainTest::test_snap_to().

{
    // Get vector center to coordinate, store in coordinate.
    coordinate -= mCenter;
    // Get distance from center of sphere
    double len = coordinate.length();
    // Scale vector to have length of radius
    coordinate *= mRadius / len;
    // If was at center, return arbitrary position on sphere
    // (all possitions are equally close)
    if( !moab::Util::is_finite( coordinate.x() ) ) coordinate.set( mRadius, 0.0, 0.0 );
    // Get position from vector
    coordinate += mCenter;
}
void MBMesquite::SphericalDomain::vertex_normal_at ( Mesh::VertexHandle  entity_handle,
Vector3D coordinate 
) const [virtual]

Returns the normal of the domain to which "entity_handle" is constrained. For non-planar surfaces, the normal is calculated at the point on the domain that is closest to the passed in value of "coordinate". If the domain does not have a normal, or the normal cannot be determined, "coordinate" is set to (0,0,0). Otherwise, "coordinate" is set to the domain's normal at the appropriate point. In summary, the handle determines the domain. The coordinate determines the point of interest on that domain.

User should see also PatchData::get_domain_normal_at_vertex and PatchData::get_domain_normal_at_element .

Implements MBMesquite::MeshDomain.

Definition at line 60 of file SphericalDomain.cpp.

References moab::Util::is_finite(), MBMesquite::Vector3D::length(), MBMesquite::length(), MBMesquite::Vector3D::set(), and MBMesquite::Vector3D::x().

Referenced by element_normal_at(), and SphericalDomainTest::test_normal_at().

{
    // normal is vector from center to input position
    coordinate -= mCenter;
    // make it a unit vector
    double length = coordinate.length();
    coordinate /= length;
    // if input position was at center, choose same position
    // on sphere as snap_to.
    if( !moab::Util::is_finite( coordinate.x() ) ) coordinate.set( 1.0, 0.0, 0.0 );
}
void MBMesquite::SphericalDomain::vertex_normal_at ( const Mesh::VertexHandle handles,
Vector3D  coordinates[],
unsigned  count,
MsqError err 
) const [virtual]

evaluate surface normals

Returns normals for a domain.

Parameters:
handlesThe domain evaluated is the one in which this mesh entity is constrained.
coordinatesAs input, a list of positions at which to evaluate the domain. As output, the resulting domain normals.
countThe length of the coordinates array.

Implements MBMesquite::MeshDomain.

Definition at line 76 of file SphericalDomain.cpp.

{
    for( unsigned i = 0; i < count; ++i )
        vertex_normal_at( handle[i], coords[i] );
}

Member Data Documentation

Definition at line 94 of file SphericalDomain.hpp.

List of all members.


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