From 0e5a7d87dbbd9d5eb3e401a3fabbaca27f28058e Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 12 Oct 2006 01:35:32 +0000
Subject: [PATCH] prepare for extrusion

---
 Geo/GEdge.cpp   | 35 ++++++++++++++++++-----------------
 Geo/GEdge.h     | 18 +++++++++---------
 Geo/GFace.cpp   | 25 +++++++++++++++----------
 Geo/GFace.h     | 22 +++++++++++-----------
 Geo/GRegion.cpp | 35 ++++++++++++++++++++---------------
 Geo/GRegion.h   | 10 ++++++++--
 Geo/GVertex.cpp |  6 +++++-
 Geo/GVertex.h   |  4 ++--
 8 files changed, 88 insertions(+), 67 deletions(-)

diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp
index de954a6eb5..d18a3275a2 100644
--- a/Geo/GEdge.cpp
+++ b/Geo/GEdge.cpp
@@ -1,4 +1,4 @@
-// $Id: GEdge.cpp,v 1.15 2006-08-26 15:13:22 remacle Exp $
+// $Id: GEdge.cpp,v 1.16 2006-10-12 01:35:32 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -24,25 +24,17 @@
 #include "GEdge.h"
 #include "GmshDefines.h"
 
-void GEdge::addFace(GFace *e)
-{ 
-  l_faces.push_back(e);  
-}
-
-void GEdge::delFace(GFace *e)
-{ 
-  l_faces.erase(std::find(l_faces.begin(), l_faces.end(), e));
-}
-
-GEdge::GEdge(GModel *model, 
-	     int tag, 
-	     GVertex *_v0, 
-	     GVertex *_v1)
+GEdge::GEdge(GModel *model, int tag, GVertex *_v0, GVertex *_v1)
   : GEntity(model, tag), v0(_v0), v1(_v1)
 {
   if(v0) v0->addEdge(this);
   if(v1) v1->addEdge(this);
+
   meshAttributes.Method = LIBRE; 
+  meshAttributes.coeffTransfinite = 0.;
+  meshAttributes.nbPointsTransfinite = 0;
+  meshAttributes.typeTransfinite = 0;
+  meshAttributes.extrude = 0;
 }
 
 GEdge::~GEdge() 
@@ -59,6 +51,16 @@ GEdge::~GEdge()
   lines.clear();
 }
 
+void GEdge::addFace(GFace *e)
+{ 
+  l_faces.push_back(e);  
+}
+
+void GEdge::delFace(GFace *e)
+{ 
+  l_faces.erase(std::find(l_faces.begin(), l_faces.end(), e));
+}
+
 SBoundingBox3d GEdge::bounds() const
 {
   Range<double> tr = parBounds(0);
@@ -109,10 +111,9 @@ std::string GEdge::getAdditionalInfoString()
   return std::string(tmp);
 }
 
-
-/// use central differences
 SVector3 GEdge::secondDer(double par) const 
 {
+  // use central differences
   const double eps = 1.e-3;
   SVector3 x1 = firstDer(par-eps);
   SVector3 x2 = firstDer(par+eps);
diff --git a/Geo/GEdge.h b/Geo/GEdge.h
index 3b242c5098..209376b878 100644
--- a/Geo/GEdge.h
+++ b/Geo/GEdge.h
@@ -26,6 +26,7 @@
 #include "SPoint3.h"
 #include "SPoint2.h"
 #include "MElement.h"
+#include "ExtrudeParams.h"
 
 // A model edge.
 class GEdge : public GEntity {
@@ -34,14 +35,11 @@ class GEdge : public GEntity {
   std::list<GFace *> l_faces;
 
  public:
-  GEdge(GModel *model, 
-	int tag, 
-	GVertex *_v0, 
-	GVertex *_v1);
-  virtual ~GEdge() ;
+  GEdge(GModel *model, int tag, GVertex *_v0, GVertex *_v1);
+  virtual ~GEdge();
 
-  GVertex *getBeginVertex () const { return v0; }
-  GVertex *getEndVertex () const { return v1; }
+  GVertex *getBeginVertex() const { return v0; }
+  GVertex *getEndVertex() const { return v1; }
 
   void addFace(GFace *f);
   void delFace(GFace *f);
@@ -86,10 +84,10 @@ class GEdge : public GEntity {
   void deleteMeshPartitions();
 
   // Returns the minimum number of segments used for meshing the edge
-  virtual int minimumMeshSegments () const {return 1;}
+  virtual int minimumMeshSegments() const {return 1;}
 
   // Returns the minimum number of segments used for drawing the edge
-  virtual int minimumDrawSegments () const {return 1;}
+  virtual int minimumDrawSegments() const {return 1;}
 
   // Returns a type-specific additional information string
   virtual std::string getAdditionalInfoString();
@@ -99,6 +97,8 @@ class GEdge : public GEntity {
     double coeffTransfinite;
     int    nbPointsTransfinite;
     int    typeTransfinite;
+    // the extrusion parameters (if any)
+    ExtrudeParams *extrude;
   } meshAttributes ;
 
   std::vector<MLine*> lines;
diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp
index 252c206793..40baeb4072 100644
--- a/Geo/GFace.cpp
+++ b/Geo/GFace.cpp
@@ -1,4 +1,4 @@
-// $Id: GFace.cpp,v 1.15 2006-08-26 15:13:22 remacle Exp $
+// $Id: GFace.cpp,v 1.16 2006-10-12 01:35:32 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -33,7 +33,16 @@
 void dsvdcmp(double **a, int m, int n, double w[], double **v);
 #endif
 
-GFace::~GFace ()
+GFace::GFace(GModel *model, int tag) : GEntity(model, tag), r1(0), r2(0) 
+{
+  meshAttributes.recombine = 0;
+  meshAttributes.recombineAngle = 0.;
+  meshAttributes.Method = LIBRE;
+  meshAttributes.transfiniteArrangement = 0;
+  meshAttributes.extrude = 0;
+}
+
+GFace::~GFace()
 { 
   std::list<GEdge*>::iterator it = l_edges.begin();
 
@@ -342,17 +351,14 @@ void GFace::getMeanPlaneData(double VX[3], double VY[3],
   z = meanPlane.z;  
 }
 
-// X=X(u,v) Y=Y(u,v) Z=Z(u,v)
-// curv = div n = dnx/dx + dny/dy + dnz/dz
- 
-// dnx/dx = dnx/du du/dx + dnx/dv dv/dx
-
-
 double GFace::curvature (const SPoint2 &param) const
 {
-
   if (geomType() == Plane)return 0;
 
+  // X=X(u,v) Y=Y(u,v) Z=Z(u,v)
+  // curv = div n = dnx/dx + dny/dy + dnz/dz
+  // dnx/dx = dnx/du du/dx + dnx/dv dv/dx
+
   const double eps = 1.e-3;
 
   Pair<SVector3,SVector3> der = firstDer(param) ;
@@ -379,5 +385,4 @@ double GFace::curvature (const SPoint2 &param) const
   //  Msg (INFO,"c = %g detJ %g",c,detJ);
 
   return  c;
- 
 }
diff --git a/Geo/GFace.h b/Geo/GFace.h
index 67447ca4e9..67816a6fb2 100644
--- a/Geo/GFace.h
+++ b/Geo/GFace.h
@@ -26,6 +26,7 @@
 #include "SPoint2.h"
 #include "SVector3.h"
 #include "Pair.h"
+#include "ExtrudeParams.h"
 
 struct mean_plane
 {
@@ -48,10 +49,7 @@ class GFace : public GEntity
   std::list<GVertex *> embedded_vertices;
 
  public:
-  GFace(GModel *model, int tag) : GEntity(model, tag), r1(0), r2(0) 
-    {
-      meshAttributes.recombine = 0;
-    }
+  GFace(GModel *model, int tag);
   virtual ~GFace();
 
   void addRegion(GRegion *r){ r1 ? r2 = r : r1 = r; }
@@ -100,7 +98,7 @@ class GFace : public GEntity
   virtual Pair<SVector3,SVector3> firstDer(const SPoint2 &param) const = 0;
 
   // Return the curvature i.e. the divergence of the normal
-  virtual double curvature (const SPoint2 &param) const;
+  virtual double curvature(const SPoint2 &param) const;
   
   // True if the surface underlying the face is periodic and we need
   // to worry about that.
@@ -132,16 +130,18 @@ class GFace : public GEntity
 
   struct {
     // do we recombine the triangles of the mesh ?
-    int    recombine;
+    int recombine;
     // what is the treshold angle for recombination
     double recombineAngle;
     // is this surface meshed using a transfinite interpolation
-    int   Method;
+    int Method;
     // these are the 3 corners of the interpolation
-    std::vector<GVertex* > corners;
-    // all diagonals of the triangulation are left (1), right (2)
-    // or alternated (3)
-    int    transfiniteArrangement;
+    std::vector<GVertex*> corners;
+    // all diagonals of the triangulation are left (1), right (2) or
+    // alternated (3)
+    int transfiniteArrangement;
+    // the extrusion parameters (if any)
+    ExtrudeParams *extrude;
   } meshAttributes ;
 
 };
diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp
index 9273ded37e..0b80245989 100644
--- a/Geo/GRegion.cpp
+++ b/Geo/GRegion.cpp
@@ -1,4 +1,4 @@
-// $Id: GRegion.cpp,v 1.11 2006-09-11 15:23:54 remacle Exp $
+// $Id: GRegion.cpp,v 1.12 2006-10-12 01:35:32 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -23,7 +23,13 @@
 #include "GRegion.h"
 #include "GFace.h"
 
-GRegion::~GRegion ()
+GRegion::GRegion(GModel *model, int tag) : GEntity (model, tag)
+{
+  meshAttributes.Method = LIBRE; 
+  meshAttributes.extrude = 0;
+}
+
+GRegion::~GRegion()
 { 
   std::list<GFace*>::iterator it = l_faces.begin();
   while(it != l_faces.end()){
@@ -110,22 +116,21 @@ void GRegion::deleteMeshPartitions()
   for(unsigned int i = 0; i < pyramids.size(); i++)
     pyramids[i]->setPartition(0);
 }
-std::list<GEdge*>  GRegion::edges() const
+
+std::list<GEdge*> GRegion::edges() const
 {
   std::list<GEdge*> e;
   std::list<GFace *>::const_iterator it =  l_faces.begin();
-  while (it != l_faces.end())
-    {
-      std::list<GEdge*> e2;
-      e2 = (*it)->edges();
-      std::list<GEdge*>::const_iterator it2 = e2.begin();
-      while (it2 != e2.end())
-	{
-	  if (std::find(e.begin(),e.end(),*it2) == e.end())
-	    e.push_back(*it2);
-	  ++it2;
-	}
-      ++it;
+  while(it != l_faces.end()){
+    std::list<GEdge*> e2;
+    e2 = (*it)->edges();
+    std::list<GEdge*>::const_iterator it2 = e2.begin();
+    while (it2 != e2.end()){
+      if (std::find(e.begin(),e.end(),*it2) == e.end())
+	e.push_back(*it2);
+      ++it2;
     }
+    ++it;
+  }
   return e;
 }
diff --git a/Geo/GRegion.h b/Geo/GRegion.h
index 2e0fe1d484..c593fc7919 100644
--- a/Geo/GRegion.h
+++ b/Geo/GRegion.h
@@ -22,6 +22,7 @@
 
 #include "GEntity.h"
 #include "MElement.h"
+#include "ExtrudeParams.h"
 
 // A model region.
 class GRegion : public GEntity {
@@ -30,7 +31,7 @@ class GRegion : public GEntity {
   std::list<int> l_dirs;
 
  public:
-  GRegion(GModel *model, int tag) : GEntity (model, tag) {}
+  GRegion(GModel *model, int tag);
   virtual ~GRegion();
 
   virtual int dim() const {return 3;}
@@ -38,7 +39,6 @@ class GRegion : public GEntity {
   virtual std::list<GFace*> faces() const{return l_faces;}
   virtual std::list<GEdge*> edges() const;
   void set(std::list<GFace*> &f) {l_faces= f;}
-  
 
   // The bounding box
   virtual SBoundingBox3d bounds() const; 
@@ -49,6 +49,12 @@ class GRegion : public GEntity {
   // Delete the mesh partitions defined on this region.
   void deleteMeshPartitions();
 
+  struct {
+    char   Method;
+    // the extrusion parameters (if any)
+    ExtrudeParams *extrude;
+  } meshAttributes ;
+
   std::vector<MTetrahedron*> tetrahedra;
   std::vector<MHexahedron*> hexahedra;
   std::vector<MPrism*> prisms;
diff --git a/Geo/GVertex.cpp b/Geo/GVertex.cpp
index 7fa491d8a6..a8574f9097 100644
--- a/Geo/GVertex.cpp
+++ b/Geo/GVertex.cpp
@@ -1,4 +1,4 @@
-// $Id: GVertex.cpp,v 1.5 2006-08-15 06:26:52 geuzaine Exp $
+// $Id: GVertex.cpp,v 1.6 2006-10-12 01:35:32 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -22,6 +22,10 @@
 #include "GVertex.h"
 #include <algorithm>
 
+GVertex::GVertex(GModel *m, int tag) : GEntity (m, tag) 
+{
+}
+
 GVertex::~GVertex()
 {
   for(unsigned int i = 0; i < mesh_vertices.size(); i++)
diff --git a/Geo/GVertex.h b/Geo/GVertex.h
index 8cf5a43a03..f93b341686 100644
--- a/Geo/GVertex.h
+++ b/Geo/GVertex.h
@@ -31,8 +31,8 @@ class GVertex : public GEntity
   std::list<GEdge*> l_edges;
 
  public:
-  GVertex(GModel *m, int tag) : GEntity (m, tag) {}
-  virtual ~GVertex() ;
+  GVertex(GModel *m, int tag);
+  virtual ~GVertex();
   virtual GPoint point() const = 0;
   virtual double x() const = 0;
   virtual double y() const = 0;
-- 
GitLab