From 3df71aed32c1b8d17c1c89a90672f52aa1f521ee Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 20 Jan 2007 14:06:39 +0000 Subject: [PATCH] *** empty log message *** --- Geo/Geo.cpp | 9 +-- Geo/Geo.h | 25 ++---- Mesh/meshGFace.cpp | 189 +++++++++++++++++++------------------------- Parser/Gmsh.tab.cpp | 2 +- Parser/Gmsh.yy.cpp | 4 +- 5 files changed, 92 insertions(+), 137 deletions(-) diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp index 70107c0ba8..b2136d6a1c 100644 --- a/Geo/Geo.cpp +++ b/Geo/Geo.cpp @@ -1,4 +1,4 @@ -// $Id: Geo.cpp,v 1.70 2007-01-17 08:14:23 geuzaine Exp $ +// $Id: Geo.cpp,v 1.71 2007-01-20 14:06:36 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -1298,13 +1298,6 @@ Curve *CreateReversedCurve(Curve * c) } } -void ModifyLcPoint(int ip, double lc) -{ - Vertex *v = FindPoint(ip); - if(v) - v->lc = lc; -} - int recognize_seg(int typ, List_T * liste, int *seg) { int i, beg, end; diff --git a/Geo/Geo.h b/Geo/Geo.h index eadead0e11..b4485bf95d 100644 --- a/Geo/Geo.h +++ b/Geo/Geo.h @@ -57,7 +57,7 @@ #define MSH_PHYSICAL_VOLUME 330 struct Coord{ - double X,Y,Z; + double X, Y, Z; }; class Vertex { @@ -66,16 +66,7 @@ class Vertex { char Visible; double lc, u, us[3], w; Coord Pos; - Vertex() - { - Visible = 1; - Pos.X = 0.0; - Pos.Y = 0.0; - Pos.Z = 0.0; - w = 1.0; - lc = 1.0; - } - Vertex(double X,double Y,double Z=0.0, double l=1.0, double W=1.0) + Vertex(double X=0., double Y=0., double Z=0., double l=1., double W=1.) { Visible = 1; Pos.X = X; @@ -87,14 +78,13 @@ class Vertex { void norme() { double d = sqrt(Pos.X * Pos.X + Pos.Y * Pos.Y + Pos.Z * Pos.Z); - if(d == 0.0) - return; + if(d == 0.0) return; Pos.X /= d; Pos.Y /= d; Pos.Z /= d; } - Vertex operator %(Vertex & autre) - { // cross product + Vertex operator % (Vertex & autre) // cross product + { return Vertex(Pos.Y * autre.Pos.Z - Pos.Z * autre.Pos.Y, -(Pos.X * autre.Pos.Z - Pos.Z * autre.Pos.X), Pos.X * autre.Pos.Y - Pos.Y * autre.Pos.X, lc, w); @@ -223,14 +213,13 @@ int comparePhysicalGroup(const void *a, const void *b); Vertex *Create_Vertex(int Num, double X, double Y, double Z, double lc, double u); Curve *Create_Curve(int Num, int Typ, int Order, List_T * Liste, List_T * Knots, int p1, int p2, double u1, double u2); +Curve *CreateReversedCurve(Curve *c); Surface *Create_Surface(int Num, int Typ); Volume *Create_Volume(int Num, int Typ); EdgeLoop *Create_EdgeLoop(int Num, List_T * intlist); SurfaceLoop *Create_SurfaceLoop(int Num, List_T * intlist); PhysicalGroup *Create_PhysicalGroup(int Num, int typ, List_T * intlist); -Curve *CreateReversedCurve(Curve *c); - void End_Curve(Curve * c); void End_Surface(Surface * s, int reset_orientations=1); @@ -259,8 +248,6 @@ SurfaceLoop *FindSurfaceLoop(int inum); Volume *FindVolume(int inum); PhysicalGroup *FindPhysicalGroup(int inum, int type); -void ModifyLcPoint(int ip, double lc); - void TranslateShapes(double X,double Y,double Z, List_T *ListShapes, int final); void DilatShapes(double X,double Y,double Z, double A, diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 25c2c953e3..b39ad0026f 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1,4 +1,4 @@ -// $Id: meshGFace.cpp,v 1.52 2007-01-19 15:34:05 geuzaine Exp $ +// $Id: meshGFace.cpp,v 1.53 2007-01-20 14:06:37 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -37,75 +37,70 @@ extern Context_T CTX; -void computeEdgeLoops (const GFace *gf, - std::vector<MVertex*> & all_mvertices, - std::vector<int> &indices) +void computeEdgeLoops(const GFace *gf, + std::vector<MVertex*> &all_mvertices, + std::vector<int> &indices) { - { - std::list<GEdge*> edges = gf->edges(); - std::list<int> ori = gf->orientations(); - std::list<GEdge*>::iterator it = edges.begin(); - std::list<int>::iterator ito = ori.begin(); + std::list<GEdge*> edges = gf->edges(); + std::list<int> ori = gf->orientations(); + std::list<GEdge*>::iterator it = edges.begin(); + std::list<int>::iterator ito = ori.begin(); - indices.push_back(0); - GVertex *start = ((*ito) == 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); - GVertex *v_end = ((*ito) != 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); - all_mvertices.push_back(start->mesh_vertices[0]); - if (*ito == 1) - for (unsigned int i=0;i<(*it)->mesh_vertices.size();i++) + indices.push_back(0); + GVertex *start = ((*ito) == 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); + GVertex *v_end = ((*ito) != 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); + all_mvertices.push_back(start->mesh_vertices[0]); + if (*ito == 1) + for (unsigned int i=0;i<(*it)->mesh_vertices.size();i++) + all_mvertices.push_back((*it)->mesh_vertices[i]); + else + for (int i=(*it)->mesh_vertices.size()-1;i>=0;i--) + all_mvertices.push_back((*it)->mesh_vertices[i]); + + GVertex *v_start = start; + while(1){ + ++it; + ++ito; + if(v_end == start){ + indices.push_back(all_mvertices.size()); + if(it == edges.end ()) break; + start = ((*ito) == 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); + v_end = ((*ito) != 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); + v_start = start; + } + else{ + if(it == edges.end ()) throw; + v_start = ((*ito) == 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); + if(v_start != v_end) throw; + v_end = ((*ito) != 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); + } + all_mvertices.push_back(v_start->mesh_vertices[0]); + if(*ito == 1) + for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) all_mvertices.push_back((*it)->mesh_vertices[i]); else - for (int i=(*it)->mesh_vertices.size()-1;i>=0;i--) + for (int i = (*it)->mesh_vertices.size()-1; i >= 0; i--) all_mvertices.push_back((*it)->mesh_vertices[i]); - - GVertex *v_start = start; - while(1) - { - ++it; - ++ito; - if (v_end == start) - { - indices.push_back(all_mvertices.size()); - if (it == edges.end ())break; - start = ((*ito) == 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); - v_end = ((*ito) != 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); - v_start = start; - } - else - { - if (it == edges.end ())throw; - v_start = ((*ito) == 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); - if(v_start != v_end)throw; - v_end = ((*ito) != 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex(); - } - all_mvertices.push_back(v_start->mesh_vertices[0]); - if (*ito == 1) - for (unsigned int i=0;i<(*it)->mesh_vertices.size();i++) - all_mvertices.push_back((*it)->mesh_vertices[i]); - else - for (int i=(*it)->mesh_vertices.size()-1;i>=0;i--) - all_mvertices.push_back((*it)->mesh_vertices[i]); - } - } - + } } extern double F_LC_ANALY (double xx, double yy, double zz); -double NewGetLc ( BDS_Point *p ) +double NewGetLc(BDS_Point *p) { return p->lc(); } -inline double computeEdgeLinearLength ( BDS_Point *p1, BDS_Point *p2) +inline double computeEdgeLinearLength(BDS_Point *p1, BDS_Point *p2) { const double dx = p1->X-p2->X; const double dy = p1->Y-p2->Y; const double dz = p1->Z-p2->Z; - const double l = sqrt (dx*dx+dy*dy+dz*dz); + const double l = sqrt(dx*dx+dy*dy+dz*dz); return l; } -inline double computeParametricEdgeLength ( BDS_Point *p1, BDS_Point *p2) + +inline double computeParametricEdgeLength(BDS_Point *p1, BDS_Point *p2) { const double dx = p1->u-p2->u; const double dy = p1->v-p2->v; @@ -113,85 +108,65 @@ inline double computeParametricEdgeLength ( BDS_Point *p1, BDS_Point *p2) return l; } -double NewGetLc ( BDS_Edge *e ) +double NewGetLc(BDS_Edge *e) { double linearLength = e->length(); - double l1 = NewGetLc ( e->p1 ); - double l2 = NewGetLc ( e->p2 ); + double l1 = NewGetLc(e->p1); + double l2 = NewGetLc(e->p2); return 2*linearLength / (l1 + l2); } - bool edgeSwapTest(BDS_Edge *e) { - BDS_Point *op[2]; - - if (!e->p1->config_modified && ! e->p2->config_modified) return false; + BDS_Point *op[2]; + + if(!e->p1->config_modified && ! e->p2->config_modified) return false; - if (e->numfaces() != 2)return false; + if(e->numfaces() != 2) return false; e->oppositeof (op); double edgeLength1, edgeLength2; edgeLength1 = e->length(); - edgeLength2 = computeEdgeLinearLength ( op[0],op[1]); - double lp1 = NewGetLc ( e->p1 ); - double lp2 = NewGetLc ( e->p1 ); - double lo1 = NewGetLc ( op[0] ); - double lo2 = NewGetLc ( op[1] ); + edgeLength2 = computeEdgeLinearLength(op[0], op[1]); + double lp1 = NewGetLc(e->p1); + double lp2 = NewGetLc(e->p1); + double lo1 = NewGetLc(op[0]); + double lo2 = NewGetLc(op[1]); - double el1 = 2*edgeLength1 / ( lp1 + lp2 ); - double el2 = 2*edgeLength2 / ( lo1 + lo2 ); + double el1 = 2*edgeLength1 / (lp1 + lp2); + double el2 = 2*edgeLength2 / (lo1 + lo2); - double q1 = fabs (1-el1); - double q2 = fabs (1-el2); + double q1 = fabs(1-el1); + double q2 = fabs(1-el2); return q2 < 0.5*q1; -// BDS_Point *op[2]; - -// if (e->numfaces() != 2)return false; - -// e->oppositeof (op); - -// double qa1 = quality_triangle ( e->p1 , e->p2 , op[0] ); -// double qa2 = quality_triangle ( e->p1 , e->p2 , op[1] ); -// double qb1 = quality_triangle ( e->p1 , op[0] , op[1] ); -// double qb2 = quality_triangle ( e->p2 , op[0] , op[1] ); -// double qa = (qa1<qa2)?qa1:qa2; -// double qb = (qb1<qb2)?qb1:qb2; - -// return (qb > 1.1*qa); } - - int edgeSwapTestQuality(BDS_Edge *e, double fact = 1.1) { - BDS_Point *op[2]; - - if (!e->p1->config_modified && ! e->p2->config_modified) return false; - - if (e->numfaces() != 2)return false; - - e->oppositeof (op); + BDS_Point *op[2]; - double qa1 = quality_triangle ( e->p1 , e->p2 , op[0] ); - double qa2 = quality_triangle ( e->p1 , e->p2 , op[1] ); - double qb1 = quality_triangle ( e->p1 , op[0] , op[1] ); - double qb2 = quality_triangle ( e->p2 , op[0] , op[1] ); - double qa = (qa1<qa2)?qa1:qa2; - double qb = (qb1<qb2)?qb1:qb2; - if (qb > fact*qa) return 1; - if (qb < qa/fact) return -1; - return 0; - + if(!e->p1->config_modified && ! e->p2->config_modified) return false; + + if(e->numfaces() != 2) return false; + + e->oppositeof (op); + + double qa1 = quality_triangle(e->p1, e->p2, op[0]); + double qa2 = quality_triangle(e->p1, e->p2, op[1]); + double qb1 = quality_triangle(e->p1, op[0], op[1]); + double qb2 = quality_triangle(e->p2, op[0], op[1]); + double qa = (qa1<qa2) ? qa1 : qa2; + double qb = (qb1<qb2) ? qb1 : qb2; + if(qb > fact*qa) return 1; + if(qb < qa/fact) return -1; + return 0; } - - -void OptimizeMesh ( GFace *gf, BDS_Mesh &m , const int NIT) +void OptimizeMesh(GFace *gf, BDS_Mesh &m, const int NIT) { // optimize for(int i = 0 ; i < NIT ; i++){ @@ -1445,9 +1420,9 @@ void orientMeshGFace::operator()(GFace *gf) { if(gf->geomType() == GEntity::ProjectionSurface) return; - // orientation of opencascade surfaces are not consistent with - // orientation of bounding edges: should do something else - //if(gf->getNativeType() == GEntity::OpenCascadeModel) return; + // surface orientions in OCC are not consistent with the orientation + // of the bounding edges, so just leave them unchanged: + if(gf->getNativeType() == GEntity::OpenCascadeModel) return; // in old versions we did not reorient transfinite surface meshes; // we could add the following to provide backward compatibility: diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index 2385de666b..df7c4b088f 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -124,7 +124,7 @@ #line 1 "Gmsh.y" -// $Id: Gmsh.tab.cpp,v 1.296 2007-01-12 08:10:32 geuzaine Exp $ +// $Id: Gmsh.tab.cpp,v 1.297 2007-01-20 14:06:37 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp index b607559387..9a5843b8a1 100644 --- a/Parser/Gmsh.yy.cpp +++ b/Parser/Gmsh.yy.cpp @@ -2,7 +2,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.295 2007-01-12 08:10:32 geuzaine Exp $ + * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.296 2007-01-20 14:06:39 geuzaine Exp $ */ #define FLEX_SCANNER @@ -722,7 +722,7 @@ char *yytext; #line 1 "Gmsh.l" #define INITIAL 0 #line 2 "Gmsh.l" -// $Id: Gmsh.yy.cpp,v 1.295 2007-01-12 08:10:32 geuzaine Exp $ +// $Id: Gmsh.yy.cpp,v 1.296 2007-01-20 14:06:39 geuzaine Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // -- GitLab