moab
measure.hpp File Reference
#include "moab/CN.hpp"

Go to the source code of this file.

Functions

double edge_length (const double *start_vtx_coords, const double *end_vtx_coords)
double measure (moab::EntityType type, int num_vertices, const double *vertex_coordinatee)

Function Documentation

double edge_length ( const double *  start_vtx_coords,
const double *  end_vtx_coords 
)

Definition at line 145 of file measure.cpp.

{
  const CartVect* start = reinterpret_cast<const CartVect*>(start_vtx_coords);
  const CartVect*   end = reinterpret_cast<const CartVect*>(  end_vtx_coords);
  return (*start - *end).len();
}
double measure ( moab::EntityType  type,
int  num_vertices,
const double *  vertex_coordinatee 
)

Definition at line 153 of file measure.cpp.

{
  const CartVect* coords = reinterpret_cast<const CartVect*>(vertex_coordinates);
  switch( type )
  {
    case moab::MBEDGE:
      return (coords[0] - coords[1]).len();
    case moab::MBTRI:
      return 0.5 * ((coords[1] - coords[0]) * (coords[2] - coords[0])).len();
    case moab::MBQUAD:
      num_vertices = 4;
    case moab::MBPOLYGON:
    {
      CartVect mid(0,0,0);
      for (int i = 0; i < num_vertices; ++i)
        mid += coords[i];
      mid /= num_vertices;
      
      double sum = 0.0;
      for (int i = 0; i < num_vertices; ++i)
      {
        int j = (i+1)%num_vertices;
        sum += ((mid - coords[i]) * (mid - coords[j])).len();
      }
      return 0.5 * sum;
    }
    case moab::MBTET:
      return tet_volume( coords[0], coords[1], coords[2], coords[3] ) ;
    case moab::MBPYRAMID:
      return tet_volume( coords[0], coords[1], coords[2], coords[4] ) +
             tet_volume( coords[0], coords[2], coords[3], coords[4] ) ;
    case moab::MBPRISM:
      return tet_volume( coords[0], coords[1], coords[2], coords[5] ) +
             tet_volume( coords[3], coords[5], coords[4], coords[0] ) +
             tet_volume( coords[1], coords[4], coords[5], coords[0] ) ;
    case moab::MBHEX:
      return tet_volume( coords[0], coords[1], coords[3], coords[4] ) +
             tet_volume( coords[7], coords[3], coords[6], coords[4] ) +
             tet_volume( coords[4], coords[5], coords[1], coords[6] ) +
             tet_volume( coords[1], coords[6], coords[3], coords[4] ) +
             tet_volume( coords[2], coords[6], coords[3], coords[1] ) ;
    default:
      return 0.0;
  }
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines