24 QVector<double> QgsMeshLayerUtils::calculateMagnitudes(
const QgsMeshDataBlock &block )
27 int count = block.
count();
28 QVector<double> ret( count );
30 for (
int i = 0; i < count; ++i )
38 void QgsMeshLayerUtils::boundingBoxToScreenRectangle(
const QgsMapToPixel &mtp,
39 const QSize &outputSize,
48 topLim = std::max(
int( ur.
y() ), 0 );
49 bottomLim = std::min(
int( ll.
y() ), outputSize.height() - 1 );
50 leftLim = std::max(
int( ll.
x() ), 0 );
51 rightLim = std::min(
int( ur.
x() ), outputSize.width() - 1 );
54 static void lamTol(
double &lam )
56 const static double eps = 1e-6;
57 if ( ( lam < 0.0 ) && ( lam > -eps ) )
64 double &lam1,
double &lam2,
double &lam3 )
66 if ( pA == pB || pA == pC || pB == pC )
75 double dot00 = v0 * v0;
76 double dot01 = v0 * v1;
77 double dot02 = v0 * v2;
78 double dot11 = v1 * v1;
79 double dot12 = v1 * v2;
82 double invDenom = 1.0 / ( dot00 * dot11 - dot01 * dot01 );
83 lam1 = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;
84 lam2 = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;
85 lam3 = 1.0 - lam1 - lam2;
93 if ( ( lam1 < 0 ) || ( lam2 < 0 ) || ( lam3 < 0 ) )
102 double val1,
double val2,
double val3,
const QgsPointXY &pt )
104 double lam1, lam2, lam3;
105 if ( !E3T_physicalToBarycentric( p1, p2, p3, pt, lam1, lam2, lam3 ) )
106 return std::numeric_limits<double>::quiet_NaN();
108 return lam1 * val3 + lam2 * val2 + lam3 * val1;
114 double lam1, lam2, lam3;
115 if ( !E3T_physicalToBarycentric( p1, p2, p3, pt, lam1, lam2, lam3 ) )
116 return std::numeric_limits<double>::quiet_NaN();
A rectangle specified with double values.
A class to represent a 2D point.
int count() const
Number of items stored in the block.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e...
DataType type() const
Type of data stored in the block.
Perform transforms between map coordinates and device coordinates.
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
Integer boolean flag whether face is active.
double scalar() const
Returns magnitude of vector for vector data or scalar value for scalar data.
A class to represent a vector.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
double xMinimum() const
Returns the x minimum value (left side of rectangle).
QgsMeshDatasetValue value(int index) const
Returns a value represented by the index For active flag the behavior is undefined.
double yMaximum() const
Returns the y maximum value (top side of rectangle).