Skip to content
Snippets Groups Projects
Commit 7475e5bb authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

Adding Loops in the parser, see example ./examples/loop.geo

Adding Print commands in the parser
parent 382011a1
No related branches found
No related tags found
No related merge requests found
/* $Id: Context.cpp,v 1.12 2000-12-05 18:38:08 geuzaine Exp $ */
/* $Id: Context.cpp,v 1.13 2000-12-06 18:28:30 remacle Exp $ */
#include "Gmsh.h"
#include "Const.h"
......@@ -293,7 +293,7 @@ void Init_Colors(int num){
void Init_Context(void){
// Cannot be set by the user
CTX.interactive = 0 ;
CTX.script = 0 ;
CTX.expose = 0 ;
CTX.db = 1 ;
CTX.overlay = 1 ;
......
/* $Id: Context.h,v 1.14 2000-12-05 20:02:12 geuzaine Exp $ */
/* $Id: Context.h,v 1.15 2000-12-06 18:28:30 remacle Exp $ */
#ifndef _CONTEXT_H_
#define _CONTEXT_H_
......@@ -55,6 +55,7 @@ typedef struct{
class Context_T {
public :
int script; /* gmsh in script mode */
int interactive; /* 0=full gfx; -1=just parse; 1,2,3=batch mesh */
int verbosity; /* 0=silent -> 3=debug */
int expose; /* 1 if everything is ready to expose and draw */
......
# $Id: Makefile,v 1.11 2000-12-05 19:38:11 geuzaine Exp $
# $Id: Makefile,v 1.12 2000-12-06 18:28:30 remacle Exp $
# ----------------------------------------------------------------------
# Makefile for Gmsh
# ----------------------------------------------------------------------
......@@ -21,7 +21,8 @@
MESA_STATIC_LIB = $(HOME)/SOURCES/Mesa-3.0-static/lib/libGLw.a\
$(HOME)/SOURCES/Mesa-3.0-static/lib/libGLU.a\
$(HOME)/SOURCES/Mesa-3.0-static/lib/libGL.a
MOTIF_LIB = -L/usr/local/lib -L/usr/X11R6/LessTif/Motif1.2/lib -lXm
MOTIF_LIB = /usr/local/lib/libXm.so.2
// MOTIF_LIB = -L/usr/local/lib -L/usr/X11R6/LessTif/Motif1.2/lib -lXm
X_LIB = -L/usr/X11R6/lib -lXt -lX11 -lXext
THREAD_LIB = -L/usr/lib -lpthread
......
/* $Id: 1D_Mesh.cpp,v 1.8 2000-12-05 20:02:16 geuzaine Exp $ */
/* $Id: 1D_Mesh.cpp,v 1.9 2000-12-06 18:28:30 remacle Exp $ */
#include "Gmsh.h"
#include "Const.h"
......@@ -100,7 +100,7 @@ void Maillage_Curve (void *data, void *dummy){
Msg(STATUS, "Meshing Curve %d", c->Num);
Points = List_Create (10, 10, sizeof (IntPoint));
c->l = Integration (c->ubeg, c->uend, F_One, Points, 1.e-5);
c->l = Integration (c->ubeg, c->uend, F_One, Points, 1.e-4);
List_Delete (Points);
if (c->Method == TRANSFINI || !Extrude_Mesh (c)){
......@@ -111,7 +111,7 @@ void Maillage_Curve (void *data, void *dummy){
}
else{
Points = List_Create (10, 10, sizeof (IntPoint));
a = Integration (c->ubeg, c->uend, F_Lc, Points, 1.e-5);
a = Integration (c->ubeg, c->uend, F_Lc, Points, 1.e-4);
N = IMAX (2, (int) (a + 1.));
if (c->Typ == MSH_SEGM_CIRC ||
......
/* $Id: 2D_Mesh.cpp,v 1.9 2000-11-28 17:18:33 geuzaine Exp $ */
/* $Id: 2D_Mesh.cpp,v 1.10 2000-12-06 18:28:30 remacle Exp $ */
/*
Maillage Delaunay d'une surface (Point insertion Technique)
......@@ -1081,8 +1081,10 @@ void Maillage_Surface (void *data, void *dum){
if (CTX.mesh.algo == DELAUNAY_OLDALGO)
Maillage_Automatique_VieuxCode (s, THEM, ori);
else
{
printf("coucou\n");
AlgorithmeMaillage2DAnisotropeModeJF (s);
}
if(CTX.mesh.nb_smoothing){
Msg(STATUS, "Mesh Smoothing");
tnxe = Tree_Create (sizeof (NXE), compareNXE);
......
%{ /* $Id: Gmsh.l,v 1.7 2000-12-05 15:23:57 geuzaine Exp $ */
%{ /* $Id: Gmsh.l,v 1.8 2000-12-06 18:28:30 remacle Exp $ */
#include <stdio.h>
#include <stdlib.h>
......@@ -171,6 +171,11 @@ Volume return tVolume;
With return tWith;
For return tFor;
EndFor return tEndFor;
Script return tScript;
Exit return tExit;
Merge return tMerge;
SS return tScalarTetrahedron;
VS return tVectorTetrahedron;
......
This diff is collapsed.
......@@ -6,148 +6,153 @@ typedef union {
Shape s;
List_T *l;
} YYSTYPE;
#define tDOUBLE 258
#define tSTRING 259
#define tBIGSTR 260
#define tEND 261
#define tAFFECT 262
#define tDOTS 263
#define tPi 264
#define tExp 265
#define tLog 266
#define tLog10 267
#define tSqrt 268
#define tSin 269
#define tAsin 270
#define tCos 271
#define tAcos 272
#define tTan 273
#define tAtan 274
#define tAtan2 275
#define tSinh 276
#define tCosh 277
#define tTanh 278
#define tFabs 279
#define tFloor 280
#define tCeil 281
#define tFmod 282
#define tModulo 283
#define tHypot 284
#define tPoint 285
#define tCircle 286
#define tEllipsis 287
#define tLine 288
#define tSurface 289
#define tSpline 290
#define tVolume 291
#define tCharacteristic 292
#define tLength 293
#define tParametric 294
#define tElliptic 295
#define tPlane 296
#define tRuled 297
#define tTransfinite 298
#define tComplex 299
#define tPhysical 300
#define tUsing 301
#define tPower 302
#define tBump 303
#define tProgression 304
#define tAssociation 305
#define tRotate 306
#define tTranslate 307
#define tSymmetry 308
#define tDilate 309
#define tExtrude 310
#define tDuplicata 311
#define tLoop 312
#define tInclude 313
#define tRecombine 314
#define tDelete 315
#define tCoherence 316
#define tView 317
#define tOffset 318
#define tAttractor 319
#define tLayers 320
#define tScalarTetrahedron 321
#define tVectorTetrahedron 322
#define tTensorTetrahedron 323
#define tScalarTriangle 324
#define tVectorTriangle 325
#define tTensorTriangle 326
#define tScalarLine 327
#define tVectorLine 328
#define tTensorLine 329
#define tScalarPoint 330
#define tVectorPoint 331
#define tTensorPoint 332
#define tBSpline 333
#define tNurbs 334
#define tOrder 335
#define tWith 336
#define tBounds 337
#define tKnots 338
#define tColor 339
#define tOptions 340
#define tGeneral 341
#define tGeometry 342
#define tMesh 343
#define tPostProcessing 344
#define tPrint 345
#define tB_SPLINE_SURFACE_WITH_KNOTS 346
#define tB_SPLINE_CURVE_WITH_KNOTS 347
#define tCARTESIAN_POINT 348
#define tTRUE 349
#define tFALSE 350
#define tUNSPECIFIED 351
#define tU 352
#define tV 353
#define tEDGE_CURVE 354
#define tVERTEX_POINT 355
#define tORIENTED_EDGE 356
#define tPLANE 357
#define tFACE_OUTER_BOUND 358
#define tEDGE_LOOP 359
#define tADVANCED_FACE 360
#define tVECTOR 361
#define tDIRECTION 362
#define tAXIS2_PLACEMENT_3D 363
#define tISO 364
#define tENDISO 365
#define tENDSEC 366
#define tDATA 367
#define tHEADER 368
#define tFILE_DESCRIPTION 369
#define tFILE_SCHEMA 370
#define tFILE_NAME 371
#define tMANIFOLD_SOLID_BREP 372
#define tCLOSED_SHELL 373
#define tADVANCED_BREP_SHAPE_REPRESENTATION 374
#define tFACE_BOUND 375
#define tCYLINDRICAL_SURFACE 376
#define tCONICAL_SURFACE 377
#define tCIRCLE 378
#define tTRIMMED_CURVE 379
#define tGEOMETRIC_SET 380
#define tCOMPOSITE_CURVE_SEGMENT 381
#define tCONTINUOUS 382
#define tCOMPOSITE_CURVE 383
#define tTOROIDAL_SURFACE 384
#define tPRODUCT_DEFINITION 385
#define tPRODUCT_DEFINITION_SHAPE 386
#define tSHAPE_DEFINITION_REPRESENTATION 387
#define tELLIPSE 388
#define tTrimmed 389
#define tSolid 390
#define tEndSolid 391
#define tVertex 392
#define tFacet 393
#define tNormal 394
#define tOuter 395
#define tLoopSTL 396
#define tEndLoop 397
#define tEndFacet 398
#define UMINUS 399
#define tDOUBLE 257
#define tSTRING 258
#define tBIGSTR 259
#define tEND 260
#define tAFFECT 261
#define tDOTS 262
#define tPi 263
#define tExp 264
#define tLog 265
#define tLog10 266
#define tSqrt 267
#define tSin 268
#define tAsin 269
#define tCos 270
#define tAcos 271
#define tTan 272
#define tAtan 273
#define tAtan2 274
#define tSinh 275
#define tCosh 276
#define tTanh 277
#define tFabs 278
#define tFloor 279
#define tCeil 280
#define tFmod 281
#define tModulo 282
#define tHypot 283
#define tPoint 284
#define tCircle 285
#define tEllipsis 286
#define tLine 287
#define tSurface 288
#define tSpline 289
#define tVolume 290
#define tCharacteristic 291
#define tLength 292
#define tParametric 293
#define tElliptic 294
#define tPlane 295
#define tRuled 296
#define tTransfinite 297
#define tComplex 298
#define tPhysical 299
#define tUsing 300
#define tPower 301
#define tBump 302
#define tProgression 303
#define tAssociation 304
#define tRotate 305
#define tTranslate 306
#define tSymmetry 307
#define tDilate 308
#define tExtrude 309
#define tDuplicata 310
#define tLoop 311
#define tInclude 312
#define tRecombine 313
#define tDelete 314
#define tCoherence 315
#define tView 316
#define tOffset 317
#define tAttractor 318
#define tLayers 319
#define tScalarTetrahedron 320
#define tVectorTetrahedron 321
#define tTensorTetrahedron 322
#define tScalarTriangle 323
#define tVectorTriangle 324
#define tTensorTriangle 325
#define tScalarLine 326
#define tVectorLine 327
#define tTensorLine 328
#define tScalarPoint 329
#define tVectorPoint 330
#define tTensorPoint 331
#define tBSpline 332
#define tNurbs 333
#define tOrder 334
#define tWith 335
#define tBounds 336
#define tKnots 337
#define tColor 338
#define tOptions 339
#define tFor 340
#define tEndFor 341
#define tScript 342
#define tExit 343
#define tMerge 344
#define tGeneral 345
#define tGeometry 346
#define tMesh 347
#define tPostProcessing 348
#define tPrint 349
#define tB_SPLINE_SURFACE_WITH_KNOTS 350
#define tB_SPLINE_CURVE_WITH_KNOTS 351
#define tCARTESIAN_POINT 352
#define tTRUE 353
#define tFALSE 354
#define tUNSPECIFIED 355
#define tU 356
#define tV 357
#define tEDGE_CURVE 358
#define tVERTEX_POINT 359
#define tORIENTED_EDGE 360
#define tPLANE 361
#define tFACE_OUTER_BOUND 362
#define tEDGE_LOOP 363
#define tADVANCED_FACE 364
#define tVECTOR 365
#define tDIRECTION 366
#define tAXIS2_PLACEMENT_3D 367
#define tISO 368
#define tENDISO 369
#define tENDSEC 370
#define tDATA 371
#define tHEADER 372
#define tFILE_DESCRIPTION 373
#define tFILE_SCHEMA 374
#define tFILE_NAME 375
#define tMANIFOLD_SOLID_BREP 376
#define tCLOSED_SHELL 377
#define tADVANCED_BREP_SHAPE_REPRESENTATION 378
#define tFACE_BOUND 379
#define tCYLINDRICAL_SURFACE 380
#define tCONICAL_SURFACE 381
#define tCIRCLE 382
#define tTRIMMED_CURVE 383
#define tGEOMETRIC_SET 384
#define tCOMPOSITE_CURVE_SEGMENT 385
#define tCONTINUOUS 386
#define tCOMPOSITE_CURVE 387
#define tTOROIDAL_SURFACE 388
#define tPRODUCT_DEFINITION 389
#define tPRODUCT_DEFINITION_SHAPE 390
#define tSHAPE_DEFINITION_REPRESENTATION 391
#define tELLIPSE 392
#define tTrimmed 393
#define tSolid 394
#define tEndSolid 395
#define tVertex 396
#define tFacet 397
#define tNormal 398
#define tOuter 399
#define tLoopSTL 400
#define tEndLoop 401
#define tEndFacet 402
#define UMINUS 403
extern YYSTYPE yylval;
%{ /* $Id: Gmsh.y,v 1.15 2000-12-05 19:19:54 geuzaine Exp $ */
%{ /* $Id: Gmsh.y,v 1.16 2000-12-06 18:28:30 remacle Exp $ */
#include <stdarg.h>
......@@ -15,6 +15,7 @@
#include "Options.h"
#include "Colors.h"
#include "Parser.h"
#include "Main.h"
#ifdef __DECCXX // bug in bison
#include <alloca.h>
......@@ -29,12 +30,14 @@ extern char ThePathForIncludes[NAME_STR_L];
static FILE *yyinTab[MAX_OPEN_FILES];
static int yylinenoTab[MAX_OPEN_FILES];
static fpos_t yyposImbricatedLoopsTab[MAX_OPEN_FILES];
static int LoopControlVariablesTab[MAX_OPEN_FILES][3];
static char yynameTab[MAX_OPEN_FILES][NAME_STR_L];
static char tmpstring[NAME_STR_L];
static Symbol TheSymbol;
static Surface *STL_Surf;
static Shape TheShape;
static int i,j,k,flag,RecursionLevel=0;
static int i,j,k,flag,RecursionLevel=0,ImbricatedLoop = 0;
static double d;
static ExtrudeParams extr;
static StringXColor *ColorField ;
......@@ -73,7 +76,7 @@ void vyyerror (char *fmt, ...);
%token tScalarLine tVectorLine tTensorLine
%token tScalarPoint tVectorPoint tTensorPoint
%token tBSpline tNurbs tOrder tWith tBounds tKnots
%token tColor tOptions
%token tColor tOptions tFor tEndFor tScript tExit tMerge
%token tGeneral tGeometry tMesh tPostProcessing tPrint
%token tB_SPLINE_SURFACE_WITH_KNOTS
......@@ -328,6 +331,8 @@ StepDataItem :
GeomFormatList :
/* none*/
{
}
| GeomFormatList GeomFormat
{
Msg(PARSER_INFO,"Gmsh File Format Read");
......@@ -345,6 +350,9 @@ GeomFormat :
| Transfini { return 1; }
| Coherence { return 1; }
| Macro { return 1; }
| Loop {return 1;}
/* | Script { return 1; }*/
| Command { return 1; }
| tOptions '{' Options '}' { return 1; }
| error tEND { yyerrok; return 1;}
;
......@@ -1055,8 +1063,118 @@ Macro :
yyin = yyinTab[--RecursionLevel];
}
}
;
/* -----------------
C O M M A N D
----------------- */
Command :
tPrint tBIGSTR tEND
{
char ext[6];
strcpy(ext,$2+(strlen($2)-4));
Replot();
extern void CreateImage (FILE *fp);
FILE *fp = 0;
if(!strcmp(ext,".gif"))
{
fp = fopen($2,"wb");
CTX.print.type = PRINT_GL2GIF;
}
else if(!strcmp(ext,".eps"))
{
fp = fopen($2,"w");
CTX.print.type = PRINT_GL2PS_RECURSIVE;
}
else if(!strcmp(ext,".xpm"))
{
fp = fopen($2,"wb");
CTX.print.type = PRINT_XDUMP;
CTX.print.format = FORMAT_XPM;
}
if(fp)
{
CreateImage(fp);
fclose(fp);
}
}
| tExit tEND
{
exit(0);
}
| tMerge tBIGSTR tEND
{
FILE *ff = yyin;
MergeProblem($2);
yyin = ff;
}
;
/* ---------------
L O O P
--------------- */
Loop :
tFor '(' FExpr ':' FExpr ')'
{
FILE* ff;
if(RecursionLevel)
ff = yyinTab[RecursionLevel-1];
else
ff = yyin;
// here, we seek remember the position in yyin
LoopControlVariablesTab[ImbricatedLoop][0] = (int)$3 ;
LoopControlVariablesTab[ImbricatedLoop][1] = (int)$5 ;
LoopControlVariablesTab[ImbricatedLoop][2] = 1 ;
fgetpos( ff, &yyposImbricatedLoopsTab[ImbricatedLoop++]);
}
| tFor '(' FExpr ':' FExpr ':' FExpr ')'
{
FILE* ff;
if(RecursionLevel)
ff = yyinTab[RecursionLevel-1];
else
ff = yyin;
// here, we seek remember the position in yyin
LoopControlVariablesTab[ImbricatedLoop][0] = (int)$3 ;
LoopControlVariablesTab[ImbricatedLoop][1] = (int)$5 ;
LoopControlVariablesTab[ImbricatedLoop][2] = (int)$7 ;
fgetpos( ff, &yyposImbricatedLoopsTab[ImbricatedLoop++]);
}
| tEndFor
{
if(LoopControlVariablesTab[ImbricatedLoop-1][1] >
LoopControlVariablesTab[ImbricatedLoop-1][0])
{
FILE* ff;
if(RecursionLevel)
ff = yyinTab[RecursionLevel-1];
else
ff = yyin;
LoopControlVariablesTab[ImbricatedLoop-1][0] +=
LoopControlVariablesTab[ImbricatedLoop-1][2];
fsetpos( yyin, &yyposImbricatedLoopsTab[ImbricatedLoop-1]);
}
else
{
ImbricatedLoop--;
}
}
/* ---------------
S C R I P T
---------------
Script :
tScript '(' FExpr ')' '{' GeomFormatList '}' tEND
{
// here put something to close the script which
// number is (int) $3
}
;
*/
/* ---------------
......
This diff is collapsed.
/* $Id: CbFile.cpp,v 1.7 2000-11-26 15:43:47 geuzaine Exp $ */
/* $Id: CbFile.cpp,v 1.8 2000-12-06 18:28:30 remacle Exp $ */
#include <unistd.h>
......@@ -91,6 +91,8 @@ void CreateImage (FILE *fp) {
break ;
case PRINT_GL2GIF :
// have to replot for filling again buffer ...
Replot();
create_gif(fp, CTX.viewport[2]-CTX.viewport[0],
CTX.viewport[3]-CTX.viewport[1]);
Msg(INFOS, "GIF Dump Complete '%s'", KeepFileName);
......
/* $Id: Main.cpp,v 1.20 2000-12-05 23:01:06 geuzaine Exp $ */
/* $Id: Main.cpp,v 1.21 2000-12-06 18:28:30 remacle Exp $ */
#include <signal.h>
......@@ -46,6 +46,7 @@ char gmsh_help[] =
" -0 output current options, flattened geometry and exit\n"
"Mesh options:\n"
" -1, -2, -3 perform batch 1D, 2D and 3D mesh generation\n"
" -script gmsh in script mode\n"
" -format msh|unv|gref set output mesh format (default: msh)\n"
" -algo iso|aniso select mesh algorithm (default: iso)\n"
" -smooth int set mesh smoothing (default: 0)\n"
......@@ -100,8 +101,12 @@ void ParseFile(char *f){
return;
}
fpos_t position;
fgetpos(yyin, &position);
fgets(String, sizeof(String), yyin) ;
rewind(yyin);
fsetpos(yyin, &position);
printf("String :: %s",String);
if(!strncmp(String, "$PTS", 4) ||
!strncmp(String, "$NO", 3) ||
......@@ -214,6 +219,9 @@ void Get_Options (int argc, char *argv[], int *nbfiles) {
else if(!strcmp(argv[i]+1, "3")){
CTX.interactive = 3; i++;
}
else if(!strcmp(argv[i]+1, "script")){
CTX.script = 1; i++;
}
else if(!strcmp(argv[i]+1, "path")){
i++;
/* we need to make a copy because of bison */
......@@ -862,6 +870,11 @@ int main(int argc, char *argv[]){
Msg(STATUS, "Ready");
Msg(SELECT, "Gmsh %g", GMSH_VERSION);
/* Compute viewport and Draw */
CTX.expose = 1 ;
Init();
Draw();
/* Open input file */
OpenProblem(TheFileName);
......@@ -886,10 +899,7 @@ int main(int argc, char *argv[]){
Msg(ERROR, "Invalid Background Mesh (no View)");
}
/* Compute viewport and Draw */
CTX.expose = 1 ;
Init();
Draw();
Replot();
/* Loop until were done */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment