cgma
SphereEvaluator Class Reference

#include <SphereEvaluator.hpp>

Inheritance diagram for SphereEvaluator:
CubitEvaluator

List of all members.

Public Member Functions

 SphereEvaluator (const SphereEvaluatorData *data)
virtual ~SphereEvaluator ()
virtual GeometryType ask_type ()
virtual CubitBoolean is_parametric () const
virtual CubitBoolean is_periodic () const
virtual CubitBoolean is_periodic_in_U (double &period) const
virtual CubitBoolean is_periodic_in_V (double &period) const
virtual CubitBoolean is_singular_in_U () const
virtual CubitBoolean is_singular_in_V () const
virtual CubitBoolean is_closed_in_U () const
virtual CubitBoolean is_closed_in_V () const
virtual CubitBoolean get_param_range_U (double &lower_bound, double &upper_bound) const
virtual CubitBoolean get_param_range_V (double &lower_bound, double &upper_bound) const
virtual const CubitEvaluatorDataevaluator_data () const
virtual CubitVector position_from_u_v (double u, double v) const
virtual CubitStatus u_v_from_position (CubitVector const &location, double &u, double &v, CubitVector *closest_location) const
virtual CubitBox bounding_box () const
virtual CubitStatus principal_curvatures (CubitVector const &location, double &curvature_1, double &curvature_2, CubitVector *closest_location=NULL)
virtual CubitStatus closest_point (CubitVector const &location, CubitVector *closest_location=NULL, CubitVector *unit_normal_ptr=NULL, CubitVector *curvature1_ptr=NULL, CubitVector *curvature2_ptr=NULL) const

Private Attributes

SphereEvaluatorData mEvalData

Detailed Description

Definition at line 34 of file SphereEvaluator.hpp.


Constructor & Destructor Documentation

Definition at line 46 of file SphereEvaluator.hpp.

{ mEvalData = *data; }
virtual SphereEvaluator::~SphereEvaluator ( ) [inline, virtual]

Definition at line 48 of file SphereEvaluator.hpp.

    {}

Member Function Documentation

virtual GeometryType SphereEvaluator::ask_type ( ) [inline, virtual]

Reimplemented from CubitEvaluator.

Definition at line 51 of file SphereEvaluator.hpp.

{ return SPHERE_SURFACE_TYPE; }
CubitBox SphereEvaluator::bounding_box ( void  ) const [virtual]

Implements CubitEvaluator.

Definition at line 33 of file SphereEvaluator.cpp.

{
    CubitVector center = mTmatrix * mEvalData.center;
            
    CubitVector min( center.x() - mEvalData.radius,
                     center.y() - mEvalData.radius,
                     center.z() - mEvalData.radius );
    CubitVector max( center.x() + mEvalData.radius,
                     center.y() + mEvalData.radius,
                     center.z() + mEvalData.radius );

    CubitBox thebbox( min, max );

    return thebbox;
}
CubitStatus SphereEvaluator::closest_point ( CubitVector const &  location,
CubitVector closest_location = NULL,
CubitVector unit_normal_ptr = NULL,
CubitVector curvature1_ptr = NULL,
CubitVector curvature2_ptr = NULL 
) const [virtual]

Implements CubitEvaluator.

Definition at line 81 of file SphereEvaluator.cpp.

{
    CubitTransformMatrix inverse_Tmatrix = mTmatrix;
    inverse_Tmatrix.inverse();
    CubitVector new_pt = inverse_Tmatrix * location;

    // ******************************************************
    // If requested, compute the normal at the input point.
    // ******************************************************

    if ( unit_normal_ptr != NULL )
    {
        CubitVector origin( 0.0, 0.0, 0.0 );
        CubitVector endpt = new_pt - mEvalData.center;

        origin = mTmatrix * origin;
        endpt  = mTmatrix * endpt;

        *unit_normal_ptr = endpt - origin;
        unit_normal_ptr->normalize();
    }

    // *************************************************************
    // If requested, compute the closest point to the input point.
    // *************************************************************

    if ( closest_location != NULL )
    {
        if ( location.within_tolerance( mEvalData.center, GEOMETRY_RESABS ) )
        {
            closest_location->set( mEvalData.center.x() + mEvalData.radius,
                                   mEvalData.center.y(),
                                   mEvalData.center.z() );
        }
        else
        {
            CubitVector vec = new_pt - mEvalData.center;
            vec.normalize();
            *closest_location = mEvalData.center + ( vec * mEvalData.radius );
            *closest_location = mTmatrix * (*closest_location);
        }
    }

    // ***********************************************************************
    // If requested, compute the curvature directions.
    // ***********************************************************************

    if ( curvature1_ptr &&
         curvature2_ptr )
    {
        PRINT_ERROR("Sphere's do not current support curvature pointer requests.\n");
        return CUBIT_FAILURE;
    }
  
    return CUBIT_SUCCESS;
}
const CubitEvaluatorData * SphereEvaluator::evaluator_data ( void  ) const [virtual]

Implements CubitEvaluator.

Definition at line 213 of file SphereEvaluator.cpp.

{
    return &mEvalData;
}
CubitBoolean SphereEvaluator::get_param_range_U ( double &  lower_bound,
double &  upper_bound 
) const [virtual]

Implements CubitEvaluator.

Definition at line 223 of file SphereEvaluator.cpp.

{
   lower_bound = 0.0;
   upper_bound = 2.0*CUBIT_PI;
   return CUBIT_TRUE;
}
CubitBoolean SphereEvaluator::get_param_range_V ( double &  lower_bound,
double &  upper_bound 
) const [virtual]

Implements CubitEvaluator.

Definition at line 238 of file SphereEvaluator.cpp.

{
   lower_bound = 0;
   upper_bound = CUBIT_PI;
   return CUBIT_TRUE;
}
virtual CubitBoolean SphereEvaluator::is_closed_in_U ( ) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 60 of file SphereEvaluator.hpp.

{ return CUBIT_TRUE; }
virtual CubitBoolean SphereEvaluator::is_closed_in_V ( ) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 61 of file SphereEvaluator.hpp.

{ return CUBIT_FALSE; }
virtual CubitBoolean SphereEvaluator::is_parametric ( ) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 52 of file SphereEvaluator.hpp.

{ return CUBIT_TRUE; }
virtual CubitBoolean SphereEvaluator::is_periodic ( ) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 53 of file SphereEvaluator.hpp.

{ return CUBIT_TRUE; }
virtual CubitBoolean SphereEvaluator::is_periodic_in_U ( double &  period) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 54 of file SphereEvaluator.hpp.

                                                                  { period = 2*CUBIT_PI;
                                                                    return CUBIT_TRUE; }
virtual CubitBoolean SphereEvaluator::is_periodic_in_V ( double &  period) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 56 of file SphereEvaluator.hpp.

                                                                  { period = 2*CUBIT_PI;
                                                                    return CUBIT_FALSE; }
virtual CubitBoolean SphereEvaluator::is_singular_in_U ( ) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 58 of file SphereEvaluator.hpp.

{ return CUBIT_FALSE; }
virtual CubitBoolean SphereEvaluator::is_singular_in_V ( ) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 59 of file SphereEvaluator.hpp.

{ return CUBIT_TRUE; }
CubitVector SphereEvaluator::position_from_u_v ( double  u,
double  v 
) const [virtual]

Implements CubitEvaluator.

Definition at line 146 of file SphereEvaluator.cpp.

{
    double two_pi = 2.0 * CUBIT_PI;

    while ( u > two_pi ) u -= two_pi;
    while ( u < 0.0    ) u += two_pi;

    double radius_modified = mEvalData.radius * sin ( v );
    double x = radius_modified * cos( u );
    double y = radius_modified * sin( u );
    double z = mEvalData.radius * cos( v );

    CubitVector position( x, y, z );
    position = mTmatrix * position;

    return position;
}
CubitStatus SphereEvaluator::principal_curvatures ( CubitVector const &  location,
double &  curvature_1,
double &  curvature_2,
CubitVector closest_location = NULL 
) [virtual]

Implements CubitEvaluator.

Definition at line 58 of file SphereEvaluator.cpp.

{

    curvature_1 = curvature_2 = 1.0 / mEvalData.radius;

    if ( closest_location )
    {
        closest_point( location, closest_location );
    }
    return CUBIT_SUCCESS;
}
CubitStatus SphereEvaluator::u_v_from_position ( CubitVector const &  location,
double &  u,
double &  v,
CubitVector closest_location 
) const [virtual]

Implements CubitEvaluator.

Definition at line 169 of file SphereEvaluator.cpp.

{
    CubitTransformMatrix inverse_Tmatrix = mTmatrix;
    inverse_Tmatrix.inverse();
    CubitVector transformed_pt = inverse_Tmatrix * location;

    CubitVector dir( transformed_pt );
    dir.normalize();

    v = acos( dir.z() );

    if ( v < GEOMETRY_RESABS )
    {
        u = 0.0;
    }
    else
    {
        dir.set( dir.x(), dir.y(), 0.0 );
        dir.normalize();
        u = acos( dir.x() );

        if ( dir.y() < 0.0 )
        {
            u = 2*CUBIT_PI - u;
        }
        while ( u < 0.0 ) u += 2*CUBIT_PI;
        while ( u >= 2*CUBIT_PI ) u -= 2*CUBIT_PI;
    }

    if ( closest_location )
        closest_point( location, closest_location );
    return CUBIT_SUCCESS;
}

Member Data Documentation


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