MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::VertexMaxQM Class Reference

#include <VertexMaxQM.hpp>

+ Inheritance diagram for MBMesquite::VertexMaxQM:
+ Collaboration diagram for MBMesquite::VertexMaxQM:

Public Member Functions

 VertexMaxQM (ElemSampleQM *metric)
virtual ~VertexMaxQM ()
ElemSampleQMget_quality_metric () const
virtual std::string get_name () const
virtual int get_negate_flag () const
 1 if metric should be minimized, -1 if metric should be maximized.
virtual bool evaluate (PatchData &pd, size_t handle, double &value, MsqError &err)
 Get metric value at a logical location in the patch.
virtual bool evaluate_with_indices (PatchData &pd, size_t handle, double &value, std::vector< size_t > &indices, MsqError &err)
 Get metric value at a logical location in the patch.

Private Attributes

ElemSampleQMmMetric
std::vector< size_t > mHandles
std::vector< size_t > mIndices

Detailed Description

Definition at line 43 of file VertexMaxQM.hpp.


Constructor & Destructor Documentation

Definition at line 44 of file VertexMaxQM.cpp.

: mMetric( metric ) {}

Definition at line 46 of file VertexMaxQM.cpp.

{}

Member Function Documentation

bool MBMesquite::VertexMaxQM::evaluate ( PatchData pd,
size_t  handle,
double &  value,
MsqError err 
) [virtual]

Get metric value at a logical location in the patch.

Evaluate the metric at one location in the PatchData.

Parameters:
pdThe patch.
handleThe location in the patch (as passed back from get_evaluations).
valueThe output metric value.

Implements MBMesquite::QualityMetric.

Definition at line 61 of file VertexMaxQM.cpp.

References MBMesquite::QualityMetric::evaluate(), get_quality_metric(), MBMesquite::VertexQM::get_vertex_corner_handles(), mHandles, MSQ_ERRFALSE, and MSQ_ERRZERO.

{
    ElemSampleQM* qm = get_quality_metric();
    get_vertex_corner_handles( pd, handle, mHandles, err );
    MSQ_ERRFALSE( err );

    bool valid = true;
    double tmpval;
    bool tmpvalid;

    value = -std::numeric_limits< double >::infinity();
    for( std::vector< size_t >::iterator h = mHandles.begin(); h != mHandles.end(); ++h )
    {
        tmpvalid = qm->evaluate( pd, *h, tmpval, err );
        MSQ_ERRZERO( err );
        if( !tmpvalid )
            valid = false;
        else if( tmpval > value )
            value = tmpval;
    }

    return valid;
}
bool MBMesquite::VertexMaxQM::evaluate_with_indices ( PatchData pd,
size_t  handle,
double &  value,
std::vector< size_t > &  indices,
MsqError err 
) [virtual]

Get metric value at a logical location in the patch.

Evaluate the metric at one location in the PatchData.

Parameters:
pdThe patch.
handleThe location in the patch (as passed back from get_evaluations).
valueThe output metric value.
indicesThe free vertices that the evaluation is a function of, specified as vertex indices in the PatchData.

Implements MBMesquite::QualityMetric.

Definition at line 85 of file VertexMaxQM.cpp.

References MBMesquite::QualityMetric::evaluate_with_indices(), get_quality_metric(), MBMesquite::VertexQM::get_vertex_corner_handles(), mHandles, mIndices, MSQ_ERRFALSE, MSQ_ERRZERO, and size.

{
    ElemSampleQM* qm = get_quality_metric();
    get_vertex_corner_handles( pd, handle, mHandles, err );
    MSQ_ERRFALSE( err );

    bool valid = true;
    double tmpval;
    bool tmpvalid;
    std::vector< size_t >::iterator i, e, h;

    value = -std::numeric_limits< double >::infinity();
    for( h = mHandles.begin(); h != mHandles.end(); ++h )
    {
        mIndices.clear();
        tmpvalid = qm->evaluate_with_indices( pd, *h, tmpval, mIndices, err );
        MSQ_ERRZERO( err );
        if( !tmpvalid )
            valid = false;
        else if( tmpval > value )
            value = tmpval;

        size_t size = indices.size();
        e           = indices.begin() + size;
        for( i = mIndices.begin(); i != mIndices.end(); ++i )
        {
            if( std::find( indices.begin(), e, *i ) == e )
            {
                indices.push_back( *i );
                e = indices.begin() + size;
            }
        }
    }

    return valid;
}
std::string MBMesquite::VertexMaxQM::get_name ( ) const [virtual]

Implements MBMesquite::QualityMetric.

Definition at line 48 of file VertexMaxQM.cpp.

References MBMesquite::QualityMetric::get_name(), and mMetric.

{
    std::string result( "VertexMaxQM(" );
    result += mMetric->get_name();
    result += ")";
    return result;
}

1 if metric should be minimized, -1 if metric should be maximized.

Implements MBMesquite::QualityMetric.

Definition at line 56 of file VertexMaxQM.cpp.

References MBMesquite::QualityMetric::get_negate_flag(), and mMetric.

{
    return mMetric->get_negate_flag();
}

Definition at line 50 of file VertexMaxQM.hpp.

References mMetric.

Referenced by evaluate(), and evaluate_with_indices().

    {
        return mMetric;
    }

Member Data Documentation

std::vector< size_t > MBMesquite::VertexMaxQM::mHandles [mutable, private]

Definition at line 69 of file VertexMaxQM.hpp.

Referenced by evaluate(), and evaluate_with_indices().

std::vector< size_t > MBMesquite::VertexMaxQM::mIndices [mutable, private]

Definition at line 69 of file VertexMaxQM.hpp.

Referenced by evaluate_with_indices().

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