From 7f4c47564c6cde7f36535ef75cd7724e5cc0048a Mon Sep 17 00:00:00 2001 From: abv Date: Thu, 21 Feb 2013 22:04:18 +0400 Subject: [PATCH] 0023787: Eliminate trivial type conversion warnings in MSVC Explicit type cast added in conversions from double to float in PrsMgr, Select3D, StdPrs, Visual3d, and Voxel. Minor corrections in ShapeProcess and TCollection. In Visual3d_ViewManager::ConvertCoord...(), output is initialized by zeros instead of RealLast() in case of failure. In XmlMXCAFDoc, material density is correctly converted to string when writing to Xml. --- src/PrsMgr/PrsMgr_PresentableObject.cxx | 6 +++--- src/Select3D/Select3D_SensitiveGroup.cxx | 6 ++++-- src/ShapeProcess/ShapeProcess_Context.cxx | 2 +- src/StdPrs/StdPrs_ToolShadedShape.cxx | 12 ++++++------ src/TCollection/TCollection_ExtendedString.cxx | 3 ++- src/Visual3d/Visual3d_Layer.cxx | 2 +- src/Visual3d/Visual3d_View.cxx | 10 ++++++---- src/Visual3d/Visual3d_ViewManager.cxx | 11 ++++------- src/Voxel/Voxel_Reader.cxx | 2 +- src/VrmlData/VrmlData_ShapeConvert.cxx | 6 +++--- src/XmlMXCAFDoc/XmlMXCAFDoc_MaterialDriver.cxx | 3 ++- 11 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cxx b/src/PrsMgr/PrsMgr_PresentableObject.cxx index bbcc1a5aa1..83480044cd 100755 --- a/src/PrsMgr/PrsMgr_PresentableObject.cxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.cxx @@ -293,9 +293,9 @@ void PrsMgr_PresentableObject::SetTransformPersistence( const Graphic3d_TransMo const gp_Pnt& ThePoint ) { myTransformPersistence.Flag = TheFlag; - myTransformPersistence.Point.x = ThePoint.X(); - myTransformPersistence.Point.y = ThePoint.Y(); - myTransformPersistence.Point.z = ThePoint.Z(); + myTransformPersistence.Point.x = (Standard_ShortReal)ThePoint.X(); + myTransformPersistence.Point.y = (Standard_ShortReal)ThePoint.Y(); + myTransformPersistence.Point.z = (Standard_ShortReal)ThePoint.Z(); Handle(Graphic3d_Structure) aStruct; for( Standard_Integer i = 1, n = myPresentations.Length(); i <= n; i++ ) diff --git a/src/Select3D/Select3D_SensitiveGroup.cxx b/src/Select3D/Select3D_SensitiveGroup.cxx index 45d30f34b4..554afffbe7 100755 --- a/src/Select3D/Select3D_SensitiveGroup.cxx +++ b/src/Select3D/Select3D_SensitiveGroup.cxx @@ -221,12 +221,14 @@ Standard_Boolean Select3D_SensitiveGroup::Matches(const Standard_Real X, Standard_Real& DMin) { myLastRank = 0; - myLastTol = aTol; + myLastTol = (Standard_ShortReal)aTol; for(Select3D_ListIteratorOfListOfSensitive It(myList);It.More();It.Next()){ myLastRank++; if (It.Value()->Matches (X, Y, aTol, DMin)) { - myX = X; myY = Y; myLastTol = aTol; + myX = (Standard_ShortReal)X; + myY = (Standard_ShortReal)Y; + myLastTol = (Standard_ShortReal)aTol; // compute and validate the depth (will call ::ComputeDepth()) return Select3D_SensitiveEntity::Matches (X, Y, aTol, DMin); } diff --git a/src/ShapeProcess/ShapeProcess_Context.cxx b/src/ShapeProcess/ShapeProcess_Context.cxx index b63975041e..41983d2bb6 100755 --- a/src/ShapeProcess/ShapeProcess_Context.cxx +++ b/src/ShapeProcess/ShapeProcess_Context.cxx @@ -77,7 +77,7 @@ Handle(Resource_Manager) ShapeProcess_Context::LoadResourceManager (const Standa // Optimisation of loading resource file: file is load only once // and reloaded only if file date has changed static Handle(Resource_Manager) sRC; - static long mtime; + static Standard_Time mtime; static TCollection_AsciiString name; if ( ! sRC.IsNull() && ! name.IsEqual ( file ) ) sRC.Nullify(); if ( ! sRC.IsNull() ) { diff --git a/src/StdPrs/StdPrs_ToolShadedShape.cxx b/src/StdPrs/StdPrs_ToolShadedShape.cxx index fa2f504166..5f16bf6f11 100755 --- a/src/StdPrs/StdPrs_ToolShadedShape.cxx +++ b/src/StdPrs/StdPrs_ToolShadedShape.cxx @@ -137,9 +137,9 @@ void StdPrs_ToolShadedShape::Normal(const TopoDS_Face& aFace, } Standard_Integer j = (i - UVNodes.Lower()) * 3; - Normals->SetValue(j + 1, Nor(i).X()); - Normals->SetValue(j + 2, Nor(i).Y()); - Normals->SetValue(j + 3, Nor(i).Z()); + Normals->SetValue(j + 1, (Standard_ShortReal)Nor(i).X()); + Normals->SetValue(j + 2, (Standard_ShortReal)Nor(i).Y()); + Normals->SetValue(j + 3, (Standard_ShortReal)Nor(i).Z()); if (aFace.Orientation() == TopAbs_REVERSED) (Nor(i)).Reverse(); @@ -179,9 +179,9 @@ void StdPrs_ToolShadedShape::Normal(const TopoDS_Face& aFace, Nor(i) = gp_Dir(eqPlan); Standard_Integer j = (i - Nodes.Lower()) * 3; - Normals->SetValue(j + 1, Nor(i).X()); - Normals->SetValue(j + 2, Nor(i).Y()); - Normals->SetValue(j + 3, Nor(i).Z()); + Normals->SetValue(j + 1, (Standard_ShortReal)Nor(i).X()); + Normals->SetValue(j + 2, (Standard_ShortReal)Nor(i).Y()); + Normals->SetValue(j + 3, (Standard_ShortReal)Nor(i).Z()); if (aFace.Orientation() == TopAbs_REVERSED) (Nor(i)).Reverse(); diff --git a/src/TCollection/TCollection_ExtendedString.cxx b/src/TCollection/TCollection_ExtendedString.cxx index d9a70d845e..62235535d7 100755 --- a/src/TCollection/TCollection_ExtendedString.cxx +++ b/src/TCollection/TCollection_ExtendedString.cxx @@ -166,10 +166,11 @@ TCollection_ExtendedString::TCollection_ExtendedString mylength = nbSymbols(astring); mystring = Allocate(ROUNDMEM((mylength+1)*2)); if(!ConvertToUnicode (astring)) + { #ifdef DEB cout <<"UTF8 decoding failure..." <TextSize (AText, AHeight, aWidth, anAscent, aDescent); + MyGraphicDriver->TextSize (AText, (Standard_ShortReal)AHeight, aWidth, anAscent, aDescent); AWidth = aWidth; AnAscent = anAscent; ADescent = aDescent; diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx index f7ec8aad07..f27fe580d5 100755 --- a/src/Visual3d/Visual3d_View.cxx +++ b/src/Visual3d/Visual3d_View.cxx @@ -359,7 +359,8 @@ Standard_Real Sx, Sy, Sz; MyCView.Orientation.IsCustomMatrix = 1; for ( i = 0; i < 4; i++) for ( j = 0; j < 4; j++) - MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j); + MyCView.Orientation.ModelViewMatrix[i][j] = + (Standard_ShortReal)MyViewOrientation.MyModelViewMatrix->Value(i,j); } else { MyCView.Orientation.IsCustomMatrix = 0; @@ -395,7 +396,8 @@ Standard_Real um, vm, uM, vM; MyCView.Mapping.IsCustomMatrix = 1; for ( i = 0; i < 4; i++) for ( j = 0; j < 4; j++) - MyCView.Mapping.ProjectionMatrix[i][j] = MyViewMapping.MyProjectionMatrix->Value(i,j); + MyCView.Mapping.ProjectionMatrix[i][j] = + (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j); } else { MyCView.Mapping.IsCustomMatrix = 0; @@ -1340,7 +1342,7 @@ Standard_Real um, vm, uM, vM; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) MyCView.Mapping.ProjectionMatrix[i][j] = - MyViewMapping.MyProjectionMatrix->Value(i,j); + (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j); } MyMatOfMapIsEvaluated = Standard_False; @@ -1408,7 +1410,7 @@ Standard_Real um, vm, uM, vM; for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) MyCView.Mapping.ProjectionMatrix[i][j] = - MyViewMapping.MyProjectionMatrix->Value(i,j); + (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j); } MyMatOfMapIsEvaluated = Standard_False; diff --git a/src/Visual3d/Visual3d_ViewManager.cxx b/src/Visual3d/Visual3d_ViewManager.cxx index 1cf0dce2ee..96d0ad3d41 100755 --- a/src/Visual3d/Visual3d_ViewManager.cxx +++ b/src/Visual3d/Visual3d_ViewManager.cxx @@ -634,9 +634,8 @@ Graphic3d_Vertex Visual3d_ViewManager::ConvertCoord (const Handle(Aspect_Window) Graphic3d_CView TheCView; Graphic3d_Vertex Point; - if (! ViewExists (AWindow, TheCView)) - Point.SetCoord (RealLast (), RealLast (), RealLast ()); - else { + if (ViewExists (AWindow, TheCView)) + { Standard_Integer Width, Height; Standard_ShortReal x, y, z; Standard_Boolean Result; @@ -753,8 +752,6 @@ Standard_Boolean BResult; if (WCT != 0.) Point.SetCoord (WCX/WCT, WCY/WCT, WCZ/WCT); - else - Point.SetCoord (RealLast (), RealLast (), RealLast ()); } } @@ -768,7 +765,7 @@ void Visual3d_ViewManager::ConvertCoordWithProj (const Handle(Aspect_Window)& AW Graphic3d_CView TheCView; if (! ViewExists (AWindow, TheCView)) { - Point.SetCoord (RealLast (), RealLast (), RealLast ()); + Point.SetCoord (0., 0., 0.); Proj.SetCoord (0., 0., 0.); } else { @@ -893,7 +890,7 @@ Standard_Boolean BResult; if (WCT != 0.) Point.SetCoord (WCX/WCT, WCY/WCT, WCZ/WCT); else - Point.SetCoord (RealLast (), RealLast (), RealLast ()); + Point.SetCoord (0., 0., 0.); // Define projection ray NPCZ = 10.0; diff --git a/src/Voxel/Voxel_Reader.cxx b/src/Voxel/Voxel_Reader.cxx index 326843d20f..d502f3c7fe 100755 --- a/src/Voxel/Voxel_Reader.cxx +++ b/src/Voxel/Voxel_Reader.cxx @@ -359,7 +359,7 @@ Standard_Boolean Voxel_Reader::ReadFloatAsciiVoxels(const TCollection_ExtendedSt return Standard_False; } } - value = Atof(line); + value = (Standard_ShortReal)Atof(line); // Set value if (!((Standard_ShortReal**)((Voxel_DS*)myFloatVoxels)->myData)[i1]) diff --git a/src/VrmlData/VrmlData_ShapeConvert.cxx b/src/VrmlData/VrmlData_ShapeConvert.cxx index 410d393b9c..68f02b2dc4 100755 --- a/src/VrmlData/VrmlData_ShapeConvert.cxx +++ b/src/VrmlData/VrmlData_ShapeConvert.cxx @@ -467,9 +467,9 @@ Handle_VrmlData_Geometry VrmlData_ShapeConvert::triToIndexedFaceSet arrVec[i] = aNormal.XYZ(); Standard_Integer j = i * 3; - Normals->SetValue(j + 1, aNormal.X()); - Normals->SetValue(j + 2, aNormal.Y()); - Normals->SetValue(j + 3, aNormal.Z()); + Normals->SetValue(j + 1, (Standard_ShortReal)aNormal.X()); + Normals->SetValue(j + 2, (Standard_ShortReal)aNormal.Y()); + Normals->SetValue(j + 3, (Standard_ShortReal)aNormal.Z()); } diff --git a/src/XmlMXCAFDoc/XmlMXCAFDoc_MaterialDriver.cxx b/src/XmlMXCAFDoc/XmlMXCAFDoc_MaterialDriver.cxx index 85f50b9594..69f149e085 100755 --- a/src/XmlMXCAFDoc/XmlMXCAFDoc_MaterialDriver.cxx +++ b/src/XmlMXCAFDoc/XmlMXCAFDoc_MaterialDriver.cxx @@ -114,7 +114,8 @@ void XmlMXCAFDoc_MaterialDriver::Paste (const Handle(TDF_Attribute)& theSource, if ( !anAtt->GetDensValType().IsNull() ) aDensTypeStr = anAtt->GetDensValType()->String().ToCString(); - XmlObjMgt::SetStringValue (theTarget, anAtt->GetDensity()); + TCollection_AsciiString aDensityStr (anAtt->GetDensity()); + XmlObjMgt::SetStringValue (theTarget, aDensityStr.ToCString()); theTarget.Element().setAttribute(::NameIndexString(), aNameString); theTarget.Element().setAttribute(::DescrIndexString(),aDescrString); theTarget.Element().setAttribute(::DensNameIndexString(),aDensNameStr);