本文整理汇总了C++中Cube::convert_type方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::convert_type方法的具体用法?C++ Cube::convert_type怎么用?C++ Cube::convert_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cube
的用法示例。
在下文中一共展示了Cube::convert_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
int
tes1_read_vol(Tes &ts,Cube &cb,int t)
{
gzFile fp;
string keyword;
tokenlist args;
int cnt;
// Tes::ReadHeader should already have read the header, which
// includes the mask
if (!ts.header_valid)
return (100);
if (t<0 || t>ts.dimt-1)
return 101;
fp=gzopen(ts.GetFileName().c_str(),"r");
if (!fp)
return (100);
// skip the header and mask and advance to our image position
gzseek(fp,ts.offset+(t*ts.datasize),SEEK_SET);
cb.SetVolume(ts.dimx,ts.dimy,ts.dimz,ts.datatype);
if (!cb.data)
return 102;
int index=0;
for (int k=0; k<ts.dimz; k++) {
for (int j=0; j<ts.dimy; j++) {
for (int i=0; i<ts.dimx; i++) {
if (ts.mask[index]) {
cnt=gzread(fp,cb.data+(ts.datasize*index),ts.datasize);
if (cnt!=ts.datasize) {
gzclose(fp);
return 103;
}
gzseek(fp,ts.datasize*(ts.dimt-1),SEEK_CUR);
}
index++;
}
}
}
gzclose(fp);
if (my_endian() != ts.filebyteorder)
cb.byteswap();
if (ts.f_scaled) {
if (ts.datatype==vb_byte || ts.datatype==vb_short || ts.datatype==vb_long)
cb.convert_type(vb_float);
cb*=ts.scl_slope;
cb+=ts.scl_inter;
}
return(0); // no error!
}
示例2: 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 {
//.........这里部分代码省略.........