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/nmSubWxs/nmDfnData.h

76 lines
3.6 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 NMDFNDATA_H
#define NMDFNDATA_H
#include <QLineF>
#include <QPolygonF>
#include <QString>
#include <QVector>
#include <QtCore/qnumeric.h>
// DFN 窗口之间传递的值记录,不持有实时工程对象或地图图元。
struct nmDfnRecord
{
// 新记录采用数据模型的有限导流默认值;来源索引仅供编辑会话保留旧属性。
nmDfnRecord() : m_dConductivity(1.0), m_dStorageRatio(1.0),
m_bFiniteConductivity(true), m_bVisible(true), m_nOriginalIndex(-1) {}
// 检查真正参与保存的几何与物性,非零有限长度才可形成裂缝。
bool isValid() const
{
const double dLength = m_oLine.length();
return qIsFinite(m_oLine.x1()) && qIsFinite(m_oLine.y1())
&& qIsFinite(m_oLine.x2()) && qIsFinite(m_oLine.y2())
&& qIsFinite(dLength) && dLength > 0.0
&& qIsFinite(m_dConductivity) && m_dConductivity >= 0.0
&& qIsFinite(m_dStorageRatio) && m_dStorageRatio >= 0.0;
}
// 精确比较业务值;显示单位或格式化文本不参与是否提交的判断。
bool operator==(const nmDfnRecord& oOther) const
{
return m_sName == oOther.m_sName && m_oLine.p1().x() == oOther.m_oLine.p1().x()
&& m_oLine.p1().y() == oOther.m_oLine.p1().y() && m_oLine.p2().x() == oOther.m_oLine.p2().x()
&& m_oLine.p2().y() == oOther.m_oLine.p2().y() && m_dConductivity == oOther.m_dConductivity
&& m_dStorageRatio == oOther.m_dStorageRatio && m_bFiniteConductivity == oOther.m_bFiniteConductivity
&& m_bVisible == oOther.m_bVisible && m_nOriginalIndex == oOther.m_nOriginalIndex;
}
QString m_sName; // 裂缝名称,文件导入及导出均保留。
QLineF m_oLine; // 米制起点、终点;长度统计使用整条线段长度。
double m_dConductivity; // 导流能力,基准单位 mD.m。
double m_dStorageRatio; // 模型已有的无量纲储能比 dW,不是裂缝宽度。
bool m_bFiniteConductivity; // true 为有限导流,false 为无限导流。
bool m_bVisible; // 原有地图可见性,编辑会话中保持。
int m_nOriginalIndex; // 原始快照索引,新生成或导入记录为 -1。
};
// 随机生成使用的边界值快照,不依赖窗口、图元或当前分析单例。
struct nmDfnBoundary
{
// 默认无有效边界,必须由所属分析提供。
nmDfnBoundary() : m_bCircle(false), m_dRadius(0.0) {}
// 返回采样包围框,圆形使用圆的外接矩形。
QRectF bounds() const
{
return m_bCircle ? QRectF(m_oCenter.x() - m_dRadius, m_oCenter.y() - m_dRadius,
2.0 * m_dRadius, 2.0 * m_dRadius) : m_oPolygon.boundingRect();
}
// 拒绝空边界、非有限坐标和退化包围框。
bool isValid() const
{
if (m_bCircle && (!qIsFinite(m_oCenter.x()) || !qIsFinite(m_oCenter.y())
|| !qIsFinite(m_dRadius) || m_dRadius <= 0.0)) return false;
if (!m_bCircle) {
if (m_oPolygon.size() < 3) return false;
for (int i = 0; i < m_oPolygon.size(); ++i)
if (!qIsFinite(m_oPolygon[i].x()) || !qIsFinite(m_oPolygon[i].y())) return false;
}
const QRectF oBounds = bounds();
return qIsFinite(oBounds.width()) && qIsFinite(oBounds.height())
&& oBounds.width() > 0.0 && oBounds.height() > 0.0;
}
bool m_bCircle; // 是否使用圆形边界。
QPointF m_oCenter; // 圆心,米制坐标。
double m_dRadius; // 圆半径,单位 m。
QPolygonF m_oPolygon; // 矩形或多边形的有序顶点,单位 m。
};
#endif // NMDFNDATA_H