#include "nmCalculationGeo.h" #include #include #include #include "nmCalculationGeoSurface.h" #include "nmCalculationGeoWell.h" nmCalculationGeo::nmCalculationGeo(const nmCalculationGeoDataOutline &outline, const QVector& 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(); }