MOAB: Mesh Oriented datABase  (version 5.2.1)
VerdictWrapper.cpp
Go to the documentation of this file.
00001 /*
00002  * VerdictWrapper.cpp
00003  *
00004  *  Created on: Nov 18, 2014
00005  *
00006  */
00007 
00008 #include "moab/Interface.hpp"
00009 #include "moab/verdict/VerdictWrapper.hpp"
00010 #include "Internals.hpp"
00011 #include "moab/verdict.h"
00012 
00013 namespace moab
00014 {
00015 VerdictWrapper::VerdictWrapper( Interface* mb ) : mbImpl( mb )
00016 {
00017     // TODO Auto-generated constructor stub
00018 }
00019 
00020 VerdictWrapper::~VerdictWrapper()
00021 {
00022     // TODO Auto-generated destructor stub
00023 }
00024 
00025 static int possibleQuality[MBMAXTYPE][MB_QUALITY_COUNT] = {
00026     /*
00027       MB_EDGE_RATIO = 0,  // 0
00028       |  MB_MAX_EDGE_RATIO , // 1
00029       |  |  MB_SKEW,            // 2
00030       |  |  |  MB_TAPER,           // 3
00031       |  |  |  |  MB_VOLUME,          // 4
00032       |  |  |  |  |  MB_STRETCH,         // 5
00033       |  |  |  |  |  |  MB_DIAGONAL,        // 6
00034       |  |  |  |  |  |  |  MB_DIMENSION,       // 7
00035       |  |  |  |  |  |  |  |  MB_ODDY,            // 8
00036       |  |  |  |  |  |  |  |  |  MB_MED_ASPECT_FROBENIUS,// 9
00037       |  |  |  |  |  |  |  |  |  |  MB_MAX_ASPECT_FROBENIUS, // 10
00038       |  |  |  |  |  |  |  |  |  |  |  MB_CONDITION,       // 11
00039       |  |  |  |  |  |  |  |  |  |  |  |  MB_JACOBIAN,        // 12
00040       |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SCALED_JACOBIAN, // 13
00041       |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SHEAR,           // 14
00042       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SHAPE,           // 15
00043       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_RELATIVE_SIZE_SQUARED, // 16
00044       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SHAPE_AND_SIZE,        // 17
00045       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_SHEAR_AND_SIZE,        // 18
00046       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_DISTORTION,            // 19
00047       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_LENGTH,                // 20
00048       only for edge |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_RADIUS_RATIO
00049       // 21 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_ASPECT_BETA //
00050       22 tet (very similar to 21) |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00051       |  MB_ASPECT_RATIO   // 23 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00052       |  |  |  MB_ASPECT_GAMMA // 24 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00053       |  |  |  |  |  MB_MINIMUM_ANGLE // 25 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00054       |  |  |  |  |  |  |  |  MB_COLLAPSE_RATIO // 26 tet |  |  |  |  |  |  |  |  |  |  |  |  |  |
00055       |  |  |  |  |  |  |  |  |  |  |  |  |  MB_WARPAGE     // 27 quad |  |  |  |  |  |  |  |  |  |
00056       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_AREA     // 28 quad |  |  |  |  |  |
00057       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  MB_MAXIMUM_ANGLE // 29
00058       quad |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00059       |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
00060     */
00061     /*0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29*/
00062     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBVERTEX
00063     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBEDGE
00064     { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1 },  //  MBTRI
00065     { 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1 },  //  MBQUAD
00066     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBPOLYGON
00067     { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0 },  //  MBTET
00068     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBPYRAMID
00069     { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBPRISM
00070     { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBKNIFE
00071     { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  // MBHEX
00072     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  //  MBPOLYHEDRON
00073     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }   //  MBENTITYSET
00074 };
00075 
00076 static int numQualities[MBMAXTYPE] = {
00077     0,   // "MBVERTEX"
00078     1,   // "MBEDGE", /**< Mesh Edge */
00079     13,  // "MBTRI", /**< Triangular element (including shells) */
00080     22,  // "MBQUAD", /**< Quadrilateral element (including shells) */
00081     0,   // "MBPOLYGON", /**< Polygon */
00082     14,  // "MBTET", /**< Tetrahedral element */
00083     0,   //"MBPYRAMID", /**< Pyramid element (where are the face ids for this defined?) */
00084     1,   // "MBPRISM", /**< Wedge element (Exodus has one, Cubit doesn't. Does Mesh need it?) */
00085     1,   // "MBKNIFE", /**< Knife element */
00086     20,  // "MBHEX", /**< Hexahedral element */
00087     0,   //"MBPOLYHEDRON", /**< Polyhedron */
00088     0,   // "MBENTITYSET", /**< MeshSet */
00089 };
00090 static char const* nameQuality[MB_QUALITY_COUNT] = {
00091     " edge ratio",                //  MB_EDGE_RATIO = 0,  // 0
00092     " maximum edge ratio",        //  MB_MAX_EDGE_RATIO , // 1
00093     " skew",                      //  MB_SKEW,            // 2
00094     " taper",                     //   MB_TAPER,            // 3
00095     " volume",                    //   MB_VOLUME,          // 4
00096     " stretch",                   //   MB_STRETCH,         // 5
00097     " diagonal",                  //   MB_DIAGONAL,        // 6
00098     " characteristic length",     //  MB_DIMENSION,       // 7
00099     " oddy",                      //   MB_ODDY,            // 8
00100     " average Frobenius aspect",  //  MB_MED_ASPECT_FROBENIUS,// 9
00101     " maximum Frobenius aspect",  //   MB_MAX_ASPECT_FROBENIUS, // 10
00102     " condition number",          //   MB_CONDITION,       // 11
00103     " jacobian",                  //   MB_JACOBIAN,        // 12
00104     " scaled jacobian",           //   MB_SCALED_JACOBIAN, // 13
00105     " shear",                     //   MB_SHEAR,           // 14
00106     " shape",                     //  MB_SHAPE,           // 15
00107     " relative size squared",     //    MB_RELATIVE_SIZE_SQUARED, // 16
00108     " shape and size",            //   MB_SHAPE_AND_SIZE,        // 17
00109     " shear and size",            //   MB_SHEAR_AND_SIZE,        // 18
00110     " distortion",                //   MB_DISTORTION,            // 19
00111                                   // next are QuadMetricVals that are not in hex metrics
00112                                   // length for edge:
00113     " length",                    //   MB_LENGTH,                // 20 only for edge
00114     " radius ratio",              //   MB_RADIUS_RATIO           // 21 tet
00115     " aspect beta",               // MB_ASPECT_BETA              // 22 tet
00116     " aspect ratio",              // MB_ASPECT_RATIO,            // 23 MBTET
00117     " aspect gamma",              // MB_ASPECT_GAMMA             // 24 tet
00118     " minimum angle",             //  MB_MINIMUM_ANGLE,         // 25  MBTET
00119     " collapse ratio",            // MB_COLLAPSE_RATIO,        // 26  MBTET
00120     " warpage",                   // MB_WARPAGE                // 27  MBQUAD
00121     " area",                      // MB_AREA                   // 28  MBQAD
00122     " maximum angle"              // MB_MAXIMUM_ANGLE          // 29  MBQUAD
00123 };
00124 
00125 static const char* nameType[MBMAXTYPE] = {
00126     "MBVERTEX",     /**< Mesh Vertex AKA node */
00127     "MBEDGE",       /**< Mesh Edge */
00128     "MBTRI",        /**< Triangular element (including shells) */
00129     "MBQUAD",       /**< Quadrilateral element (including shells) */
00130     "MBPOLYGON",    /**< Polygon */
00131     "MBTET",        /**< Tetrahedral element */
00132     "MBPYRAMID",    /**< Pyramid element (where are the face ids for this defined?) */
00133     "MBPRISM",      /**< Wedge element (Exodus has one, Cubit doesn't. Does Mesh need it?) */
00134     "MBKNIFE",      /**< Knife element */
00135     "MBHEX",        /**< Hexahedral element */
00136     "MBPOLYHEDRON", /**< Polyhedron */
00137     "MBENTITYSET",  /**< MeshSet */
00138 };
00139 
00140 ErrorCode VerdictWrapper::quality_measure( EntityHandle eh, QualityType q, double& quality, int num_nodes,
00141                                            EntityType etype, double* coords )
00142 {
00143     double coordinates[27][3];  // at most 27 nodes per element
00144 
00145     if( 0 == num_nodes && NULL == coords )
00146     {
00147         etype = TYPE_FROM_HANDLE( eh );
00148         if( possibleQuality[etype][q] == 0 ) return MB_NOT_IMPLEMENTED;
00149 
00150         // get coordinates of points, if not passed already
00151         const EntityHandle* conn = NULL;
00152         // int num_nodes;
00153         ErrorCode rval = mbImpl->get_connectivity( eh, conn, num_nodes );
00154         if( rval != MB_SUCCESS ) return rval;
00155         if( etype != MBPOLYHEDRON )
00156         {
00157             rval = mbImpl->get_coords( conn, num_nodes, &( coordinates[0][0] ) );
00158             if( rval != MB_SUCCESS ) return rval;
00159         }
00160     }
00161     else
00162     {
00163         if( num_nodes > 27 ) return MB_FAILURE;
00164         for( int i = 0; i < num_nodes; i++ )
00165         {
00166             for( int j = 0; j < 3; j++ )
00167                 coordinates[i][j] = coords[3 * i + j];
00168         }
00169     }
00170     VerdictFunction func = 0;
00171 
00172     switch( etype )
00173     {
00174         case MBHEX: {
00175             num_nodes = 8;
00176             switch( q )
00177             {
00178                 case MB_EDGE_RATIO:
00179                     func = v_hex_edge_ratio;
00180                     break;  // 0
00181                 case MB_MAX_EDGE_RATIO:
00182                     func = v_hex_max_edge_ratio;
00183                     break;  // 1
00184                 case MB_SKEW:
00185                     func = v_hex_skew;
00186                     break;  // 2
00187                 case MB_TAPER:
00188                     func = v_hex_taper;
00189                     break;  // 3
00190                 case MB_VOLUME:
00191                     func = v_hex_volume;
00192                     break;  // 4
00193                 case MB_STRETCH:
00194                     func = v_hex_stretch;
00195                     break;  // 5
00196                 case MB_DIAGONAL:
00197                     func = v_hex_diagonal;
00198                     break;  // 6
00199                 case MB_DIMENSION:
00200                     func = v_hex_dimension;
00201                     break;  // 7
00202                 case MB_ODDY:
00203                     func = v_hex_oddy;
00204                     break;  // 8
00205                 case MB_MED_ASPECT_FROBENIUS:
00206                     func = v_hex_med_aspect_frobenius;
00207                     break;  // 9
00208                 case MB_MAX_ASPECT_FROBENIUS:
00209                     func = v_hex_max_aspect_frobenius;
00210                     break;  // 10
00211                 case MB_CONDITION:
00212                     func = v_hex_condition;
00213                     break;  // 11
00214                 case MB_JACOBIAN:
00215                     func = v_hex_jacobian;
00216                     break;  // 12
00217                 case MB_SCALED_JACOBIAN:
00218                     func = v_hex_scaled_jacobian;
00219                     break;  // 13
00220                 case MB_SHEAR:
00221                     func = v_hex_shear;
00222                     break;  // 14
00223                 case MB_SHAPE:
00224                     func = v_hex_shape;
00225                     break;  // 15
00226                 case MB_RELATIVE_SIZE_SQUARED:
00227                     func = v_hex_relative_size_squared;
00228                     break;  // 16
00229                 case MB_SHAPE_AND_SIZE:
00230                     func = v_hex_shape_and_size;
00231                     break;  // 17
00232                 case MB_SHEAR_AND_SIZE:
00233                     func = v_hex_shear_and_size;
00234                     break;  // 18
00235                 case MB_DISTORTION:
00236                     func = v_hex_distortion;
00237                     break;  // 19
00238                 default:
00239                     return MB_FAILURE;
00240             }
00241             break;
00242         }
00243         case MBEDGE: {
00244             num_nodes = 2;
00245             switch( q )
00246             {
00247                 case MB_LENGTH:
00248                     func = v_edge_length;
00249                     break;  // 20
00250                 default:
00251                     return MB_FAILURE;
00252             }
00253             break;
00254         }
00255         case MBTET: {
00256             num_nodes = 4;
00257             switch( q )
00258             {
00259                 case MB_EDGE_RATIO:
00260                     func = v_tet_edge_ratio;
00261                     break;  // 0 //! Calculates tet edge ratio metric.
00262                 case MB_RADIUS_RATIO:
00263                     func = v_tet_radius_ratio;
00264                     break;  // 21
00265                 case MB_ASPECT_BETA:
00266                     func = v_tet_aspect_beta;
00267                     break;  // 22
00268                 case MB_ASPECT_RATIO:
00269                     func = v_tet_aspect_ratio;
00270                     break;  // 23
00271                 case MB_ASPECT_GAMMA:
00272                     func = v_tet_aspect_gamma;
00273                     break;  // 24
00274                 case MB_MAX_ASPECT_FROBENIUS:
00275                     func = v_tet_aspect_frobenius;
00276                     break;  // 10
00277                 case MB_MINIMUM_ANGLE:
00278                     func = v_tet_minimum_angle;
00279                     break;  // 25
00280                 case MB_COLLAPSE_RATIO:
00281                     func = v_tet_collapse_ratio;
00282                     break;  // 26
00283                 case MB_VOLUME:
00284                     func = v_tet_volume;
00285                     break;  // 4
00286                 case MB_CONDITION:
00287                     func = v_tet_condition;
00288                     break;  // 11
00289                 case MB_JACOBIAN:
00290                     func = v_tet_jacobian;
00291                     break;  // 12
00292                 case MB_SCALED_JACOBIAN:
00293                     func = v_tet_scaled_jacobian;
00294                     break;  // 13
00295                 case MB_SHAPE:
00296                     func = v_tet_shape;
00297                     break;  // 15
00298                 case MB_RELATIVE_SIZE_SQUARED:
00299                     func = v_tet_relative_size_squared;
00300                     break;  // 16
00301                 case MB_SHAPE_AND_SIZE:
00302                     func = v_tet_shape_and_size;
00303                     break;  // 17
00304                 case MB_DISTORTION:
00305                     func = v_tet_distortion;
00306                     break;  // 19
00307                 default:
00308                     return MB_FAILURE;
00309             }
00310             break;
00311         }
00312         case MBPRISM: {
00313             num_nodes = 6;
00314             switch( q )
00315             {
00316                 case MB_VOLUME:
00317                     func = v_wedge_volume;
00318                     break;  // 4
00319                 default:
00320                     return MB_FAILURE;
00321             }
00322             break;
00323         }
00324         case MBKNIFE: {
00325             num_nodes = 7;
00326             switch( q )
00327             {
00328                 case MB_VOLUME:
00329                     func = v_knife_volume;
00330                     break;  // 4
00331                 default:
00332                     return MB_FAILURE;
00333             }
00334             break;
00335         }
00336         case MBQUAD: {
00337             num_nodes = 4;
00338             switch( q )
00339             {
00340                 case MB_EDGE_RATIO:
00341                     func = v_quad_edge_ratio;
00342                     break;  // 0
00343                 case MB_MAX_EDGE_RATIO:
00344                     func = v_quad_max_edge_ratio;
00345                     break;  // 1
00346                 case MB_ASPECT_RATIO:
00347                     func = v_quad_aspect_ratio;
00348                     break;  // 23
00349                 case MB_RADIUS_RATIO:
00350                     func = v_quad_radius_ratio;
00351                     break;  // 21
00352                 case MB_MED_ASPECT_FROBENIUS:
00353                     func = v_quad_med_aspect_frobenius;
00354                     break;  // 9
00355                 case MB_MAX_ASPECT_FROBENIUS:
00356                     func = v_quad_max_aspect_frobenius;
00357                     break;  // 10
00358                 case MB_SKEW:
00359                     func = v_quad_skew;
00360                     break;  // 2
00361                 case MB_TAPER:
00362                     func = v_quad_taper;
00363                     break;  // 3
00364                 case MB_WARPAGE:
00365                     func = v_quad_warpage;
00366                     break;  // 27
00367                 case MB_AREA:
00368                     func = v_quad_area;
00369                     break;  // 28
00370                 case MB_STRETCH:
00371                     func = v_quad_stretch;
00372                     break;  // 5
00373                 case MB_MINIMUM_ANGLE:
00374                     func = v_quad_minimum_angle;
00375                     break;  // 25
00376                 case MB_MAXIMUM_ANGLE:
00377                     func = v_quad_maximum_angle;
00378                     break;  // 29
00379                 case MB_ODDY:
00380                     func = v_quad_oddy;
00381                     break;  // 8
00382                 case MB_CONDITION:
00383                     func = v_quad_condition;
00384                     break;  // 11
00385                 case MB_JACOBIAN:
00386                     func = v_quad_jacobian;
00387                     break;  // 12
00388                 case MB_SCALED_JACOBIAN:
00389                     func = v_quad_scaled_jacobian;
00390                     break;  // 13
00391                 case MB_SHEAR:
00392                     func = v_quad_shear;
00393                     break;  // 14
00394                 case MB_SHAPE:
00395                     func = v_quad_shape;
00396                     break;  // 15
00397                 case MB_RELATIVE_SIZE_SQUARED:
00398                     func = v_quad_relative_size_squared;
00399                     break;  // 16
00400                 case MB_SHAPE_AND_SIZE:
00401                     func = v_quad_shape_and_size;
00402                     break;  // 17
00403                 case MB_SHEAR_AND_SIZE:
00404                     func = v_quad_shear_and_size;
00405                     break;  // 18
00406                 case MB_DISTORTION:
00407                     func = v_quad_distortion;
00408                     break;  // 19
00409                 default:
00410                     return MB_FAILURE;
00411             }
00412             break;
00413         }
00414 
00415         case MBTRI: {
00416             num_nodes = 3;
00417             switch( q )
00418             {
00419                 case MB_EDGE_RATIO:
00420                     func = v_tri_edge_ratio;
00421                     break;  // 0
00422                 case MB_ASPECT_RATIO:
00423                     func = v_tri_aspect_ratio;
00424                     break;  // 23
00425                 case MB_RADIUS_RATIO:
00426                     func = v_tri_radius_ratio;
00427                     break;  // 21
00428                 case MB_MAX_ASPECT_FROBENIUS:
00429                     func = v_tri_aspect_frobenius;
00430                     break;  // 10
00431                 case MB_AREA:
00432                     func = v_tri_area;
00433                     break;  // 28
00434                 case MB_MINIMUM_ANGLE:
00435                     func = v_tri_minimum_angle;
00436                     break;  // 25
00437                 case MB_MAXIMUM_ANGLE:
00438                     func = v_tri_maximum_angle;
00439                     break;  // 29
00440                 case MB_CONDITION:
00441                     func = v_tri_condition;
00442                     break;  // 11
00443                 case MB_SCALED_JACOBIAN:
00444                     func = v_tri_scaled_jacobian;
00445                     break;  // 13
00446                 // does not exist, even though it was defined in verdict.h; remove it from there too
00447                 // case MB_SHEAR:                func = v_tri_shear; break;                  // 14
00448                 case MB_RELATIVE_SIZE_SQUARED:
00449                     func = v_tri_relative_size_squared;
00450                     break;  // 16
00451                 case MB_SHAPE:
00452                     func = v_tri_shape;
00453                     break;  // 15
00454                 case MB_SHAPE_AND_SIZE:
00455                     func = v_tri_shape_and_size;
00456                     break;  // 17
00457                 case MB_DISTORTION:
00458                     func = v_tri_distortion;
00459                     break;  // 19
00460                 default:
00461                     return MB_FAILURE;
00462             }
00463             break;
00464         }
00465         default:
00466             break;  // some have no measures
00467     }
00468 
00469     if( !func ) return MB_NOT_IMPLEMENTED;
00470     // actual computation happens here
00471     quality = ( *func )( num_nodes, coordinates );
00472 
00473     return MB_SUCCESS;
00474 }
00475 const char* VerdictWrapper::quality_name( QualityType q )
00476 {
00477     return nameQuality[q];
00478 }
00479 const char* VerdictWrapper::entity_type_name( EntityType etype )
00480 {
00481     return nameType[etype];
00482 }
00483 int VerdictWrapper::num_qualities( EntityType etype )
00484 {
00485     return numQualities[etype];
00486 }
00487 int VerdictWrapper::possible_quality( EntityType et, QualityType q )
00488 {
00489     return possibleQuality[et][q];
00490 }
00491 // relative size needs a base size, that is set at global level, one for each major type (hex, tet,
00492 // quad, tri)
00493 ErrorCode VerdictWrapper::set_size( double size )
00494 {
00495     // set the sizes for all of them; maybe we can set by type, this should be enough for simplicity
00496     v_set_hex_size( size );
00497     v_set_tet_size( size );
00498     v_set_quad_size( size );
00499     v_set_tri_size( size );
00500     return MB_SUCCESS;
00501 }
00502 
00503 ErrorCode VerdictWrapper::all_quality_measures( EntityHandle eh, std::map< QualityType, double >& qualities )
00504 {
00505     EntityType etype = TYPE_FROM_HANDLE( eh );
00506     if( etype == MBPOLYHEDRON || etype == MBVERTEX || etype == MBENTITYSET )
00507         return MB_SUCCESS;  // no quality for polyhedron or vertex or set
00508 
00509     double coordinates[27][3];  // at most 27 nodes per element
00510     // get coordinates of points, if not passed already
00511     const EntityHandle* conn = NULL;
00512     int num_nodes;
00513     ErrorCode rval = mbImpl->get_connectivity( eh, conn, num_nodes );
00514     if( rval != MB_SUCCESS ) return rval;
00515     rval = mbImpl->get_coords( conn, num_nodes, &( coordinates[0][0] ) );
00516     if( rval != MB_SUCCESS ) return rval;
00517 
00518     switch( etype )
00519     {
00520         case MBEDGE: {
00521             double leng          = v_edge_length( 2, coordinates );
00522             qualities[MB_LENGTH] = leng;
00523             break;
00524         }
00525         case MBHEX: {
00526             num_nodes = 8;
00527             HexMetricVals hexMetric;
00528             v_hex_quality( num_nodes, coordinates, V_HEX_ALL, &hexMetric );
00529             qualities[MB_EDGE_RATIO]           = hexMetric.edge_ratio;
00530             qualities[MB_MAX_EDGE_RATIO]       = hexMetric.max_edge_ratio;
00531             qualities[MB_SKEW]                 = hexMetric.skew;
00532             qualities[MB_TAPER]                = hexMetric.taper;
00533             qualities[MB_VOLUME]               = hexMetric.volume;
00534             qualities[MB_STRETCH]              = hexMetric.stretch;
00535             qualities[MB_DIAGONAL]             = hexMetric.diagonal;
00536             qualities[MB_DIMENSION]            = hexMetric.dimension;
00537             qualities[MB_ODDY]                 = hexMetric.oddy;
00538             qualities[MB_MED_ASPECT_FROBENIUS] = hexMetric.med_aspect_frobenius;
00539             // MB_CONDITION is the same as MB_MAX_ASPECT_FROBENIUS
00540             qualities[MB_MAX_ASPECT_FROBENIUS]  = hexMetric.condition;
00541             qualities[MB_CONDITION]             = hexMetric.condition;
00542             qualities[MB_JACOBIAN]              = hexMetric.jacobian;
00543             qualities[MB_SCALED_JACOBIAN]       = hexMetric.scaled_jacobian;
00544             qualities[MB_SHEAR]                 = hexMetric.shear;
00545             qualities[MB_SHAPE]                 = hexMetric.shape;
00546             qualities[MB_RELATIVE_SIZE_SQUARED] = hexMetric.relative_size_squared;
00547             qualities[MB_SHAPE_AND_SIZE]        = hexMetric.shape_and_size;
00548             qualities[MB_SHEAR_AND_SIZE]        = hexMetric.shear_and_size;
00549             qualities[MB_DISTORTION]            = hexMetric.distortion;
00550             break;
00551         }
00552 
00553         case MBTET: {
00554             num_nodes = 4;
00555             TetMetricVals tetMetrics;
00556             v_tet_quality( num_nodes, coordinates, V_TET_ALL, &tetMetrics );
00557             qualities[MB_EDGE_RATIO]            = tetMetrics.edge_ratio;
00558             qualities[MB_RADIUS_RATIO]          = tetMetrics.radius_ratio;
00559             qualities[MB_ASPECT_BETA]           = tetMetrics.aspect_beta;
00560             qualities[MB_ASPECT_RATIO]          = tetMetrics.aspect_ratio;
00561             qualities[MB_ASPECT_GAMMA]          = tetMetrics.aspect_gamma;
00562             qualities[MB_MAX_ASPECT_FROBENIUS]  = tetMetrics.aspect_frobenius;
00563             qualities[MB_MINIMUM_ANGLE]         = tetMetrics.minimum_angle;
00564             qualities[MB_COLLAPSE_RATIO]        = tetMetrics.collapse_ratio;
00565             qualities[MB_VOLUME]                = tetMetrics.volume;
00566             qualities[MB_CONDITION]             = tetMetrics.condition;
00567             qualities[MB_JACOBIAN]              = tetMetrics.jacobian;
00568             qualities[MB_SCALED_JACOBIAN]       = tetMetrics.scaled_jacobian;
00569             qualities[MB_SHAPE]                 = tetMetrics.shape;
00570             qualities[MB_RELATIVE_SIZE_SQUARED] = tetMetrics.relative_size_squared;
00571             qualities[MB_SHAPE_AND_SIZE]        = tetMetrics.shape_and_size;
00572             qualities[MB_DISTORTION]            = tetMetrics.distortion;
00573             break;
00574         }
00575         case MBPRISM: {
00576             num_nodes            = 6;
00577             double volu          = v_wedge_volume( num_nodes, coordinates );
00578             qualities[MB_VOLUME] = volu;
00579             break;
00580         }
00581         case MBKNIFE: {
00582             num_nodes            = 7;
00583             double volu          = v_knife_volume( num_nodes, coordinates );
00584             qualities[MB_VOLUME] = volu;
00585             break;
00586         }
00587         case MBQUAD: {
00588             num_nodes = 4;
00589             QuadMetricVals quadMetrics;
00590             v_quad_quality( num_nodes, coordinates, V_QUAD_ALL, &quadMetrics );
00591             qualities[MB_EDGE_RATIO]            = quadMetrics.edge_ratio;
00592             qualities[MB_MAX_EDGE_RATIO]        = quadMetrics.max_edge_ratio;
00593             qualities[MB_ASPECT_RATIO]          = quadMetrics.aspect_ratio;           // 23
00594             qualities[MB_RADIUS_RATIO]          = quadMetrics.radius_ratio;           // 21
00595             qualities[MB_MED_ASPECT_FROBENIUS]  = quadMetrics.med_aspect_frobenius;   // 9
00596             qualities[MB_MAX_ASPECT_FROBENIUS]  = quadMetrics.max_aspect_frobenius;   // 10
00597             qualities[MB_SKEW]                  = quadMetrics.skew;                   // 2
00598             qualities[MB_TAPER]                 = quadMetrics.taper;                  // 3
00599             qualities[MB_WARPAGE]               = quadMetrics.warpage;                // 27
00600             qualities[MB_AREA]                  = quadMetrics.area;                   // 28
00601             qualities[MB_STRETCH]               = quadMetrics.stretch;                // 5
00602             qualities[MB_MINIMUM_ANGLE]         = quadMetrics.minimum_angle;          // 25
00603             qualities[MB_MAXIMUM_ANGLE]         = quadMetrics.maximum_angle;          // 29
00604             qualities[MB_ODDY]                  = quadMetrics.oddy;                   // 8
00605             qualities[MB_CONDITION]             = quadMetrics.condition;              // 11
00606             qualities[MB_JACOBIAN]              = quadMetrics.jacobian;               // 12
00607             qualities[MB_SCALED_JACOBIAN]       = quadMetrics.scaled_jacobian;        // 13
00608             qualities[MB_SHEAR]                 = quadMetrics.shear;                  // 14
00609             qualities[MB_SHAPE]                 = quadMetrics.shape;                  // 15
00610             qualities[MB_RELATIVE_SIZE_SQUARED] = quadMetrics.relative_size_squared;  // 16
00611             qualities[MB_SHAPE_AND_SIZE]        = quadMetrics.shape_and_size;         // 17
00612             qualities[MB_SHEAR_AND_SIZE]        = quadMetrics.shear_and_size;         // 18
00613             qualities[MB_DISTORTION]            = quadMetrics.distortion;             // 19
00614             break;
00615         }
00616 
00617         case MBTRI: {
00618             num_nodes = 3;
00619             TriMetricVals triMetrics;
00620             v_tri_quality( num_nodes, coordinates, V_TRI_ALL, &triMetrics );
00621             qualities[MB_EDGE_RATIO]           = triMetrics.edge_ratio;        // 0
00622             qualities[MB_ASPECT_RATIO]         = triMetrics.aspect_ratio;      // 23
00623             qualities[MB_RADIUS_RATIO]         = triMetrics.radius_ratio;      // 21
00624             qualities[MB_MAX_ASPECT_FROBENIUS] = triMetrics.aspect_frobenius;  // 10
00625             qualities[MB_AREA]                 = triMetrics.area;              // 28
00626             qualities[MB_MINIMUM_ANGLE]        = triMetrics.minimum_angle;     // 25
00627             qualities[MB_MAXIMUM_ANGLE]        = triMetrics.maximum_angle;     // 29
00628             qualities[MB_CONDITION]            = triMetrics.condition;         // 11
00629             qualities[MB_SCALED_JACOBIAN]      = triMetrics.scaled_jacobian;   // 13
00630             // does not exist, even though it was defined in verdict.h; remove it from there too
00631             // case MB_SHEAR:                func = v_tri_shear; break;                  // 14
00632             qualities[MB_RELATIVE_SIZE_SQUARED] = triMetrics.relative_size_squared;  // 16
00633             qualities[MB_SHAPE]                 = triMetrics.shape;                  // 15
00634             qualities[MB_SHAPE_AND_SIZE]        = triMetrics.shape_and_size;         // 17
00635             qualities[MB_DISTORTION]            = triMetrics.distortion;             // 19
00636             break;
00637         }
00638         default:
00639             return MB_NOT_IMPLEMENTED;
00640     }
00641     return MB_SUCCESS;
00642 }
00643 
00644 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines