From d02633e9b51c718dd662e84d1aa54dbc71a49689 Mon Sep 17 00:00:00 2001
From: Laurent Van Migroet <l.vanmiegroet@ulg.ac.be>
Date: Mon, 31 May 2010 09:42:30 +0000
Subject: [PATCH] Fix Bug compile on msvc + remove some warning Change float to
 double in mpeg_encode/rgbtoycc.cpp ok ?

---
 Numeric/Numeric.cpp              | 21 +++++++++++----------
 Solver/function.cpp              | 10 +++++-----
 Solver/function.h                |  4 ++--
 contrib/mpeg_encode/rgbtoycc.cpp | 12 ++++++------
 4 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/Numeric/Numeric.cpp b/Numeric/Numeric.cpp
index f636204b39..d38bd96e37 100644
--- a/Numeric/Numeric.cpp
+++ b/Numeric/Numeric.cpp
@@ -825,19 +825,19 @@ void signedDistancesPointsTriangle(std::vector<double>&distances,
   SVector3 t3 = p3 - p2;
   SVector3 n = crossprod(t1, t2);
   n.normalize();
-
+	
   double mat[3][3] = {{t1.x(), t2.x(), -n.x()},
                       {t1.y(), t2.y(), -n.y()},
                       {t1.z(), t2.z(), -n.z()}};
   double inv[3][3];
   double det = inv3x3(mat, inv);
-  
+  const unsigned pts_size=pts.size();
   distances.clear();
-  distances.resize(pts.size());
+  distances.resize(pts_size);
   closePts.clear();
-  closePts.resize(pts.size());
+  closePts.resize(pts_size);
 
-  for (unsigned int i = 0; i < pts.size(); i++)
+  for (unsigned int i = 0; i < pts_size; ++i)
     distances[i] = 1.e22;
 
   if(det == 0.0) return;
@@ -847,7 +847,7 @@ void signedDistancesPointsTriangle(std::vector<double>&distances,
   const double n2t3 = dot(t3, t3);
 
   double u, v, d;
-  for (unsigned int i = 0; i < pts.size();i++){
+  for (unsigned int i = 0; i < pts_size;++i){
     const SPoint3 &p = pts[i];
     SVector3 pp1 = p - p1;
     u = (inv[0][0] * pp1.x() + inv[0][1] * pp1.y() + inv[0][2] * pp1.z());
@@ -909,14 +909,15 @@ void signedDistancesPointsLine (std::vector<double>&distances,
 
   SVector3 t1 = p2 - p1;
   const double n2t1 = dot(t1, t1);
-  
+
+  const unsigned pts_size=pts.size();
   distances.clear();
-  distances.resize(pts.size());
+  distances.resize(pts_size);
   closePts.clear();
-  closePts.resize(pts.size());
+  closePts.resize(pts_size);
 
   double d;
-  for (unsigned int i = 0; i < pts.size();i++){
+  for (unsigned int i = 0; i <pts_size;++i){
     const SPoint3 &p = pts[i];
     SVector3 pp1 = p - p1;
     const double t12 = dot(pp1, t1) / n2t1;
diff --git a/Solver/function.cpp b/Solver/function.cpp
index 5c603d903f..1f175c6c4e 100644
--- a/Solver/function.cpp
+++ b/Solver/function.cpp
@@ -32,12 +32,12 @@ void function::setArgument(fullMatrix<double> &v, const function *f, int iMap) {
     throw;
   arguments.push_back(argument(v, iMap, f));
   dependencies.insert(dependency(iMap, f));
-  for(std::set<dependency>::iterator it = f->dependencies.begin(); it != f->dependencies.end(); it++) {
+  for(std::set<dependency>::const_iterator it = f->dependencies.begin(); it != f->dependencies.end(); it++) {
     if (it->iMap> 0 && iMap >0)
       Msg::Error("consecutive secondary caches");
     dependencies.insert(dependency(iMap + it->iMap, it->f));
   }
-  for (int i = 0; i < _functionReplaces.size(); i++) {
+  for (double i = 0; i < _functionReplaces.size(); i++) {
     functionReplace &replace = *_functionReplaces[i];
     for (std::set<dependency>::iterator it = replace._fromParent.begin(); it != replace._fromParent.end(); it++) {
       if (it->iMap> 0 && iMap >0)
@@ -80,7 +80,7 @@ dataCacheDouble &dataCacheMap::get(const function *f, dataCacheDouble *caller) {
   // can I use the cache of my parent ?
   if(_parent && r==NULL) {
     bool okFromParent = true;
-    for (std::set<function::dependency>::iterator it = f->dependencies.begin(); it != f->dependencies.end(); it++) {
+    for (std::set<function::dependency>::const_iterator it = f->dependencies.begin(); it != f->dependencies.end(); it++) {
       if (it->iMap > _parent->_secondaryCaches.size())
         okFromParent=false;
       dataCacheMap *m = getSecondaryCache(it->iMap);
@@ -152,9 +152,9 @@ void functionReplace::replace(fullMatrix<double> &v, const function *f, int iMap
 
 void functionReplace::get(fullMatrix<double> &v, const function *f, int iMap) {
   bool allDepFromParent = true;
-  for (std::set<function::dependency>::iterator itDep = f->dependencies.begin(); itDep != f->dependencies.end(); itDep++){
+  for (std::set<function::dependency>::const_iterator itDep = f->dependencies.begin(); itDep != f->dependencies.end(); itDep++){
     bool depFromParent = (_replaced.count(*itDep)==0);
-    for (std::set<function::dependency>::iterator itDep2 = itDep->f->dependencies.begin(); itDep2 != itDep->f->dependencies.end() && depFromParent; itDep2++)
+    for (std::set<function::dependency>::const_iterator itDep2 = itDep->f->dependencies.begin(); itDep2 != itDep->f->dependencies.end() && depFromParent; itDep2++)
       depFromParent &= (_replaced.count(*itDep2)==0);
     if(depFromParent)
       _master->dependencies.insert(*itDep);
diff --git a/Solver/function.h b/Solver/function.h
index 09d433ef4a..b341fcce31 100644
--- a/Solver/function.h
+++ b/Solver/function.h
@@ -16,7 +16,7 @@ class dataCacheDouble;
 
 class functionConstant;
 class functionReplace;
-class functionReplaceCache;
+struct functionReplaceCache;
 
 // An abstract interface to functions 
 // more explanation at the head of this file
@@ -26,7 +26,7 @@ class function {
   bool _invalidatedOnElement;
   std::vector<functionReplace*> _functionReplaces;
   class dependency {
-    public : int iMap; const function *f;
+    public : unsigned iMap; const function *f;
     dependency(int iMap_, const function *f_){iMap = iMap_; f = f_; }
     bool operator < (const dependency &d) const {
       return (d.iMap <iMap || d.f < f);
diff --git a/contrib/mpeg_encode/rgbtoycc.cpp b/contrib/mpeg_encode/rgbtoycc.cpp
index c6a9829085..54c59a1cab 100644
--- a/contrib/mpeg_encode/rgbtoycc.cpp
+++ b/contrib/mpeg_encode/rgbtoycc.cpp
@@ -89,9 +89,9 @@ PNMtoYUV(MpegFrame *frame)
     register xel *src0, *src1;
     register int ydivisor, cdivisor;
     static boolean  first = TRUE;
-    static float  mult299[1024], mult587[1024], mult114[1024];
-    static float  mult16874[1024], mult33126[1024], mult5[1024];
-    static float mult41869[1024], mult08131[1024];
+    static double  mult299[1024], mult587[1024], mult114[1024];
+    static double  mult16874[1024], mult33126[1024], mult5[1024];
+    static double mult41869[1024], mult08131[1024];
 
     if ( first ) {
         register int index;
@@ -256,9 +256,9 @@ PPMtoYUV(MpegFrame *frame)
     register uint8 *src0, *src1;
     register int cdivisor;
     static boolean  first = TRUE;
-    static float  mult299[1024], mult587[1024], mult114[1024];
-    static float  mult16874[1024], mult33126[1024], mult5[1024];
-    static float mult41869[1024], mult08131[1024];
+    static double  mult299[1024], mult587[1024], mult114[1024];
+    static double  mult16874[1024], mult33126[1024], mult5[1024];
+    static double mult41869[1024], mult08131[1024];
 
     if ( first ) {
         register int index;
-- 
GitLab