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

access to all point/line/surface/reg nums in parser to make definition of

compounds, transfinite, etc. easier
parent 80647d7b
No related branches found
No related tags found
No related merge requests found
...@@ -875,6 +875,80 @@ PhysicalGroup *FindPhysicalGroup(int num, int type) ...@@ -875,6 +875,80 @@ PhysicalGroup *FindPhysicalGroup(int num, int type)
return NULL; return NULL;
} }
static void GetAllEntityNumbers(int dim, std::set<int> &nums)
{
GModel *m = GModel::current();
switch(dim){
case 0:
{
List_T *l = Tree2List(m->getGEOInternals()->Points);
Vertex *p;
for(int i = 0; i < List_Nbr(l); i++){
List_Read(l, i, &p);
nums.insert(p->Num);
}
List_Delete(l);
for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); it++)
nums.insert((*it)->tag());
}
break;
case 1:
{
List_T *l = Tree2List(m->getGEOInternals()->Curves);
Curve *p;
for(int i = 0; i < List_Nbr(l); i++){
List_Read(l, i, &p);
if(p->Num >= 0)
nums.insert(p->Num);
}
List_Delete(l);
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++){
if((*it)->tag() >= 0)
nums.insert((*it)->tag());
}
}
break;
case 2:
{
List_T *l = Tree2List(m->getGEOInternals()->Surfaces);
Surface *p;
for(int i = 0; i < List_Nbr(l); i++){
List_Read(l, i, &p);
nums.insert(p->Num);
}
List_Delete(l);
for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++)
nums.insert((*it)->tag());
}
break;
case 3:
{
List_T *l = Tree2List(m->getGEOInternals()->Volumes);
Volume *p;
for(int i = 0; i < List_Nbr(l); i++){
List_Read(l, i, &p);
nums.insert(p->Num);
}
List_Delete(l);
for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++)
nums.insert((*it)->tag());
}
break;
}
}
List_T *GetAllEntityNumbers(int dim)
{
std::set<int> nums;
GetAllEntityNumbers(dim, nums);
List_T *l = List_Create(nums.size(), 1, sizeof(double));
for(std::set<int>::iterator it = nums.begin(); it != nums.end(); it++){
double a = *it;
List_Add(l, &a);
}
return l;
}
static void CopyVertex(Vertex *v, Vertex *vv) static void CopyVertex(Vertex *v, Vertex *vv)
{ {
vv->lc = v->lc; vv->lc = v->lc;
......
...@@ -271,6 +271,7 @@ SurfaceLoop *FindSurfaceLoop(int inum); ...@@ -271,6 +271,7 @@ SurfaceLoop *FindSurfaceLoop(int inum);
Volume *FindVolume(int inum); Volume *FindVolume(int inum);
LevelSet *FindLevelSet(int inum); LevelSet *FindLevelSet(int inum);
PhysicalGroup *FindPhysicalGroup(int inum, int type); PhysicalGroup *FindPhysicalGroup(int inum, int type);
List_T *GetAllEntityNumbers(int dim);
void TranslateShapes(double X,double Y,double Z, List_T *shapes); void TranslateShapes(double X,double Y,double Z, List_T *shapes);
void DilatShapes(double X,double Y,double Z, double A, List_T *shapes); void DilatShapes(double X,double Y,double Z, double A, List_T *shapes);
......
...@@ -257,7 +257,8 @@ static void getEdgeVertices(GEdge *ge, MElement *ele, std::vector<MVertex*> &ve, ...@@ -257,7 +257,8 @@ static void getEdgeVertices(GEdge *ge, MElement *ele, std::vector<MVertex*> &ve,
if(reparamOK){ if(reparamOK){
double relax = 1.; double relax = 1.;
while (1){ while (1){
if(computeEquidistantParameters(ge, std::min(u0,u1), std::max(u0,u1), nPts + 2, US, relax)) if(computeEquidistantParameters(ge, std::min(u0,u1), std::max(u0,u1),
nPts + 2, US, relax))
break; break;
relax /= 2.0; relax /= 2.0;
if(relax < 1.e-2) if(relax < 1.e-2)
...@@ -265,7 +266,8 @@ static void getEdgeVertices(GEdge *ge, MElement *ele, std::vector<MVertex*> &ve, ...@@ -265,7 +266,8 @@ static void getEdgeVertices(GEdge *ge, MElement *ele, std::vector<MVertex*> &ve,
} }
if(relax < 1.e-2) if(relax < 1.e-2)
Msg::Warning Msg::Warning
("Failed to compute equidistant parameters (relax = %g, value = %g) for edge %d-%d parametrized with %g %g on GEdge %d", ("Failed to compute equidistant parameters (relax = %g, value = %g) "
"for edge %d-%d parametrized with %g %g on GEdge %d",
relax, US[1], v0->getNum(), v1->getNum(),u0,u1,ge->tag()); relax, US[1], v0->getNum(), v1->getNum(),u0,u1,ge->tag());
} }
} }
...@@ -283,8 +285,8 @@ static void getEdgeVertices(GEdge *ge, MElement *ele, std::vector<MVertex*> &ve, ...@@ -283,8 +285,8 @@ static void getEdgeVertices(GEdge *ge, MElement *ele, std::vector<MVertex*> &ve,
} }
else { else {
GPoint pc = ge->point(US[u0<u1? j + 1 : nPts - 1 - (j + 1)]); GPoint pc = ge->point(US[u0<u1? j + 1 : nPts - 1 - (j + 1)]);
v = new MEdgeVertex(pc.x(), pc.y(), pc.z(), ge, US[u0<u1? j + 1 : nPts - 1 - (j + 1)]); v = new MEdgeVertex(pc.x(), pc.y(), pc.z(), ge,
US[u0 < u1 ? j + 1 : nPts - 1 - (j + 1)]);
if (displ2D || displ3D){ if (displ2D || displ3D){
SPoint3 pc2 = edge.interpolate(t); SPoint3 pc2 = edge.interpolate(t);
if (displ2D)displ2D->add(v, SVector3(pc2.x(), pc2.y(), pc2.z())); if (displ2D)displ2D->add(v, SVector3(pc2.x(), pc2.y(), pc2.z()));
...@@ -540,15 +542,30 @@ static void reorientQuadPoints(std::vector<MVertex*> &vtcs, int orientation, ...@@ -540,15 +542,30 @@ static void reorientQuadPoints(std::vector<MVertex*> &vtcs, int orientation,
int p1 = indices[iEdge]; int p1 = indices[iEdge];
int p2 = indices[(iEdge+1)%4]; int p2 = indices[(iEdge+1)%4];
int nbP = order-1; int nbP = order-1;
if (p1 == 0 && p2 == 1){for (int i=4+0*nbP;i< 4+1*nbP;i++) tmp[index++] = vtcs[i];} if (p1 == 0 && p2 == 1){
else if (p1 == 1 && p2 == 2){for (int i=4+1*nbP;i< 4+2*nbP;i++) tmp[index++] = vtcs[i];} for (int i = 4+0*nbP; i < 4+1*nbP; i++) tmp[index++] = vtcs[i];
else if (p1 == 2 && p2 == 3){for (int i=4+2*nbP;i< 4+3*nbP;i++) tmp[index++] = vtcs[i];} }
else if (p1 == 3 && p2 == 0){for (int i=4+3*nbP;i< 4+4*nbP;i++) tmp[index++] = vtcs[i];} else if (p1 == 1 && p2 == 2){
for (int i = 4+1*nbP; i< 4+2*nbP; i++) tmp[index++] = vtcs[i];
else if (p1 == 1 && p2 == 0){for (int i=4+1*nbP-1;i>= 4+0*nbP;i--) tmp[index++] = vtcs[i];} }
else if (p1 == 2 && p2 == 1){for (int i=4+2*nbP-1;i>= 4+1*nbP;i--) tmp[index++] = vtcs[i];} else if (p1 == 2 && p2 == 3){
else if (p1 == 3 && p2 == 2){for (int i=4+3*nbP-1;i>= 4+2*nbP;i--) tmp[index++] = vtcs[i];} for (int i = 4+2*nbP; i< 4+3*nbP; i++) tmp[index++] = vtcs[i];
else if (p1 == 0 && p2 == 3){for (int i=4+4*nbP-1;i>= 4+3*nbP;i--) tmp[index++] = vtcs[i];} }
else if (p1 == 3 && p2 == 0){
for (int i = 4+3*nbP; i< 4+4*nbP; i++) tmp[index++] = vtcs[i];
}
else if (p1 == 1 && p2 == 0){
for (int i = 4+1*nbP-1; i >= 4+0*nbP; i--) tmp[index++] = vtcs[i];
}
else if (p1 == 2 && p2 == 1){
for (int i = 4+2*nbP-1; i >= 4+1*nbP; i--) tmp[index++] = vtcs[i];
}
else if (p1 == 3 && p2 == 2){
for (int i = 4+3*nbP-1; i >= 4+2*nbP; i--) tmp[index++] = vtcs[i];
}
else if (p1 == 0 && p2 == 3){
for (int i = 4+4*nbP-1; i >= 4+3*nbP; i--) tmp[index++] = vtcs[i];
}
else printf("ouuls\n"); else printf("ouuls\n");
} }
for (int i=0;i<index;i++)vtcs[start+4+i] = tmp[i]; for (int i=0;i<index;i++)vtcs[start+4+i] = tmp[i];
...@@ -558,12 +575,8 @@ static void reorientQuadPoints(std::vector<MVertex*> &vtcs, int orientation, ...@@ -558,12 +575,8 @@ static void reorientQuadPoints(std::vector<MVertex*> &vtcs, int orientation,
order -= 2; order -= 2;
if (start >= vtcs.size()) break; if (start >= vtcs.size()) break;
} }
// printf("after : ");
// for (int i=0;i<vtcs.size();i++)printf("%p ",vtcs[i]);
// printf("\n");
} }
// KH: check face orientation wrt element ... // KH: check face orientation wrt element ...
static void getFaceVertices(GRegion *gr, MElement *ele, std::vector<MVertex*> &vf, static void getFaceVertices(GRegion *gr, MElement *ele, std::vector<MVertex*> &vf,
......
This diff is collapsed.
/* A Bison parser, made by GNU Bison 2.3. */ /* A Bison parser, made by GNU Bison 2.4.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C /* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
Free Software Foundation, Inc. 2009, 2010 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation, either version 3 of the License, or
any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -16,9 +16,7 @@ ...@@ -16,9 +16,7 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program. If not, see <http://www.gnu.org/licenses/>. */
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains /* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work part or all of the Bison parser skeleton and distribute that work
...@@ -33,6 +31,7 @@ ...@@ -33,6 +31,7 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
...@@ -171,145 +170,16 @@ ...@@ -171,145 +170,16 @@
tPLUSPLUS = 387 tPLUSPLUS = 387
}; };
#endif #endif
/* Tokens. */
#define tDOUBLE 258
#define tSTRING 259
#define tBIGSTR 260
#define tEND 261
#define tAFFECT 262
#define tDOTS 263
#define tPi 264
#define tMPI_Rank 265
#define tMPI_Size 266
#define tEuclidian 267
#define tCoordinates 268
#define tExp 269
#define tLog 270
#define tLog10 271
#define tSqrt 272
#define tSin 273
#define tAsin 274
#define tCos 275
#define tAcos 276
#define tTan 277
#define tRand 278
#define tAtan 279
#define tAtan2 280
#define tSinh 281
#define tCosh 282
#define tTanh 283
#define tFabs 284
#define tFloor 285
#define tCeil 286
#define tFmod 287
#define tModulo 288
#define tHypot 289
#define tPrintf 290
#define tSprintf 291
#define tStrCat 292
#define tStrPrefix 293
#define tStrRelative 294
#define tBoundingBox 295
#define tDraw 296
#define tToday 297
#define tSyncModel 298
#define tCreateTopology 299
#define tDistanceFunction 300
#define tPoint 301
#define tCircle 302
#define tEllipse 303
#define tLine 304
#define tSphere 305
#define tPolarSphere 306
#define tSurface 307
#define tSpline 308
#define tVolume 309
#define tCharacteristic 310
#define tLength 311
#define tParametric 312
#define tElliptic 313
#define tPlane 314
#define tRuled 315
#define tTransfinite 316
#define tComplex 317
#define tPhysical 318
#define tCompound 319
#define tPeriodic 320
#define tUsing 321
#define tPlugin 322
#define tDegenerated 323
#define tRotate 324
#define tTranslate 325
#define tSymmetry 326
#define tDilate 327
#define tExtrude 328
#define tLevelset 329
#define tLoop 330
#define tRecombine 331
#define tSmoother 332
#define tSplit 333
#define tDelete 334
#define tCoherence 335
#define tIntersect 336
#define tLayers 337
#define tHole 338
#define tAlias 339
#define tAliasWithOptions 340
#define tText2D 341
#define tText3D 342
#define tInterpolationScheme 343
#define tTime 344
#define tCombine 345
#define tBSpline 346
#define tBezier 347
#define tNurbs 348
#define tNurbsOrder 349
#define tNurbsKnots 350
#define tColor 351
#define tColorTable 352
#define tFor 353
#define tIn 354
#define tEndFor 355
#define tIf 356
#define tEndIf 357
#define tExit 358
#define tField 359
#define tReturn 360
#define tCall 361
#define tFunction 362
#define tShow 363
#define tHide 364
#define tGetValue 365
#define tGetEnv 366
#define tGetString 367
#define tGMSH_MAJOR_VERSION 368
#define tGMSH_MINOR_VERSION 369
#define tGMSH_PATCH_VERSION 370
#define tHomRank 371
#define tHomGen 372
#define tHomCut 373
#define tHomSeq 374
#define tAFFECTDIVIDE 375
#define tAFFECTTIMES 376
#define tAFFECTMINUS 377
#define tAFFECTPLUS 378
#define tOR 379
#define tAND 380
#define tNOTEQUAL 381
#define tEQUAL 382
#define tGREATEROREQUAL 383
#define tLESSOREQUAL 384
#define UNARYPREC 385
#define tMINUSMINUS 386
#define tPLUSPLUS 387
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
#line 88 "Gmsh.y"
{ {
/* Line 1685 of yacc.c */
#line 88 "Gmsh.y"
char *c; char *c;
int i; int i;
unsigned int u; unsigned int u;
...@@ -317,14 +187,17 @@ typedef union YYSTYPE ...@@ -317,14 +187,17 @@ typedef union YYSTYPE
double v[5]; double v[5];
Shape s; Shape s;
List_T *l; List_T *l;
}
/* Line 1529 of yacc.c. */
#line 323 "Gmsh.tab.hpp"
YYSTYPE; /* Line 1685 of yacc.c */
#line 195 "Gmsh.tab.hpp"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif #endif
extern YYSTYPE gmsh_yylval; extern YYSTYPE gmsh_yylval;
...@@ -3920,6 +3920,22 @@ FExpr_Multi : ...@@ -3920,6 +3920,22 @@ FExpr_Multi :
List_Add($$, &v->Pos.Z); List_Add($$, &v->Pos.Z);
} }
} }
| tPoint tBIGSTR
{
$$ = GetAllEntityNumbers(0);
}
| tLine tBIGSTR
{
$$ = GetAllEntityNumbers(1);
}
| tSurface tBIGSTR
{
$$ = GetAllEntityNumbers(2);
}
| tVolume tBIGSTR
{
$$ = GetAllEntityNumbers(3);
}
| Transform | Transform
{ {
$$ = List_Create(List_Nbr($1), 1, sizeof(double)); $$ = List_Create(List_Nbr($1), 1, sizeof(double));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment