Ejemplo n.º 1
0
// Needs buffer of size BBI_MAX_LINE_LENGTH. Could possibly make it variable size
char *config_read_line(char *buf, FILE* in_file)
{

	if (!fgets(buf, BBI_MAX_LINE_LENGTH, in_file)) return NULL;
	trim_back(buf);
	if (*buf == NULL) return buf;
	char *p;
	while ( *(p = buf +(strlen(buf)-1) ) == '\\')
	{
		char line[BBI_MAX_LINE_LENGTH];
		if (fgets(line, sizeof line, in_file))
		{
			char *newline = trim_front(line);
			trim_back(newline);
			if (strlen(buf) + strlen(newline) < BBI_MAX_LINE_LENGTH) strcpy(p,newline);
			else
			{
				return buf;    // line too long, possible error message. for now it's just an error during later parsing
			}
		}
		else
		{
			return buf;    // FIX, possible error message.
		}
	}
	return buf;
}
Ejemplo n.º 2
0
void IChatHandler::_fCmd_Say(IWorldPlayer *_player, const char *_message)
{
	FDASSERT(_player);
	FDASSERT(_message);

	CFileReader t_message;
	t_message.setContent(_message);

	//read the name
	t_message.readString(m_buffer, BUF_SIZE);

	//you cannot pm yourself
	if (strcmp(_player->getCharacter()->getName(), m_buffer) == 0)
	{
		return;
	}

	//get the message
	_message = trim_front(t_message.getContentRest());

	IWorldPlayer *t_player = m_pserver->getPlayer(m_buffer);

	if (t_player)
	{
		//send to the sender
		_player->getClient()->send(IPacketCreator::privateMessage(_player, t_player, _message));

		//and to the receiver
		t_player->getClient()->send(IPacketCreator::privateMessage(_player, 0, _message));
	}
	else
	{
		_player->greenText("Not connected");
	}
}
Ejemplo n.º 3
0
int does_movie_exist(char *mov_name, char *moviefile){
  char *movie;

  if(mov_name == NULL || strlen(mov_name) < 1)return 0;
  trim(mov_name);
  movie = trim_front(mov_name);
  strcpy(moviefile, movie);
  strcat(moviefile, ".mp4");
  if(file_exists(moviefile) == 1)return 1;
  return 0;
}
Ejemplo n.º 4
0
char *get_moviefile_path(char *moviefile_path){
  char moviefile[1024], *movie;

  trim(movie_name);
  movie = trim_front(movie_name);
  strcpy(moviefile, movie);
  strcat(moviefile, movie_ext);
  strcpy(moviefile_path, "");

  // if a script is running  prepend path defined in script

  if(script_dir_path != NULL&&strlen(script_dir_path) > 0){
    strcat(moviefile_path, script_dir_path);
    strcat(moviefile_path, dirseparator);
  }
  strcat(moviefile_path, moviefile);
  return moviefile_path;
}
GtUword front_prune_edist_inplace(
#ifndef OUTSIDE_OF_GT
                         bool forward,
                         GtAllocatedMemory *frontspace,
#endif
                         Trimstat *trimstat,
                         Polished_point *best_polished_point,
                         Fronttrace *front_trace,
                         const Polishing_info *pol_info,
                         GtUword history,
                         GtUword minmatchnum,
                         GtUword maxalignedlendifference,
                         FTsequenceResources *ufsr,
                         GtUword ustart,
                         GtUword ulen,
                         FTsequenceResources *vfsr,
                         GtUword vstart,
                         GtUword vlen)
{
  const GtUword sumseqlength = ulen + vlen,
                minsizeforshift = sumseqlength/1000,
                minlenforhistorycheck = GT_MULT2(history);
  /* so the space for allocating the fronts is
     sizeof (Frontvalue) * ((m+n)/1000 + maxvalid), where maxvalid is a small
     constant. */
  GtUword distance, trimleft = 0, valid = 1UL, maxvalid = 0, sumvalid = 0;
  const uint64_t mask = ((uint64_t) 1) << (history-1);
  Frontvalue *validbasefront;
  bool diedout = false;
  Sequenceobject useq, vseq;

#ifdef OUTSIDE_OF_GT
  GtAllocatedMemory *frontspace = gt_malloc(sizeof *frontspace);
  frontspace->space = NULL;
  frontspace->allocated = 0;
  frontspace->offset = 0;
  sequenceobject_init(&useq,useqptr,ustart,ulen);
  sequenceobject_init(&vseq,vseqptr,vstart,vlen);
#else
  GtReadmode readmode = forward ? GT_READMODE_FORWARD : GT_READMODE_REVERSE;
  sequenceobject_init(&useq,ufsr->extend_char_access,ufsr->encseq,readmode,
                      ustart,ulen,ufsr->encseq_r,ufsr->sequence_cache,
                      ufsr->totallength);
  sequenceobject_init(&vseq,ufsr->extend_char_access,vfsr->encseq,readmode,
                      vstart,vlen,vfsr->encseq_r,vfsr->sequence_cache,
                      vfsr->totallength);
  frontspace->offset = 0;
#endif
#ifdef TRIM_INFO_OUT
  printf("regionalquality(minmatchnum)=" GT_WU "\n",minmatchnum);
#endif
  for (distance = 0, valid = 1UL; /* Nothing */; distance++, valid += 2)
  {
    GtUword trim, maxalignedlen, minlenfrommaxdiff;

#ifdef TRIM_INFO_OUT
    printf("distance=" GT_WU ",full=" GT_WU ",trimleft=" GT_WU
           ",valid=" GT_WU "\n",distance,
                  GT_MULT2(distance) + 1,
                  trimleft,valid);
#endif
    gt_assert(valid <= GT_MULT2(distance) + 1);
    sumvalid += valid;
    if (maxvalid < valid)
    {
      maxvalid = valid;
    }
    validbasefront = frontspace_allocate(minsizeforshift,trimleft,valid,
                                         frontspace);
    if (distance == 0)
    {
      validbasefront->row = 0;
      validbasefront->matchhistory = 0;
      validbasefront->matchhistory_count = 0;
      validbasefront->backreference = 0; /* No back reference */
      add_matches(validbasefront + distance,validbasefront,mask,&useq,&vseq);
      maxalignedlen = GT_MULT2(validbasefront->row);
    } else
    {
      gt_assert(valid >= 3UL);
      frontspace_check((const Frontvalue *) frontspace->space,
                       ((const Frontvalue *) frontspace->space)
                        + frontspace->allocated - 1,
                       validbasefront + trimleft);
      frontspace_check((const Frontvalue *) frontspace->space,
                       ((const Frontvalue *) frontspace->space)
                         + frontspace->allocated - 1,
                       validbasefront + trimleft + valid - 1);
      if (valid == 3UL)
      {
        maxalignedlen
          = front_second_inplace(validbasefront + distance,
                                 validbasefront + trimleft,
                                 history,
                                 &useq,
                                 &vseq);
      } else
      {
        maxalignedlen
          = front_next_inplace(validbasefront + distance,
                               validbasefront + trimleft,
                               validbasefront + trimleft + valid - 1,
                               history,
                               &useq,
                               &vseq);
      }
    }
    gt_assert(valid > 0);
    minlenfrommaxdiff = maxalignedlen >= maxalignedlendifference
                          ? maxalignedlen - maxalignedlendifference
                          : 0;
#ifdef TRIM_INFO_OUT
    printf("maxalignedlen=" GT_WU ",maxlenfrommaxdiff=" GT_WU "\n",
           maxalignedlen,minlenfrommaxdiff);
#endif
    trim = trim_front(true,
#ifdef TRIM_INFO_OUT
                      distance,
#endif
                      ulen,
                      vlen,
                      minmatchnum,
                      minlenforhistorycheck,
                      minlenfrommaxdiff,
                      validbasefront + distance,
                      validbasefront + trimleft,
                      validbasefront + trimleft + valid);
#ifdef TRIM_INFO_OUT
    printf("trim on left=" GT_WU "\n",trim);
#endif
    if (trim > 0)
    {
      trimleft += trim;
      gt_assert(valid >= trim);
      valid -= trim;
    }
    if (valid > 0)
    {
      trim = trim_front(false,
#ifdef TRIM_INFO_OUT
                        distance,
#endif
                        ulen,
                        vlen,
                        minmatchnum,
                        minlenforhistorycheck,
                        minlenfrommaxdiff,
                        validbasefront + distance,
                        validbasefront + trimleft + valid - 1,
                        validbasefront + trimleft - 1);
#ifdef TRIM_INFO_OUT
      printf("trim on right=" GT_WU "\n",trim);
#endif
      gt_assert(trim < valid);
      if (trim > 0)
      {
        gt_assert(valid >= trim);
        valid -= trim;
      }
    }
    if (valid == 0)
    {
      diedout = true;
      break;
    }
    if (front_trace != NULL)
    {
      front_trace_add_gen(front_trace,trimleft,valid);
    }
    update_trace_and_polished(best_polished_point,
#ifndef OUTSIDE_OF_GT
                              &useq.min_access_pos,
                              &vseq.min_access_pos,
#endif
                              front_trace,
                              pol_info,
                              distance,
                              trimleft,
                              validbasefront + distance,
                              validbasefront + trimleft,
                              validbasefront + trimleft + valid - 1);
    if ((vlen > ulen && vlen - ulen <= distance) ||
        (vlen <= ulen && ulen - vlen <= distance))
    {
      if (distance + vlen - ulen >= trimleft &&
          distance + vlen - ulen <= trimleft + valid - 1 &&
          validbasefront[distance + vlen - ulen].row == ulen)
      {
        break;
      }
    }
    if (distance >= sumseqlength)
    {
      break;
    }
  }
  trimstat_add(trimstat,diedout,sumvalid,maxvalid,distance,
               sizeof (Frontvalue) * frontspace->allocated,
#ifndef OUTSIDE_OF_GT
               useq.sequence_cache != NULL &&
               vseq.sequence_cache != NULL ? MAX(useq.sequence_cache->allocated,
                                                 vseq.sequence_cache->allocated)
                                           : 0
#else
               0
#endif
              );
  return diedout ? sumseqlength + 1 : distance;
}
Ejemplo n.º 6
0
void trim(std::string& s)
{
  trim_front(s);
  trim_back(s);
}
Ejemplo n.º 7
0
int readsmv(FILE *streamsmv, FILE *stream_out, casedata *smvcase){
  
  int igrid,ipdim;
  int islice,iplot3d,iboundary;
  char buffer[255];
  mesh *meshinfo=NULL;
  slice *sliceinfo=NULL;
  boundary *boundaryinfo=NULL;
  plot3d *plot3dinfo=NULL;
  int nmeshes, nsliceinfo, nplot3dinfo, nboundary_files;
  int itrnx, itrny, itrnz;

  igrid=0;
  ipdim=0;
  nmeshes=0;
  nsliceinfo=0;
  nplot3dinfo=0;
  nboundary_files=0;
  itrnx=0;
  itrny=0;
  itrnz=0;

  while(!feof(streamsmv)){
    if(fgets(buffer,255,streamsmv)==NULL)break;
    CheckMemory;
    if(strncmp(buffer," ",1)==0)continue;

    if(
      match(buffer,"SLCF") == 1||
      match(buffer,"SLCC") == 1||
      match(buffer,"SLFL") == 1||
      match(buffer,"SLCT") == 1
      ){
      nsliceinfo++;
      continue;
    }
    if(match(buffer,"BNDF") == 1||
       match(buffer,"BNDC") == 1
       ){
      nboundary_files++;
      continue;
    }
    if(
      match(buffer,"PL3D") == 1){
      nplot3dinfo++;
      continue;
    }
    if(match(buffer,"GRID") == 1){
      nmeshes++;
      continue;
    }
    if(match(buffer,"PDIM") == 1){
      ipdim++;
      continue;
    }
  }

  if(nmeshes!=ipdim){
    fprintf(stderr,"*** Error (fatal): number of GRID statements (%i) not equal to\n",nmeshes);
    fprintf(stderr,"                 number of PDIM statements (%i)\n",ipdim);
    exit(0);
  }

  // allocate memory for mesh info

  if(nmeshes>0&&nmeshes==ipdim){
    NewMemory((void **)&meshinfo,nmeshes*sizeof(mesh));
  }
  smvcase->meshinfo = meshinfo;
  smvcase->nmeshes = nmeshes;

  // allocate memory for slice file info

  if(nsliceinfo>0){
    slice *slicei;
    int i;

    NewMemory((void **)&sliceinfo,nsliceinfo*sizeof(slice));
    for(i=0;i<nsliceinfo;i++){
      slicei = sliceinfo + i;
      slicei->file=NULL;
    }
  }
  smvcase->sliceinfo=sliceinfo;
  smvcase->nsliceinfo = nsliceinfo;

  // allocate memory for boundary file info

  if(nboundary_files>0){
    boundary *boundaryi;
    int i;

    NewMemory((void **)&boundaryinfo,nboundary_files*sizeof(boundary));
    for(i=0;i<nboundary_files;i++){
      boundaryi = boundaryinfo + i;
      boundaryi->file=NULL;
    }
  }
  smvcase->boundaryinfo = boundaryinfo;
  smvcase->nboundary_files = nboundary_files;

  // allocate memory for plot3d file info

  if(nplot3dinfo>0){
    NewMemory((void **)&plot3dinfo,nplot3dinfo*sizeof(plot3d));
  }
  smvcase->nplot3dinfo = nplot3dinfo;
  smvcase->plot3dinfo = plot3dinfo;

  islice=0;
  iplot3d=0;
  iboundary=0;
  ipdim=0;
  igrid=0;
  rewind(streamsmv);
  while(!feof(streamsmv)){
    if(fgets(buffer,255,streamsmv)==NULL)break;
    CheckMemory;
    if(stream_out==NULL&&strncmp(buffer," ",1)==0)continue;

  /*
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ GRID ++++++++++++++++++++++++++++++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  */
    if(match(buffer,"GRID") == 1){
      mesh *meshi;
      float *xp, *yp, *zp;
      int ibar, jbar, kbar;

      meshi=meshinfo+igrid;
      igrid++;
      fgets(buffer,255,streamsmv);
      sscanf(buffer,"%i %i %i",&ibar,&jbar,&kbar);
      NewMemory((void **)&xp,sizeof(float)*(ibar+1));
      NewMemory((void **)&yp,sizeof(float)*(jbar+1));
      NewMemory((void **)&zp,sizeof(float)*(kbar+1));
      meshi->ibar=ibar;
      meshi->jbar=jbar;      
      meshi->kbar=kbar;
      meshi->xplt=xp;
      meshi->yplt=yp;
      meshi->zplt=zp;

      if(stream_out!=NULL){
        trim(buffer);
        fprintf(stream_out,"GRID\n%s\n",buffer);
      }
      
      continue;
    }
  /*
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ PDIM ++++++++++++++++++++++++++++++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  */
    if(match(buffer,"PDIM") == 1){
      mesh *meshi;

      meshi=meshinfo+ipdim;
      ipdim++;
      fgets(buffer,255,streamsmv);
      sscanf(buffer,"%f %f %f %f %f %f",&meshi->xbar0,&meshi->xbar,&meshi->ybar0,&meshi->ybar,&meshi->zbar0,&meshi->zbar);
      if(stream_out!=NULL){
        trim(buffer);
        fprintf(stream_out,"PDIM\n%s\n",buffer);
      }
      continue;
    }
  /*
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ TRNX ++++++++++++++++++++++++++++++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  */
    if(match(buffer,"TRNX")==1){
      float *xpltcopy, *xplt;
      int ibar, idummy, nn;
      mesh *meshi;

      if(stream_out!=NULL){
        trim(buffer);
        fprintf(stream_out,"%s\n",buffer);
      }
      itrnx++;
      meshi = meshinfo + itrnx - 1;
      xpltcopy=meshi->xplt;
      xplt = meshi->xplt;

      ibar=meshi->ibar;
      fgets(buffer,255,streamsmv);
      if(stream_out!=NULL){
        trim(buffer);
        fprintf(stream_out,"%s\n",buffer);
      }
      sscanf(buffer,"%i ",&idummy);
      for(nn=0;nn<idummy;nn++){
        fgets(buffer,255,streamsmv);
        if(stream_out!=NULL){
          trim(buffer);
          fprintf(stream_out,"%s\n",buffer);
        }
      }
      for(nn=0;nn<=ibar;nn++){
        fgets(buffer,255,streamsmv);
        if(stream_out!=NULL){
          trim(buffer);
          fprintf(stream_out,"%s\n",buffer);
        }
        sscanf(buffer,"%i %f",&idummy,xpltcopy);
        xpltcopy++;
      }
      meshi->dx=xplt[1]-xplt[0];
      
      continue;
    }
  /*
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ TRNY ++++++++++++++++++++++++++++++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  */
    if(match(buffer,"TRNY")==1){
      float *ypltcopy, *yplt;
      int jbar, idummy, nn;
      mesh *meshi;

      if(stream_out!=NULL){
        trim(buffer);
        fprintf(stream_out,"%s\n",buffer);
      }
      itrny++;
      meshi = meshinfo + itrny - 1;
      yplt = meshi->yplt;
      ypltcopy=meshi->yplt;
      jbar=meshi->jbar;
      fgets(buffer,255,streamsmv);
      if(stream_out!=NULL){
        trim(buffer);
        fprintf(stream_out,"%s\n",buffer);
      }
      sscanf(buffer,"%i ",&idummy);
      for(nn=0;nn<idummy;nn++){
        fgets(buffer,255,streamsmv);
        if(stream_out!=NULL){
          trim(buffer);
          fprintf(stream_out,"%s\n",buffer);
        }
      }
      for(nn=0;nn<=jbar;nn++){
        fgets(buffer,255,streamsmv);
        if(stream_out!=NULL){
          trim(buffer);
          fprintf(stream_out,"%s\n",buffer);
        }
        sscanf(buffer,"%i %f",&idummy,ypltcopy);
        ypltcopy++;
      }
      meshi->dy=yplt[1]-yplt[0];
      continue;
    }
  /*
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ TRNZ ++++++++++++++++++++++++++++++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  */
    if(match(buffer,"TRNZ")==1){
      float *zpltcopy,*zplt;
      int kbar, idummy, nn;
      mesh *meshi;

      if(stream_out!=NULL){
        trim(buffer);
        fprintf(stream_out,"%s\n",buffer);
      }
      itrnz++;
      meshi = meshinfo + itrnz - 1;
      zplt = meshi->zplt;
      zpltcopy=meshi->zplt;
      kbar=meshi->kbar;
      fgets(buffer,255,streamsmv);
      if(stream_out!=NULL){
        trim(buffer);
        fprintf(stream_out,"%s\n",buffer);
      }
      sscanf(buffer,"%i ",&idummy);
      for(nn=0;nn<idummy;nn++){
        fgets(buffer,255,streamsmv);
        if(stream_out!=NULL){
          trim(buffer);
          fprintf(stream_out,"%s\n",buffer);
        }
      }
      for(nn=0;nn<=kbar;nn++){
        fgets(buffer,255,streamsmv);
        if(stream_out!=NULL){
          trim(buffer);
          fprintf(stream_out,"%s\n",buffer);
        }
        sscanf(buffer,"%i %f",&idummy,zpltcopy);
        zpltcopy++;
      }
      meshi->dz = zplt[1]-zplt[0];
      continue;
    }
    if(match(buffer,"ENDF") == 1){
      char endian_filename[1024];
      FILE *ENDIANfile;
      int endian=0, endian_native, endian_data, len;

      if(fgets(buffer,255,streamsmv)==NULL)break;
      len=strlen(buffer);
      buffer[len-1]='\0';
      trim(buffer);
      fullfile(endian_filename,smvcase->dir,buffer);
      ENDIANfile = fopen(endian_filename,"rb");
      if(ENDIANfile!=NULL){
        endian_native = getendian();
        FSEEK(ENDIANfile,4,SEEK_SET);
        fread(&endian_data,4,1,ENDIANfile);
        fclose(ENDIANfile);
        endian=endian_native;
        if(endian_data!=1)endian=1-endian_native;
        smvcase->endian=endian;
      }
      if(stream_out!=NULL){
        int lenout;

        make_outfile(endian_filename, NULL, buffer, ".end");
        fprintf(stream_out,"ENDF\n %s\n",endian_filename);
        make_outfile(endian_filename, destdir, buffer, ".end");
        lenout=strlen(endian_filename);
        FORTendianout(endian_filename,lenout);
      }
      continue;
    }
  /*
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ PL3D ++++++++++++++++++++++++++++++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  */
    if(match(buffer,"PL3D") == 1){
      mesh *plot3dmesh;
      plot3d *plot3di;
      float time_local;
      int meshnumber=1;
      char full_file[1024];
      FILE_SIZE filesize;

      if(strlen(buffer)>4){
        sscanf(buffer+4,"%f %i",&time_local,&meshnumber);
      }

      plot3dmesh = meshinfo + meshnumber - 1;

      plot3di = plot3dinfo + iplot3d;
      plot3di->plot3dmesh=plot3dmesh;
      plot3di->time=time_local;
      trim(buffer);
      strcpy(plot3di->keyword,buffer);

      fgets(buffer,255,streamsmv);
      fullfile(full_file,smvcase->dir,buffer);
      if(getfileinfo(full_file,NULL,&filesize)==0){
        NewMemory((void **)&plot3di->file,(unsigned int)(strlen(full_file)+1));
        NewMemory((void **)&plot3di->histogram[0],sizeof(histogramdata));
        NewMemory((void **)&plot3di->histogram[1],sizeof(histogramdata));
        NewMemory((void **)&plot3di->histogram[2],sizeof(histogramdata));
        NewMemory((void **)&plot3di->histogram[3],sizeof(histogramdata));
        NewMemory((void **)&plot3di->histogram[4],sizeof(histogramdata));
      
        CheckMemory;
        strcpy(plot3di->file,trim_front(buffer));
        CheckMemory;
        if(readlabels(plot3di->labels+0,streamsmv)==2)break;
        if(readlabels(plot3di->labels+1,streamsmv)==2)break;
        if(readlabels(plot3di->labels+2,streamsmv)==2)break;
        if(readlabels(plot3di->labels+3,streamsmv)==2)break;
        if(readlabels(plot3di->labels+4,streamsmv)==2)break;

        CheckMemory;
      
        iplot3d++;
      }
      else{
        if(display_warnings==1)fprintf(stderr,"*** Warning: the file, %s, does not exist.\n",full_file);
        CheckMemory;
        if(readlabels(plot3di->labels+0,streamsmv)==2)break;
        if(readlabels(plot3di->labels+1,streamsmv)==2)break;
        if(readlabels(plot3di->labels+2,streamsmv)==2)break;
        if(readlabels(plot3di->labels+3,streamsmv)==2)break;
        if(readlabels(plot3di->labels+4,streamsmv)==2)break;
        nplot3dinfo--;
        smvcase->nplot3dinfo=nplot3dinfo;
      }
      continue;
    }

  /*
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ SLCF ++++++++++++++++++++++++++++++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  */
    if(
      match(buffer,"SLCF") == 1||
      match(buffer,"SLCC") == 1||
      match(buffer,"SLFL") == 1||
      match(buffer,"SLCT") == 1)
    {
      int version_local=0;
      int len;
      FILE_SIZE filesize;
      slice *slicei;
      int meshnumber=0;
      mesh *slicemesh;
      char full_file[1024];

      len=strlen(buffer);
      if(len>4){
        sscanf(buffer+4,"%i %i",&meshnumber,&version_local);
      }

      slicei = sliceinfo + islice;

      slicemesh = smvcase->meshinfo+meshnumber-1;
      slicei->slicemesh = slicemesh;
      trim(buffer);

      strcpy(slicei->keyword,buffer);

      if(match(buffer,"SLCF") == 1){
        slicei->slicetype=1;
      }
      if(match(buffer,"SLCC") == 1){
        slicei->slicetype=2;
      }
      if(match(buffer,"SLFL") == 1){
        slicei->slicetype=3;
      }
      if(match(buffer,"SLCT") == 1){
        slicei->slicetype=4;
      }

      slicei->version=version_local;

      if(fgets(buffer,255,streamsmv)==NULL)break;
      trim(buffer);
      if(strlen(buffer)==0)break;
      fullfile(full_file,smvcase->dir,buffer);
      if(getfileinfo(full_file,NULL,&filesize)==0){
        int is1=-1, is2=-1, js1=-1, js2=-1, ks1=-1, ks2=-1;
        int ni, nj, nk;
        int error, lenfile;
        int endian;
        float *xplt, *yplt, *zplt;

        endian=getendian();
        NewMemory((void **)&slicei->file,(unsigned int)(strlen(full_file)+1));
        NewMemory((void **)&slicei->histogram,sizeof(histogramdata));
        STRCPY(slicei->file,trim_front(buffer));
        if(readlabels(&slicei->label,streamsmv)==2){
          fprintf(stderr,"*** Warning: problem reading SLCF entry\n");
          break;
        }
        slicei->filesize=filesize;
        lenfile=strlen(full_file);
        FORTgetsliceparms(full_file,&is1,&is2,&js1,&js2,&ks1,&ks2,&ni,&nj,&nk,&slicei->volslice,&error,lenfile);
        slicei->is1=is1;
        slicei->is2=is2;
        slicei->js1=js1;
        slicei->js2=js2;
        slicei->ks1=ks1;
        slicei->ks2=ks2;
        xplt = slicemesh->xplt;
        yplt = slicemesh->yplt;
        zplt = slicemesh->zplt;
        slicei->xmin = xplt[is1];
        slicei->xmax = xplt[is2];
        slicei->ymin = yplt[js1];
        slicei->ymax = yplt[js2];
        slicei->zmin = zplt[ks1];
        slicei->zmax = zplt[ks2];
        slicei->slice2=NULL;

        islice++;
      }
      else{
        if(display_warnings==1)fprintf(stderr,"*** Warning: the file, %s, does not exist.\n",buffer);
        if(readlabels(&sliceinfo[islice].label,streamsmv)==2)break;
        nsliceinfo--;
        smvcase->nsliceinfo=nsliceinfo;
      }
      continue;
    }
  /*
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ BNDF ++++++++++++++++++++++++++++++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  */
    if(match(buffer,"BNDF") == 1||
       match(buffer,"BNDC") == 1
       ){
      int version_local=0;
      int len;
      FILE_SIZE filesize;
      boundary *boundaryi;
      int meshnumber=0;
      mesh *boundarymesh;
      char full_file[1024];

      len=strlen(buffer);
      if(len>4){
        sscanf(buffer+4,"%i %i",&meshnumber,&version_local);
      }

      boundaryi = boundaryinfo + iboundary;

      boundarymesh = smvcase->meshinfo+meshnumber-1;
      boundaryi->boundarymesh = boundarymesh;
      trim(buffer);

      strcpy(boundaryi->keyword,buffer);

      boundaryi->version=version_local;

      if(match(buffer,"BNDF") == 1){
        boundaryi->boundarytype=1;
      }
      if(match(buffer,"BNDC") == 1){
        boundaryi->boundarytype=2;
      }

      if(fgets(buffer,255,streamsmv)==NULL)break;
      trim(buffer);
      if(strlen(buffer)==0)break;
      fullfile(full_file,smvcase->dir,buffer);
      if(getfileinfo(full_file,NULL,&filesize)==0){
        int lenfile, endian, npatches, error, boundaryunitnumber;

        NewMemory((void **)&boundaryi->file,(unsigned int)(strlen(full_file)+1));
        NewMemory((void **)&boundaryi->histogram,sizeof(histogramdata));
        STRCPY(boundaryi->file,trim_front(buffer));
        if(readlabels(&boundaryi->label,streamsmv)==2){
          fprintf(stderr,"*** Warning: problem reading BNDF entry\n");
          break;
        }
        boundaryi->filesize=filesize;
        lenfile=strlen(full_file);
        endian=getendian();
        boundaryunitnumber=15;
        FORTgetboundaryheader1(full_file,&boundaryunitnumber, &npatches, &error, lenfile);
        if(npatches>0){
          int *pi1, *pi2, *pj1, *pj2, *pk1, *pk2, *patchdir, *patch2index, *patchsize, *qoffset;
          int i;

          NewMemory((void **)&pi1,npatches*sizeof(int));
          NewMemory((void **)&pi2,npatches*sizeof(int));
          NewMemory((void **)&pj1,npatches*sizeof(int));
          NewMemory((void **)&pj2,npatches*sizeof(int));
          NewMemory((void **)&pk1,npatches*sizeof(int));
          NewMemory((void **)&pk2,npatches*sizeof(int));
          NewMemory((void **)&patchdir,npatches*sizeof(int));
          NewMemory((void **)&patch2index,npatches*sizeof(int));
          NewMemory((void **)&patchsize,npatches*sizeof(int));
          NewMemory((void **)&qoffset,npatches*sizeof(int));
          boundaryi->pi1=pi1;
          boundaryi->pi2=pi2;
          boundaryi->pj1=pj1;
          boundaryi->pj2=pj2;
          boundaryi->pk1=pk1;
          boundaryi->pk2=pk2;
          boundaryi->patchdir=patchdir;
          boundaryi->patch2index=patch2index;
          boundaryi->npatches=npatches;
          boundaryi->patchsize=patchsize;
          boundaryi->qoffset=qoffset;
          FORTgetboundaryheader2(&boundaryunitnumber, &version_local, &npatches, pi1, pi2, pj1, pj2, pk1, pk2, patchdir);
          for(i=0;i<npatches;i++){
            boundaryi->patchsize[i] = (pi2[i]+1-pi1[i])*(pj2[i]+1-pj1[i])*(pk2[i]+1-pk1[i]);
            if(i==0){
              boundaryi->qoffset[i]=0;
            }
            else{
              boundaryi->qoffset[i]=boundaryi->qoffset[i-1]+boundaryi->patchsize[i-1];
            }
          }
          CheckMemory;
       }

        boundaryi->boundary2=NULL;

        iboundary++;
      }
      else{
        fprintf(stderr,"*** Warning: the file, %s, does not exist.\n",buffer);
        if(readlabels(&boundaryinfo[iboundary].label,streamsmv)==2)break;
        nboundary_files--;
        smvcase->nboundary_files=nboundary_files;
      }
      continue;
    }

  /*
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++ vis keywords not differenced++++++++++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  */

    // skip over the following keywords

    if(
       match(buffer,"ISOF") == 1||
       match(buffer,"ISOG") == 1||
       match(buffer,"TISOF")==1||
       match(buffer,"SMOKE3D")==1||
       match(buffer,"SMOKF3D")==1||
       match(buffer,"VSMOKF3D")==1||
       match(buffer,"PART")==1||
       match(buffer,"EVAC")==1||
       match(buffer,"PRT5")==1||
       match(buffer,"EVA5")==1
       ){
      char comm[1024];

      strcpy(comm,buffer);
      fgets(buffer,255,streamsmv);
      if(match(comm,"PRT5")==1||match(comm,"EVA5")==1){
        int i, nlines;

        fgets(buffer,255,streamsmv);
        sscanf(buffer,"%i",&nlines);
        for(i=0;i<nlines;i++){
          fgets(buffer,255,streamsmv);
        }
      }
      else{
        fgets(buffer,255,streamsmv);
        fgets(buffer,255,streamsmv);
        fgets(buffer,255,streamsmv);
      }
      if(match(comm,"TISOF")==1){
        int i;

        for(i=0;i<3;i++){
          fgets(buffer,255,streamsmv);
        }
      }
      continue;
    }
    if(stream_out!=NULL){
      trim(buffer);
      fprintf(stream_out,"%s\n",buffer);
    }
    continue;
  }
  if(stream_out!=NULL){
    fprintf(stream_out,"SMOKEDIFF\n");
  }
  return 0;
}
Ejemplo n.º 8
0
	static void trim (std::string & str) {
	
		trim_back(str);
		trim_front(str);
	
	}
Ejemplo n.º 9
0
extern "C" void Smoke3d_CB(int var) {
    int i;
    char *tour_label;
    char *vol_prefixptr;

    updatemenu=1;
    switch(var) {
        float temp_min, temp_max;

    case VOL_UNLOAD_ALL:
        UnLoadVolSmoke3DMenu(-1);
        break;
    case VOL_PREFIX:
        break;
    case VOL_TOUR_LIST:
        TOUR_CB(TOUR_LIST);
        break;
    case START_FRAME:
        if(vol_startframe0<0) {
            vol_startframe0=0;
            SPINNER_startframe->set_int_val(vol_startframe0);
        }
        break;
    case SKIP_FRAME:
        if(vol_skipframe0<1) {
            vol_skipframe0=1;
            SPINNER_skipframe->set_int_val(vol_skipframe0);
        }
        break;
    case CANCEL_GENERATE_IMAGES:
        Script_CB(SCRIPT_CANCEL_NOW);
        break;
    case GENERATE_IMAGES:
        if(selected_tour==NULL) {
            tour_label=NULL;
        }
        else {
            tour_label=selected_tour->label;
        }
        trim(vol_prefix);
        vol_prefixptr=trim_front(vol_prefix);
        if(strlen(vol_prefixptr)==0)vol_prefixptr=fdsprefix;
        init_volrender_script(vol_prefixptr, tour_label, vol_startframe0, vol_skipframe0);
        break;
    case NONGPU_VOL_FACTOR:
        init_volrender_surface(NOT_FIRSTCALL);
        break;
    case GPU_VOL_FACTOR:
        break;
    case COMBINE_MESHES:
        define_volsmoke_textures();
        break;
    case SHOW_FIRECOLORMAP:
        Update_Smokecolormap(smoke_render_option);
        if(show_firecolormap==1) {
            show_glui_colorbar();
        }
        else {
            hide_glui_colorbar();
        }
        break;
    case TEMP_MIN:
        temp_min = 20.0;
        temp_max = (float)(10.0*(int)(temperature_cutoff/10.0)-10.0);
        SPINNER_temperature_min->set_float_limits(temp_min,temp_max);
        Update_Smokecolormap(smoke_render_option);
        break;
    case TEMP_CUTOFF:
        temp_min = (float)(10*(int)(temperature_min/10.0) + 10.0);
        temp_max = (float)(10*(int)(temperature_max/10.0) - 10.0);
        SPINNER_temperature_cutoff->set_float_limits(temp_min,temp_max);
        Update_Smokecolormap(smoke_render_option);
        break;
    case TEMP_MAX:
        temp_min = (float)(10*(int)(temperature_cutoff/10.0)+10.0);
        temp_max = 1800.0;
        SPINNER_temperature_max->set_float_limits(temp_min,temp_max);
        Update_Smokecolormap(smoke_render_option);
        break;
    case LOAD_COMPRESSED_DATA:
        if(load_volcompressed==1) {
            CHECKBOX_compress_volsmoke->disable();
        }
        else {
            CHECKBOX_compress_volsmoke->enable();
        }
        break;
    case SMOKE_OPTIONS:
        if(firecolormap_type!=FIRECOLORMAP_NOCONSTRAINT&&smoke_render_option==RENDER_SLICE) {
            PANEL_colormap2b->enable();
            SPINNER_hrrpuv_cutoff->enable();
            PANEL_colormap2b->open();
        }
        else {
            PANEL_colormap2b->disable();
            PANEL_colormap2b->close();
        }
        if(smoke_render_option==RENDER_SLICE) {
            if(PANEL_colormap2a!=NULL) {
                PANEL_colormap2a->disable();
                PANEL_colormap2a->close();
            }
            if(PANEL_absorption!=NULL)PANEL_absorption->enable();
            firecolormap_type=firecolormap_type_save;
            RADIO_use_colormap->set_int_val(firecolormap_type);
            RADIOBUTTON_direct->enable();
            SPINNER_smoke3d_fire_halfdepth->enable();
        }
        else {
            if(PANEL_colormap2a!=NULL) {
                PANEL_colormap2a->enable();
                PANEL_colormap2a->open();
            }
            if(PANEL_absorption!=NULL)PANEL_absorption->disable();
            firecolormap_type_save=firecolormap_type;
            firecolormap_type=FIRECOLORMAP_CONSTRAINT;
            RADIO_use_colormap->set_int_val(firecolormap_type);
            RADIOBUTTON_direct->disable();
            SPINNER_smoke3d_fire_halfdepth->disable();
        }
        Smoke3d_CB(FIRECOLORMAP_TYPE);
        Update_Smoke_Type();
        break;
    case FIRECOLORMAP_TYPE:
        if(firecolormap_type==FIRECOLORMAP_CONSTRAINT&&smoke_render_option==RENDER_VOLUME) {
            PANEL_colormap2a->open();
            PANEL_colormap2a->enable();
        }
        else {
            PANEL_colormap2a->close();
            PANEL_colormap2a->disable();
        }
        if(firecolormap_type!=FIRECOLORMAP_NOCONSTRAINT&&smoke_render_option==RENDER_SLICE) {
            PANEL_colormap2b->enable();
            SPINNER_hrrpuv_cutoff->enable();
            PANEL_colormap2b->open();
        }
        else {
            PANEL_colormap2b->disable();
            PANEL_colormap2b->close();
        }
        if(firecolormap_type!=FIRECOLORMAP_DIRECT) {
            LISTBOX_smoke_colorbar->enable();
            ROLLOUT_colormap3->disable();
            ROLLOUT_colormap3->close();
            if(fire_colorbar_index_save!=-1) {
                SmokeColorBarMenu(fire_colorbar_index_save);
            }
            else {
                SmokeColorBarMenu(fire_colorbar_index);
            }
        }
        else {
            LISTBOX_smoke_colorbar->disable();
            ROLLOUT_colormap3->enable();
            ROLLOUT_colormap3->open();
            SPINNER_smoke3d_smoke_albedo->enable();
            SPINNER_smoke3d_fire_red->enable();
            SPINNER_smoke3d_fire_green->enable();
            SPINNER_smoke3d_fire_blue->enable();
            SPINNER_smoke3d_fire_halfdepth->enable();

            fire_colorbar_index_save=fire_colorbar_index;
        }
        if(LISTBOX_smoke_colorbar->get_int_val()!=fire_colorbar_index) {
            LISTBOX_smoke_colorbar->set_int_val(fire_colorbar_index);
        }
        Update_Smokecolormap(smoke_render_option);
        break;
    case SMOKE_COLORBAR_LIST:
        SmokeColorBarMenu(fire_colorbar_index);
        Update_Smokecolormap(smoke_render_option);
        updatemenu=1;
        break;
    case SMOKETEST:
        update_alpha();
        break;
    case FRAMELOADING:
        smoke3dframestep = smoke3dframeskip+1;
        updatemenu=1;
        break;
    case SAVE_SETTINGS:
        writeini(LOCAL_INI,NULL);
        break;
    case GLOBAL_FIRE_CUTOFF:
        glutPostRedisplay();
        force_redisplay=1;
        Idle_CB();
        Update_Smokecolormap(smoke_render_option);
        break;
    case FIRE_RED:
    case FIRE_GREEN:
    case FIRE_BLUE:
    case SMOKE_SHADE:
        glutPostRedisplay();
        force_redisplay=1;
        Update_Smokecolormap(smoke_render_option);
        Idle_CB();
        break;
    case FIRE_HALFDEPTH:
        for(i=0; i<nmeshes; i++) {
            mesh *meshi;

            meshi = meshinfo + i;
            meshi->update_firehalfdepth=1;
        }
        glutPostRedisplay();
        force_redisplay=1;
        Update_Smokecolormap(smoke_render_option);
        Idle_CB();
        break;
#ifdef pp_GPU
    case SMOKE_RTHICK:

        smoke3d_thick = log_base2(smoke3d_rthick);
        glutPostRedisplay();
        force_redisplay=1;
        Idle_CB();
        break;
#else
    case SMOKE_THICK:
        glutPostRedisplay();
        force_redisplay=1;
        Idle_CB();
        break;
#endif
#ifdef pp_CULL
    case CULL_PORTSIZE:
        initcull(cullsmoke);
        break;
    case CULL_SMOKE:
        initcull(cullsmoke);
        break;
#endif
    case VOL_NGRID:
        glutPostRedisplay();
        break;
    case VOL_SMOKE:
    {
        volrenderdata *vr;

        vr = &meshinfo->volrenderinfo;
        if(vr!=NULL&&vr->smokeslice!=NULL&&vr->smokeslice->slicetype==SLICE_CENTER) {
            if(usegpu==1&&combine_meshes==1) {
                combine_meshes=0;
                update_combine_meshes();
                Smoke3d_CB(COMBINE_MESHES);
            }
            if(usegpu==0&&combine_meshes==0) {
                combine_meshes=1;
                update_combine_meshes();
                Smoke3d_CB(COMBINE_MESHES);
            }
        }
    }
    if(smoke_render_option==RENDER_SLICE) {
#ifdef pp_GPU
        if(usegpu==1) {
            RADIO_skipframes->set_int_val(0);
            RADIO_skipframes->disable();
#ifdef pp_CULL
            if(cullactive==1) {
                CHECKBOX_smokecullflag->enable();
            }
            SPINNER_cull_portsize->enable();
            CHECKBOX_show_cullports->enable();
#endif
        }
        else {
            RADIO_skipframes->enable();
#ifdef pp_CULL
            CHECKBOX_smokecullflag->disable();
            SPINNER_cull_portsize->disable();
            CHECKBOX_show_cullports->disable();
#endif
        }
#else
        RADIO_skipframes->enable();
#endif
    }
    break;
    default:
#ifdef _DEBUG
        abort();
#endif
        break;
    }
}
Ejemplo n.º 10
0
void init_lang(void){
  int maxlangs, nlangs;
  filelistdata *filelistinfo;
  int i;

  nlanglistinfo=0;
  maxlangs = get_nfilelist(smokeview_bindir,"*.po");
  if(maxlangs==0)return;
  nlangs = get_filelist(smokeview_bindir,"*.po", maxlangs, &filelistinfo);
  if(nlangs==0)return;
  for(i=0;i<nlangs;i++){
    char *file;
    filelistdata *filelisti;

    filelisti = filelistinfo + i;
    file=filelisti->file;
    if(strstr(file,"template")!=NULL||filelisti->type==1)continue;
    nlanglistinfo++;
  }
  if(nlanglistinfo==0)return;
  NewMemory((void **)&langlistinfo,nlanglistinfo*sizeof(langlistdata));
  nlanglistinfo=0;
  for(i=0;i<nlangs;i++){
    char *file;
    filelistdata *filelisti;
    langlistdata *langi;
    int len;
    char *lang_code;

    langi = langlistinfo + nlanglistinfo;
    filelisti = filelistinfo + i;
    file=filelisti->file;
    if(strstr(file,"template")!=NULL||filelisti->type==1)continue;
    trim(file);
    file=trim_front(file);
    len=strlen(file);
    langi->file=file;
    strncpy(langi->lang_code,file+len-5,2);
    langi->lang_code[2]='\0';
    lang_code=langi->lang_code;
    if(strcmp(lang_code,"fr")==0){
      strcpy(langi->lang_name,_("French"));
    }
    else if(strcmp(lang_code,"it")==0){
      strcpy(langi->lang_name,_("Italian"));
    }
    else if(strcmp(lang_code,"de")==0){
      strcpy(langi->lang_name,_("German"));
    }
    else if(strcmp(lang_code,"pl")==0){
      strcpy(langi->lang_name,_("Polish"));
    }
    else if(strcmp(lang_code,"es")==0){
      strcpy(langi->lang_name,_("Spanish"));
    }
    else{
      strcpy(langi->lang_name,langi->lang_code);
    }
    nlanglistinfo++;
  }
  init_translate(smokeview_bindir,tr_name);
}