MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::ConicDomain Class Reference

#include <ConicDomain.hpp>

+ Inheritance diagram for MBMesquite::ConicDomain:
+ Collaboration diagram for MBMesquite::ConicDomain:

Public Member Functions

 ConicDomain (double radius_at_point, double height_to_apex, Vector3D axis_direction=Vector3D(0, 0, 1), Vector3D axis_point=Vector3D(0, 0, 0), bool outward_normal=true)
 ConicDomain ()
virtual ~ConicDomain ()
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 count, MsqError &err) const
const Vector3Daxis () const
const Vector3Dpoint () const
double point_radius () const
double height_from_point () const

Protected Member Functions

virtual void evaluate (Mesh::VertexHandle handle, const Vector3D &point, Vector3D &closest, Vector3D &normal) const

Private Attributes

Vector3D mAxis
 Direction of central axis of cone. Unit vector.
Vector3D mPoint
 A point on the axis of the cone.
double mRadius
 Radius at mPoint.
double mHeight
 Distance from mPoint to apex, in direction of mAxis.
double outwardSign
 1.0 if normal points away from axis, -1.0 otherwise

Detailed Description

Define the geometry of an unbounded cone with circular cross-section.

Definition at line 45 of file ConicDomain.hpp.


Constructor & Destructor Documentation

MBMesquite::ConicDomain::ConicDomain ( double  radius_at_point,
double  height_to_apex,
Vector3D  axis_direction = Vector3D( 0, 0, 1 ),
Vector3D  axis_point = Vector3D( 0, 0, 0 ),
bool  outward_normal = true 
) [inline]
Parameters:
radius_at_pointThe radius of the cone at axis_point
height_to_apexThe distance in the direction of axis_direction from axis_point to the apex
axis_directionVector defining the direction of the axis
axis_pointA point through which the axis passes. Cone is not bounded at apex. It extends infinitely in both directions.

Definition at line 57 of file ConicDomain.hpp.

        : mAxis( axis_direction / axis_direction.length() ), mPoint( axis_point ), mRadius( radius_at_point ),
          mHeight( height_to_apex ), outwardSign( outward_normal ? 1.0 : -1.0 )
    {
    }

Definition at line 67 of file ConicDomain.hpp.

{}

Definition at line 38 of file ConicDomain.cpp.

{}

Member Function Documentation

const Vector3D& MBMesquite::ConicDomain::axis ( ) const [inline]

Definition at line 93 of file ConicDomain.hpp.

Referenced by ConicDomainTest::test_construct(), and ConicDomainTest::test_snap_to().

    {
        return mAxis;
    }
void MBMesquite::ConicDomain::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 126 of file ConicDomain.cpp.

References evaluate().

Referenced by ConicDomainTest::test_closest_point().

{
    evaluate( handle, position, closest, normal );
}
void MBMesquite::ConicDomain::domain_DoF ( const Mesh::VertexHandle handle_array,
unsigned short *  dof_array,
size_t  count,
MsqError err 
) const [virtual]

Definition at line 135 of file ConicDomain.cpp.

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

Implements MBMesquite::MeshDomain.

Definition at line 112 of file ConicDomain.cpp.

References evaluate(), and l.

Referenced by ConicDomainTest::test_normal_at().

{
    Vector3D p( v ), l;
    // NOTE: Explicitly invoke this class's evaluate method for elements.
    //       BoundedCylindarDomain overrides evaluate for vertices only.
    ConicDomain::evaluate( h, p, l, v );
}
void MBMesquite::ConicDomain::evaluate ( Mesh::VertexHandle  handle,
const Vector3D point,
Vector3D closest,
Vector3D normal 
) const [protected, virtual]

Definition at line 40 of file ConicDomain.cpp.

References MBMesquite::Vector3D::length(), MBMesquite::length_squared(), mAxis, mHeight, mPoint, mRadius, n, outwardSign, and t.

Referenced by closest_point(), element_normal_at(), snap_to(), and vertex_normal_at().

{
    // translate such that cone point (mPoint) is at origin
    Vector3D pt = p_point - mPoint;

    // find the plane containing both the input point an the axis
    Vector3D n = mAxis * pt;
    double len = n.length();
    if( len < 1e-12 )
    {
        // point on axis
        // choose any plane that does't contain the axis
        if( fabs( mAxis[0] ) <= fabs( mAxis[1] ) && fabs( mAxis[0] ) < fabs( mAxis[2] ) )
            n = mAxis * Vector3D( 1, 0, 0 );
        else if( fabs( mAxis[1] ) <= fabs( mAxis[2] ) )
            n = mAxis * Vector3D( 0, 1, 0 );
        else
            n = mAxis * Vector3D( 0, 0, 1 );
    }
    else
    {
        n /= len;
    }
    // Find two points that are the intersection of the plane with the
    // circular cross-section of the cone centered at mPoint
    Vector3D p1 = mRadius * ( n * mAxis );
    Vector3D p2 = -p1;
    // Define two lines of intersect between the cone and the plane
    // as the two lines from the apex to each of p1 and p2.
    Vector3D apex = mHeight * mAxis;
    Vector3D v1   = p1 - apex;
    Vector3D v2   = p2 - apex;
    // Find closest point on each line to input position
    double t1 = v1 % ( p_point - apex ) / ( v1 % v1 );
    double t2 = v2 % ( p_point - apex ) / ( v2 % v2 );
    // Select the closest of the two
    p1 = apex + t1 * v1;
    p2 = apex + t2 * v2;
    double t;
    if( ( p1 - p_point ).length_squared() < ( p2 - p_point ).length_squared() )
    {
        normal  = v1 * n;
        closest = p1;
        t       = t1;
    }
    else
    {
        normal  = v2 * n;
        closest = p2;
        t       = t2;
    }
    // If we're below the apex (t > 0), then the normal
    // should be in the same direction as the axis.  Otherwise
    // it should be in the opposite direction.
    if( t * ( normal % mAxis ) < 0.0 ) normal = -normal;
    // normalize and translate
    normal *= outwardSign / normal.length();
    closest += mPoint;
}
double MBMesquite::ConicDomain::height_from_point ( ) const [inline]

Definition at line 105 of file ConicDomain.hpp.

Referenced by ConicDomainTest::test_construct(), and ConicDomainTest::test_snap_to().

    {
        return mHeight;
    }
const Vector3D& MBMesquite::ConicDomain::point ( ) const [inline]

Definition at line 97 of file ConicDomain.hpp.

Referenced by ConicDomainTest::test_construct(), and ConicDomainTest::test_snap_to().

    {
        return mPoint;
    }
double MBMesquite::ConicDomain::point_radius ( ) const [inline]

Definition at line 101 of file ConicDomain.hpp.

Referenced by ConicDomainTest::test_construct().

    {
        return mRadius;
    }
void MBMesquite::ConicDomain::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 100 of file ConicDomain.cpp.

References evaluate(), and n.

Referenced by ConicDomainTest::test_snap_to().

{
    Vector3D p( v ), n;
    evaluate( h, p, v, n );
}
void MBMesquite::ConicDomain::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 106 of file ConicDomain.cpp.

References evaluate(), and l.

Referenced by ConicDomainTest::test_normal_at(), and vertex_normal_at().

{
    Vector3D p( v ), l;
    evaluate( h, p, l, v );
}
void MBMesquite::ConicDomain::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 120 of file ConicDomain.cpp.

References vertex_normal_at().

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

Member Data Documentation

Direction of central axis of cone. Unit vector.

Definition at line 117 of file ConicDomain.hpp.

Referenced by evaluate().

Distance from mPoint to apex, in direction of mAxis.

Definition at line 120 of file ConicDomain.hpp.

Referenced by evaluate().

A point on the axis of the cone.

Definition at line 118 of file ConicDomain.hpp.

Referenced by evaluate().

Radius at mPoint.

Definition at line 119 of file ConicDomain.hpp.

Referenced by evaluate().

1.0 if normal points away from axis, -1.0 otherwise

Definition at line 121 of file ConicDomain.hpp.

Referenced by evaluate().

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