MOAB: Mesh Oriented datABase  (version 5.3.0)
MBMesquite::MeshWriter::Transform2D Class Reference

Transform from coordinates in the XY-plane to graphics coordinates. More...

+ Collaboration diagram for MBMesquite::MeshWriter::Transform2D:

Public Member Functions

 Transform2D (PatchData *pd, Projection &proj, unsigned width, unsigned height, bool flip_about_horizontal)
 Transform2D (const Vector3D *verts, size_t num_vert, Projection &projection, unsigned width, unsigned height)
void transform (const Vector3D &coords, int &horizontal, int &vertical) const
int max_horizontal () const
int max_vertical () const

Private Attributes

ProjectionmyProj
float myScale
int horizOffset
int vertOffset
int horizMax
int vertMax
int vertSign

Detailed Description

Transform from coordinates in the XY-plane to graphics coordinates.

Definition at line 59 of file MeshWriter.cpp.


Constructor & Destructor Documentation

MBMesquite::MeshWriter::Transform2D::Transform2D ( PatchData pd,
Projection proj,
unsigned  width,
unsigned  height,
bool  flip_about_horizontal 
)

Definition at line 599 of file MeshWriter.cpp.

References MBMesquite::PatchData::get_vertex_array(), horizMax, horizOffset, myProj, myScale, MBMesquite::PatchData::num_nodes(), MBMesquite::MeshWriter::Projection::project(), vertMax, and vertOffset.

        : myProj( projection ), vertSign( flip ? -1 : 1 )
    {
        // Get the bounding box of the projected points
        float w_max, w_min, h_max, h_min;
        w_max = h_max = -std::numeric_limits< float >::max();
        w_min = h_min = std::numeric_limits< float >::max();
        MsqError err;
        const MsqVertex* verts = pd->get_vertex_array( err );
        const size_t num_vert  = pd->num_nodes();
        for( unsigned i = 0; i < num_vert; ++i )
        {
            float w, h;
            myProj.project( verts[i], w, h );
            if( w > w_max ) w_max = w;
            if( w < w_min ) w_min = w;
            if( h > h_max ) h_max = h;
            if( h < h_min ) h_min = h;
        }

        // Determine the scale factor
        const float w_scale = (float)width / ( w_max - w_min );
        const float h_scale = (float)height / ( h_max - h_min );
        myScale             = w_scale > h_scale ? h_scale : w_scale;

        // Determine offset
        horizOffset = -(int)( myScale * w_min );
        vertOffset  = -(int)( myScale * ( flip ? -h_max : h_min ) );

        // Determine bounding box
        horizMax = (int)( w_max * myScale ) + horizOffset;
        vertMax  = (int)( ( flip ? -h_min : h_max ) * myScale ) + vertOffset;
    }
MBMesquite::MeshWriter::Transform2D::Transform2D ( const Vector3D verts,
size_t  num_vert,
Projection projection,
unsigned  width,
unsigned  height 
)

Definition at line 633 of file MeshWriter.cpp.

References horizMax, horizOffset, myProj, myScale, MBMesquite::MeshWriter::Projection::project(), vertMax, and vertOffset.

        : myProj( projection ), vertSign( 1 )
    {
        // Get the bounding box of the projected points
        float w_max, w_min, h_max, h_min;
        w_max = h_max = -std::numeric_limits< float >::max();
        w_min = h_min = std::numeric_limits< float >::max();
        for( unsigned i = 0; i < num_vert; ++i )
        {
            float w, h;
            myProj.project( verts[i], w, h );
            if( w > w_max ) w_max = w;
            if( w < w_min ) w_min = w;
            if( h > h_max ) h_max = h;
            if( h < h_min ) h_min = h;
        }

        // Determine the scale factor
        const float w_scale = (float)width / ( w_max - w_min );
        const float h_scale = (float)height / ( h_max - h_min );
        myScale             = w_scale > h_scale ? h_scale : w_scale;

        // Determine offset
        horizOffset = -(int)( myScale * w_min );
        vertOffset  = -(int)( myScale * h_min );

        // Determine bounding box
        horizMax = (int)( w_max * myScale ) + horizOffset;
        vertMax  = (int)( h_max * myScale ) + vertOffset;
    }

Member Function Documentation

void MBMesquite::MeshWriter::Transform2D::transform ( const Vector3D coords,
int &  horizontal,
int &  vertical 
) const

Member Data Documentation

Definition at line 81 of file MeshWriter.cpp.

Referenced by Transform2D().

Definition at line 80 of file MeshWriter.cpp.

Referenced by transform(), and Transform2D().

Definition at line 78 of file MeshWriter.cpp.

Referenced by transform(), and Transform2D().

Definition at line 79 of file MeshWriter.cpp.

Referenced by transform(), and Transform2D().

Definition at line 81 of file MeshWriter.cpp.

Referenced by Transform2D().

Definition at line 80 of file MeshWriter.cpp.

Referenced by transform(), and Transform2D().

Definition at line 82 of file MeshWriter.cpp.

Referenced by transform().

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines