From eee1eac32a7897c15a6b7563092e7e6bbed4dea1 Mon Sep 17 00:00:00 2001
From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be>
Date: Sat, 23 Feb 2008 16:21:51 +0000
Subject: [PATCH] *** empty log message ***

---
 Geo/GEdge.cpp      |  3 ++-
 Geo/GEdge.h        |  1 +
 Geo/OCCEdge.cpp    |  4 ++--
 Geo/OCCFace.cpp    | 14 +++++++++++---
 Geo/gmshEdge.cpp   | 10 ++++++----
 Geo/gmshFace.cpp   |  7 ++++++-
 Mesh/meshGFace.cpp |  9 ++++++++-
 7 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp
index a939343027..ae46c4e480 100644
--- a/Geo/GEdge.cpp
+++ b/Geo/GEdge.cpp
@@ -1,4 +1,4 @@
-// $Id: GEdge.cpp,v 1.44 2008-02-23 15:40:29 geuzaine Exp $
+// $Id: GEdge.cpp,v 1.45 2008-02-23 16:19:22 remacle Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -73,6 +73,7 @@ void GEdge::resetMeshAttributes()
   meshAttributes.typeTransfinite = 0;
   meshAttributes.extrude = 0;
   meshAttributes.meshSize = 1.e22;
+  meshAttributes.minimumMeshSegments = 1;
 }
 
 void GEdge::addFace(GFace *e)
diff --git a/Geo/GEdge.h b/Geo/GEdge.h
index 869d828824..a44d5504cf 100644
--- a/Geo/GEdge.h
+++ b/Geo/GEdge.h
@@ -124,6 +124,7 @@ class GEdge : public GEntity {
     double meshSize;
     int    nbPointsTransfinite;
     int    typeTransfinite;
+    int   minimumMeshSegments;
     // the extrusion parameters (if any)
     ExtrudeParams *extrude;
   } meshAttributes ;
diff --git a/Geo/OCCEdge.cpp b/Geo/OCCEdge.cpp
index a5083fb13b..c5354020fc 100644
--- a/Geo/OCCEdge.cpp
+++ b/Geo/OCCEdge.cpp
@@ -1,4 +1,4 @@
-// $Id: OCCEdge.cpp,v 1.34 2008-02-17 09:30:28 geuzaine Exp $
+// $Id: OCCEdge.cpp,v 1.35 2008-02-23 16:19:22 remacle Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -210,7 +210,7 @@ int OCCEdge::minimumMeshSegments() const
   // 1D mesh (4 segments, one of which is degenerated)
   if (getBeginVertex() == getEndVertex()) np = std::max(4, np);
 
-  return np;
+  return std::max(np,meshAttributes.minimumMeshSegments);
 }
 
 int OCCEdge::minimumDrawSegments() const
diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp
index b34cadde52..bb6d3d9a64 100644
--- a/Geo/OCCFace.cpp
+++ b/Geo/OCCFace.cpp
@@ -1,4 +1,4 @@
-// $Id: OCCFace.cpp,v 1.37 2008-02-22 21:09:00 geuzaine Exp $
+// $Id: OCCFace.cpp,v 1.38 2008-02-23 16:19:22 remacle Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -65,11 +65,19 @@ OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape
     }      
     
     //    GEdgeLoop el(l_wire,l_oris);
-    GEdgeLoop el(l_wire);
-    
+    GEdgeLoop el(l_wire);        
+
     for(GEdgeLoop::citer it = el.begin() ; it != el.end() ; ++it){
       l_edges.push_back(it->ge);
       l_dirs.push_back(it->_sign);
+      if (el.count() == 2){
+	it->ge->meshAttributes.minimumMeshSegments = 
+	  std::max(it->ge->meshAttributes.minimumMeshSegments,2);
+      }
+      if (el.count() == 1){
+	it->ge->meshAttributes.minimumMeshSegments = 
+	  std::max(it->ge->meshAttributes.minimumMeshSegments,3);
+      }
     }
     
     edgeLoops.push_back(el);
diff --git a/Geo/gmshEdge.cpp b/Geo/gmshEdge.cpp
index eb3d2115b8..9b1b21a347 100644
--- a/Geo/gmshEdge.cpp
+++ b/Geo/gmshEdge.cpp
@@ -1,4 +1,4 @@
-// $Id: gmshEdge.cpp,v 1.45 2008-02-17 09:30:28 geuzaine Exp $
+// $Id: gmshEdge.cpp,v 1.46 2008-02-23 16:21:51 remacle Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -106,13 +106,15 @@ GEntity::GeomType gmshEdge::geomType() const
 
 int gmshEdge::minimumMeshSegments () const
 {
+  int np;
   if(geomType() == Line)
-    return GEdge::minimumMeshSegments();
+    np = GEdge::minimumMeshSegments();
   else if(geomType() == Circle || geomType() == Ellipse)
-    return (int)(fabs(c->Circle.t1 - c->Circle.t2) *
+    np = (int)(fabs(c->Circle.t1 - c->Circle.t2) *
 		 (double)CTX.mesh.min_circ_points / Pi) - 1;
   else
-    return CTX.mesh.min_curv_points - 1;
+    np = CTX.mesh.min_curv_points - 1;
+  return std::max(np,meshAttributes.minimumMeshSegments);
 }
 
 int gmshEdge::minimumDrawSegments () const
diff --git a/Geo/gmshFace.cpp b/Geo/gmshFace.cpp
index 9b610518eb..3027b811ae 100644
--- a/Geo/gmshFace.cpp
+++ b/Geo/gmshFace.cpp
@@ -1,4 +1,4 @@
-// $Id: gmshFace.cpp,v 1.50 2008-02-22 21:09:00 geuzaine Exp $
+// $Id: gmshFace.cpp,v 1.51 2008-02-23 16:19:22 remacle Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -33,10 +33,15 @@ gmshFace::gmshFace(GModel *m, Surface *face)
     Curve *c;
     List_Read(s->Generatrices, i, &c);
     GEdge *e = m->getEdgeByTag(abs(c->Num));
+
     if(e){
       l_edges.push_back(e);
       e->addFace(this);
       l_dirs.push_back((c->Num > 0) ? 1 : -1);
+      if (List_Nbr(s->Generatrices) == 2){
+	e->meshAttributes.minimumMeshSegments = 
+	  std::max(e->meshAttributes.minimumMeshSegments,2);
+      }
     }
     else
       Msg(GERROR, "Unknown curve %d", c->Num);
diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp
index 0e0f158b59..709cfb91d4 100644
--- a/Mesh/meshGFace.cpp
+++ b/Mesh/meshGFace.cpp
@@ -1,4 +1,4 @@
-// $Id: meshGFace.cpp,v 1.121 2008-02-23 15:30:07 geuzaine Exp $
+// $Id: meshGFace.cpp,v 1.122 2008-02-23 16:19:22 remacle Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -446,6 +446,13 @@ bool gmsh2DMeshGenerator(GFace *gf, int RECUR_ITER, bool debug = true)
     doc.points[all_vertices.size() + ip].data = bb[ip];
   }
 
+  // if the number of vertices is less or equal to 2, then no elements are generated
+  if (all_vertices.size() <= 2){
+    free(doc.points);
+    free(doc.delaunay);
+    for(int ip = 0; ip < 4; ip++) delete bb[ip];
+  }
+
   // Use "fast" inhouse recursive algo to generate the triangulation
   // At this stage the triangulation is not what we need
   //   -) It does not necessary recover the boundaries
-- 
GitLab