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 () | |
Utility functions for computational geometry and mathematical calculations.
|
static |
Definition at line 78 of file Util.cpp.
79 {
80 const EntityHandle* connectivity = NULL;
81 int number_nodes = 0;
82 // TODO make the return value nonvoid
83 ErrorCode rval = MB->get_connectivity( handle, connectivity, number_nodes, true );MB_CHK_SET_ERR_RET( rval, "can't get_connectivity" );
84
85 coord[0] = coord[1] = coord[2] = 0.0;
86
87 for( int i = 0; i < number_nodes; i++ )
88 {
89 double node_coords[3];
90 MB->get_coords( &( connectivity[i] ), 1, node_coords );
91
92 coord[0] += node_coords[0];
93 coord[1] += node_coords[1];
94 coord[2] += node_coords[2];
95 }
96
97 coord[0] /= (double)number_nodes;
98 coord[1] /= (double)number_nodes;
99 coord[2] /= (double)number_nodes;
100 }
References ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), and MB_CHK_SET_ERR_RET.
|
inlinestatic |
Definition at line 63 of file Util.hpp.
64 {
65 return moab_isfinite( (double)value );
66 }
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().
|
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 );MB_CHK_SET_ERR_RET( rval, "can't get_connectivity" );
49 assert( number_nodes >= 3 );
50
51 // get_coordinates
52 double coords[3][3];
53 MB->get_coords( &( connectivity[0] ), 1, coords[0] );
54 MB->get_coords( &( connectivity[1] ), 1, coords[1] );
55 MB->get_coords( &( connectivity[2] ), 1, coords[2] );
56
57 double vecs[2][3];
58 vecs[0][0] = coords[1][0] - coords[0][0];
59 vecs[0][1] = coords[1][1] - coords[0][1];
60 vecs[0][2] = coords[1][2] - coords[0][2];
61 vecs[1][0] = coords[2][0] - coords[0][0];
62 vecs[1][1] = coords[2][1] - coords[0][1];
63 vecs[1][2] = coords[2][2] - coords[0][2];
64
65 x = vecs[0][1] * vecs[1][2] - vecs[0][2] * vecs[1][1];
66 y = vecs[0][2] * vecs[1][0] - vecs[0][0] * vecs[1][2];
67 z = vecs[0][0] * vecs[1][1] - vecs[0][1] * vecs[1][0];
68
69 double mag = sqrt( x * x + y * y + z * z );
70 if( mag > std::numeric_limits< double >::epsilon() )
71 {
72 x /= mag;
73 y /= mag;
74 z /= mag;
75 }
76 }
References ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), and MB_CHK_SET_ERR_RET.
Referenced by moab::Skinner::has_larger_angle().