From bc387133f563ffb56500fbd29880c1e9080d91dd Mon Sep 17 00:00:00 2001
From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be>
Date: Wed, 12 Feb 2003 09:20:42 +0000
Subject: [PATCH] added ReadImg.* into Graphics modified Makefiles (now
 libfltk_images.a is used) This is a beta version of image loading with gmsh

---
 Graphics/Makefile           |  3 ++-
 Mesh/2D_Mesh_Aniso.cpp      | 11 +++++++++--
 Mesh/3D_Mesh.cpp            | 14 +++++++-------
 Parser/OpenFile.cpp         | 27 +++++++++++++++++++++++----
 Parser/OpenFile.h           |  2 +-
 benchmarks/2d/Square-01.geo |  4 ++--
 benchmarks/2d/Square-02.geo |  2 +-
 7 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/Graphics/Makefile b/Graphics/Makefile
index 63827eef9b..92e8e1d360 100644
--- a/Graphics/Makefile
+++ b/Graphics/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.42 2003-02-11 08:54:56 geuzaine Exp $
+# $Id: Makefile,v 1.43 2003-02-12 09:20:41 remacle Exp $
 
 include ../variables
 
@@ -14,6 +14,7 @@ SRC = Draw.cpp \
       PostElement.cpp \
       Iso.cpp \
       Entity.cpp \
+      ReadImg.cpp \
       Visibility.cpp \
       Scale.cpp \
       Graph2D.cpp \
diff --git a/Mesh/2D_Mesh_Aniso.cpp b/Mesh/2D_Mesh_Aniso.cpp
index 28dbf78949..4487040ac9 100644
--- a/Mesh/2D_Mesh_Aniso.cpp
+++ b/Mesh/2D_Mesh_Aniso.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_Mesh_Aniso.cpp,v 1.30 2003-01-23 20:19:21 geuzaine Exp $
+// $Id: 2D_Mesh_Aniso.cpp,v 1.31 2003-02-12 09:20:41 remacle Exp $
 //
 // Copyright (C) 1997 - 2003 C. Geuzaine, J.-F. Remacle
 //
@@ -69,10 +69,17 @@ static int ZONEELIMINEE, Methode = 0;
 static double volume;
 static List_T *coquille;
 static Edge *THEEDGE;
-
+extern void LCBGM (double X, double Y, double Z, double *l);
 double Interpole_lcTriangle (Simplex * s, Vertex * vv){
   double Xp, Yp, X[3], Y[3], det, u, v, q1, q2, q3;
 
+  if (THEM->BGM.Typ == ONFILE)
+    {
+      double LL;
+      LCBGM (vv->Pos.X,vv->Pos.Y,0.0,&LL);
+      return LL * CTX.mesh.lc_factor;
+    }
+
   Xp = vv->Pos.X;
   Yp = vv->Pos.Y;
 
diff --git a/Mesh/3D_Mesh.cpp b/Mesh/3D_Mesh.cpp
index 268c600b3e..7545871b72 100644
--- a/Mesh/3D_Mesh.cpp
+++ b/Mesh/3D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 3D_Mesh.cpp,v 1.45 2003-01-23 20:19:22 geuzaine Exp $
+// $Id: 3D_Mesh.cpp,v 1.46 2003-02-12 09:20:41 remacle Exp $
 //
 // Copyright (C) 1997 - 2003 C. Geuzaine, J.-F. Remacle
 //
@@ -48,7 +48,7 @@ extern int         FACE_DIMENSION;
 
 static Tree_T *Tsd, *Sim_Sur_Le_Bord, *POINTS_TREE;
 static List_T *Simplexes_Destroyed, *Simplexes_New, *Suppress;
-static List_T *LLL, *POINTS;
+static List_T *LLL, *POINTS_LIST;
 static Simplex *THES;
 static Vertex *THEV;
 static Tree_T *SimXFac;
@@ -125,7 +125,7 @@ void add_points (void *a, void *b){
 }
 
 void add_points_2 (void *a, void *b){
-  List_Add (POINTS, a);
+  List_Add (POINTS_LIST, a);
 }
 
 
@@ -769,7 +769,7 @@ void Convex_Hull_Mesh (List_T * Points, Mesh * m){
       THEV->Pos.Z -= dz;          
       if(count > 5){
         N++;
-        List_Add(POINTS,&THEV);
+        List_Add(POINTS_LIST,&THEV);
         Msg(WARNING, "Unable to add point %d (will try it later)", THEV->Num);
         break;
       }
@@ -865,7 +865,7 @@ void Maillage_Volume (void *data, void *dum){
     s = &S;
     
     POINTS_TREE = Tree_Create (sizeof (Vertex *), comparePosition);
-    POINTS = List_Create (100, 100, sizeof (Vertex *));
+    POINTS_LIST = List_Create (100, 100, sizeof (Vertex *));
     LOCAL->Simplexes = v->Simplexes;
     LOCAL->Vertices = v->Vertices;
     
@@ -876,7 +876,7 @@ void Maillage_Volume (void *data, void *dum){
     Tree_Action (POINTS_TREE, add_points_2);
     Tree_Delete (POINTS_TREE);
     
-    N = List_Nbr (POINTS);
+    N = List_Nbr (POINTS_LIST);
     n = N / 30 + 1;
 
     if(!N) return;
@@ -885,7 +885,7 @@ void Maillage_Volume (void *data, void *dum){
     
     Msg(STATUS2, "Mesh 3D... (initial)");
     
-    Convex_Hull_Mesh (POINTS, LOCAL);
+    Convex_Hull_Mesh (POINTS_LIST, LOCAL);
     
     if(!Coherence (v, LOCAL)) 
       Msg(GERROR, "Surface recovery failed (send a bug report with the geo file to <gmsh@geuz.org>!)");
diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp
index 007151c1b4..597ea5d591 100644
--- a/Parser/OpenFile.cpp
+++ b/Parser/OpenFile.cpp
@@ -1,4 +1,4 @@
-// $Id: OpenFile.cpp,v 1.37 2003-02-11 09:18:48 geuzaine Exp $
+// $Id: OpenFile.cpp,v 1.38 2003-02-12 09:20:41 remacle Exp $
 //
 // Copyright (C) 1997 - 2003 C. Geuzaine, J.-F. Remacle
 //
@@ -30,6 +30,7 @@
 #include "Views.h"
 #include "MinMax.h"
 #include "Visibility.h"
+#include "ReadImg.h"
 
 #ifndef _BLACKBOX
 #include "GmshUI.h"
@@ -105,8 +106,24 @@ void ParseString(char *str){
   }
 }
 
-void MergeProblem(char *name){
-  ParseFile(name,0);  
+
+int MergeProblem(char *name){
+
+  char ext[5];
+
+  strncpy (ext,&name[strlen(name)-4],5);
+  /// a jpg file is used as an inpu, we transform it onto 
+  /// a post pro file that could be used as a background mesh
+
+  if(!strcmp(ext,".ppm") ||!strcmp(ext,".pnm"))
+    {
+      read_pnm (name);
+      return 1;
+    }
+  else
+    {
+      return ParseFile(name,0);  
+    }
 }
 
 void MergeProblemWithBoundingBox(char *name){
@@ -146,6 +163,7 @@ void OpenProblem(char *name){
      !strcmp(ext,".msh") || !strcmp(ext,".MSH") ||
      !strcmp(ext,".stl") || !strcmp(ext,".STL") ||
      !strcmp(ext,".sms") || !strcmp(ext,".SMS") ||
+     !strcmp(ext,".ppm") || !strcmp(ext,".pnm") ||
      !strcmp(ext,".pos") || !strcmp(ext,".POS")){
     CTX.base_filename[strlen(name)-4] = '\0';
   }
@@ -161,7 +179,8 @@ void OpenProblem(char *name){
 
   int nb = List_Nbr(CTX.post.list);
 
-  int status = ParseFile(CTX.filename,0);
+  int status = MergeProblem(CTX.filename);
+    //ParseFile(CTX.filename,0);
 
   ApplyLcFactor(THEM);
 
diff --git a/Parser/OpenFile.h b/Parser/OpenFile.h
index 602e471c72..f076bbb5f8 100644
--- a/Parser/OpenFile.h
+++ b/Parser/OpenFile.h
@@ -25,7 +25,7 @@
 int  ParseFile(char *filename, int silent);
 void ParseString(char *str);
 void OpenProblem(char *filename);
-void MergeProblem(char *filename);
+int MergeProblem(char *filename);
 void MergeProblemWithBoundingBox(char *filename);
 void SystemCall(char *command);
 
diff --git a/benchmarks/2d/Square-01.geo b/benchmarks/2d/Square-01.geo
index 4f234fc01a..9d91879787 100644
--- a/benchmarks/2d/Square-01.geo
+++ b/benchmarks/2d/Square-01.geo
@@ -12,5 +12,5 @@ Line(3) = {1,4};
 Line(4) = {4,3};       
 Line Loop(5) = {1,2,3,4};       
 Plane Surface(6) = {5};       
-Attractor Point{2} = {0.05,0.05,2};
-Mesh.Algorithm = 2;
+//Attractor Point{2} = {0.05,0.05,2};
+//Mesh.Algorithm = 2;
diff --git a/benchmarks/2d/Square-02.geo b/benchmarks/2d/Square-02.geo
index d1b5976cd6..f781bd1dba 100644
--- a/benchmarks/2d/Square-02.geo
+++ b/benchmarks/2d/Square-02.geo
@@ -3,7 +3,7 @@ Square non uniformly
 meshed  
 ******************************/  
 lc = .1;   
-Point(1) = {0.0,0.0,0,lc*.1};   
+Point(1) = {0.0,0.0,0,lc*.01};   
 Point(2) = {1,0.0,0,lc};   
 Point(3) = {1,1,0,lc};   
 Point(4) = {0,1,0,lc};   
-- 
GitLab