0024087: Eliminate compiler warning C4244 in MSVC++ with warning level 4
authoromy <omy@opencascade.com>
Mon, 29 Jul 2013 06:27:34 +0000 (10:27 +0400)
committeromy <omy@opencascade.com>
Thu, 1 Aug 2013 08:38:21 +0000 (12:38 +0400)
Most of the compiler warnings C4244 have been eliminated.

17 files changed:
src/AdvApp2Var/AdvApp2Var_SysBase.cxx
src/BinTools/BinTools_LocationSet.cxx
src/DDataStd/DDataStd_BasicCommands.cxx
src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx
src/IntPatch/IntPatch_PrmPrmIntersection.cxx
src/Interface/Interface_InterfaceModel.cxx
src/LDOM/LDOM_OSStream.cxx
src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx
src/OpenGl/OpenGl_GraduatedTrihedron.hxx
src/OpenGl/OpenGl_View_2.cxx
src/OpenGl/OpenGl_Window.cxx
src/Resource/Resource_ConvertUnicode.c
src/StepFile/recfile.pc
src/ViewerTest/ViewerTest_ViewerCommands.cxx
src/Voxel/Voxel_BooleanOperation.cxx
src/Voxel/Voxel_Reader.cxx
src/VrmlData/VrmlData_ShapeConvert.cxx

index 4fbec48..576214e 100755 (executable)
@@ -2999,11 +2999,11 @@ int AdvApp2Var_SysBase::mcrrqst_(integer *iunit,
 /* RANGING OF PARAMETERS IN MCRGENE */
 
     mcrgene_.icore[mcrgene_.ncore].prot = mcrgene_.lprot;
-    mcrgene_.icore[mcrgene_.ncore].unit = *iunit;
+    mcrgene_.icore[mcrgene_.ncore].unit = (unsigned char)(*iunit);
     mcrgene_.icore[mcrgene_.ncore].reqsize = *isize;
     mcrgene_.icore[mcrgene_.ncore].loc = loc;
     mcrgene_.icore[mcrgene_.ncore].offset = *iofset;
-    mcrgene_.icore[mcrgene_.ncore].alloctype = ksys;
+    mcrgene_.icore[mcrgene_.ncore].alloctype = (unsigned char)ksys;
     mcrgene_.icore[mcrgene_.ncore].size = ibyte;
     mcrgene_.icore[mcrgene_.ncore].addr = iaddr;
     mcrgene_.icore[mcrgene_.ncore].userzone = mcrgene_.ncore;
index dbeada2..4eb0476 100755 (executable)
@@ -238,7 +238,7 @@ void  BinTools_LocationSet::Read(Standard_IStream& IS)
     OCC_CATCH_SIGNALS
     for (i = 1; i <= nbLoc; i++) { 
       
-      const Standard_Byte aTypLoc = IS.get();
+      const Standard_Byte aTypLoc = (Standard_Byte)IS.get();
       if (aTypLoc == 1) {
        IS >> T;
        L = T;
index 8a18ac3..a3b44cc 100755 (executable)
@@ -1157,13 +1157,13 @@ static Standard_Integer DDataStd_SetByteArray (Draw_Interpretor& di,
     Handle(TDataStd_ByteArray) A = TDataStd_ByteArray::Set(label, From, To, isDelta);
     
     j = 6;
-    for(Standard_Integer i = From; i<=To; i++) {
+    for(Standard_Integer i = From; i<=To; ++i) {
       Standard_Integer ival = Draw::Atoi(arg[j]);
-      if(ival > 255) {
-       cout << "Bad value = " << ival<< endl;
-       return 1;
+      if(ival < 0 && 255 < ival) {
+        cout << "Bad value = " << ival<< endl;
+        return 1;
       }
-      A->SetValue(i,  (unsigned)ival); 
+      A->SetValue(i, (Standard_Byte)ival); 
       j++;
     }
     return 0; 
@@ -1393,7 +1393,7 @@ static Standard_Integer DDataStd_ChangeByteArray (Draw_Interpretor& di,
       }
     Standard_Integer low = A->Lower(), up = A->Upper();
     if(low <= indx && indx <= up)
-      A->SetValue(indx, (unsigned)ival);
+      A->SetValue(indx, (Standard_Byte)ival);
     else {
       Handle(TColStd_HArray1OfByte) Arr = A->InternalArray();
       Handle(TColStd_HArray1OfByte) arr;
@@ -1405,7 +1405,7 @@ static Standard_Integer DDataStd_ChangeByteArray (Draw_Interpretor& di,
          arr->SetValue(i, Arr->Value(i));
        for(i=Arr->Upper()+1; i<= up; i++) {
          if(i == up)
-           arr->SetValue(i, (unsigned)ival);
+           arr->SetValue(i, (Standard_Byte)ival);
          else
            arr->SetValue(i, 0);
        }
@@ -1414,7 +1414,7 @@ static Standard_Integer DDataStd_ChangeByteArray (Draw_Interpretor& di,
        arr = new TColStd_HArray1OfByte(low, up);
        for(i=low; i< up; i++)
          arr->SetValue(i, Arr->Value(i));
-       arr->SetValue(up, (unsigned)ival);
+       arr->SetValue(up, (Standard_Byte)ival);
       }
       A->ChangeArray(arr);
     }
index fc0f179..e9457e2 100644 (file)
@@ -153,15 +153,11 @@ inline void Graphic3d_ArrayOfPrimitives::SetVertexColor(const Standard_Integer a
   }
 
   if( myPrimitiveArray->vcolours ) {
-    unsigned char red   = (unsigned int)(R * 255.);
-    unsigned char green = (unsigned int)(G * 255.);
-    unsigned char blue  = (unsigned int)(B * 255.);
-    unsigned char alpha = 0;
-    Standard_Integer outColor ;
-    outColor = red;
-    outColor += green << 8;
-    outColor += blue  << 16;
-    outColor += alpha << 24;
+    unsigned int red   = (unsigned int)(R * 255.);
+    unsigned int green = (unsigned int)(G * 255.);
+    unsigned int blue  = (unsigned int)(B * 255.);
+    unsigned int alpha = 0;
+    Standard_Integer outColor = alpha << 24 | blue << 16 | green << 8 | red;
     SetVertexColor( anIndex, outColor );
   }
   myPrimitiveArray->num_vertexs = Max(anIndex,myPrimitiveArray->num_vertexs);
index 68a7c36..4b87723 100755 (executable)
@@ -2914,7 +2914,7 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
     for(j=0;j<SV1;j++) { 
       aIPD.xIP1(i, j)=-1;
       const gp_Pnt& P=aIPD.xP1(i, j);
-      aIPD.xP1DS2(i, j) = CodeReject(x20,y20,z20,x21,y21,z21,P.X(),P.Y(),P.Z());
+      aIPD.xP1DS2(i, j) = (char)CodeReject(x20,y20,z20,x21,y21,z21,P.X(),P.Y(),P.Z());
       int ix = (int)((P.X()-x0  + dx2 )/dx);
       if(DansGrille(ix)) { 
        int iy = (int)((P.Y()-y0 + dy2)/dy);
@@ -2932,7 +2932,7 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S
     for(j=0;j<SV2;j++) { 
       aIPD.xIP2(i, j)=-1;
       const gp_Pnt& P=aIPD.xP2(i, j);
-      aIPD.xP2DS1(i, j) = CodeReject(x10,y10,z10,x11,y11,z11,P.X(),P.Y(),P.Z());
+      aIPD.xP2DS1(i, j) = (char)CodeReject(x10,y10,z10,x11,y11,z11,P.X(),P.Y(),P.Z());
       int ix = (int)((P.X()-x0 + dx2)/dx);
       if(DansGrille(ix)) { 
        int iy = (int)((P.Y()-y0 + dy2)/dy);
index 844cfb9..eb407aa 100755 (executable)
@@ -793,7 +793,7 @@ Standard_Boolean Interface_InterfaceModel::SetCategoryNumber
       c->SetValue(i,thecategory->Value(i));
     thecategory = c;
   }
-  Standard_Character cval = (val + 32);
+  Standard_Character cval = (Standard_Character)(val + 32);
   thecategory->SetValue(num,cval);
   return Standard_True;
 }
index b3e4732..edb6f7d 100755 (executable)
@@ -104,7 +104,7 @@ Standard_CString LDOM_SBuffer::str () const
 //=======================================================================
 int LDOM_SBuffer::overflow(int c)
 {
-  char cc = c;
+  char cc = (char)c;
   return xsputn(&cc,1);
 }
 
index 8651e71..0a3f178 100755 (executable)
@@ -728,9 +728,9 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const
   {
     const Quantity_Color& aSrcColor = myTextureColorMap.Value (Standard_Integer(aCol) + 1);
     Image_ColorRGBA& aColor = aData.ChangeValue (0, aCol);
-    aColor.r() = int(255.0 * aSrcColor.Red());
-    aColor.g() = int(255.0 * aSrcColor.Green());
-    aColor.b() = int(255.0 * aSrcColor.Blue());
+    aColor.r() = Standard_Byte(255.0 * aSrcColor.Red());
+    aColor.g() = Standard_Byte(255.0 * aSrcColor.Green());
+    aColor.b() = Standard_Byte(255.0 * aSrcColor.Blue());
     aColor.a() = 0xFF;
   }
 
@@ -738,9 +738,9 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const
   const Quantity_Color& aLastColorSrc = myTextureColorMap.Last();
   const Image_ColorRGBA aLastColor =
   {{
-    int(255.0 * aLastColorSrc.Red()),
-    int(255.0 * aLastColorSrc.Green()),
-    int(255.0 * aLastColorSrc.Blue()),
+    Standard_Byte(255.0 * aLastColorSrc.Red()),
+    Standard_Byte(255.0 * aLastColorSrc.Green()),
+    Standard_Byte(255.0 * aLastColorSrc.Blue()),
     0xFF
   }};
 
@@ -752,9 +752,9 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const
 
   const Image_ColorRGBA anInvalidColor =
   {{
-    int(255.0 * myInvalidColor.Red()),
-    int(255.0 * myInvalidColor.Green()),
-    int(255.0 * myInvalidColor.Blue()),
+    Standard_Byte(255.0 * myInvalidColor.Red()),
+    Standard_Byte(255.0 * myInvalidColor.Green()),
+    Standard_Byte(255.0 * myInvalidColor.Blue()),
     0xFF
   }};
   for (Standard_Size aCol = 0; aCol < anImage->SizeX(); ++aCol)
index 3b128bf..d69ede1 100644 (file)
@@ -69,7 +69,9 @@ protected:
   unsigned int myNbX, myNbY, myNbZ;
   int myXOffset, myYOffset, myZOffset;
   int myXAxisOffset, myYAxisOffset, myZAxisOffset;
-  unsigned char myDrawXTickmarks, myDrawYTickmarks, myDrawZTickmarks;
+  Standard_Boolean myDrawXTickmarks;
+  Standard_Boolean myDrawYTickmarks;
+  Standard_Boolean myDrawZTickmarks;
   unsigned int myXTickmarkLength, myYTickmarkLength, myZTickmarkLength;
   float myGridColor[3];
   TEL_COLOUR myXColor;
index 8e73348..2e2b5f6 100644 (file)
@@ -1389,9 +1389,9 @@ void OpenGl_View::CreateBackgroundTexture (const Standard_CString  theFilePath,
       {
         aSrcColor = anImageLoaded.PixelColor ((Standard_Integer )aCol, (Standard_Integer )aRow);
         Image_ColorRGB& aColor = aDataNew.ChangeValue (aRow, aCol);
-        aColor.r() = int(255.0 * aSrcColor.Red());
-        aColor.g() = int(255.0 * aSrcColor.Green());
-        aColor.b() = int(255.0 * aSrcColor.Blue());
+        aColor.r() = Standard_Byte(255.0 * aSrcColor.Red());
+        aColor.g() = Standard_Byte(255.0 * aSrcColor.Green());
+        aColor.b() = Standard_Byte(255.0 * aSrcColor.Blue());
       }
     }
     anImageLoaded.Clear();
index 588ed32..a05ec82 100644 (file)
@@ -61,14 +61,14 @@ namespace
     Standard_Size aStencilIter = 0, aColorIter = 0, aDepthIter = 0;
     for (aStencilIter = 0; aStencilIter < sizeof(BUFF_BITS_STENCIL) / sizeof(int); ++aStencilIter)
     {
-      aPixelFrmtTmp.cStencilBits = BUFF_BITS_STENCIL[aStencilIter];
+      aPixelFrmtTmp.cStencilBits = (BYTE)(BUFF_BITS_STENCIL[aStencilIter]);
       for (aDepthIter = 0; aDepthIter < sizeof(BUFF_BITS_DEPTH) / sizeof(int); ++aDepthIter)
       {
-        aPixelFrmtTmp.cDepthBits = BUFF_BITS_DEPTH[aDepthIter];
+        aPixelFrmtTmp.cDepthBits = (BYTE)(BUFF_BITS_DEPTH[aDepthIter]);
         aPixelFrmtIdGood = 0;
         for (aColorIter = 0; aColorIter < sizeof(BUFF_BITS_COLOR) / sizeof(int); ++aColorIter)
         {
-          aPixelFrmtTmp.cColorBits = BUFF_BITS_COLOR[aColorIter];
+          aPixelFrmtTmp.cColorBits = (BYTE)(BUFF_BITS_COLOR[aColorIter]);
           aPixelFrmtIdLast = ChoosePixelFormat (theDevCtx, &aPixelFrmtTmp);
           if (aPixelFrmtIdLast == 0)
           {
index 21bfab6..9d51d9b 100755 (executable)
@@ -139,7 +139,7 @@ void Resource_sjis_to_unicode (unsigned int *ph, unsigned int *pl)
     return ;
   }
 
-  sjis = ((*ph) << 8) | (*pl) ;
+  sjis = (char16)(((*ph) << 8) | (*pl)) ;
   uni  = sjisuni [sjis] ;
   *ph = uni >> 8 ;
   *pl = uni & 0xFF ;
@@ -158,7 +158,7 @@ void Resource_unicode_to_sjis (unsigned int *ph, unsigned int *pl)
   if ( *ph == 0 && *pl == 0 )
     return ;
 
-  uni  = ((*ph) << 8) | (*pl) ;
+  uni  = (char16)(((*ph) << 8) | (*pl)) ;
   sjis = unisjis [uni] ;
   *ph = sjis >> 8 ;
   *pl = sjis & 0xFF ;
@@ -213,7 +213,7 @@ void Resource_gb_to_unicode (unsigned int *ph, unsigned int *pl)
   *ph  = (*ph) & 0x7f ;
   *pl  = (*pl) & 0x7f ;
 
-  gb   = ((*ph) << 8) | (*pl) ;
+  gb   = (char16)(((*ph) << 8) | (*pl)) ;
   uni  = gbuni [gb] ;
   *ph  = uni >> 8 ;
   *pl  = uni & 0xFF ;
@@ -232,7 +232,7 @@ void Resource_unicode_to_gb (unsigned int *ph, unsigned int *pl)
   if ( *ph == 0 && *pl == 0 )
     return ;
 
-  uni  = ((*ph) << 8) | (*pl) ;
+  uni  = (char16)(((*ph) << 8) | (*pl));
   gb   = unigb [uni] ;
   if (gb != 0) {
     *ph  = ( gb >> 8   ) | 0x80 ;
index ff6db0b..f4066e4 100755 (executable)
@@ -373,7 +373,7 @@ void rec_deblist()
   default: {
     char bufsub[10];
     if (numsub > 9) sprintf (bufsub,"$%d",numsub) ;
-    else {  bufsub[0] = '$'; bufsub[1] = numsub + 48; bufsub[2] = '\0';  }
+    else {  bufsub[0] = '$'; bufsub[1] = (char)(numsub + 48); bufsub[2] = '\0';  }
     subrec->ident = rec_newtext(bufsub) ;
     }
   }
index f7e3c18..6b9030e 100755 (executable)
@@ -2010,7 +2010,7 @@ static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
 //==============================================================================
 
 
-static int ViewerMainLoop(Standard_Integer argc, const char** argv)
+int ViewerMainLoop(Standard_Integer argc, const char** argv)
 {
   Ppick = (argc > 0)? 1 : 0;
   Pargc = argc;
index b72ac65..7ec5b76 100755 (executable)
@@ -163,7 +163,7 @@ Standard_Boolean Voxel_BooleanOperation::Cut(      Voxel_ColorDS& theVoxels1,
            Standard_Integer value = value1 - value2;
            if (value < 0)
              value = 0;
-           theVoxels1.Set(ix, iy, iz, value);
+           theVoxels1.Set(ix, iy, iz, (Standard_Byte)value);
          }
        }
       }
index 8824f4b..ac235a4 100755 (executable)
@@ -211,7 +211,7 @@ Standard_Boolean Voxel_Reader::ReadBoolAsciiVoxels(const TCollection_ExtendedStr
        ((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1] = 
          (Standard_Byte*) calloc(8/*number of bytes in slice*/, sizeof(Standard_Byte));
       }
-      (((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1])[i2] = value;
+      (((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1])[i2] = (Standard_Byte)value;
     }
   }
 
@@ -288,7 +288,7 @@ Standard_Boolean Voxel_Reader::ReadColorAsciiVoxels(const TCollection_ExtendedSt
        ((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1] = 
          (Standard_Byte*) calloc(32/*number of bytes in slice*/, sizeof(Standard_Byte));
       }
-      (((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1])[i2] = value;
+      (((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1])[i2] = (Standard_Byte)value;
     }
   }
 
@@ -422,7 +422,7 @@ Standard_Boolean Voxel_Reader::ReadBoolBinaryVoxels(const TCollection_ExtendedSt
        ((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1] = 
          (Standard_Byte*) calloc(8/*number of bytes in slice*/, sizeof(Standard_Byte));
       }
-      (((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1])[i2] = value;
+      (((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1])[i2] = (Standard_Byte)value;
     }
   }
 
@@ -477,7 +477,7 @@ Standard_Boolean Voxel_Reader::ReadColorBinaryVoxels(const TCollection_ExtendedS
        ((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1] = 
          (Standard_Byte*) calloc(32/*number of bytes in slice*/, sizeof(Standard_Byte));
       }
-      (((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1])[i2] = value;
+      (((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1])[i2] = (Standard_Byte)value;
     }
   }
 
index 22ffec8..b70ff5a 100755 (executable)
@@ -82,7 +82,7 @@ void VrmlData_ShapeConvert::AddShape (const TopoDS_Shape& theShape,
     char buf[2048], * optr = &buf[0];
     char * eptr = &buf[sizeof(buf)-1];
     for (const char * ptr = theName;; ptr++) {
-      int sym = *ptr;
+      char sym = *ptr;
       if (sym == '\0' || sym == '\n' || sym == '\r') {
         * optr = '\0';
         break;