From 3dda2bc79cde24fcf38654064d2d0234a9c2899f Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sun, 26 Nov 2006 04:36:46 +0000
Subject: [PATCH] some initial steps before reimplemeting extrusion

---
 Geo/GFace.h                |  1 -
 Geo/gmshFace.cpp           | 24 +++++++-------
 Mesh/Makefile              |  3 +-
 Mesh/meshGFace.cpp         | 29 ++---------------
 Mesh/meshGFace.h           | 49 ++++++++++++----------------
 Mesh/meshGFaceExtruded.cpp | 67 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 104 insertions(+), 69 deletions(-)
 create mode 100644 Mesh/meshGFaceExtruded.cpp

diff --git a/Geo/GFace.h b/Geo/GFace.h
index 6666e8c091..a4daf11ab3 100644
--- a/Geo/GFace.h
+++ b/Geo/GFace.h
@@ -29,7 +29,6 @@
 #include "Pair.h"
 #include "ExtrudeParams.h"
 
-
 struct mean_plane
 {
   double plan[3][3];
diff --git a/Geo/gmshFace.cpp b/Geo/gmshFace.cpp
index adc962d18e..eb9ef81592 100644
--- a/Geo/gmshFace.cpp
+++ b/Geo/gmshFace.cpp
@@ -1,4 +1,4 @@
-// $Id: gmshFace.cpp,v 1.23 2006-11-25 18:03:49 geuzaine Exp $
+// $Id: gmshFace.cpp,v 1.24 2006-11-26 04:36:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -69,19 +69,17 @@ gmshFace::gmshFace(GModel *m, Surface *face)
   meshAttributes.recombine = s->Recombine;
   meshAttributes.recombineAngle = s->RecombineAngle;
   meshAttributes.Method = s->Method;
-  if (s->Method == TRANSFINI)
-    {
-      meshAttributes.Method = s->Method;
-      meshAttributes.transfiniteArrangement = s->Recombine_Dir;
-      for (int i=0;i< List_Nbr(s->TrsfPoints);i++)
-	{
-	  Vertex *corn;
-	  List_Read(s->TrsfPoints, i, &corn);
-	  GVertex *gv = m->vertexByTag(corn->Num);
-	  if(!gv) throw;
-	  meshAttributes.corners.push_back(gv);
-	}
+  meshAttributes.extrude = s->Extrude;
+  if(meshAttributes.Method == TRANSFINI){
+    meshAttributes.transfiniteArrangement = s->Recombine_Dir;
+    for(int i = 0; i < List_Nbr(s->TrsfPoints); i++){
+      Vertex *corn;
+      List_Read(s->TrsfPoints, i, &corn);
+      GVertex *gv = m->vertexByTag(corn->Num);
+      if(!gv) throw;
+      meshAttributes.corners.push_back(gv);
     }
+  }
 }
 
 gmshFace::gmshFace(GModel *m, int num)
diff --git a/Mesh/Makefile b/Mesh/Makefile
index efa522f1b0..b290d039e8 100644
--- a/Mesh/Makefile
+++ b/Mesh/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.146 2006-11-26 01:17:13 geuzaine Exp $
+# $Id: Makefile,v 1.147 2006-11-26 04:36:46 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -34,6 +34,7 @@ SRC = Generator.cpp \
         meshGEdge.cpp \
         meshGFace.cpp \
           meshGFaceTransfinite.cpp \
+          meshGFaceExtruded.cpp \
         meshGRegion.cpp \
           meshGRegionDelaunayInsertion.cpp \
       DivideAndConquer.cpp \
diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp
index 5042c59421..76ddc0ad9a 100644
--- a/Mesh/meshGFace.cpp
+++ b/Mesh/meshGFace.cpp
@@ -1,4 +1,4 @@
-// $Id: meshGFace.cpp,v 1.31 2006-11-26 01:03:17 geuzaine Exp $
+// $Id: meshGFace.cpp,v 1.32 2006-11-26 04:36:46 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -80,19 +80,6 @@ public :
   }
 };
 
-fromParametricToCartesian::fromParametricToCartesian ( GFace *_gf )  
-  : gf(_gf)
-{
-}
-
-void fromParametricToCartesian::operator () (MVertex * v)
-{
-  GPoint coords =  gf->point (SPoint2(v->x(),v->y()));
-  v->x() = coords.x();  
-  v->y() = coords.y();
-  v->z() = coords.z();
-} 
-
 void computeEdgeLoops (const GFace *gf,
 		       std::vector<MVertex*> & all_mvertices,
 		       std::vector<int> &indices)
@@ -880,9 +867,6 @@ void gmsh2DMeshGenerator ( GFace *gf )
   delete [] Y_;
   delete [] Z_;
 
-  //  fromParametricToCartesian p2c ( gf );
-  //  std::for_each(all_vertices.begin(),all_vertices.end(),p2c);    
-  //  std::for_each(gf->mesh_vertices.begin(),gf->mesh_vertices.end(),p2c);    
 }
 
 // this function buils a list of vertices (BDS) that 
@@ -1366,21 +1350,14 @@ void meshGFace :: operator() (GFace *gf)
 {  
   if(gf->geomType() == GEntity::DiscreteSurface) return;
 
-  // Send a messsage to the GMSH environment
   Msg(STATUS2, "Meshing surface %d (%s)", gf->tag(),gf->getTypeString().c_str());
 
-  // TEST TEST 
-  //  if (gf->surfPeriodic(2)) return;
-
   // destroy the mesh if it exists
   deMeshGFace dem;
   dem(gf);
 
-  // Only apply this technique to unknown surfaces or planar surfaces
-  // when it is unknown, try your best ...
-
-  if (MeshTransfiniteSurface(gf))return;
-
+  if(MeshTransfiniteSurface(gf)) return;
+  if(MeshExtrudedSurface(gf)) return;
 
   std::vector<MVertex*> points;
   std::vector<int> indices;
diff --git a/Mesh/meshGFace.h b/Mesh/meshGFace.h
index a214c5957a..192723ace1 100644
--- a/Mesh/meshGFace.h
+++ b/Mesh/meshGFace.h
@@ -21,47 +21,40 @@
 // Please report all bugs and problems to <gmsh@geuz.org>.
 
 #include <vector>
+
 class MVertex;
 class GFace;
-// compute edge loops of the face, all_mvertices
-// are the vertices of the 
-void computeEdgeLoops (const GFace *gf,
-		       std::vector<MVertex*> & all_mvertices,
-		       std::vector<int> &indices);
-
-int MeshTransfiniteSurface( GFace *gf);
-
-class fromParametricToCartesian
-{
-  GFace *gf;
-public :
-  fromParametricToCartesian ( GFace *_gf ) ; 
-  void operator () (MVertex * v);
-};    
 
 // Create the mesh of the face
-class meshGFace 
-{
-  public :
-  void operator () ( GFace * );
+class meshGFace {
+ public :
+  void operator () (GFace *);
 };
 
-// destroy the mesh of the face
-class deMeshGFace 
-{
+// Destroy the mesh of the face
+class deMeshGFace {
  public :
-  void operator () ( GFace * );
+  void operator () (GFace *);
 };
 
 // Orient the mesh of a face to match the orientation of the
-// underlying geometry (this is doubly useful: 1) some surface mesh
-// algorithms do not respect the original geometrical orientation and
+// underlying geometry. This is doubly useful: 
+// 1) some surface mesh algorithms do not respect the original
+//    geometrical orientation and
 // 2) some volume algorithms need to change the surface mesh
-// orientation)
-class orientMeshGFace 
-{
+//    orientation
+class orientMeshGFace {
   public :
   void operator () ( GFace * );
 };
 
+// Compute edge loops of the face, all_mvertices are the vertices of
+// the
+void computeEdgeLoops(const GFace *gf,
+		      std::vector<MVertex*> &all_mvertices,
+		      std::vector<int> &indices);
+
+int MeshTransfiniteSurface(GFace *gf);
+int MeshExtrudedSurface(GFace *gf);
+
 #endif
diff --git a/Mesh/meshGFaceExtruded.cpp b/Mesh/meshGFaceExtruded.cpp
new file mode 100644
index 0000000000..4d81462be3
--- /dev/null
+++ b/Mesh/meshGFaceExtruded.cpp
@@ -0,0 +1,67 @@
+// $Id: meshGFaceExtruded.cpp,v 1.1 2006-11-26 04:36:46 geuzaine Exp $
+//
+// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+// 
+// Please report all bugs and problems to <gmsh@geuz.org>.
+
+#include <map>
+#include "ExtrudeParams.h"
+#include "meshGFace.h"
+#include "GVertex.h"
+#include "GEdge.h"
+#include "GFace.h"
+#include "MVertex.h"
+#include "MElement.h"
+#include "Context.h"
+#include "Message.h"
+
+int MeshExtrudedSurface(GFace *gf)
+{
+  ExtrudeParams *ep = gf->meshAttributes.extrude;
+
+  if(!ep || !ep->mesh.ExtrudeMesh)
+    return false;
+
+  Msg(GERROR, "Extrusion has yet to be reinterfaced!");
+
+  if(ep->geo.Mode == EXTRUDED_ENTITY) {
+    // extruded from a curve
+    /*
+    c = FindCurve(abs(ep->geo.Source));
+    if(!c)
+      return false;
+    for(int i = 0; i < List_Nbr(c->Vertices); i++) {
+      List_Read(c->Vertices, i, &v1);
+      Extrude_Vertex(&v1, NULL);
+    }
+    Extrude_Curve(&c, NULL);
+    */
+  }
+  else {
+    // this is the "hat" of an extruded surface
+    /*
+    source = FindSurface(ep->geo.Source);
+    if(!source)
+      return false;
+    copy_mesh(ss, s);
+    */
+  }
+
+  return 1;
+}
+  
-- 
GitLab