cgma
CubitFacetEdge Class Reference

#include <CubitFacetEdge.hpp>

Inheritance diagram for CubitFacetEdge:
FacetEntity ToolDataUser CubitFacetEdgeData

List of all members.

Public Member Functions

 CubitFacetEdge ()
virtual ~CubitFacetEdge ()
virtual int id ()=0
virtual void set_id (int)
int is_flipped ()
void is_flipped (int flipped)
void toggle_is_flipped ()
virtual CubitPointpoint (int index)=0
virtual CubitFacetadj_facet (int index)=0
virtual int bezier_order ()
virtual int control_points (CubitVector *ctrl_pts)
virtual CubitVectorcontrol_points ()
virtual void control_points (CubitVector *ctrl_pts, int order)
virtual CubitStatus control_points (CubitFacet *facet, CubitVector *ctrl_pts)
virtual void get_control_points (CubitPoint *point_ptr, CubitVector ctrl_pts[3])
virtual void set_control_points (CubitPoint *point_ptr, CubitVector ctrl_pts[3])
void set_control_points (const double *ctrl_pt_array)
virtual void set_flag (int my_flag)
virtual int get_flag ()
virtual void facets (DLIList< CubitFacet * > &facet_list)=0
virtual void edges (DLIList< CubitFacetEdge * > &edge_list)=0
virtual void points (DLIList< CubitPoint * > &point_list)=0
virtual int num_adj_facets ()=0
void tris (DLIList< CubitFacet * > &facet_list)
void tris (int *, DLIList< CubitFacet * > &facet_list)
virtual void add_facet (CubitFacet *)
virtual CubitStatus remove_facet (CubitFacet *)=0
virtual CubitPointstart_node ()=0
virtual CubitPointend_node ()=0
virtual void flip ()=0
virtual int number_tris ()
virtual int number_faces ()
virtual void marked (int my_flag)
virtual int marked ()
CubitStatus evaluate_position (const CubitVector &start_position, CubitVector *eval_point, CubitVector *eval_tangent)
CubitStatus evaluate (double &t, CubitVector *eval_point, CubitVector *eval_tangent)
CubitStatus evaluate_single (double &t, CubitVector *outv)
CubitStatus evaluate_single_tangent (double &t, CubitVector *outv)
CubitStatus evaluate_2nd_derivative (double &t, CubitVector *outv)
CubitStatus closest_point (const CubitVector &point, CubitVector &closest_point)
CubitStatus intersect (CubitVector &aa, CubitVector &bb, CubitVector &norm, CubitVector &qq, CubitBoolean &does_intersect)
void boundary_edge_points (CubitPoint *&pt0, CubitPoint *&pt1, int tool_id=0)
double dist_to_edge (const CubitVector &this_point, CubitVector &close_point, CubitBoolean &outside_edge)
CubitStatus proj_to_line (const CubitVector &this_point, CubitVector &proj_point)
CubitStatus edge_tangent (const CubitVector &point_on_edge, CubitVector &tangent)
CubitStatus edge_curvature (const CubitVector &point_on_edge, CubitVector &curvature, CubitFacetEdge *closest_edge)
double length ()
CubitVector position_from_fraction (double zero_to_one)
CubitVector center ()
CubitPointother_point (CubitPoint *point_ptr)
void get_parents (DLIList< FacetEntity * > &facet_list)
CubitFacetother_facet (CubitFacet *facet_ptr)
CubitFacetother_facet_on_surf (CubitFacet *facet_ptr)
int num_adj_facets_on_surf (int tool_id)
CubitFacetadj_facet_on_surf (int tool_id)
CubitBoolean contains (CubitPoint *point_ptr)
void set_as_feature ()
CubitBoolean is_feature ()
void debug_draw (int color=-1, int flush=1, int draw_uv=0)
CubitPointshared_point (CubitFacetEdge *edge_ptr)
void add_facets ()
CubitBox bounding_box ()
double angle_between_facets ()
int less_than (CubitFacetEdge *&e1, CubitFacetEdge *&e2)

Static Public Member Functions

static int intersect_2D_segments (double P0[2], double P1[2], double P2[2], double P3[2], double qq[4])
static int intersect_intervals (double u0, double u1, double v0, double v1, double w[2])
static CubitStatus order_edge_list (DLIList< CubitFacetEdge * > &edge_list, CubitPoint *start_point, CubitPoint *&end_point)
static CubitPointfind_start_point_for_edge_list (DLIList< CubitFacetEdge * > edge_list)

Protected Attributes

CubitVector controlPoints [3]
int bezierOrder
int markedFlag
IttyBit isFeature
CubitBoolean isFlipped

Detailed Description

Definition at line 38 of file CubitFacetEdge.hpp.


Constructor & Destructor Documentation

Definition at line 41 of file CubitFacetEdge.cpp.

{ 
} 

Member Function Documentation

virtual void CubitFacetEdge::add_facet ( CubitFacet ) [inline, virtual]

Reimplemented in CubitFacetEdgeData.

Definition at line 122 of file CubitFacetEdge.hpp.

{ assert(0); }

Definition at line 1082 of file CubitFacetEdge.cpp.

{
  CubitPoint *p0 = point (0);
  CubitPoint *p1 = point (1);

  DLIList<CubitFacet *> adj_facets;
  p0->shared_facets(p1, adj_facets );

  CubitFacet *facet;
  int ii;
  for(ii=0; ii<adj_facets.size(); ii++)
  {
    facet = adj_facets.get_and_step();
    facet->add_edge( this );
  }
}
virtual CubitFacet* CubitFacetEdge::adj_facet ( int  index) [pure virtual]

Implemented in CubitFacetEdgeData.

Definition at line 854 of file CubitFacetEdge.cpp.

{ 
  DLIList<CubitFacet *> cf_list; 
  facets( cf_list ); 
  CubitFacet *adj_facet = NULL; 
  int found = 0; 
  for (int ii=0; ii<cf_list.size() && !found; ii++) 
  { 
    adj_facet = cf_list.get_and_step(); 
    if (adj_facet->tool_id() == tool_id) 
    { 
      found = 1; 
    } 
  } 
  if (!found) 
    adj_facet = NULL; 
  return adj_facet; 
} 

Definition at line 1099 of file CubitFacetEdge.cpp.

{
  CubitFacet *facet0 = adj_facet(0);
  CubitFacet *facet1 = adj_facet(1);

  // assumes facets are always oriented with outwards pointing normal

  CubitVector n0 = facet0->normal();
  CubitVector n1 = facet1->normal();

  // get orientation of edge with respect to facet0

  CubitPoint *p0 = point(0);
  CubitPoint *p1 = point(1);
  CubitPoint *pnext = facet0->next_node(p0);
  if (pnext != p1)
  {
    pnext = p0;
    p0 = p1;
    p1 = pnext;
  }
  CubitVector evec = p1->coordinates() - p0->coordinates();
  evec.normalize();
  CubitVector cross = n0 * n1;  cross.normalize();
  double angle;
  double edot = evec % cross;
  double ndot = n0 % n1;
  if (ndot >= 1.0)
    angle = 0.0;
  else if (ndot <= -1.0)
    angle = CUBIT_PI;
  else 
    angle = acos(ndot);
  if (edot <= 0.0)
  {
    angle = 2.0 * CUBIT_PI - angle;
  }
  return angle;
}
virtual int CubitFacetEdge::bezier_order ( ) [inline, virtual]

Definition at line 90 of file CubitFacetEdge.hpp.

{return bezierOrder;};
void CubitFacetEdge::boundary_edge_points ( CubitPoint *&  pt0,
CubitPoint *&  pt1,
int  tool_id = 0 
)

Definition at line 492 of file CubitFacetEdge.cpp.

{ 
  if(num_adj_facets() == 0) 
  { 
    pt0 = point(0); 
    pt1 = point(1); 
    return; 
  } 
  CubitFacet *facet = NULL; 
  if (tool_id != 0) 
  { 
    int ii; 
    int found = 0; 
    DLIList <CubitFacet *> adj_facets; 
    facets(adj_facets); 
    for (ii=0; ii<adj_facets.size() && !found; ii++) 
    { 
      facet = adj_facets.get_and_step(); 
      if (facet->tool_id() == tool_id) 
        found = 1; 
    } 
    assert(found); 
  } 
  else 
  { 
    facet = adj_facet(0); 
    if (!facet) facet = adj_facet(1); 
    assert(facet != 0); 
  } 
   
  int index = facet->edge_index( this ); 
  int use = facet->edge_use( index ); 
  if (use == 1) { 
    pt0 = point(0); 
    pt1 = point(1); 
  } 
  else { 
    pt0 = point(1); 
    pt1 = point(0); 
  } 
} 

Definition at line 934 of file CubitFacetEdge.cpp.

{
  CubitPoint *p1 = point (0);
  CubitPoint *p2 = point (1);

  CubitVector bbox_min, bbox_max;
  bbox_min.x(CUBIT_MIN(p1->x(),p2->x()));
  bbox_min.y(CUBIT_MIN(p1->y(),p2->y()));
  bbox_min.z(CUBIT_MIN(p1->z(),p2->z()));
  bbox_max.x(CUBIT_MAX(p1->x(),p2->x()));
  bbox_max.y(CUBIT_MAX(p1->y(),p2->y()));
  bbox_max.z(CUBIT_MAX(p1->z(),p2->z()));
  CubitBox edge_box(bbox_min,bbox_max);
  return edge_box;
}

Definition at line 184 of file CubitFacetEdge.hpp.

{ return position_from_fraction(0.5); }
CubitStatus CubitFacetEdge::closest_point ( const CubitVector point,
CubitVector closest_point 
)

Definition at line 381 of file CubitFacetEdge.cpp.

{  
  //CubitStatus rv = CUBIT_SUCCESS; 
  CubitPoint *pt0 = this->point(0); 
  CubitPoint *pt1 = this->point(1); 
 
  // the edge vector 
 
  CubitVector e0 ( pt1->x() - pt0->x(), 
                   pt1->y() - pt0->y(), 
                   pt1->z() - pt0->z() ); 
  double elen = e0.normalize(); 
   
  // vector from vert0 to point 
 
  CubitVector v0 ( point.x() - pt0->x(), 
                   point.y() - pt0->y(), 
                   point.z() - pt0->z() ); 
   
  // project to edge 
 
  double len = v0%e0; 
  if (len <= 0.0) 
  { 
    closest_point = pt0->coordinates(); 
  } 
  else if( len >= elen ) 
  { 
    closest_point = pt1->coordinates(); 
  } 
  else 
  { 
    closest_point.x ( pt0->x() + e0.x() * len ); 
    closest_point.y ( pt0->y() + e0.y() * len ); 
    closest_point.z ( pt0->z() + e0.z() * len ); 
  } 
 
  return CUBIT_SUCCESS; 
}

Definition at line 879 of file CubitFacetEdge.cpp.

{ 
  if (point(0) == point_ptr || point(1) == point_ptr) 
    return CUBIT_TRUE; 
  return CUBIT_FALSE; 
} 
int CubitFacetEdge::control_points ( CubitVector ctrl_pts) [virtual]

Definition at line 69 of file CubitFacetEdge.cpp.

{ 
  DLIList<CubitPoint*> my_points; 
  points(my_points); 
   
  ctrl_pts[0] = my_points.get()->coordinates(); 
  for(int i=0; i<bezierOrder-1; i++) { 
    ctrl_pts[i+1] = controlPoints[i]; 
  } 
  ctrl_pts[bezierOrder] = my_points.next()->coordinates(); 
  return bezierOrder; 
}
virtual CubitVector* CubitFacetEdge::control_points ( ) [inline, virtual]

Definition at line 93 of file CubitFacetEdge.hpp.

{ return controlPoints; };
void CubitFacetEdge::control_points ( CubitVector ctrl_pts,
int  order 
) [inline, virtual]

Definition at line 250 of file CubitFacetEdge.hpp.

{
  assert(order > 0 && order <=4);
  bezierOrder = order;
  for(int i=0; i<order-1; i++){
    controlPoints[i] = ctrl_pts[i];
  }
}
CubitStatus CubitFacetEdge::control_points ( CubitFacet facet,
CubitVector ctrl_pts 
) [virtual]

Definition at line 89 of file CubitFacetEdge.cpp.

{ 
  int index = -1; 
  CubitBoolean found = CUBIT_FALSE; 
  for (int i=0; i<3 && !found; i++) { 
    if (this == facet->edge(i)) { 
      index = i; 
      found = CUBIT_TRUE; 
    } 
  } 
  if (!found) { 
    return CUBIT_FAILURE; 
  } 
 
  DLIList<CubitPoint*> my_points; 
  points(my_points); 
   
  switch (facet->edge_use(index)) { 
  case 1: 
    ctrl_pts[0] = my_points.get()->coordinates(); 
    ctrl_pts[1] = controlPoints[0]; 
    ctrl_pts[2] = controlPoints[1]; 
    ctrl_pts[3] = controlPoints[2]; 
    ctrl_pts[4] = my_points.next()->coordinates(); 
    break; 
  case -1: 
    ctrl_pts[0] = my_points.next()->coordinates(); 
    ctrl_pts[1] = controlPoints[2]; 
    ctrl_pts[2] = controlPoints[1]; 
    ctrl_pts[3] = controlPoints[0]; 
    ctrl_pts[4] = my_points.get()->coordinates(); 
    break; 
  default: 
    return CUBIT_FAILURE; 
  } 
  return CUBIT_SUCCESS; 
} 
void CubitFacetEdge::debug_draw ( int  color = -1,
int  flush = 1,
int  draw_uv = 0 
) [virtual]

Implements FacetEntity.

Definition at line 892 of file CubitFacetEdge.cpp.

{ 
  if ( color == -1 ) 
    color = CUBIT_RED_INDEX;
  GfxDebug::draw_facet_edge(this, color);
  GfxDebug::draw_point( point(0)->coordinates(), color );
  GfxDebug::draw_point( point(1)->coordinates(), color );
  if ( flush ) 
    GfxDebug::flush(); 
} 
double CubitFacetEdge::dist_to_edge ( const CubitVector this_point,
CubitVector close_point,
CubitBoolean outside_edge 
)

Definition at line 543 of file CubitFacetEdge.cpp.

{ 
  double dist = 0.0; 
  CubitVector p0 = point(0)->coordinates(); 
  CubitVector p1 = point(1)->coordinates(); 
  CubitVector edge_vec( p1, p0 ); 
  CubitVector point_vec( this_point, p0 ); 
  double edge_length;  
  edge_length = edge_vec.normalize(); 
  double dist_on_edge = edge_vec % point_vec; 
  if (dist_on_edge < 0.0e0) 
  { 
    close_point = p0; 
    outside_edge = CUBIT_TRUE; 
  } 
  else if (dist_on_edge > edge_length) 
  { 
    close_point = p1; 
    outside_edge = CUBIT_TRUE; 
  } 
  else 
  { 
    close_point = p0 - edge_vec * dist_on_edge; 
    outside_edge = CUBIT_FALSE; 
  } 
  dist = close_point.distance_between( this_point );  
  return dist; 
}
CubitStatus CubitFacetEdge::edge_curvature ( const CubitVector point_on_edge,
CubitVector curvature,
CubitFacetEdge closest_edge 
)

Definition at line 659 of file CubitFacetEdge.cpp.

{ 
  CubitVector vec_ba, vec_ca, center_point;

  //if point(0) is middle point
  if( closest_edge->other_point( point(0) ) )  
  {
    center_point = point(0)->coordinates();
    vec_ba = closest_edge->point(0)->coordinates() - center_point; 
    vec_ca = point(1)->coordinates() - center_point; 
  }
  //if point(1) is middle point
  else if( closest_edge->other_point( point(1) ) )  
  {
    center_point = point(1)->coordinates();
    vec_ba = point(0)->coordinates() - center_point; 
    vec_ca = closest_edge->point(1)->coordinates() - center_point; 
  }
  else
    assert(0);
  
  // Squares of lengths of the edges incident to `a'.
  double ba_length = vec_ba.length_squared();
  double ca_length = vec_ca.length_squared();
  
  // Cross product of these edges.
  // (Take your chances with floating-point roundoff.)
  CubitVector cross_bc = vec_ba * vec_ca;
  
  // Calculate the denominator of the formulae.
  double temp_dbl = cross_bc % cross_bc;
  CubitVector circle_center(0.0,0.0,0.0);
  if(fabs(temp_dbl) > CUBIT_DBL_MIN){
    double denominator = 0.5 / (temp_dbl);
    assert(denominator != 0.0);
  
    // Calculate offset (from `a') of circumcenter.
    circle_center  = (ba_length * vec_ca - ca_length * vec_ba) * cross_bc;
    circle_center *= denominator;

    //store radius
    double radius = circle_center.length();
    circle_center.normalize();
    circle_center /= radius;
  } 
  curvature = circle_center; 

  return CUBIT_SUCCESS; 
} 
CubitStatus CubitFacetEdge::edge_tangent ( const CubitVector point_on_edge,
CubitVector tangent 
)

Definition at line 642 of file CubitFacetEdge.cpp.

{ 
  CubitStatus stat = CUBIT_SUCCESS; 
  tangent = point(1)->coordinates() - 
            point(0)->coordinates(); 
  tangent.normalize(); 
  return stat; 
}
virtual void CubitFacetEdge::edges ( DLIList< CubitFacetEdge * > &  edge_list) [pure virtual]

Implements FacetEntity.

Implemented in CubitFacetEdgeData.

virtual CubitPoint* CubitFacetEdge::end_node ( ) [pure virtual]

Implemented in CubitFacetEdgeData.

CubitStatus CubitFacetEdge::evaluate ( double &  t,
CubitVector eval_point,
CubitVector eval_tangent 
)

Definition at line 204 of file CubitFacetEdge.cpp.

{ 
  CubitStatus stat = CUBIT_SUCCESS; 
 
  // project the position to the linear edge 
   
  double tt = (t + 1) * 0.5; 
  if (tt <= 0.0) tt = 0.0; 
  if (tt >= 1.0) tt = 1.0; 
  *eval_point = point(0)->coordinates() +  
    tt * (point(1)->coordinates() - point(0)->coordinates()); 
 
  // evaluate the point on the facet (if the order is higher than 0) 
 
  CubitFacet *facet_ptr = this->adj_facet( 0 ); 
  if (!facet_ptr || facet_ptr->is_flat()) 
  { 
    if (eval_tangent) 
    { 
      *eval_tangent = point(1)->coordinates() - point(0)->coordinates(); 
      (*eval_tangent).normalize(); 
    } 
  } 
  else 
  { 
    CubitVector areacoord; 
    FacetEvalTool::facet_area_coordinate( facet_ptr, *eval_point, areacoord ); 
    stat = facet_ptr->evaluate( areacoord, eval_point, eval_tangent ); 
    if (stat != CUBIT_SUCCESS) 
      return stat; 
    if (eval_tangent) 
    { 
      CubitVector edvec = point(1)->coordinates() - point(0)->coordinates(); 
      edvec.normalize(); 
      CubitVector cross = edvec * *eval_tangent; 
      *eval_tangent = *eval_tangent * cross; 
      (*eval_tangent).normalize(); 
    } 
  } 
  return stat; 
} 

Definition at line 335 of file CubitFacetEdge.cpp.

{
CubitVector P0, P1, second_d;
DLIList<CubitPoint*> my_points; 
double val;
  // project the position to the linear edge 
   
  double tt = (t + 1) * 0.5; 
  if (tt <= 0.0) tt = 0.0; 
  if (tt >= 1.0) tt = 1.0; 

  points(my_points);
 
  P0 = my_points.get()->coordinates();
  P1 = my_points.next()->coordinates();

  val = 12.*(1.-tt)*(1.-tt)*P0.x() -
        24.*(2.*tt*tt - 3.*tt + 1.)*controlPoints[0].x() +
        12.*(6.*tt*tt - 6.*tt + 1.)*controlPoints[1].x() +
        24.*(tt - 2.*tt*tt)*controlPoints[2].x() +
        12.*tt*tt*P1.x();
  second_d.x(val);
  val = 12.*(1.-tt)*(1.-tt)*P0.y() -
        24.*(2.*tt*tt - 3.*tt + 1.)*controlPoints[0].y() +
        12.*(6.*tt*tt - 6.*tt + 1.)*controlPoints[1].y() +
        24.*(tt - 2.*tt*tt)*controlPoints[2].y() +
        12.*tt*tt*P1.y();
  second_d.y(val);
  val = 12.*(1.-tt)*(1.-tt)*P0.z() -
        24.*(2.*tt*tt - 3.*tt + 1.)*controlPoints[0].z() +
        12.*(6.*tt*tt - 6.*tt + 1.)*controlPoints[1].z() +
        24.*(tt - 2.*tt*tt)*controlPoints[2].z() +
        12.*tt*tt*P1.z();
  second_d.z(val);
  *outv = second_d;
  
  return CUBIT_SUCCESS;
}
CubitStatus CubitFacetEdge::evaluate_position ( const CubitVector start_position,
CubitVector eval_point,
CubitVector eval_tangent 
)

Definition at line 135 of file CubitFacetEdge.cpp.

{ 
  CubitStatus stat = CUBIT_SUCCESS; 
 
  // find the adjacent facet 
 
  CubitFacet *facet_ptr = this->adj_facet( 0 ); 
 
  // If there is none or this is a linear representation -  
  // then project to the linear edge  
 
  if (!facet_ptr || facet_ptr->eval_order() == 0 || facet_ptr->is_flat()) 
  { 
    if (eval_point) 
    { 
      closest_point(start_position, *eval_point); 
    } 
    if (eval_tangent) 
    { 
      *eval_tangent = point(1)->coordinates() - point(0)->coordinates(); 
      (*eval_tangent).normalize(); 
    } 
  } 
  else 
  { 
    int vert0 = facet_ptr->point_index( point(0) ); 
    int vert1 = facet_ptr->point_index( point(1) ); 
    CubitVector pt_on_plane, close_point; 
    CubitVector start = start_position; 
    double dist_to_plane; 
    CubitBoolean outside_facet; 
    FacetEvalTool::project_to_facet_plane( facet_ptr, start,  
                                           pt_on_plane, dist_to_plane ); 
    stat = FacetEvalTool::project_to_facetedge( facet_ptr,  
                                                vert0, vert1, 
                                                start, 
                                                pt_on_plane,  
                                                close_point, 
                                                outside_facet ); 
    if (eval_point) 
    { 
      *eval_point = close_point; 
    } 
    if (eval_tangent) 
    { 
      CubitVector edvec = point(1)->coordinates() - point(0)->coordinates(); 
      edvec.normalize(); 
      CubitVector areacoord; 
      FacetEvalTool::facet_area_coordinate( facet_ptr, close_point, areacoord );  
      FacetEvalTool::eval_facet_normal(facet_ptr, areacoord, *eval_tangent); 
      CubitVector cross = edvec * *eval_tangent; 
      *eval_tangent = *eval_tangent * cross; 
      (*eval_tangent).normalize(); 
    } 
  }

  return stat;
} 

Definition at line 255 of file CubitFacetEdge.cpp.

{
CubitVector P0, P1;
double t4, t3, t2, one_minus_t, one_minus_t2, one_minus_t3, one_minus_t4;
DLIList<CubitPoint*> my_points; 
  // project the position to the linear edge 
   
  double tt = (t + 1) * 0.5; 
  if (tt <= 0.0) tt = 0.0; 
  if (tt >= 1.0) tt = 1.0; 

  points(my_points);
 
  P0 = my_points.get()->coordinates();
  P1 = my_points.next()->coordinates();

  t2 = tt*tt;
  t3 = t2*tt;
  t4 = t3*tt;  
  one_minus_t = 1.-tt;
  one_minus_t2 = one_minus_t*one_minus_t;
  one_minus_t3 = one_minus_t2*one_minus_t;
  one_minus_t4 = one_minus_t3*one_minus_t;
  
  *outv = one_minus_t4*P0 + 
       4.*one_minus_t3*tt* controlPoints[0] + 
       6.*one_minus_t2*t2*controlPoints[1] + 
       4.*one_minus_t* t3*controlPoints[2] + 
                    t4*P1;

  return CUBIT_SUCCESS;
}

Definition at line 296 of file CubitFacetEdge.cpp.

{
CubitVector P0, P1;
double t3, t2, one_minus_t, one_minus_t2, one_minus_t3;
DLIList<CubitPoint*> my_points; 
  // project the position to the linear edge 
   
  double tt = (t + 1) * 0.5; 
  if (tt <= 0.0) tt = 0.0; 
  if (tt >= 1.0) tt = 1.0; 

  points(my_points);
 
  P0 = my_points.get()->coordinates();
  P1 = my_points.next()->coordinates();

  t2 = tt*tt;
  t3 = t2*tt;
  one_minus_t = 1.-tt;
  one_minus_t2 = one_minus_t*one_minus_t;
  one_minus_t3 = one_minus_t2*one_minus_t;
  
  *outv = -4.*one_minus_t3*P0 +
          4.*(one_minus_t3 -3.*tt*one_minus_t2)*controlPoints[0] +
          12.*(tt*one_minus_t2 - t2*one_minus_t)*controlPoints[1] +
          4.*(3.*t2*one_minus_t - t3)*controlPoints[2] +
          4.*t3*P1;

  return CUBIT_SUCCESS;
}
virtual void CubitFacetEdge::facets ( DLIList< CubitFacet * > &  facet_list) [pure virtual]

Implements FacetEntity.

Implemented in CubitFacetEdgeData.

Definition at line 1229 of file CubitFacetEdge.cpp.

{
  // look for an edge with a point only connected to the one edge in the set
  //
  // TODO - this algorithm could be made more efficient by only checking one endpoint
  //        per edge.  The current implementation should match the order points were
  //        checked in previous functionality.
  //        If speed becomes an issue it could be reimplemented
  //

  if (1 == edge_list.size())
  {
    return edge_list[0]->point(0);
  }

  int i;
  CubitPoint *start_point = NULL;
  for (i=0; i<edge_list.size() && (start_point == NULL); i++)
  {
    CubitFacetEdge *tmp_edge = edge_list.get_and_step();
    DLIList<CubitFacetEdge*> pt_edges;
    tmp_edge->point(0)->edges(pt_edges);

    pt_edges.intersect_unordered(edge_list);
    if (pt_edges.size() == 1)
    {
      start_point = tmp_edge->point(0);
    }
    else
    {
      pt_edges.clean_out();
      tmp_edge->point(1)->edges(pt_edges);
      pt_edges.intersect_unordered(edge_list);
      if (pt_edges.size() == 1)
      {
        start_point = tmp_edge->point(1);
      }
    }
  }
  return start_point;
}
virtual void CubitFacetEdge::flip ( ) [pure virtual]

Implemented in CubitFacetEdgeData.

void CubitFacetEdge::get_control_points ( CubitPoint point_ptr,
CubitVector  ctrl_pts[3] 
) [inline, virtual]

Definition at line 270 of file CubitFacetEdge.hpp.

{
  DLIList<CubitPoint*> my_points;
  points(my_points);
  
  if (point_ptr == my_points.get())
  {
    ctrl_pts[0] = controlPoints[0];
    ctrl_pts[1] = controlPoints[1];
    ctrl_pts[2] = controlPoints[2];
  }
  else if(point_ptr == my_points.next())
  {
    ctrl_pts[0] = controlPoints[2];
    ctrl_pts[1] = controlPoints[1];
    ctrl_pts[2] = controlPoints[0];
  }
  else
  {
    assert(0);  // point_ptr does not match either point
  }
}
virtual int CubitFacetEdge::get_flag ( ) [inline, virtual]

Definition at line 110 of file CubitFacetEdge.hpp.

{return markedFlag;};
void CubitFacetEdge::get_parents ( DLIList< FacetEntity * > &  facet_list) [virtual]

Implements FacetEntity.

Definition at line 758 of file CubitFacetEdge.cpp.

{ 
  DLIList<CubitFacet *> cf_list; 
  facets( cf_list ); 
  for (int ii=0; ii<cf_list.size(); ii++) 
    facet_list.append(cf_list.get_and_step()); 
} 
virtual int CubitFacetEdge::id ( ) [pure virtual]

Implemented in CubitFacetEdgeData.

CubitStatus CubitFacetEdge::intersect ( CubitVector aa,
CubitVector bb,
CubitVector norm,
CubitVector qq,
CubitBoolean does_intersect 
)

Definition at line 429 of file CubitFacetEdge.cpp.

{  
 
  CubitPoint *pt0 = this->point(0); 
  CubitPoint *pt1 = this->point(1); 

  double P0[2], P1[2], AA[2], BB[2];
  CubitVector absnorm(fabs(norm.x()), fabs(norm.y()), fabs(norm.z()));
  if (absnorm.x() >= absnorm.y() && absnorm.x() >= absnorm.z())
  {
    P0[0] = pt0->coordinates().y();  P0[1] = pt0->coordinates().z();
    P1[0] = pt1->coordinates().y();  P1[1] = pt1->coordinates().z();
    AA[0] = aa.y();                  AA[1] = aa.z();
    BB[0] = bb.y();                  BB[1] = bb.z();
  }
  else if (absnorm.y() >= absnorm.x() && absnorm.y() >= absnorm.z())
  {
    P0[0] = pt0->coordinates().z();  P0[1] = pt0->coordinates().x();
    P1[0] = pt1->coordinates().z();  P1[1] = pt1->coordinates().x();
    AA[0] = aa.z();                  AA[1] = aa.x();
    BB[0] = bb.z();                  BB[1] = bb.x();
  }
  else
  {
    P0[0] = pt0->coordinates().x();  P0[1] = pt0->coordinates().y();
    P1[0] = pt1->coordinates().x();  P1[1] = pt1->coordinates().y();
    AA[0] = aa.x();                  AA[1] = aa.y();
    BB[0] = bb.x();                  BB[1] = bb.y();
  }

  double QQ[4], s;
  int ninter = intersect_2D_segments(P0, P1, AA, BB, QQ);

  if (ninter != 1)
  {
    does_intersect = CUBIT_FALSE;
    return CUBIT_SUCCESS;
  }
  does_intersect = CUBIT_TRUE;
 
  double dx = P1[0] - P0[0];
  double dy = P1[1] - P0[1];
  if (fabs(dx) > fabs(dy))
    s = (QQ[0] - P0[0]) / dx;
  else
    s = (QQ[1] - P0[1]) / dy;
  
  qq = pt0->coordinates() + s * (pt1->coordinates() - pt0->coordinates());
 
  return CUBIT_SUCCESS; 
}  
int CubitFacetEdge::intersect_2D_segments ( double  P0[2],
double  P1[2],
double  P2[2],
double  P3[2],
double  qq[4] 
) [static]

Definition at line 963 of file CubitFacetEdge.cpp.

{

  double D0[2], D1[2];
  D0[0] = P1[0] - P0[0];  D0[1] = P1[1] - P0[1];
  D1[0] = P3[0] - P2[0];  D1[1] = P3[1] - P2[1];

  // segments P0 + s * D0 for s in [0,1],
  //          P2 + t * D1 for t in [0,1]

  double sqr_epsilon = DBL_EPSILON * DBL_EPSILON;
  double E[2];
  E[0] = P2[0] - P0[0];
  E[1] = P2[1] - P0[1];

  double kross = D0[0] * D1[1] - D0[1] * D1[0];
  double sqr_kross = kross * kross;
  double sqr_len0 = D0[0] * D0[0] + D0[1] * D0[1];
  double sqr_len1 = D1[0] * D1[0] + D1[1] * D1[1];
  if (sqr_kross > sqr_epsilon  * sqr_len0 * sqr_len1)
  {
    // lines of the segment are not parallel

    double s = (E[0] * D1[1] - E[1] * D1[0]) / kross;
    if (s < 0.0 || s > 1.0)
    {
       // intersection of lines is not a point on segment P0 + s * D0
      return 0;
    }

    double t = (E[0] * D0[1] - E[1] * D0[0]) / kross;
    if (t < 0.0 || t > 1.0)
    {
      // intersection of lines is not a point on segment P1 + t * D1
      return 0;
    }

    // intersection of lines is a point on each segment

    qq[0] = P0[0] + s * D0[0];
    qq[1] = P0[1] + s * D0[1];
    return 1;
  }

  // lines of the segments are parallel

  double sqr_lenE = E[0] * E[0] + E[1] * E[1];
  kross = E[0] * D0[1] - E[1] * D0[1];
  sqr_kross = kross * kross;
  if (sqr_kross > sqr_epsilon  * sqr_len0 * sqr_lenE)
  {
    // lines of the segments are different
    return 0;
  }

  // lines of the segment are the same.  Need to test for overlap of segments

  double s0 = (D0[0] * E[0] + D0[1] * E[1]) / sqr_len0;
  double s1 = s0 + (D0[0] * D1[0] + D0[1] * D1[1]) / sqr_len0;
  double smin = CUBIT_MIN(s0, s1);
  double smax = CUBIT_MAX(s0, s1);

  double w[2];
  int imax = intersect_intervals(0.0, 1.0, smin, smax, w);
  for (int i=0; i<imax; i++)
  {
    qq[i*2]   = P0[0] + w[i] * D0[0];
    qq[i*2+1] = P0[1] + w[i] * D0[1];
  }
  return imax;
}
int CubitFacetEdge::intersect_intervals ( double  u0,
double  u1,
double  v0,
double  v1,
double  w[2] 
) [static]

Definition at line 1041 of file CubitFacetEdge.cpp.

{
  if (u1 < v0 || u0 > v1)
    return 0;

  if (u1 > v0)
  {
    if (u0 < v1)
    {
      if (u0 < v0) 
        w[0] = v0;
      else 
        w[0] = u0;
      if (u1 > v1) 
        w[1] = v1;
      else 
        w[1] = u1;
      return 2;
    }
    else
    {
      w[0] = u0;
      return 1;
    }
  }
  else
  {
    w[0] = u1;
    return 1;
  }
  return 0;
}

Definition at line 212 of file CubitFacetEdge.hpp.

{return (isFeature ? CUBIT_TRUE : CUBIT_FALSE); }
int CubitFacetEdge::is_flipped ( ) [inline]

Definition at line 66 of file CubitFacetEdge.hpp.

    {
      if(isFlipped)
        return 1;
      return 0;
    }
void CubitFacetEdge::is_flipped ( int  flipped) [inline]

Definition at line 72 of file CubitFacetEdge.hpp.

    {
      if(flipped)
        isFlipped = CUBIT_TRUE;
      else
        isFlipped = CUBIT_FALSE;
    }

Definition at line 718 of file CubitFacetEdge.cpp.

{ 
  CubitVector start = point(0)->coordinates(); 
  CubitVector end = point(1)->coordinates(); 
  return start.distance_between( end ); 
} 
int CubitFacetEdge::less_than ( CubitFacetEdge *&  e1,
CubitFacetEdge *&  e2 
) [inline]

Definition at line 239 of file CubitFacetEdge.hpp.

  {
    double len1 = e1->length();
    double len2 = e2->length();
  
    if (len1 == len2) return 0;
    return (len1 < len2) ? -1 : 1;
  }
virtual void CubitFacetEdge::marked ( int  my_flag) [inline, virtual]

Reimplemented in CubitFacetEdgeData.

Definition at line 131 of file CubitFacetEdge.hpp.

{ set_flag(my_flag); }
virtual int CubitFacetEdge::marked ( ) [inline, virtual]

Reimplemented in CubitFacetEdgeData.

Definition at line 132 of file CubitFacetEdge.hpp.

{ return get_flag(); }
virtual int CubitFacetEdge::num_adj_facets ( ) [pure virtual]

Implemented in CubitFacetEdgeData.

Definition at line 831 of file CubitFacetEdge.cpp.

{ 
 
  DLIList<CubitFacet *> cf_list; 
  facets( cf_list ); 
  CubitFacet *adj_facet = NULL; 
  int nfacets = 0; 
  for (int ii=0; ii<cf_list.size(); ii++) 
  { 
    adj_facet = cf_list.get_and_step(); 
    if (adj_facet->tool_id() == tool_id) 
      nfacets++; 
  } 
  return nfacets; 
} 
virtual int CubitFacetEdge::number_faces ( ) [inline, virtual]

Definition at line 129 of file CubitFacetEdge.hpp.

{ return 0; }
virtual int CubitFacetEdge::number_tris ( ) [inline, virtual]

Reimplemented in CubitFacetEdgeData.

Definition at line 128 of file CubitFacetEdge.hpp.

{ return num_adj_facets(); }
CubitStatus CubitFacetEdge::order_edge_list ( DLIList< CubitFacetEdge * > &  edge_list,
CubitPoint start_point,
CubitPoint *&  end_point 
) [static]

Definition at line 1143 of file CubitFacetEdge.cpp.

{
  int i;
  assert(start_point);

  end_point = NULL;

  // invalid input
  if (0 == edge_list.size())
    return CUBIT_FAILURE;

  // simple case of a single edge - endpoitn
  if (1 == edge_list.size())
  {
    end_point = edge_list.get()->other_point(start_point);
    return end_point ? CUBIT_SUCCESS : CUBIT_FAILURE;
  }

  edge_list.reset();

  // note that a periodic/closed curve will fail
  // we could handle that case here if needed, but we may need more information
  // to know where to start and end the curve
  if (NULL == start_point)
    return CUBIT_FAILURE;

  // put edges in a set for faster searching
  std::set<CubitFacetEdge *> edge_set;
  for (i=0; i<edge_list.size(); i++)
    edge_set.insert(dynamic_cast<CubitFacetEdge*> (edge_list.step_and_get()));

  // a vector for the ordered list
  std::vector<CubitFacetEdge*> ordered_edges;

  // find connected edges from the start point
  CubitPoint *cur_pt = start_point;
  do
  {
    // get edges connected to the current point and find the next edge
    DLIList<CubitFacetEdge *> pt_edges;
    cur_pt->edges(pt_edges);

    std::set<CubitFacetEdge *>::iterator iter_found;
    CubitFacetEdge *cur_edge = NULL;
    for (i=0; i<pt_edges.size() && !cur_edge; i++)
    {
      CubitFacetEdge *tmp_edge = pt_edges.get_and_step();
      iter_found = edge_set.find(tmp_edge);
      if ( iter_found != edge_set.end() )
        cur_edge = tmp_edge;
    }

    // if we don't find a connection before we empty the set
    // then not all the edges are connected  -- return failure
    if (NULL == cur_edge)
      return CUBIT_FAILURE;

    // add the edge to the ordered list
    ordered_edges.push_back( cur_edge );
    edge_set.erase(iter_found);

    cur_pt = cur_edge->other_point(cur_pt);
  }
  while ( edge_set.size());

  if (ordered_edges.size() != (size_t)edge_list.size())
    return CUBIT_FAILURE;

  // store the edges in the correct order
  edge_list.clean_out();

  std::vector<CubitFacetEdge*>::iterator iter;
  for (iter=ordered_edges.begin(); iter!=ordered_edges.end(); iter++)
    edge_list.append(*iter);

  // get the end point
  CubitFacetEdge *edge1 = edge_list[edge_list.size() - 1];
  CubitFacetEdge *edge2 = edge_list[edge_list.size() - 2];

  end_point = edge1->other_point( edge1->shared_point(edge2) );

  return CUBIT_SUCCESS;
}

Definition at line 773 of file CubitFacetEdge.cpp.

{ 
  DLIList<CubitFacet *> cf_list; 
  facets( cf_list ); 
  assert(cf_list.size() < 3); 
  CubitFacet *adj_facet = NULL; 
  if (cf_list.size() > 0) 
  { 
    adj_facet = cf_list.get_and_step(); 
    if (adj_facet == facet_ptr) 
    { 
      if (cf_list.size() == 2) 
      { 
        adj_facet = cf_list.get(); 
      } 
    } 
  } 
  return adj_facet; 
} 

Definition at line 802 of file CubitFacetEdge.cpp.

{ 
  assert(facet_ptr != 0); 
  int tool_id = facet_ptr->tool_id(); 
  DLIList<CubitFacet *> cf_list; 
  facets( cf_list ); 
  CubitFacet *adj_facet = NULL; 
  int found = 0; 
  for (int ii=0; ii<cf_list.size() && !found; ii++) 
  { 
    adj_facet = cf_list.get_and_step(); 
    if (adj_facet != facet_ptr) 
    { 
      if (adj_facet->tool_id() == tool_id) 
        found = 1; 
    } 
  } 
  if (!found) 
    adj_facet = NULL; 
  return adj_facet; 
} 

Definition at line 743 of file CubitFacetEdge.cpp.

{ 
  if (point(0) == point_ptr) 
    return point(1); 
  if(point(1) == point_ptr) 
    return point(0); 
  return NULL; 
} 
virtual CubitPoint* CubitFacetEdge::point ( int  index) [pure virtual]

Implemented in CubitFacetEdgeData.

virtual void CubitFacetEdge::points ( DLIList< CubitPoint * > &  point_list) [pure virtual]

Implements FacetEntity.

Implemented in CubitFacetEdgeData.

Definition at line 731 of file CubitFacetEdge.cpp.

{
  return (1.0 - f) * point(0)->coordinates() +
                f  * point(1)->coordinates();
}
CubitStatus CubitFacetEdge::proj_to_line ( const CubitVector this_point,
CubitVector proj_point 
)

Definition at line 620 of file CubitFacetEdge.cpp.

{ 
  CubitStatus stat = CUBIT_SUCCESS; 
  CubitVector p0 = point(0)->coordinates(); 
  CubitVector p1 = point(1)->coordinates(); 
  CubitVector edge_vec( p0,p1 ); 
  CubitVector point_vec( p0, this_point ); 
  edge_vec.normalize(); 
  double dist_on_edge = edge_vec % point_vec;   
  proj_point = p0 + (edge_vec * dist_on_edge); 
 
  return stat; 
} 
virtual CubitStatus CubitFacetEdge::remove_facet ( CubitFacet ) [pure virtual]

Implemented in CubitFacetEdgeData.

void CubitFacetEdge::set_as_feature ( ) [inline]

Definition at line 211 of file CubitFacetEdge.hpp.

{ isFeature = 1; }
void CubitFacetEdge::set_control_points ( CubitPoint point_ptr,
CubitVector  ctrl_pts[3] 
) [inline, virtual]

Definition at line 304 of file CubitFacetEdge.hpp.

{
  DLIList<CubitPoint*> my_points;
  points(my_points);

  if (point_ptr == my_points.get())
  {
    controlPoints[0] = ctrl_pts[0];
    controlPoints[1] = ctrl_pts[1];
    controlPoints[2] = ctrl_pts[2];
  }
  else if(point_ptr == my_points.next())
  {
    controlPoints[0] = ctrl_pts[2];
    controlPoints[1] = ctrl_pts[1];
    controlPoints[2] = ctrl_pts[0];
  }
  else
  {
    assert(0);  // point_ptr does not match either point
  }
}
void CubitFacetEdge::set_control_points ( const double *  ctrl_pt_array)

Definition at line 51 of file CubitFacetEdge.cpp.

{ 
  int ii;
  for (ii=0; ii<3; ii++)
  {
    controlPoints[ii].x( ctrl_pt_array[ii*3] );
    controlPoints[ii].y( ctrl_pt_array[ii*3+1] );
    controlPoints[ii].z( ctrl_pt_array[ii*3+2] );
  }
}
virtual void CubitFacetEdge::set_flag ( int  my_flag) [inline, virtual]

Definition at line 109 of file CubitFacetEdge.hpp.

{markedFlag = my_flag;};
virtual void CubitFacetEdge::set_id ( int  ) [inline, virtual]

Reimplemented in CubitFacetEdgeData.

Definition at line 64 of file CubitFacetEdge.hpp.

{};

Definition at line 909 of file CubitFacetEdge.cpp.

{
  CubitPoint *pA = this->point(0);
  CubitPoint *pB = this->point(1);
  CubitPoint *pC = edge_ptr->point(0);
  CubitPoint *pD = edge_ptr->point(1);
  CubitPoint *pShared = NULL;
  if (pA == pC || pA == pD)
  {
    pShared = pA;
  }
  else if (pB == pC || pB == pD)
  {
    pShared = pB;
  }
  return pShared;
}
virtual CubitPoint* CubitFacetEdge::start_node ( ) [pure virtual]

Implemented in CubitFacetEdgeData.

Definition at line 80 of file CubitFacetEdge.hpp.

void CubitFacetEdge::tris ( DLIList< CubitFacet * > &  facet_list) [inline]

Definition at line 115 of file CubitFacetEdge.hpp.

{ facets(facet_list); }
void CubitFacetEdge::tris ( int *  ,
DLIList< CubitFacet * > &  facet_list 
) [inline]

Definition at line 116 of file CubitFacetEdge.hpp.

                                         { facets(facet_list); }

Member Data Documentation

int CubitFacetEdge::bezierOrder [protected]

Definition at line 47 of file CubitFacetEdge.hpp.

Definition at line 44 of file CubitFacetEdge.hpp.

Definition at line 53 of file CubitFacetEdge.hpp.

Definition at line 56 of file CubitFacetEdge.hpp.

int CubitFacetEdge::markedFlag [protected]

Definition at line 50 of file CubitFacetEdge.hpp.


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