tmp
This commit is contained in:
parent
4023169559
commit
3bc94c1db2
@ -531,25 +531,20 @@ namespace gctl
|
||||
* @brief 生成一维网格节点数组,其中每一个点都是一个二维坐标点。
|
||||
*
|
||||
* @param out_ps 返回网格节点数组
|
||||
* @param[in] xmin x最小值
|
||||
* @param[in] xmax x最大值
|
||||
* @param[in] x_st x起始值
|
||||
* @param[in] x_ed x终止值
|
||||
* @param[in] dx x间隔
|
||||
* @param[in] ele 高程值
|
||||
*/
|
||||
template <typename T>
|
||||
void grid_points_1d(array<point2c<T>> &out_ps, T xmin, T xmax, T dx, T ele)
|
||||
void grid_points_1d(array<point2c<T>> &out_ps, T x_st, T x_ed, T dx, T ele)
|
||||
{
|
||||
if (xmin >= xmax || xmin + dx > xmax || dx <= 0)
|
||||
{
|
||||
throw std::invalid_argument("[gctl::grid_points_1d] Invalid parameters.");
|
||||
}
|
||||
|
||||
int xnum = round((xmax - xmin)/dx) + 1;
|
||||
int xnum = round(std::abs((x_ed - x_st)/dx)) + 1;
|
||||
|
||||
out_ps.resize(xnum);
|
||||
for (int i = 0; i < xnum; i++)
|
||||
{
|
||||
out_ps[i].x = xmin + dx*i;
|
||||
out_ps[i].x = x_st + dx*i;
|
||||
out_ps[i].y = ele;
|
||||
}
|
||||
return;
|
||||
|
@ -375,6 +375,20 @@ namespace gctl
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void grid_points_1d(array<point2p<T>> &obsp, T deg_st, T deg_ed, T ddeg, T rad)
|
||||
{
|
||||
int m = round(std::abs((deg_st - deg_ed)/ddeg)) + 1;
|
||||
|
||||
obsp.resize(m);
|
||||
for (size_t i = 0; i < m; i++)
|
||||
{
|
||||
obsp[i].arc = arc(deg_st + i*ddeg);
|
||||
obsp[i].rad = rad;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _GCTL_POINT2P_H
|
@ -963,6 +963,29 @@ void gctl::geodsv_io::fill_column_point2dc(const array<point2dc> &data, std::str
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::geodsv_io::fill_column_point2dp(const array<point2dp> &data, int rid, int cid, int p)
|
||||
{
|
||||
if (rid > col_num_ || cid > col_num_ || rid == cid || rid <= 0 || cid <= 0)
|
||||
{
|
||||
throw std::runtime_error("[gctl::geodsv_io] Invalid column index.");
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
std::string s;
|
||||
for (size_t i = 1; i <= std::min(row_num_, (int) data.size()); i++)
|
||||
{
|
||||
table_[i][rid].value(data[i - 1].rad, p);
|
||||
table_[i][cid].value(data[i - 1].arc, p);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::geodsv_io::fill_column_point2dp(const array<point2dp> &data, std::string rname, std::string cname, int p)
|
||||
{
|
||||
fill_column_point2dp(data, name_index(rname, false), name_index(cname, false), p);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::geodsv_io::fill_column_point3dc(const array<point3dc> &data, int xid, int yid, int zid, int p)
|
||||
{
|
||||
if (xid > col_num_ || yid > col_num_ || zid > col_num_ || xid == yid || yid == zid || xid == zid
|
||||
@ -1035,6 +1058,28 @@ void gctl::geodsv_io::get_column_point2dc(array<point2dc> &data, std::string xna
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::geodsv_io::get_column_point2dp(array<point2dp> &data, int rid, int cid)
|
||||
{
|
||||
if (rid > col_num_ || cid > col_num_ || rid == cid || rid <= 0 || cid <= 0)
|
||||
{
|
||||
throw std::runtime_error("[gctl::geodsv_io] Invalid column index.");
|
||||
}
|
||||
|
||||
data.resize(row_num_);
|
||||
for (size_t i = 1; i <= row_num_; i++)
|
||||
{
|
||||
data[i - 1].rad = table_[i][rid].value<double>();
|
||||
data[i - 1].arc = table_[i][cid].value<double>();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::geodsv_io::get_column_point2dp(array<point2dp> &data, std::string rname, std::string cname)
|
||||
{
|
||||
get_column_point2dp(data, name_index(rname, false), name_index(cname, false));
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::geodsv_io::get_column_point3dc(array<point3dc> &data, int xid, int yid, int zid)
|
||||
{
|
||||
if (xid > col_num_ || yid > col_num_ || zid > col_num_ || xid == yid || yid == zid || xid == zid
|
||||
|
@ -828,6 +828,26 @@ namespace gctl
|
||||
*/
|
||||
void fill_column_point2dc(const array<point2dc> &data, std::string xname, std::string yname, int p = 6);
|
||||
|
||||
/**
|
||||
* @brief 填充二维坐标列
|
||||
*
|
||||
* @param rid rad坐标列索引 从1开始
|
||||
* @param cid arc坐标列索引 从1开始
|
||||
* @param data 返回的二维坐标数据
|
||||
* @param p 填入的浮点数据有效位数(精度)
|
||||
*/
|
||||
void fill_column_point2dp(const array<point2dp> &data, int rid, int cid, int p = 6);
|
||||
|
||||
/**
|
||||
* @brief 填充二维坐标列
|
||||
*
|
||||
* @param rname rad坐标列名称
|
||||
* @param cname arc坐标列名称
|
||||
* @param data 返回的二维坐标数据
|
||||
* @param p 填入的浮点数据有效位数(精度)
|
||||
*/
|
||||
void fill_column_point2dp(const array<point2dp> &data, std::string rname, std::string cname, int p = 6);
|
||||
|
||||
/**
|
||||
* @brief 填充三维坐标列
|
||||
*
|
||||
@ -890,6 +910,24 @@ namespace gctl
|
||||
*/
|
||||
void get_column_point2dc(array<point2dc> &data, std::string xname, std::string yname);
|
||||
|
||||
/**
|
||||
* @brief 读取二维坐标列
|
||||
*
|
||||
* @param rid rad坐标列索引 从1开始
|
||||
* @param cid arc坐标列索引 从1开始
|
||||
* @param data 返回的二维坐标数据
|
||||
*/
|
||||
void get_column_point2dp(array<point2dp> &data, int rid, int cid);
|
||||
|
||||
/**
|
||||
* @brief 读取二维坐标列
|
||||
*
|
||||
* @param rname rad坐标列名称
|
||||
* @param cname arc坐标列名称
|
||||
* @param data 返回的二维坐标数据
|
||||
*/
|
||||
void get_column_point2dp(array<point2dp> &data, std::string rname, std::string cname);
|
||||
|
||||
/**
|
||||
* @brief 读取三维坐标列
|
||||
*
|
||||
|
@ -152,4 +152,15 @@ void gctl::gmshio::save_physical_groups(const array<gmsh_physical_group> &phy_gr
|
||||
}
|
||||
gmsh_out << "$EndPhysicalNames\n";
|
||||
return;
|
||||
}
|
||||
|
||||
int gctl::gmshio::physical_name2tag(const array<gmsh_physical_group> &phy_groups, std::string name)
|
||||
{
|
||||
for (size_t i = 0; i < phy_groups.size(); i++)
|
||||
{
|
||||
if (phy_groups[i].name == name) return phy_groups[i].phys_tag;
|
||||
}
|
||||
|
||||
throw std::runtime_error("[gctl::gmshio::physical_name2tag] Physical group name not found.");
|
||||
return -1;
|
||||
}
|
@ -61,6 +61,7 @@ namespace gctl
|
||||
|
||||
void read_physical_groups(array<gmsh_physical_group> &phy_groups);
|
||||
void save_physical_groups(const array<gmsh_physical_group> &phy_groups);
|
||||
int physical_name2tag(const array<gmsh_physical_group> &phy_groups, std::string name);
|
||||
|
||||
template <typename A> void read_node(array<vertex<point2dc, A>> &out_nodes);
|
||||
template <typename A> void read_node(array<vertex<point3dc, A>> &out_nodes);
|
||||
|
@ -48,6 +48,12 @@ namespace gctl
|
||||
return deg*GCTL_Pi/180.0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T deg(T arc)
|
||||
{
|
||||
return arc*180.0/GCTL_Pi;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T sind(T deg)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user