moab
|
Utility functions for normal and centroid for entities. More...
#include <Util.hpp>
Static Public Member Functions | |
static void | normal (Interface *MB, EntityHandle handle, double &x, double &y, double &z) |
static void | centroid (Interface *MB, EntityHandle handle, Coord &coord) |
Private Member Functions | |
Util () |
moab::Util::Util | ( | ) | [inline, private] |
void moab::Util::centroid | ( | Interface * | MB, |
EntityHandle | handle, | ||
Coord & | coord | ||
) | [static] |
Definition at line 80 of file Util.cpp.
{ const EntityHandle *connectivity; int number_nodes = 0; MB->get_connectivity(handle, connectivity, number_nodes,true); coord.x=0.0; coord.y=0.0; coord.z=0.0; for(int i = 0; i< number_nodes; i++) { double node_coords[3]; MB->get_coords(&(connectivity[i]), 1, node_coords); coord.x+=node_coords[0]; coord.y+=node_coords[1]; coord.z+=node_coords[2]; } coord.x/=(double)number_nodes; coord.y/=(double)number_nodes; coord.z/=(double)number_nodes; }
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 45 of file Util.cpp.
{ // get connectivity const EntityHandle *connectivity; int number_nodes = 0; MB->get_connectivity(handle, connectivity, number_nodes, true); 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; } }