Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
measure.hpp File Reference
#include "moab/CN.hpp"
+ Include dependency graph for measure.hpp:
+ This graph shows which files directly or indirectly include this file:

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

◆ edge_length()

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

Definition at line 35 of file measure.cpp.

36 {
37  const CartVect* start = reinterpret_cast< const CartVect* >( start_vtx_coords );
38  const CartVect* end = reinterpret_cast< const CartVect* >( end_vtx_coords );
39  return ( *start - *end ).length();
40 }

References moab::CartVect::length().

Referenced by gather_set_stats(), and moab::Intx2Mesh::intersect_meshes_kdtree().

◆ measure()

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

Definition at line 42 of file measure.cpp.

43 {
44  const CartVect* coords = reinterpret_cast< const CartVect* >( vertex_coordinates );
45  switch( type )
46  {
47  case moab::MBEDGE:
48  return ( coords[0] - coords[1] ).length();
49  case moab::MBTRI:
50  return 0.5 * ( ( coords[1] - coords[0] ) * ( coords[2] - coords[0] ) ).length();
51  case moab::MBQUAD:
52  num_vertices = 4;
53  // fall through
54  case moab::MBPOLYGON: {
55  CartVect mid( 0, 0, 0 );
56  for( int i = 0; i < num_vertices; ++i )
57  mid += coords[i];
58  mid /= num_vertices;
59 
60  double sum = 0.0;
61  for( int i = 0; i < num_vertices; ++i )
62  {
63  int j = ( i + 1 ) % num_vertices;
64  sum += ( ( mid - coords[i] ) * ( mid - coords[j] ) ).length();
65  }
66  return 0.5 * sum;
67  }
68  case moab::MBTET:
69  return tet_volume( coords[0], coords[1], coords[2], coords[3] );
70  case moab::MBPYRAMID:
71  return tet_volume( coords[0], coords[1], coords[2], coords[4] ) +
72  tet_volume( coords[0], coords[2], coords[3], coords[4] );
73  case moab::MBPRISM:
74  return tet_volume( coords[0], coords[1], coords[2], coords[5] ) +
75  tet_volume( coords[3], coords[5], coords[4], coords[0] ) +
76  tet_volume( coords[1], coords[4], coords[5], coords[0] );
77  case moab::MBHEX:
78  return tet_volume( coords[0], coords[1], coords[3], coords[4] ) +
79  tet_volume( coords[7], coords[3], coords[6], coords[4] ) +
80  tet_volume( coords[4], coords[5], coords[1], coords[6] ) +
81  tet_volume( coords[1], coords[6], coords[3], coords[4] ) +
82  tet_volume( coords[2], coords[6], coords[3], coords[1] );
83  default:
84  return 0.0;
85  }
86 }

References length(), MBEDGE, MBHEX, MBPOLYGON, MBPRISM, MBPYRAMID, MBQUAD, MBTET, MBTRI, moab::sum(), and tet_volume().