From c56cd2a9e800451c3f49b442844cc4091d66722e Mon Sep 17 00:00:00 2001
From: Boris Martin <boris.martin@uliege.be>
Date: Mon, 18 Mar 2024 21:11:01 +0100
Subject: [PATCH 1/5] Code quality

---
 src/common/gmsh.cpp | 6 ++----
 src/geo/GEdge.h     | 4 ++--
 src/geo/GFace.h     | 4 ++--
 src/geo/GRegion.h   | 4 ++--
 src/geo/GVertex.h   | 4 ++--
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/common/gmsh.cpp b/src/common/gmsh.cpp
index 253b4b9f6f..137ab86e8e 100644
--- a/src/common/gmsh.cpp
+++ b/src/common/gmsh.cpp
@@ -3605,8 +3605,7 @@ GMSH_API void gmsh::model::mesh::createEdges(const vectorpair &dimTags)
   if(!_checkInit()) return;
   std::vector<GEntity *> entities;
   _getEntities(dimTags, entities);
-  for(std::size_t i = 0; i < entities.size(); i++) {
-    GEntity *ge = entities[i];
+  for(GEntity *ge : entities) {
     for(std::size_t j = 0; j < ge->getNumMeshElements(); j++) {
       MElement *e = ge->getMeshElement(j);
       for(int k = 0; k < e->getNumEdges(); k++) {
@@ -3622,8 +3621,7 @@ GMSH_API void gmsh::model::mesh::createFaces(const vectorpair &dimTags)
   if(!_checkInit()) return;
   std::vector<GEntity *> entities;
   _getEntities(dimTags, entities);
-  for(std::size_t i = 0; i < entities.size(); i++) {
-    GEntity *ge = entities[i];
+  for(GEntity *ge : entities) {
     for(std::size_t j = 0; j < ge->getNumMeshElements(); j++) {
       MElement *e = ge->getMeshElement(j);
       for(int k = 0; k < e->getNumFaces(); k++) {
diff --git a/src/geo/GEdge.h b/src/geo/GEdge.h
index 385fc0d43d..614ed1ad13 100644
--- a/src/geo/GEdge.h
+++ b/src/geo/GEdge.h
@@ -207,10 +207,10 @@ public:
   MElement *const *getStartElementType(int type) const;
 
   // get the element at the given index
-  MElement *getMeshElement(std::size_t index) const;
+  MElement *getMeshElement(std::size_t index) const override;
   // get the element at the given index for a given familyType
   MElement *getMeshElementByType(const int familyType,
-                                 const std::size_t index) const;
+                                 const std::size_t index) const override;
 
   // reset the mesh attributes to default values
   virtual void resetMeshAttributes();
diff --git a/src/geo/GFace.h b/src/geo/GFace.h
index 373543ccce..8b24f89c23 100644
--- a/src/geo/GFace.h
+++ b/src/geo/GFace.h
@@ -276,10 +276,10 @@ public:
   MElement *const *getStartElementType(int type) const;
 
   // get the element at the given index
-  MElement *getMeshElement(std::size_t index) const;
+  MElement *getMeshElement(std::size_t index) const override;
   // get the element at the given index for a given familyType
   MElement *getMeshElementByType(const int familyType,
-                                 const std::size_t index) const;
+                                 const std::size_t index) const override;
 
   // reset the mesh attributes to default values
   virtual void resetMeshAttributes();
diff --git a/src/geo/GRegion.h b/src/geo/GRegion.h
index 004aed5885..69e1c00e20 100644
--- a/src/geo/GRegion.h
+++ b/src/geo/GRegion.h
@@ -131,10 +131,10 @@ public:
   MElement *const *getStartElementType(int type) const;
 
   // get the element at the given index
-  MElement *getMeshElement(std::size_t index) const;
+  MElement *getMeshElement(std::size_t index) const override;
   // get the element at the given index for a given familyType
   MElement *getMeshElementByType(const int familyType,
-                                 const std::size_t index) const;
+                                 const std::size_t index) const override;
 
   // reset the mesh attributes to default values
   virtual void resetMeshAttributes();
diff --git a/src/geo/GVertex.h b/src/geo/GVertex.h
index 037cf04a2b..8bdc482223 100644
--- a/src/geo/GVertex.h
+++ b/src/geo/GVertex.h
@@ -101,8 +101,8 @@ public:
   };
 
   // get number of elements in the mesh
-  std::size_t getNumMeshElements() const { return points.size(); }
-  std::size_t getNumMeshElementsByType(const int familyType) const;
+  std::size_t getNumMeshElements() const override { return points.size(); }
+  std::size_t getNumMeshElementsByType(const int familyType) const override;
   void getNumMeshElements(unsigned *const c) const;
 
   // get the element at the given index
-- 
GitLab


From f4353e836749b528d831be32396cbed6d3c0e12e Mon Sep 17 00:00:00 2001
From: Boris Martin <boris.martin@uliege.be>
Date: Wed, 20 Mar 2024 10:25:46 +0100
Subject: [PATCH 2/5] revert overrides

---
 src/geo/GEdge.h   | 4 ++--
 src/geo/GFace.h   | 4 ++--
 src/geo/GRegion.h | 4 ++--
 src/geo/GVertex.h | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/geo/GEdge.h b/src/geo/GEdge.h
index 614ed1ad13..385fc0d43d 100644
--- a/src/geo/GEdge.h
+++ b/src/geo/GEdge.h
@@ -207,10 +207,10 @@ public:
   MElement *const *getStartElementType(int type) const;
 
   // get the element at the given index
-  MElement *getMeshElement(std::size_t index) const override;
+  MElement *getMeshElement(std::size_t index) const;
   // get the element at the given index for a given familyType
   MElement *getMeshElementByType(const int familyType,
-                                 const std::size_t index) const override;
+                                 const std::size_t index) const;
 
   // reset the mesh attributes to default values
   virtual void resetMeshAttributes();
diff --git a/src/geo/GFace.h b/src/geo/GFace.h
index 8b24f89c23..373543ccce 100644
--- a/src/geo/GFace.h
+++ b/src/geo/GFace.h
@@ -276,10 +276,10 @@ public:
   MElement *const *getStartElementType(int type) const;
 
   // get the element at the given index
-  MElement *getMeshElement(std::size_t index) const override;
+  MElement *getMeshElement(std::size_t index) const;
   // get the element at the given index for a given familyType
   MElement *getMeshElementByType(const int familyType,
-                                 const std::size_t index) const override;
+                                 const std::size_t index) const;
 
   // reset the mesh attributes to default values
   virtual void resetMeshAttributes();
diff --git a/src/geo/GRegion.h b/src/geo/GRegion.h
index 69e1c00e20..004aed5885 100644
--- a/src/geo/GRegion.h
+++ b/src/geo/GRegion.h
@@ -131,10 +131,10 @@ public:
   MElement *const *getStartElementType(int type) const;
 
   // get the element at the given index
-  MElement *getMeshElement(std::size_t index) const override;
+  MElement *getMeshElement(std::size_t index) const;
   // get the element at the given index for a given familyType
   MElement *getMeshElementByType(const int familyType,
-                                 const std::size_t index) const override;
+                                 const std::size_t index) const;
 
   // reset the mesh attributes to default values
   virtual void resetMeshAttributes();
diff --git a/src/geo/GVertex.h b/src/geo/GVertex.h
index 8bdc482223..037cf04a2b 100644
--- a/src/geo/GVertex.h
+++ b/src/geo/GVertex.h
@@ -101,8 +101,8 @@ public:
   };
 
   // get number of elements in the mesh
-  std::size_t getNumMeshElements() const override { return points.size(); }
-  std::size_t getNumMeshElementsByType(const int familyType) const override;
+  std::size_t getNumMeshElements() const { return points.size(); }
+  std::size_t getNumMeshElementsByType(const int familyType) const;
   void getNumMeshElements(unsigned *const c) const;
 
   // get the element at the given index
-- 
GitLab


From 21a47b4bf2837b3e642b571b7f43c2a6a4ae223f Mon Sep 17 00:00:00 2001
From: Boris Martin <boris.martin@uliege.be>
Date: Wed, 20 Mar 2024 10:46:57 +0100
Subject: [PATCH 3/5] Replaced macros by using statement

---
 src/geo/GModel.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/geo/GModel.h b/src/geo/GModel.h
index d67a86a8f0..b9111d2268 100644
--- a/src/geo/GModel.h
+++ b/src/geo/GModel.h
@@ -22,10 +22,6 @@
 #include "MFaceHash.h"
 #include "MEdgeHash.h"
 
-#define hashmapMFace                                                           \
-  std::unordered_map<MFace, std::size_t, MFaceHash, MFaceEqual>
-#define hashmapMEdge                                                           \
-  std::unordered_map<MEdge, std::size_t, MEdgeHash, MEdgeEqual>
 
 template <class scalar> class simpleFunction;
 
@@ -43,6 +39,9 @@ class MElementOctree;
 // A geometric model. The model is a "not yet" non-manifold B-Rep.
 class GModel {
 private:
+  using hashmapMFace = std::unordered_map<MFace, std::size_t, MFaceHash, MFaceEqual>;
+  using hashmapMEdge = std::unordered_map<MEdge, std::size_t, MEdgeHash, MEdgeEqual>;
+
   std::multimap<std::pair<const std::vector<int>, const std::vector<int> >,
                 std::pair<const std::string, const std::vector<int> > >
     _homologyRequests;
-- 
GitLab


From e96621f7e8a1c90948257233d466c75495e66d3c Mon Sep 17 00:00:00 2001
From: Boris Martin <boris.martin@uliege.be>
Date: Thu, 28 Mar 2024 15:36:56 +0100
Subject: [PATCH 4/5] added public alias

---
 src/geo/GModel.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/geo/GModel.h b/src/geo/GModel.h
index b9111d2268..c6110447f8 100644
--- a/src/geo/GModel.h
+++ b/src/geo/GModel.h
@@ -38,9 +38,10 @@ class MElementOctree;
 
 // A geometric model. The model is a "not yet" non-manifold B-Rep.
 class GModel {
-private:
+public:
   using hashmapMFace = std::unordered_map<MFace, std::size_t, MFaceHash, MFaceEqual>;
   using hashmapMEdge = std::unordered_map<MEdge, std::size_t, MEdgeHash, MEdgeEqual>;
+private:
 
   std::multimap<std::pair<const std::vector<int>, const std::vector<int> >,
                 std::pair<const std::string, const std::vector<int> > >
-- 
GitLab


From a2f1a03750e40a5197350ca45da864d8ed845899 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@uliege.be>
Date: Fri, 29 Mar 2024 12:22:56 +0100
Subject: [PATCH 5/5] thanks Boris!

---
 CREDITS.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CREDITS.txt b/CREDITS.txt
index 16d07ddb9b..7ea93b2c1a 100644
--- a/CREDITS.txt
+++ b/CREDITS.txt
@@ -63,7 +63,7 @@ Schloemer, Simon Tournier, Alexandru Dadalau, Thomas Ulrich, Matthias Diener,
 Jamie Border, Kenneth Jansen, Steven Masfaraud, Sai Sumanth Moturu, Arie
 Westland, Andreas Farley, Mahesh Madhav, Zoltan Csati, Thierry Hocquellet,
 Christophe Bourcier, Mattéo Couplet, Mahesh Madhav, Giuseppe Musacchio, Romin
-Tomasetti, Lin Qi Chen, Tim Furlan, Matthias Lang.
+Tomasetti, Lin Qi Chen, Tim Furlan, Matthias Lang, Boris Martin.
 
 Special thanks to Bill Spitzak, Michael Sweet, Matthias Melcher, Greg Ercolano
 and others for the Fast Light Tool Kit on which Gmsh's GUI is based. See
-- 
GitLab