cgma
CubitFacet Class Reference

#include <CubitFacet.hpp>

Inheritance diagram for CubitFacet:
FacetEntity ToolDataUser CubitFacetData FaceterFacetData

List of all members.

Public Member Functions

 CubitFacet ()
virtual ~CubitFacet ()
CubitVector normal ()
CubitVector update_normal (void)
const CubitBoxbounding_box ()
void bounding_box (CubitBox &box)
void reset_bounding_box ()
void weight (double facweight)
double weight ()
void get_control_points (CubitVector points[6])
void set_control_points (CubitVector points[6])
void set_control_points (const double *pt_array)
CubitVectorcontrol_points ()
int eval_order ()
virtual CubitPointpoint (int index)=0
void marked (int mark)
int marked ()
int is_flat ()
void is_flat (int flat)
const CubitPlaneplane ()
void plane (CubitPlane &this_plane)
void update_plane ()
int is_backwards ()
void is_backwards (int flipped)
virtual int id ()=0
virtual void set_id (int ii)=0
int tool_id ()
void set_tool_id (int tool_id)
virtual CubitFacetEdgeedge (int index)=0
virtual void edge (CubitFacetEdge *the_edge, int index)=0
virtual void edge_use (int direction, int index)=0
virtual int edge_use (int index)=0
virtual void flip ()=0
virtual int sense (int)
virtual CubitPointsplit_edge (CubitPoint *edge_pt1, CubitPoint *edge_pt2, const CubitVector &position)
virtual CubitPointinsert_point (const CubitVector &position, CubitFacet *&new_tri1, CubitFacet *&new_tri2)
virtual CubitStatus closest_point (const CubitVector &point, CubitVector &closest_point)
CubitVector center ()
void debug_draw (int color=-1, int flush_it=1, int draw_uv=0)
CubitStatus closest_point_trimmed (const CubitVector &point, CubitVector &closest_point, CubitPoint *&next_edge_p1, CubitPoint *&next_edge_p2)
void get_edge_1 (CubitPoint *&p1, CubitPoint *&p2)
void get_edge_2 (CubitPoint *&p1, CubitPoint *&p2)
void get_edge_3 (CubitPoint *&p1, CubitPoint *&p2)
void get_edge_pts (int index, CubitPoint *&p1, CubitPoint *&p2)
CubitFacetEdgeedge_from_pts (CubitPoint *p1, CubitPoint *p2, int &index)
int edge_index (CubitPoint *p1, CubitPoint *p2, int &sense)
int edge_index (CubitFacetEdge *edge)
int point_index (CubitPoint *pt)
void opposite_edge (CubitPoint *point, CubitPoint *&p1, CubitPoint *&p2)
CubitPointopposite_point (CubitFacetEdge *edge)
void points (CubitPoint *&p0, CubitPoint *&p1, CubitPoint *&p2)
void points (CubitPoint *pts[3])
void tri_nodes (CubitPoint *&p0, CubitPoint *&p1, CubitPoint *&p2)
void points (DLIList< CubitPoint * > &point_list)
void facets (DLIList< CubitFacet * > &facet_list)
void edges (DLIList< CubitFacetEdge * > &edge_list)
CubitBoolean contains (CubitPoint *p1)
CubitFacetEdgeshared_edge (CubitFacet *cubit_facet)
CubitFacetshared_facet (CubitPoint *p1, CubitPoint *p2)
void shared_facets (CubitPoint *p1, CubitPoint *p2, DLIList< CubitFacet * > &adj_facet_list)
CubitFacetadjacent (int &index, int *tool_data)
CubitPointnext_node (CubitPoint *current_point)
CubitFacetshared_facet_on_surf (CubitPoint *p1, CubitPoint *p2, int tool_id)
double min_diagonal ()
double angle (CubitPoint *pt)
void update_bezier_bounding_box ()
CubitFacetEdgeprev_edge (CubitFacetEdge *edge)
CubitFacetEdgenext_edge (CubitFacetEdge *edge)
int other_index (CubitPoint *pt1, CubitPoint *pt2)
CubitStatus evaluate_position (const CubitVector &start_position, CubitVector *eval_point, CubitVector *eval_normal=NULL)
CubitStatus evaluate (CubitVector &areacoord, CubitVector *eval_point, CubitVector *eval_normal=NULL)
void get_parents (DLIList< FacetEntity * > &)
CubitFacetEdgenext_edge_at_point (CubitFacetEdge *edge_ptr, CubitPoint *point_ptr)
CubitStatus get_edge_control_points (CubitVector P[3][5])
double area ()
double aspect_ratio ()
CubitStatus init_patch ()
void add_edge (CubitFacetEdge *edge)
void unlink_from_children (void)

Static Public Attributes

static const int point_edge_conn [30][2]
static const int point_facet_conn [16][3]
static const double my_points [15][3]

Protected Attributes

CubitPlanecachedPlane
CubitBox bBox
double facetWeight
CubitVectorpatchCtrlPts
int markedFlag
int isFlat
int isBackwards
int toolID

Detailed Description

Definition at line 46 of file CubitFacet.hpp.


Constructor & Destructor Documentation

Definition at line 32 of file CubitFacet.cpp.

  : cachedPlane(NULL), facetWeight(0.0), patchCtrlPts(NULL),
    markedFlag(0), isFlat(999), isBackwards(0), toolID(0)

{

}
CubitFacet::~CubitFacet ( ) [virtual]

Definition at line 46 of file CubitFacet.cpp.

{
  if (cachedPlane )
    delete cachedPlane;
  cachedPlane = NULL;
  if (patchCtrlPts)
    delete [] patchCtrlPts;
}

Member Function Documentation

Definition at line 1191 of file CubitFacet.cpp.

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

  // find the points on this facet

  int p0_index = point_index( p0 );
  int p1_index = point_index( p1 );
  assert(p0_index >=0 && p1_index >= 0);
  assert(p0_index != p1_index);

  // add the edge based on the relative index of the points
  // set the edge use based on their order

  int edge_index;
  if ((p0_index+1)%3 == p1_index)
  {
    edge_index = (p1_index + 1)%3;
    assert(this->edge(edge_index) == NULL);
    this->edge( edge, edge_index );
    this->edge_use(1, edge_index);
  }
  else if((p0_index+2)%3 == p1_index)
  {
    edge_index = (p0_index + 1)%3;
    assert(this->edge(edge_index) == NULL);
    this->edge( edge, edge_index );
    this->edge_use(-1, edge_index);
  }
  else
  {
    assert(0);  // shouldn't happen
  }

  // add the facet to the edge

  edge->add_facet( this );
}
CubitFacet* CubitFacet::adjacent ( int &  index,
int *  tool_data 
) [inline]

Definition at line 278 of file CubitFacet.hpp.

  {
        //convert MESHING TRI edge index to GEOMETRY FACET edge index
        index = (index+2)%3;
        CubitPoint *p1, *p2; 
   
        get_edge_pts( index, p1, p2 ); 
        return shared_facet_on_surf( p1, p2, *tool_data ); 
  } 
double CubitFacet::angle ( CubitPoint pt)

Definition at line 760 of file CubitFacet.cpp.

{
  int ii, index = -1;
  CubitBoolean found=CUBIT_FALSE;
  for (ii=0; ii<3 && !found; ii++) {
    if (pt==this->point(ii)) {
      index = ii;
      found = CUBIT_TRUE;
    }
  }
  if (!found) {
    return 0.0e0;
  }
  CubitVector e0 = this->point((index+1)%3)->coordinates() - pt->coordinates();
  CubitVector e1 = this->point((index+2)%3)->coordinates() - pt->coordinates();
  e0.normalize();
  e1.normalize();
  double myangle;
  double cosangle = e0%e1;
  if (cosangle >= 1.0) {
    myangle = 0.0e0;
  }
  else if( cosangle <= -1.0 ) {
    myangle = CUBIT_PI;
  }
  else {
    myangle = acos(cosangle);
  }
  return myangle;
}
double CubitFacet::area ( )

Definition at line 1130 of file CubitFacet.cpp.

{
  CubitVector e0(point(0)->coordinates(), point(1)->coordinates());
  CubitVector e1(point(0)->coordinates(), point(2)->coordinates());
  double area = (e0 * e1).length() * 0.5;
  return area;
}

Definition at line 1138 of file CubitFacet.cpp.

{
  static const double normal_coeff = sqrt( 3. ) / 6.;

  // three vectors for each side 
  CubitVector a = point(1)->coordinates() - point(0)->coordinates();
  CubitVector b = point(2)->coordinates() - point(1)->coordinates();
  CubitVector c = point(0)->coordinates() - point(2)->coordinates();
    
  double a1 = a.length();
  double b1 = b.length();
  double c1 = c.length();
 
  double hm = a1 > b1 ? a1 : b1;
  hm = hm > c1 ? hm : c1;

  CubitVector ab = a * b;
  double denominator = ab.length();

  if( denominator < CUBIT_DBL_MIN ) 
    return (double)CUBIT_DBL_MAX;
  else
  {
    double aspect_ratio;
    aspect_ratio = normal_coeff * hm * (a1 + b1 + c1) / denominator;
    
    if( aspect_ratio > 0 )
      return (double) CUBIT_MIN( aspect_ratio, CUBIT_DBL_MAX );
    return (double) CUBIT_MAX( aspect_ratio, -CUBIT_DBL_MAX );
  }
}
const CubitBox& CubitFacet::bounding_box ( void  ) [inline]

Definition at line 95 of file CubitFacet.hpp.

{return bBox;}; 
void CubitFacet::bounding_box ( CubitBox box) [inline]

Definition at line 96 of file CubitFacet.hpp.

  { bBox = box; } 

Definition at line 577 of file CubitFacet.cpp.

{
   CubitVector vec( point(0)->coordinates() );
   vec += point(1)->coordinates();
   vec += point(2)->coordinates();
   vec /= 3.0;
   return vec;
}
CubitStatus CubitFacet::closest_point ( const CubitVector point,
CubitVector closest_point 
) [virtual]

Definition at line 270 of file CubitFacet.cpp.

{
  CubitPlane fac_plane = plane();
  closest_point = fac_plane.project( point );
  return CUBIT_SUCCESS;
}
CubitStatus CubitFacet::closest_point_trimmed ( const CubitVector point,
CubitVector closest_point,
CubitPoint *&  next_edge_p1,
CubitPoint *&  next_edge_p2 
)

Definition at line 285 of file CubitFacet.cpp.

{
  CubitVector p1 = point(0)->coordinates();
  CubitVector p2 = point(1)->coordinates();
  CubitVector p3 = point(2)->coordinates();
  //First get the edge vectors.
  p1.x();
  p2.x();

  CubitVector y1 = p2 - p1;
  CubitVector y2 = p3 - p2;
  CubitVector y3 = p1 - p3;
  //Now get the vectors from the point to the vertices of the facet.
  CubitVector w1 = mypoint - p1;
  CubitVector w2 = mypoint - p2;
  CubitVector w3 = mypoint - p3;
  //Now cross the edge vectors with the vectors to the point.  If the point
  //in questionis inside the facet then each of these vectors will be in in
  //the same direction as the normal of this facet.
  CubitVector x1 = y1*w1;
  CubitVector x2 = y2*w2;
  CubitVector x3 = y3*w3;

  //Now take the dot products to help us determine if it is in the triangle.
  CubitVector n = normal();
  double d1 = x1%n;
  double d2 = x2%n;
  double d3 = x3%n;

  //If this is true, then we just take the closest point to this facet.
  if ( d1 >= -GEOMETRY_RESABS && d2 >= -GEOMETRY_RESABS && d3 >= -GEOMETRY_RESABS )
  {
    CubitStatus rv = this->closest_point(mypoint, closest_point);
    if ( rv != CUBIT_SUCCESS )
    {
      PRINT_ERROR("Closest Point Trimmed Error.  Point in facet but can't"
                  " calc. point.\n");
      return CUBIT_FAILURE;
    }
    next_edge_p1 = NULL;
    next_edge_p2 = NULL;
    return CUBIT_SUCCESS;
  }
  CubitBoolean close_p1 = CUBIT_FALSE;
  CubitBoolean close_p2 = CUBIT_FALSE;
  CubitBoolean close_p3 = CUBIT_FALSE;
  double k1, k2, k3;
  //Now with the "d" values, determine which point or edge we
  //should project to.  We have to go through each of these and
  //determine which is the closest.
  if ( d1 < 0.0 )
  {
    double w1_dot_y1 = w1%y1;
    double y1_squared = y1.length_squared();
    if ( y1_squared <= CUBIT_DBL_MIN && y1_squared >= -CUBIT_DBL_MIN )
    {
      PRINT_ERROR("Length of facet edge too small.\n");
      return CUBIT_FAILURE;
    }
    k1 = w1_dot_y1/y1_squared;
    if ( k1 < 0.0 )
      close_p1 = CUBIT_TRUE;
    else if ( k1 > 1.0 )
      close_p2 = CUBIT_TRUE;
    else if ( k1 >= 0.0 && k1 <= 1.0 + GEOMETRY_RESABS )
    {
      //So we know that y1, is the closest edge.
      closest_point = p1 + k1*y1;
      next_edge_p1 = point(0);
      next_edge_p2 = point(1);
      return CUBIT_SUCCESS;
    }
  }
  if ( d2 < 0.0 )
  {
    double w2_dot_y2 = w2%y2;
    double y2_squared = y2.length_squared();
    if ( y2_squared <= CUBIT_DBL_MIN && y2_squared >= -CUBIT_DBL_MIN )
    {
      PRINT_ERROR("Length of facet edge too small.\n");
      return CUBIT_FAILURE;
    }
    k2 = w2_dot_y2/y2_squared;
    if ( k2 < 0.0 )
    {
      close_p2 = CUBIT_TRUE;
    }
    else if ( k2 > 1.0 )
    {
      close_p3 = CUBIT_TRUE;
    }
    else if ( k2 >= 0.0 && k2 <= 1.0 + GEOMETRY_RESABS )
    {
      //So we know that y2, is the closest edge.
      closest_point = p2 + k2*y2;
      next_edge_p1 = point(1);
      next_edge_p2 = point(2);
      return CUBIT_SUCCESS;
    }
  }
  if ( d3 < 0.0 )
  {
    double w3_dot_y3 = w3%y3;
    double y3_squared = y3.length_squared();
    if ( y3_squared <= CUBIT_DBL_MIN && y3_squared >= -CUBIT_DBL_MIN )
    {
      PRINT_ERROR("Length of facet edge too small.\n");
      return CUBIT_FAILURE;
    }
    k3 = w3_dot_y3/y3_squared;
    if ( k3 < 0.0 )
    {
      close_p3 = CUBIT_TRUE;
    }
    else if ( k3 > 1.0 )
    {
      close_p1 = CUBIT_TRUE;
    }
    else if ( k3 >= 0.0 && k3 <= 1.0 + GEOMETRY_RESABS )
    {
      //So we know that y3, is the closest edge.
      closest_point = p3 + k3*y3;
      next_edge_p1 = point(2);
      next_edge_p2 = point(0);
      return CUBIT_SUCCESS;
    }
  }
  //Now we have the distances, and which edges the point is closest to.
  if ( close_p1 && !close_p2 && !close_p3 )
  {
    closest_point = p1 ;
    next_edge_p1 = point(0);
    next_edge_p2 = NULL;
    return CUBIT_SUCCESS;
  }
  else if ( close_p2 && !close_p1 && !close_p3 )
  {
    closest_point = p2;
    next_edge_p1 = point(1);
    next_edge_p2 = NULL;
    return CUBIT_SUCCESS;
  }
  else if ( close_p3 && !close_p1 && !close_p2 )
  {
    closest_point = p3;
    next_edge_p1 = point(2);
    next_edge_p2 = NULL;
    return CUBIT_SUCCESS;
  }
  else if( close_p1 && close_p2 && !close_p3 )
  {
    if( w1.length_squared() < w2.length_squared() )
      closest_point = p1; 
    else
      closest_point = p2;
    return CUBIT_SUCCESS;
  }
  else if( close_p2 && close_p3 && !close_p1 )
  {
    if( w2.length_squared() < w3.length_squared() )
      closest_point = p2; 
    else
      closest_point = p3;
    return CUBIT_SUCCESS;
  }
  else if( close_p1 && close_p3 && !close_p2 )
  {
    if( w1.length_squared() < w3.length_squared() )
      closest_point = p1; 
    else
      closest_point = p3;
    return CUBIT_SUCCESS;
  }

  PRINT_ERROR("Problems finding the closest point to a facet.\n");
  return CUBIT_FAILURE;
}

Definition at line 472 of file CubitFacet.cpp.

{
  for ( int i = 0; i < 3; i++ )
    if ( point(i) == p1 )
      return CUBIT_TRUE;
  return CUBIT_FALSE;
}

Definition at line 108 of file CubitFacet.hpp.

{return patchCtrlPts;};
void CubitFacet::debug_draw ( int  color = -1,
int  flush_it = 1,
int  draw_uv = 0 
) [virtual]

Implements FacetEntity.

Definition at line 592 of file CubitFacet.cpp.

{
  if ( color == -1 )
    color = CUBIT_RED_INDEX;
  GfxDebug::draw_facet(this, color, draw_uv);
  if ( flush_it )
    GfxDebug::flush();
}
virtual CubitFacetEdge* CubitFacet::edge ( int  index) [pure virtual]

Implemented in CubitFacetData, and FaceterFacetData.

virtual void CubitFacet::edge ( CubitFacetEdge the_edge,
int  index 
) [pure virtual]

Implemented in CubitFacetData, and FaceterFacetData.

CubitFacetEdge * CubitFacet::edge_from_pts ( CubitPoint p1,
CubitPoint p2,
int &  index 
)

Definition at line 801 of file CubitFacet.cpp.

{
  if ((point(0) == p1 && point(1) == p2) ||
    (point(0) == p2 && point(1) == p1)) {
    edge_index = 2;
    return edge(2);
  }
  if ((point(1) == p1 && point(2) == p2) ||
    (point(1) == p2 && point(2) == p1)) {
    edge_index = 0;
    return edge(0);
  }
  if ((point(2) == p1 && point(0) == p2) ||
    (point(2) == p2 && point(0) == p1)) {
    edge_index = 1;
    return edge(1);
  }
  edge_index = -1;
  return NULL;
}
int CubitFacet::edge_index ( CubitPoint p1,
CubitPoint p2,
int &  sense 
)

Definition at line 835 of file CubitFacet.cpp.

{
  if (point(0) == p1 && point(1) == p2)
  {
    sense = 1;
    return 2;
  }
  if (point(0) == p2 && point(1) == p1)
  {
    sense = -1;
    return 2;
  }
  if (point(1) == p1 && point(2) == p2)
  {
    sense = 1;
    return 0;
  }
  if (point(1) == p2 && point(2) == p1)
  {
    sense = -1;
    return 0;
  }
  if (point(2) == p1 && point(0) == p2)
  {
    sense = 1;
    return 1;
  }
  if (point(2) == p2 && point(0) == p1)
  {
    sense = -1;
    return 1;
  }
  sense = 0;
  return -1;
}

Definition at line 872 of file CubitFacet.cpp.

{
  if (edge(0) == theedge) return 0;
  if (edge(1) == theedge) return 1;
  if (edge(2) == theedge) return 2;
  return -1;
}
virtual void CubitFacet::edge_use ( int  direction,
int  index 
) [pure virtual]

Implemented in CubitFacetData, and FaceterFacetData.

virtual int CubitFacet::edge_use ( int  index) [pure virtual]

Implemented in CubitFacetData, and FaceterFacetData.

void CubitFacet::edges ( DLIList< CubitFacetEdge * > &  edge_list) [inline, virtual]

Implements FacetEntity.

Definition at line 260 of file CubitFacet.hpp.

    { for ( int i = 0; i < 3; i++ ) 
      edge_list.append(edge(i)); 
    } 
int CubitFacet::eval_order ( ) [inline]

Definition at line 111 of file CubitFacet.hpp.

    { return (patchCtrlPts == NULL) ? 0 : 4; } 
CubitStatus CubitFacet::evaluate ( CubitVector areacoord,
CubitVector eval_point,
CubitVector eval_normal = NULL 
)

Definition at line 251 of file CubitFacet.cpp.

{
  if (isBackwards)
  {
    double temp = areacoord.y();
    areacoord.y( areacoord.z() );
    areacoord.z( temp );
  }
  return FacetEvalTool::eval_facet( this, areacoord, eval_point, eval_normal );
}
CubitStatus CubitFacet::evaluate_position ( const CubitVector start_position,
CubitVector eval_point,
CubitVector eval_normal = NULL 
)

Definition at line 200 of file CubitFacet.cpp.

{
  CubitStatus stat = CUBIT_SUCCESS;

  if (is_flat())
  {
    if (eval_point != NULL)
      closest_point(start_position, *eval_point);
    if (eval_normal != NULL)
      *eval_normal = normal();
  }
  else  // project to the smooth facet
  {
    // project the position to the planar facet
    CubitVector close_point;
    stat = closest_point(start_position, close_point);

    // get the area coordinates of this point as a starting guess
    CubitVector area_coordinates;
    FacetEvalTool::facet_area_coordinate(this, close_point, area_coordinates);

    // now evaluate the smooth facet (this may alter the area coords)
    CubitVector proj_point;
    CubitBoolean outside;
    double tol = sqrt(area()) * 1.0e-3;
    stat = FacetEvalTool::project_to_facet( this, close_point, area_coordinates,
                                            proj_point, outside, tol );

    if (eval_point != NULL)
    {
      *eval_point = proj_point;
    }
    // compute the smooth normal if required
    if (eval_normal != NULL)
    {
      FacetEvalTool::eval_facet_normal(this, area_coordinates, *eval_normal);
    }
  }

  return stat;
}
void CubitFacet::facets ( DLIList< CubitFacet * > &  facet_list) [inline, virtual]

Implements FacetEntity.

Definition at line 258 of file CubitFacet.hpp.

    { facet_list.append( this ); } 
void CubitFacet::flip ( ) [pure virtual]

Implemented in CubitFacetData, and FaceterFacetData.

Definition at line 1041 of file CubitFacet.cpp.

{
  // must be implemented in child class
  assert(0);

}

Definition at line 102 of file CubitFacet.cpp.

{
  assert(patchCtrlPts != 0);
  memcpy( points, patchCtrlPts, 6 *sizeof(CubitVector) );
}
void CubitFacet::get_edge_1 ( CubitPoint *&  p1,
CubitPoint *&  p2 
) [inline]

Definition at line 216 of file CubitFacet.hpp.

    { p1 = point(0); p2 = point(1);} 
void CubitFacet::get_edge_2 ( CubitPoint *&  p1,
CubitPoint *&  p2 
) [inline]

Definition at line 218 of file CubitFacet.hpp.

    { p1 = point(1); p2 = point(2);} 
void CubitFacet::get_edge_3 ( CubitPoint *&  p1,
CubitPoint *&  p2 
) [inline]

Definition at line 220 of file CubitFacet.hpp.

    { p1 = point(2); p2 = point(0);} 

Definition at line 1105 of file CubitFacet.cpp.

{
  CubitStatus stat;
  CubitFacetEdge *edge_ptr;
  CubitVector ctrl_pts[5];
  int ii, jj;
  for (ii=0; ii<3; ii++) {
    edge_ptr = edge(ii);
    stat = edge_ptr->control_points(this, ctrl_pts);
    if (stat!= CUBIT_SUCCESS)
      return stat;
    for (jj=0; jj<5; jj++)
    {
      P[ii][jj] = ctrl_pts[jj];
    }
  }
  return stat;
}
void CubitFacet::get_edge_pts ( int  index,
CubitPoint *&  p1,
CubitPoint *&  p2 
)

Definition at line 907 of file CubitFacet.cpp.

{
  assert(index >=0 && index <=2);

    p1 = point((index+1)%3);
    p2 = point((index+2)%3);
}
void CubitFacet::get_parents ( DLIList< FacetEntity * > &  ) [inline, virtual]

Implements FacetEntity.

Definition at line 322 of file CubitFacet.hpp.

{}; 
virtual int CubitFacet::id ( ) [pure virtual]

Implemented in CubitFacetData, and FaceterFacetData.

Definition at line 1179 of file CubitFacet.cpp.

CubitPoint * CubitFacet::insert_point ( const CubitVector position,
CubitFacet *&  new_tri1,
CubitFacet *&  new_tri2 
) [virtual]

Reimplemented in CubitFacetData, and FaceterFacetData.

Definition at line 715 of file CubitFacet.cpp.

{
  // this function should be implemented in child class since it creates
  // new facet and point entities
  assert(1);
  CubitPoint* new_point = NULL;
  return new_point;
}
int CubitFacet::is_backwards ( ) [inline]

Definition at line 134 of file CubitFacet.hpp.

{return isBackwards;}; 
void CubitFacet::is_backwards ( int  flipped) [inline]

Definition at line 135 of file CubitFacet.hpp.

{ isBackwards = flipped; } 

Definition at line 144 of file CubitFacet.cpp.

{
  if (isFlat != 999)
  {
    return isFlat;
  }

  // check the edges first.  If on a boundary then assume not flat for now
  // This is to account for any in-plane curvature in the boundary edges

  int ii;
  CubitBoolean on_boundary = CUBIT_FALSE;
  for (ii=0; ii<3 && !on_boundary; ii++)
  {
    CubitPoint *point_ptr = point(ii);
    CubitFacetEdge *edge_ptr = edge(ii);
    TDFacetBoundaryPoint *td = TDFacetBoundaryPoint::get_facet_boundary_point(point_ptr);
    if (td != NULL || (edge_ptr && edge_ptr->num_adj_facets() <= 1))
    {
      on_boundary = CUBIT_TRUE;
    }
  }
  if (on_boundary)
  {
    isFlat = 0;
  }
  else
  {

    CubitPoint *p0, *p1, *p2;
    points(p0, p1, p2);

    CubitVector n0 = p0->normal( this );
    CubitVector n1 = p1->normal( this );
    CubitVector n2 = p2->normal( this );
    double dot0 = n0 % n1;
    double dot1 = n1 % n2;
    double dot2 = n2 % n0;

    double tol = 1.0 - GEOMETRY_RESABS;
    if (fabs(dot0) > tol && fabs(dot1) > tol && fabs(dot2) > tol)
      isFlat = 1;
    else
      isFlat = 0;
  }

  return isFlat;
}
void CubitFacet::is_flat ( int  flat) [inline]

Definition at line 126 of file CubitFacet.hpp.

{isFlat = flat;}; 
void CubitFacet::marked ( int  mark) [inline]

Definition at line 121 of file CubitFacet.hpp.

{markedFlag = mark;}; 
int CubitFacet::marked ( ) [inline]

Definition at line 122 of file CubitFacet.hpp.

{return markedFlag;}; 

Definition at line 633 of file CubitFacet.cpp.

{
    //from the three points find the minimum diagonal.
  CubitVector p1 = point(0)->coordinates();
  CubitVector p2 = point(1)->coordinates();
  CubitVector p3 = point(2)->coordinates();
  CubitVector temp1 = p2-p1;
  CubitVector mid_side_1 = p1 + temp1/2.0;
  CubitVector temp2 = p3-p2;
  CubitVector mid_side_2 = p2 + temp2/2.0;
  CubitVector temp3 = p1-p3;
  CubitVector mid_side_3 = p3 + temp3/2.0;
  CubitVector diagv_1 = p3 - mid_side_1;
  CubitVector diagv_2 = p2 - mid_side_3;
  CubitVector diagv_3 = p1 - mid_side_2;

  double diag_1 = diagv_1.length();
  double diag_2 = diagv_2.length();
  double diag_3 = diagv_3.length();
  if ( diag_1 >= diag_2 && diag_1 >= diag_3 )
    return diag_1;
  else if ( diag_2 > diag_1 && diag_2 > diag_3 )
    return diag_2;
  return diag_3;
}

Definition at line 1001 of file CubitFacet.cpp.

{
  int i;
  for (i=0; i<3; i++) {
    if (theedge == edge(i)) {
      return edge((i+1)%3);
    }
  }
  return NULL;
}

Definition at line 1057 of file CubitFacet.cpp.

{
  int eidx = edge_index( edge_ptr );
  int pidx = point_index( point_ptr );
  switch(eidx)
  {
    case 0:
      switch(pidx)
      {
        case 1: eidx = 2; break;
        case 2: eidx = 1; break;
        default: eidx = -1; break;
      }
      break;
    case 1:
      switch(pidx)
      {
        case 0: eidx = 2; break;
        case 2: eidx = 0; break;
        default: eidx = -1; break;
      }
      break;
    case 2:
      switch(pidx)
      {
        case 0: eidx = 1; break;
        case 1: eidx = 0; break;
        default: eidx = -1; break;
      }
      break;
    default:
      eidx = -1;
      break;
  }
  if (eidx == -1)
    return (CubitFacetEdge *)NULL;

  return edge( eidx );
}
CubitPoint* CubitFacet::next_node ( CubitPoint current_point) [inline]

Definition at line 290 of file CubitFacet.hpp.

  {
    int index = point_index(current_point);
    return point((index+1)%3);
  }

Definition at line 62 of file CubitFacet.cpp.

{
  CubitPlane fac_plane = plane();
  CubitVector the_normal = fac_plane.normal();
  if (isBackwards)
    the_normal = -the_normal;
  return the_normal;
}
void CubitFacet::opposite_edge ( CubitPoint point,
CubitPoint *&  p1,
CubitPoint *&  p2 
)

Definition at line 669 of file CubitFacet.cpp.

{
  p1 = p2 = 0;
  int i;

  for( i = 0; i < 3; i++ )
    if( point(i) == thepoint )
      break;

  if( i < 3 ) //point is on this triangle
  {
    p1 = point((i+1)%3);
    p2 = point((i+2)%3);
  }
}

Definition at line 1232 of file CubitFacet.cpp.

{
  int i;
  for( i = 0; i < 3; i++ )
    if( point(i) != edge->point(0) && point(i) != edge->point(1) )
      return point(i);

  return NULL;
}
int CubitFacet::other_index ( CubitPoint pt1,
CubitPoint pt2 
)

Definition at line 737 of file CubitFacet.cpp.

{
  int i;
  for( i = 0; (point(i) != pt1) && (i < 3); i++ );
  if( i == 3 ) return -1;

  int i1 = (i+1)%3;
  int i2 = (i+2)%3;

  if( point(i1) == pt2 ) return i2;
  else if( point(i2) == pt2 ) return i1;
  else return -1;
}

Definition at line 108 of file CubitFacet.cpp.

{
  if( ! cachedPlane )
  {
    CubitPoint *p0, *p1, *p2;
    points(p0, p1, p2);
    CubitVector v1 = p1->coordinates() - p0->coordinates();
    CubitVector v2 = p2->coordinates() - p0->coordinates();
    cachedPlane = new CubitPlane( v1 * v2, p0->coordinates() );
  }
  return *cachedPlane;
}
void CubitFacet::plane ( CubitPlane this_plane) [inline]

Definition at line 350 of file CubitFacet.hpp.

{ 
  this_plane = plane(); 
} 
virtual CubitPoint* CubitFacet::point ( int  index) [pure virtual]

Implemented in CubitFacetData, and FaceterFacetData.

Definition at line 888 of file CubitFacet.cpp.

{
  if (point(0) == pt) return 0;
  if (point(1) == pt) return 1;
  if (point(2) == pt) return 2;
  return -1;
}
void CubitFacet::points ( CubitPoint *&  p0,
CubitPoint *&  p1,
CubitPoint *&  p2 
) [inline]

Definition at line 248 of file CubitFacet.hpp.

    { p0 = point(0); p1 = point(1); p2 = point(2); }
void CubitFacet::points ( CubitPoint pts[3]) [inline]

Definition at line 250 of file CubitFacet.hpp.

    { pts[0] = point(0); pts[1] = point(1); pts[2] = point(2); }
void CubitFacet::points ( DLIList< CubitPoint * > &  point_list) [inline, virtual]

Implements FacetEntity.

Definition at line 254 of file CubitFacet.hpp.

    { for ( int i = 0; i < 3; i++ ) 
      point_list.append(point(i)); 
    } 

Definition at line 1021 of file CubitFacet.cpp.

{
  int i;
  for (i=0; i<3; i++) {
    if (theedge == edge(i)) {
      return edge((i+2)%3);
    }
  }
  return NULL;
}

Definition at line 966 of file CubitFacet.cpp.

{

  CubitPoint *p1 = point (0);
  CubitPoint *p2 = point (1);
  CubitPoint *p3 = point (2);

  // define the bounding box

  if (!patchCtrlPts || is_flat())
  {
    CubitVector bbox_min, bbox_max;
    bbox_min.x(min3(p1->x(),p2->x(),p3->x()));
    bbox_min.y(min3(p1->y(),p2->y(),p3->y()));
    bbox_min.z(min3(p1->z(),p2->z(),p3->z()));
    bbox_max.x(max3(p1->x(),p2->x(),p3->x()));
    bbox_max.y(max3(p1->y(),p2->y(),p3->y()));
    bbox_max.z(max3(p1->z(),p2->z(),p3->z()));
    bBox.reset(bbox_min,bbox_max);
  }
  else
  {
    update_bezier_bounding_box( );
  }
}
virtual int CubitFacet::sense ( int  ) [inline, virtual]

Reimplemented in CubitFacetData.

Definition at line 161 of file CubitFacet.hpp.

{ assert(0); return -1;}

Definition at line 80 of file CubitFacet.cpp.

{
  if (!patchCtrlPts) {
    patchCtrlPts = new CubitVector [6];
  }
  memcpy( patchCtrlPts, points, 6 *sizeof(CubitVector) );
}
void CubitFacet::set_control_points ( const double *  pt_array)

Definition at line 88 of file CubitFacet.cpp.

{
  if (!patchCtrlPts) {
    patchCtrlPts = new CubitVector [6];
  }
  int ii;
  for (ii=0; ii<6; ii++)
  {
    patchCtrlPts[ii].x(pt_array[3*ii]);
    patchCtrlPts[ii].y(pt_array[3*ii+1]);
    patchCtrlPts[ii].z(pt_array[3*ii+2]);
  }
}
virtual void CubitFacet::set_id ( int  ii) [pure virtual]

Implemented in CubitFacetData, and FaceterFacetData.

void CubitFacet::set_tool_id ( int  tool_id) [inline]

Definition at line 141 of file CubitFacet.hpp.

Definition at line 1260 of file CubitFacet.cpp.

 {
   for( int i=0; i<3; i++ )
     for( int j=0; j<3; j++ )
       if( edge(i) == cubit_facet->edge(j) )
         return edge(i);       

   return NULL;
 }

Definition at line 487 of file CubitFacet.cpp.

{
    //Find the other facet that shares these two points.
  int ii;
  DLIList<CubitFacet*> facet_list;
  p1->facets(facet_list);

  for ( ii = facet_list.size(); ii > 0; ii-- )
  {
    CubitFacet *t_facet = facet_list.get_and_step();
    if ( t_facet == this )
      continue;
    if ( t_facet->contains(p2) )
    {
      assert( t_facet->contains(p1) );
      return t_facet;
    }
  }
  return (CubitFacet*)NULL;
}
CubitFacet * CubitFacet::shared_facet_on_surf ( CubitPoint p1,
CubitPoint p2,
int  tool_id 
)

Definition at line 545 of file CubitFacet.cpp.

{
    //Find the other facet that shares these two points and that
    // is marked with flag.
  int ii;
  DLIList<CubitFacet*> facet_list;
  p1->facets(facet_list);

  for ( ii = facet_list.size(); ii > 0; ii-- )
  {
    CubitFacet *t_facet = facet_list.get_and_step();
    if ( t_facet == this )
      continue;
    if ( t_facet->contains(p2) )
    {
      if (tool_id == t_facet->tool_id())
      {
        assert( t_facet->contains(p1) );
        return t_facet;
      }
    }
  }
  return (CubitFacet*)NULL;
}
void CubitFacet::shared_facets ( CubitPoint p1,
CubitPoint p2,
DLIList< CubitFacet * > &  adj_facet_list 
)

Definition at line 515 of file CubitFacet.cpp.

{
    //Find the other facets that share these two points.
  int ii;
  DLIList<CubitFacet*> facet_list;
  p1->facets(facet_list);

  for ( ii = facet_list.size(); ii > 0; ii-- )
  {
    CubitFacet *t_facet = facet_list.get_and_step();
    if ( t_facet == this )
      continue;
    if ( t_facet->contains(p2) )
    {
      assert( t_facet->contains(p1) );
      adj_facet_list.append( t_facet );
    }
  }
}
CubitPoint * CubitFacet::split_edge ( CubitPoint edge_pt1,
CubitPoint edge_pt2,
const CubitVector position 
) [virtual]

Reimplemented in CubitFacetData, and FaceterFacetData.

Definition at line 695 of file CubitFacet.cpp.

{
  // this function should be implemented in child class since it creates
  // new facet and point entities
  assert(1);
  CubitPoint* new_point = NULL;
  return new_point;
}
int CubitFacet::tool_id ( ) [inline]

Definition at line 140 of file CubitFacet.hpp.

{return toolID;} 
void CubitFacet::tri_nodes ( CubitPoint *&  p0,
CubitPoint *&  p1,
CubitPoint *&  p2 
) [inline]

Definition at line 252 of file CubitFacet.hpp.

    { points( p0, p1, p2); } 

Definition at line 1248 of file CubitFacet.cpp.

{
    
    this->point(0)->remove_facet(this);
    this->point(1)->remove_facet(this);
    this->point(2)->remove_facet(this);
    this->edge(0)->remove_facet(this);
    this->edge(1)->remove_facet(this);
    this->edge(2)->remove_facet(this);    
  
}

Definition at line 923 of file CubitFacet.cpp.

{
  int i,j;
  CubitVector ctrl_pts[5], min, max;
  CubitFacetEdge *myedge;
  CubitBox bbox = bounding_box();
  min = bbox.minimum();
  max = bbox.maximum();
  for (i=0; i<3; i++) {
    myedge = edge(i);
    assert(myedge != 0);
    myedge->control_points( this, ctrl_pts );
    for (j=1; j<4; j++) {
      if (ctrl_pts[j].x() < min.x()) min.x( ctrl_pts[j].x() );
      if (ctrl_pts[j].y() < min.y()) min.y( ctrl_pts[j].y() );
      if (ctrl_pts[j].z() < min.z()) min.z( ctrl_pts[j].z() );
      if (ctrl_pts[j].x() > max.x()) max.x( ctrl_pts[j].x() );
      if (ctrl_pts[j].y() > max.y()) max.y( ctrl_pts[j].y() );
      if (ctrl_pts[j].z() > max.z()) max.z( ctrl_pts[j].z() );
    }
  }
  CubitVector patch_ctrl_pts[6];
  get_control_points( patch_ctrl_pts );
  assert(patch_ctrl_pts != 0);
  for (j=0; j<6; j++) {
    if (patch_ctrl_pts[j].x() < min.x()) min.x( patch_ctrl_pts[j].x() );
    if (patch_ctrl_pts[j].y() < min.y()) min.y( patch_ctrl_pts[j].y() );
    if (patch_ctrl_pts[j].z() < min.z()) min.z( patch_ctrl_pts[j].z() );
    if (patch_ctrl_pts[j].x() > max.x()) max.x( patch_ctrl_pts[j].x() );
    if (patch_ctrl_pts[j].y() > max.y()) max.y( patch_ctrl_pts[j].y() );
    if (patch_ctrl_pts[j].z() > max.z()) max.z( patch_ctrl_pts[j].z() );
  }
  bBox.reset(min,max);
}

Definition at line 1242 of file CubitFacet.cpp.

{
   this->update_plane();
   return normal();
}

Definition at line 121 of file CubitFacet.cpp.

{
  if ( ! cachedPlane )
    return;
  
  CubitPoint *p0, *p1, *p2;
  points(p0, p1, p2);
  CubitVector v1 = p1->coordinates() - p0->coordinates();
  CubitVector v2 = p2->coordinates() - p0->coordinates();
  CubitVector normal = v1 * v2;
  if (is_backwards()) normal = -normal;
  cachedPlane->set(normal, p0->coordinates() );
}
void CubitFacet::weight ( double  facweight) [inline]

Definition at line 101 of file CubitFacet.hpp.

{ facetWeight = facweight; } 
double CubitFacet::weight ( ) [inline]

Definition at line 102 of file CubitFacet.hpp.

{ return facetWeight; } 

Member Data Documentation

Definition at line 58 of file CubitFacet.hpp.

Definition at line 55 of file CubitFacet.hpp.

double CubitFacet::facetWeight [protected]

Definition at line 61 of file CubitFacet.hpp.

int CubitFacet::isBackwards [protected]

Definition at line 73 of file CubitFacet.hpp.

int CubitFacet::isFlat [protected]

Definition at line 70 of file CubitFacet.hpp.

int CubitFacet::markedFlag [protected]

Definition at line 67 of file CubitFacet.hpp.

const double CubitFacet::my_points [static]
Initial value:
 {
  {1.00, 0.00, 0.00},{0.75, 0.25, 0.00},{0.50, 0.50, 0.00},
  {0.25, 0.75, 0.00},{0.00, 1.00, 0.00},{0.75, 0.00, 0.25},
  {0.50, 0.25, 0.25},{0.25, 0.50, 0.25},{0.00, 0.75, 0.25},
  {0.50, 0.00, 0.50},{0.25, 0.25, 0.50},{0.00, 0.50, 0.50},
  {0.25, 0.00, 0.75},{0.00, 0.25, 0.75},{0.00, 0.00, 1.00} }

Definition at line 51 of file CubitFacet.hpp.

Definition at line 64 of file CubitFacet.hpp.

const int CubitFacet::point_edge_conn [static]
Initial value:
 { {4, 8}, {8, 11}, {11, 13}, {13, 14},
                                            {3, 7}, {7, 10}, {10, 12},
                                            {2, 6}, {6, 9},
                                            {1, 5},
                                            {14, 12}, {12, 9}, {9, 5}, {5, 0},
                                            {13, 10}, {10, 6}, {6, 1},
                                            {11, 7}, {7, 2},
                                            {8, 3},
                                            {0, 1}, {1, 2}, {2, 3}, {3, 4},
                                            {5, 6}, {6, 7}, {7, 8},
                                            {9, 10}, {10, 11},
                                            {12, 13} }

Definition at line 49 of file CubitFacet.hpp.

const int CubitFacet::point_facet_conn [static]
Initial value:
 {
  {0, 1, 5}, {1, 6, 5}, {1, 2, 6}, {2, 7, 6}, {2, 3, 7}, {3, 8, 7}, {3, 4, 8},
  {5, 6, 9}, {6, 10, 9}, {6, 7, 10}, {7, 11, 10}, {7, 8, 11},
  {9, 10, 12}, {10, 13, 12}, {10, 11, 13},
  {12, 13, 14} }

Definition at line 50 of file CubitFacet.hpp.

int CubitFacet::toolID [protected]

Definition at line 76 of file CubitFacet.hpp.


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