Skip to content
Snippets Groups Projects
Gmsh.tab.cpp 290 KiB
Newer Older
	if((pd = (double*)List_Pointer_Test(pSymbol->val, (int)(yyvsp[-4].d)))){
	  switch((yyvsp[-2].i)){
	  case 0 : *pd = (yyvsp[-1].d); break;
	  case 1 : *pd += (yyvsp[-1].d); break;
	  case 2 : *pd -= (yyvsp[-1].d); break;
	  case 3 : *pd *= (yyvsp[-1].d); break;
	    if((yyvsp[-1].d)) *pd /= (yyvsp[-1].d); 
	    else yymsg(GERROR, "Division by zero in '%s[%d] /= %g'", (yyvsp[-6].c), (int)(yyvsp[-4].d), (yyvsp[-1].d));
	  if(!(yyvsp[-2].i))
	    List_Put(pSymbol->val, (int)(yyvsp[-4].d), &(yyvsp[-1].d));
	    yymsg(GERROR, "Uninitialized variable '%s[%d]'", (yyvsp[-6].c), (int)(yyvsp[-4].d));
	Free((yyvsp[-6].c));
    ;}
    break;

  case 64:
#line 678 "Gmsh.y"
    {
      if(List_Nbr((yyvsp[-5].l)) != List_Nbr((yyvsp[-1].l))){
	yymsg(GERROR, "Incompatible array dimensions in affectation");
	Free((yyvsp[-8].c));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Symbol TheSymbol;
	TheSymbol.Name = (yyvsp[-8].c);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Symbol *pSymbol;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	if(!(pSymbol = (Symbol*)Tree_PQuery(Symbol_T, &TheSymbol))){
	  if(!(yyvsp[-2].i)){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	    TheSymbol.val = List_Create(5, 5, sizeof(double));
	    for(int i = 0; i < List_Nbr((yyvsp[-5].l)); i++){
	      List_Put(TheSymbol.val, (int)(*(double*)List_Pointer((yyvsp[-5].l), i)),
		       (double*)List_Pointer((yyvsp[-1].l), i));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	    Tree_Add(Symbol_T, &TheSymbol);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  else{
	    yymsg(GERROR, "Unknown variable '%s'", (yyvsp[-8].c));
	    Free((yyvsp[-8].c));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  }
	  for(int i = 0; i < List_Nbr((yyvsp[-5].l)); i++){
	    int j = (int)(*(double*)List_Pointer((yyvsp[-5].l), i));
	    double d = *(double*)List_Pointer((yyvsp[-1].l), i);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	    double *pd;
	    if((pd = (double*)List_Pointer_Test(pSymbol->val, j))){
	      switch((yyvsp[-2].i)){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	      case 0 : *pd = d; break;
	      case 1 : *pd += d; break;
	      case 2 : *pd -= d; break;
	      case 3 : *pd *= d; break;
	      case 4 : 
		if((yyvsp[-1].l)) *pd /= d; 
		else yymsg(GERROR, "Division by zero in '%s[%d] /= %g'", (yyvsp[-8].c), j, d);
	      if(!(yyvsp[-2].i))
		List_Put(pSymbol->val, j, &d);
	      else
		yymsg(GERROR, "Uninitialized variable '%s[%d]'", (yyvsp[-8].c), j);	  
	  Free((yyvsp[-8].c));
      List_Delete((yyvsp[-5].l));
      List_Delete((yyvsp[-1].l));
    ;}
    break;

  case 65:
#line 732 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      Symbol TheSymbol;
      TheSymbol.Name = (yyvsp[-5].c);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      Symbol *pSymbol;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(!(pSymbol = (Symbol*)Tree_PQuery(Symbol_T, &TheSymbol))){
	TheSymbol.val = List_Create(5, 5, sizeof(double));
	List_Copy((yyvsp[-1].l), TheSymbol.val);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Tree_Add(Symbol_T, &TheSymbol);
      }
      else{
	List_Reset(pSymbol->val);
	List_Copy((yyvsp[-1].l), pSymbol->val);
	Free((yyvsp[-5].c));
      }
      List_Delete((yyvsp[-1].l));
    ;}
    break;

  case 66:
#line 749 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      // appends to the list
      Symbol TheSymbol;
      TheSymbol.Name = (yyvsp[-5].c);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      Symbol *pSymbol;
      if(!(pSymbol = (Symbol*)Tree_PQuery(Symbol_T, &TheSymbol))){
	TheSymbol.val = List_Create(5, 5, sizeof(double));
	List_Copy((yyvsp[-1].l), TheSymbol.val);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Tree_Add(Symbol_T, &TheSymbol);
      }
      else{
	for(int i = 0; i < List_Nbr((yyvsp[-1].l)); i++)
	  List_Add(pSymbol->val, List_Pointer((yyvsp[-1].l), i));
	Free((yyvsp[-5].c));
      }
      List_Delete((yyvsp[-1].l));
    ;}
    break;

  case 67:
#line 767 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      Symbol TheSymbol;
      TheSymbol.Name = (yyvsp[-2].c);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      Symbol *pSymbol;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(!(pSymbol = (Symbol*)Tree_PQuery(Symbol_T, &TheSymbol)))
	yymsg(GERROR, "Unknown variable '%s'", (yyvsp[-2].c)); 
	*(double*)List_Pointer_Fast(pSymbol->val, 0) += (yyvsp[-1].i);
      Free((yyvsp[-2].c));
    ;}
    break;

  case 68:
#line 778 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      Symbol TheSymbol;
      TheSymbol.Name = (yyvsp[-5].c);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      Symbol *pSymbol;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(!(pSymbol = (Symbol*)Tree_PQuery(Symbol_T, &TheSymbol)))
	yymsg(GERROR, "Unknown variable '%s'", (yyvsp[-5].c)); 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	double *pd;
	if((pd = (double*)List_Pointer_Test(pSymbol->val, (int)(yyvsp[-3].d))))
	  *pd += (yyvsp[-1].i);
	  yymsg(GERROR, "Uninitialized variable '%s[%d]'", (yyvsp[-5].c), (int)(yyvsp[-3].d));
      }
      Free((yyvsp[-5].c));
    ;}
    break;

  case 69:
#line 797 "Gmsh.y"
    { 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      char* (*pStrOpt)(int num, int action, char *value);
      StringXString *pStrCat;
      if(!(pStrCat = Get_StringOptionCategory((yyvsp[-5].c))))
	yymsg(GERROR, "Unknown string option class '%s'", (yyvsp[-5].c));
	if(!(pStrOpt = (char *(*) (int, int, char *))Get_StringOption((yyvsp[-3].c), pStrCat)))
	  yymsg(GERROR, "Unknown string option '%s.%s'", (yyvsp[-5].c), (yyvsp[-3].c));
	  pStrOpt(0, GMSH_SET|GMSH_GUI, (yyvsp[-1].c));
      }
      Free((yyvsp[-5].c)); Free((yyvsp[-3].c)); //FIXME: somtimes leak $5
    ;}
    break;

  case 70:
#line 811 "Gmsh.y"
    { 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      char* (*pStrOpt)(int num, int action, char *value);
      StringXString *pStrCat;
      if(!(pStrCat = Get_StringOptionCategory((yyvsp[-8].c))))
	yymsg(GERROR, "Unknown string option class '%s'", (yyvsp[-8].c));
	if(!(pStrOpt = (char *(*) (int, int, char *))Get_StringOption((yyvsp[-3].c), pStrCat)))
	  yymsg(GERROR, "Unknown string option '%s[%d].%s'", (yyvsp[-8].c), (int)(yyvsp[-6].d), (yyvsp[-3].c));
	  pStrOpt((int)(yyvsp[-6].d), GMSH_SET|GMSH_GUI, (yyvsp[-1].c));
      Free((yyvsp[-8].c)); Free((yyvsp[-3].c)); //FIXME: somtimes leak $8
    ;}
    break;

  case 71:
#line 828 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      double (*pNumOpt)(int num, int action, double value);
      StringXNumber *pNumCat;
      if(!(pNumCat = Get_NumberOptionCategory((yyvsp[-5].c))))
	yymsg(GERROR, "Unknown numeric option class '%s'", (yyvsp[-5].c));
	if(!(pNumOpt = (double (*) (int, int, double))Get_NumberOption((yyvsp[-3].c), pNumCat)))
	  yymsg(GERROR, "Unknown numeric option '%s.%s'", (yyvsp[-5].c), (yyvsp[-3].c));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  double d = 0;
	  switch((yyvsp[-2].i)){
	  case 0 : d = (yyvsp[-1].d); break;
	  case 1 : d = pNumOpt(0, GMSH_GET, 0) + (yyvsp[-1].d); break;
	  case 2 : d = pNumOpt(0, GMSH_GET, 0) - (yyvsp[-1].d); break;
	  case 3 : d = pNumOpt(0, GMSH_GET, 0) * (yyvsp[-1].d); break;
	    if((yyvsp[-1].d)) d = pNumOpt(0, GMSH_GET, 0) / (yyvsp[-1].d); 
	    else yymsg(GERROR, "Division by zero in '%s.%s /= %g'", (yyvsp[-5].c), (yyvsp[-3].c), (yyvsp[-1].d));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  pNumOpt(0, GMSH_SET|GMSH_GUI, d);
      Free((yyvsp[-5].c)); Free((yyvsp[-3].c));
    ;}
    break;

  case 72:
#line 854 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      double (*pNumOpt)(int num, int action, double value);
      StringXNumber *pNumCat;
      if(!(pNumCat = Get_NumberOptionCategory((yyvsp[-8].c))))
	yymsg(GERROR, "Unknown numeric option class '%s'", (yyvsp[-8].c));
	if(!(pNumOpt =  (double (*) (int, int, double))Get_NumberOption((yyvsp[-3].c), pNumCat)))
	  yymsg(GERROR, "Unknown numeric option '%s[%d].%s'", (yyvsp[-8].c), (int)(yyvsp[-6].d), (yyvsp[-3].c));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  double d = 0;
	  switch((yyvsp[-2].i)){
	  case 0 : d = (yyvsp[-1].d); break;
	  case 1 : d = pNumOpt((int)(yyvsp[-6].d), GMSH_GET, 0) + (yyvsp[-1].d); break;
	  case 2 : d = pNumOpt((int)(yyvsp[-6].d), GMSH_GET, 0) - (yyvsp[-1].d); break;
	  case 3 : d = pNumOpt((int)(yyvsp[-6].d), GMSH_GET, 0) * (yyvsp[-1].d); break;
	    if((yyvsp[-1].d)) d = pNumOpt((int)(yyvsp[-6].d), GMSH_GET, 0) / (yyvsp[-1].d);
	    else yymsg(GERROR, "Division by zero in '%s[%d].%s /= %g'", 
		       (yyvsp[-8].c), (int)(yyvsp[-6].d), (yyvsp[-3].c), (yyvsp[-1].d));
	  pNumOpt((int)(yyvsp[-6].d), GMSH_SET|GMSH_GUI, d);
      Free((yyvsp[-8].c)); Free((yyvsp[-3].c));
    ;}
    break;

  case 73:
#line 881 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      double (*pNumOpt)(int num, int action, double value);
      StringXNumber *pNumCat;
      if(!(pNumCat = Get_NumberOptionCategory((yyvsp[-4].c))))
	yymsg(GERROR, "Unknown numeric option class '%s'", (yyvsp[-4].c));
	if(!(pNumOpt =  (double (*) (int, int, double))Get_NumberOption((yyvsp[-2].c), pNumCat)))
	  yymsg(GERROR, "Unknown numeric option '%s.%s'", (yyvsp[-4].c), (yyvsp[-2].c));
	  pNumOpt(0, GMSH_SET|GMSH_GUI, pNumOpt(0, GMSH_GET, 0)+(yyvsp[-1].i));
      Free((yyvsp[-4].c)); Free((yyvsp[-2].c));
    ;}
    break;

  case 74:
#line 895 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      double (*pNumOpt)(int num, int action, double value);
      StringXNumber *pNumCat;
      if(!(pNumCat = Get_NumberOptionCategory((yyvsp[-7].c))))
	yymsg(GERROR, "Unknown numeric option class '%s'", (yyvsp[-7].c));
	if(!(pNumOpt =  (double (*) (int, int, double))Get_NumberOption((yyvsp[-2].c), pNumCat)))
	  yymsg(GERROR, "Unknown numeric option '%s[%d].%s'", (yyvsp[-7].c), (int)(yyvsp[-5].d), (yyvsp[-2].c));
	  pNumOpt((int)(yyvsp[-5].d), GMSH_SET|GMSH_GUI, pNumOpt((int)(yyvsp[-5].d), GMSH_GET, 0)+(yyvsp[-1].i));
      Free((yyvsp[-7].c)); Free((yyvsp[-2].c));
    ;}
    break;

  case 75:
#line 912 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      unsigned int (*pColOpt)(int num, int action, unsigned int value);
      StringXColor *pColCat;
      if(!(pColCat = Get_ColorOptionCategory((yyvsp[-7].c))))
	yymsg(GERROR, "Unknown color option class '%s'", (yyvsp[-7].c));
	if(!(pColOpt =  (unsigned int (*) (int, int, unsigned int))Get_ColorOption((yyvsp[-3].c), pColCat)))
	  yymsg(GERROR, "Unknown color option '%s.Color.%s'", (yyvsp[-7].c), (yyvsp[-3].c));
	  pColOpt(0, GMSH_SET|GMSH_GUI, (yyvsp[-1].u));
      Free((yyvsp[-7].c)); Free((yyvsp[-3].c));
    ;}
    break;

  case 76:
#line 926 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      unsigned int (*pColOpt)(int num, int action, unsigned int value);
      StringXColor *pColCat;
      if(!(pColCat = Get_ColorOptionCategory((yyvsp[-10].c))))
	yymsg(GERROR, "Unknown color option class '%s'", (yyvsp[-10].c));
	if(!(pColOpt =  (unsigned int (*) (int, int, unsigned int))Get_ColorOption((yyvsp[-3].c), pColCat)))
	  yymsg(GERROR, "Unknown color option '%s[%d].Color.%s'", (yyvsp[-10].c), (int)(yyvsp[-8].d), (yyvsp[-3].c));
	  pColOpt((int)(yyvsp[-8].d), GMSH_SET|GMSH_GUI, (yyvsp[-1].u));
      Free((yyvsp[-10].c)); Free((yyvsp[-3].c));
    ;}
    break;

  case 77:
#line 943 "Gmsh.y"
    {
      GmshColorTable *ct = Get_ColorTable(0);
	yymsg(GERROR, "View[%d] does not exist", 0);
	ct->size = List_Nbr((yyvsp[-1].l));
	if(ct->size > COLORTABLE_NBMAX_COLOR)
	  yymsg(GERROR, "Too many (%d>%d) colors in View[%d].ColorTable", 
		ct->size, COLORTABLE_NBMAX_COLOR, 0);
	  for(int i = 0; i < ct->size; i++) List_Read((yyvsp[-1].l), i, &ct->table[i]);
	if(ct->size == 1){
	  ct->size = 2;
	  ct->table[1] = ct->table[0];
	}
      Free((yyvsp[-5].c));
      List_Delete((yyvsp[-1].l));
    ;}
    break;

  case 78:
#line 963 "Gmsh.y"
    {
      GmshColorTable *ct = Get_ColorTable((int)(yyvsp[-6].d));
	yymsg(GERROR, "View[%d] does not exist", (int)(yyvsp[-6].d));
	ct->size = List_Nbr((yyvsp[-1].l));
	  yymsg(GERROR, "Too many (%d>%d) colors in View[%d].ColorTable", 
		   ct->size, COLORTABLE_NBMAX_COLOR, (int)(yyvsp[-6].d));
	  for(int i = 0; i < ct->size; i++) List_Read((yyvsp[-1].l), i, &ct->table[i]);
	if(ct->size == 1){
	  ct->size = 2;
	  ct->table[1] = ct->table[0];
	}
      Free((yyvsp[-8].c));
      List_Delete((yyvsp[-1].l));
    ;}
    break;

  case 79:
#line 986 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      try {
	GMSH_PluginManager::instance()->setPluginOption((yyvsp[-6].c), (yyvsp[-3].c), (yyvsp[-1].d)); 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      }
      catch (...) {
	yymsg(GERROR, "Unknown option '%s' or plugin '%s'", (yyvsp[-3].c), (yyvsp[-6].c));
      Free((yyvsp[-6].c)); Free((yyvsp[-3].c));
    ;}
    break;

  case 80:
#line 996 "Gmsh.y"
    {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      try {
	GMSH_PluginManager::instance()->setPluginOption((yyvsp[-6].c), (yyvsp[-3].c), (yyvsp[-1].c)); 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      }
      catch (...) {
	yymsg(GERROR, "Unknown option '%s' or plugin '%s'", (yyvsp[-3].c), (yyvsp[-6].c));
      Free((yyvsp[-6].c)); Free((yyvsp[-3].c)); // FIXME: sometimes leak $8
    ;}
    break;

  case 81:
#line 1015 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindPoint(num, THEM)){
	yymsg(GERROR, "Point %d already exists", num);
      }
      else{
	Vertex *v = Create_Vertex(num, CTX.geom.scaling_factor * (yyvsp[-1].v)[0],
				  CTX.geom.scaling_factor * (yyvsp[-1].v)[1],
				  CTX.geom.scaling_factor * (yyvsp[-1].v)[2],
				  CTX.geom.scaling_factor * (yyvsp[-1].v)[3], 1.0);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Tree_Add(THEM->Points, &v);
      }
      (yyval.s).Type = MSH_POINT;
      (yyval.s).Num = num;
    ;}
    break;

  case 82:
#line 1031 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindPhysicalGroup(num, MSH_PHYSICAL_POINT, THEM)){
	yymsg(GERROR, "Physical point %d already exists", num);
      }
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_POINT, temp);
	List_Delete(temp);
	List_Add(THEM->PhysicalGroups, &p);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_PHYSICAL_POINT;
      (yyval.s).Num = num;
    ;}
    break;

  case 83:
#line 1047 "Gmsh.y"
    {
      for(int i = 0; i < List_Nbr((yyvsp[-9].l)); i++){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	double p;
      	List_Read((yyvsp[-9].l), i, &p);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        Vertex *v = FindPoint((int)p, THEM);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  yymsg(WARNING, "Unknown point %d", (int)p);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  Attractor *a = Create_Attractor(List_Nbr(THEM->Metric->Attractors)+1,
					  (yyvsp[-6].d), (yyvsp[-4].d), (yyvsp[-2].d), v, NULL, NULL);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  List_Add(THEM->Metric->Attractors, &a);
      List_Delete((yyvsp[-9].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      // dummy values
      (yyval.s).Type = 0;
      (yyval.s).Num = 0;
    ;}
    break;

  case 84:
#line 1066 "Gmsh.y"
    {
      for(int i = 0; i < List_Nbr((yyvsp[-3].l)); i++){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	double d;
	List_Read((yyvsp[-3].l), i, &d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Vertex *v = FindPoint((int)d, THEM);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  yymsg(WARNING, "Unknown point %d", (int)d);
	  v->lc = (yyvsp[-1].d);
      List_Delete((yyvsp[-3].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      // dummy values
      (yyval.s).Type = 0;
      (yyval.s).Num = 0;
    ;}
    break;

  case 85:
#line 1085 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindCurve(num, THEM)){
	yymsg(GERROR, "Curve %d already exists", num);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Curve *c = Create_Curve(num, MSH_SEGM_LINE, 1, temp, NULL,
				-1, -1, 0., 1.);
	Tree_Add(THEM->Curves, &c);
	CreateReversedCurve(THEM, c);
	List_Delete(temp);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_SEGM_LINE;
      (yyval.s).Num = num;
    ;}
    break;

  case 86:
#line 1103 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindCurve(num, THEM)){
	yymsg(GERROR, "Curve %d already exists", num);
      }
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Curve *c = Create_Curve(num, MSH_SEGM_SPLN, 3, temp, NULL,
				-1, -1, 0., 1.);
	Tree_Add(THEM->Curves, &c);
	CreateReversedCurve(THEM, c);
	List_Delete(temp);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_SEGM_SPLN;
      (yyval.s).Num = num;
    ;}
    break;

  case 87:
#line 1121 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindCurve(num, THEM)){
	yymsg(GERROR, "Curve %d already exists", num);
      }
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Curve *c = Create_Curve(num, MSH_SEGM_CIRC, 2, temp, NULL,
				-1, -1, 0., 1.);
	Tree_Add(THEM->Curves, &c);
	CreateReversedCurve(THEM, c);
	List_Delete(temp);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_SEGM_CIRC;
      (yyval.s).Num = num;
    ;}
    break;

  case 88:
#line 1139 "Gmsh.y"
    {
      int num = (int)(yyvsp[-6].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindCurve(num, THEM)){
	yymsg(GERROR, "Curve %d already exists", num);
      }
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-3].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Curve *c = Create_Curve(num, MSH_SEGM_CIRC, 2, temp, NULL,
				-1, -1, 0., 1.);
	c->Circle.n[0] = (yyvsp[-1].v)[0];
	c->Circle.n[1] = (yyvsp[-1].v)[1];
	c->Circle.n[2] = (yyvsp[-1].v)[2];
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	End_Curve(c);
	Tree_Add(THEM->Curves, &c);
	Curve *rc = CreateReversedCurve(THEM, c);
	rc->Circle.n[0] = (yyvsp[-1].v)[0];
	rc->Circle.n[1] = (yyvsp[-1].v)[1];
	rc->Circle.n[2] = (yyvsp[-1].v)[2];
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	End_Curve(rc);
	List_Delete(temp);
      List_Delete((yyvsp[-3].l));
      (yyval.s).Type = MSH_SEGM_CIRC;
      (yyval.s).Num = num;
    ;}
    break;

  case 89:
#line 1165 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindCurve(num, THEM)){
	yymsg(GERROR, "Curve %d already exists", num);
      }
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Curve *c = Create_Curve(num, MSH_SEGM_ELLI, 2, temp, NULL,
				-1, -1, 0., 1.);
	Tree_Add(THEM->Curves, &c);
	CreateReversedCurve(THEM, c);
	List_Delete(temp);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_SEGM_ELLI;
      (yyval.s).Num = num;
    ;}
    break;

  case 90:
#line 1183 "Gmsh.y"
    {
      int num = (int)(yyvsp[-6].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindCurve(num, THEM)){
	yymsg(GERROR, "Curve %d already exists", num);
      }
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-3].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Curve *c = Create_Curve(num, MSH_SEGM_ELLI, 2, temp, NULL,
				-1, -1, 0., 1.);
	c->Circle.n[0] = (yyvsp[-1].v)[0];
	c->Circle.n[1] = (yyvsp[-1].v)[1];
	c->Circle.n[2] = (yyvsp[-1].v)[2];
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	End_Curve(c);
	Tree_Add(THEM->Curves, &c);
	Curve *rc = CreateReversedCurve(THEM, c);
	rc->Circle.n[0] = (yyvsp[-1].v)[0];
	rc->Circle.n[1] = (yyvsp[-1].v)[1];
	rc->Circle.n[2] = (yyvsp[-1].v)[2];
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	End_Curve(c);
	List_Delete(temp);
      }
      List_Delete((yyvsp[-3].l));
      (yyval.s).Type = MSH_SEGM_ELLI;
      (yyval.s).Num = num;
    ;}
    break;

  case 91:
#line 1210 "Gmsh.y"
    {
      int num = (int)(yyvsp[-14].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindCurve(num, THEM)){
	yymsg(GERROR, "Curve %d already exists", num);
      }
      else{
	Curve *c = Create_Curve(num, MSH_SEGM_PARAMETRIC, 2, NULL, NULL,
				-1, -1, (yyvsp[-10].d), (yyvsp[-8].d));
	strcpy(c->functu, (yyvsp[-6].c));
	strcpy(c->functv, (yyvsp[-4].c));
	strcpy(c->functw, (yyvsp[-2].c));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Tree_Add(THEM->Curves, &c);
	CreateReversedCurve(THEM, c);
      }
      Free((yyvsp[-6].c)); Free((yyvsp[-4].c)); Free((yyvsp[-2].c));
      (yyval.s).Type = MSH_SEGM_PARAMETRIC;
      (yyval.s).Num = num;
    ;}
    break;

  case 92:
#line 1229 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
      if(List_Nbr((yyvsp[-1].l)) < 4){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	yymsg(GERROR, "Too few control points for BSpline %d (%d < 4)", num,
	      List_Nbr((yyvsp[-1].l)));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      }
      else{
	if(FindCurve(num, THEM)){
	  yymsg(GERROR, "Curve %d already exists", num);
	}
	else{
	  List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  Curve *c = Create_Curve(num, MSH_SEGM_BSPLN, 2, temp, NULL,
				  -1, -1, 0., 1.);
	  Tree_Add(THEM->Curves, &c);
	  CreateReversedCurve(THEM, c);
	  List_Delete(temp);
	}
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_SEGM_BSPLN;
      (yyval.s).Num = num;
    ;}
    break;

  case 93:
#line 1253 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
      if(List_Nbr((yyvsp[-1].l)) < 4){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	yymsg(GERROR, "Too few control points for Bezier curve %d (%d < 4)", num,
	      List_Nbr((yyvsp[-1].l)));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      }
      else{
	if(FindCurve(num, THEM)){
	  yymsg(GERROR, "Curve %d already exists", num);
	}
	else{
	  List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  Curve *c = Create_Curve(num, MSH_SEGM_BEZIER, 2, temp, NULL,
				  -1, -1, 0., 1.);
	  Tree_Add(THEM->Curves, &c);
	  CreateReversedCurve(THEM, c);
	  List_Delete(temp);
	}
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_SEGM_BEZIER;
      (yyval.s).Num = num;
    ;}
    break;

  case 94:
#line 1277 "Gmsh.y"
    {
      int num = (int)(yyvsp[-8].d);
      if(List_Nbr((yyvsp[-5].l)) + (int)(yyvsp[-1].d) + 1 != List_Nbr((yyvsp[-3].l))){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	yymsg(GERROR, "Wrong definition of Nurbs Curve %d: "
	      "got %d knots, need N + D + 1 = %d + %d + 1 = %d",
	      (int)(yyvsp[-8].d), List_Nbr((yyvsp[-3].l)), List_Nbr((yyvsp[-5].l)), (int)(yyvsp[-1].d), List_Nbr((yyvsp[-5].l)) + (int)(yyvsp[-1].d) + 1);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else{
	if(FindCurve(num, THEM)){
	  yymsg(GERROR, "Curve %d already exists", num);
	}
	else{
	  List_T *temp = ListOfDouble2ListOfInt((yyvsp[-5].l));
	  Curve *c = Create_Curve(num, MSH_SEGM_NURBS, (int)(yyvsp[-1].d), temp, (yyvsp[-3].l),
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
				  -1, -1, 0., 1.);
	  Tree_Add(THEM->Curves, &c);
	  CreateReversedCurve(THEM, c);
	  List_Delete(temp);
	}
      }
      List_Delete((yyvsp[-5].l));
      List_Delete((yyvsp[-3].l));
      (yyval.s).Type = MSH_SEGM_NURBS;
      (yyval.s).Num = num;
    ;}
    break;

  case 95:
#line 1303 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindEdgeLoop(num, THEM)){
	yymsg(GERROR, "Line loop %d already exists", num);
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	sortEdgesInLoop(num, temp);
	EdgeLoop *l = Create_EdgeLoop(num, temp);
	Tree_Add(THEM->EdgeLoops, &l);
	List_Delete(temp);
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_SEGM_LOOP;
      (yyval.s).Num = num;
    ;}
    break;

  case 96:
#line 1320 "Gmsh.y"
    {
      for(int i = 0; i < List_Nbr((yyvsp[-9].l)); i++){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	double p;
      	List_Read((yyvsp[-9].l), i, &p);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	Curve *c = FindCurve((int)p, THEM);
        if(!c)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  yymsg(WARNING, "Unknown curve %d", (int)p);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	else{
	  Attractor *a = Create_Attractor(List_Nbr(THEM->Metric->Attractors)+1,
					  (yyvsp[-6].d), (yyvsp[-4].d), (yyvsp[-2].d), NULL, c, NULL);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  List_Add(THEM->Metric->Attractors, &a);
        }
      }
      // dummy values
      (yyval.s).Type = 0;
      (yyval.s).Num = 0;
    ;}
    break;

  case 97:
#line 1338 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindPhysicalGroup(num, MSH_PHYSICAL_LINE, THEM)){
	yymsg(GERROR, "Physical line %d already exists", num);
      }
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_LINE, temp);
	List_Delete(temp);
	List_Add(THEM->PhysicalGroups, &p);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_PHYSICAL_LINE;
      (yyval.s).Num = num;
    ;}
    break;

  case 98:
#line 1357 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindSurface(num, THEM)){
	yymsg(GERROR, "Surface %d already exists", num);
      }
      else{
	Surface *s = Create_Surface(num, MSH_SURF_PLAN);
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	setSurfaceGeneratrices(s, temp);
	List_Delete(temp);
	s->Support = s;
	End_Surface(s);
	Tree_Add(THEM->Surfaces, &s);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_SURF_PLAN;
      (yyval.s).Num = num;
    ;}
    break;

  case 99:
#line 1376 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d), type = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindSurface(num, THEM)){
	yymsg(GERROR, "Surface %d already exists", num);
      }
      else{
	double d;
	List_Read((yyvsp[-1].l), 0, &d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	EdgeLoop *el = FindEdgeLoop((int)fabs(d), THEM);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	if(!el){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  yymsg(GERROR, "Unknown line loop %d", (int)d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	}
	else{
	  int j = List_Nbr(el->Curves);
	  if(j == 4){
	    type = MSH_SURF_REGL;
	  }
	  else if(j == 3){
	    type = MSH_SURF_TRIC;
	  }
	  else{
	    yymsg(GERROR, "Wrong definition of Ruled Surface %d: "
		  "%d borders instead of 3 or 4", num, j);
	    type = MSH_SURF_PLAN;
	  }
	  Surface *s = Create_Surface(num, type);
	  List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  setSurfaceGeneratrices(s, temp);
	  List_Delete(temp);
	  s->Support = s;
	  End_Surface(s);
	  Tree_Add(THEM->Surfaces, &s);
	}
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = type;
      (yyval.s).Num = num;
    ;}
    break;

  case 100:
#line 1415 "Gmsh.y"
    {
      int num = (int)(yyvsp[-8].d);
      Surface *support = FindSurface((int)(yyvsp[-4].d), THEM);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(!support){
	yymsg(GERROR, "Unknown support surface %d", (int)(yyvsp[-4].d));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      }
      else{
	if(FindSurface(num, THEM)){
	  yymsg(GERROR, "Surface %d already exists", num);
	}
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  Surface *s = Create_Surface(num, MSH_SURF_TRIMMED);
	  List_T *temp = ListOfDouble2ListOfInt((yyvsp[-2].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  setSurfaceGeneratrices(s, temp);
	  List_Delete(temp);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  End_Surface(s);
	  Tree_Add(THEM->Surfaces, &s);
      List_Delete((yyvsp[-2].l));
      (yyval.s).Type = MSH_SURF_TRIMMED;
      (yyval.s).Num = num;
    ;}
    break;

  case 101:
#line 1442 "Gmsh.y"
    {
      int num = (int)(yyvsp[-16].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindSurface(num, THEM)){
	yymsg(GERROR, "Surface %d already exists", num);
      }
      else{
	CreateNurbsSurface(num, (int)(yyvsp[-4].d), (int)(yyvsp[-2].d), (yyvsp[-13].l), (yyvsp[-10].l), (yyvsp[-8].l));
      }
      for(int i = 0; i < List_Nbr((yyvsp[-13].l)); i++)
	List_Delete((List_T*)List_Pointer((yyvsp[-13].l), i));
      List_Delete((yyvsp[-13].l));
      List_Delete((yyvsp[-10].l));
      List_Delete((yyvsp[-8].l));
      (yyval.s).Type = MSH_SURF_NURBS;
      (yyval.s).Num = num;
    ;}
    break;

  case 102:
#line 1461 "Gmsh.y"
    {
      int num = (int)(yyvsp[-16].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindSurface(num, THEM)){
	yymsg(GERROR, "Surface %d already exists", num);
      }
      else{
	CreateNurbsSurfaceSupport(num, (int)(yyvsp[-4].d), (int)(yyvsp[-2].d), (yyvsp[-13].l), (yyvsp[-10].l), (yyvsp[-8].l));
      }
      for(int i = 0; i < List_Nbr((yyvsp[-13].l)); i++)
	List_Delete((List_T*)List_Pointer((yyvsp[-13].l), i));
      List_Delete((yyvsp[-13].l));
      List_Delete((yyvsp[-10].l));
      List_Delete((yyvsp[-8].l));
      (yyval.s).Type = MSH_SURF_NURBS;
      (yyval.s).Num = num;
    ;}
    break;

  case 103:
#line 1478 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindSurfaceLoop(num, THEM)){
	yymsg(GERROR, "Surface loop %d already exists", num);
      }
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	SurfaceLoop *l = Create_SurfaceLoop(num, temp);
	Tree_Add(THEM->SurfaceLoops, &l);
	List_Delete(temp);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_SURF_LOOP;
      (yyval.s).Num = num;
    ;}
    break;

  case 104:
#line 1494 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindPhysicalGroup(num, MSH_PHYSICAL_SURFACE, THEM)){
	yymsg(GERROR, "Physical surface %d already exists", num);
      }
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_SURFACE, temp);
	List_Delete(temp);
	List_Add(THEM->PhysicalGroups, &p);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_PHYSICAL_SURFACE;
      (yyval.s).Num = num;
    ;}
    break;

  case 105:
#line 1514 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindVolume(num, THEM)){
	yymsg(GERROR, "Volume %d already exists", num);
      }
      else{
	Volume *v = Create_Volume(num, MSH_VOLUME);
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	setVolumeSurfaces(v, temp);
	List_Delete(temp);
	Tree_Add(THEM->Volumes, &v);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_VOLUME;
      (yyval.s).Num = num;
    ;}
    break;

  case 106:
#line 1531 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindVolume(num, THEM)){
	yymsg(GERROR, "Volume %d already exists", num);
      }
      else{
	Volume *v = Create_Volume(num, MSH_VOLUME);
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	setVolumeSurfaces(v, temp);
	List_Delete(temp);
	Tree_Add(THEM->Volumes, &v);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_VOLUME;
      (yyval.s).Num = num;
    ;}
    break;

  case 107:
#line 1548 "Gmsh.y"
    {
      int num = (int)(yyvsp[-4].d);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(FindPhysicalGroup(num, MSH_PHYSICAL_VOLUME, THEM)){
	yymsg(GERROR, "Physical volume %d already exists", num);
      }
      else{
	List_T *temp = ListOfDouble2ListOfInt((yyvsp[-1].l));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_VOLUME, temp);
	List_Delete(temp);
	List_Add(THEM->PhysicalGroups, &p);
      }
      List_Delete((yyvsp[-1].l));
      (yyval.s).Type = MSH_PHYSICAL_VOLUME;
      (yyval.s).Num = num;
    ;}