You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Include/nmNum/nmData/nmLayerGeometry.h

62 lines
3.5 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef NMLAYERGEOMETRY_H
#define NMLAYERGEOMETRY_H
#include "nmData_global.h"
#include <QColor>
#include <QString>
#include <QVector>
class nmDataLayer;
// 单层的值快照。长度统一为米,不持有 QObject,也不依赖界面或当前分析。
struct NM_DATA_EXPORT nmLayerGeometryRow
{
// 默认零厚度只用于待填充记录,补齐合法边界后才能参与几何提交。
nmLayerGeometryRow();
QString m_sName; // 层名称,独立于表格行号,插入其他层时不自动改名。
QColor m_clrLayer; // 层色块和剖面填充色,不参与几何计算。
double m_dTopDepth; // 顶深,单位 m;深度增大表示向下。
double m_dBottomDepth; // 底深,单位 m;有效层必须满足 m_dBottomDepth > m_dTopDepth。
double m_dThickness; // 层自身厚度,单位 m,不包含相邻层之间的间隙。
bool m_bLegacyGap; // true 表示与下一层分离;重排时按实际间距更新,末层为 false。
};
// 剖面展示和井深定位使用的分层几何副本,不描述参与求解的多层流动物性。
// 所有几何修改先在临时副本中计算,合法后才替换自身。
// 名称、颜色编辑无需重算边界,避免仅打开/改名就改变旧工程的数值精度。
class NM_DATA_EXPORT nmLayerGeometry
{
public:
QVector<nmLayerGeometryRow> m_vecLayers; // 按从上到下的物理顺序存放,与表格行顺序一致。
// 复制持久化对象的业务字段,不接管/修改输入对象;遇到空指针返回 false,result 不变。
// 允许复制空列表或旧的无效几何,是否可提交须另行调用 isValid() 判断。
static bool fromLayers(const QVector<nmDataLayer*>& layers, nmLayerGeometry& result);
// 检查有限数值、正厚度、厚度与边界一致、不重叠,以及厚度累计/整体跨度不溢出。
bool isValid() const;
// 汇总各层几何厚度用于界面显示,不包含历史间隙,也不回写储层参数 h。
// 本方法不负责校验数据。
double totalThickness() const;
// 按原始值精确比较,供未修改判定及外部修改检查使用;不比较格式化显示文本。
// geometryOnly 为 true 时忽略名称和颜色,仍比较边界、厚度及旧间隙标志。
bool equals(const nmLayerGeometry& other, bool geometryOnly = false) const;
// 以米制首层顶深重新排列,保留各层厚度及历史间距;失败时当前副本不变。
bool setFirstTop(double top);
// row 为零起始行号;调整该层厚度并重算后续边界,首层顶深和历史间距保持不变。
bool setThickness(int row, double thickness);
// 在 row 前插入,row == m_vecLayers.size() 表示末尾追加;新层上方不额外创建间隙。
bool insertLayer(int row, const QString& name, double thickness, const QColor& color);
// 至少保留一层;删除中间层时合并其两侧间距,删除首层时保留原首层顶深。
bool removeLayer(int row);
private:
// 就地重算边界,仅供临时副本调用;失败可能已改写部分行,不可直接用于正式副本。
// gaps 与 m_vecLayers 等长,表示各层上方间距;首层直接使用 firstTop。
bool relayout(double firstTop, const QVector<double>& gaps);
// 从实际顶底深度提取间距,第 0 项为零;不依赖可能与旧几何不一致的布尔标志。
QVector<double> gaps() const;
};
#endif // NMLAYERGEOMETRY_H