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

Specify a projection to use for output. More...

#include <MeshWriter.hpp>

+ Collaboration diagram for MBMesquite::MeshWriter::Projection:

Public Member Functions

 Projection (PlanarDomain *domain)
 Projection (const Vector3D &view)
 Projection (const Vector3D &view, const Vector3D &up)
 Projection (Axis horizontal, Axis vertical)
void project (const Vector3D &point, float &horiz, float &vert)

Static Public Member Functions

static Matrix3D rotation (const Vector3D &axis, double angle)

Private Member Functions

void init (const Vector3D &view)
void init (const Vector3D &view, const Vector3D &up)

Private Attributes

Matrix3D myTransform

Detailed Description

Specify a projection to use for output.

This class defines a projection used to transform R^3 vertex positions to 2D positions to use in graphics file formats.

Definition at line 57 of file MeshWriter.hpp.


Constructor & Destructor Documentation

Project into specified plane - choice of up direction is arbitrary

Definition at line 514 of file MeshWriter.cpp.

References init(), and MBMesquite::PlanarDomain::vertex_normal_at().

    {
        Vector3D normal;
        domain->vertex_normal_at( 0, normal );
        init( normal );
    }

Project into plane with specified normal - choice of up direction is arbitrary

Definition at line 521 of file MeshWriter.cpp.

References init().

    {
        init( n );
    }

Project points into plane normal to #view vector. Orient projection such that the projection of the #up vector into the plane is parallel with the vertical direction in the output.

Definition at line 526 of file MeshWriter.cpp.

References init().

    {
        init( n, up );
    }

Specify which principal axes should be aligned with the horizontal and vertical in the output

Definition at line 531 of file MeshWriter.cpp.

References init().

    {
        Vector3D horiz( 0, 0, 0 ), vert( 0, 0, 0 );
        horiz[h] = 1.0;
        vert[v]  = 1.0;
        init( horiz * vert, vert );
    }

Member Function Documentation

void MBMesquite::MeshWriter::Projection::init ( const Vector3D view) [private]

Definition at line 539 of file MeshWriter.cpp.

References init(), MBMesquite::MeshWriter::X, MBMesquite::MeshWriter::Y, and MBMesquite::MeshWriter::Z.

    {
        // Choose an "up" direction

        Axis max = X;
        for( Axis i = Y; i <= Z; i = (Axis)( i + 1 ) )
            if( fabs( n[i] ) > fabs( n[max] ) ) max = i;

        Axis up;
        if( max == Y )
            up = Z;
        else
            up = Y;

        // Initialize rotation matrix

        Vector3D up_vect( 0, 0, 0 );
        up_vect[up] = 1.0;
        init( n, up_vect );
    }
void MBMesquite::MeshWriter::Projection::init ( const Vector3D view,
const Vector3D up 
) [private]

Definition at line 560 of file MeshWriter.cpp.

References moab::angle(), MBMesquite::Vector3D::interior_angle(), MBMesquite::Vector3D::length(), n, u, and z.

    {
        MsqError err;
        const Vector3D n = n1 / n1.length();
        const Vector3D u = up1 / up1.length();

        // Rotate for projection
        const Vector3D z( 0., 0., 1. );
        Vector3D r    = n * z;
        double angle  = r.interior_angle( n, z, err );
        Matrix3D rot1 = rotation( r, angle );

        // In-plane rotation for up vector
        Vector3D pu = u - n * ( n % u );
        Vector3D y( 0., 1., 0. );
        angle         = z.interior_angle( pu, y, err );
        Matrix3D rot2 = rotation( z, angle );

        this->myTransform = rot1 * rot2;
    }
void MBMesquite::MeshWriter::Projection::project ( const Vector3D point,
float &  horiz,
float &  vert 
)

Project a point into the plane

Definition at line 595 of file MeshWriter.cpp.

References MBMesquite::Vector3D::x(), and MBMesquite::Vector3D::y().

Referenced by MBMesquite::MeshWriter::Transform2D::transform(), and MBMesquite::MeshWriter::Transform2D::Transform2D().

    {
        Vector3D pr = myTransform * p;
        h           = (float)pr.x();
        v           = (float)pr.y();
    }
Matrix3D MBMesquite::MeshWriter::Projection::rotation ( const Vector3D axis,
double  angle 
) [static]

Definition at line 581 of file MeshWriter.cpp.

References MBMesquite::Vector3D::x(), MBMesquite::Vector3D::y(), z, and MBMesquite::Vector3D::z().

    {
        const double c = cos( angle );
        const double s = sin( angle );
        const double x = axis.x();
        const double y = axis.y();
        const double z = axis.z();

        const double xform[9] = { c + x * x * ( 1 - c ),      -z * s + x * y * ( 1 - c ), y * s + x * z * ( 1 - c ),
                                  z * s + x * y * ( 1 - c ),  c + y * y * ( 1 - c ),      -x * s + y * z * ( 1 - c ),
                                  -y * s + x * z * ( 1 - c ), x * s + y * z * ( 1 - c ),  c + z * z * ( 1 - c ) };
        return Matrix3D( xform );
    }

Member Data Documentation

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