From e04a193ac6e3a60698d26ab155e74bd027a7baf2 Mon Sep 17 00:00:00 2001
From: Anthony Royer <anthony.royer@uliege.be>
Date: Wed, 20 Feb 2019 15:58:43 +0100
Subject: [PATCH] Adapt 'gmsh::model::mesh::reorderElements' to 'std::size_t'

---
 Common/gmsh.cpp  |  2 +-
 Geo/GEdge.cpp    |  4 ++--
 Geo/GEdge.h      |  2 +-
 Geo/GEntity.h    |  2 +-
 Geo/GFace.cpp    |  8 ++++----
 Geo/GFace.h      |  2 +-
 Geo/GRegion.cpp  | 14 +++++++-------
 Geo/GRegion.h    |  2 +-
 Geo/GVertex.cpp  |  4 ++--
 Geo/GVertex.h    |  2 +-
 api/gen.py       |  2 +-
 api/gmsh.h       |  2 +-
 api/gmsh.h_cwrap |  4 ++--
 api/gmsh.jl      |  4 ++--
 api/gmsh.py      |  2 +-
 api/gmshc.cpp    |  4 ++--
 api/gmshc.h      |  2 +-
 17 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/Common/gmsh.cpp b/Common/gmsh.cpp
index b76aaba8c4..2b751cddce 100644
--- a/Common/gmsh.cpp
+++ b/Common/gmsh.cpp
@@ -2466,7 +2466,7 @@ GMSH_API void gmsh::model::mesh::embed(const int dim,
 
 GMSH_API void
 gmsh::model::mesh::reorderElements(const int elementType, const int tag,
-                                   const std::vector<int> &ordering)
+                                   const std::vector<std::size_t> &ordering)
 {
   if(!_isInitialized()) {
     throw -1;
diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp
index 3981b3a01f..e916039634 100644
--- a/Geo/GEdge.cpp
+++ b/Geo/GEdge.cpp
@@ -769,14 +769,14 @@ void GEdge::mesh(bool verbose)
 #endif
 }
 
-bool GEdge::reorder(const int elementType, const std::vector<int> &ordering)
+bool GEdge::reorder(const int elementType, const std::vector<std::size_t> &ordering)
 {
   if(lines.size() != 0) {
     if(lines.front()->getTypeForMSH() != elementType) { return false; }
 
     if(ordering.size() != lines.size()) return false;
 
-    for(std::vector<int>::const_iterator it = ordering.begin();
+    for(std::vector<std::size_t>::const_iterator it = ordering.begin();
         it != ordering.end(); ++it) {
       if(*it < 0 || *it >= static_cast<int>(lines.size())) return false;
     }
diff --git a/Geo/GEdge.h b/Geo/GEdge.h
index 9c263b44a9..ddbb7c6248 100644
--- a/Geo/GEdge.h
+++ b/Geo/GEdge.h
@@ -244,7 +244,7 @@ public:
   SPoint3 closestPoint(SPoint3 &p, double tolerance);
   virtual void mesh(bool verbose);
 
-  virtual bool reorder(const int elementType, const std::vector<int> &ordering);
+  virtual bool reorder(const int elementType, const std::vector<std::size_t> &ordering);
 };
 
 #endif
diff --git a/Geo/GEntity.h b/Geo/GEntity.h
index 5609ea954a..414ce38fcd 100644
--- a/Geo/GEntity.h
+++ b/Geo/GEntity.h
@@ -405,7 +405,7 @@ public:
   std::map<MVertex *, MVertex *> correspondingHOPoints;
 
   // reorder the mesh elements of the given type, according to ordering
-  virtual bool reorder(const int elementType, const std::vector<int> &ordering)
+  virtual bool reorder(const int elementType, const std::vector<std::size_t> &ordering)
   {
     return false;
   }
diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp
index dc2deca72d..964ddd572c 100644
--- a/Geo/GFace.cpp
+++ b/Geo/GFace.cpp
@@ -2046,13 +2046,13 @@ void GFace::removeElement(int type, MElement *e)
   }
 }
 
-bool GFace::reorder(const int elementType, const std::vector<int> &ordering)
+bool GFace::reorder(const int elementType, const std::vector<std::size_t> &ordering)
 {
   if(triangles.size() != 0) {
     if(triangles.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != triangles.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(triangles.size())) return false;
       }
@@ -2075,7 +2075,7 @@ bool GFace::reorder(const int elementType, const std::vector<int> &ordering)
     if(quadrangles.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != quadrangles.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(quadrangles.size())) return false;
       }
@@ -2098,7 +2098,7 @@ bool GFace::reorder(const int elementType, const std::vector<int> &ordering)
     if(polygons.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != polygons.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(polygons.size())) return false;
       }
diff --git a/Geo/GFace.h b/Geo/GFace.h
index f0df224588..2b90807bf6 100644
--- a/Geo/GFace.h
+++ b/Geo/GFace.h
@@ -363,7 +363,7 @@ public:
   std::vector<SVector3> storage3; // sizes and directions storage
   std::vector<double> storage4; // sizes and directions storage
 
-  virtual bool reorder(const int elementType, const std::vector<int> &ordering);
+  virtual bool reorder(const int elementType, const std::vector<std::size_t> &ordering);
 };
 
 #endif
diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp
index a45659932f..a605bc11c4 100644
--- a/Geo/GRegion.cpp
+++ b/Geo/GRegion.cpp
@@ -591,13 +591,13 @@ void GRegion::removeElement(int type, MElement *e)
   }
 }
 
-bool GRegion::reorder(const int elementType, const std::vector<int> &ordering)
+bool GRegion::reorder(const int elementType, const std::vector<std::size_t> &ordering)
 {
   if(tetrahedra.size() != 0) {
     if(tetrahedra.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != tetrahedra.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(tetrahedra.size())) return false;
       }
@@ -620,7 +620,7 @@ bool GRegion::reorder(const int elementType, const std::vector<int> &ordering)
     if(hexahedra.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != hexahedra.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(hexahedra.size())) return false;
       }
@@ -643,7 +643,7 @@ bool GRegion::reorder(const int elementType, const std::vector<int> &ordering)
     if(prisms.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != prisms.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(prisms.size())) return false;
       }
@@ -666,7 +666,7 @@ bool GRegion::reorder(const int elementType, const std::vector<int> &ordering)
     if(pyramids.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != pyramids.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(pyramids.size())) return false;
       }
@@ -689,7 +689,7 @@ bool GRegion::reorder(const int elementType, const std::vector<int> &ordering)
     if(polyhedra.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != polyhedra.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(polyhedra.size())) return false;
       }
@@ -712,7 +712,7 @@ bool GRegion::reorder(const int elementType, const std::vector<int> &ordering)
     if(trihedra.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != trihedra.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(trihedra.size())) return false;
       }
diff --git a/Geo/GRegion.h b/Geo/GRegion.h
index d121b835de..41475b84e0 100644
--- a/Geo/GRegion.h
+++ b/Geo/GRegion.h
@@ -164,7 +164,7 @@ public:
   // get the boundary layer columns
   BoundaryLayerColumns *getColumns() { return &_columns; }
 
-  virtual bool reorder(const int elementType, const std::vector<int> &ordering);
+  virtual bool reorder(const int elementType, const std::vector<std::size_t> &ordering);
 
   // set the reverseMesh constraint in the bounding surfaces so that the
   // boundary mesh has outward pointing normals, based on the STL triangulation
diff --git a/Geo/GVertex.cpp b/Geo/GVertex.cpp
index 976975cc5a..8ead92b22e 100644
--- a/Geo/GVertex.cpp
+++ b/Geo/GVertex.cpp
@@ -180,13 +180,13 @@ void GVertex::removeElement(int type, MElement *e)
   }
 }
 
-bool GVertex::reorder(const int elementType, const std::vector<int> &ordering)
+bool GVertex::reorder(const int elementType, const std::vector<std::size_t> &ordering)
 {
   if(points.size() != 0) {
     if(points.front()->getTypeForMSH() == elementType) {
       if(ordering.size() != points.size()) return false;
 
-      for(std::vector<int>::const_iterator it = ordering.begin();
+      for(std::vector<std::size_t>::const_iterator it = ordering.begin();
           it != ordering.end(); ++it) {
         if(*it < 0 || *it >= static_cast<int>(points.size())) return false;
       }
diff --git a/Geo/GVertex.h b/Geo/GVertex.h
index 8d03df9e0f..1b2f32b958 100644
--- a/Geo/GVertex.h
+++ b/Geo/GVertex.h
@@ -106,7 +106,7 @@ public:
   void addElement(int type, MElement *e);
   void removeElement(int type, MElement *e);
 
-  virtual bool reorder(const int elementType, const std::vector<int> &ordering);
+  virtual bool reorder(const int elementType, const std::vector<std::size_t> &ordering);
 };
 
 #endif
diff --git a/api/gen.py b/api/gen.py
index 80c3a00ef4..e1c6f8451d 100644
--- a/api/gen.py
+++ b/api/gen.py
@@ -305,7 +305,7 @@ doc = '''Embed the geometrical entities of dimension `dim' and tags `tags' in th
 mesh.add('embed',doc,None,iint('dim'),ivectorint('tags'),iint('inDim'),iint('inTag'))
 
 doc = '''Reorder the elements of type `elementType' classified on the entity of tag `tag' according to `ordering'.'''
-mesh.add('reorderElements',doc,None,iint('elementType'),iint('tag'),ivectorint('ordering'))
+mesh.add('reorderElements',doc,None,iint('elementType'),iint('tag'),ivectorsize('ordering'))
 
 doc = '''Renumber the node tags in a contiunous sequence.'''
 mesh.add('renumberNodes',doc,None)
diff --git a/api/gmsh.h b/api/gmsh.h
index 2105880f26..763f24d4a7 100644
--- a/api/gmsh.h
+++ b/api/gmsh.h
@@ -707,7 +707,7 @@ namespace gmsh { // Top-level functions
       // `tag' according to `ordering'.
       GMSH_API void reorderElements(const int elementType,
                                     const int tag,
-                                    const std::vector<int> & ordering);
+                                    const std::vector<std::size_t> & ordering);
 
       // Renumber the node tags in a contiunous sequence.
       GMSH_API void renumberNodes();
diff --git a/api/gmsh.h_cwrap b/api/gmsh.h_cwrap
index 5cb5f4f84b..23b118b22a 100644
--- a/api/gmsh.h_cwrap
+++ b/api/gmsh.h_cwrap
@@ -1326,10 +1326,10 @@ namespace gmsh { // Top-level functions
       // `tag' according to `ordering'.
       GMSH_API void reorderElements(const int elementType,
                                     const int tag,
-                                    const std::vector<int> & ordering)
+                                    const std::vector<std::size_t> & ordering)
       {
         int ierr = 0;
-        int *api_ordering_; size_t api_ordering_n_; vector2ptr(ordering, &api_ordering_, &api_ordering_n_);
+        size_t *api_ordering_; size_t api_ordering_n_; vector2ptr(ordering, &api_ordering_, &api_ordering_n_);
         gmshModelMeshReorderElements(elementType, tag, api_ordering_, api_ordering_n_, &ierr);
         if(ierr) throw ierr;
         gmshFree(api_ordering_);
diff --git a/api/gmsh.jl b/api/gmsh.jl
index a6f0f5bc5d..e1fba4e5b6 100644
--- a/api/gmsh.jl
+++ b/api/gmsh.jl
@@ -1701,8 +1701,8 @@ according to `ordering`.
 function reorderElements(elementType, tag, ordering)
     ierr = Ref{Cint}()
     ccall((:gmshModelMeshReorderElements, gmsh.lib), Nothing,
-          (Cint, Cint, Ptr{Cint}, Csize_t, Ptr{Cint}),
-          elementType, tag, convert(Vector{Cint}, ordering), length(ordering), ierr)
+          (Cint, Cint, Ptr{Csize_t}, Csize_t, Ptr{Cint}),
+          elementType, tag, convert(Vector{Csize_t}, ordering), length(ordering), ierr)
     ierr[] != 0 && error("gmshModelMeshReorderElements returned non-zero error code: $(ierr[])")
     return nothing
 end
diff --git a/api/gmsh.py b/api/gmsh.py
index d1d8cad778..ddc4453d19 100644
--- a/api/gmsh.py
+++ b/api/gmsh.py
@@ -2028,7 +2028,7 @@ class model:
             Reorder the elements of type `elementType' classified on the entity of tag
             `tag' according to `ordering'.
             """
-            api_ordering_, api_ordering_n_ = _ivectorint(ordering)
+            api_ordering_, api_ordering_n_ = _ivectorsize(ordering)
             ierr = c_int()
             lib.gmshModelMeshReorderElements(
                 c_int(elementType),
diff --git a/api/gmshc.cpp b/api/gmshc.cpp
index 3d4cfb04f4..82e03483b4 100644
--- a/api/gmshc.cpp
+++ b/api/gmshc.cpp
@@ -1150,11 +1150,11 @@ GMSH_API void gmshModelMeshEmbed(const int dim, int * tags, size_t tags_n, const
   }
 }
 
-GMSH_API void gmshModelMeshReorderElements(const int elementType, const int tag, int * ordering, size_t ordering_n, int * ierr)
+GMSH_API void gmshModelMeshReorderElements(const int elementType, const int tag, size_t * ordering, size_t ordering_n, int * ierr)
 {
   if(ierr) *ierr = 0;
   try {
-    std::vector<int> api_ordering_(ordering, ordering + ordering_n);
+    std::vector<std::size_t> api_ordering_(ordering, ordering + ordering_n);
     gmsh::model::mesh::reorderElements(elementType, tag, api_ordering_);
   }
   catch(int api_ierr_){
diff --git a/api/gmshc.h b/api/gmshc.h
index 7b43fb7470..db4c55ef5b 100644
--- a/api/gmshc.h
+++ b/api/gmshc.h
@@ -760,7 +760,7 @@ GMSH_API void gmshModelMeshEmbed(const int dim,
  * `tag' according to `ordering'. */
 GMSH_API void gmshModelMeshReorderElements(const int elementType,
                                            const int tag,
-                                           int * ordering, size_t ordering_n,
+                                           size_t * ordering, size_t ordering_n,
                                            int * ierr);
 
 /* Renumber the node tags in a contiunous sequence. */
-- 
GitLab