26 void QgsMeshLayerUtils::calculateMinimumMaximum(
double &min,
double &max,
const QVector<double> &arr )
30 min = std::numeric_limits<double>::max();
31 max = std::numeric_limits<double>::min();
33 for (
const double val : arr )
35 if ( !std::isnan( val ) )
47 min = std::numeric_limits<double>::quiet_NaN();
48 max = std::numeric_limits<double>::quiet_NaN();
52 void QgsMeshLayerUtils::calculateMinMaxForDatasetGroup(
double &min,
double &max,
QgsMeshDataProvider *provider,
int groupIndex )
56 min = std::numeric_limits<double>::quiet_NaN();
57 max = std::numeric_limits<double>::quiet_NaN();
61 min = std::numeric_limits<double>::max();
62 max = std::numeric_limits<double>::min();
65 for (
int i = 0; i < count; ++i )
69 min = std::min( min, dMin );
70 max = std::max( max, dMax );
76 if ( !index.
isValid() || !provider )
78 min = std::numeric_limits<double>::quiet_NaN();
79 max = std::numeric_limits<double>::quiet_NaN();
91 bool firstIteration =
true;
92 for (
int i = 0; i < count; ++i )
96 if ( std::isnan( v ) )
100 firstIteration =
false;
119 void QgsMeshLayerUtils::boundingBoxToScreenRectangle(
const QgsMapToPixel &mtp,
120 const QSize &outputSize,
129 topLim = std::max(
int( ur.
y() ), 0 );
130 bottomLim = std::min(
int( ll.
y() ), outputSize.height() - 1 );
131 leftLim = std::max(
int( ll.
x() ), 0 );
132 rightLim = std::min(
int( ur.
x() ), outputSize.width() - 1 );
135 static void lamTol(
double &lam )
137 const static double eps = 1e-6;
138 if ( ( lam < 0.0 ) && ( lam > -eps ) )
145 double &lam1,
double &lam2,
double &lam3 )
147 if ( pA == pB || pA == pC || pB == pC )
156 double dot00 = v0 * v0;
157 double dot01 = v0 * v1;
158 double dot02 = v0 * v2;
159 double dot11 = v1 * v1;
160 double dot12 = v1 * v2;
163 double invDenom = 1.0 / ( dot00 * dot11 - dot01 * dot01 );
164 lam1 = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;
165 lam2 = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;
166 lam3 = 1.0 - lam1 - lam2;
174 if ( ( lam1 < 0 ) || ( lam2 < 0 ) || ( lam3 < 0 ) )
183 double val1,
double val2,
double val3,
const QgsPointXY &pt )
185 double lam1, lam2, lam3;
186 if ( !E3T_physicalToBarycentric( p1, p2, p3, pt, lam1, lam2, lam3 ) )
187 return std::numeric_limits<double>::quiet_NaN();
189 return lam1 * val3 + lam2 * val2 + lam3 * val1;
195 double lam1, lam2, lam3;
196 if ( !E3T_physicalToBarycentric( p1, p2, p3, pt, lam1, lam2, lam3 ) )
197 return std::numeric_limits<double>::quiet_NaN();
A rectangle specified with double values.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
virtual int faceCount() const =0
Returns number of faces in the native mesh.
A class to represent a 2D point.
bool isValid() const
Returns whether index is valid, ie at least groups is set.
virtual int datasetCount(int groupIndex) const =0
Returns number of datasets loaded in the group.
virtual int vertexCount() const =0
Returns number of vertices in the native mesh.
Perform transforms between map coordinates and device coordinates.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
double scalar() const
Returns magnitude of vector for vector data or scalar value for scalar data.
A class to represent a vector.
Base class for providing data for QgsMeshLayer.
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
virtual int datasetGroupCount() const =0
Returns number of datasets groups loaded.
virtual QgsMeshDatasetValue datasetValue(QgsMeshDatasetIndex index, int valueIndex) const =0
Returns vector/scalar value associated with the index from the dataset.
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata(int groupIndex) const =0
Returns dataset group metadata.