// ----------------------------------------------------- // --------------- TEST: FileUtil Class --------------- // ----------------------------------------------------- // --------------- TEST1: fullfile ------------- // ----------------------------------------------------- bool fullfileTest(){ std::string path = fullfile(3, "/Users/herbert19lee/Develop", "HRF", "Util"); if (path.compare("/Users/herbert19lee/Develop/HRF/Util") != 0) { return false; } //std::cout << path << std::endl; return true; }
/* Helper function to write an image to a directory of DICOM files using C++ */ static int write_dcm_dir_cpp(const char *path, const Image *const im, const Dcm_meta *const meta) { Image slice; // Initialize C intermediates init_im(&slice); // Initialize the metadata to defaults, if it is null Dcm_meta meta_new; set_meta_defaults(meta, &meta_new); // Get the number of leading zeros for the file names const int num_slices = im->nz; const int num_zeros = static_cast<int>(ceil(log10( static_cast<double>(num_slices)))); // Form the printf format string for file names #define BUF_LEN 16 char format[BUF_LEN]; snprintf(format, BUF_LEN, "%%0%dd.%s", num_zeros, ext_dcm); #undef BUF_LEN // Resize the slice buffer slice.nx = im->nx; slice.ny = im->ny; slice.nz = 1; slice.nc = im->nc; im_default_stride(&slice); if (im_resize(&slice)) { im_free(&slice); return SIFT3D_FAILURE; } // Copy the units to the slice memcpy(SIFT3D_IM_GET_UNITS(&slice), SIFT3D_IM_GET_UNITS(im), IM_NDIMS * sizeof(double)); // Get the maximum absolute value of the whole image volume const float max_val = im_max_abs(im); // Write each slice for (int i = 0; i < num_slices; i++) { // Form the slice file name #define BUF_LEN 1024 char buf[BUF_LEN]; snprintf(buf, BUF_LEN, format, i); // Form the full file path std::string fullfile(path + sepStr + buf); // Copy the data to the slice int x, y, z, c; SIFT3D_IM_LOOP_START_C(&slice, x, y, z, c) SIFT3D_IM_GET_VOX(&slice, x, y, z, c) = SIFT3D_IM_GET_VOX(im, x, y, i, c); SIFT3D_IM_LOOP_END_C // Generate a new SOPInstanceUID dcmGenerateUniqueIdentifier(meta_new.instance_uid, SITE_INSTANCE_UID_ROOT); // Set the instance number const unsigned int instance = static_cast<unsigned int>(i + 1); meta_new.instance_num = instance; // Write the slice to a file if (write_dcm(fullfile.c_str(), &slice, &meta_new, max_val)) { im_free(&slice); return SIFT3D_FAILURE; } } // Clean up im_free (&slice); return SIFT3D_SUCCESS; }
/* Helper funciton to read a directory of DICOM files using C++ */ static int read_dcm_dir_cpp(const char *path, Image *const im) { struct stat st; DIR *dir; struct dirent *ent; int i, nx, ny, nz, nc, num_files, off_z; // Verify that the directory exists if (stat(path, &st)) { SIFT3D_ERR("read_dcm_dir_cpp: cannot find file %s \n", path); return SIFT3D_FAILURE; } else if (!S_ISDIR(st.st_mode)) { SIFT3D_ERR("read_dcm_dir_cpp: file %s is not a directory \n", path); return SIFT3D_FAILURE; } // Open the directory if ((dir = opendir(path)) == NULL) { SIFT3D_ERR("read_dcm_dir_cpp: unexpected error opening " "directory %s \n", path); return SIFT3D_FAILURE; } // Get all of the .dcm files in the directory std::vector<Dicom> dicoms; while ((ent = readdir(dir)) != NULL) { // Form the full file path std::string fullfile(std::string(path) + sepStr + ent->d_name); // Check if it is a DICOM file if (im_get_format(fullfile.c_str()) != DICOM) continue; // Read the file Dicom dicom(fullfile); if (!dicom.isValid()) { closedir(dir); return SIFT3D_FAILURE; } // Add the file to the list dicoms.push_back(dicom); } // Release the directory closedir(dir); // Get the number of files num_files = dicoms.size(); // Verify that dicom files were found if (num_files == 0) { SIFT3D_ERR("read_dcm_dir_cpp: no DICOM files found in %s \n", path); return SIFT3D_FAILURE; } // Check that the files are from the same series const Dicom &first = dicoms[0]; for (int i = 1; i < num_files; i++) { const Dicom &dicom = dicoms[i]; if (!first.eqSeries(dicom)) { SIFT3D_ERR("read_dcm_dir_cpp: file %s is from a " "different series than file %s \n", dicom.name().c_str(), first.name().c_str()); return SIFT3D_FAILURE; } } // Initialize the output dimensions nx = first.getNx(); ny = first.getNy(); nc = first.getNc(); // Verify the dimensions of the other files, counting the total // series z-dimension nz = 0; for (i = 0; i < num_files; i++) { // Get a slice const Dicom &dicom = dicoms[i]; // Verify the dimensions if (dicom.getNx() != nx || dicom.getNy() != ny || dicom.getNc() != nc) { SIFT3D_ERR("read_dcm_dir_cpp: slice %s " "(%d, %d, %d) does not match the " "dimensions of slice %s (%d, %d, %d) \n", dicom.name().c_str(), dicom.getNx(), dicom.getNy(), dicom.getNc(), first.name().c_str(), nx, ny, nc); return SIFT3D_FAILURE; } // Count the z-dimension nz += dicom.getNz(); } // Resize the output im->nx = nx; im->ny = ny; im->nz = nz; im->nc = nc; im->ux = first.getUx(); im->uy = first.getUy(); im->uz = first.getUz(); im_default_stride(im); if (im_resize(im)) return SIFT3D_FAILURE; // Sort the slices by z position std::sort(dicoms.begin(), dicoms.end()); // Allocate a temporary image for the slices Image slice; init_im(&slice); // Read the image data off_z = 0; for (i = 0; i < num_files; i++) { int x, y, z, c; const char *slicename = dicoms[i].name().c_str(); // Read the slice if (read_dcm(slicename, &slice)) { im_free(&slice); return SIFT3D_FAILURE; } // Copy the data to the volume SIFT3D_IM_LOOP_START_C(&slice, x, y, z, c) SIFT3D_IM_GET_VOX(im, x, y, z + off_z, c) = SIFT3D_IM_GET_VOX(&slice, x, y, z, c); SIFT3D_IM_LOOP_END_C off_z += slice.nz; } assert(off_z == nz); im_free(&slice); return SIFT3D_SUCCESS; }
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; }