From 96fd1bd5917b5137113571825f2b0ffe4a5f4a65 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 26 Sep 2006 01:05:44 +0000
Subject: [PATCH] use MVertex::distance + better check in writePOS

---
 Geo/GModelIO.cpp | 10 ++++++----
 Geo/MElement.cpp | 16 ++++------------
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/Geo/GModelIO.cpp b/Geo/GModelIO.cpp
index 962f6b4092..ee1d3fa573 100644
--- a/Geo/GModelIO.cpp
+++ b/Geo/GModelIO.cpp
@@ -1,4 +1,4 @@
-// $Id: GModelIO.cpp,v 1.56 2006-09-23 02:48:09 geuzaine Exp $
+// $Id: GModelIO.cpp,v 1.57 2006-09-26 01:05:43 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -680,7 +680,9 @@ int GModel::writePOS(const std::string &name, double scalingFactor)
     return 0;
   }
 
-  if(numRegion()){
+  int status = getMeshStatus();
+
+  if(status >= 3){
     fprintf(fp, "View \"Volumes\" {\n");
     fprintf(fp, "T2(1.e5,30,%d){\"Elementary Entity\", \"Element Number\", "
 	    "\"Gamma\", \"Eta\", \"Rho\"};\n", (1<<16)|(4<<8));
@@ -697,7 +699,7 @@ int GModel::writePOS(const std::string &name, double scalingFactor)
     fprintf(fp, "};\n");
   }
   
-  if(numFace()){
+  if(status >= 2){
     fprintf(fp, "View \"Surfaces\" {\n");
     fprintf(fp, "T2(1.e5,30,%d){\"Elementary Entity\", \"Element Number\", "
 	    "\"Gamma\", \"Eta\", \"Rho\"};\n", (1<<16)|(4<<8));
@@ -710,7 +712,7 @@ int GModel::writePOS(const std::string &name, double scalingFactor)
     fprintf(fp, "};\n");
   }
 
-  if(numEdge()){
+  if(status >= 1){
     fprintf(fp, "View \"Lines\" {\n");
     fprintf(fp, "T2(1.e5,30,%d){\"Elementary Entity\", \"Element Number\", "
 	    "\"Gamma\", \"Eta\", \"Rho\"};\n", (1<<16)|(4<<8));
diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp
index 3950b2a0bb..5eeb4cb1cf 100644
--- a/Geo/MElement.cpp
+++ b/Geo/MElement.cpp
@@ -1,4 +1,4 @@
-// $Id: MElement.cpp,v 1.20 2006-09-10 15:36:15 geuzaine Exp $
+// $Id: MElement.cpp,v 1.21 2006-09-26 01:05:44 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -26,20 +26,12 @@
 
 int MElement::_globalNum = 0;
 
-static double dist(MVertex *v1, MVertex *v2)
-{
-  double dx = v1->x() - v2->x();
-  double dy = v1->y() - v2->y();
-  double dz = v1->z() - v2->z();
-  return sqrt(dx * dx + dy * dy + dz * dz);
-}
-
 double MElement::minEdge()
 {
   double m = 1.e25;
   for(int i = 0; i < getNumEdges(); i++){
     MEdge e = getEdge(i);
-    m = std::min(m, dist(e.getVertex(0), e.getVertex(1)));
+    m = std::min(m, e.getVertex(0)->distance(e.getVertex(1)));
   }
   return m;
 }
@@ -49,7 +41,7 @@ double MElement::maxEdge()
   double m = 0.;
   for(int i = 0; i < getNumEdges(); i++){
     MEdge e = getEdge(i);
-    m = std::max(m, dist(e.getVertex(0), e.getVertex(1)));
+    m = std::max(m, e.getVertex(0)->distance(e.getVertex(1)));
   }
   return m;
 }
@@ -83,7 +75,7 @@ double MTetrahedron::etaShapeMeasure()
   double lij2 = 0.;
   for(int i = 0; i <= 3; i++) {
     for(int j = i + 1; j <= 3; j++) {
-      double lij = dist(_v[i], _v[j]);
+      double lij = _v[i]->distance(_v[j]);
       lij2 += lij * lij;
     }
   }
-- 
GitLab