From: kgv Date: Sat, 12 Jun 2021 12:35:38 +0000 (+0300) Subject: 0032437: Coding Rules - eliminate MinGW warning -Wmaybe-uninitialized X-Git-Tag: V7_6_0_beta~112 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=902b31b6ee125969afbbb88b81e8212218e95261 0032437: Coding Rules - eliminate MinGW warning -Wmaybe-uninitialized --- diff --git a/src/AIS/AIS_ColorScale.cxx b/src/AIS/AIS_ColorScale.cxx index ece1e08764..36b1aa6fdf 100644 --- a/src/AIS/AIS_ColorScale.cxx +++ b/src/AIS/AIS_ColorScale.cxx @@ -914,7 +914,7 @@ void AIS_ColorScale::drawText (const Handle(Graphic3d_Group)& theGroup, //======================================================================= Standard_Integer AIS_ColorScale::TextWidth (const TCollection_ExtendedString& theText) const { - Standard_Integer aWidth, anAscent, aDescent; + Standard_Integer aWidth = 0, anAscent = 0, aDescent = 0; TextSize (theText, myTextHeight, aWidth, anAscent, aDescent); return aWidth; } @@ -925,7 +925,7 @@ Standard_Integer AIS_ColorScale::TextWidth (const TCollection_ExtendedString& th //======================================================================= Standard_Integer AIS_ColorScale::TextHeight (const TCollection_ExtendedString& theText) const { - Standard_Integer aWidth, anAscent, aDescent; + Standard_Integer aWidth = 0, anAscent = 0, aDescent = 0; TextSize (theText, myTextHeight, aWidth, anAscent, aDescent); return anAscent + aDescent; } @@ -940,19 +940,14 @@ void AIS_ColorScale::TextSize (const TCollection_ExtendedString& theText, Standard_Integer& theAscent, Standard_Integer& theDescent) const { - if (!HasInteractiveContext()) + Standard_ShortReal aWidth = 10.0f, anAscent = 1.0f, aDescent = 1.0f; + if (HasInteractiveContext()) { - return; + const TCollection_AsciiString aText (theText); + const Handle(V3d_Viewer)& aViewer = GetContext()->CurrentViewer(); + const Handle(Graphic3d_CView)& aView = aViewer->ActiveViewIterator().Value()->View(); + aViewer->Driver()->TextSize (aView, aText.ToCString(), (Standard_ShortReal)theHeight, aWidth, anAscent, aDescent); } - - Standard_ShortReal aWidth = 10.0f; - Standard_ShortReal anAscent = 1.0f; - Standard_ShortReal aDescent = 1.0f; - const TCollection_AsciiString aText (theText); - - const Handle(V3d_Viewer)& aViewer = GetContext()->CurrentViewer(); - const Handle(Graphic3d_CView)& aView = aViewer->ActiveViewIterator().Value()->View(); - aViewer->Driver()->TextSize (aView, aText.ToCString(), (Standard_ShortReal)theHeight, aWidth, anAscent, aDescent); theWidth = (Standard_Integer)aWidth; theAscent = (Standard_Integer)anAscent; theDescent = (Standard_Integer)aDescent; diff --git a/src/Font/Font_TextFormatter.cxx b/src/Font/Font_TextFormatter.cxx index c32f253f87..eddc4bc83e 100644 --- a/src/Font/Font_TextFormatter.cxx +++ b/src/Font/Font_TextFormatter.cxx @@ -310,38 +310,37 @@ Standard_Boolean Font_TextFormatter::GlyphBoundingBox (const Standard_Integer th Font_Rect& theBndBox) const { if (theIndex < 0 || theIndex >= Corners().Size()) + { return Standard_False; + } const NCollection_Vec2& aLeftCorner = BottomLeft (theIndex); - if (theIndex + 1 < myCorners.Length()) // not the last symbol + theBndBox.Left = aLeftCorner.x(); + theBndBox.Right = aLeftCorner.x() + myLastSymbolWidth; + theBndBox.Bottom = aLeftCorner.y(); + theBndBox.Top = theBndBox.Bottom + myLineSpacing; + if (theIndex + 1 >= myCorners.Length()) { - const NCollection_Vec2& aNextLeftCorner = BottomLeft (theIndex + 1); - theBndBox.Left = aLeftCorner.x(); - theBndBox.Bottom = aLeftCorner.y(); - theBndBox.Top = theBndBox.Bottom + myLineSpacing; - if (Abs (aLeftCorner.y() - aNextLeftCorner.y()) < Precision::Confusion()) // in the same row - { - theBndBox.Right = aNextLeftCorner.x(); - } - else - { - // the next symbol is on the next row either by '\n' or by wrapping - Standard_ShortReal aLineWidth = LineWidth (LineIndex (theIndex)); - theBndBox.Left = aLeftCorner.x(); - switch (myAlignX) - { - case Graphic3d_HTA_LEFT: theBndBox.Right = aLineWidth; break; - case Graphic3d_HTA_RIGHT: theBndBox.Right = myBndWidth; break; - case Graphic3d_HTA_CENTER: theBndBox.Right = 0.5f * (myBndWidth + aLineWidth); break; - } - } + // the last symbol + return Standard_True; + } + + const NCollection_Vec2& aNextLeftCorner = BottomLeft (theIndex + 1); + if (Abs (aLeftCorner.y() - aNextLeftCorner.y()) < Precision::Confusion()) // in the same row + { + theBndBox.Right = aNextLeftCorner.x(); } - else // the last symbol + else { + // the next symbol is on the next row either by '\n' or by wrapping + Standard_ShortReal aLineWidth = LineWidth (LineIndex (theIndex)); theBndBox.Left = aLeftCorner.x(); - theBndBox.Right = aLeftCorner.x() + myLastSymbolWidth; - theBndBox.Bottom = aLeftCorner.y(); - theBndBox.Top = theBndBox.Bottom + myLineSpacing; + switch (myAlignX) + { + case Graphic3d_HTA_LEFT: theBndBox.Right = aLineWidth; break; + case Graphic3d_HTA_RIGHT: theBndBox.Right = myBndWidth; break; + case Graphic3d_HTA_CENTER: theBndBox.Right = 0.5f * (myBndWidth + aLineWidth); break; + } } return Standard_True; } @@ -355,7 +354,9 @@ Standard_Boolean Font_TextFormatter::IsLFSymbol (const Standard_Integer theIndex { Font_Rect aBndBox; if (!GlyphBoundingBox (theIndex, aBndBox)) + { return Standard_False; + } return Abs (aBndBox.Right - aBndBox.Left) < Precision::Confusion(); } @@ -402,7 +403,9 @@ Standard_Integer Font_TextFormatter::LinePositionIndex (const Standard_Integer t Standard_Integer Font_TextFormatter::LineIndex (const Standard_Integer theIndex) const { if (myLineSpacing < 0.0f) + { return 0; + } return (Standard_Integer)Abs((BottomLeft (theIndex).y() + myAscender) / myLineSpacing); } @@ -414,13 +417,19 @@ Standard_Integer Font_TextFormatter::LineIndex (const Standard_Integer theIndex) Standard_ShortReal Font_TextFormatter::LineWidth (const Standard_Integer theIndex) const { if (theIndex < 0) + { return 0; + } if (theIndex < myNewLines.Length()) + { return theIndex == 0 ? myNewLines[0] : myNewLines[theIndex] - myNewLines[theIndex -1]; + } if (theIndex == myNewLines.Length()) // the last line + { return theIndex == 0 ? myPen.x() : myPen.x() - myNewLines[theIndex -1]; + } return 0; } diff --git a/src/Standard/Standard_StackTrace.cxx b/src/Standard/Standard_StackTrace.cxx index 81e2063680..271c7e2b3b 100644 --- a/src/Standard/Standard_StackTrace.cxx +++ b/src/Standard/Standard_StackTrace.cxx @@ -17,6 +17,8 @@ #include #include +#include + #if defined(__APPLE__) #import #endif diff --git a/src/TopOpeBRep/TopOpeBRep_LineInter.cxx b/src/TopOpeBRep/TopOpeBRep_LineInter.cxx index a6bf3b5285..f31d9f7d0f 100644 --- a/src/TopOpeBRep/TopOpeBRep_LineInter.cxx +++ b/src/TopOpeBRep/TopOpeBRep_LineInter.cxx @@ -14,6 +14,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include @@ -45,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -342,38 +342,43 @@ Standard_Boolean TopOpeBRep_LineInter::IsPeriodic() const //======================================================================= //function : Period -//purpose : +//purpose : //======================================================================= - Standard_Real TopOpeBRep_LineInter::Period() const { - Standard_Real f,l; - Bounds(f,l); - return (l - f); + Standard_Real aFirst = 0.0, aLast = 0.0; + Bounds (aFirst, aLast); + return (aLast - aFirst); } //======================================================================= //function : Bounds -//purpose : +//purpose : //======================================================================= - -void TopOpeBRep_LineInter::Bounds(Standard_Real& First,Standard_Real& Last) const +void TopOpeBRep_LineInter::Bounds (Standard_Real& theFirst, Standard_Real& theLast) const { - if ( myILG.IsNull() ) { - TopOpeBRep_LineInter* p = (TopOpeBRep_LineInter*)this; // NYI deconst - p->SetOK(Standard_False); + theFirst = 0.0; theLast = 0.0; + if (myILG.IsNull()) + { + TopOpeBRep_LineInter* aPtr = const_cast(this); // NYI deconst + aPtr->SetOK (Standard_False); return; } - - First = 0.; Last = 0.; - if ( IsPeriodic() ) - Last = Curve()->Period(); - - if ( myILG->HasFirstPoint() ) - First = myILG->FirstPoint().ParameterOnLine(); - if ( myILG->HasLastPoint() ) - Last = myILG->LastPoint().ParameterOnLine(); + if (IsPeriodic()) + { + theLast = Curve()->Period(); + } + + if (myILG->HasFirstPoint()) + { + theFirst = myILG->FirstPoint().ParameterOnLine(); + } + + if (myILG->HasLastPoint()) + { + theLast = myILG->LastPoint().ParameterOnLine(); + } } //======================================================================= diff --git a/src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx b/src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx index 6ed5f5bc81..81b8dc02d2 100644 --- a/src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx +++ b/src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx @@ -14,6 +14,7 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include @@ -65,7 +66,6 @@ #include #include #include -#include #include #include #include @@ -459,9 +459,10 @@ void TopOpeBRepDS_BuildTool::UpdateEdgeCurveTol // newtol *= 1.5; - TopoDS_Vertex Vmin,Vmax; Standard_Real parmin,parmax; - GetOrientedEdgeVertices(E,Vmin,Vmax,parmin,parmax); - + TopoDS_Vertex Vmin, Vmax; + Standard_Real parmin = 0.0, parmax = 0.0; + GetOrientedEdgeVertices (E, Vmin, Vmax, parmin, parmax); + Standard_Real tolmin=BRep_Tool::Tolerance(Vmin); if(newtol>tolmin) tolmin=newtol; Standard_Real tolmax=BRep_Tool::Tolerance(Vmax); @@ -546,20 +547,20 @@ void TopOpeBRepDS_BuildTool::ApproxCurves // Vmin,Vmax = bounding vertices of edge // and their parameters parmin,parmax . - TopoDS_Vertex Vmin,Vmax;Standard_Real parmin,parmax; - GetOrientedEdgeVertices(E,Vmin,Vmax,parmin,parmax); + TopoDS_Vertex Vmin, Vmax; + Standard_Real parmin = 0.0, parmax = 0.0; + GetOrientedEdgeVertices (E, Vmin, Vmax, parmin, parmax); Handle(Geom_Curve) C3Dnew; Handle(Geom2d_Curve) PC1new; Handle(Geom2d_Curve) PC2new; - Standard_Real tolreached3d,tolreached2d; - + Standard_Real tolreached3d = 0.0, tolreached2d = 0.0; Standard_Boolean approxMade = myCurveTool.MakeCurves(parmin,parmax, C3D,PC1,PC2,F1,F2, C3Dnew,PC1new,PC2new, tolreached3d,tolreached2d); - Standard_Real newtol,newparmin,newparmax; + Standard_Real newtol = 0.0, newparmin = 0.0, newparmax = 0.0; // MSV Nov 12, 2001: if approx failed than leave old curves of degree 1 if (!approxMade) { newtol = BRep_Tool::Tolerance(E); @@ -680,20 +681,19 @@ void TopOpeBRepDS_BuildTool::ComputePCurves // get bounding vertices Vmin,Vmax supported by the new edge // and their corresponding parameters parmin,parmax . - - TopoDS_Vertex Vmin,Vmax;Standard_Real parmin,parmax; - GetOrientedEdgeVertices(E,Vmin,Vmax,parmin,parmax); - - Handle(Geom2d_Curve) PC1new; - Handle(Geom2d_Curve) PC2new; - - if(C3D.IsNull()) { - Standard_Real tolreached2d1 = Precision::Confusion(), tolreached2d2 = Precision::Confusion(), r1, r2, tol=Precision::Confusion(); + TopoDS_Vertex Vmin, Vmax; + Standard_Real parmin = 0.0, parmax = 0.0; + GetOrientedEdgeVertices (E, Vmin, Vmax, parmin, parmax); + + Handle(Geom2d_Curve) PC1new, PC2new; + if(C3D.IsNull()) + { + Standard_Real tolreached2d1 = Precision::Confusion(), tolreached2d2 = Precision::Confusion(), tol=Precision::Confusion(); if (comppc1) PC1new = myCurveTool.MakePCurveOnFace(F1,C3D,tolreached2d1); if (comppc2) PC2new = myCurveTool.MakePCurveOnFace(F2,C3D,tolreached2d2); - r1 = TopOpeBRepTool_ShapeTool::Resolution3d(F1,tolreached2d1); - r2 = TopOpeBRepTool_ShapeTool::Resolution3d(F2,tolreached2d2); + Standard_Real r1 = TopOpeBRepTool_ShapeTool::Resolution3d(F1,tolreached2d1); + Standard_Real r2 = TopOpeBRepTool_ShapeTool::Resolution3d(F2,tolreached2d2); tol = Max(tol,r1); tol = Max(tol,r2); newC.Tolerance(tol); @@ -1380,10 +1380,10 @@ void TopOpeBRepDS_BuildTool::RecomputeBSpline1Curve // Vmin,Vmax = bounding vertices of edge // and their parameters parmin,parmax . - TopoDS_Vertex Vmin,Vmax; Standard_Real parmin,parmax; - ::GetOrientedEdgeVertices(E,Vmin,Vmax,parmin,parmax); + TopoDS_Vertex Vmin, Vmax; + Standard_Real parmin = 0.0, parmax = 0.0; + ::GetOrientedEdgeVertices (E, Vmin, Vmax, parmin, parmax); - Handle(Geom_Curve) C3Dnew; Handle(Geom2d_Curve) PC1new; Handle(Geom2d_Curve) PC2new; @@ -1461,9 +1461,9 @@ void TopOpeBRepDS_BuildTool::RecomputeCurveOnCone // get bounding vertices Vmin,Vmax supported by the new edge // and their corresponding parameters parmin,parmax . - - TopoDS_Vertex Vmin,Vmax; Standard_Real parmin,parmax; - ::GetOrientedEdgeVertices(E,Vmin,Vmax,parmin,parmax); + TopoDS_Vertex Vmin, Vmax; + Standard_Real parmin = 0.0, parmax = 0.0; + ::GetOrientedEdgeVertices (E, Vmin, Vmax, parmin, parmax); if ( C3D->IsPeriodic() ) { // ellipse on cone : periodize parmin,parmax @@ -1538,5 +1538,3 @@ void TopOpeBRepDS_BuildTool::RecomputeCurveOnCone if (!PC1new.IsNull()) C2.Curve1(PC1new); if (!PC2new.IsNull()) C2.Curve2(PC2new); }*/ // - merge 04-07-97 - -