cgma
CylinderEvaluator Class Reference

#include <CylinderEvaluator.hpp>

Inheritance diagram for CylinderEvaluator:
CubitEvaluator

List of all members.

Public Member Functions

 CylinderEvaluator (const CylinderEvaluatorData *data)
virtual ~CylinderEvaluator ()
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 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 const CubitEvaluatorDataevaluator_data () 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

Protected Member Functions

CubitVector base () const

Private Attributes

CylinderEvaluatorData mEvalData

Detailed Description

Definition at line 36 of file CylinderEvaluator.hpp.


Constructor & Destructor Documentation

virtual CylinderEvaluator::~CylinderEvaluator ( ) [inline, virtual]

Definition at line 51 of file CylinderEvaluator.hpp.

    {}

Member Function Documentation

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

Reimplemented from CubitEvaluator.

Definition at line 54 of file CylinderEvaluator.hpp.

{ return CONE_SURFACE_TYPE; }
CubitVector CylinderEvaluator::base ( ) const [protected]

Definition at line 262 of file CylinderEvaluator.cpp.

{
    return CubitVector( 0.0, 0.0, -0.5*mEvalData.height );
}
CubitBox CylinderEvaluator::bounding_box ( void  ) const [virtual]

Implements CubitEvaluator.

Definition at line 48 of file CylinderEvaluator.cpp.

{
    int ipt = 0;
    CubitVector pts[8];
    CubitVector axis( 0.0, 0.0, 1.0 );
    CubitVector base_pt = base();
    CubitVector top_pt = base() + mEvalData.height * axis;
    CubitVector x_dir( 1.0, 0.0, 0.0 );
    CubitVector y_dir( 0.0, 1.0, 0.0 );
    double scale = mEvalData.base_radius_y * mEvalData.base_radius_x;

    pts[0] = base_pt + ( x_dir * mEvalData.base_radius_x );
    pts[1] = base_pt - ( x_dir * mEvalData.base_radius_x );
    pts[2] = base_pt + ( y_dir * mEvalData.base_radius_y );
    pts[3] = base_pt - ( y_dir * mEvalData.base_radius_y );
    pts[4] = top_pt  + ( x_dir * mEvalData.top_radius );
    pts[5] = top_pt  - ( x_dir * mEvalData.top_radius );
    pts[6] = top_pt  + ( y_dir * mEvalData.top_radius * scale );
    pts[7] = top_pt  - ( y_dir * mEvalData.top_radius * scale );

    for ( ipt = 0; ipt < 8; ipt++ )
    {
        pts[ipt] = mTmatrix * pts[ipt];
    }

    CubitVector min( pts[0] ),
                max( pts[0] );
    for ( ipt = 1; ipt < 8; ipt++ )
    {
        CubitVector *pt = &(pts[ipt]);
        if ( min.x() > pt->x() ) min.x( pt->x() );
        if ( min.y() > pt->y() ) min.y( pt->y() );
        if ( min.z() > pt->z() ) min.z( pt->z() );
        if ( max.x() < pt->x() ) max.x( pt->x() );
        if ( max.y() < pt->y() ) max.y( pt->y() );
        if ( max.z() < pt->z() ) max.z( pt->z() );
    }

    CubitBox thebbox( min, max );

    return thebbox;
}
CubitStatus CylinderEvaluator::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 123 of file CylinderEvaluator.cpp.

{
    CubitTransformMatrix inverse_Tmatrix = mTmatrix;
    inverse_Tmatrix.inverse();
    CubitVector new_pt = inverse_Tmatrix * location;
    CubitVector normal;
    double dist = sqrt( ( new_pt.x() * new_pt.x() ) + ( new_pt.y() * new_pt.y() ) );
    if ( dist < GEOMETRY_RESABS )
    {
        normal.set( 1.0, 0.0, 0.0 );
    }
    else
    {
        normal.set( new_pt.x(), new_pt.y(), 0.0 );
    }
    normal.normalize();
    if ( unit_normal_ptr )
    {
        CubitVector origin( 0.0, 0.0, 0.0 );
        CubitVector endpt( normal );

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

        *unit_normal_ptr = endpt - origin;
        unit_normal_ptr->normalize();
    }
    if ( closest_location != NULL )
    {
        CubitVector axis_pt( 0.0, 0.0, new_pt.z() );
        double v = axis_pt.z() - base().z();
        double radius = v * ( ( mEvalData.top_radius - mEvalData.base_radius_x ) / mEvalData.height ) + mEvalData.base_radius_x;

        *closest_location = axis_pt + ( radius * normal );
        *closest_location = mTmatrix * (*closest_location);
    }
    return CUBIT_SUCCESS;
}
const CubitEvaluatorData * CylinderEvaluator::evaluator_data ( void  ) const [virtual]

Implements CubitEvaluator.

Definition at line 225 of file CylinderEvaluator.cpp.

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

Implements CubitEvaluator.

Definition at line 235 of file CylinderEvaluator.cpp.

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

Implements CubitEvaluator.

Definition at line 250 of file CylinderEvaluator.cpp.

{
   lower_bound = 0.0;
   upper_bound = mEvalData.height;
   return CUBIT_TRUE;
}
virtual CubitBoolean CylinderEvaluator::is_closed_in_U ( ) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 63 of file CylinderEvaluator.hpp.

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

Implements CubitEvaluator.

Definition at line 64 of file CylinderEvaluator.hpp.

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

Implements CubitEvaluator.

Definition at line 55 of file CylinderEvaluator.hpp.

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

Implements CubitEvaluator.

Definition at line 56 of file CylinderEvaluator.hpp.

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

Implements CubitEvaluator.

Definition at line 57 of file CylinderEvaluator.hpp.

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

Implements CubitEvaluator.

Definition at line 59 of file CylinderEvaluator.hpp.

                                                                  { period = mEvalData.height;
                                                                    return CUBIT_FALSE; }
virtual CubitBoolean CylinderEvaluator::is_singular_in_U ( ) const [inline, virtual]

Implements CubitEvaluator.

Definition at line 61 of file CylinderEvaluator.hpp.

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

Implements CubitEvaluator.

Definition at line 62 of file CylinderEvaluator.hpp.

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

Implements CubitEvaluator.

Definition at line 170 of file CylinderEvaluator.cpp.

{
    double radius = v * ( ( mEvalData.top_radius - mEvalData.base_radius_x ) / mEvalData.height ) + mEvalData.base_radius_x;
    CubitVector base_pt = base();
    double two_pi = 2.0 * CUBIT_PI;

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

    double x = radius * sin( u );
    double y = radius * cos( u );
    double z = base_pt.z() + v;

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

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

Implements CubitEvaluator.

Definition at line 100 of file CylinderEvaluator.cpp.

{
    PRINT_ERROR("principles_curvatures not implemented for cylinders yet.\n");
    return CUBIT_FAILURE;

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

Implements CubitEvaluator.

Definition at line 194 of file CylinderEvaluator.cpp.

{
    CubitTransformMatrix inverse_Tmatrix = mTmatrix;
    inverse_Tmatrix.inverse();
    CubitVector transformed_pt = inverse_Tmatrix * location;
    CubitVector base_pt = base();
    CubitVector dir( transformed_pt.x(), transformed_pt.y(), 0.0 );
    dir.normalize();

    v = transformed_pt.z() - base_pt.z();
    u = acos( dir.y() );
    if ( dir.x() < 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