Skip to content

Commit fd492ab

Browse files
committedApr 18, 2019
fix rendering of mesh triangle with 0,0 vertex
1 parent d332292 commit fd492ab

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed
 

‎src/core/mesh/qgsmeshlayerutils.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,25 @@ double QgsMeshLayerUtils::interpolateFromFacesData( const QgsPointXY &p1, const
123123

124124
QgsRectangle QgsMeshLayerUtils::triangleBoundingBox( const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3 )
125125
{
126-
QgsRectangle bbox;
127-
bbox.combineExtentWith( p1.x(), p1.y() );
128-
bbox.combineExtentWith( p2.x(), p2.y() );
129-
bbox.combineExtentWith( p3.x(), p3.y() );
126+
// p1
127+
double xMin = p1.x();
128+
double xMax = p1.x();
129+
double yMin = p1.y();
130+
double yMax = p1.y();
131+
132+
//p2
133+
xMin = ( ( xMin < p2.x() ) ? xMin : p2.x() );
134+
xMax = ( ( xMax > p2.x() ) ? xMax : p2.x() );
135+
yMin = ( ( yMin < p2.y() ) ? yMin : p2.y() );
136+
yMax = ( ( yMax > p2.y() ) ? yMax : p2.y() );
137+
138+
// p3
139+
xMin = ( ( xMin < p3.x() ) ? xMin : p3.x() );
140+
xMax = ( ( xMax > p3.x() ) ? xMax : p3.x() );
141+
yMin = ( ( yMin < p3.y() ) ? yMin : p3.y() );
142+
yMax = ( ( yMax > p3.y() ) ? yMax : p3.y() );
143+
144+
QgsRectangle bbox( xMin, yMin, xMax, yMax );
130145
return bbox;
131146
}
132147

0 commit comments

Comments
 (0)
Please sign in to comment.