Skip to content

Commit

Permalink
fix rendering of mesh triangle with 0,0 vertex
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Apr 18, 2019
1 parent c1a76c4 commit 32d24dc
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/core/mesh/qgsmeshlayerutils.cpp
Expand Up @@ -120,10 +120,25 @@ double QgsMeshLayerUtils::interpolateFromFacesData( const QgsPointXY &p1, const

QgsRectangle QgsMeshLayerUtils::triangleBoundingBox( const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3 )
{
QgsRectangle bbox;
bbox.combineExtentWith( p1.x(), p1.y() );
bbox.combineExtentWith( p2.x(), p2.y() );
bbox.combineExtentWith( p3.x(), p3.y() );
// p1
double xMin = p1.x();
double xMax = p1.x();
double yMin = p1.y();
double yMax = p1.y();

//p2
xMin = ( ( xMin < p2.x() ) ? xMin : p2.x() );
xMax = ( ( xMax > p2.x() ) ? xMax : p2.x() );
yMin = ( ( yMin < p2.y() ) ? yMin : p2.y() );
yMax = ( ( yMax > p2.y() ) ? yMax : p2.y() );

// p3
xMin = ( ( xMin < p3.x() ) ? xMin : p3.x() );
xMax = ( ( xMax > p3.x() ) ? xMax : p3.x() );
yMin = ( ( yMin < p3.y() ) ? yMin : p3.y() );
yMax = ( ( yMax > p3.y() ) ? yMax : p3.y() );

QgsRectangle bbox( xMin, yMin, xMax, yMax );
return bbox;
}

Expand Down

0 comments on commit 32d24dc

Please sign in to comment.