From 040fa6a3e5b8a80d0f8aba41dca5c960cc742f31 Mon Sep 17 00:00:00 2001
From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be>
Date: Mon, 25 Jun 2001 18:34:59 +0000
Subject: [PATCH] *** empty log message ***

---
 Geo/CAD.cpp         | 14 +++++++++++++-
 Mesh/2D_Mesh.cpp    |  4 +++-
 Mesh/2D_Util.cpp    |  4 ++--
 Mesh/3D_Extrude.cpp | 33 ++++++++++++++++++++++++---------
 4 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/Geo/CAD.cpp b/Geo/CAD.cpp
index ac1fd5de93..75cad6df55 100644
--- a/Geo/CAD.cpp
+++ b/Geo/CAD.cpp
@@ -1,4 +1,4 @@
-// $Id: CAD.cpp,v 1.24 2001-06-07 15:13:08 geuzaine Exp $
+// $Id: CAD.cpp,v 1.25 2001-06-25 18:34:59 remacle Exp $
 
 #include "Gmsh.h"
 #include "Geo.h"
@@ -1258,6 +1258,8 @@ void ReplaceAllDuplicates ( Mesh *m ){
   Volume *vol;
   int i,j,start,end;
 
+  List_T *points2delete = List_Create(100,100,sizeof(Vertex*));
+
   /* Create unique points */
 
   All = Tree2List(m->Points);
@@ -1271,6 +1273,8 @@ void ReplaceAllDuplicates ( Mesh *m ){
     }
     else{
       Tree_Suppress(m->Points,&v);
+      Tree_Suppress(m->Vertices,&v);      
+      //      List_Add(points2delete,&v);      
     }
   }
 
@@ -1396,6 +1400,14 @@ void ReplaceAllDuplicates ( Mesh *m ){
                               List_Pointer(vol->Surfaces,j)));
     }
   }
+
+  for(int k = 0; k < List_Nbr(points2delete);k++)
+    {
+      List_Read(points2delete,i,&v);      
+      Free_Vertex(&v,0);
+    }
+
+
 }
 
 /* NEW CAD FUNCTIONS */
diff --git a/Mesh/2D_Mesh.cpp b/Mesh/2D_Mesh.cpp
index 2ed9ba2226..dbe5d1042b 100644
--- a/Mesh/2D_Mesh.cpp
+++ b/Mesh/2D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_Mesh.cpp,v 1.28 2001-06-25 13:30:57 remacle Exp $
+// $Id: 2D_Mesh.cpp,v 1.29 2001-06-25 18:34:59 remacle Exp $
 
 /*
    Maillage Delaunay d'une surface (Point insertion Technique)
@@ -693,6 +693,8 @@ int mesh_domain (ContourPeek * ListContours, int numcontours,
           break;
         }
       }
+      // MEMORY_LEAK -JF
+      //      Free(del_P);
     }
 
     *numpoints = doc->numPoints;
diff --git a/Mesh/2D_Util.cpp b/Mesh/2D_Util.cpp
index 21e220484c..b7358ee611 100644
--- a/Mesh/2D_Util.cpp
+++ b/Mesh/2D_Util.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_Util.cpp,v 1.10 2001-05-20 19:24:53 geuzaine Exp $
+// $Id: 2D_Util.cpp,v 1.11 2001-06-25 18:34:59 remacle Exp $
 
 #include "Gmsh.h"
 #include "Const.h"
@@ -82,7 +82,7 @@ int Insert_Point (MPoint pt, int *numpoints, int *numalloc,
       gPointArray[*numpoints].quality = MIN(find_quality(pt,BGM),qual);
     else 
       gPointArray[*numpoints].quality = qual;
-    Free(v);
+    Free_Vertex(&v,0);
   }
     
   (*numpoints)++;
diff --git a/Mesh/3D_Extrude.cpp b/Mesh/3D_Extrude.cpp
index 9d5153640d..c4dc60197e 100644
--- a/Mesh/3D_Extrude.cpp
+++ b/Mesh/3D_Extrude.cpp
@@ -1,4 +1,4 @@
-// $Id: 3D_Extrude.cpp,v 1.10 2001-06-07 14:20:08 remacle Exp $
+// $Id: 3D_Extrude.cpp,v 1.11 2001-06-25 18:34:59 remacle Exp $
 
 #include "Gmsh.h"
 #include "Const.h"
@@ -16,7 +16,7 @@ static int TEST_IS_ALL_OK;
 static Surface *THES;
 static Volume *THEV;
 static ExtrudeParams *ep;
-static Tree_T *Vertex_Bound, *ToAdd = NULL;
+static Tree_T *Vertex_Bound = NULL, *ToAdd = NULL;
 
 typedef struct{
   int a, b;
@@ -42,6 +42,19 @@ void InitExtrude (){
     Tree_Ares = Tree_Create (sizeof (nxn), compnxn);
   if (!Tree_Swaps)
     Tree_Swaps = Tree_Create (sizeof (nxn), compnxn);
+  if(Vertex_Bound)
+    Tree_Delete(Vertex_Bound);
+  Vertex_Bound = Tree_Create (sizeof (Vertex *), comparePosition);
+  List_T *l1 = Tree2List (THEM->Points);
+  List_T *l2 = Tree2List (THEM->Vertices);
+
+  for(int i=0;i<List_Nbr(l1);i++)Tree_Insert(Vertex_Bound,List_Pointer(l1,i));
+  for(int i=0;i<List_Nbr(l2);i++)Tree_Insert(Vertex_Bound,List_Pointer(l2,i));
+
+  List_Delete(l1);
+  List_Delete(l2);
+
+  //Vertex_Bound = THEM->Vertices;
 }
 
 /* MEMORY LEAK JF */
@@ -325,8 +338,9 @@ void Extrude_Vertex (void *data, void *dum){
 
   pV = (Vertex **) data;
   v = *pV;
-  if (v->Extruded_Points)
-    List_Delete (v->Extruded_Points);
+  // BUG FOR MULTIPLE POINTS IN EXTRUSION
+  if (v->Extruded_Points)return;
+  //    List_Delete (v->Extruded_Points);
   v->Extruded_Points = List_Create (ep->mesh.NbLayer, 1, sizeof (Vertex *));
   List_Add (v->Extruded_Points, &v);
 
@@ -346,6 +360,7 @@ void Extrude_Vertex (void *data, void *dum){
       else{
         List_Add (v->Extruded_Points, &newv);
         Tree_Insert (THEM->Vertices, &newv);
+        Tree_Insert (Vertex_Bound, &newv);
         if (ToAdd)
           Tree_Insert (ToAdd, &newv);
       }
@@ -437,10 +452,12 @@ int Extrude_Mesh (Curve * c){
   if (!c->Extrude->mesh.ExtrudeMesh)
     return false;
 
-  Vertex_Bound = NULL;
+  InitExtrude();
+
+  //  Vertex_Bound = NULL;
   ep = c->Extrude;
 
-  Tree_Ares = Tree_Swaps = NULL;
+  //  Tree_Ares = Tree_Swaps = NULL;
 
   if (ep->geo.Mode == EXTRUDED_ENTITY){
     Extrude_Vertex (&c->beg, NULL);
@@ -576,7 +593,7 @@ int Extrude_Mesh (Surface * s){
   if (!s->Extrude->mesh.ExtrudeMesh)
     return false;
   FACE_DIMENSION = 2;
-  Vertex_Bound = Tree_Create (sizeof (Vertex *), comparePosition);
+  //  Vertex_Bound = Tree_Create (sizeof (Vertex *), comparePosition);
 
   ep = s->Extrude;
   THES = s;
@@ -621,8 +638,6 @@ int Extrude_Mesh (Volume * v){
   if (!v->Extrude->mesh.ExtrudeMesh)
     return false;
 
-  Vertex_Bound = Tree_Create (sizeof (Vertex *), comparePosition);
-
   ep = v->Extrude;
   THEV = v;
   if (ep->geo.Mode == EXTRUDED_ENTITY){
-- 
GitLab