0032437: Coding Rules - eliminate MinGW warning -Wmaybe-uninitialized
authorkgv <kgv@opencascade.com>
Sat, 12 Jun 2021 12:35:38 +0000 (15:35 +0300)
committerkgv <kgv@opencascade.com>
Sun, 13 Jun 2021 11:08:59 +0000 (14:08 +0300)
src/AIS/AIS_ColorScale.cxx
src/Font/Font_TextFormatter.cxx
src/Standard/Standard_StackTrace.cxx
src/TopOpeBRep/TopOpeBRep_LineInter.cxx
src/TopOpeBRepDS/TopOpeBRepDS_BuildTool.cxx

index ece1e08..36b1aa6 100644 (file)
@@ -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 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;
 }
   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 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;
 }
   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
 {
                                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;
   theWidth   = (Standard_Integer)aWidth;
   theAscent  = (Standard_Integer)anAscent;
   theDescent = (Standard_Integer)aDescent;
index c32f253..eddc4bc 100644 (file)
@@ -310,38 +310,37 @@ Standard_Boolean Font_TextFormatter::GlyphBoundingBox (const Standard_Integer th
                                                        Font_Rect& theBndBox) const
 {
   if (theIndex < 0 || theIndex >= Corners().Size())
                                                        Font_Rect& theBndBox) const
 {
   if (theIndex < 0 || theIndex >= Corners().Size())
+  {
     return Standard_False;
     return Standard_False;
+  }
 
   const NCollection_Vec2<Standard_ShortReal>& aLeftCorner = BottomLeft (theIndex);
 
   const NCollection_Vec2<Standard_ShortReal>& 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<Standard_ShortReal>& 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<Standard_ShortReal>& 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.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;
 }
   }
   return Standard_True;
 }
@@ -355,7 +354,9 @@ Standard_Boolean Font_TextFormatter::IsLFSymbol (const Standard_Integer theIndex
 {
   Font_Rect aBndBox;
   if (!GlyphBoundingBox (theIndex, aBndBox))
 {
   Font_Rect aBndBox;
   if (!GlyphBoundingBox (theIndex, aBndBox))
+  {
     return Standard_False;
     return Standard_False;
+  }
 
   return Abs (aBndBox.Right - aBndBox.Left) < Precision::Confusion();
 }
 
   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)
 Standard_Integer Font_TextFormatter::LineIndex (const Standard_Integer theIndex) const
 {
   if (myLineSpacing < 0.0f)
+  {
     return 0;
     return 0;
+  }
 
   return (Standard_Integer)Abs((BottomLeft (theIndex).y() + myAscender) / myLineSpacing);
 }
 
   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)
 Standard_ShortReal Font_TextFormatter::LineWidth (const Standard_Integer theIndex) const
 {
   if (theIndex < 0)
+  {
     return 0;
     return 0;
+  }
 
   if (theIndex < myNewLines.Length())
 
   if (theIndex < myNewLines.Length())
+  {
     return theIndex == 0 ? myNewLines[0] : myNewLines[theIndex] - myNewLines[theIndex -1];
     return theIndex == 0 ? myNewLines[0] : myNewLines[theIndex] - myNewLines[theIndex -1];
+  }
 
   if (theIndex == myNewLines.Length()) // the last line
 
   if (theIndex == myNewLines.Length()) // the last line
+  {
     return theIndex == 0 ? myPen.x() : myPen.x() - myNewLines[theIndex -1];
     return theIndex == 0 ? myPen.x() : myPen.x() - myNewLines[theIndex -1];
+  }
 
   return 0;
 }
 
   return 0;
 }
index 81e2063..271c7e2 100644 (file)
@@ -17,6 +17,8 @@
 #include <Message.hxx>
 #include <Standard_Mutex.hxx>
 
 #include <Message.hxx>
 #include <Standard_Mutex.hxx>
 
+#include <Standard_WarningDisableFunctionCast.hxx>
+
 #if defined(__APPLE__)
   #import <TargetConditionals.h>
 #endif
 #if defined(__APPLE__)
   #import <TargetConditionals.h>
 #endif
index a6bf3b5..f31d9f7 100644 (file)
@@ -14,6 +14,7 @@
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+#include <TopOpeBRep_LineInter.hxx>
 
 #include <Adaptor2d_Curve2d.hxx>
 #include <BRepAdaptor_Curve2d.hxx>
 
 #include <Adaptor2d_Curve2d.hxx>
 #include <BRepAdaptor_Curve2d.hxx>
@@ -45,7 +46,6 @@
 #include <TopOpeBRep.hxx>
 #include <TopOpeBRep_Bipoint.hxx>
 #include <TopOpeBRep_FFTransitionTool.hxx>
 #include <TopOpeBRep.hxx>
 #include <TopOpeBRep_Bipoint.hxx>
 #include <TopOpeBRep_FFTransitionTool.hxx>
-#include <TopOpeBRep_LineInter.hxx>
 #include <TopOpeBRep_VPointInter.hxx>
 #include <TopOpeBRep_VPointInterIterator.hxx>
 #include <TopOpeBRep_WPointInter.hxx>
 #include <TopOpeBRep_VPointInter.hxx>
 #include <TopOpeBRep_VPointInterIterator.hxx>
 #include <TopOpeBRep_WPointInter.hxx>
@@ -342,38 +342,43 @@ Standard_Boolean TopOpeBRep_LineInter::IsPeriodic() const
 
 //=======================================================================
 //function : Period
 
 //=======================================================================
 //function : Period
-//purpose  : 
+//purpose  :
 //=======================================================================
 //=======================================================================
-
 Standard_Real TopOpeBRep_LineInter::Period() const
 {
 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
 }
 
 //=======================================================================
 //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<TopOpeBRep_LineInter*>(this); // NYI deconst
+    aPtr->SetOK (Standard_False);
     return;
   }
     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();
+  }
 }
 
 //=======================================================================
 }
 
 //=======================================================================
index 6ed5f5b..81b8dc0 100644 (file)
@@ -14,6 +14,7 @@
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
+#include <TopOpeBRepDS_BuildTool.hxx>
 
 #include <BRep_Tool.hxx>
 #include <BRepAdaptor_Surface.hxx>
 
 #include <BRep_Tool.hxx>
 #include <BRepAdaptor_Surface.hxx>
@@ -65,7 +66,6 @@
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
-#include <TopOpeBRepDS_BuildTool.hxx>
 #include <TopOpeBRepDS_Curve.hxx>
 #include <TopOpeBRepDS_DataStructure.hxx>
 #include <TopOpeBRepDS_Dumper.hxx>
 #include <TopOpeBRepDS_Curve.hxx>
 #include <TopOpeBRepDS_DataStructure.hxx>
 #include <TopOpeBRepDS_Dumper.hxx>
@@ -459,9 +459,10 @@ void TopOpeBRepDS_BuildTool::UpdateEdgeCurveTol
 
 //  newtol *= 1.5;
 
 
 //  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);
   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 <E>
   // and their parameters parmin,parmax .
 
   // Vmin,Vmax = bounding vertices of edge <E>
   // 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;
 
   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_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);
   // 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 <E>
   // and their corresponding parameters parmin,parmax .
 
   // get bounding vertices Vmin,Vmax supported by the new edge <E>
   // 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);
     
     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);
     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 <E>
   // and their parameters parmin,parmax .
 
   // Vmin,Vmax = bounding vertices of edge <E>
   // 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;
   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 <E>
   // and their corresponding parameters parmin,parmax .
 
   // get bounding vertices Vmin,Vmax supported by the new edge <E>
   // 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
 
   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
   if (!PC1new.IsNull()) C2.Curve1(PC1new);
   if (!PC2new.IsNull()) C2.Curve2(PC2new);
 }*/ // - merge 04-07-97
-
-