Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
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 | |
static void | centroid (Interface *MB, EntityHandle handle, CartVect &coord) |
Private Member Functions | |
Util () |
Utility functions for computational geometry and mathematical calculations.
moab::Util::Util | ( | ) | [inline, private] |
void moab::Util::centroid | ( | Interface * | MB, |
EntityHandle | handle, | ||
CartVect & | coord | ||
) | [static] |
Definition at line 78 of file Util.cpp.
References ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), and MB_CHK_SET_ERR_RET.
{ const EntityHandle* connectivity = NULL; int number_nodes = 0; // TODO make the return value nonvoid ErrorCode rval = MB->get_connectivity( handle, connectivity, number_nodes, true );MB_CHK_SET_ERR_RET( rval, "can't get_connectivity" ); coord[0] = coord[1] = coord[2] = 0.0; for( int i = 0; i < number_nodes; i++ ) { double node_coords[3]; MB->get_coords( &( connectivity[i] ), 1, node_coords ); coord[0] += node_coords[0]; coord[1] += node_coords[1]; coord[2] += node_coords[2]; } coord[0] /= (double)number_nodes; coord[1] /= (double)number_nodes; coord[2] /= (double)number_nodes; }
template bool moab::Util::is_finite< double > | ( | T | value | ) | [inline, static] |
Definition at line 63 of file Util.hpp.
References moab_isfinite.
Referenced by moab::ReadMCNP5::average_tally_values(), moab::Matrix3::invert(), moab::point_perp(), moab::AdaptiveKDTree::ray_intersect_triangles(), moab::ReadMCNP5::read_element_values_and_errors(), moab::GeomUtil::segment_box_intersect(), and moab::BSPTree::set_split_plane().
{ return moab_isfinite( (double)value ); }
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.
References ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), and MB_CHK_SET_ERR_RET.
Referenced by moab::Skinner::has_larger_angle().
{ // get connectivity const EntityHandle* connectivity = NULL; int number_nodes = 0; // TODO make the return value nonvoid ErrorCode rval = MB->get_connectivity( handle, connectivity, number_nodes, true );MB_CHK_SET_ERR_RET( rval, "can't get_connectivity" ); assert( number_nodes >= 3 ); // get_coordinates double coords[3][3]; MB->get_coords( &( connectivity[0] ), 1, coords[0] ); MB->get_coords( &( connectivity[1] ), 1, coords[1] ); MB->get_coords( &( connectivity[2] ), 1, coords[2] ); double vecs[2][3]; vecs[0][0] = coords[1][0] - coords[0][0]; vecs[0][1] = coords[1][1] - coords[0][1]; vecs[0][2] = coords[1][2] - coords[0][2]; vecs[1][0] = coords[2][0] - coords[0][0]; vecs[1][1] = coords[2][1] - coords[0][1]; vecs[1][2] = coords[2][2] - coords[0][2]; x = vecs[0][1] * vecs[1][2] - vecs[0][2] * vecs[1][1]; y = vecs[0][2] * vecs[1][0] - vecs[0][0] * vecs[1][2]; z = vecs[0][0] * vecs[1][1] - vecs[0][1] * vecs[1][0]; double mag = sqrt( x * x + y * y + z * z ); if( mag > std::numeric_limits< double >::epsilon() ) { x /= mag; y /= mag; z /= mag; } }