Mesh Oriented datABase  (version 5.6.0)
An array-based unstructured mesh library
moab::Util Class Reference

Utility functions for computational geometry and mathematical calculations. More...

#include <Util.hpp>

Static Public Member Functions

template<typename T >
static bool is_finite (T value)
 
static void normal (Interface *MB, EntityHandle handle, double &x, double &y, double &z)
 temporary normal function for MBEntities. This should be moved to an appropriate MB algorithms file More...
 
static void centroid (Interface *MB, EntityHandle handle, CartVect &coord)
 

Private Member Functions

 Util ()
 

Detailed Description

Utility functions for computational geometry and mathematical calculations.

Definition at line 44 of file Util.hpp.

Constructor & Destructor Documentation

◆ Util()

moab::Util::Util ( )
inlineprivate

Definition at line 61 of file Util.hpp.

61 {}

Member Function Documentation

◆ centroid()

void moab::Util::centroid ( Interface MB,
EntityHandle  handle,
CartVect coord 
)
static

Definition at line 79 of file Util.cpp.

80 {
81  const EntityHandle* connectivity = NULL;
82  int number_nodes = 0;
83  // TODO make the return value nonvoid
84  ErrorCode rval = MB->get_connectivity( handle, connectivity, number_nodes, true );
85  MB_CHK_SET_ERR_RET( rval, "can't get_connectivity" );
86 
87  coord[0] = coord[1] = coord[2] = 0.0;
88 
89  for( int i = 0; i < number_nodes; i++ )
90  {
91  double node_coords[3];
92  MB->get_coords( &( connectivity[i] ), 1, node_coords );
93 
94  coord[0] += node_coords[0];
95  coord[1] += node_coords[1];
96  coord[2] += node_coords[2];
97  }
98 
99  coord[0] /= (double)number_nodes;
100  coord[1] /= (double)number_nodes;
101  coord[2] /= (double)number_nodes;
102 }

References ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), and MB_CHK_SET_ERR_RET.

◆ is_finite()

template<typename T >
template bool moab::Util::is_finite< double > ( value)
inlinestatic

◆ normal()

void moab::Util::normal ( Interface MB,
EntityHandle  handle,
double &  x,
double &  y,
double &  z 
)
static

temporary normal function for MBEntities. This should be moved to an appropriate MB algorithms file

Definition at line 42 of file Util.cpp.

43 {
44  // get connectivity
45  const EntityHandle* connectivity = NULL;
46  int number_nodes = 0;
47  // TODO make the return value nonvoid
48  ErrorCode rval = MB->get_connectivity( handle, connectivity, number_nodes, true );
49  MB_CHK_SET_ERR_RET( rval, "can't get_connectivity" );
50  assert( number_nodes >= 3 );
51 
52  // get_coordinates
53  double coords[3][3];
54  MB->get_coords( &( connectivity[0] ), 1, coords[0] );
55  MB->get_coords( &( connectivity[1] ), 1, coords[1] );
56  MB->get_coords( &( connectivity[2] ), 1, coords[2] );
57 
58  double vecs[2][3];
59  vecs[0][0] = coords[1][0] - coords[0][0];
60  vecs[0][1] = coords[1][1] - coords[0][1];
61  vecs[0][2] = coords[1][2] - coords[0][2];
62  vecs[1][0] = coords[2][0] - coords[0][0];
63  vecs[1][1] = coords[2][1] - coords[0][1];
64  vecs[1][2] = coords[2][2] - coords[0][2];
65 
66  x = vecs[0][1] * vecs[1][2] - vecs[0][2] * vecs[1][1];
67  y = vecs[0][2] * vecs[1][0] - vecs[0][0] * vecs[1][2];
68  z = vecs[0][0] * vecs[1][1] - vecs[0][1] * vecs[1][0];
69 
70  double mag = sqrt( x * x + y * y + z * z );
71  if( mag > std::numeric_limits< double >::epsilon() )
72  {
73  x /= mag;
74  y /= mag;
75  z /= mag;
76  }
77 }

References ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), and MB_CHK_SET_ERR_RET.

Referenced by moab::Skinner::has_larger_angle().


The documentation for this class was generated from the following files: