From 41cfdb51481f6b969ef6d28d974d5f627e6966b0 Mon Sep 17 00:00:00 2001 From: Laurent Van Migroet <l.vanmiegroet@ulg.ac.be> Date: Sat, 17 Dec 2011 12:42:31 +0000 Subject: [PATCH] Fix for MSVC and warning remove --- Common/ListUtils.cpp | 9 ++++++- Common/avl.cpp | 9 ++++++- Geo/Curvature.cpp | 42 ++++++++++++++++----------------- Geo/GModel.cpp | 8 +++---- Geo/MHexahedron.cpp | 2 +- Numeric/BergotBasis.cpp | 27 +++++++++++---------- Numeric/jacobiPolynomials.cpp | 4 ++-- Numeric/legendrePolynomials.cpp | 4 ++-- Plugin/AnalyseCurvedMesh.cpp | 1 + 9 files changed, 61 insertions(+), 45 deletions(-) diff --git a/Common/ListUtils.cpp b/Common/ListUtils.cpp index 050ac635f3..7284a29cd7 100644 --- a/Common/ListUtils.cpp +++ b/Common/ListUtils.cpp @@ -12,7 +12,14 @@ #include <string.h> #include <errno.h> #include <sys/types.h> -#include <stdint.h> +#ifdef _MSC_VER +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include <stdint.h> +#endif #include "MallocUtils.h" #include "ListUtils.h" #include "TreeUtils.h" diff --git a/Common/avl.cpp b/Common/avl.cpp index d49893c671..618f7fc620 100644 --- a/Common/avl.cpp +++ b/Common/avl.cpp @@ -26,7 +26,14 @@ // Modified for Gmsh (C++ and 64 bit compatibility) #include <stdio.h> -#include <stdint.h> +#ifdef _MSC_VER +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include <stdint.h> +#endif #include "avl.h" #include "MallocUtils.h" diff --git a/Geo/Curvature.cpp b/Geo/Curvature.cpp index 20cae44ffb..358daf5f2d 100644 --- a/Geo/Curvature.cpp +++ b/Geo/Curvature.cpp @@ -64,7 +64,7 @@ void Curvature::retrieveCompounds() std::vector<GEntity*> entities; _model->getEntities(entities); - for(int ie = 0; ie < entities.size(); ++ie) { + for(unsigned ie = 0; ie < entities.size(); ++ie) { if(entities[ie]->geomType() == GEntity::CompoundSurface) { GFaceCompound* compound = dynamic_cast<GFaceCompound*>(entities[ie]); @@ -87,9 +87,9 @@ void Curvature::retrieveCompounds() // initialization of the map and renumbering of the selected entities void Curvature::initializeMap() { - for (int i = 0; i< _ptFinalEntityList.size(); ++i){ + for (unsigned i = 0; i< _ptFinalEntityList.size(); ++i){ GFace* face = _ptFinalEntityList[i]; - for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ + for (unsigned iElem = 0; iElem < face->getNumMeshElements(); iElem++){ MElement *e = face->getMeshElement(iElem); const int E = e->getNum(); _ElementToInt[E] = 1; @@ -132,7 +132,7 @@ void Curvature::computeVertexNormals() _VertexArea.resize(_ElementToInt.size() ); _VertexNormal.resize(_VertexToInt.size()); - for (int i = 0; i < _ptFinalEntityList.size(); ++i){ + for (unsigned i = 0; i < _ptFinalEntityList.size(); ++i){ // face is a pointer to one surface of the group "FinalEntityList" GFace* face = _ptFinalEntityList[i]; @@ -191,12 +191,12 @@ void Curvature::curvatureTensor() _CurveTensor.resize(_VertexToInt.size()); - for (int i = 0; i< _ptFinalEntityList.size(); ++i){ + for (unsigned i = 0; i< _ptFinalEntityList.size(); ++i){ // face is a pointer to one surface of the group "FinalEntityList" GFace* face = _ptFinalEntityList[i]; //Loop over the element all the element of the "myTag"-surface - for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ + for (unsigned iElem = 0; iElem < face->getNumMeshElements(); iElem++){ MElement *e = face->getMeshElement(iElem); //Pointer to one element const int E = _ElementToInt[e->getNum()]; //The NEW tag of the corresponding element @@ -344,12 +344,12 @@ void Curvature::computeRusinkiewiczNormals() _TriangleArea.resize(_ElementToInt.size() ); _VertexNormal.resize(_VertexToInt.size()); - for (int i = 0; i< _ptFinalEntityList.size(); ++i){ + for (unsigned i = 0; i< _ptFinalEntityList.size(); ++i){ // face is a pointer to one surface of the group "FinalEntityList" GFace* face = _ptFinalEntityList[i]; //Loop over the element all the element of the "myTag"-surface - for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ + for (unsigned iElem = 0; iElem < face->getNumMeshElements(); iElem++){ // Pointer to one element MElement *e = face->getMeshElement(iElem); const int E = _ElementToInt[e->getNum()]; @@ -400,13 +400,13 @@ void Curvature::computePointareas() _pointareas.resize(_VertexToInt.size()); _cornerareas.resize(_ElementToInt.size()); - for (int i = 0; i< _ptFinalEntityList.size(); ++i) + for (unsigned i = 0; i< _ptFinalEntityList.size(); ++i) { //face is a pointer to one surface of the group "FinalEntityList" GFace* face = _ptFinalEntityList[i]; //Loop over the element all the element of the "myTag"-surface - for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ + for (unsigned iElem = 0; iElem < face->getNumMeshElements(); iElem++){ MElement *E = face->getMeshElement(iElem); //Pointer to one element // The NEW tag of the corresponding element const int EIdx = _ElementToInt[E->getNum()]; @@ -616,7 +616,7 @@ void Curvature::computeCurvature_Rusinkiewicz(int isMax) GFace* face = _ptFinalEntityList[i]; //Loop over the element all the element of the "myTag"-surface - for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ + for (unsigned iElem = 0; iElem < face->getNumMeshElements(); iElem++){ MElement *E = face->getMeshElement(iElem); // Pointer to one element MVertex* A = E->getVertex(0); // Pointers to vertices of triangle @@ -634,7 +634,7 @@ void Curvature::computeCurvature_Rusinkiewicz(int isMax) } } - for (int ivertex = 0; ivertex < _VertexToInt.size(); ++ivertex){ + for (unsigned ivertex = 0; ivertex < _VertexToInt.size(); ++ivertex){ _pdir1[ivertex] = crossprod(_pdir1[ivertex], _VertexNormal[ivertex]); _pdir1[ivertex].normalize(); _pdir2[ivertex] = crossprod(_VertexNormal[ivertex], _pdir1[ivertex]); @@ -768,9 +768,9 @@ void Curvature::computeCurvature_RBF() // fill set of MVertex std::set<MVertex*> allNodes; - for (int i = 0; i< _ptFinalEntityList.size(); ++i) { + for (unsigned i = 0; i< _ptFinalEntityList.size(); ++i) { GFaceCompound* face = (GFaceCompound*)_ptFinalEntityList[i]; - for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++) { + for (unsigned iElem = 0; iElem < face->getNumMeshElements(); iElem++) { MElement *e = face->getMeshElement(iElem); for(int j = 0; j < e->getNumVertices(); j++){ allNodes.insert(e->getVertex(j)); @@ -974,10 +974,10 @@ void Curvature::writeToPosFile( const std::string & filename) int idxelem = 0; - for (int i = 0; i< _ptFinalEntityList.size(); ++i) { + for (unsigned i = 0; i< _ptFinalEntityList.size(); ++i) { GFace* face = _ptFinalEntityList[i]; - for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ + for (unsigned iElem = 0; iElem < face->getNumMeshElements(); iElem++){ MElement *e = face->getMeshElement(iElem); const int E = _ElementToInt[e->getNum()]; //std::cout << "We are now looking at element Nr: " << E << std::endl; @@ -1047,7 +1047,7 @@ void Curvature::writeToVtkFile( const std::string & filename) std::vector<VtkPoint> coord; coord.resize(npoints); - for (int i = 0; i< _ptFinalEntityList.size(); ++i){ + for (unsigned i = 0; i< _ptFinalEntityList.size(); ++i){ GFace* face = _ptFinalEntityList[i]; for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ @@ -1092,7 +1092,7 @@ void Curvature::writeToVtkFile( const std::string & filename) outfile << std::endl << "CELLS " << _ElementToInt.size() << " " << 4*_ElementToInt.size() << std::endl; - for (int i = 0; i< _ptFinalEntityList.size(); ++i){ + for (unsigned i = 0; i< _ptFinalEntityList.size(); ++i){ GFace* face = _ptFinalEntityList[i]; for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ @@ -1139,12 +1139,12 @@ void Curvature::writeDirectionsToPosFile( const std::string & filename) outfile.open(filename.c_str()); outfile << "View \"Curvature_DirMax \"{" << std::endl; - for (int i = 0; i< _ptFinalEntityList.size(); ++i){ + for (unsigned i = 0; i< _ptFinalEntityList.size(); ++i){ //face is a pointer to one surface of the group "FinalEntityList" GFace* face = _ptFinalEntityList[i]; //Loop over the element all the element of the "myTag"-surface - for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ + for (unsigned iElem = 0; iElem < face->getNumMeshElements(); iElem++){ MElement *e = face->getMeshElement(iElem); //Pointer to one element const int E = _ElementToInt[e->getNum()]; //The NEW tag of the corresponding element @@ -1183,7 +1183,7 @@ void Curvature::writeDirectionsToPosFile( const std::string & filename) for (int i = 0; i< _ptFinalEntityList.size(); ++i){ GFace* face = _ptFinalEntityList[i]; - for (int iElem = 0; iElem < face->getNumMeshElements(); iElem++){ + for (unsigned iElem = 0; iElem < face->getNumMeshElements(); iElem++){ MElement *e = face->getMeshElement(iElem); //Pointer to one element const int E = _ElementToInt[e->getNum()]; //The NEW tag of the corresponding element diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 1e9e2b3095..9c4e4f92a2 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -572,7 +572,7 @@ int GModel::adaptMesh(int technique, simpleFunction<double> *f, std::vector<doub if (getDim() == 2){ for (fiter fit = firstFace(); fit != lastFace(); ++fit){ if ((*fit)->quadrangles.size())return -1; - for (int i=0;i<(*fit)->triangles.size();i++){ + for (unsigned i=0;i<(*fit)->triangles.size();i++){ elements.push_back((*fit)->triangles[i]); } } @@ -580,7 +580,7 @@ int GModel::adaptMesh(int technique, simpleFunction<double> *f, std::vector<doub else if (getDim() == 3){ for (riter rit = firstRegion(); rit != lastRegion(); ++rit){ if ((*rit)->hexahedra.size())return -1; - for (int i=0;i<(*rit)->tetrahedra.size();i++){ + for (unsigned i=0;i<(*rit)->tetrahedra.size();i++){ elements.push_back((*rit)->tetrahedra[i]); } } @@ -1741,7 +1741,7 @@ void GModel::createTopologyFromFaces(std::vector<discreteFace*> &discFaces, int //EMI RBF fix if (ignoreHoles && nbBounds > 0){ int index = 0; - int boundSize = 0; + unsigned boundSize = 0; for (int ib = 0; ib < nbBounds; ib++){ if (boundaries[ib].size() > boundSize){ boundSize = boundaries[ib].size() ; @@ -1754,7 +1754,7 @@ void GModel::createTopologyFromFaces(std::vector<discreteFace*> &discFaces, int } // create new discrete edges - for (int ib = 0; ib < boundaries.size(); ib++){ + for (unsigned ib = 0; ib < boundaries.size(); ib++){ int numE = getMaxElementaryNumber(1) + 1; discreteEdge *e = new discreteEdge(this, numE, 0, 0); add(e); diff --git a/Geo/MHexahedron.cpp b/Geo/MHexahedron.cpp index 66cb52a2ec..4f63c25526 100644 --- a/Geo/MHexahedron.cpp +++ b/Geo/MHexahedron.cpp @@ -173,7 +173,7 @@ static void _myGetFaceRep(MHexahedron *hex, int num, double *x, double *y, doubl int iVertex4 = hex->faces_hexa(iFace,3); SPoint3 pnt1, pnt2, pnt3; - double J1[3][3], J2[3][3], J3[3][3]; + // double J1[3][3], J2[3][3], J3[3][3]; /* 0 diff --git a/Numeric/BergotBasis.cpp b/Numeric/BergotBasis.cpp index b0668cc617..636c6e500b 100644 --- a/Numeric/BergotBasis.cpp +++ b/Numeric/BergotBasis.cpp @@ -47,12 +47,13 @@ int BergotBasis::size() const { void BergotBasis::f(double u, double v, double w, double* val) const { double uhat = (w == 1.) ? 1 : u/(1.-w); - double uFcts[order+1]; - legendre->f(uhat,uFcts); + + std::vector<double> uFcts(order+1); + legendre->f(uhat,&(uFcts[0])); double vhat = (w == 1.) ? 1 : v/(1.-w); - double vFcts[order+1]; - legendre->f(vhat,vFcts); + std::vector<double> vFcts(order+1); + legendre->f(vhat,&(vFcts[0])); double what = 2.*w - 1.; std::map<int,double* > wFcts; @@ -88,17 +89,17 @@ void BergotBasis::f(double u, double v, double w, double* val) const { } void BergotBasis::df(double u, double v, double w, double grads[][3]) const { - double uFcts[order+1]; - legendre->f(u,uFcts); - - double uGrads[order+1]; - legendre->df(u,uGrads); + std::vector<double> uFcts(order+1); + legendre->f(u,&(uFcts[0])); + + std::vector<double> uGrads(order+1); + legendre->df(u,&(uGrads[0])); - double vFcts[order+1]; - legendre->f(v,vFcts); + std::vector<double> vFcts(order+1); + legendre->f(v,&(vFcts[0])); - double vGrads[order+1]; - legendre->df(v,vGrads); + std::vector<double> vGrads(order+1); + legendre->df(v,&(vGrads[0])); std::map<int,double* > wFcts; diff --git a/Numeric/jacobiPolynomials.cpp b/Numeric/jacobiPolynomials.cpp index b3184eaa78..911a1d0ed3 100644 --- a/Numeric/jacobiPolynomials.cpp +++ b/Numeric/jacobiPolynomials.cpp @@ -35,8 +35,8 @@ void JacobiPolynomials::f(double u, double *val) const { void JacobiPolynomials::df(double u, double *val) const { - double tmp[n+1]; - f(u,tmp); + std::vector<double> tmp(n+1); + f(u,&(tmp[0])); val[0] = 0; if (n>=1) val[1] = 0.5*(alphaPlusBeta + 2.); diff --git a/Numeric/legendrePolynomials.cpp b/Numeric/legendrePolynomials.cpp index 2b229ec692..397c59e0f5 100644 --- a/Numeric/legendrePolynomials.cpp +++ b/Numeric/legendrePolynomials.cpp @@ -19,8 +19,8 @@ void LegendrePolynomials::f(double u, double *val) const { } void LegendrePolynomials::df(double u, double *val) const { - double tmp[n+1]; - f(u,tmp); + std::vector<double> tmp(n+1); + f(u,&(tmp[0])); val[0] = 0; double g2 = (1.-u*u); diff --git a/Plugin/AnalyseCurvedMesh.cpp b/Plugin/AnalyseCurvedMesh.cpp index 571fd987b9..c3c20a85db 100644 --- a/Plugin/AnalyseCurvedMesh.cpp +++ b/Plugin/AnalyseCurvedMesh.cpp @@ -317,6 +317,7 @@ PView *GMSH_AnalyseCurvedMeshPlugin::execute(PView *v) new PView("Jmin", "ElementData", _m, data); Msg::Info("Done computation J_min, J_max (%fs)", Cpu()-t); } + return 0; } void GMSH_AnalyseCurvedMeshPlugin::checkValidity(int toDo) -- GitLab