本文整理汇总了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;
}