const double aRotTol = theIsEmulated
? double(myTouchToleranceScale) * myTouchRotationThresholdPx
: 0.0;
- if (double (Abs (aDelta.x()) + Abs (aDelta.y())) > aRotTol)
+ const Graphic3d_Vec2d aDeltaF (aDelta);
+ if (Abs (aDeltaF.x()) + Abs (aDeltaF.y()) > aRotTol)
{
const double aRotAccel = myNavigationMode == AIS_NavigationMode_FirstPersonWalk ? myMouseAccel : myOrbitAccel;
const Graphic3d_Vec2i aRotDelta = thePoint - myMousePressPoint;
const double aPanTol = theIsEmulated
? double(myTouchToleranceScale) * myTouchPanThresholdPx
: 0.0;
- if (double (Abs (aDelta.x()) + Abs (aDelta.y())) > aPanTol)
+ const Graphic3d_Vec2d aDeltaF (aDelta);
+ if (Abs (aDeltaF.x()) + Abs (aDeltaF.y()) > aPanTol)
{
if (myUpdateStartPointPan)
{
Graphic3d_Vec2i aWinSize;
theView->Window()->Size (aWinSize.x(), aWinSize.y());
- const Graphic3d_Vec2d aPanFromCenterPx (double(theParams.Point.x()) - 0.5 * double(aWinSize.x()),
- double(aWinSize.y() - theParams.Point.y() - 1) - 0.5 * double(aWinSize.y()));
- aDxy.x() += -aViewDims1.X() * aPanFromCenterPx.x() / double(aWinSize.x());
- aDxy.y() += -aViewDims1.Y() * aPanFromCenterPx.y() / double(aWinSize.y());
+ const Graphic3d_Vec2d aWinSizeF (aWinSize);
+ const Graphic3d_Vec2d aPanFromCenterPx (double(theParams.Point.x()) - 0.5 * aWinSizeF.x(),
+ aWinSizeF.y() - double(theParams.Point.y()) - 1.0 - 0.5 * aWinSizeF.y());
+ aDxy.x() += -aViewDims1.X() * aPanFromCenterPx.x() / aWinSizeF.x();
+ aDxy.y() += -aViewDims1.Y() * aPanFromCenterPx.y() / aWinSizeF.y();
}
//theView->Translate (aCam, aDxy.x(), aDxy.y());
void SetVertice (const Standard_Integer theIndex, const Standard_ShortReal theX, const Standard_ShortReal theY, const Standard_ShortReal theZ)
{
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > myAttribs->NbMaxElements(), "BAD VERTEX index");
- Graphic3d_Vec3& aVec = *reinterpret_cast<Graphic3d_Vec3*> (myAttribs->ChangeData() + myPosStride * (theIndex - 1));
+ Graphic3d_Vec3& aVec = *reinterpret_cast<Graphic3d_Vec3*> (myAttribs->ChangeData() + myPosStride * ((Standard_Size)theIndex - 1));
aVec.x() = theX;
aVec.y() = theY;
aVec.z() = theZ;
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > myAttribs->NbMaxElements(), "BAD VERTEX index");
if (myColData != NULL)
{
- Graphic3d_Vec4ub* aColorPtr = reinterpret_cast<Graphic3d_Vec4ub* >(myColData + myColStride * (theIndex - 1));
+ Graphic3d_Vec4ub* aColorPtr = reinterpret_cast<Graphic3d_Vec4ub* >(myColData + myColStride * ((Standard_Size)theIndex - 1));
aColorPtr->SetValues (Standard_Byte(theR * 255.0),
Standard_Byte(theG * 255.0),
Standard_Byte(theB * 255.0), 255);
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > myAttribs->NbMaxElements(), "BAD VERTEX index");
if (myColData != NULL)
{
- Graphic3d_Vec4ub* aColorPtr = reinterpret_cast<Graphic3d_Vec4ub* >(myColData + myColStride * (theIndex - 1));
+ Graphic3d_Vec4ub* aColorPtr = reinterpret_cast<Graphic3d_Vec4ub* >(myColData + myColStride * ((Standard_Size)theIndex - 1));
(*aColorPtr) = theColor;
}
myAttribs->NbElements = Max (theIndex, myAttribs->NbElements);
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > myAttribs->NbMaxElements(), "BAD VERTEX index");
if (myColData != NULL)
{
- *reinterpret_cast<Standard_Integer* >(myColData + myColStride * (theIndex - 1)) = theColor32;
+ *reinterpret_cast<Standard_Integer* >(myColData + myColStride * ((Standard_Size)theIndex - 1)) = theColor32;
}
}
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > myAttribs->NbMaxElements(), "BAD VERTEX index");
if (myNormData != NULL)
{
- Graphic3d_Vec3& aVec = *reinterpret_cast<Graphic3d_Vec3* >(myNormData + myNormStride * (theIndex - 1));
+ Graphic3d_Vec3& aVec = *reinterpret_cast<Graphic3d_Vec3* >(myNormData + myNormStride * ((Standard_Size)theIndex - 1));
aVec.x() = Standard_ShortReal (theNX);
aVec.y() = Standard_ShortReal (theNY);
aVec.z() = Standard_ShortReal (theNZ);
Standard_OutOfRange_Raise_if (theIndex < 1 || theIndex > myAttribs->NbMaxElements(), "BAD VERTEX index");
if (myTexData != NULL)
{
- Graphic3d_Vec2& aVec = *reinterpret_cast<Graphic3d_Vec2* >(myTexData + myTexStride * (theIndex - 1));
+ Graphic3d_Vec2& aVec = *reinterpret_cast<Graphic3d_Vec2* >(myTexData + myTexStride * ((Standard_Size)theIndex - 1));
aVec.x() = Standard_ShortReal (theTX);
aVec.y() = Standard_ShortReal (theTY);
}
{
theX = theY = theZ = 0.0;
Standard_OutOfRange_Raise_if (theRank < 1 || theRank > myAttribs->NbElements, "BAD VERTEX index");
- const Graphic3d_Vec3& aVec = *reinterpret_cast<const Graphic3d_Vec3*> (myAttribs->Data() + myPosStride * (theRank - 1));
+ const Graphic3d_Vec3& aVec = *reinterpret_cast<const Graphic3d_Vec3*> (myAttribs->Data() + myPosStride * ((Standard_Size)theRank - 1));
theX = Standard_Real(aVec.x());
theY = Standard_Real(aVec.y());
theZ = Standard_Real(aVec.z());
Graphic3d_Vec4ub& theColor) const
{
Standard_OutOfRange_Raise_if (myColData == NULL || theIndex < 1 || theIndex > myAttribs->NbElements, "BAD VERTEX index");
- theColor = *reinterpret_cast<const Graphic3d_Vec4ub* >(myColData + myColStride * (theIndex - 1));
+ theColor = *reinterpret_cast<const Graphic3d_Vec4ub* >(myColData + myColStride * ((Standard_Size)theIndex - 1));
}
//! Returns the vertex color values from the vertex table if defined.
{
return;
}
- const Graphic3d_Vec4ub& aColor = *reinterpret_cast<const Graphic3d_Vec4ub* >(myColData + myColStride * (theRank - 1));
+ const Graphic3d_Vec4ub& aColor = *reinterpret_cast<const Graphic3d_Vec4ub* >(myColData + myColStride * ((Standard_Size)theRank - 1));
theR = Standard_Real(aColor.r()) / 255.0;
theG = Standard_Real(aColor.g()) / 255.0;
theB = Standard_Real(aColor.b()) / 255.0;
Standard_OutOfRange_Raise_if (theRank < 1 || theRank > myAttribs->NbElements, "BAD VERTEX index");
if (myColData != NULL)
{
- theColor = *reinterpret_cast<const Standard_Integer* >(myColData + myColStride * (theRank - 1));
+ theColor = *reinterpret_cast<const Standard_Integer* >(myColData + myColStride * ((Standard_Size)theRank - 1));
}
}
Standard_OutOfRange_Raise_if (theRank < 1 || theRank > myAttribs->NbElements, "BAD VERTEX index");
if (myNormData != NULL)
{
- const Graphic3d_Vec3& aVec = *reinterpret_cast<const Graphic3d_Vec3* >(myNormData + myNormStride * (theRank - 1));
+ const Graphic3d_Vec3& aVec = *reinterpret_cast<const Graphic3d_Vec3* >(myNormData + myNormStride * ((Standard_Size)theRank - 1));
theNX = Standard_Real(aVec.x());
theNY = Standard_Real(aVec.y());
theNZ = Standard_Real(aVec.z());
Standard_OutOfRange_Raise_if (theRank < 1 || theRank > myAttribs->NbElements, "BAD VERTEX index");
if (myTexData != NULL)
{
- const Graphic3d_Vec2& aVec = *reinterpret_cast<const Graphic3d_Vec2* >(myTexData + myTexStride * (theRank - 1));
+ const Graphic3d_Vec2& aVec = *reinterpret_cast<const Graphic3d_Vec2* >(myTexData + myTexStride * ((Standard_Size)theRank - 1));
theTX = Standard_Real(aVec.x());
theTY = Standard_Real(aVec.y());
}
// If input value is out of valid range for integers,
// minimal or maximal possible integer is returned.
//-------------------------------------------------------------------
-inline Standard_Integer RealToInt (const Standard_Real Value)
+inline Standard_Integer RealToInt (const Standard_Real theValue)
{
// Note that on WNT under MS VC++ 8.0 conversion of double value less
// than INT_MIN or greater than INT_MAX to integer will cause signal
// "Floating point multiple trap" (OCC17861)
- return Value < INT_MIN ? INT_MIN
- : Value > INT_MAX ? INT_MAX
- : (Standard_Integer)Value;
+ return theValue < static_cast<Standard_Real>(INT_MIN)
+ ? static_cast<Standard_Integer>(INT_MIN)
+ : (theValue > static_cast<Standard_Real>(INT_MAX)
+ ? static_cast<Standard_Integer>(INT_MAX)
+ : static_cast<Standard_Integer>(theValue));
}
// =======================================================================