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.
65 lines
1.8 KiB
C++
65 lines
1.8 KiB
C++
#include "nmCalculationGeo.h"
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
#include <QStringList>
|
|
|
|
#include "nmCalculationGeoSurface.h"
|
|
#include "nmCalculationGeoWell.h"
|
|
|
|
nmCalculationGeo::nmCalculationGeo(const nmCalculationGeoDataOutline &outline, const QVector<nmCalculationGeoDataWell>& wellList, double lc): m_outline(outline),
|
|
m_vWellList(wellList), m_dGridSize(lc)
|
|
{
|
|
}
|
|
|
|
QString nmCalculationGeo::generateOCCGeoCodes(bool is3D)
|
|
{
|
|
int flag = 0;
|
|
QStringList geoLines;
|
|
// 生成线、面
|
|
nmCalculationGeoSurface surface(m_outline, m_dGridSize);
|
|
geoLines.append(surface.generateSurfaceGeoCodes());
|
|
// 对于井做处理
|
|
flag = flag + m_vWellList.size();
|
|
nmCalculationGeoWell wells(m_vWellList);
|
|
geoLines.append(wells.generateWellGeoCodes(flag));
|
|
geoLines.append("Transfinite Surface(1) = {1}; ");
|
|
|
|
if (is3D) {
|
|
// 设置网格厚度,目前只支持单层网格
|
|
double gridThickness = 0.2;
|
|
geoLines.append(QString("Extrude {0, 0, %1} {Surface{1};Layers{1};Recombine;}").arg(gridThickness));
|
|
}
|
|
|
|
return geoLines.join("\n");
|
|
}
|
|
|
|
void nmCalculationGeo::generate2DFile(const QString& fileName)
|
|
{
|
|
QFile file(fileName);
|
|
|
|
//检查
|
|
if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
qWarning("Cannot open file for writing: %s", qPrintable(file.errorString()));
|
|
return;
|
|
}
|
|
|
|
QTextStream out(&file);
|
|
out << generateOCCGeoCodes(false);
|
|
file.close();
|
|
}
|
|
|
|
void nmCalculationGeo::generate3DFile(const QString& fileName)
|
|
{
|
|
QFile file(fileName);
|
|
|
|
//检查
|
|
if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
qWarning("Cannot open file for writing: %s", qPrintable(file.errorString()));
|
|
return;
|
|
}
|
|
|
|
QTextStream out(&file);
|
|
out << generateOCCGeoCodes();
|
|
file.close();
|
|
}
|