当前位置: 首页>>代码示例>>C++>>正文


C++ Cube::WriteFile方法代码示例

本文整理汇总了C++中Cube::WriteFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::WriteFile方法的具体用法?C++ Cube::WriteFile怎么用?C++ Cube::WriteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cube的用法示例。


在下文中一共展示了Cube::WriteFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void
Extractor::Go()
{
  double val;

  for (int i=0; i<newcube.dimx; i++) {
    for (int j=0; j<newcube.dimy; j++) {
      for (int k=0; k<newcube.dimz; k++) {
	val=regioncode(i,j,k);
	if (xvflag==0 || val==xval)
	  newcube.SetValue(i,j,k,val);
      }
    }
  }
  newcube.WriteFile();

  return;
}
开发者ID:kimberg,项目名称:voxbo,代码行数:18,代码来源:extractmask.cpp

示例2: receive_3d


//.........这里部分代码省略.........
	if (!c)
		complain(ERROR_NOMEM);

	//----------------------------------------------
	// Store the user header into the Cube object.
	//
	for (i=0; i < total_header_items; i++) {
		c->header.push_back (user_header[i]);
	}

	//----------------------------------------------
	// Now we process specific user header data
	// that we know have equivalents in the Tes object.
	//
	for (i=0; i < total_header_items; i++) {
		const char *s = user_header[i].c_str();
		char *s2 = s ? strchr(s, ':') : NULL;
		if (s2 && '*' == *s2)
			continue;
#ifdef DEBUG
		fprintf(stderr, "putdata got user header line: %s\n", s);
#endif
		if (!s2) s2 = s ? strchr (s, '=') : NULL;
		if (s2) {
			*s2++ = 0;
			if (!strcasecmp (s, "VoxSizes(xyz)")) {
				double x,y,z;
				if (3 == sscanf (s2, "%lg %lg %lg", &x,&y,&z)) {
					c->voxsize[0] = x;
					c->voxsize[1] = y;
					c->voxsize[2] = z;
				} else {
					WARNING("invalid voxsizes from user header.");
				}
			}
			else
			if (!strcasecmp (s, "Origin(xyz)")) {
				int x,y,z;
				if (3 == sscanf (s2, "%d %d %d", &x,&y,&z)) {
					c->origin[0] = x;
					c->origin[1] = y;
					c->origin[2] = z;
				} else {
					WARNING("invalid origin from user header.");
				}
			}
			else
			if (!strcasecmp (s, "Orientation")) {
				c->orient = s2;
			} 
			else
			if (!strcasecmp (s, "Scale")) {
				// float f = atof(s2);
				// c->scalefactor = f ? f : 1.0;
			} 
			else
			if (!strcasecmp (s, "ByteOrder")) {
				c->filebyteorder = atoi(s2)? ENDIAN_BIG : ENDIAN_LITTLE;
			}
		} 
	}

	//----------------------------------------------
	// Get the data
	//
	ulong chunk_size = dimx * dimy * dimz * datasize;
	unsigned char *chunk = (unsigned char*) malloc (chunk_size);
	if (!chunk) 
		complain(ERROR_NOMEM);
	if (chunk_size != fread (chunk,1,chunk_size,f))
		complain(ERROR_READFAIL);

	fclose (f);
	read_completed = true;

	c->data = chunk;

	//----------------------------------------------
	// Write the Cube to a file.
	//
	c->SetFileName (path);
#ifdef DEBUG
	fprintf(stderr, "Calling write cube to file %s\n", path);
#endif
	c->WriteFile ();

	//----------------------------------------------
	// Return the success code
	//
	f = fopen (fifo_to_idl, "wb");
	if (!f)
		return 0;
	fprintf (f, "0\n");
	fflush(f);
	fclose(f);

	delete c;

	return 0;
}
开发者ID:Ampelbein,项目名称:voxbo,代码行数:101,代码来源:putdata.cpp

示例3: if

int
main(int argc,char *argv[])
{
  if (argc==1) {
    vbconv_help();
    exit(0);
  }
  tokenlist args;
  string outfile;
  int floatflag=0,nanflag=0,extractflag=0;
  set<int> includeset,excludeset;
  list<string> filelist;
  VBFF nullff;

  args.Transfer(argc-1,argv+1);
  for (size_t i=0; i<args.size(); i++) {
    if (args[i]=="-f")
      floatflag=1;
    else if (args[i]=="-n")
      nanflag=1;
    else if (args[i]=="-i" && i<args.size()-1) {
      includeset=numberset(args[++i]);
      if (includeset.empty()) {
        cout << "[E] vbconv: invalid inclusion range specified with -i\n";
        exit(111);
      }
    }
    else if (args[i]=="-e" && i<args.size()-1) {
      excludeset=numberset(args[++i]);
      if (excludeset.empty()) {
        cout << "[E] vbconv: invalid exclusion range specified with -e\n";
        exit(111);
      }
    }
    else if (args[i]=="-x" && i<args.size()-1)
      extractflag=1;
    else if (args[i]=="-v") {
      vbconv_version();
      exit(0);
    }
    else if (args[i]=="-h") {
      vbconv_help();
      exit(0);
    }
    else if (args[i]=="-o" && i<args.size()-1)
      outfile=args[++i];
    else {
      filelist.push_back(args[i]);
    }
  }

  if (filelist.size()<1) {
    printf("[E] vbconv: requires at least one input file\n");
    exit(10);
  }
  // if there's no -o flag and exactly two files specified, convert
  // the first to the second
  if (filelist.size()==2 && outfile.size()==0) {
    outfile=filelist.back();
    filelist.pop_back();
  }
  if (outfile.size()==0) {
    printf("[E] vbconv: requires an output filename be provided\n");
    exit(11);
  }

  // multiple files, must be 3D/4D combination
  if (filelist.size()>1) {
    Tes newtes;
    ConvertMultiple(filelist,nanflag,floatflag,newtes);
    if (WriteTes(newtes,outfile,extractflag,floatflag,nanflag,includeset,excludeset))
      exit(223);
    exit(0);  // just in case
  }
  int err;
  // just one file, see what kind
  Cube cb;
  if (cb.ReadFile(filelist.front())==0) {
    cb.fileformat=nullff;
    if (floatflag && cb.datatype!=vb_float)
      cb.convert_type(vb_float);
    if (nanflag)
      cb.removenans();
    if ((err=cb.WriteFile(outfile))) {
      printf("[E] vbconv: error %d writing %s\n",err,outfile.c_str());
      exit(4);
    }
    else {
      printf("[I] vbconv: wrote cube %s\n",outfile.c_str());
      exit(0);
    }
  }
  Tes ts;
  if (ts.ReadFile(filelist.front())==0) {
    ts.fileformat=nullff;
    if ((err=WriteTes(ts,outfile,extractflag,floatflag,nanflag,includeset,excludeset))) {
      printf("[E] vbconv: error %d writing %s\n",err,outfile.c_str());
      exit(4);
    }
    else {
//.........这里部分代码省略.........
开发者ID:kimberg,项目名称:voxbo,代码行数:101,代码来源:vbconv.cpp

示例4: exit

int
main(int argc,char *argv[])
{
  tokenlist args;
  Tes *tes;
  Cube *cub;
  int ind=0;
  stringstream tmps;

  args.Transfer(argc-1,argv+1);

  if (args.size() == 0) {
    tes2cub_help();
    exit(0);
  }

  if (args.size() != 2 && args.size() != 3) {
    tes2cub_help();
    exit(5);
  }

  if (args.size() == 3)
    ind = strtol(args[2]);
  tes = new Tes();
  if (tes->ReadFile(args[0])) {
    tmps.str("");
    tmps << "tes2cub: couldn't read tes file " << args[0];
    printErrorMsg(VB_ERROR,tmps.str());
    exit(5);
  }
  if (!tes->data_valid) {
    tmps.str("");
    tmps << "tes2cub: tes file " << args[0] << "isn't valid.";
    printErrorMsg(VB_ERROR,tmps.str());
    exit(5);
  }
  if (ind > tes->dimt) {
    tmps.str("");
    tmps << "tes2cub: index (" << ind << ") is beyond the last image (" << tes->dimt << ").";
    printErrorMsg(VB_ERROR,tmps.str());
    exit(5);
  } 
  cub = new Cube((*tes)[ind]);
  if (!cub->data_valid) {
    tmps.str("");
    tmps << "tes2cub: error extracting the cube from the 4D file (shouldn't happen!).";
    printErrorMsg(VB_ERROR,tmps.str());
    exit(5);
  } 
  if (!cub->WriteFile(args[1])) {
    tmps.str("");
    tmps << "tes2cub: wrote cube " << ind << " to file " << args[1] << ".";
    printErrorMsg(VB_INFO,tmps.str());
    exit(0);
  }
  else {
    tmps.str("");
    tmps << "tes2cub: failed to write extracted cube to file " << args[1] << ".";
    printErrorMsg(VB_INFO,tmps.str());
    exit(5);
  }
  exit(0);
}
开发者ID:kimberg,项目名称:voxbo,代码行数:63,代码来源:tes2cub.cpp


注:本文中的Cube::WriteFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。