From dc0e62c0e2600d2d92f15e0f9d8373c2026d9a02 Mon Sep 17 00:00:00 2001 From: emv Date: Fri, 18 Oct 2019 14:35:24 +0300 Subject: [PATCH] Using size_t instead of int (where possible) in INTERP_KERNEL. --- .../Barycentric3DIntersectorP1P1.txx | 4 ++-- src/INTERP_KERNEL/CurveIntersector.txx | 4 ++-- src/INTERP_KERNEL/Geometric2DIntersector.txx | 20 +++++++++---------- src/INTERP_KERNEL/Interpolation2D1D.txx | 2 +- src/INTERP_KERNEL/InterpolationCurve.txx | 2 +- src/INTERP_KERNEL/InterpolationPlanar.txx | 2 +- src/INTERP_KERNEL/InterpolationUtils.hxx | 16 +++++++-------- .../MappedBarycentric3DIntersectorP1P1.txx | 4 ++-- src/INTERP_KERNEL/PlanarIntersector.txx | 4 ++-- .../PointLocator2DIntersector.txx | 4 ++-- .../PointLocator3DIntersectorP0P1.txx | 4 ++-- .../PointLocator3DIntersectorP1P1.txx | 4 ++-- .../TriangulationIntersector.txx | 8 ++++---- .../Test/MEDCouplingBasicsTest0.cxx | 2 +- .../Test/MEDCouplingBasicsTest1.cxx | 8 ++++---- .../Test/MEDCouplingBasicsTest2.cxx | 12 +++++------ .../Test/MEDCouplingBasicsTest4.cxx | 2 +- 17 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx b/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx index 6b0bdf5cf..f2af80b6f 100644 --- a/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx @@ -56,9 +56,9 @@ namespace INTERP_KERNEL std::vector CoordsT; const ConnType *startOfCellNodeConnT=Intersector3DP1P1::getStartConnOfTargetCell(targetCell); Intersector3DP1P1::getRealTargetCoordinates(OTT::indFC(targetCell),CoordsT); - int nbOfNodesT=CoordsT.size()/SPACEDIM; + std::size_t nbOfNodesT=CoordsT.size()/SPACEDIM; const double *coordsS=Intersector3DP1P1::_src_mesh.getCoordinatesPtr(); - for(int nodeIdT=0;nodeIdT::ind2C(startOfCellNodeConnT[nodeIdT])]; if(!resRow.empty()) diff --git a/src/INTERP_KERNEL/CurveIntersector.txx b/src/INTERP_KERNEL/CurveIntersector.txx index 81d54f386..1aa6db204 100644 --- a/src/INTERP_KERNEL/CurveIntersector.txx +++ b/src/INTERP_KERNEL/CurveIntersector.txx @@ -159,8 +159,8 @@ namespace INTERP_KERNEL void CurveIntersector::adjustBoundingBoxes (std::vector& bbox, double adjustmentEpsAbs) { - long size = bbox.size()/(2*SPACEDIM); - for (int i=0; i nodes2(nbOfSourceNodes); - for(int i=0;i& targetCoords, const std::vector& sourceCoords) { - int nbOfTargetNodes=targetCoords.size()/SPACEDIM; + std::size_t nbOfTargetNodes=targetCoords.size()/SPACEDIM; std::vector nodes(nbOfTargetNodes); - for(int i=0;i nodes2(nbOfSourceNodes); - for(int i=0;i nodes2(nbOfTargetNodes); - for(int i=0;i& coords, NormalizedCellType type) { - int nbNodes=coords.size()/SPACEDIM; + std::size_t nbNodes=coords.size()/SPACEDIM; std::vector nodes(nbNodes); - for(int i=0;i bary_poly(const std::vector& V) { std::vector Bary; - long taille=V.size(); + std::size_t taille=V.size(); double x=0; double y=0; - for(long i=0;i(taille)); + double B=2*y/(static_cast(taille)); Bary.push_back(A);//taille vecteur=2*nb de points. Bary.push_back(B); @@ -801,9 +801,9 @@ namespace INTERP_KERNEL inline void verif_point_dans_vect(const double* P, std::vector& V, double absolute_precision ) { - long taille=V.size(); + std::size_t taille=V.size(); bool isPresent=false; - for(long i=0;i& V) { - long taille=V.size(); + std::size_t taille=V.size(); int A=0; - for(long i=0;i CoordsT; const ConnType *startOfCellNodeConnT=Intersector3DP1P1::getStartConnOfTargetCell(targetCell); Intersector3DP1P1::getRealTargetCoordinates(OTT::indFC(targetCell),CoordsT); - int nbOfNodesT=CoordsT.size()/SPACEDIM; + std::size_t nbOfNodesT=CoordsT.size()/SPACEDIM; const double *coordsS=Intersector3DP1P1::_src_mesh.getCoordinatesPtr(); - for(int nodeIdT=0;nodeIdT::ind2C(startOfCellNodeConnT[nodeIdT])]; if(!resRow.empty()) diff --git a/src/INTERP_KERNEL/PlanarIntersector.txx b/src/INTERP_KERNEL/PlanarIntersector.txx index 22ac30f91..59871ce69 100644 --- a/src/INTERP_KERNEL/PlanarIntersector.txx +++ b/src/INTERP_KERNEL/PlanarIntersector.txx @@ -132,8 +132,8 @@ namespace INTERP_KERNEL { /* We build the segment tree for locating possible matching intersections*/ - long size = bbox.size()/(2*SPACEDIM); - for (int i=0; i::max(); for(int idim=0; idim& coords, NormalizedCellType type) { - int nbNodes=coords.size()/SPACEDIM; + std::size_t nbNodes=coords.size()/SPACEDIM; std::vector nodes(nbNodes); - for(int i=0;i coordsTarget; Intersector3DP0P1::getRealTargetCoordinates(OTT::indFC(targetCell),coordsTarget); - int nbNodesT=coordsTarget.size()/SPACEDIM; + std::size_t nbNodesT=coordsTarget.size()/SPACEDIM; const double *coordsS=Intersector3DP0P1::_src_mesh.getCoordinatesPtr(); const ConnType *startOfCellNodeConnT=Intersector3DP0P1::getStartConnOfTargetCell(targetCell); for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) @@ -63,7 +63,7 @@ namespace INTERP_KERNEL const CellModel& cmTypeS=CellModel::GetCellModel(tS); std::vector connOfCurCellS; Intersector3DP0P1::getConnOfSourceCell(OTT::indFC(*iterCellS),connOfCurCellS); - for(int nodeIdT=0;nodeIdT::isElementContainsPointAlg3D(&coordsTarget[nodeIdT*SPACEDIM],&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision)) { diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx index c587e0102..b1fa6fbe3 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx @@ -54,7 +54,7 @@ namespace INTERP_KERNEL { std::vector CoordsT; Intersector3DP1P1::getRealTargetCoordinates(OTT::indFC(targetCell),CoordsT); - int nbOfNodesT=CoordsT.size()/SPACEDIM; + std::size_t nbOfNodesT=CoordsT.size()/SPACEDIM; const double *coordsS=Intersector3DP1P1::_src_mesh.getCoordinatesPtr(); for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) { @@ -63,7 +63,7 @@ namespace INTERP_KERNEL throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==3. Only TETRA4 supported !"); const CellModel& cmTypeS=CellModel::GetCellModel(tS); const ConnType *startOfCellNodeConnT=Intersector3DP1P1::getStartConnOfTargetCell(targetCell); - for(int nodeIdT=0;nodeIdT::ind2C(startOfCellNodeConnT[nodeIdT])]; std::vector connOfCurCellS; diff --git a/src/INTERP_KERNEL/TriangulationIntersector.txx b/src/INTERP_KERNEL/TriangulationIntersector.txx index 5efe430ff..93d75d625 100644 --- a/src/INTERP_KERNEL/TriangulationIntersector.txx +++ b/src/INTERP_KERNEL/TriangulationIntersector.txx @@ -103,7 +103,7 @@ namespace INTERP_KERNEL bool isSourceQuad) { double result = 0.; - ConnType nbNodesS=sourceCoords.size()/SPACEDIM; + ConnType nbNodesS=static_cast(sourceCoords.size())/SPACEDIM; //Compute the intersection area double area[SPACEDIM]; for(ConnType iT = 1; iT<3; iT++) @@ -144,8 +144,8 @@ namespace INTERP_KERNEL const std::vector& sourceCoords) { double result = 0.; - ConnType nbNodesS=sourceCoords.size()/SPACEDIM; - ConnType nbNodesT=targetCoords.size()/SPACEDIM; + ConnType nbNodesS=static_cast(sourceCoords.size())/SPACEDIM; + ConnType nbNodesT=static_cast(targetCoords.size())/SPACEDIM; //Compute the intersection area double area[SPACEDIM]; for(ConnType iT = 1; iT inter; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx index 1ee95f1ae..91184f47a 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx @@ -1629,7 +1629,7 @@ MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DTetraTargetMesh(const double i int MEDCouplingBasicsTest::countNonZero(const std::vector< std::map >& matrix) { - int ret=0.; + int ret=0; for(std::vector< std::map >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++) for(std::map::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++) if (!INTERP_KERNEL::epsilonEqual((*iter2).second, 0.)) ret +=1; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index 65b3a6c5e..bcaf814dc 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -1219,7 +1219,7 @@ void MEDCouplingBasicsTest1::testFindCommonNodes() // targetMesh=build3DTargetMesh_1(); bool areNodesMerged; - unsigned int time=targetMesh->getTimeOfThis(); + std::size_t time=targetMesh->getTimeOfThis(); o2n=targetMesh->mergeNodes(1e-10,areNodesMerged,newNbOfNodes); targetMesh->updateTime(); CPPUNIT_ASSERT(time==targetMesh->getTimeOfThis()); @@ -1818,7 +1818,7 @@ void MEDCouplingBasicsTest1::testOperationsOnFields3() void MEDCouplingBasicsTest1::testOperationsOnFields4() { MEDCouplingUMesh *m=build2DTargetMesh_1(); - int nbOfCells=m->getNumberOfCells(); + std::size_t nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL); f1->setMesh(m); DataArrayDouble *array=DataArrayDouble::New(); @@ -2234,13 +2234,13 @@ void MEDCouplingBasicsTest1::testGetValueOn1() { MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); MEDCouplingFieldDouble *fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS); - int nbOfCells=targetMesh->getNumberOfCells(); + std::size_t nbOfCells=targetMesh->getNumberOfCells(); fieldOnCells->setMesh(targetMesh); DataArrayDouble *array=DataArrayDouble::New(); array->alloc(nbOfCells,2); fieldOnCells->setArray(array); double *tmp=array->getPointer(); - for(int i=0;idecrRef(); // diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index 8fdca210a..cd7ca7559 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -636,8 +636,8 @@ void MEDCouplingBasicsTest2::testRenumberCellsForFields() MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); f->setMesh(m); DataArrayDouble *arr=DataArrayDouble::New(); - int nbOfCells=m->getNumberOfCells(); - arr->alloc(nbOfCells,3); + + arr->alloc(m->getNumberOfCells(),3); f->setArray(arr); arr->decrRef(); const double values1[15]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.}; @@ -883,13 +883,13 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith() bool isExcep=false; try { mesh1->checkGeoEquivalWith(mesh2,0,1e-12,cellCor,nodeCor);//deepEqual fails } - catch(INTERP_KERNEL::Exception& e) { isExcep=true; } + catch(INTERP_KERNEL::Exception&) { isExcep=true; } CPPUNIT_ASSERT(isExcep); isExcep=false; CPPUNIT_ASSERT(cellCor==0); CPPUNIT_ASSERT(nodeCor==0); try { mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual has detected something } - catch(INTERP_KERNEL::Exception& e) { isExcep=true; } + catch(INTERP_KERNEL::Exception&) { isExcep=true; } CPPUNIT_ASSERT(isExcep); isExcep=false; CPPUNIT_ASSERT(cellCor==0); CPPUNIT_ASSERT(nodeCor==0); @@ -931,7 +931,7 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith2() void MEDCouplingBasicsTest2::testCopyTinyStringsFromOnFields() { MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - int nbOfCells=m->getNumberOfCells(); + std::size_t nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); f->setMesh(m); CPPUNIT_ASSERT_EQUAL(5,f->getNumberOfMeshPlacesExpected()); @@ -1107,7 +1107,7 @@ void MEDCouplingBasicsTest2::testChangeUnderlyingMesh1() void MEDCouplingBasicsTest2::testGetMaxValue1() { MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - int nbOfCells=m->getNumberOfCells(); + std::size_t nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); f->setMesh(m); DataArrayDouble *a1=DataArrayDouble::New(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index 550dfd02e..743fef5d5 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -734,7 +734,7 @@ void MEDCouplingBasicsTest4::testGetValueOn2() MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); f->setMesh(m); DataArrayDouble *arr=DataArrayDouble::New(); - int nbOfCells=m->getNumberOfCells(); + std::size_t nbOfCells=m->getNumberOfCells(); arr->alloc(nbOfCells,3); f->setArray(arr); arr->decrRef(); -- 2.39.2