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.
nmWATI/Src/nmNum/nmCalculation/nmCalculationGeoSurface.cpp

51 lines
1.6 KiB
C++

#include "nmCalculationGeoSurface.h"
#include <QStringList>
nmCalculationGeoSurface::nmCalculationGeoSurface(const nmCalculationGeoDataOutline& outline, const double& gridSize): m_outline(outline), m_dGridSize(gridSize)
{
}
//面的文件部分的创造
QString nmCalculationGeoSurface::generateSurfaceGeoCodes()
{
QStringList geoLines;
QVector<QPointF> points = m_outline.points();
geoLines.append(QString("SetFactory(\"OpenCASCADE\");"));//加入OCC
for(int i = 0; i < points.size(); ++i) {
const QPointF& point = points[i];
//点point部分多边形相关点的坐标以及网格划分的基础网格大小
geoLines.append(QString("Point(%1)={%2,%3,0,%4};")
.arg(i + 1)
.arg(point.x())
.arg(point.y())
.arg(m_dGridSize));
}
for(int i = 0; i < points.size(); i++) {
//线:规定多边形的两点连接成线
geoLines.append(QString("Line(%1)={%2,%3};")
.arg(i + 1)
.arg(i + 1)
.arg((i + 1) % points.size() + 1));
}
QStringList pointIndexList;
//面:多线封闭连接成面
pointIndexList.append("Line Loop(1) = {");
for (int i = 1; i <= points.size(); ++i) {
pointIndexList.append(QString::number(i));
if (i < points.size()) {
pointIndexList.append(",");
}
}
pointIndexList.append("};");
geoLines.append(pointIndexList.join(""));
geoLines.append("Plane Surface(1) = {1};");//面:单独的面
return geoLines.join("\n");
}