From 7bc700b666a18d62a0c633b021b3c4a629daa487 Mon Sep 17 00:00:00 2001
From: Tristan Carrier Baudouin <tristan.carrier@uclouvain.be>
Date: Thu, 9 Jun 2011 08:04:42 +0000
Subject: [PATCH] lpcvt

---
 Mesh/BackgroundMesh.h        |  2 ++
 Mesh/meshGFaceLloyd.cpp      | 12 +++++++-----
 Numeric/DivideAndConquer.cpp |  3 +++
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/Mesh/BackgroundMesh.h b/Mesh/BackgroundMesh.h
index 393b1eb349..103bb924b8 100644
--- a/Mesh/BackgroundMesh.h
+++ b/Mesh/BackgroundMesh.h
@@ -9,6 +9,7 @@
 #include "STensor3.h"
 #include "simpleFunction.h"
 #include <vector>
+#include <list>
 
 class MElementOctree;
 class GFace;
@@ -71,5 +72,6 @@ bool Extend1dMeshIn2dSurfaces();
 bool Extend2dMeshIn3dVolumes();
 SMetric3 max_edge_curvature_metric(const GVertex *gv, double &l);
 SMetric3 max_edge_curvature_metric(const GEdge *ge, double u, double &l);
+void replaceMeshCompound(GFace*,std::list<GEdge*>&);
 
 #endif
diff --git a/Mesh/meshGFaceLloyd.cpp b/Mesh/meshGFaceLloyd.cpp
index 8712e771ae..c9b7d225d0 100644
--- a/Mesh/meshGFaceLloyd.cpp
+++ b/Mesh/meshGFaceLloyd.cpp
@@ -323,11 +323,13 @@ void smoothing::optimize_face(GFace* gf){
   w.set_max(2*ITER_MAX);
   w.set_triangulator(&triangulator);
   w.set_octree(octree);
-	
-  minlbfgscreate(2*num_interior,4,x,state);
-  minlbfgssetcond(state,epsg,epsf,epsx,maxits);
-  minlbfgsoptimize(state,callback,NULL,&w);
-  minlbfgsresults(state,x,rep);
+
+  if(num_interior>0){
+    minlbfgscreate(2*num_interior,4,x,state);
+    minlbfgssetcond(state,epsg,epsf,epsx,maxits);
+    minlbfgsoptimize(state,callback,NULL,&w);
+    minlbfgsresults(state,x,rep);
+  }
 
   /*lpcvt obj2;
   SPoint2 val = obj2.seed(triangulator,gf);
diff --git a/Numeric/DivideAndConquer.cpp b/Numeric/DivideAndConquer.cpp
index c00acdd004..2ab5ea79d1 100644
--- a/Numeric/DivideAndConquer.cpp
+++ b/Numeric/DivideAndConquer.cpp
@@ -19,6 +19,7 @@
 #include "DivideAndConquer.h"
 #include "Numeric.h"
 #include "robustPredicates.h"
+#include "BackgroundMesh.h"
 
 // FIXME: should not introduce dependencies to Geo/ code in Numeric
 #include "GPoint.h"
@@ -935,6 +936,7 @@ void DocRecord::concave(double x,double y,GFace* gf){
   std::set<int>::iterator it2;
   
   list = gf->edges();
+  replaceMeshCompound(gf,list);
   for(it1=list.begin();it1!=list.end();it1++){
 	edge = *it1;
 	for(i=0;i<edge->getNumMeshElements();i++){
@@ -1076,6 +1078,7 @@ bool DocRecord::delaunay_conformity(GFace* gf){
   std::list<GEdge*>::iterator it;
 	
   list = gf->edges();
+  replaceMeshCompound(gf,list);
   for(it=list.begin();it!=list.end();it++){
     edge = *it;
 	for(i=0;i<edge->getNumMeshElements();i++){
-- 
GitLab