158 lines
4.7 KiB
C++
158 lines
4.7 KiB
C++
/********************************************************
|
||
* ██████╗ ██████╗████████╗██╗
|
||
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
||
* ██║ ███╗██║ ██║ ██║
|
||
* ██║ ██║██║ ██║ ██║
|
||
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
||
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
||
* Geophysical Computational Tools & Library (GCTL)
|
||
*
|
||
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
|
||
*
|
||
* GCTL is distributed under a dual licensing scheme. You can redistribute
|
||
* it and/or modify it under the terms of the GNU Lesser General Public
|
||
* License as published by the Free Software Foundation, either version 2
|
||
* of the License, or (at your option) any later version. You should have
|
||
* received a copy of the GNU Lesser General Public License along with this
|
||
* program. If not, see <http://www.gnu.org/licenses/>.
|
||
*
|
||
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
||
* the GCTL, please consider the option to obtain a commercial license for a
|
||
* fee. These licenses are offered by the GCTL's original author. As a rule,
|
||
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
||
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
||
* to include some description of your company and the realm of its activities.
|
||
* Also add information on how to contact you by electronic and paper mail.
|
||
******************************************************/
|
||
|
||
#ifndef _GCTL_MESHDATA_H
|
||
#define _GCTL_MESHDATA_H
|
||
|
||
#include "gctl_mesh_config.h"
|
||
#include "gctl/core.h"
|
||
#include "gctl/geometry.h"
|
||
|
||
namespace gctl
|
||
{
|
||
/**
|
||
* @brief 网格数据的数值类型
|
||
*/
|
||
enum mesh_data_value_e
|
||
{
|
||
Scalar, ///< 标量数据
|
||
Vector, ///< 矢量数据
|
||
Tensor, ///< 张量数据
|
||
};
|
||
|
||
/**
|
||
* @brief 网格文件中的数据对象(纯虚类)。此类为具体类型的数据对象的基类
|
||
*/
|
||
class meshdata
|
||
{
|
||
protected:
|
||
std::string datname; // 数据的名称
|
||
mesh_data_type_e dattype; // 数据的赋值属性 顶点或是元素(设置后不可更改)
|
||
mesh_data_value_e valtype; // 数据的类型(设置后不可更改)
|
||
bool output_ok; // 是否可输出数据
|
||
|
||
public:
|
||
// 构造函数
|
||
meshdata(std::string in_name, mesh_data_type_e in_type, bool if_output);
|
||
|
||
// 析构函数
|
||
virtual ~meshdata();
|
||
|
||
/**
|
||
* @brief 设置数据名称
|
||
*
|
||
* @param[in] in_name 名称字符串
|
||
*/
|
||
void set_datname(std::string in_name);
|
||
|
||
/**
|
||
* @brief 返回数据的名称
|
||
*
|
||
* @return 名称字符串
|
||
*/
|
||
std::string get_datname();
|
||
|
||
/**
|
||
* @brief 返回数据的赋值类型
|
||
*
|
||
* @return 数据赋值类型的枚举
|
||
*/
|
||
mesh_data_type_e get_dattype();
|
||
|
||
/**
|
||
* @brief 返回数据值的类型
|
||
*
|
||
* @return 数据值类型的枚举
|
||
*/
|
||
mesh_data_value_e get_valtype();
|
||
|
||
/**
|
||
* @brief 设置数据对象输出状态的设置情况
|
||
*
|
||
* @param[in] if_output 是否可输出此对象
|
||
*/
|
||
void set_output(bool if_output);
|
||
|
||
/**
|
||
* @brief 返回数据对象输出状态的设置情况
|
||
*
|
||
* @return 是否可输出此对象
|
||
*/
|
||
bool get_output();
|
||
|
||
/**
|
||
* @brief 显示数据对象的头信息
|
||
*/
|
||
void show_info(std::ostream &os = std::clog);
|
||
|
||
/**
|
||
* @brief 显示数据统计参数
|
||
*/
|
||
virtual void show_stats(std::ostream &os = std::clog) = 0;
|
||
|
||
/**
|
||
* @brief 返回数据块的指针 所有子类的数据块均为gctl::array类型,这是一个通用的接口。
|
||
*
|
||
* @note 注意因为具体的返回类型未知 因此需在调用后按实际数据类型转换指针
|
||
*
|
||
* @return 数据块的指针
|
||
*/
|
||
virtual void *get_datval_ptr() = 0;
|
||
|
||
/**
|
||
* @brief 载入二进制文件
|
||
*
|
||
* @warning 不要直接调用此函数,应该在网格类型的相应函数中调用
|
||
*
|
||
* @param infile 输入文件的流(以二进制方式打开)
|
||
*/
|
||
virtual void load_binary(std::ifstream &infile) = 0;
|
||
|
||
/**
|
||
* @brief 保存二进制文件
|
||
*
|
||
* @warning 不要直接调用此函数,应该在网格类型的相应函数中调用
|
||
*
|
||
* @param outfile 输出的文件流(以二进制方式打开)
|
||
*/
|
||
virtual void save_binary(std::ofstream &outfile) = 0;
|
||
|
||
/**
|
||
* @brief 销毁指针的对象 可销毁此基类或子类指针指向的对象
|
||
*
|
||
* @param obj_ptr 网格数据指针
|
||
*/
|
||
static void destroy(meshdata *obj_ptr)
|
||
{
|
||
delete obj_ptr;
|
||
obj_ptr = nullptr;
|
||
return;
|
||
}
|
||
};
|
||
}
|
||
|
||
#endif //_GCTL_MESHDATA_H
|