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

Construct target matrices from factors of guide matrices. More...

#include <LVQDTargetCalculator.hpp>

+ Inheritance diagram for MBMesquite::LVQDTargetCalculator:
+ Collaboration diagram for MBMesquite::LVQDTargetCalculator:

Public Member Functions

 LVQDTargetCalculator (TargetCalculator *lambda_source, TargetCalculator *V_source, TargetCalculator *Q_source, TargetCalculator *delta_source)
 ~LVQDTargetCalculator ()
bool get_3D_target (PatchData &pd, size_t element, Sample sample, MsqMatrix< 3, 3 > &W_out, MsqError &err)
 Get a target matrix.
bool get_surface_target (PatchData &pd, size_t element, Sample sample, MsqMatrix< 3, 2 > &W_out, MsqError &err)
 Get a target matrix.
bool get_2D_target (PatchData &pd, size_t element, Sample sample, MsqMatrix< 2, 2 > &W_out, MsqError &err)
 Get a target matrix.
bool have_surface_orient () const
 Use 3x2 W for surface elements if true, 2x2 W if false.

Private Member Functions

int add_source (TargetCalculator *source)
bool evaluate_guide_2D (PatchData &pd, size_t element, Sample sample, int idx, double &lambda, MsqMatrix< 3, 2 > &V, MsqMatrix< 2, 2 > &Q, MsqMatrix< 2, 2 > &delta, MsqError &err)

Private Attributes

TargetCalculatoruniqueGuides [4]
 Up to 4 unique target sources.
int numUniqueGuides
 Number of unique target sources.
int lambdaIdx
int vIdx
int qIdx
int deltaIdx

Detailed Description

Construct target matrices from factors of guide matrices.

Given a set of guide matrices, extract certain properties from them and combine those properties to produce a target matrix. \(\mathbf{W}=\lambda(\mathbf{W_\lambda}) \times \mathbf{V}(\mathbf{W_V}) \times \mathbf{Q}(\mathbf{W_Q}) \times \mathbf{\Delta}(\mathbf{W_\Delta})\)

  • \(\lambda\) - scalar - size component of \(\mathbf{W_\lambda}\)
  • \(\mathbf{V}\) - 3x3 or 3x2 - orientation component of \(\mathbf{W_V}\)
  • \(\mathbf{Q}\) - 3x3 or 2x2 - shape component of \(\mathbf{W_Q}\)
  • \(\mathbf{\Delta}\) - 3x3 or 2x2 - aspect ratio component of \(\mathbf{W_\Delta}\)

Definition at line 53 of file LVQDTargetCalculator.hpp.


Constructor & Destructor Documentation

Definition at line 55 of file LVQDTargetCalculator.cpp.

References add_source(), deltaIdx, lambdaIdx, qIdx, and vIdx.

    : numUniqueGuides( 0 )
{
    lambdaIdx = add_source( lambda_source );
    vIdx      = add_source( V_source );
    qIdx      = add_source( Q_source );
    deltaIdx  = add_source( delta_source );
}

Member Function Documentation

Definition at line 42 of file LVQDTargetCalculator.cpp.

References numUniqueGuides, and uniqueGuides.

Referenced by LVQDTargetCalculator().

{
    if( !source ) return -1;
    int idx = std::find( uniqueGuides, uniqueGuides + numUniqueGuides, source ) - uniqueGuides;
    if( idx == numUniqueGuides )
    {
        assert( idx < 4 );
        uniqueGuides[idx] = source;
        ++numUniqueGuides;
    }
    return idx;
}
bool MBMesquite::LVQDTargetCalculator::evaluate_guide_2D ( PatchData pd,
size_t  element,
Sample  sample,
int  idx,
double &  lambda,
MsqMatrix< 3, 2 > &  V,
MsqMatrix< 2, 2 > &  Q,
MsqMatrix< 2, 2 > &  delta,
MsqError err 
) [private]

Definition at line 122 of file LVQDTargetCalculator.cpp.

References MBMesquite::TargetCalculator::factor_2D(), MBMesquite::TargetCalculator::factor_surface(), MBMesquite::TargetCalculator::get_2D_target(), MBMesquite::TargetCalculator::get_surface_target(), have_surface_orient(), MSQ_CHKERR, and uniqueGuides.

Referenced by get_2D_target(), and get_surface_target().

{
    bool valid;
    if( uniqueGuides[idx]->have_surface_orient() )
    {
        MsqMatrix< 3, 2 > W;
        valid = uniqueGuides[idx]->get_surface_target( pd, element, sample, W, err );
        if( MSQ_CHKERR( err ) || !valid ) return false;
        valid = factor_surface( W, lambda, V, Q, delta, err );
        if( MSQ_CHKERR( err ) || !valid ) return false;
    }
    else
    {
        MsqMatrix< 2, 2 > W;
        valid = uniqueGuides[idx]->get_2D_target( pd, element, sample, W, err );
        if( MSQ_CHKERR( err ) || !valid ) return false;
        MsqMatrix< 2, 2 > junk;
        valid = factor_2D( W, lambda, junk, Q, delta, err );
        if( MSQ_CHKERR( err ) || !valid ) return false;
        V = MsqMatrix< 3, 2 >( 1.0 );
    }
    return true;
}
bool MBMesquite::LVQDTargetCalculator::get_2D_target ( PatchData pd,
size_t  element,
Sample  sample,
MsqMatrix< 2, 2 > &  W_out,
MsqError err 
) [virtual]

Get a target matrix.

Parameters:
pdThe current PatchData
elementThe index an element within the patch data.
sampleThe sample point in the element.
W_outThe resulting target matrix.

Implements MBMesquite::TargetCalculator.

Definition at line 154 of file LVQDTargetCalculator.cpp.

References deltaIdx, evaluate_guide_2D(), have_surface_orient(), INTERNAL_ERROR, lambdaIdx, MSQ_CHKERR, MSQ_SETERR, numUniqueGuides, and qIdx.

Referenced by LVQDTargetTest::target().

{
    double lambda[4];
    MsqMatrix< 3, 2 > V[4];
    MsqMatrix< 2, 2 > W, Q[4], delta[4];
    bool valid;

    if( have_surface_orient() )
    {
        MSQ_SETERR( err )( "Incorrect surface mesh target type", MsqError::INTERNAL_ERROR );
        return false;
    }

    for( int i = 0; i < numUniqueGuides; ++i )
    {
        valid = evaluate_guide_2D( pd, element, sample, i, lambda[i], V[i], Q[i], delta[i], err );
        if( MSQ_CHKERR( err ) || !valid ) return false;
    }

    if( qIdx >= 0 )
    {
        W_out = Q[qIdx];
        if( lambdaIdx >= 0 ) W_out *= lambda[lambdaIdx];
        if( deltaIdx >= 0 ) W_out = W_out * delta[deltaIdx];
    }
    else if( deltaIdx >= 0 )
    {
        W_out = delta[deltaIdx];
        if( lambdaIdx >= 0 ) W_out *= lambda[lambdaIdx];
    }
    else if( lambdaIdx >= 0 )
    {
        W_out = MsqMatrix< 2, 2 >( lambda[lambdaIdx] );
    }
    else
    {
        W_out = MsqMatrix< 2, 2 >( 1.0 );
    }

    return true;
}
bool MBMesquite::LVQDTargetCalculator::get_3D_target ( PatchData pd,
size_t  element,
Sample  sample,
MsqMatrix< 3, 3 > &  W_out,
MsqError err 
) [virtual]

Get a target matrix.

Parameters:
pdThe current PatchData
elementThe index an element within the patch data.
sampleThe sample point in the element.
W_outThe resulting target matrix.

Implements MBMesquite::TargetCalculator.

Definition at line 74 of file LVQDTargetCalculator.cpp.

References deltaIdx, MBMesquite::TargetCalculator::factor_3D(), MBMesquite::TargetCalculator::get_3D_target(), lambdaIdx, MSQ_CHKERR, numUniqueGuides, qIdx, uniqueGuides, and vIdx.

Referenced by LVQDTargetTest::target().

{
    double lambda[4];
    MsqMatrix< 3, 3 > V[4], Q[4], delta[4], W;
    bool valid;

    for( int i = 0; i < numUniqueGuides; ++i )
    {
        valid = uniqueGuides[i]->get_3D_target( pd, element, sample, W, err );
        if( MSQ_CHKERR( err ) || !valid ) return false;
        valid = factor_3D( W, lambda[i], V[i], Q[i], delta[i], err );
        if( MSQ_CHKERR( err ) || !valid ) return false;
    }

    if( vIdx >= 0 )
    {
        W_out = V[vIdx];
        if( lambdaIdx >= 0 ) W_out *= lambda[lambdaIdx];
        if( qIdx >= 0 ) W_out = W_out * Q[qIdx];
        if( deltaIdx >= 0 ) W_out = W_out * delta[deltaIdx];
    }
    else if( qIdx >= 0 )
    {
        W_out = Q[qIdx];
        if( lambdaIdx >= 0 ) W_out *= lambda[lambdaIdx];
        if( deltaIdx >= 0 ) W_out = W_out * delta[deltaIdx];
    }
    else if( deltaIdx >= 0 )
    {
        W_out = delta[deltaIdx];
        if( lambdaIdx >= 0 ) W_out *= lambda[lambdaIdx];
    }
    else if( lambdaIdx >= 0 )
    {
        W_out = MsqMatrix< 3, 3 >( lambda[lambdaIdx] );
    }
    else
    {
        W_out = MsqMatrix< 3, 3 >( 1.0 );
    }

    return true;
}
bool MBMesquite::LVQDTargetCalculator::get_surface_target ( PatchData pd,
size_t  element,
Sample  sample,
MsqMatrix< 3, 2 > &  W_out,
MsqError err 
) [virtual]

Get a target matrix.

Parameters:
pdThe current PatchData
elementThe index an element within the patch data.
sampleThe sample point in the element.
W_outThe resulting target matrix.

Implements MBMesquite::TargetCalculator.

Definition at line 200 of file LVQDTargetCalculator.cpp.

References deltaIdx, evaluate_guide_2D(), have_surface_orient(), INTERNAL_ERROR, lambdaIdx, MSQ_CHKERR, MSQ_SETERR, numUniqueGuides, qIdx, and vIdx.

Referenced by LVQDTargetTest::target().

{
    double lambda[4];
    MsqMatrix< 3, 2 > V[4], W;
    MsqMatrix< 2, 2 > Q[4], delta[4], junk, W2;
    bool valid;

    if( !have_surface_orient() )
    {
        MSQ_SETERR( err )( "Incorrect surface mesh target type", MsqError::INTERNAL_ERROR );
        return false;
    }

    for( int i = 0; i < numUniqueGuides; ++i )
    {
        valid = evaluate_guide_2D( pd, element, sample, i, lambda[i], V[i], Q[i], delta[i], err );
        if( MSQ_CHKERR( err ) || !valid ) return false;
    }

    if( vIdx >= 0 )
    {
        W_out = V[vIdx];
        if( lambdaIdx >= 0 ) W_out *= lambda[lambdaIdx];
        if( qIdx >= 0 ) W_out = W_out * Q[qIdx];
        if( deltaIdx >= 0 ) W_out = W_out * delta[deltaIdx];
    }
    else if( qIdx >= 0 )
    {
        W_out( 0, 0 ) = Q[qIdx]( 0, 0 );
        W_out( 0, 1 ) = Q[qIdx]( 0, 1 );
        W_out( 1, 0 ) = Q[qIdx]( 1, 0 );
        W_out( 1, 1 ) = Q[qIdx]( 1, 1 );
        W_out( 2, 0 ) = 0.0;
        W_out( 2, 1 ) = 0.0;
        if( lambdaIdx >= 0 ) W_out *= lambda[lambdaIdx];
        if( deltaIdx >= 0 ) W_out = W_out * delta[deltaIdx];
    }
    else if( deltaIdx >= 0 )
    {
        W_out( 0, 0 ) = delta[deltaIdx]( 0, 0 );
        W_out( 0, 1 ) = delta[deltaIdx]( 0, 1 );
        W_out( 1, 0 ) = delta[deltaIdx]( 1, 0 );
        W_out( 1, 1 ) = delta[deltaIdx]( 1, 1 );
        W_out( 2, 0 ) = 0.0;
        W_out( 2, 1 ) = 0.0;
        if( lambdaIdx >= 0 ) W_out *= lambda[lambdaIdx];
    }
    else if( lambdaIdx >= 0 )
    {
        W_out = MsqMatrix< 3, 2 >( lambda[lambdaIdx] );
    }
    else
    {
        W_out = MsqMatrix< 3, 2 >( 1.0 );
    }

    return true;
}

Use 3x2 W for surface elements if true, 2x2 W if false.

If true, then the targets for surface elements attempt some control of orientation and therefore get_surface_target must be used to get the targets. If false, then the target contains no orientation data and is therefore the same as the corresponding 2D target for surface elements. In this case, get_2D_target should be used.

Implements MBMesquite::TargetCalculator.

Definition at line 69 of file LVQDTargetCalculator.cpp.

References vIdx.

Referenced by evaluate_guide_2D(), get_2D_target(), and get_surface_target().

{
    return ( vIdx >= 0 );
}

Member Data Documentation

Index into uniqueGuides for respective source, or -1 for no source.

Definition at line 86 of file LVQDTargetCalculator.hpp.

Referenced by get_2D_target(), get_3D_target(), get_surface_target(), and LVQDTargetCalculator().

Number of unique target sources.

Definition at line 85 of file LVQDTargetCalculator.hpp.

Referenced by add_source(), get_2D_target(), get_3D_target(), and get_surface_target().

Up to 4 unique target sources.

Definition at line 84 of file LVQDTargetCalculator.hpp.

Referenced by add_source(), evaluate_guide_2D(), and get_3D_target().

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