From 002c38f3c7daac9e94cfd4ed4ab5dc0b3d60f633 Mon Sep 17 00:00:00 2001
From: Laurent Van Migroet <l.vanmiegroet@ulg.ac.be>
Date: Mon, 21 Sep 2009 12:34:23 +0000
Subject: [PATCH] passing DI_Point by reference instead of copy

---
 Geo/MElementCut.cpp                         | 26 ++++++++++-----------
 contrib/DiscreteIntegration/Integration3D.h | 26 ++++++++++-----------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/Geo/MElementCut.cpp b/Geo/MElementCut.cpp
index 2bd688d6fa..db2583a770 100644
--- a/Geo/MElementCut.cpp
+++ b/Geo/MElementCut.cpp
@@ -81,7 +81,7 @@ void MPolyhedron::_init()
         _innerVertices.push_back(_parts[i]->getVertex(j));
     }
   }
-  
+
 }
 
 bool MPolyhedron::isInside(double u, double v, double w)
@@ -116,7 +116,7 @@ void MPolyhedron::getIntegrationPoints(int pOrder, int *npts, IntPt **pts) const
     MVertex v2(uvw[2][0], uvw[2][1], uvw[2][2]);
     MVertex v3(uvw[3][0], uvw[3][1], uvw[3][2]);
     MTetrahedron tt(&v0, &v1, &v2, &v3);
-    
+
     for(int ip = 0; ip < nptsi; ip++){
       const double u = ptsi[ip].pt[0];
       const double v = ptsi[ip].pt[1];
@@ -133,7 +133,7 @@ void MPolyhedron::getIntegrationPoints(int pOrder, int *npts, IntPt **pts) const
   }
 }
 
-void MPolyhedron::writeMSH(FILE *fp, double version, bool binary, int num, 
+void MPolyhedron::writeMSH(FILE *fp, double version, bool binary, int num,
                            int elementary, int physical, int parentNum)
 {
   int type = getTypeForMSH();
@@ -272,7 +272,7 @@ bool MPolygon::isInside(double u, double v, double w)
     if(_parts[i]->isInside(uvw[0],uvw[1],uvw[2]))
       return true;
   }
-  return false; 
+  return false;
 }
 
 void MPolygon::getIntegrationPoints(int pOrder, int *npts, IntPt **pts) const
@@ -309,7 +309,7 @@ void MPolygon::getIntegrationPoints(int pOrder, int *npts, IntPt **pts) const
   }
 }
 
-void MPolygon::writeMSH(FILE *fp, double version, bool binary, int num, 
+void MPolygon::writeMSH(FILE *fp, double version, bool binary, int num,
                         int elementary, int physical, int parentNum)
 {
   int type = getTypeForMSH();
@@ -421,14 +421,14 @@ void MLineBorder::getIntegrationPoints(int pOrder, int *npts, IntPt **pts) const
 
 #if defined(HAVE_DINTEGRATION)
 
-static bool equalV(MVertex *v, DI_Point p)
+static bool equalV(MVertex *v, const DI_Point &p)
 {
-  return (fabs(v->x() - p.x()) < 1.e-15 && 
+  return (fabs(v->x() - p.x()) < 1.e-15 &&
           fabs(v->y() - p.y()) < 1.e-15 &&
           fabs(v->z() - p.z()) < 1.e-15);
 }
 
-static int getElementVertexNum(DI_Point p, MElement *e)
+static int getElementVertexNum(DI_Point &p, MElement *e)
 {
   for(int i = 0; i < e->getNumVertices(); i++)
     if(equalV(e->getVertex(i), p))
@@ -475,7 +475,7 @@ static int getBorderTag(int lsTag, int count, int &elementaryMax, std::map<int,
 }
 
 static void elementCutMesh(MElement *e, gLevelset *ls,
-                           std::map<int, std::map<int, double> > &verticesLs, 
+                           std::map<int, std::map<int, double> > &verticesLs,
                            GEntity *ge, GModel *GM, int &numEle, std::map<int, MVertex*> &vertexMap,
                            std::vector<MVertex*> &newVertices,
                            std::map<int, std::vector<MElement*> > elements[10],
@@ -636,7 +636,7 @@ static void elementCutMesh(MElement *e, gLevelset *ls,
       MPolyhedron *p1 = NULL, *p2 = NULL;
       if(isCut) {
         std::vector<MTetrahedron*> poly[2];
-        
+
         for (unsigned int i = nbTe; i < tetras.size(); i++){
           MVertex *mv[4] = {NULL, NULL, NULL, NULL};
           for(int j = 0; j < 4; j++){
@@ -679,7 +679,7 @@ static void elementCutMesh(MElement *e, gLevelset *ls,
           elements[9][elementary].push_back(p2);
           assignPhysicals(GM, gePhysicals, elementary, 3, physicals);
         }
-      } 
+      }
       else { // no cut
         int reg = getElementaryTag(tetras[nbTe].lsTag(), elementary, newtags[3]);
         if(eType == MSH_TET_4)
@@ -925,7 +925,7 @@ static void elementCutMesh(MElement *e, gLevelset *ls,
 
 #endif
 
-GModel *buildCutMesh(GModel *gm, gLevelset *ls, 
+GModel *buildCutMesh(GModel *gm, gLevelset *ls,
                      std::map<int, std::vector<MElement*> > elements[10],
                      std::map<int, MVertex*> &vertexMap,
                      std::map<int, std::map<int, std::string> > physicals[4])
@@ -968,7 +968,7 @@ GModel *buildCutMesh(GModel *gm, gLevelset *ls,
     for(unsigned int j = 0; j < gmEntities[i]->getNumMeshElements(); j++) {
       MElement *e = gmEntities[i]->getMeshElement(j);
       e->setVolumePositive();
-      elementCutMesh(e, ls, verticesLs, gmEntities[i], gm, numEle, vertexMap, newVertices, 
+      elementCutMesh(e, ls, verticesLs, gmEntities[i], gm, numEle, vertexMap, newVertices,
                      elements, physicals, borderTags, newtags, cp, lines, triangles, quads, tetras, hexas);
       cutGM->getMeshPartitions().insert(e->getPartition());
     }
diff --git a/contrib/DiscreteIntegration/Integration3D.h b/contrib/DiscreteIntegration/Integration3D.h
index f9a4968a9d..9875ebc066 100644
--- a/contrib/DiscreteIntegration/Integration3D.h
+++ b/contrib/DiscreteIntegration/Integration3D.h
@@ -137,7 +137,7 @@ static inline double LineLength(double x1, double y1, double z1, double x2, doub
 {
   return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2));
 }
-static inline double LineLength (const DI_Point p1, const DI_Point p2)
+static inline double LineLength (const DI_Point &p1, const DI_Point &p2)
 {
   return LineLength(p1.x(), p1.y(), p1.z(), p2.x(), p2.y(), p2.z());
 }
@@ -152,7 +152,7 @@ static inline double TriSurf(double x1, double y1, double z1, double x2, double
                   + (z1 * (x2 - x3) - z2 * (x1 - x3) + z3 * (x1 - x2)) *
                     (z1 * (x2 - x3) - z2 * (x1 - x3) + z3 * (x1 - x2)));
 }
-static inline double TriSurf (const DI_Point p1, const DI_Point p2, const DI_Point p3)
+static inline double TriSurf (const DI_Point &p1, const DI_Point &p2, const DI_Point &p3)
 {
   return TriSurf(p1.x(), p1.y(), p1.z(), p2.x(), p2.y(), p2.z(), p3.x(), p3.y(), p3.z());
 }
@@ -167,8 +167,8 @@ static inline double TetraVol(double x1, double y1, double z1, double x2, double
   if(vol < 0) {printf("TET HAS NEGATIVE VOLUME = %g\n", vol);}
   return vol;
 }
-static inline double TetraVol(const DI_Point p1, const DI_Point p2,
-                              const DI_Point p3, const DI_Point p4)
+static inline double TetraVol(const DI_Point &p1, const DI_Point &p2,
+                              const DI_Point &p3, const DI_Point &p4)
 {
   return TetraVol (p1.x(), p1.y(), p1.z(), p2.x(), p2.y(), p2.z(),
                    p3.x(), p3.y(), p3.z(), p4.x(), p4.y(), p4.z());
@@ -273,9 +273,9 @@ class DI_Element
   void getCuttingPoints (const DI_Element *e, const std::vector<const gLevelset *> RPNi,
                          std::vector<DI_CuttingPoint> &cp) const;
   // return the ith point
-  inline DI_Point pt (int i) const {return i < nbVert() ? *pts_[i] : *mid_[i - nbVert()];}
+  inline DI_Point & pt (int i) const {return i < nbVert() ? *pts_[i] : *mid_[i - nbVert()];}
   // return the ith middle point
-  inline DI_Point mid (int i) const {return *mid_[i];}
+  inline DI_Point & mid (int i) const {return *mid_[i];}
   // return the coordinates of the ith point
   inline double x (int i) const {return i < nbVert() ? pts_[i]->x() : mid_[i - nbVert()]->x();}
   inline double y (int i) const {return i < nbVert() ? pts_[i]->y() : mid_[i - nbVert()]->y();}
@@ -322,7 +322,7 @@ class DI_CuttingPoint
   double xl_, yl_, zl_;
   std::vector<double> Ls;
  public:
-  DI_CuttingPoint (const DI_Point pt)
+  DI_CuttingPoint (const DI_Point &pt)
     : x_(pt.x()), y_(pt.y()), z_(pt.z()), xl_(pt.x()), yl_(pt.y()), zl_(pt.z()), Ls(pt.Ls) { }
   inline void addLocC (double xl, double yl, double zl) {xl_ = xl; yl_ = yl; zl_ = zl;}
   inline void move (double x, double y, double z) {x_ = x; y_ = y; z_ = z;}
@@ -377,7 +377,7 @@ class DI_Line : public DI_Element
     pts_[1] = new DI_Point(x1, y1, z1);
     integral_ = length;
   }
-  DI_Line (const DI_Point pt0, const DI_Point pt1, const int tag = -1)
+  DI_Line (const DI_Point &pt0, const DI_Point &pt1, const int tag = -1)
   {
     lsTag_ = tag;
     pts_ = new DI_Point*[2];
@@ -454,7 +454,7 @@ class DI_Triangle : public DI_Element
     pts_[2] = new DI_Point(x2, y2, z2);
     integral_ = surface;
   }
-  DI_Triangle (const DI_Point pt0, const DI_Point pt1, const DI_Point pt2, const int tag = -1)
+  DI_Triangle (const DI_Point &pt0, const DI_Point &pt1, const DI_Point &pt2, const int tag = -1)
   {
     lsTag_ = tag;
     pts_ = new DI_Point*[3];
@@ -548,7 +548,7 @@ class DI_Quad : public DI_Element
     pts_[3] = new DI_Point(x3, y3, z3);
     integral_ = surf;
   }
-  DI_Quad (const DI_Point pt0, const DI_Point pt1, const DI_Point pt2, const DI_Point pt3,
+  DI_Quad (const DI_Point &pt0, const DI_Point &pt1, const DI_Point &pt2, const DI_Point &pt3,
            const int tag = -1)
   {
     lsTag_ = tag;
@@ -644,7 +644,7 @@ class DI_Tetra : public DI_Element
     pts_[3] = new DI_Point(x3, y3, z3);
     integral_ = vol;
   }
-  DI_Tetra (const DI_Point pt0, const DI_Point pt1, const DI_Point pt2, const DI_Point pt3)
+  DI_Tetra (const DI_Point &pt0, const DI_Point &pt1, const DI_Point &pt2, const DI_Point &pt3)
   {
     pts_ = new DI_Point*[4];
     pts_[0] = new DI_Point(pt0);
@@ -756,8 +756,8 @@ class DI_Hexa : public DI_Element
     pts_[6] = new DI_Point(x6, y6, z6); pts_[7] = new DI_Point(x7, y7, z7);
     integral_ = vol;
   }
-  DI_Hexa (const DI_Point pt0, const DI_Point pt1, const DI_Point pt2, const DI_Point pt3,
-           const DI_Point pt4, const DI_Point pt5, const DI_Point pt6, const DI_Point pt7) {
+  DI_Hexa (const DI_Point &pt0, const DI_Point &pt1, const DI_Point &pt2, const DI_Point &pt3,
+           const DI_Point &pt4, const DI_Point &pt5, const DI_Point &pt6, const DI_Point &pt7) {
     pts_ = new DI_Point*[8];
     pts_[0] = new DI_Point(pt0);    pts_[1] = new DI_Point(pt1);
     pts_[2] = new DI_Point(pt2);    pts_[3] = new DI_Point(pt3);
-- 
GitLab