Skip to content
Snippets Groups Projects
Gmsh.tab.cpp 426 KiB
Newer Older
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed


Christophe Geuzaine's avatar
Christophe Geuzaine committed
#line 5320 "Gmsh.y"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

int PrintListOfDouble(char *format, List_T *list, char *buffer)
{
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  // if format does not contain formatting characters, dump the list (useful for
  // quick debugging of lists)
  for(unsigned int i = 0; i < strlen(format); i++)
    if(format[i] == '%') numFormats++;
  if(!numFormats){
    strcpy(buffer, format);
    for(int i = 0; i < List_Nbr(list); i++){
      double d;
      List_Read(list, i, &d);
      char tmp[256];
Christophe Geuzaine's avatar
Christophe Geuzaine committed
      sprintf(tmp, " [%d]%g", i, d);
  char tmp1[256], tmp2[256];
  int j = 0, k = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  buffer[j] = '\0';

  while(j < (int)strlen(format) && format[j] != '%') j++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  strncpy(buffer, format, j);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  for(int i = 0; i < List_Nbr(list); i++){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    if(j < (int)strlen(format)){
      if(format[j] == '%'){
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      while(j < (int)strlen(format) && format[j] != '%') j++;
      if(k != j){
	strncpy(tmp1, &(format[k]), j-k);
	tmp1[j-k] = '\0';
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	sprintf(tmp2, tmp1, *(double*)List_Pointer(list, i));
	strcat(buffer, tmp2);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    else
  }
  if(j != (int)strlen(format))
    return -1;
  return 0;
}
fullMatrix<double> ListOfListOfDouble2Matrix(List_T *list)
{
  int M = List_Nbr(list);
  int N = 0;
  for(int i = 0; i < M; i++){
    List_T *line = *(List_T**)List_Pointer_Fast(list, i);
    N = std::max(N, List_Nbr(line));
  }
  fullMatrix<double> mat(M, N);
  for(int i = 0; i < M; i++){
    List_T *line = *(List_T**)List_Pointer_Fast(list, i);
    for(int j = 0; j < List_Nbr(line); j++){
      double val;
      List_Read(line, j, &val);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
      mat(i, j) = val;
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  for(int i = 0; i < List_Nbr(list); i++)
    List_Delete(*(List_T**)List_Pointer(list, i));
  List_Delete(list);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
void yyerror(const char *s)
  Msg::Error("'%s', line %d : %s (%s)", gmsh_yyname.c_str(), gmsh_yylineno - 1,
             s, gmsh_yytext);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  gmsh_yyerrorstate++;
void yymsg(int level, const char *fmt, ...)
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  char tmp[1024];
  va_start(args, fmt);
  vsprintf(tmp, fmt, args);
  va_end(args);
    Msg::Error("'%s', line %d : %s", gmsh_yyname.c_str(), gmsh_yylineno - 1, tmp);
    Msg::Warning("'%s', line %d : %s", gmsh_yyname.c_str(), gmsh_yylineno - 1, tmp);