From b1492cb30fcac293dcedabecb914a8a9db0fe536 Mon Sep 17 00:00:00 2001 From: mzernova Date: Fri, 6 Sep 2019 13:56:40 +0300 Subject: [PATCH] 0022777: Visualization - Unsafe way to get attribute values from MeshVS_Drawer Set default values for local variables used for storing values that are obtained by MeshVS_Drawer::Get****() methods --- src/MeshVS/MeshVS_CommonSensitiveEntity.cxx | 1 + src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx | 5 +++-- src/MeshVS/MeshVS_MeshPrsBuilder.cxx | 7 ++++--- src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx | 4 ++-- src/MeshVS/MeshVS_TextPrsBuilder.cxx | 14 ++++++++------ 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx b/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx index 2f118c1adb..c0165fc44f 100644 --- a/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx +++ b/src/MeshVS/MeshVS_CommonSensitiveEntity.cxx @@ -34,6 +34,7 @@ MeshVS_CommonSensitiveEntity::MeshVS_CommonSensitiveEntity (const Handle(SelectM myDataSource (theParentMesh->GetDataSource()), mySelMethod (theSelMethod) { + myMaxFaceNodes = 0; theParentMesh->GetDrawer()->GetInteger (MeshVS_DA_MaxFaceNodes, myMaxFaceNodes); Standard_ASSERT_RAISE (myMaxFaceNodes > 0, "The maximal amount of nodes in a face must be greater than zero to create sensitive entity"); diff --git a/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx index e267a56afa..7ceb2696f3 100644 --- a/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx @@ -179,8 +179,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& //Now we are ready to draw faces with equal colors Aspect_TypeOfLine anEdgeType = Aspect_TOL_SOLID; Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID; - Standard_Integer anEdgeInt, aLineInt; - Standard_Real anEdgeWidth, aLineWidth; + Standard_Real anEdgeWidth = 1.0, aLineWidth = 1.0; Quantity_Color anInteriorColor; Quantity_Color anEdgeColor, aLineColor; Standard_Boolean anEdgeOn = Standard_True, IsReflect = Standard_False, @@ -197,9 +196,11 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& aDrawer->GetBoolean( MeshVS_DA_SmoothShading, IsMeshSmoothShading ); aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, toSupressBackFaces); + Standard_Integer anEdgeInt = Aspect_TOL_SOLID; if ( aDrawer->GetInteger ( MeshVS_DA_EdgeType, anEdgeInt) ) anEdgeType = (Aspect_TypeOfLine) anEdgeInt; + Standard_Integer aLineInt = Aspect_TOL_SOLID; if ( aDrawer->GetInteger ( MeshVS_DA_BeamType, aLineInt) ) aLineType = (Aspect_TypeOfLine) aLineInt; diff --git a/src/MeshVS/MeshVS_MeshPrsBuilder.cxx b/src/MeshVS/MeshVS_MeshPrsBuilder.cxx index b627d16d7f..7f7d01a5c5 100644 --- a/src/MeshVS/MeshVS_MeshPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_MeshPrsBuilder.cxx @@ -195,7 +195,7 @@ void MeshVS_MeshPrsBuilder::BuildElements( const Handle(Prs3d_Presentation)& Prs aDispMode &= MeshVS_DMF_OCCMask; //-------------------------------------------------------- - Standard_Real aShrinkCoef; + Standard_Real aShrinkCoef = 0.0; aDrawer->GetDouble ( MeshVS_DA_ShrinkCoeff, aShrinkCoef ); Standard_Boolean IsWireFrame = ( aDispMode==MeshVS_DMF_WireFrame ), @@ -203,11 +203,12 @@ void MeshVS_MeshPrsBuilder::BuildElements( const Handle(Prs3d_Presentation)& Prs IsShrink = ( aDispMode==MeshVS_DMF_Shrink ), HasHilightFlag = ( ( DisplayMode & MeshVS_DMF_HilightPrs ) != 0 ), HasSelectFlag = ( ( DisplayMode & MeshVS_DMF_SelectionPrs ) != 0 ), - IsMeshReflect, IsMeshAllowOverlap, IsReflect, IsMeshSmoothShading = Standard_False; + IsMeshReflect = Standard_False, IsMeshAllowOverlap = Standard_False, + IsMeshSmoothShading = Standard_False; aDrawer->GetBoolean ( MeshVS_DA_Reflection, IsMeshReflect ); aDrawer->GetBoolean ( MeshVS_DA_IsAllowOverlapped, IsMeshAllowOverlap ); - IsReflect = ( IsMeshReflect && !HasHilightFlag ); + const Standard_Boolean IsReflect = ( IsMeshReflect && !HasHilightFlag ); aDrawer->GetBoolean ( MeshVS_DA_SmoothShading, IsMeshSmoothShading ); // display mode for highlighted prs of groups diff --git a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx index 1d90c3fc79..8856854542 100644 --- a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx @@ -411,8 +411,7 @@ void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, // Aspect_InteriorStyle aStyle; // Standard_Integer aStyleInt; Aspect_TypeOfLine anEdgeType = Aspect_TOL_SOLID; - Standard_Integer anEdgeInt; - Standard_Real anEdgeWidth; + Standard_Real anEdgeWidth = 1.0; Quantity_Color anInteriorColor; Quantity_Color anEdgeColor, aLineColor; Standard_Boolean aShowEdges = Standard_True; @@ -423,6 +422,7 @@ void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, aDrawer->GetDouble ( MeshVS_DA_EdgeWidth, anEdgeWidth ); aDrawer->GetBoolean( MeshVS_DA_ShowEdges, aShowEdges ); + Standard_Integer anEdgeInt = Aspect_TOL_SOLID; if ( aDrawer->GetInteger ( MeshVS_DA_EdgeType, anEdgeInt ) ) anEdgeType = (Aspect_TypeOfLine) anEdgeInt; diff --git a/src/MeshVS/MeshVS_TextPrsBuilder.cxx b/src/MeshVS/MeshVS_TextPrsBuilder.cxx index 2e6ffdfcd1..92725ea070 100644 --- a/src/MeshVS/MeshVS_TextPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_TextPrsBuilder.cxx @@ -167,27 +167,29 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, Standard_Real AExpansionFactor = 1.0; Standard_Real ASpace = 0.0; Aspect_TypeOfStyleText ATextStyle = Aspect_TOST_ANNOTATION; - Standard_Integer AStyleInt; Aspect_TypeOfDisplayText ADisplayType = Aspect_TODT_NORMAL; - TCollection_AsciiString AFontString; - Standard_Integer ADispInt; // Bold font is used by default for better text readability Font_FontAspect AFontAspectType = Font_FA_Bold; - Standard_Integer AAspect; - aDrawer->GetColor ( MeshVS_DA_TextColor, AColor ); aDrawer->GetDouble ( MeshVS_DA_TextExpansionFactor, AExpansionFactor ); aDrawer->GetDouble ( MeshVS_DA_TextSpace, ASpace ); + TCollection_AsciiString AFontString = Font_NOF_ASCII_MONO; if ( aDrawer->GetAsciiString ( MeshVS_DA_TextFont, AFontString ) ) AFont = AFontString.ToCString(); + + Standard_Integer AStyleInt = Aspect_TOST_ANNOTATION; if ( aDrawer->GetInteger ( MeshVS_DA_TextStyle, AStyleInt ) ) ATextStyle = (Aspect_TypeOfStyleText) AStyleInt; + + Standard_Integer ADispInt = Aspect_TODT_NORMAL; if ( aDrawer->GetInteger ( MeshVS_DA_TextDisplayType, ADispInt ) ) ADisplayType = (Aspect_TypeOfDisplayText) ADispInt; + + Standard_Integer AAspect = Font_FA_Bold; if ( aDrawer->GetInteger ( MeshVS_DA_TextFontAspect, AAspect ) ) - AFontAspectType = (Font_FontAspect)AAspect; + AFontAspectType = (Font_FontAspect)AAspect; Handle (Graphic3d_AspectText3d) aTextAspect = new Graphic3d_AspectText3d ( AColor, AFont, AExpansionFactor, ASpace, ATextStyle, ADisplayType ); -- 2.20.1