cgma
GeoTet Class Reference

#include <GeoTet.hpp>

Inheritance diagram for GeoTet:
ToolDataUser

List of all members.

Public Member Functions

 GeoTet (GeoNode *nodes[4])
 ~GeoTet ()
void tet_nodes (GeoNode *&na, GeoNode *&nb, GeoNode *&nc, GeoNode *&nd)
void tet_face_nodes (int face_index, GeoNode *&na, GeoNode *&nb, GeoNode *&nc)
GeoTetget_connected_tet (GeoNode *na, GeoNode *nb, GeoNode *nc)
GeoTetget_connected_tet (int face_index)
int node_index (GeoNode *node_ptr)
void opposite_edge (GeoNode *a_node, GeoNode *b_node, GeoNode *&c_node, GeoNode *&d_node)
void marked (int flag)
int marked ()
void inside (int is_inside)
int inside ()
CubitStatus circumsphere (CubitVector &circumcenter, double *radius=NULL)

Private Attributes

GeoNodemNodes [4]
cBit isMarked: 1
cBit isInside: 1

Detailed Description

Definition at line 26 of file GeoTet.hpp.


Constructor & Destructor Documentation

GeoTet::GeoTet ( GeoNode nodes[4])

Definition at line 31 of file GeoTet.cpp.

                                  : isMarked(0), isInside(0)
{
  mNodes[0] = nodes[0];
  mNodes[1] = nodes[1];
  mNodes[2] = nodes[2];
  mNodes[3] = nodes[3];
}

Definition at line 45 of file GeoTet.cpp.

{
}

Member Function Documentation

CubitStatus GeoTet::circumsphere ( CubitVector circumcenter,
double *  radius = NULL 
)

Definition at line 199 of file GeoTet.cpp.

{
  double reltol = DBL_EPSILON * 100.0;

  CubitVector a = mNodes[0]->coordinates();
  CubitVector b = mNodes[1]->coordinates();
  CubitVector c = mNodes[2]->coordinates();
  CubitVector d = mNodes[3]->coordinates();

  CubitVector da = a - d;
  CubitVector db = b - d;
  CubitVector dc = c - d;

  double rhsa = 0.5*(SQR(da.x()) + SQR(da.y()) + SQR(da.z()));
  double rhsb = 0.5*(SQR(db.x()) + SQR(db.y()) + SQR(db.z()));
  double rhsc = 0.5*(SQR(dc.x()) + SQR(dc.y()) + SQR(dc.z()));

  double cpa = db.y()*dc.z() - dc.y()*db.z();
  double cpb = dc.y()*da.z() - da.y()*dc.z();
  double cpc = da.y()*db.z() - db.y()*da.z();

  double det = da.x()*cpa + db.x()*cpb + dc.x()*cpc;

  double xmax = CUBIT_MAX(fabs(a.x()),fabs(b.x()));
         xmax = CUBIT_MAX(xmax,fabs(c.x())); 
         xmax = CUBIT_MAX(xmax,fabs(d.x()));
  double ymax = CUBIT_MAX(fabs(a.y()),fabs(b.y()));
         ymax = CUBIT_MAX(ymax,fabs(c.y())); 
         ymax = CUBIT_MAX(ymax,fabs(d.y()));
  double zmax = CUBIT_MAX(fabs(a.z()),fabs(b.z()));
         zmax = CUBIT_MAX(zmax,fabs(c.z())); 
         zmax = CUBIT_MAX(zmax,fabs(d.z()));
  double tolabs = reltol*xmax*ymax*zmax;
  if (fabs(det) <= tolabs) {
    return CUBIT_FAILURE;
  }
  center.x( (rhsa*cpa + rhsb*cpb + rhsc*cpc)/det );
  cpa = db.x()*rhsc - dc.x()*rhsb;
  cpb = dc.x()*rhsa - da.x()*rhsc;
  cpc = da.x()*rhsb - db.x()*rhsa;
  center.y( (da.z()*cpa + db.z()*cpb + dc.z()*cpc)/det );
  center.z( -(da.y()*cpa + db.y()*cpb + dc.y()*cpc)/det );
  center += d;

  if ( radius )
  {
      double radsq = SQR(center.x()) + SQR(center.y()) + SQR(center.z());
      *radius = sqrt( radsq );
  }

  return CUBIT_SUCCESS;
}
GeoTet * GeoTet::get_connected_tet ( GeoNode na,
GeoNode nb,
GeoNode nc 
)

Definition at line 100 of file GeoTet.cpp.

{
  GeoTet *adj_tet = NULL;
  int ii;

  // get the tets adjacent 
  DLIList<GeoTet *> *tet_list_ptr = na->tet_list();
  GeoTet *tet_ptr;
  for (ii=0; ii<tet_list_ptr->size() && !adj_tet; ii++)
  {
    tet_ptr = tet_list_ptr->get_and_step();
    if (tet_ptr != this)
    {
      if (tet_ptr->node_index( nb ) >= 0 &&
          tet_ptr->node_index( nc ) >= 0)
      {
        adj_tet = tet_ptr;
      }
    }
  }

  return adj_tet;
}
GeoTet * GeoTet::get_connected_tet ( int  face_index)

Definition at line 87 of file GeoTet.cpp.

{
    GeoNode *n1, *n2, *n3;
    tet_face_nodes( face_indx, n1, n2, n3 );
    return get_connected_tet( n1, n2, n3 );
}
void GeoTet::inside ( int  is_inside) [inline]

Definition at line 72 of file GeoTet.hpp.

{ isInside = is_inside; }
int GeoTet::inside ( ) [inline]

Definition at line 73 of file GeoTet.hpp.

{ return isInside; }
void GeoTet::marked ( int  flag) [inline]

Definition at line 68 of file GeoTet.hpp.

{ isMarked = flag; }
int GeoTet::marked ( ) [inline]

Definition at line 69 of file GeoTet.hpp.

{ return isMarked; }
int GeoTet::node_index ( GeoNode node_ptr)

Definition at line 130 of file GeoTet.cpp.

{
  int ii;
  for (ii=0; ii<4; ii++)
  {
    if (mNodes[ii] == node_ptr)
      return ii;
  }
  return -1;
}
void GeoTet::opposite_edge ( GeoNode a_node,
GeoNode b_node,
GeoNode *&  c_node,
GeoNode *&  d_node 
)

Definition at line 149 of file GeoTet.cpp.

{
  int ii;
  c_node = d_node = NULL;
  for (ii=0; ii<4; ii++)
  {
    if (mNodes[ii] != a_node && mNodes[ii] != b_node)
    {
      if (!c_node)
      {
        c_node = mNodes[ii];
      }
      else if(!d_node)
      {
        d_node = mNodes[ii];
      }
      else
      {
        PRINT_ERROR("a_node or b_node are not on this tet.\n");
        return;
      }
    }
  }
}
void GeoTet::tet_face_nodes ( int  face_index,
GeoNode *&  na,
GeoNode *&  nb,
GeoNode *&  nc 
)

Definition at line 69 of file GeoTet.cpp.

{
    int node_face_idx[4][3] = { { 1, 2, 3 },
                                { 3, 2, 0 },
                                { 0, 1, 3 },
                                { 2, 1, 0 } };
    na = mNodes[node_face_idx[face_index][0]];
    nb = mNodes[node_face_idx[face_index][1]];
    nc = mNodes[node_face_idx[face_index][2]];

}
void GeoTet::tet_nodes ( GeoNode *&  na,
GeoNode *&  nb,
GeoNode *&  nc,
GeoNode *&  nd 
)

Definition at line 55 of file GeoTet.cpp.

{
  na = mNodes[0];
  nb = mNodes[1];
  nc = mNodes[2];
  nd = mNodes[3];
}

Member Data Documentation

Definition at line 36 of file GeoTet.hpp.

Definition at line 33 of file GeoTet.hpp.

GeoNode* GeoTet::mNodes[4] [private]

Definition at line 30 of file GeoTet.hpp.


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