MOAB: Mesh Oriented datABase  (version 5.4.1)
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)
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 42 of file Util.hpp.


Constructor & Destructor Documentation

moab::Util::Util ( ) [inline, private]

Definition at line 59 of file Util.hpp.

{}

Member Function Documentation

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;
}
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;
    }
}

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines