Drop temporary aliases from Tuple2D and Tuple3D

Change-Id: I091b68bbeee74452a3d6a03711cfc482b7a78e1d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157685
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2023-10-08 13:14:39 +03:00
parent e64d85c9eb
commit 347112fbd8
13 changed files with 177 additions and 200 deletions

View File

@ -26,16 +26,16 @@ namespace basegfx
B2DPoint& B2DPoint::operator*=( const ::basegfx::B2DHomMatrix& rMat )
{
double fTempX(
rMat.get(0, 0) * mfX +
rMat.get(0, 1) * mfY +
rMat.get(0, 0) * mnX +
rMat.get(0, 1) * mnY +
rMat.get(0, 2));
double fTempY(
rMat.get(1, 0) * mfX +
rMat.get(1, 1) * mfY +
rMat.get(1, 0) * mnX +
rMat.get(1, 1) * mnY +
rMat.get(1, 2));
mfX = fTempX;
mfY = fTempY;
mnX = fTempX;
mnY = fTempY;
return *this;
}

View File

@ -26,28 +26,28 @@ namespace basegfx
B3DPoint& B3DPoint::operator*=( const ::basegfx::B3DHomMatrix& rMat )
{
double fTempX(
rMat.get(0, 0) * mfX +
rMat.get(0, 1) * mfY +
rMat.get(0, 2) * mfZ +
rMat.get(0, 0) * mnX +
rMat.get(0, 1) * mnY +
rMat.get(0, 2) * mnZ +
rMat.get(0, 3));
double fTempY(
rMat.get(1, 0) * mfX +
rMat.get(1, 1) * mfY +
rMat.get(1, 2) * mfZ +
rMat.get(1, 0) * mnX +
rMat.get(1, 1) * mnY +
rMat.get(1, 2) * mnZ +
rMat.get(1, 3));
double fTempZ(
rMat.get(2, 0) * mfX +
rMat.get(2, 1) * mfY +
rMat.get(2, 2) * mfZ +
rMat.get(2, 0) * mnX +
rMat.get(2, 1) * mnY +
rMat.get(2, 2) * mnZ +
rMat.get(2, 3));
if(!rMat.isLastLineDefault())
{
const double fOne(1.0);
const double fTempM(
rMat.get(3, 0) * mfX +
rMat.get(3, 1) * mfY +
rMat.get(3, 2) * mfZ +
rMat.get(3, 0) * mnX +
rMat.get(3, 1) * mnY +
rMat.get(3, 2) * mnZ +
rMat.get(3, 3));
if(!fTools::equalZero(fTempM) && !fTools::equal(fOne, fTempM))
@ -58,9 +58,9 @@ namespace basegfx
}
}
mfX = fTempX;
mfY = fTempY;
mfZ = fTempZ;
mnX = fTempX;
mnY = fTempY;
mnZ = fTempZ;
return *this;
}

View File

@ -29,8 +29,8 @@ namespace basegfx
if(fTools::equalZero(fLen))
{
mfX = 0.0;
mfY = 0.0;
mnX = 0.0;
mnY = 0.0;
}
else
{
@ -42,8 +42,8 @@ namespace basegfx
if(!fTools::equalZero(fLen))
{
mfX /= fLen;
mfY /= fLen;
mnX /= fLen;
mnY /= fLen;
}
}
}
@ -53,22 +53,22 @@ namespace basegfx
double B2DVector::getLength() const
{
if(fTools::equalZero(mfX))
if(fTools::equalZero(mnX))
{
return fabs(mfY);
return fabs(mnY);
}
else if(fTools::equalZero(mfY))
else if(fTools::equalZero(mnY))
{
return fabs(mfX);
return fabs(mnX);
}
return hypot( mfX, mfY );
return hypot( mnX, mnY );
}
double B2DVector::angle( const B2DVector& rVec ) const
{
return atan2(mfX * rVec.getY() - mfY * rVec.getX(),
mfX * rVec.getX() + mfY * rVec.getY());
return atan2(mnX * rVec.getY() - mnY * rVec.getX(),
mnX * rVec.getX() + mnY * rVec.getY());
}
const B2DVector& B2DVector::getEmptyVector()
@ -78,12 +78,12 @@ namespace basegfx
B2DVector& B2DVector::operator*=( const B2DHomMatrix& rMat )
{
const double fTempX( rMat.get(0,0)*mfX +
rMat.get(0,1)*mfY );
const double fTempY( rMat.get(1,0)*mfX +
rMat.get(1,1)*mfY );
mfX = fTempX;
mfY = fTempY;
const double fTempX( rMat.get(0,0)*mnX +
rMat.get(0,1)*mnY );
const double fTempY( rMat.get(1,0)*mnX +
rMat.get(1,1)*mnY );
mnX = fTempX;
mnY = fTempY;
return *this;
}
@ -101,8 +101,8 @@ namespace basegfx
fLen /= sqrt(fLenNow);
}
mfX *= fLen;
mfY *= fLen;
mnX *= fLen;
mnY *= fLen;
}
return *this;

View File

@ -34,9 +34,9 @@ namespace basegfx
{
fLen = sqrt(fLen);
mfX /= fLen;
mfY /= fLen;
mfZ /= fLen;
mnX /= fLen;
mnY /= fLen;
mnZ /= fLen;
}
}
@ -52,12 +52,12 @@ namespace basegfx
B3DVector& B3DVector::operator*=( const ::basegfx::B3DHomMatrix& rMat )
{
const double fTempX( rMat.get(0,0)*mfX + rMat.get(0,1)*mfY + rMat.get(0,2)*mfZ );
const double fTempY( rMat.get(1,0)*mfX + rMat.get(1,1)*mfY + rMat.get(1,2)*mfZ );
const double fTempZ( rMat.get(2,0)*mfX + rMat.get(2,1)*mfY + rMat.get(2,2)*mfZ );
mfX = fTempX;
mfY = fTempY;
mfZ = fTempZ;
const double fTempX( rMat.get(0,0)*mnX + rMat.get(0,1)*mnY + rMat.get(0,2)*mnZ );
const double fTempY( rMat.get(1,0)*mnX + rMat.get(1,1)*mnY + rMat.get(1,2)*mnZ );
const double fTempZ( rMat.get(2,0)*mnX + rMat.get(2,1)*mnY + rMat.get(2,2)*mnZ );
mnX = fTempX;
mnY = fTempY;
mnZ = fTempZ;
return *this;
}

View File

@ -75,22 +75,22 @@ namespace basegfx
{}
// data access read
double getRed() const { return mfX; }
double getGreen() const { return mfY; }
double getBlue() const { return mfZ; }
double getRed() const { return mnX; }
double getGreen() const { return mnY; }
double getBlue() const { return mnZ; }
// data access write
void setRed(double fNew) { mfX = fNew; }
void setGreen(double fNew) { mfY = fNew; }
void setBlue(double fNew) { mfZ = fNew; }
void setRed(double fNew) { mnX = fNew; }
void setGreen(double fNew) { mnY = fNew; }
void setBlue(double fNew) { mnZ = fNew; }
/** *=operator to allow usage from BColor, too
*/
BColor& operator*=( const BColor& rPnt )
{
mfX *= rPnt.mfX;
mfY *= rPnt.mfY;
mfZ *= rPnt.mfZ;
mnX *= rPnt.mnX;
mnY *= rPnt.mnY;
mnZ *= rPnt.mnZ;
return *this;
}
@ -98,9 +98,9 @@ namespace basegfx
*/
BColor& operator*=(double t)
{
mfX *= t;
mfY *= t;
mfZ *= t;
mnX *= t;
mnY *= t;
mnZ *= t;
return *this;
}
@ -109,9 +109,9 @@ namespace basegfx
*/
BColor& operator=( const ::basegfx::B3DTuple& rVec )
{
mfX = rVec.getX();
mfY = rVec.getY();
mfZ = rVec.getZ();
mnX = rVec.getX();
mnY = rVec.getY();
mnZ = rVec.getZ();
return *this;
}
@ -122,7 +122,7 @@ namespace basegfx
const double fGreenWeight(151.0 / 256.0); // 0.59
const double fBlueWeight(28.0 / 256.0); // 0.11
return (mfX * fRedWeight + mfY * fGreenWeight + mfZ * fBlueWeight);
return (mnX * fRedWeight + mnY * fGreenWeight + mnZ * fBlueWeight);
}
// distances in color space
@ -152,17 +152,17 @@ namespace basegfx
// clamp color to [0.0..1.0] values in all three intensity components
BColor& clamp()
{
mfX = std::clamp(mfX, 0.0, 1.0);
mfY = std::clamp(mfY, 0.0, 1.0);
mfZ = std::clamp(mfZ, 0.0, 1.0);
mnX = std::clamp(mnX, 0.0, 1.0);
mnY = std::clamp(mnY, 0.0, 1.0);
mnZ = std::clamp(mnZ, 0.0, 1.0);
return *this;
}
void invert()
{
mfX = 1.0 - mfX;
mfY = 1.0 - mfY;
mfZ = 1.0 - mfZ;
mnX = 1.0 - mnX;
mnY = 1.0 - mnY;
mnZ = 1.0 - mnZ;
}
static const BColor& getEmptyBColor()

View File

@ -87,8 +87,8 @@ namespace basegfx
*/
B2DPoint& operator*=( const B2DPoint& rPnt )
{
mfX *= rPnt.mfX;
mfY *= rPnt.mfY;
mnX *= rPnt.mnX;
mnY *= rPnt.mnY;
return *this;
}
@ -96,8 +96,8 @@ namespace basegfx
*/
B2DPoint& operator*=(double t)
{
mfX *= t;
mfY *= t;
mnX *= t;
mnY *= t;
return *this;
}
@ -106,8 +106,8 @@ namespace basegfx
*/
BASEGFX_DLLPUBLIC B2DPoint& operator=(Tuple2D<double>& rPoint)
{
mfX = rPoint.getX();
mfY = rPoint.getY();
mnX = rPoint.getX();
mnY = rPoint.getY();
return *this;
}

View File

@ -73,9 +73,9 @@ namespace basegfx
*/
B3DPoint& operator*=( const B3DPoint& rPnt )
{
mfX *= rPnt.mfX;
mfY *= rPnt.mfY;
mfZ *= rPnt.mfZ;
mnX *= rPnt.mnX;
mnY *= rPnt.mnY;
mnZ *= rPnt.mnZ;
return *this;
}
@ -83,9 +83,9 @@ namespace basegfx
*/
B3DPoint& operator*=(double t)
{
mfX *= t;
mfY *= t;
mfZ *= t;
mnX *= t;
mnY *= t;
mnZ *= t;
return *this;
}
@ -94,9 +94,9 @@ namespace basegfx
*/
B3DPoint& operator=( const ::basegfx::B3DTuple& rVec )
{
mfX = rVec.getX();
mfY = rVec.getY();
mfZ = rVec.getZ();
mnX = rVec.getX();
mnY = rVec.getY();
mnZ = rVec.getZ();
return *this;
}

View File

@ -18,19 +18,8 @@ namespace basegfx
template <typename TYPE> class Tuple2D
{
protected:
union {
// temporary alias mnX with mfX and mnY with mfY
struct
{
TYPE mnX;
TYPE mnY;
};
struct
{
TYPE mfX;
TYPE mfY;
};
};
TYPE mnX;
TYPE mnY;
public:
/** Create a 2D Tuple
@ -82,13 +71,13 @@ public:
template <typename T = TYPE, std::enable_if_t<std::is_integral_v<T>, int> = 0>
bool equal(const Tuple2D<TYPE>& rTup) const
{
return mfX == rTup.mfX && mfY == rTup.mfY;
return mnX == rTup.mnX && mnY == rTup.mnY;
}
template <typename T = TYPE, std::enable_if_t<std::is_floating_point_v<T>, int> = 0>
bool equal(const Tuple2D<TYPE>& rTup) const
{
return this == &rTup || (fTools::equal(mfX, rTup.mfX) && fTools::equal(mfY, rTup.mfY));
return this == &rTup || (fTools::equal(mnX, rTup.mnX) && fTools::equal(mnY, rTup.mnY));
}
template <typename T = TYPE, std::enable_if_t<std::is_integral_v<T>, int> = 0>
@ -100,56 +89,56 @@ public:
template <typename T = TYPE, std::enable_if_t<std::is_floating_point_v<T>, int> = 0>
bool equalZero() const
{
return fTools::equalZero(mfX) && fTools::equalZero(mfY);
return fTools::equalZero(mnX) && fTools::equalZero(mnY);
}
// operator overrides
Tuple2D<TYPE>& operator+=(const Tuple2D<TYPE>& rTup)
{
mfX += rTup.mfX;
mfY += rTup.mfY;
mnX += rTup.mnX;
mnY += rTup.mnY;
return *this;
}
Tuple2D<TYPE>& operator-=(const Tuple2D<TYPE>& rTup)
{
mfX -= rTup.mfX;
mfY -= rTup.mfY;
mnX -= rTup.mnX;
mnY -= rTup.mnY;
return *this;
}
Tuple2D<TYPE>& operator/=(const Tuple2D<TYPE>& rTup)
{
mfX /= rTup.mfX;
mfY /= rTup.mfY;
mnX /= rTup.mnX;
mnY /= rTup.mnY;
return *this;
}
Tuple2D<TYPE>& operator*=(const Tuple2D<TYPE>& rTup)
{
mfX *= rTup.mfX;
mfY *= rTup.mfY;
mnX *= rTup.mnX;
mnY *= rTup.mnY;
return *this;
}
Tuple2D<TYPE>& operator*=(TYPE t)
{
mfX *= t;
mfY *= t;
mnX *= t;
mnY *= t;
return *this;
}
Tuple2D<TYPE>& operator/=(TYPE t)
{
mfX /= t;
mfY /= t;
mnX /= t;
mnY /= t;
return *this;
}
Tuple2D<TYPE> operator-(void) const { return Tuple2D<TYPE>(-mfX, -mfY); }
Tuple2D<TYPE> operator-(void) const { return Tuple2D<TYPE>(-mnX, -mnY); }
bool operator==(const Tuple2D<TYPE>& rTup) const { return mfX == rTup.mfX && mfY == rTup.mfY; }
bool operator==(const Tuple2D<TYPE>& rTup) const { return mnX == rTup.mnX && mnY == rTup.mnY; }
bool operator!=(const Tuple2D<TYPE>& rTup) const { return !(*this == rTup); }
};

View File

@ -15,21 +15,9 @@ namespace basegfx
template <typename TYPE> class Tuple3D
{
protected:
union {
// temporary alias mnX with mfX, mnY with mfY and mnZ with mfZ
struct
{
TYPE mnX;
TYPE mnY;
TYPE mnZ;
};
struct
{
TYPE mfX;
TYPE mfY;
TYPE mfZ;
};
};
TYPE mnX;
TYPE mnY;
TYPE mnZ;
public:
/** Create a 3D Tuple
@ -75,55 +63,55 @@ public:
Tuple3D& operator+=(const Tuple3D& rTup)
{
mfX += rTup.mfX;
mfY += rTup.mfY;
mfZ += rTup.mfZ;
mnX += rTup.mnX;
mnY += rTup.mnY;
mnZ += rTup.mnZ;
return *this;
}
Tuple3D& operator-=(const Tuple3D& rTup)
{
mfX -= rTup.mfX;
mfY -= rTup.mfY;
mfZ -= rTup.mfZ;
mnX -= rTup.mnX;
mnY -= rTup.mnY;
mnZ -= rTup.mnZ;
return *this;
}
Tuple3D& operator/=(const Tuple3D& rTup)
{
mfX /= rTup.mfX;
mfY /= rTup.mfY;
mfZ /= rTup.mfZ;
mnX /= rTup.mnX;
mnY /= rTup.mnY;
mnZ /= rTup.mnZ;
return *this;
}
Tuple3D& operator*=(const Tuple3D& rTup)
{
mfX *= rTup.mfX;
mfY *= rTup.mfY;
mfZ *= rTup.mfZ;
mnX *= rTup.mnX;
mnY *= rTup.mnY;
mnZ *= rTup.mnZ;
return *this;
}
Tuple3D& operator*=(TYPE t)
{
mfX *= t;
mfY *= t;
mfZ *= t;
mnX *= t;
mnY *= t;
mnZ *= t;
return *this;
}
Tuple3D& operator/=(TYPE t)
{
mfX /= t;
mfY /= t;
mfZ /= t;
mnX /= t;
mnY /= t;
mnZ /= t;
return *this;
}
bool operator==(const Tuple3D& rTup) const
{
return mfX == rTup.mfX && mfY == rTup.mfY && mfZ == rTup.mfZ;
return mnX == rTup.mnX && mnY == rTup.mnY && mnZ == rTup.mnZ;
}
bool operator!=(const Tuple3D& rTup) const { return !operator==(rTup); }

View File

@ -76,7 +76,7 @@ namespace basegfx
B2DTuple operator-(void) const
{
return B2DTuple(-mfX, -mfY);
return B2DTuple(-mnX, -mnY);
}
BASEGFX_DLLPUBLIC static const B2DTuple& getEmptyTuple();

View File

@ -70,8 +70,8 @@ namespace basegfx
{
// Here, normally two if(...)'s should be used. In the assumption that
// both double members can be accessed as an array a shortcut is used here.
// if(0 == nPos) return mfX; if(1 == nPos) return mfY; return mfZ;
return *((&mfX) + nPos);
// if(0 == nPos) return mnX; if(1 == nPos) return mnY; return mnZ;
return *((&mnX) + nPos);
}
/// Array-access to 3D Tuple
@ -79,8 +79,8 @@ namespace basegfx
{
// Here, normally two if(...)'s should be used. In the assumption that
// both double members can be accessed as an array a shortcut is used here.
// if(0 == nPos) return mfX; if(1 == nPos) return mfY; return mfZ;
return *((&mfX) + nPos);
// if(0 == nPos) return mnX; if(1 == nPos) return mnY; return mnZ;
return *((&mnX) + nPos);
}
// comparators with tolerance
@ -89,32 +89,32 @@ namespace basegfx
bool equalZero() const
{
return (this == &getEmptyTuple() ||
(::basegfx::fTools::equalZero(mfX)
&& ::basegfx::fTools::equalZero(mfY)
&& ::basegfx::fTools::equalZero(mfZ)));
(::basegfx::fTools::equalZero(mnX)
&& ::basegfx::fTools::equalZero(mnY)
&& ::basegfx::fTools::equalZero(mnZ)));
}
bool equal(const B3DTuple& rTup) const
{
return (
this == &rTup ||
(::basegfx::fTools::equal(mfX, rTup.mfX) &&
::basegfx::fTools::equal(mfY, rTup.mfY) &&
::basegfx::fTools::equal(mfZ, rTup.mfZ)));
(::basegfx::fTools::equal(mnX, rTup.mnX) &&
::basegfx::fTools::equal(mnY, rTup.mnY) &&
::basegfx::fTools::equal(mnZ, rTup.mnZ)));
}
// operators
B3DTuple operator-(void) const
{
return B3DTuple(-mfX, -mfY, -mfZ);
return B3DTuple(-mnX, -mnY, -mnZ);
}
bool operator==(const B3DTuple& rTup) const
{
return ::basegfx::fTools::equal(mfX, rTup.mfX) &&
::basegfx::fTools::equal(mfY, rTup.mfY) &&
::basegfx::fTools::equal(mfZ, rTup.mfZ);
return ::basegfx::fTools::equal(mnX, rTup.mnX) &&
::basegfx::fTools::equal(mnY, rTup.mnY) &&
::basegfx::fTools::equal(mnZ, rTup.mnZ);
}
bool operator!=(const B3DTuple& rTup) const { return !operator==(rTup); }
@ -123,36 +123,36 @@ namespace basegfx
{
if(0.0 == fCompareValue)
{
if(::basegfx::fTools::equalZero(mfX))
if(::basegfx::fTools::equalZero(mnX))
{
mfX = 0.0;
mnX = 0.0;
}
if(::basegfx::fTools::equalZero(mfY))
if(::basegfx::fTools::equalZero(mnY))
{
mfY = 0.0;
mnY = 0.0;
}
if(::basegfx::fTools::equalZero(mfZ))
if(::basegfx::fTools::equalZero(mnZ))
{
mfZ = 0.0;
mnZ = 0.0;
}
}
else
{
if(::basegfx::fTools::equal(mfX, fCompareValue))
if(::basegfx::fTools::equal(mnX, fCompareValue))
{
mfX = fCompareValue;
mnX = fCompareValue;
}
if(::basegfx::fTools::equal(mfY, fCompareValue))
if(::basegfx::fTools::equal(mnY, fCompareValue))
{
mfY = fCompareValue;
mnY = fCompareValue;
}
if(::basegfx::fTools::equal(mfZ, fCompareValue))
if(::basegfx::fTools::equal(mnZ, fCompareValue))
{
mfZ = fCompareValue;
mnZ = fCompareValue;
}
}
}

View File

@ -80,8 +80,8 @@ namespace basegfx
*/
B2DVector& operator*=( const B2DVector& rPnt )
{
mfX *= rPnt.mfX;
mfY *= rPnt.mfY;
mnX *= rPnt.mnX;
mnY *= rPnt.mnY;
return *this;
}
@ -89,8 +89,8 @@ namespace basegfx
*/
B2DVector& operator*=(double t)
{
mfX *= t;
mfY *= t;
mnX *= t;
mnY *= t;
return *this;
}
@ -99,8 +99,8 @@ namespace basegfx
*/
B2DVector& operator=(Tuple2D<double> const& rVector)
{
mfX = rVector.getX();
mfY = rVector.getY();
mnX = rVector.getX();
mnY = rVector.getY();
return *this;
}
@ -131,7 +131,7 @@ namespace basegfx
@return
The Scalar value of the two involved 2D Vectors
*/
double scalar( const B2DVector& rVec ) const { return((mfX * rVec.mfX) + (mfY * rVec.mfY)); }
double scalar( const B2DVector& rVec ) const { return((mnX * rVec.mnX) + (mnY * rVec.mnY)); }
/** Calculate the length of the cross product with another 2D Vector
@ -148,7 +148,7 @@ namespace basegfx
@return
The length of the cross product of the two involved 2D Vectors
*/
double cross( const B2DVector& rVec ) const { return(mfX * rVec.getY() - mfY * rVec.getX()); }
double cross( const B2DVector& rVec ) const { return(mnX * rVec.getY() - mnY * rVec.getX()); }
/** Calculate the Angle with another 2D Vector

View File

@ -73,9 +73,9 @@ namespace basegfx
*/
B3DVector& operator*=( const B3DVector& rPnt )
{
mfX *= rPnt.mfX;
mfY *= rPnt.mfY;
mfZ *= rPnt.mfZ;
mnX *= rPnt.mnX;
mnY *= rPnt.mnY;
mnZ *= rPnt.mnZ;
return *this;
}
@ -83,9 +83,9 @@ namespace basegfx
*/
B3DVector& operator*=(double t)
{
mfX *= t;
mfY *= t;
mfZ *= t;
mnX *= t;
mnY *= t;
mnZ *= t;
return *this;
}
@ -94,9 +94,9 @@ namespace basegfx
*/
B3DVector& operator=( const ::basegfx::B3DTuple& rVec )
{
mfX = rVec.getX();
mfY = rVec.getY();
mfZ = rVec.getZ();
mnX = rVec.getX();
mnY = rVec.getY();
mnZ = rVec.getZ();
return *this;
}
@ -118,7 +118,7 @@ namespace basegfx
*/
double getXZLength() const
{
double fLen((mfX * mfX) + (mfZ * mfZ)); // #i73040#
double fLen((mnX * mnX) + (mnZ * mnZ)); // #i73040#
if((0.0 == fLen) || (1.0 == fLen))
return fLen;
return sqrt(fLen);
@ -130,7 +130,7 @@ namespace basegfx
*/
double getYZLength() const
{
double fLen((mfY * mfY) + (mfZ * mfZ));
double fLen((mnY * mnY) + (mnZ * mnZ));
if((0.0 == fLen) || (1.0 == fLen))
return fLen;
return sqrt(fLen);
@ -154,9 +154,9 @@ namespace basegfx
fLen /= sqrt(fLenNow);
}
mfX *= fLen;
mfY *= fLen;
mfZ *= fLen;
mnX *= fLen;
mnY *= fLen;
mnZ *= fLen;
}
return *this;
@ -194,7 +194,7 @@ namespace basegfx
*/
double scalar(const B3DVector& rVec) const
{
return ((mfX * rVec.mfX) + (mfY * rVec.mfY) + (mfZ * rVec.mfZ));
return ((mnX * rVec.mnX) + (mnY * rVec.mnY) + (mnZ * rVec.mnZ));
}
/** Transform vector by given transformation matrix.