]> OCCT Git - occt-copy.git/commitdiff
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 4fbec48f896e2ae6c1a0f8d4c0c3ebb8b751b3e6..576214e434afe8e2a2a403765ea334da655c3442 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 dbeada263628e9ca6e5726d15cf3a89ab8417f2a..4eb0476c9d5ff7b13f708d38e167705c153dc805 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 8a18ac3b28a35514c270e6557d3dd0e9a3991584..a3b44cc2de10e5b2bf7f3a56eaa4633485b1eb83 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 fc0f179482625d251e3cf8a5421d8700eaa20485..e9457e20351b4ad8757832a43a15473e1d3cc5ad 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 68a7c362348242735ac58740589c4e1cd6522831..4b87723c5cb7917bde8ae59dc194353a7b1b8b59 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 844cfb9cb92ab7b058f7d5715631b00dae88c31e..eb407aab3dd184d0337c1db7a14eaec5938a54bc 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 b3e4732a5801a1b4486b97788bcbd6b3a50fd6f1..edb6f7d5051a36a48b37dbb524aad15cb01b3d97 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 8651e71942055049775b99763119db47f82179aa..0a3f178f0b6ebc921f4fb35e259515d8e1bc037f 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 3b128bf7ad68620898276977f0dc72b0d8b25926..d69ede116e01b0601ff0261c6feed5fda8e3f0fd 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 8e7334806cf387a4d659f2624e9c191ca13628b9..2e2b5f66e55673e5b0f68e7f96c5a1ad9102e15a 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 588ed32cf77bdbd6f69f8a42d959f71188e35b1c..a05ec8295a4d12b996e951766e0775f9057f61ac 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 21bfab64bbbf78c11e848e619e971b3fb031037b..9d51d9b7bdfde1dbac548b3af7dbc877a66f60d3 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 ff6db0bfc636695cf67b86625ab536ed0a5d38a6..f4066e4f7a11540ce32fc979995c58d299b26a82 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 f7e3c18cf013f422379bd0c6bf07b1d233a6d50d..6b9030e17ad950c0163f1f35f55e38cb2d017b79 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 b72ac6545d8e50b4341862101d857aeeb349996c..7ec5b7636fc603e44f92ffd010bdf2ad7b97114c 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 8824f4b3fe524259fd981ced498c9d0eea0a82d0..ac235a499f1c9538f628a98c06013925da427576 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 22ffec8cf4852dc6bc8d82956b791a4f9b587486..b70ff5a80bd8714da714955a456bff272b268155 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;