{
const CartVect* coords = reinterpret_cast<const CartVect*>(vertex_coordinates);
switch( type )
{
case moab::MBEDGE:
return (coords[0] - coords[1]).len();
case moab::MBTRI:
return 0.5 * ((coords[1] - coords[0]) * (coords[2] - coords[0])).len();
case moab::MBQUAD:
num_vertices = 4;
case moab::MBPOLYGON:
{
CartVect mid(0,0,0);
for (int i = 0; i < num_vertices; ++i)
mid += coords[i];
mid /= num_vertices;
double sum = 0.0;
for (int i = 0; i < num_vertices; ++i)
{
int j = (i+1)%num_vertices;
sum += ((mid - coords[i]) * (mid - coords[j])).len();
}
return 0.5 * sum;
}
case moab::MBTET:
return tet_volume( coords[0], coords[1], coords[2], coords[3] ) ;
case moab::MBPYRAMID:
return tet_volume( coords[0], coords[1], coords[2], coords[4] ) +
tet_volume( coords[0], coords[2], coords[3], coords[4] ) ;
case moab::MBPRISM:
return tet_volume( coords[0], coords[1], coords[2], coords[5] ) +
tet_volume( coords[3], coords[5], coords[4], coords[0] ) +
tet_volume( coords[1], coords[4], coords[5], coords[0] ) ;
case moab::MBHEX:
return tet_volume( coords[0], coords[1], coords[3], coords[4] ) +
tet_volume( coords[7], coords[3], coords[6], coords[4] ) +
tet_volume( coords[4], coords[5], coords[1], coords[6] ) +
tet_volume( coords[1], coords[6], coords[3], coords[4] ) +
tet_volume( coords[2], coords[6], coords[3], coords[1] ) ;
default:
return 0.0;
}
}