MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Transform from coordinates in the XY-plane to graphics coordinates. More...
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 | |
Projection & | myProj |
float | myScale |
int | horizOffset |
int | vertOffset |
int | horizMax |
int | vertMax |
int | vertSign |
Transform from coordinates in the XY-plane to graphics coordinates.
Definition at line 59 of file MeshWriter.cpp.
MBMesquite::MeshWriter::Transform2D::Transform2D | ( | PatchData * | pd, |
Projection & | proj, | ||
unsigned | width, | ||
unsigned | height, | ||
bool | flip_about_horizontal | ||
) |
Definition at line 602 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 636 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; }
int MBMesquite::MeshWriter::Transform2D::max_horizontal | ( | ) | const [inline] |
Definition at line 68 of file MeshWriter.cpp.
Referenced by MBMesquite::MeshWriter::write_eps(), MBMesquite::MeshWriter::write_eps_triangle(), and MBMesquite::MeshWriter::write_svg().
{ return horizMax; }
int MBMesquite::MeshWriter::Transform2D::max_vertical | ( | ) | const [inline] |
Definition at line 72 of file MeshWriter.cpp.
Referenced by MBMesquite::MeshWriter::write_eps(), MBMesquite::MeshWriter::write_eps_triangle(), and MBMesquite::MeshWriter::write_svg().
{ return vertMax; }
void MBMesquite::MeshWriter::Transform2D::transform | ( | const Vector3D & | coords, |
int & | horizontal, | ||
int & | vertical | ||
) | const |
Definition at line 671 of file MeshWriter.cpp.
References horizOffset, myProj, myScale, MBMesquite::MeshWriter::Projection::project(), vertOffset, and vertSign.
Referenced by MBMesquite::MeshWriter::write_eps(), MBMesquite::MeshWriter::write_eps_quadratic_edge(), MBMesquite::MeshWriter::write_eps_triangle(), and MBMesquite::MeshWriter::write_svg().
{ float horiz, vert; myProj.project( coords, horiz, vert ); horizontal = (int)( myScale * horiz ) + horizOffset; vertical = vertSign * (int)( myScale * vert ) + vertOffset; }
int MBMesquite::MeshWriter::Transform2D::horizMax [private] |
Definition at line 81 of file MeshWriter.cpp.
Referenced by Transform2D().
int MBMesquite::MeshWriter::Transform2D::horizOffset [private] |
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().
float MBMesquite::MeshWriter::Transform2D::myScale [private] |
Definition at line 79 of file MeshWriter.cpp.
Referenced by transform(), and Transform2D().
int MBMesquite::MeshWriter::Transform2D::vertMax [private] |
Definition at line 81 of file MeshWriter.cpp.
Referenced by Transform2D().
int MBMesquite::MeshWriter::Transform2D::vertOffset [private] |
Definition at line 80 of file MeshWriter.cpp.
Referenced by transform(), and Transform2D().
int MBMesquite::MeshWriter::Transform2D::vertSign [private] |
Definition at line 82 of file MeshWriter.cpp.
Referenced by transform().