Пример #1
0
void Usage(OptionParser &op, const char * msg) {

	if (msg) {
		cerr << ProgName << " : " << msg << endl;
	}
	cerr << "Usage: " << ProgName << " [options] (-cmap cmap.txt | -omap omap.txt) file.vtf" << endl;
	op.PrintOptionHelp(stderr);

}
Пример #2
0
int	main(int argc, char **argv) {

	OptionParser op;
	FILE	*fp;
	const char	*metafile;
	const char	*datafile;

	float	timer = 0.0;
	float	read_timer = 0.0;
	float	write_timer = 0.0;
	float	xform_timer = 0.0;
	string	s;

	MyBase::SetErrMsgCB(ErrMsgCBHandler);

	//
	// Parse command line arguments
	//
	ProgName = Basename(argv[0]);

	if (op.AppendOptions(set_opts) < 0) {
		exit(1);
	}

	if (op.ParseOptions(&argc, argv, get_options) < 0) {
		exit(1);
	}

	if (opt.help) {
		cerr << "Usage: " << ProgName << " [options] vdfFile outputFile" << endl;
		op.PrintOptionHelp(stderr);
		exit(0);
	}

	if (argc != 3) {
		cerr << "Usage: " << ProgName << " [options] vdfFile dataFile" << endl;
		op.PrintOptionHelp(stderr);
		exit(1);
	}

	metafile = argv[1];	// Path to a vdf file
	datafile = argv[2];	// Path to raw data file 

    if (opt.debug) MyBase::SetDiagMsgFilePtr(stderr);

	WaveletBlockIOBase	*wbwriter3D = NULL;
	WaveCodecIO	*wcwriter = NULL;
	VDFIOBase *vdfio = NULL;

	size_t min[3] = {opt.xregion.min, opt.yregion.min, opt.zregion.min};
	size_t max[3] = {opt.xregion.max, opt.yregion.max, opt.zregion.max};

	// Determine if variable is 3D
	//
	MetadataVDC metadata (metafile);
	if (MetadataVDC::GetErrCode() != 0) {
		MyBase::SetErrMsg("Error processing metafile \"%s\"", metafile);
		exit(1);
	}
	Metadata::VarType_T vtype = metadata.GetVarType(opt.varname);
	if (vtype == Metadata::VARUNKNOWN) {
		MyBase::SetErrMsg("Unknown variable \"%s\"", opt.varname);
		exit(1);
	}

	
	bool vdc1 = (metadata.GetVDCType() == 1);
	if (vdc1) {

		// Create an appropriate WaveletBlock writer. 
		//
		if (min[0] == min[1] && min[1] == min[2] && min[2] == max[0] &&
			max[0] == max[1]  && max[1] == max[2] && max[2] == (size_t) -1 &&
			vtype == Metadata::VAR3D) {

			wbwriter3D = new WaveletBlock3DBufWriter(metadata);
		}
		else {
			wbwriter3D = new WaveletBlock3DRegionWriter(metadata);
		}
		vdfio = wbwriter3D;
	} 
	else {
		wcwriter = new WaveCodecIO(metadata, opt.nthreads);
		vdfio = wcwriter;
	}
	if (vdfio->GetErrCode() != 0) {
		exit(1);
	}

	fp = FOPEN64(datafile, "rb");
	if (! fp) {
		MyBase::SetErrMsg("Could not open file \"%s\" : %M", datafile);
		exit(1);
	}


	double t0 = GetTime();

	if (min[0] == min[1] && min[1] == min[2] && min[2] == max[0] &&
		max[0] == max[1]  && max[1] == max[2] && max[2] == (size_t) -1 &&
		vtype == Metadata::VAR3D) {

		process_volume(
			vdfio, fp, vtype, &read_timer,
			&write_timer, &xform_timer
		);
	}
	else {
		process_region(
			vdfio, fp, vtype, 
			&read_timer, &write_timer, &xform_timer
		);
	}


	timer = GetTime() - t0;

	if (! opt.quiet) {
		const float *range = vdfio->GetDataRange();

		fprintf(stdout, "read time : %f\n", read_timer);
		fprintf(stdout, "write time : %f\n", write_timer);
		fprintf(stdout, "transform time : %f\n", xform_timer);
		fprintf(stdout, "total transform time : %f\n", timer);
		fprintf(stdout, "min and max values of data output: %g, %g\n",range[0], range[1]);
	}

	exit(0);
}
Пример #3
0
int	main(int argc, char **argv) {

	OptionParser op;
	const char	*metafile;

	string	s;

	MyBase::SetErrMsgCB(ErrMsgCB);

	ProgName = Basename(argv[0]);

	if (op.AppendOptions(set_opts) < 0) {
		cerr << ProgName << " : " << op.GetErrMsg();
		exit(1);
	}

	if (op.ParseOptions(&argc, argv, get_options) < 0) {
		cerr << ProgName << " : " << op.GetErrMsg();
		exit(1);
	}

	if (opt.help) {
		cerr << "Usage: " << ProgName << " [options] metafile datafile" << endl;
		op.PrintOptionHelp(stderr);
		exit(0);
	}

	if (argc != 2) {
		cerr << "Usage: " << ProgName << " [options] metafile " << endl;
		op.PrintOptionHelp(stderr);
		exit(1);
	}

	metafile = argv[1];
	map <long, map <string, VarFileInfo > > statsvec;


	const MetadataVDC *metadata = new MetadataVDC(metafile);
	if (MyBase::GetErrCode() != 0) exit(1);

	if (getStats(metadata, statsvec) < 0) {
		exit(1);
	}
	

	string sort = opt.sort;

	int numApproximations;
	if (metadata->GetVDCType() == 2) {
		if (opt.level < 0) numApproximations = metadata->GetCRatios().size();
		else numApproximations = opt.level+1;
	} else {
		if (opt.level < 0) numApproximations = metadata->GetNumTransforms()+1;
		else numApproximations = opt.level+1;
	}

	if (sort.compare("time") == 0) {
		map <long, map <string, VarFileInfo > >::iterator iter1;
		for (iter1 = statsvec.begin(); iter1 != statsvec.end(); iter1++) {
			map <string, VarFileInfo>::iterator iter2;

			for (iter2 = iter1->second.begin(); iter2 != iter1->second.end(); iter2++) {
				const VarFileInfo &vfiref = iter2->second;

				for(int j=0; j<numApproximations; j++) {
					PrintVariable(metadata,vfiref, j);
				}
			}
		}
	}
	else if (sort.compare("level") == 0) {
		for (int j=0; j<numApproximations; j++) {
			map <long, map <string, VarFileInfo > >::iterator iter1;
			for (iter1 = statsvec.begin(); iter1 != statsvec.end(); iter1++) {
				map <string, VarFileInfo>::iterator iter2;

				for (iter2 = iter1->second.begin(); iter2 != iter1->second.end(); iter2++) {
					const VarFileInfo &vfiref = iter2->second;

					PrintVariable(metadata,vfiref, j);
				}
			}
		}
	}
	else if (sort.compare("varname") == 0) {
		const vector <string> varNames = metadata->GetVariableNames();
		vector <string>::const_iterator iter1;
		for (iter1=varNames.begin(); iter1 != varNames.end(); iter1++) {
		
			for (int j=0; j<numApproximations; j++) {
				map <long, map <string, VarFileInfo > >::iterator iter2;
				for (iter2 = statsvec.begin(); iter2 != statsvec.end(); iter2++) {

					const VarFileInfo &vfiref = iter2->second[*iter1];;

					PrintVariable(metadata,vfiref, j);
				}
			}
		}
	}
	else {
		MyBase::SetErrMsg("Invalid sort \"%s\"", sort.c_str());
		exit(1);
	}

	exit(0);
}