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


C++ smart_ptr::set_fp_data方法代码示例

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


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

示例1: read_surface

ulong read_surface(
	const std::string& fname, ulong nx, ulong ny,
	smart_ptr< h5_pool_iface > pool, const std::string& surf_name = "",
	const bool invert_z = false
) {
	// set C locale for proper numbers reading
	setlocale(LC_NUMERIC, "C");

	// open file
	std::ifstream f(fname.c_str(), std::ios::in);
	if(!f) {
		BSERR << "Error opening file " << fname << bs_end;
		return 0;
	}

	std::string linebuf;
	std::istringstream line_s;
	//std::size_t pos;
	//t_float point[3];
	//ulong row, col;

	// setup buffer with dimensions passed
	ulong dims[3] = {nx, ny};
	spv_float databuf = BS_KERNEL.create_object(v_float::bs_type());
	databuf->resize(dims[0] * dims[1] * 3);
	std::fill(databuf->begin(), databuf->end(), 0.);

	// actually read file
	ulong n_points = 0;
	while(std::getline(f, linebuf)) {
		line_s.clear();

		// parse some info from comments
		if(linebuf[0] == '#') {
			if(linebuf.find("Information from grid:") != std::string::npos) {
				// EarthVision grid format
				n_points = read_earth_vision_grid(f, dims, databuf);
				break;
			}
			continue;
		}
		// skip ! comments
		if(linebuf[0] == '!') continue;

		if(linebuf.substr(0, 6) == "FSASCI") {
			// CPS-3 grid format
			n_points = read_cps3_grid(f, dims, databuf);
			break;
		}

		if(linebuf[0] == '@') {
			if(linebuf.find("grid") != std::string::npos) {
				// Zmap+grid format
				n_points = read_zmap_grid(f, dims, databuf);
				break;
			}
		}

		// try to read as Irap classic grid
		// TODO: impleent Irap reading
	}

	// restore locale
	setlocale(LC_NUMERIC, "");

	// check if we read nothing
	if(!n_points) {
		BSERR << "No valid data is read from " << fname << bs_end;
		return n_points;
	}
	else {
		BSOUT << "read_surface: succefully read " << n_points << " points from " << fname << bs_end;
	}

	// find out surface name
	std::string surf_name_ = surf_name;
	if(!surf_name.size()) {
		surf_name_ = fname.substr(0, fname.rfind('.'));
		const std::size_t slashpos = std::min(surf_name_.rfind('/'), surf_name_.rfind('\\'));
		if(slashpos != std::string::npos)
			surf_name_ = surf_name_.substr(slashpos + 1);
	}

	// write array to pool
	if(invert_z) {
		for(ulong i = 0; i < databuf->size() / 3; ++i) {
			databuf->ss(i*3 + 2) = -databuf->ss(i*3 + 2);
		}
	}
	//npy_intp h5p_dims[] = { 0, npy_intp(dims[0]), 0, npy_intp(dims[1]), 0, 1 };
	npy_intp h5p_dims[] = { npy_intp(dims[0]), npy_intp(dims[1]), 3 };
	//pool->declare_fp_data(surf_name_, 0, 3, &h5p_dims[0], 1);
	pool->declare_fp_data(surf_name_, 0, 3, &h5p_dims[0], 0);
	pool->set_fp_data(surf_name_, databuf);
	return n_points;
}
开发者ID:bs-eagle,项目名称:bs-eagle,代码行数:96,代码来源:surface_reader.cpp


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