Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cb3348c

Browse files
committedApr 17, 2019
fix rendering of mesh triangle with 0,0 vertex
1 parent 1fac5a6 commit cb3348c

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
@@ -120,10 +120,25 @@ double QgsMeshLayerUtils::interpolateFromFacesData( const QgsPointXY &p1, const
120120

121121
QgsRectangle QgsMeshLayerUtils::triangleBoundingBox( const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3 )
122122
{
123-
QgsRectangle bbox;
124-
bbox.combineExtentWith( p1.x(), p1.y() );
125-
bbox.combineExtentWith( p2.x(), p2.y() );
126-
bbox.combineExtentWith( p3.x(), p3.y() );
123+
// p1
124+
double xMin = p1.x();
125+
double xMax = p1.x();
126+
double yMin = p1.y();
127+
double yMax = p1.y();
128+
129+
//p2
130+
xMin = ( ( xMin < p2.x() ) ? xMin : p2.x() );
131+
xMax = ( ( xMax > p2.x() ) ? xMax : p2.x() );
132+
yMin = ( ( yMin < p2.y() ) ? yMin : p2.y() );
133+
yMax = ( ( yMax > p2.y() ) ? yMax : p2.y() );
134+
135+
// p3
136+
xMin = ( ( xMin < p3.x() ) ? xMin : p3.x() );
137+
xMax = ( ( xMax > p3.x() ) ? xMax : p3.x() );
138+
yMin = ( ( yMin < p3.y() ) ? yMin : p3.y() );
139+
yMax = ( ( yMax > p3.y() ) ? yMax : p3.y() );
140+
141+
QgsRectangle bbox( xMin, yMin, xMax, yMax );
127142
return bbox;
128143
}
129144

0 commit comments

Comments
 (0)
Please sign in to comment.