cgma
Curve Class Reference

#include <Curve.hpp>

Inheritance diagram for Curve:
GeometryEntity TopologyBridge CompositeCurve CurveSM FacetCurve OCCCurve PartitionCurve PartPTCurve SegmentedCurve SubCurve

List of all members.

Public Types

typedef TBPoint ChildType

Public Member Functions

 Curve ()
virtual ~Curve ()
virtual CubitSense relative_sense (Curve *other_curve)
virtual CubitStatus get_point_direction (CubitVector &origin, CubitVector &direction)
virtual CubitStatus get_center_radius (CubitVector &center, double &radius)=0
virtual double length_from_u (double parameter1, double parameter2)=0
virtual double get_arc_length ()
virtual double get_arc_length (const CubitVector &point1, const CubitVector &point2)
virtual double get_arc_length (const CubitVector &point1, const int which_end)
virtual CubitVector center_point ()
virtual CubitStatus mid_point (const CubitVector &point1, const CubitVector &point2, CubitVector &mid_point)
virtual CubitStatus mid_point (CubitVector &mid_point)
virtual CubitStatus position_from_fraction (const double fraction_along_curve, CubitVector &output_position)
virtual CubitBoolean is_periodic (double &period)=0
virtual CubitBoolean get_param_range (double &lower_bound, double &upper_bound)=0
virtual CubitStatus get_interior_extrema (DLIList< CubitVector * > &interior_points, CubitSense &return_sense)=0
virtual CubitStatus closest_point (CubitVector const &location, CubitVector &closest_location, CubitVector *tangent_ptr=NULL, CubitVector *curvature_ptr=NULL, double *param=NULL)=0
virtual CubitStatus closest_point_trimmed (CubitVector const &from_pt, CubitVector &result_pt)
virtual CubitPointContainment point_containment (const CubitVector &point)=0
virtual double u_from_position (const CubitVector &input_position)=0
virtual CubitStatus position_from_u (double u_value, CubitVector &output_position)=0
virtual double u_from_arc_length (double root_param, double arc_length)=0
virtual CubitBoolean is_position_on (const CubitVector &test_position)=0
virtual GeometryType geometry_type ()
virtual double start_param ()=0
virtual double end_param ()=0
virtual CubitStatus point_from_arc_length (double root_param, const double arc_length, CubitVector &new_point)
virtual CubitStatus point_from_arc_length (const CubitVector &root_point, double const arc_length, CubitVector &new_point)
virtual CubitBoolean is_tolerant ()
virtual CubitBoolean G1_discontinuous (double u, CubitVector *minus_tangent=NULL, CubitVector *plus_tangent=NULL)
virtual CubitStatus get_spline_params (bool &rational, int &degree, DLIList< CubitVector > &cntrl_pts, DLIList< double > &cntrl_pt_weights, DLIList< double > &knots, bool &spline_is_reversed) const =0
virtual CubitStatus get_ellipse_params (CubitVector &center, CubitVector &normal, CubitVector &major_axis, double &radius_ratio) const =0

Detailed Description

Definition at line 37 of file Curve.hpp.


Member Typedef Documentation

Definition at line 47 of file Curve.hpp.


Constructor & Destructor Documentation

Definition at line 42 of file Curve.cpp.

{}
Curve::~Curve ( ) [virtual]

Definition at line 55 of file Curve.cpp.

{}

Member Function Documentation

CubitVector Curve::center_point ( ) [inline, virtual]

Definition at line 417 of file Curve.hpp.

{
  double s_param = start_param();
  double length = 0.5 * measure();
  double param2 = u_from_arc_length(s_param, length);
  CubitVector center;
  position_from_u(param2, center);
  return center;
}
virtual CubitStatus Curve::closest_point ( CubitVector const &  location,
CubitVector closest_location,
CubitVector tangent_ptr = NULL,
CubitVector curvature_ptr = NULL,
double *  param = NULL 
) [pure virtual]
CubitStatus Curve::closest_point_trimmed ( CubitVector const &  from_pt,
CubitVector result_pt 
) [virtual]

Reimplemented in CompositeCurve, and SegmentedCurve.

Definition at line 203 of file Curve.cpp.

{
    // Get the untrimmed point
  double param;
  if ( !closest_point(from_pt, result, NULL, NULL, &param) )
    return CUBIT_FAILURE;  
  
  double param_range = 0.0;
  double period, start_param, end_param;
  
    // Get whether periodic
  CubitBoolean is_per = this->is_periodic(period);
    // Get the parameter range
  get_param_range( start_param, end_param );
  
    // Make sure the start_param is lower than end_param.
  if (start_param > end_param)
  {
      // use param_range as temp
    param_range = start_param;
    start_param = end_param;
    end_param = param_range;
  }
  param_range = end_param - start_param;
  
    // If the Curve does not loop onto itself...
  if(  is_per == CUBIT_FALSE  ||
       param_range < period)
  {
      // If not within parameter range, return
      // the the closest endpoint
    CubitVector start, end;
    position_from_u( start_param, start );
    position_from_u( end_param, end );

    if( (param < start_param) || (param > end_param) )
    {
      result = ( (start - result).length_squared() < 
                 (end - result).length_squared() ) ? start : end ;
    }
    else
    {
      double tmp_dist_sq = (from_pt - result).length_squared();
      if( (start-from_pt).length_squared() < tmp_dist_sq )
        result = start;
      else if( (end-from_pt).length_squared() < tmp_dist_sq )
        result = end;
    }
  }

  
  return CUBIT_SUCCESS;
}
virtual double Curve::end_param ( ) [pure virtual]
CubitBoolean Curve::G1_discontinuous ( double  u,
CubitVector minus_tangent = NULL,
CubitVector plus_tangent = NULL 
) [virtual]

Reimplemented in OCCCurve, FacetCurve, CompositeCurve, SegmentedCurve, PartPTCurve, and SubCurve.

Definition at line 267 of file Curve.cpp.

{
    double start_param, end_param;
    if( ! get_param_range( start_param, end_param ) ) return CUBIT_FALSE;
    //if the curve is not parametric, just return false.
    if( start_param > end_param )
    {
        double tmp = start_param;
        start_param = end_param;
        end_param = tmp;
    }
    
    double u_minus = (2 * CUBIT_RESABS);
    double u_plus = u_minus;
    
    //can't be C1 discontinous at an end point!
    if( ((u - u_minus) < start_param) || ((u + u_plus) > end_param) )
        return CUBIT_FALSE;

    CubitVector position;
    position_from_u( u, position );
    const double res_abs_sqr = CUBIT_RESABS * CUBIT_RESABS;

    CubitVector minus_position, minus_tangent;
    position_from_u( u - u_minus, minus_position );
    double u_minus2 = u_from_position( minus_position );
    minus_tangent = position - minus_position;

    while( ((u - u_minus2) > (u - CUBIT_RESABS)) || 
           (minus_tangent.length_squared() < res_abs_sqr) )
    {
        u_minus *= 10.;
        //can't be C1 discontinous at an end point!
        if( (u - u_minus) < start_param ) return CUBIT_FALSE;
        position_from_u( u - u_minus, minus_position );
        u_minus2 = u_from_position( minus_position );
        minus_tangent = position - minus_position;
    }
    
    CubitVector plus_position, plus_tangent;
    position_from_u( u + u_plus, plus_position );
    double u_plus2 = u_from_position( plus_position );
    plus_tangent = plus_position - position;
    
    while( ((u + u_plus2) < (u + CUBIT_RESABS)) ||
           ((position - plus_position).length_squared() < res_abs_sqr) )
    {
        u_plus *= 10.;
        //can't be C1 discontinous at an end point!
        if( (u + u_plus) > end_param ) return CUBIT_FALSE;
        position_from_u( u + u_plus, plus_position );
        u_plus2 = u_from_position( plus_position );
        plus_tangent = plus_position - position;
    }
    
    plus_tangent.normalize();
    minus_tangent.normalize();
    if( (plus_tangent * minus_tangent).length_squared() > (2 * res_abs_sqr) )
    {
        if( plus_tangent_r ) *plus_tangent_r = plus_tangent;
        if( minus_tangent_r ) * minus_tangent_r = minus_tangent;
        return CUBIT_TRUE;
    }
    
    return CUBIT_FALSE; 
}
virtual GeometryType Curve::geometry_type ( ) [inline, virtual]

Implements GeometryEntity.

Reimplemented in OCCCurve, FacetCurve, CompositeCurve, PartPTCurve, and SubCurve.

Definition at line 300 of file Curve.hpp.

double Curve::get_arc_length ( ) [inline, virtual]

Definition at line 390 of file Curve.hpp.

{
  return measure();
}
double Curve::get_arc_length ( const CubitVector point1,
const CubitVector point2 
) [inline, virtual]

Definition at line 396 of file Curve.hpp.

{
  double param1 = u_from_position(point1);
  double param2 = u_from_position(point2);
  return fabs(length_from_u(param1, param2));
}
double Curve::get_arc_length ( const CubitVector point1,
const int  which_end 
) [inline, virtual]

Definition at line 405 of file Curve.hpp.

{
  double param1 = u_from_position(point1);
  double param2;
  if (which_end == 0) param2 = start_param();
  else param2 = end_param();
  
  return fabs(length_from_u(param1, param2));
}
CubitStatus Curve::get_center_radius ( CubitVector center,
double &  radius 
) [pure virtual]

Implemented in OCCCurve, FacetCurve, CompositeCurve, PartPTCurve, SubCurve, and SegmentedCurve.

Definition at line 80 of file Curve.cpp.

{
  CubitVector start_pos, closest_pos;
  if ( position_from_u(start_param(), start_pos) &&
       closest_point(start_pos, closest_pos, 0, &c) ) 
  {
    r = c.length();
    if (r > CUBIT_RESABS) 
    {
      r = 1.0 / r;
      c *= r * r;
      c += closest_pos;
      return CUBIT_SUCCESS;
    }
  }
  return CUBIT_FAILURE; 
}
virtual CubitStatus Curve::get_ellipse_params ( CubitVector center,
CubitVector normal,
CubitVector major_axis,
double &  radius_ratio 
) const [pure virtual]
virtual CubitStatus Curve::get_interior_extrema ( DLIList< CubitVector * > &  interior_points,
CubitSense return_sense 
) [pure virtual]
virtual CubitBoolean Curve::get_param_range ( double &  lower_bound,
double &  upper_bound 
) [pure virtual]
CubitStatus Curve::get_point_direction ( CubitVector origin,
CubitVector direction 
) [virtual]

Reimplemented in OCCCurve, FacetCurve, CompositeCurve, and SegmentedCurve.

Definition at line 74 of file Curve.cpp.

{
   return CUBIT_FAILURE;
}
virtual CubitStatus Curve::get_spline_params ( bool &  rational,
int &  degree,
DLIList< CubitVector > &  cntrl_pts,
DLIList< double > &  cntrl_pt_weights,
DLIList< double > &  knots,
bool &  spline_is_reversed 
) const [pure virtual]
virtual CubitBoolean Curve::is_periodic ( double &  period) [pure virtual]
virtual CubitBoolean Curve::is_position_on ( const CubitVector test_position) [pure virtual]
virtual CubitBoolean Curve::is_tolerant ( ) [inline, virtual]

Definition at line 331 of file Curve.hpp.

{ return CUBIT_FALSE; };
virtual double Curve::length_from_u ( double  parameter1,
double  parameter2 
) [pure virtual]
CubitStatus Curve::mid_point ( const CubitVector point1,
const CubitVector point2,
CubitVector mid_point 
) [inline, virtual]

Definition at line 447 of file Curve.hpp.

{
  double param1 = u_from_position(point1);
  double param2 = u_from_position(point2);
  param1 = 0.5 * (param1 + param2);
  return position_from_u(param1, midpoint);
}
CubitStatus Curve::mid_point ( CubitVector mid_point) [inline, virtual]

Definition at line 428 of file Curve.hpp.

{
  double param1 = 0.5 * (start_param() + end_param());
  
  return position_from_u(param1, midpoint);
}
CubitStatus Curve::point_from_arc_length ( double  root_param,
const double  arc_length,
CubitVector new_point 
) [virtual]

Definition at line 136 of file Curve.cpp.

{
  double low_param = start_param();
  double high_param = end_param();

  if (high_param < low_param)
  {
    double temp = high_param;
    high_param = low_param;
    low_param = temp;
  }

    // Comment: The way we handle points not on the bounded curve is
    //          different for periodic and non-periodic curves!
    //          Periodic curves leave the parameter off of the curve,
    //          while non-periodic curves move the point to the closest
    //          endpoint.  Just an observation!
  
  
    // Adjust the parameter for periodic curves
  double periodic_param;

  if ( is_periodic( periodic_param ))
  {
    while (root_param < low_param)
      root_param += periodic_param;
    while (root_param > high_param)
      root_param -= periodic_param;
      // If you're moving in the positive direction and
      // you're almost at the start point...
    if (fabs( this->end_param() - root_param ) <= CUBIT_RESABS &&
        arc_length > 0.0 )
    {
        //the root param should be switched with the start param.
      root_param = this->start_param();
    }
      // If you're moving in the negative direction and
      // you're almost at the end point...
    else if (fabs( this->start_param() - root_param ) <= CUBIT_RESABS &&
             arc_length < 0.0 )
    {
      root_param = this->end_param();
    }
  }
  else if ( root_param < (low_param + CUBIT_RESABS) )
    root_param = low_param;
  else if ( root_param > (high_param - CUBIT_RESABS) )
    root_param = high_param;
 
    // Get the parameter value of the new point
  double new_param = this->u_from_arc_length( root_param,
                                              arc_length );
  
    // Now get the coordinates (in world space) representing this parameter
    // value
  return this->position_from_u(new_param, new_point);
}
CubitStatus Curve::point_from_arc_length ( const CubitVector root_point,
double const  arc_length,
CubitVector new_point 
) [virtual]

Definition at line 112 of file Curve.cpp.

{
    // Get the parameter value of the root point
  double root_param = u_from_position( root_point );
  return point_from_arc_length(root_param, arc_length, new_point);
}
CubitStatus Curve::position_from_fraction ( const double  fraction_along_curve,
CubitVector output_position 
) [inline, virtual]

Definition at line 436 of file Curve.hpp.

{
  CubitStatus result = CUBIT_FAILURE;
  double param_1 = start_param() +
    fraction_along_curve * (end_param() - start_param() );
  result = position_from_u( param_1, output_position );
  return result;
}
virtual CubitStatus Curve::position_from_u ( double  u_value,
CubitVector output_position 
) [pure virtual]
CubitSense Curve::relative_sense ( Curve other_curve) [virtual]

Definition at line 58 of file Curve.cpp.

{
  CubitVector center, junk, this_tangent, other_tangent;
  double start, end;
  
  if (!get_param_range(start,end)                 ||
      !position_from_u(0.5*(start+end), center)   ||
      !closest_point(center, junk, &this_tangent) ||
      !other_curve->closest_point(center, junk, &other_tangent))
    return CUBIT_UNKNOWN;
  
  double dot = this_tangent % other_tangent;
  return dot == 0.0 ? CUBIT_UNKNOWN : dot > 0. ? CUBIT_FORWARD : CUBIT_REVERSED;
}
virtual double Curve::start_param ( ) [pure virtual]
virtual double Curve::u_from_arc_length ( double  root_param,
double  arc_length 
) [pure virtual]
virtual double Curve::u_from_position ( const CubitVector input_position) [pure virtual]

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