Skip to content
Snippets Groups Projects
Commit 5e38696c authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

allow recombine, transfinite and embedding constraints on GModel entities
in parser
parent 9236322d
No related branches found
No related tags found
No related merge requests found
......@@ -91,7 +91,6 @@ Atan2 return tAtan2;
ArcTan2 return tAtan2;
Bezier return tBezier;
Bump return tBump;
BSpline return tBSpline;
BoundingBox return tBoundingBox;
......@@ -165,8 +164,6 @@ Physical return tPhysical;
Pi return tPi;
Plane return tPlane;
Point return tPoint;
Power return tProgression;
Progression return tProgression;
Parametric return tParametric;
PolarSphere return tPolarSphere;
Printf return tPrintf;
......
This diff is collapsed.
......@@ -98,66 +98,64 @@
tComplex = 314,
tPhysical = 315,
tUsing = 316,
tBump = 317,
tProgression = 318,
tPlugin = 319,
tRotate = 320,
tTranslate = 321,
tSymmetry = 322,
tDilate = 323,
tExtrude = 324,
tLoop = 325,
tRecombine = 326,
tSmoother = 327,
tSplit = 328,
tDelete = 329,
tCoherence = 330,
tIntersect = 331,
tLayers = 332,
tHole = 333,
tAlias = 334,
tAliasWithOptions = 335,
tText2D = 336,
tText3D = 337,
tInterpolationScheme = 338,
tTime = 339,
tCombine = 340,
tBSpline = 341,
tBezier = 342,
tNurbs = 343,
tOrder = 344,
tKnots = 345,
tColor = 346,
tColorTable = 347,
tFor = 348,
tIn = 349,
tEndFor = 350,
tIf = 351,
tEndIf = 352,
tExit = 353,
tField = 354,
tReturn = 355,
tCall = 356,
tFunction = 357,
tShow = 358,
tHide = 359,
tGetValue = 360,
tGMSH_MAJOR_VERSION = 361,
tGMSH_MINOR_VERSION = 362,
tGMSH_PATCH_VERSION = 363,
tAFFECTDIVIDE = 364,
tAFFECTTIMES = 365,
tAFFECTMINUS = 366,
tAFFECTPLUS = 367,
tOR = 368,
tAND = 369,
tNOTEQUAL = 370,
tEQUAL = 371,
tGREATEROREQUAL = 372,
tLESSOREQUAL = 373,
UNARYPREC = 374,
tMINUSMINUS = 375,
tPLUSPLUS = 376
tPlugin = 317,
tRotate = 318,
tTranslate = 319,
tSymmetry = 320,
tDilate = 321,
tExtrude = 322,
tLoop = 323,
tRecombine = 324,
tSmoother = 325,
tSplit = 326,
tDelete = 327,
tCoherence = 328,
tIntersect = 329,
tLayers = 330,
tHole = 331,
tAlias = 332,
tAliasWithOptions = 333,
tText2D = 334,
tText3D = 335,
tInterpolationScheme = 336,
tTime = 337,
tCombine = 338,
tBSpline = 339,
tBezier = 340,
tNurbs = 341,
tOrder = 342,
tKnots = 343,
tColor = 344,
tColorTable = 345,
tFor = 346,
tIn = 347,
tEndFor = 348,
tIf = 349,
tEndIf = 350,
tExit = 351,
tField = 352,
tReturn = 353,
tCall = 354,
tFunction = 355,
tShow = 356,
tHide = 357,
tGetValue = 358,
tGMSH_MAJOR_VERSION = 359,
tGMSH_MINOR_VERSION = 360,
tGMSH_PATCH_VERSION = 361,
tAFFECTDIVIDE = 362,
tAFFECTTIMES = 363,
tAFFECTMINUS = 364,
tAFFECTPLUS = 365,
tOR = 366,
tAND = 367,
tNOTEQUAL = 368,
tEQUAL = 369,
tGREATEROREQUAL = 370,
tLESSOREQUAL = 371,
UNARYPREC = 372,
tMINUSMINUS = 373,
tPLUSPLUS = 374
};
#endif
/* Tokens. */
......@@ -220,66 +218,64 @@
#define tComplex 314
#define tPhysical 315
#define tUsing 316
#define tBump 317
#define tProgression 318
#define tPlugin 319
#define tRotate 320
#define tTranslate 321
#define tSymmetry 322
#define tDilate 323
#define tExtrude 324
#define tLoop 325
#define tRecombine 326
#define tSmoother 327
#define tSplit 328
#define tDelete 329
#define tCoherence 330
#define tIntersect 331
#define tLayers 332
#define tHole 333
#define tAlias 334
#define tAliasWithOptions 335
#define tText2D 336
#define tText3D 337
#define tInterpolationScheme 338
#define tTime 339
#define tCombine 340
#define tBSpline 341
#define tBezier 342
#define tNurbs 343
#define tOrder 344
#define tKnots 345
#define tColor 346
#define tColorTable 347
#define tFor 348
#define tIn 349
#define tEndFor 350
#define tIf 351
#define tEndIf 352
#define tExit 353
#define tField 354
#define tReturn 355
#define tCall 356
#define tFunction 357
#define tShow 358
#define tHide 359
#define tGetValue 360
#define tGMSH_MAJOR_VERSION 361
#define tGMSH_MINOR_VERSION 362
#define tGMSH_PATCH_VERSION 363
#define tAFFECTDIVIDE 364
#define tAFFECTTIMES 365
#define tAFFECTMINUS 366
#define tAFFECTPLUS 367
#define tOR 368
#define tAND 369
#define tNOTEQUAL 370
#define tEQUAL 371
#define tGREATEROREQUAL 372
#define tLESSOREQUAL 373
#define UNARYPREC 374
#define tMINUSMINUS 375
#define tPLUSPLUS 376
#define tPlugin 317
#define tRotate 318
#define tTranslate 319
#define tSymmetry 320
#define tDilate 321
#define tExtrude 322
#define tLoop 323
#define tRecombine 324
#define tSmoother 325
#define tSplit 326
#define tDelete 327
#define tCoherence 328
#define tIntersect 329
#define tLayers 330
#define tHole 331
#define tAlias 332
#define tAliasWithOptions 333
#define tText2D 334
#define tText3D 335
#define tInterpolationScheme 336
#define tTime 337
#define tCombine 338
#define tBSpline 339
#define tBezier 340
#define tNurbs 341
#define tOrder 342
#define tKnots 343
#define tColor 344
#define tColorTable 345
#define tFor 346
#define tIn 347
#define tEndFor 348
#define tIf 349
#define tEndIf 350
#define tExit 351
#define tField 352
#define tReturn 353
#define tCall 354
#define tFunction 355
#define tShow 356
#define tHide 357
#define tGetValue 358
#define tGMSH_MAJOR_VERSION 359
#define tGMSH_MINOR_VERSION 360
#define tGMSH_PATCH_VERSION 361
#define tAFFECTDIVIDE 362
#define tAFFECTTIMES 363
#define tAFFECTMINUS 364
#define tAFFECTPLUS 365
#define tOR 366
#define tAND 367
#define tNOTEQUAL 368
#define tEQUAL 369
#define tGREATEROREQUAL 370
#define tLESSOREQUAL 371
#define UNARYPREC 372
#define tMINUSMINUS 373
#define tPLUSPLUS 374
......@@ -297,7 +293,7 @@ typedef union YYSTYPE
List_T *l;
}
/* Line 1529 of yacc.c. */
#line 301 "Gmsh.tab.hpp"
#line 297 "Gmsh.tab.hpp"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
......
......@@ -90,7 +90,7 @@ void FixRelativePath(const char *in, char *out);
%token tPoint tCircle tEllipse tLine tSphere tPolarSphere tSurface tSpline tVolume
%token tCharacteristic tLength tParametric tElliptic
%token tPlane tRuled tTransfinite tComplex tPhysical
%token tUsing tBump tProgression tPlugin
%token tUsing tPlugin
%token tRotate tTranslate tSymmetry tDilate tExtrude
%token tLoop tRecombine tSmoother tSplit tDelete tCoherence tIntersect
%token tLayers tHole tAlias tAliasWithOptions
......@@ -101,8 +101,9 @@ void FixRelativePath(const char *in, char *out);
%token tGMSH_MAJOR_VERSION tGMSH_MINOR_VERSION tGMSH_PATCH_VERSION
%type <d> FExpr FExpr_Single
%type <v> VExpr VExpr_Single
%type <v> VExpr VExpr_Single TransfiniteType
%type <i> NumericAffectation NumericIncrement PhysicalId
%type <i> TransfiniteArrangement
%type <u> ColorExpr
%type <c> StringExpr StringExprVar SendToFile
%type <l> FExpr_Multi ListOfDouble RecursiveListOfDouble
......@@ -2435,124 +2436,114 @@ ExtrudeParameter :
// T R A N S F I N I T E
Transfinite :
tTransfinite tLine ListOfDouble tAFFECT FExpr tEND
TransfiniteType :
{
for(int i = 0; i < List_Nbr($3); i++){
double d;
List_Read($3, i, &d);
int j = (int)fabs(d);
Curve *c = FindCurve(j);
if(!c)
yymsg(1, "Unknown curve %d", j);
else{
c->Method = MESH_TRANSFINITE;
c->nbPointsTransfinite = ($5 > 2) ? (int)$5 : 2;
c->typeTransfinite = sign(d);
c->coeffTransfinite = 1.0;
}
}
List_Delete($3);
$$[0] = $$[1] = 1.;
}
| tTransfinite tLine ListOfDouble tAFFECT FExpr tUsing tProgression FExpr tEND
| tUsing tSTRING FExpr
{
for(int i = 0; i < List_Nbr($3); i++){
double d;
List_Read($3, i, &d);
int j = (int)fabs(d);
Curve *c = FindCurve(j);
if(!c)
yymsg(1, "Unknown curve %d", j);
else{
c->Method = MESH_TRANSFINITE;
c->nbPointsTransfinite = ($5 > 2) ? (int)$5 : 2;
c->typeTransfinite = sign(d); // Progresion : code 1 ou -1
c->coeffTransfinite = fabs($8);
}
if(!strcmp($2, "Progression") || !strcmp($2, "Power"))
$$[0] = 1.;
else if(!strcmp($2, "Bump"))
$$[0] = 2.;
else{
yymsg(0, "Unknown transfinite mesh type");
$$[0] = 1.;
}
List_Delete($3);
$$[1] = $3;
Free($2);
}
;
TransfiniteArrangement :
{
$$ = -1; // left
}
| tSTRING
{
if(!strcmp($1, "Right"))
$$ = 1;
else if(!strcmp($1, "Left"))
$$ = -1;
else // alternated
$$ = 0;
Free($1);
}
| tTransfinite tLine ListOfDouble tAFFECT FExpr tUsing tBump FExpr tEND
;
Transfinite :
tTransfinite tLine ListOfDouble tAFFECT FExpr TransfiniteType tEND
{
int type = (int)$6[0];
double coef = fabs($6[1]);
for(int i = 0; i < List_Nbr($3); i++){
double d;
List_Read($3, i, &d);
int j = (int)fabs(d);
Curve *c = FindCurve(j);
if(!c)
yymsg(1, "Unknown curve %d", j);
else{
if(c){
c->Method = MESH_TRANSFINITE;
c->nbPointsTransfinite = ($5 > 2) ? (int)$5 : 2;
c->typeTransfinite = 2 * sign(d); // Bump : code 2 ou -2
c->coeffTransfinite = fabs($8);
c->typeTransfinite = type * sign(d);
c->coeffTransfinite = coef;
}
else{
GEdge *ge = GModel::current()->getEdgeByTag(j);
if(ge){
ge->meshAttributes.Method = MESH_TRANSFINITE;
ge->meshAttributes.nbPointsTransfinite = ($5 > 2) ? (int)$5 : 2;
ge->meshAttributes.typeTransfinite = sign(d);
ge->meshAttributes.coeffTransfinite = 1.;
}
else
yymsg(0, "Unknown line %d", j);
}
}
List_Delete($3);
}
| tTransfinite tSurface '{' FExpr '}' tAFFECT ListOfDouble tEND
| tTransfinite tSurface '{' FExpr '}' tAFFECT ListOfDouble TransfiniteArrangement tEND
{
Surface *s = FindSurface((int)$4);
if(!s)
yymsg(1, "Unknown surface %d", (int)$4);
else{
s->Method = MESH_TRANSFINITE;
s->Recombine_Dir = -1;
int k = List_Nbr($7);
if(k != 3 && k != 4){
yymsg(0, "Wrong definition of Transfinite Surface %d: "
"%d points instead of 3 or 4" , (int)$4, k);
}
else{
List_Reset(s->TrsfPoints);
for(int i = 0; i < k; i++){
double d;
List_Read($7, i, &d);
int j = (int)fabs(d);
Vertex *v = FindPoint(j);
if(!v)
yymsg(1, "Unknown point %d", j);
else
List_Add(s->TrsfPoints, &v);
}
}
int k = List_Nbr($7);
if(k != 3 && k != 4){
yymsg(0, "Wrong definition of Transfinite Surface %d: "
"%d points instead of 3 or 4" , (int)$4, k);
}
List_Delete($7);
}
| tTransfinite tSurface '{' FExpr '}' tAFFECT ListOfDouble tSTRING tEND
{
Surface *s = FindSurface((int)$4);
if(!s)
yymsg(1, "Unknown surface %d", (int)$4);
else{
s->Method = MESH_TRANSFINITE;
int k = List_Nbr($7);
if(k != 3 && k != 4){
yymsg(0, "Wrong definition of Transfinite Surface %d: "
"%d points instead of 3 or 4" , (int)$4, k);
}
else{
Surface *s = FindSurface((int)$4);
if(s){
s->Method = MESH_TRANSFINITE;
s->Recombine_Dir = $8;
List_Reset(s->TrsfPoints);
if (!strcmp($8, "Right"))
s->Recombine_Dir = 1;
else if (!strcmp($8, "Left"))
s->Recombine_Dir = -1;
else
s->Recombine_Dir = 0;
for(int i = 0; i < k; i++){
double d;
List_Read($7, i, &d);
int j = (int)fabs(d);
Vertex *v = FindPoint(j);
if(!v)
yymsg(1, "Unknown point %d", j);
else
Vertex *v = FindPoint((int)fabs(d));
if(v)
List_Add(s->TrsfPoints, &v);
else
yymsg(0, "Unknown point %d", (int)fabs(d));
}
}
else{
GFace *gf = GModel::current()->getFaceByTag((int)$4);
if(gf){
gf->meshAttributes.Method = MESH_TRANSFINITE;
gf->meshAttributes.transfiniteArrangement = $8;
for(int i = 0; i < k; i++){
double d;
List_Read($7, i, &d);
GVertex *gv = GModel::current()->getVertexByTag((int)fabs(d));
if(gv)
gf->meshAttributes.corners.push_back(gv);
else
yymsg(0, "Unknown point %d", (int)fabs(d));
}
}
else
yymsg(0, "Unknown surface %d", (int)$4);
}
}
List_Delete($7);
Free($8);
}
| tElliptic tSurface '{' FExpr '}' tAFFECT ListOfDouble tEND
{
......@@ -2561,28 +2552,43 @@ Transfinite :
}
| tTransfinite tVolume '{' FExpr '}' tAFFECT ListOfDouble tEND
{
Volume *v = FindVolume((int)$4);
if(!v)
yymsg(1, "Unknown volume %d", (int)$4);
int k = List_Nbr($7);
if(k != 6 && k != 8){
yymsg(0, "Wrong definition of Transfinite Volume %d: "
"%d points instead of 6 or 8" , (int)$4, k);
}
else{
v->Method = MESH_TRANSFINITE;
int k = List_Nbr($7);
if(k != 6 && k != 8)
yymsg(0, "Wrong definition of Transfinite Volume %d: "
"%d points instead of 6 or 8" , (int)$4, k);
else{
Volume *v = FindVolume((int)$4);
if(v){
v->Method = MESH_TRANSFINITE;
List_Reset(v->TrsfPoints);
for(int i = 0; i < k; i++){
double d;
List_Read($7, i, &d);
int j = (int)fabs(d);
Vertex *vert = FindPoint(j);
if(!vert)
yymsg(1, "Unknown point %d", j);
else
Vertex *vert = FindPoint((int)fabs(d));
if(vert)
List_Add(v->TrsfPoints, &vert);
else
yymsg(0, "Unknown point %d", (int)fabs(d));
}
}
else{
GRegion *gr = GModel::current()->getRegionByTag((int)$4);
if(gr){
gr->meshAttributes.Method = MESH_TRANSFINITE;
for(int i = 0; i < k; i++){
double d;
List_Read($7, i, &d);
GVertex *gv = GModel::current()->getVertexByTag((int)fabs(d));
if(gv)
gr->meshAttributes.corners.push_back(gv);
else
yymsg(0, "Unknown point %d", (int)fabs(d));
}
}
else
yymsg(0, "Unknown volume %d", (int)$4);
}
}
List_Delete($7);
}
......@@ -2597,6 +2603,15 @@ Transfinite :
s->Recombine = 1;
s->RecombineAngle = $5;
}
else{
GFace *gf = GModel::current()->getFaceByTag(j);
if(gf){
gf->meshAttributes.recombine = 1;
gf->meshAttributes.recombineAngle = $5;
}
else
yymsg(1, "Unknown surface %d", j);
}
}
List_Delete($3);
}
......@@ -2610,6 +2625,13 @@ Transfinite :
if(s){
s->Recombine = 1;
}
else{
GFace *gf = GModel::current()->getFaceByTag(j);
if(gf)
gf->meshAttributes.recombine = 1;
else
yymsg(1, "Unknown surface %d", j);
}
}
List_Delete($3);
}
......@@ -2620,7 +2642,16 @@ Transfinite :
List_Read($3, i, &d);
int j = (int)d;
Surface *s = FindSurface(j);
if(s) s->TransfiniteSmoothing = (int)$5;
if(s){
s->TransfiniteSmoothing = (int)$5;
}
else{
GFace *gf = GModel::current()->getFaceByTag(j);
if(gf)
gf->meshAttributes.transfiniteSmoothing = (int)$5;
else
yymsg(1, "Unknown surface %d", (int)$5);
}
}
List_Delete($3);
}
......@@ -2633,14 +2664,48 @@ Embedding :
tPoint '{' RecursiveListOfDouble '}' tIn tSurface '{' FExpr '}' tEND
{
Surface *s = FindSurface((int)$8);
if(s)
if(s){
setSurfaceEmbeddedPoints(s, $3);
}
else{
GFace *gf = GModel::current()->getFaceByTag((int)$8);
if(gf){
for(int i = 0; i < List_Nbr($3); i++){
int iPoint;
List_Read($3, i, &iPoint);
GVertex *gv = GModel::current()->getVertexByTag(iPoint);
if(gv)
gf->addEmbeddedVertex(gv);
else
yymsg(0, "Unknown point %d", iPoint);
}
}
else
yymsg(0, "Unknown surface %d", (int)$8);
}
}
| tLine '{' RecursiveListOfDouble '}' tIn tSurface '{' FExpr '}' tEND
{
Surface *s = FindSurface((int)$8);
if(s)
if(s){
setSurfaceEmbeddedCurves(s, $3);
}
else{
GFace *gf = GModel::current()->getFaceByTag((int)$8);
if(gf){
for(int i = 0; i < List_Nbr($3); i++){
int iCurve;
List_Read($3, i, &iCurve);
GEdge *ge = GModel::current()->getEdgeByTag(iCurve);
if(ge)
gf->addEmbeddedEdge(ge);
else
yymsg(0, "Unknown line %d", iCurve);
}
}
else
yymsg(0, "Unknown surface %d", (int)$8);
}
}
| tLine '{' RecursiveListOfDouble '}' tIn tVolume '{' FExpr '}' tEND
{
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment