From 9721781be7f519326a07db58c885212703423df7 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 1 Feb 2010 14:23:54 +0000
Subject: [PATCH] better detection of zero-length lines

---
 Geo/Geo.cpp                   |  8 --------
 Mesh/meshGEdge.cpp            | 13 +++++++++----
 benchmarks/stl/artery_GEO.geo |  0
 doc/VERSIONS.txt              |  8 +++++---
 4 files changed, 14 insertions(+), 15 deletions(-)
 create mode 100644 benchmarks/stl/artery_GEO.geo

diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp
index 944db841d3..e96b5896ec 100644
--- a/Geo/Geo.cpp
+++ b/Geo/Geo.cpp
@@ -523,14 +523,6 @@ Curve *Create_Curve(int Num, int Typ, int Order, List_T *Liste,
     pC->k = NULL;
 
   if(Liste) {
-    if(Typ == MSH_SEGM_LINE && List_Nbr(Liste) == 2){
-      int iPnt0, iPnt1;
-      List_Read(Liste, 0, &iPnt0);
-      List_Read(Liste, 1, &iPnt1);
-      if(iPnt0 == iPnt1)
-        Msg::Error("Zero-length straight line from point %d to point %d",
-                   iPnt0, iPnt1);
-    }
     pC->Control_Points = List_Create(List_Nbr(Liste), 1, sizeof(Vertex *));
     for(int j = 0; j < List_Nbr(Liste); j++) {
       int iPnt;
diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp
index 78b5cc06cc..b7d9e2b349 100644
--- a/Mesh/meshGEdge.cpp
+++ b/Mesh/meshGEdge.cpp
@@ -267,16 +267,21 @@ void meshGEdge::operator() (GEdge *ge)
   double t_end = bounds.high();
   
   // first compute the length of the curve by integrating one
+  double length;
   std::vector<IntPoint> Points;
-  double length = Integration(ge, t_begin, t_end, F_One, Points, 1.e-8 * CTX::instance()->lc);
+  if(ge->geomType() == GEntity::Line && ge->getBeginVertex() == ge->getEndVertex())
+    length = 0.; // special case t avoid infinite loop in integration
+  else
+    length = Integration(ge, t_begin, t_end, F_One, Points, 1.e-8 * CTX::instance()->lc);
   ge->setLength(length);
   Points.clear();
 
-  if(length == 0.0)
+  if(length == 0. && CTX::instance()->mesh.toleranceEdgeLength == 0.)
+    Msg::Error("Curve %d has a zero length", ge->tag());
+  else
     Msg::Debug("Curve %d has a zero length", ge->tag());
 
-  // TEST
-  if (length < CTX::instance()->mesh.toleranceEdgeLength) ge->setTooSmall(true);
+  if(length < CTX::instance()->mesh.toleranceEdgeLength) ge->setTooSmall(true);
 
   // Integrate detJ/lc du 
   double a;
diff --git a/benchmarks/stl/artery_GEO.geo b/benchmarks/stl/artery_GEO.geo
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/doc/VERSIONS.txt b/doc/VERSIONS.txt
index 315f901055..e5a5f39ebb 100644
--- a/doc/VERSIONS.txt
+++ b/doc/VERSIONS.txt
@@ -1,6 +1,8 @@
-2.4.3 (?): new client/server visualization mode; new option to force
-the type of views dynamically; small bug fixes and usability
-improvements.
+2.5.0 (?): new client/server visualization mode; new compound
+geometrical entities (useful for remeshing); new option to force the
+type of views dynamically; bumped mesh version format to 2.2 (change
+in the meaning of the partion tags; this only affect partioned
+meshes); small bug fixes and usability improvements.
 
 2.4.2 (Sep 21, 2009): solver code refactoring + better IDE
 integration.
-- 
GitLab