From d518eed8dbf6d7a84f885452d676abb8bfc7a5d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=85=E5=85=83=E5=A4=A9=E9=81=93?= Date: Tue, 25 Jul 2023 13:12:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9fluent=E9=9B=86=E6=88=90?= =?UTF-8?q?=E6=A1=88=E4=BE=8B=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MSHdataExchange.cpp | 1063 ++++++++--------- src/SolverControl/SolverControlerBase.cpp | 6 +- 2 files changed, 477 insertions(+), 592 deletions(-) diff --git a/src/PluginMeshDataExchange/MSHdataExchange.cpp b/src/PluginMeshDataExchange/MSHdataExchange.cpp index 53da77a..454d884 100644 --- a/src/PluginMeshDataExchange/MSHdataExchange.cpp +++ b/src/PluginMeshDataExchange/MSHdataExchange.cpp @@ -18,41 +18,40 @@ #include #include -namespace MeshData -{ - MSHdataExchange::MSHdataExchange(const QString &fileName, MeshOperation operation, GUI::MainWindow *mw, int modelId) : // _fileName(fileName), - _operation(operation), - _meshData(MeshData::getInstance()), - _totalNumber(0), - MeshThreadBase(fileName, operation, mw), - _modelId(modelId) +namespace MeshData { + MSHdataExchange::MSHdataExchange(const QString& fileName, MeshOperation operation, + GUI::MainWindow* mw, int modelId) + : // _fileName(fileName), + _operation(operation) + , _meshData(MeshData::getInstance()) + , _totalNumber(0) + , MeshThreadBase(fileName, operation, mw) + , _modelId(modelId) { _fileName = fileName; - _file = new QFile(_fileName); + _file = new QFile(_fileName); } MSHdataExchange::~MSHdataExchange() { - if (_stream != nullptr) + if(_stream != nullptr) delete _stream; - if (_file != nullptr) + if(_file != nullptr) delete _file; - _file = nullptr; + _file = nullptr; _stream = nullptr; } QString MSHdataExchange::readLine() { - while (_threadRuning) - { - if (_stream->atEnd()) - { + while(_threadRuning) { + if(_stream->atEnd()) { //_threadRuning = false; return QString(); ; } QString line = _stream->readLine().simplified(); - if (line.isEmpty()) + if(line.isEmpty()) continue; return line; } @@ -62,28 +61,24 @@ namespace MeshData bool MSHdataExchange::readHeader() { QFileInfo tempinfo(_fileName); - if (!tempinfo.exists()) + if(!tempinfo.exists()) return false; QString name = tempinfo.fileName(); QString path = tempinfo.filePath(); - QFile tempfile(_fileName); - if (!tempfile.open(QIODevice::ReadOnly)) + QFile tempfile(_fileName); + if(!tempfile.open(QIODevice::ReadOnly)) return false; // QTextStream* tempStream=new QTextStream(&tempfile); QTextStream tempStream(&tempfile); - while (!tempStream.atEnd()) - { - if (!_threadRuning) + while(!tempStream.atEnd()) { + if(!_threadRuning) return false; QString line = tempStream.readLine().simplified(); - if (line.contains("GAMBIT")) - { + if(line.contains("GAMBIT")) { mMeshType = typeGambit; tempfile.close(); return true; - } - else if (line.contains("Fluent")) - { + } else if(line.contains("Fluent")) { mMeshType = typeFluent; tempfile.close(); return true; @@ -102,209 +97,195 @@ namespace MeshData { ModuleBase::ThreadTask::run(); bool result = false; - switch (_operation) - { - case MESH_READ: - emit showInformation(tr("Import MSH Mesh File From \"%1\"").arg(_fileName)); - result = read(); - setReadResult(result); - break; - case MESH_WRITE: - emit showInformation(tr("Export MSH Mesh File From \"%1\"").arg(_fileName)); - // result = write(); - // setWriteResult(result); - break; + switch(_operation) { + case MESH_READ: + emit showInformation(tr("Import MSH Mesh File From \"%1\"").arg(_fileName)); + result = read(); + setReadResult(result); + break; + case MESH_WRITE: + emit showInformation(tr("Export MSH Mesh File From \"%1\"").arg(_fileName)); + // result = write(); + // setWriteResult(result); + break; } defaultMeshFinished(); } bool MSHdataExchange::read() { - if (!readHeader()) - { - // QMessageBox::warning(nullptr, tr("Prompt"), tr("The file format could not parse the amount!"), QMessageBox::Ok); + if(!readHeader()) { + // QMessageBox::warning(nullptr, tr("Prompt"), tr("The file format could not parse the + // amount!"), QMessageBox::Ok); return false; } _file = new QFile(); QFileInfo info(_fileName); - if (!info.exists()) + if(!info.exists()) return false; _baseFileName = info.fileName(); - _filePath = info.filePath(); + _filePath = info.filePath(); _file->setFileName(_fileName); - if (!_file->open(QIODevice::ReadOnly)) + if(!_file->open(QIODevice::ReadOnly)) return false; - _stream = new QTextStream(_file); - CFDMeshReader* reader = new CFDMeshReader; + _stream = new QTextStream(_file); + CFDMeshReader* reader = new CFDMeshReader; CFDMshFileParser* parser = new CFDMshFileParser; reader->setMeshFileParser(parser); bool ok = reader->readFile(_fileName.toStdString()); - if (!ok) + if(!ok) return ok; vtkSmartPointer dataset = reader->getGrid(); - MeshKernal *k = new MeshKernal; + MeshKernal* k = new MeshKernal; k->setName(_baseFileName); k->setPath(_filePath); - k->setMeshData((vtkDataSet *)dataset); + k->setMeshData((vtkDataSet*)dataset); _meshData->appendMeshKernal(k); - int kid = k->getID(); + int kid = k->getID(); std::unordered_map zones = parser->getZones(); - QMap zoneNames{}; - for (auto zone : zones) - { + QMap zoneNames{}; + for(auto zone : zones) { zoneNames.insert(zone.first, zone.second); } std::unordered_map> zoneIndexes = parser->getCellZones(); - for (auto it : zoneIndexes) - { - int setid = it.first; - MeshSet* set = new MeshSet; + for(auto it : zoneIndexes) { + int setid = it.first; + MeshSet* set = new MeshSet; set->setType(SetType::Element); - if (zoneNames.contains(setid)) + if(zoneNames.contains(setid)) set->setName(QString::fromStdString(zoneNames[setid])); else set->setName("ElementSet" + QString::number(it.first)); - MeshSet *s = _idsetList.value(setid); - if (s != nullptr) - { + MeshSet* s = _idsetList.value(setid); + if(s != nullptr) { delete s; _idsetList.remove(setid); } _idsetList[setid] = set; - int firstIndex = it.second.first; - int lastIndex = it.second.second; - for (int i = firstIndex; i <= lastIndex; ++i) + int firstIndex = it.second.first; + int lastIndex = it.second.second; + for(int i = firstIndex; i <= lastIndex; ++i) set->appendTempMem(i - 1); } std::unordered_map> faceZones = parser->getPointZones(); - for (auto it : faceZones) - { - int setid = it.first; - MeshSet* set = new MeshSet; + for(auto it : faceZones) { + int setid = it.first; + MeshSet* set = new MeshSet; set->setType(SetType::Node); - if (zoneNames.contains(setid)) + if(zoneNames.contains(setid)) set->setName(QString::fromStdString(zoneNames[setid])); else set->setName("PointSet" + QString::number(it.first)); MeshSet* s = _idsetList.value(setid); - if (s != nullptr) - { + if(s != nullptr) { delete s; _idsetList.remove(setid); } _idsetList[setid] = set; - int firstIndex = it.second.first; - int lastIndex = it.second.second; - for (int i = firstIndex; i <= lastIndex; ++i) + int firstIndex = it.second.first; + int lastIndex = it.second.second; + for(int i = firstIndex; i <= lastIndex; ++i) set->appendTempMem(i - 1); } - std::unordered_map> face2CellIndex = parser->getFaceIDtoCellIndex(); - for (auto faceZone : parser->getFaceZones()) - { + std::unordered_map> face2CellIndex = + parser->getFaceIDtoCellIndex(); + for(auto faceZone : parser->getFaceZones()) { int zoneId = faceZone.first; - if (zoneNames.contains(zoneId)) - { + if(zoneNames.contains(zoneId)) { BoundMeshSet* set = new BoundMeshSet; set->setName(QString::fromStdString(zoneNames[zoneId])); QMap> cellFaces{}; - int firstIndex = faceZone.second.first; - int lastIndex = faceZone.second.second; - for (int i = firstIndex; i <= lastIndex; ++i) - { + int firstIndex = faceZone.second.first; + int lastIndex = faceZone.second.second; + for(int i = firstIndex; i <= lastIndex; ++i) { int cellIndex = face2CellIndex[i].first; - int index = face2CellIndex[i].second; + int index = face2CellIndex[i].second; cellFaces[cellIndex - 1].push_back(index - 1); + set->appendTempMem(i - 1); } MeshSet* s = _idsetList.value(zoneId); - if (s != nullptr) - { + if(s != nullptr) { delete s; _idsetList.remove(zoneId); } _idsetList[zoneId] = set; } } - QList setList = _idsetList.values(); - for (int i = 0; i < _idsetList.size(); ++i) - { - MeshSet *set = setList.at(i); + QList setList = _idsetList.values(); + for(int i = 0; i < _idsetList.size(); ++i) { + MeshSet* set = setList.at(i); set->setKeneralID(kid); _meshData->appendMeshSet(set); } delete parser; delete reader; return ok; - //if (mMeshType == typeGambit) + // if (mMeshType == typeGambit) //{ // if (!readGambitFile(dataset)) // return false; // else // return true; - //} - //else if (mMeshType == typeFluent) + // } + // else if (mMeshType == typeFluent) //{ // if (!readFluentFile(dataset)) // return false; - //} - //return true; + // } + // return true; } - void MSHdataExchange::readPoints10(vtkUnstructuredGrid *dataset, QString info) + void MSHdataExchange::readPoints10(vtkUnstructuredGrid* dataset, QString info) { vtkSmartPointer points = dataset->GetPoints(); - if (points == nullptr) - { + if(points == nullptr) { points = vtkSmartPointer::New(); dataset->SetPoints(points); } - int type = 0; - int index = 0; - int setid = 0; - int startIndex = 0; - int endIndex = 0; - QStringList infos = info.split(" "); - if (infos.length() > 5) - { - if (!_threadRuning) + int type = 0; + int index = 0; + int setid = 0; + int startIndex = 0; + int endIndex = 0; + QStringList infos = info.split(" "); + if(infos.length() > 5) { + if(!_threadRuning) return; - index = strToInt(infos.at(0), true); - setid = strToInt(infos.at(1), true); - startIndex = strToInt(infos.at(2), true); - endIndex = strToInt(infos.at(3), true); - _ND = strToInt(infos.at(5)); - MeshSet *set = new MeshSet; + index = strToInt(infos.at(0), true); + setid = strToInt(infos.at(1), true); + startIndex = strToInt(infos.at(2), true); + endIndex = strToInt(infos.at(3), true); + _ND = strToInt(infos.at(5)); + MeshSet* set = new MeshSet; set->setType(SetType::Node); set->setName("Point"); - MeshSet *s = _idsetList.value(setid); - if (s != nullptr) - { + MeshSet* s = _idsetList.value(setid); + if(s != nullptr) { delete s; _idsetList.remove(setid); } // _idsetList[setid] = set; // vtkIdTypeArray* idlist = vtkIdTypeArray::New(); - double coordinate[3] = {0.0, 0.0, 0.0}; + double coordinate[3] = { 0.0, 0.0, 0.0 }; // fluent文件会多出一行( - if (mMeshType == typeFluent) - { + if(mMeshType == typeFluent) { QString line = this->readLine(); } // - for (int i = startIndex; i <= endIndex; i++) - { - if (!_threadRuning) + for(int i = startIndex; i <= endIndex; i++) { + if(!_threadRuning) return; // idlist->InsertNextValue(i); set->appendTempMem(i); - QString scoor = this->readLine(); + QString scoor = this->readLine(); QStringList scoors = scoor.split(" "); // qDebug() << i << endl; - coordinate[0] = scoors.at(0).toDouble(); - coordinate[1] = scoors.at(1).toDouble(); - if (_ND == 3) + coordinate[0] = scoors.at(0).toDouble(); + coordinate[1] = scoors.at(1).toDouble(); + if(_ND == 3) coordinate[2] = scoors.at(2).toDouble(); points->InsertNextPoint(coordinate); } @@ -312,143 +293,126 @@ namespace MeshData } } - void MSHdataExchange::readPoints130(vtkUnstructuredGrid *dataset, QString info) + void MSHdataExchange::readPoints130(vtkUnstructuredGrid* dataset, QString info) { vtkSmartPointer points = dataset->GetPoints(); - if (points == nullptr) - { + if(points == nullptr) { points = vtkSmartPointer::New(); dataset->SetPoints(points); } - QStringList infos = info.split(" "); - const int setid = infos.at(1).toInt(); - const int startIndex = infos.at(2).toInt(); - const int endIndex = infos.at(3).toInt(); - _ND = infos.at(5).toInt(); - MeshSet *set = new MeshSet; + QStringList infos = info.split(" "); + const int setid = infos.at(1).toInt(); + const int startIndex = infos.at(2).toInt(); + const int endIndex = infos.at(3).toInt(); + _ND = infos.at(5).toInt(); + MeshSet* set = new MeshSet; set->setType(SetType::Node); set->setName("001"); - MeshSet *s = _idsetList.value(setid); - if (s != nullptr) - { + MeshSet* s = _idsetList.value(setid); + if(s != nullptr) { delete s; _idsetList.remove(setid); } - _idsetList[setid] = set; + _idsetList[setid] = set; // vtkIdTypeArray* idlist = vtkIdTypeArray::New(); - double coordinate[3] = {0.0, 0.0, 0.0}; - for (int i = startIndex; i <= endIndex; ++i) - { - if (!_threadRuning) + double coordinate[3] = { 0.0, 0.0, 0.0 }; + for(int i = startIndex; i <= endIndex; ++i) { + if(!_threadRuning) return; // idlist->InsertNextValue(i); set->appendTempMem(i); - QString scoor = this->readLine(); + QString scoor = this->readLine(); QStringList scoors = scoor.split(" "); - coordinate[0] = scoors.at(0).toDouble(); - coordinate[1] = scoors.at(1).toDouble(); - if (_ND == 3) + coordinate[0] = scoors.at(0).toDouble(); + coordinate[1] = scoors.at(1).toDouble(); + if(_ND == 3) coordinate[2] = scoors.at(2).toDouble(); points->InsertNextPoint(coordinate); } // set->setIDList(idlist); } - void MSHdataExchange::readCells120(vtkUnstructuredGrid *dataset, QString info) + void MSHdataExchange::readCells120(vtkUnstructuredGrid* dataset, QString info) { - QStringList infos = info.split(" "); - const int setid = infos.at(1).toInt(); - const int startIndex = infos.at(4).toInt(); - const int endIndex = infos.at(5).toInt(); - MeshSet *set = new MeshSet; + QStringList infos = info.split(" "); + const int setid = infos.at(1).toInt(); + const int startIndex = infos.at(4).toInt(); + const int endIndex = infos.at(5).toInt(); + MeshSet* set = new MeshSet; set->setType(SetType::Element); set->setName("002"); - MeshSet *s = _idsetList.value(setid); - if (s != nullptr) - { + MeshSet* s = _idsetList.value(setid); + if(s != nullptr) { delete s; _idsetList.remove(setid); } - _idsetList[setid] = set; + _idsetList[setid] = set; // vtkIdTypeArray* idlist = vtkIdTypeArray::New(); - double coordinate[3] = {0.0, 0.0, 0.0}; - for (int i = startIndex; i <= endIndex; ++i) - { - if (!_threadRuning) + double coordinate[3] = { 0.0, 0.0, 0.0 }; + for(int i = startIndex; i <= endIndex; ++i) { + if(!_threadRuning) return; // idlist->InsertNextValue(i); set->appendTempMem(i); - QString sele = this->readLine(); - QStringList selelist = sele.split(" "); - QList member; + QString sele = this->readLine(); + QStringList selelist = sele.split(" "); + QList member; vtkSmartPointer idlist = vtkSmartPointer::New(); - for (int i = 0; i < selelist.size(); ++i) - { - if (!_threadRuning) + for(int i = 0; i < selelist.size(); ++i) { + if(!_threadRuning) return; int d = selelist.at(i).toInt(); - if (!member.contains(d)) - { + if(!member.contains(d)) { member.append(d); idlist->InsertNextId(d); } } - if (member.size() == 3) - { + if(member.size() == 3) { dataset->InsertNextCell(VTK_TRIANGLE, idlist); - } - else if (member.size() == 4) - { + } else if(member.size() == 4) { dataset->InsertNextCell(VTK_QUAD, idlist); } } // set->setIDList(idlist); } - void MSHdataExchange::readFluentCells12(vtkUnstructuredGrid *dataset, QString info) + void MSHdataExchange::readFluentCells12(vtkUnstructuredGrid* dataset, QString info) { - QStringList infos = info.split(" "); - const int setid = strToInt(infos.at(1), true); - const int startIndex = strToInt(infos.at(2), true); - const int endIndex = strToInt(infos.at(3), true); - MeshSet *set = new MeshSet; + QStringList infos = info.split(" "); + const int setid = strToInt(infos.at(1), true); + const int startIndex = strToInt(infos.at(2), true); + const int endIndex = strToInt(infos.at(3), true); + MeshSet* set = new MeshSet; set->setType(SetType::Element); set->setName("002"); - MeshSet *s = _idsetList.value(setid); - if (s != nullptr) - { + MeshSet* s = _idsetList.value(setid); + if(s != nullptr) { delete s; _idsetList.remove(setid); } - _idsetList[setid] = set; + _idsetList[setid] = set; // vtkIdTypeArray* idlist = vtkIdTypeArray::New(); - double coordinate[3] = {0.0, 0.0, 0.0}; - for (int i = startIndex; i <= endIndex; ++i) - { + double coordinate[3] = { 0.0, 0.0, 0.0 }; + for(int i = startIndex; i <= endIndex; ++i) { // idlist->InsertNextValue(i); set->appendTempMem(i); - QString sele = this->readLine(); - QStringList selelist = sele.split(" "); - QList member; + QString sele = this->readLine(); + QStringList selelist = sele.split(" "); + QList member; vtkSmartPointer idlist = vtkSmartPointer::New(); - for (int i = 0; i < selelist.size(); ++i) - { + for(int i = 0; i < selelist.size(); ++i) { int d = selelist.at(i).toInt(); - if (!member.contains(d)) - { + if(!member.contains(d)) { member.append(d); idlist->InsertNextId(d); } } - if (member.size() == 3) - { + if(member.size() == 3) { dataset->InsertNextCell(VTK_TRIANGLE, idlist); - } - else if (member.size() == 4) - { + } else if(member.size() == 4) { dataset->InsertNextCell(VTK_QUAD, idlist); } } @@ -459,114 +423,96 @@ namespace MeshData { // qDebug() << zone; QStringList zoneinfo = zone.split(" "); - const int setid = zoneinfo.at(1).toInt(); - MeshSet *set = _idsetList.value(setid); - if (set != nullptr) + const int setid = zoneinfo.at(1).toInt(); + MeshSet* set = _idsetList.value(setid); + if(set != nullptr) set->setName(zoneinfo.at(3)); } - bool MSHdataExchange::readFace13(vtkUnstructuredGrid *dataset, QString info) + bool MSHdataExchange::readFace13(vtkUnstructuredGrid* dataset, QString info) { - int index; + int index; - int bctype; - int facenumber; - int facetype; - int elemtype; - int startIndex; - int endIndex; - int setid; - char *ch; + int bctype; + int facenumber; + int facetype; + int elemtype; + int startIndex; + int endIndex; + int setid; + char* ch; // qDebug() << info; QStringList infos = info.split(" "); - setid = strToInt(infos.at(1), true); + setid = strToInt(infos.at(1), true); - startIndex = strToInt(infos.at(2), true); - endIndex = strToInt(infos.at(3), true); - bctype = strToInt(infos.at(4), true); - facetype = strToInt(infos.at(5)); + startIndex = strToInt(infos.at(2), true); + endIndex = strToInt(infos.at(3), true); + bctype = strToInt(infos.at(4), true); + facetype = strToInt(infos.at(5)); - MeshSet *set = new MeshSet; + MeshSet* set = new MeshSet; set->setType(SetType::Element); set->setName("002"); - MeshSet *s = _idsetList.value(setid); - if (s != nullptr) - { + MeshSet* s = _idsetList.value(setid); + if(s != nullptr) { delete s; _idsetList.remove(setid); } - _idsetList[setid] = set; - //获取面的数量 - facenumber = endIndex - startIndex + 1; + _idsetList[setid] = set; + // 获取面的数量 + facenumber = endIndex - startIndex + 1; // vtkIdTypeArray* idlist = vtkIdTypeArray::New(); - double coordinate[3] = {0.0, 0.0, 0.0}; - for (int i = 0; i < facenumber; ++i) - { - if (!_threadRuning) + double coordinate[3] = { 0.0, 0.0, 0.0 }; + for(int i = 0; i < facenumber; ++i) { + if(!_threadRuning) return false; QList member; // idlist->InsertNextValue(_staticid); set->appendTempMem(_staticid); _staticid++; - QString sele = this->readLine(); - QStringList selelist = sele.split(" "); - int firstFaceType = 0; - if (mMeshType == typeGambit) - { - //取每一个面对应的类型,不是头中的类型 - if (selelist.count() > 1) - { + QString sele = this->readLine(); + QStringList selelist = sele.split(" "); + int firstFaceType = 0; + if(mMeshType == typeGambit) { + // 取每一个面对应的类型,不是头中的类型 + if(selelist.count() > 1) { firstFaceType = strToInt(selelist.at(0)); } - } - else if (mMeshType == typeFluent) // fluent类型文件,面中没有类型,这里取的是头中的类型 + } else if(mMeshType == typeFluent) // fluent类型文件,面中没有类型,这里取的是头中的类型 { firstFaceType = facetype; } vtkSmartPointer pointIdList = vtkSmartPointer::New(); - //第一个字符串是单元类型,不需要保存,最后两个字符串不需要保存,一个是cellid,另外一个为0 - // 4 1 77 32b0 29 0 1 - int j = 0; - if (mMeshType == typeFluent) - { + // 第一个字符串是单元类型,不需要保存,最后两个字符串不需要保存,一个是cellid,另外一个为0 + // 4 1 77 32b0 29 0 1 + int j = 0; + if(mMeshType == typeFluent) { j = 0; - } - else if (mMeshType == typeGambit) - { + } else if(mMeshType == typeGambit) { j = 1; } - for (j; j <= selelist.count() - 3; j++) - { - if (!_threadRuning) + for(j; j <= selelist.count() - 3; j++) { + if(!_threadRuning) return false; int pointIndex = strToInt(selelist.at(j), true); - if (pointIndex > 0) - { + if(pointIndex > 0) { pointIndex = pointIndex - 1; - if (!member.contains(pointIndex)) - { + if(!member.contains(pointIndex)) { member.append(pointIndex); pointIdList->InsertNextId(pointIndex); } } } - if (firstFaceType == 3) - { + if(firstFaceType == 3) { dataset->InsertNextCell(VTK_TRIANGLE, pointIdList); - } - else if (firstFaceType == 4) - { + } else if(firstFaceType == 4) { dataset->InsertNextCell(VTK_QUAD, pointIdList); - } - else if (firstFaceType == 2) - { + } else if(firstFaceType == 2) { dataset->InsertNextCell(VTK_LINE, pointIdList); - } - else if (firstFaceType == 5) - { + } else if(firstFaceType == 5) { dataset->InsertNextCell(VTK_POLYGON, pointIdList); } } @@ -584,10 +530,8 @@ namespace MeshData bool MSHdataExchange::isHex(QString line) { bool isHex = false; - for (int i = 0; i < line.length(); i++) - { - if (line.at(i) > '9') - { + for(int i = 0; i < line.length(); i++) { + if(line.at(i) > '9') { isHex = true; return isHex; } @@ -597,60 +541,49 @@ namespace MeshData int MSHdataExchange::strToInt(QString line, bool isHex) { - if (isHex) - { + if(isHex) { return line.toInt(0, 16); - } - else - { + } else { return line.toInt(); } } - bool MSHdataExchange::readGambitFile(vtkUnstructuredGrid *dataset) + bool MSHdataExchange::readGambitFile(vtkUnstructuredGrid* dataset) { QString line; - do - { - if (!_threadRuning) + do { + if(!_threadRuning) return false; line = this->readLine(); - char *ch; + char* ch; QByteArray ba = line.toLatin1(); - ch = ba.data(); - if (line.endsWith(")(")) - { + ch = ba.data(); + if(line.endsWith(")(")) { line = line.remove("(").remove(")"); - if (line.isEmpty()) + if(line.isEmpty()) continue; QStringList slist = line.split(" "); - int index; - //取出数字标识 + int index; + // 取出数字标识 sscanf(ch, "(%d", &index); - if (slist.at(0) == "0") - { + if(slist.at(0) == "0") { _describe = slist.at(1); _describe.remove("\""); } - if (index == 130) - { + if(index == 130) { readPoints130(dataset, line); - } - else if (slist.at(0) == "120") - { + } else if(slist.at(0) == "120") { readCells120(dataset, line); } // 10为GAMBIT to Fluent File - else if (index == 10) - { - //读取16进制 + else if(index == 10) { + // 读取16进制 readPoints10(dataset, line); } - //读取Face - if (index == 13) - { + // 读取Face + if(index == 13) { //(13(0 1 1a7c9 0)) // 13如果为13标志,在13后插入空格,和其他格式对应上 QString replaceLine; @@ -658,34 +591,30 @@ namespace MeshData replaceLine.insert(2, " "); readFace13(dataset, replaceLine); } - } - else if (line.endsWith("))") && line.startsWith("(")) - { + } else if(line.endsWith("))") && line.startsWith("(")) { line = line.remove("(").remove(")"); - if (line.isEmpty()) + if(line.isEmpty()) continue; QStringList slist = line.split(" "); - if (slist.at(0) == "45") + if(slist.at(0) == "45") readZone45(line); } - } while (!_stream->atEnd()); + } while(!_stream->atEnd()); _file->close(); - QList setList = _idsetList.values(); - if (dataset != nullptr) - { - MeshKernal *k = new MeshKernal; + QList setList = _idsetList.values(); + if(dataset != nullptr) { + MeshKernal* k = new MeshKernal; k->setName(_baseFileName); k->setPath(_filePath); - k->setMeshData((vtkDataSet *)dataset); + k->setMeshData((vtkDataSet*)dataset); _meshData->appendMeshKernal(k); int kid = k->getID(); - for (int i = 0; i < setList.size(); ++i) - { - if (!_threadRuning) + for(int i = 0; i < setList.size(); ++i) { + if(!_threadRuning) return false; - MeshSet *set = setList.at(i); + MeshSet* set = setList.at(i); // set->setDataSet(dataset); set->setKeneralID(kid); _meshData->appendMeshSet(set); @@ -693,84 +622,74 @@ namespace MeshData return true; } - for (int i = 0; i < setList.size(); ++i) - { - MeshSet *set = setList.at(i); + for(int i = 0; i < setList.size(); ++i) { + MeshSet* set = setList.at(i); delete set; } _idsetList.clear(); return false; } - bool MSHdataExchange::readFluentFile(vtkUnstructuredGrid *dataset) + bool MSHdataExchange::readFluentFile(vtkUnstructuredGrid* dataset) { QString line; - do - { - if (!_threadRuning) + do { + if(!_threadRuning) return false; line = this->readLine(); - char *ch; + char* ch; QByteArray ba = line.toLatin1(); - ch = ba.data(); - line = line.remove("(").remove(")"); - if (line.isEmpty()) + ch = ba.data(); + line = line.remove("(").remove(")"); + if(line.isEmpty()) continue; - QStringList slist = line.split(" "); + QStringList slist = line.split(" "); - int startIndex = 0; - int index; - //取出数字标识 + int startIndex = 0; + int index; + // 取出数字标识 sscanf(ch, "(%d", &index); - if (slist.at(0) == "0") - { + if(slist.at(0) == "0") { _describe = slist.at(1); _describe.remove("\""); } // 10为GAMBIT to Fluent File - else if (index == 10) - { - + else if(index == 10) { startIndex = strToInt(slist.at(1), true); - //如果startindex<1应该是区的标识,不读取 - if (startIndex < 1) + // 如果startindex<1应该是区的标识,不读取 + if(startIndex < 1) continue; - //读取16进制 + // 读取16进制 readPoints10(dataset, line); } - //读取Face - else if (index == 13) - { + // 读取Face + else if(index == 13) { // face面总的信息不读取 startIndex = strToInt(slist.at(1), true); - if (startIndex < 1) - { + if(startIndex < 1) { continue; } readFace13(dataset, line); } - //读取区域名称,包含边界 - if (index == 39) - { + // 读取区域名称,包含边界 + if(index == 39) { QStringList slist = line.split(" "); readZone45(line); } - } while (!_stream->atEnd()); + } while(!_stream->atEnd()); _file->close(); - QList setList = _idsetList.values(); - if (dataset != nullptr) - { - MeshKernal *k = new MeshKernal; + QList setList = _idsetList.values(); + if(dataset != nullptr) { + MeshKernal* k = new MeshKernal; k->setName(_baseFileName); k->setPath(_filePath); - k->setMeshData((vtkDataSet *)dataset); + k->setMeshData((vtkDataSet*)dataset); _meshData->appendMeshKernal(k); int kid = k->getID(); - for (int i = 0; i < setList.size(); ++i) - { - MeshSet *set = setList.at(i); + for(int i = 0; i < setList.size(); ++i) { + MeshSet* set = setList.at(i); // set->setDataSet(dataset); set->setKeneralID(kid); _meshData->appendMeshSet(set); @@ -778,16 +697,14 @@ namespace MeshData return true; } - for (int i = 0; i < setList.size(); ++i) - { - MeshSet *set = setList.at(i); + for(int i = 0; i < setList.size(); ++i) { + MeshSet* set = setList.at(i); delete set; } _idsetList.clear(); return false; } - bool CFDMshFileParser::setFile(const std::string& file) { m_File = file; @@ -799,17 +716,17 @@ namespace MeshData return m_Points; } - std::unordered_map> CFDMshFileParser::getFaces() + std::unordered_map> CFDMshFileParser::getFaces() { return m_Faces; } - std::unordered_map> CFDMshFileParser::getCells() + std::unordered_map> CFDMshFileParser::getCells() { return m_Cells; } - std::unordered_map CFDMshFileParser::getCellsType() + std::unordered_map CFDMshFileParser::getCellsType() { return m_CellsType; } @@ -843,8 +760,7 @@ namespace MeshData { std::ifstream in{}; in.open(m_File, std::ios_base::in); - if (!in.is_open()) - { + if(!in.is_open()) { return false; } std::stringstream buffer; @@ -852,13 +768,13 @@ namespace MeshData m_ByteArray = std::string(buffer.str()); in.close(); bool p = this->readPoints(); - if (!p) + if(!p) return p; bool f = this->readFaces(); - if (!f) + if(!f) return f; bool c = this->readCellsType(); - if (!c) + if(!c) return c; this->readZones(); return true; @@ -866,54 +782,48 @@ namespace MeshData bool CFDMshFileParser::readPoints() { - //读取点 - const std::string nodeLabel{"\n(10"}; - int nlSize = nodeLabel.size(); - int first = m_ByteArray.find(nodeLabel); - if (first == -1) + // 读取点 + const std::string nodeLabel{ "\n(10" }; + int nlSize = nodeLabel.size(); + int first = m_ByteArray.find(nodeLabel); + if(first == -1) return false; - while (first != -1) - { - int end = m_ByteArray.find("\n", first+nlSize); - if (end == -1) + while(first != -1) { + int end = m_ByteArray.find("\n", first + nlSize); + if(end == -1) return false; - std::string element{m_ByteArray.substr(first+1, end-first)}; + std::string element{ m_ByteArray.substr(first + 1, end - first) }; stringTrimmed(element); std::vector list{}; this->stringSplit(element, ' ', list); - if (list.size() < 5) + if(list.size() < 5) return false; - bool ok; + bool ok; std::string zoneIdStr = list.at(1).substr(1); - int zoneID{-1}; + int zoneID{ -1 }; sscanf(zoneIdStr.c_str(), "%X", &zoneID); std::string firstIndex = list.at(2); - std::string lastIndex = list.at(3); - int fIndex{ 0 }, lIndex{ 0 }; + std::string lastIndex = list.at(3); + int fIndex{ 0 }, lIndex{ 0 }; sscanf(firstIndex.c_str(), "%X", &fIndex); sscanf(lastIndex.c_str(), "%X", &lIndex); - if (zoneID == 0) - { + if(zoneID == 0) { std::string pnStr = list.at(3); - m_PointNumber = strtol(pnStr.c_str(), 0, 16); - } - else - { + m_PointNumber = strtol(pnStr.c_str(), 0, 16); + } else { m_PointZones[zoneID] = std::make_pair(fIndex, lIndex); - int first = m_ByteArray.find(")", end + 1); - if (first == -1) + int first = m_ByteArray.find(")", end + 1); + if(first == -1) break; - std::string nodes = m_ByteArray.substr(end+1, first-end); + std::string nodes = m_ByteArray.substr(end + 1, first - end); std::vector arrays{}; stringSplit(nodes, '\n', arrays); - for (auto& array : arrays) - { - std::string coords {array}; + for(auto& array : arrays) { + std::string coords{ array }; stringTrimmed(coords); std::vector cs{}; stringSplit(coords, ' ', cs); - if (cs.size() == 3) - { + if(cs.size() == 3) { m_Points.push_back(atof(cs.at(0).c_str())); m_Points.push_back(atof(cs.at(1).c_str())); m_Points.push_back(atof(cs.at(2).c_str())); @@ -929,34 +839,31 @@ namespace MeshData bool CFDMshFileParser::readZones() { std::string zoneLable{ "\n(39" }; - int first = m_ByteArray.find(zoneLable); - if (first == -1) - { + int first = m_ByteArray.find(zoneLable); + if(first == -1) { zoneLable = "\n(45"; - first = m_ByteArray.find(zoneLable); + first = m_ByteArray.find(zoneLable); } - if (first == -1) + if(first == -1) return false; int clSize = zoneLable.size(); - while (first != -1) - { - int end = m_ByteArray.find("\n", first + clSize); + while(first != -1) { + int end = m_ByteArray.find("\n", first + clSize); std::string line = m_ByteArray.substr(first + clSize, end - first - clSize); - int i = line.find("("); - if (i == -1) + int i = line.find("("); + if(i == -1) return false; int j = line.find(")"); - if (j == -1) + if(j == -1) return false; std::string element = line.substr(i + 1, j - i - 1); stringTrimmed(element); std::vector segs{}; stringSplit(element, ' ', segs); - if (segs.size() >= 3) - { - std::string name = segs.at(2); - int zoneID = strtol(segs.at(0).c_str(), 0, 10); - m_Zones[zoneID] = name; + if(segs.size() >= 3) { + std::string name = segs.at(2); + int zoneID = strtol(segs.at(0).c_str(), 0, 10); + m_Zones[zoneID] = name; } first = m_ByteArray.find(zoneLable, end); } @@ -965,52 +872,47 @@ namespace MeshData bool CFDMshFileParser::readFaces() { - //读取面及单元 - const std::string faceLable{"\n(13"}; - int flSize = faceLable.size(); - int first = m_ByteArray.find(faceLable); - if (first == -1) + // 读取面及单元 + const std::string faceLable{ "\n(13" }; + int flSize = faceLable.size(); + int first = m_ByteArray.find(faceLable); + if(first == -1) return false; - while (first != -1) - { - int end = m_ByteArray.find("\n", first+flSize); - if (end == -1) + while(first != -1) { + int end = m_ByteArray.find("\n", first + flSize); + if(end == -1) return false; - //以(13开头的整行 - std::string element{m_ByteArray.substr(first+1, end-first)}; - int a = element.find("(", 3); - int b = element.find_last_of(")"); - element = element.substr(a+1, b-a-1); + // 以(13开头的整行 + std::string element{ m_ByteArray.substr(first + 1, end - first) }; + int a = element.find("(", 3); + int b = element.find_last_of(")"); + element = element.substr(a + 1, b - a - 1); stringTrimmed(element); std::vector list{}; stringSplit(element, ' ', list); - if (list.size() < 4) + if(list.size() < 4) return false; std::string zoneStr = list.at(0); - int zoneId{ -1 }; + int zoneId{ -1 }; sscanf(zoneStr.c_str(), "%x", &zoneId); - int startFaceIndex = strtol(list.at(1).c_str(), 0 ,16); - int endFaceIndex = strtol(list.at(2).c_str(), 0, 16); - if (zoneId == 0) - { - m_FaceNumber = strtol(list.at(2).c_str(), 0 , 16); - } - else - { + int startFaceIndex = strtol(list.at(1).c_str(), 0, 16); + int endFaceIndex = strtol(list.at(2).c_str(), 0, 16); + if(zoneId == 0) { + m_FaceNumber = strtol(list.at(2).c_str(), 0, 16); + } else { m_FaceZones[zoneId] = std::make_pair(startFaceIndex, endFaceIndex); int bcType; sscanf(list.at(3).c_str(), "%d", &bcType); int faceType; sscanf(list.at(4).c_str(), "%d", &faceType); - int first = m_ByteArray.find(")",end+1); - if (first == -1) + int first = m_ByteArray.find(")", end + 1); + if(first == -1) break; - std::string faces = m_ByteArray.substr(end+1, first-end); + std::string faces = m_ByteArray.substr(end + 1, first - end); std::vector arrays{}; stringSplit(faces, '\n', arrays); - for (auto& array : arrays) - { - std::string coords {array}; + for(auto& array : arrays) { + std::string coords{ array }; stringTrimmed(coords); std::vector cs{}; stringSplit(coords, ' ', cs); @@ -1026,50 +928,46 @@ namespace MeshData bool CFDMshFileParser::readCellsType() { - //读取单元类型 + // 读取单元类型 const std::string cellLable{ "\n(12" }; - int clSize = cellLable.size(); - int first = m_ByteArray.find(cellLable); - if (first == -1) + int clSize = cellLable.size(); + int first = m_ByteArray.find(cellLable); + if(first == -1) return false; - while (first != -1) - { + while(first != -1) { int end = m_ByteArray.find("\n", first + clSize); - if (end == -1) + if(end == -1) return false; - std::string element{ m_ByteArray.substr(first + cellLable.size(), end - first-cellLable.size()) }; + std::string element{ m_ByteArray.substr(first + cellLable.size(), + end - first - cellLable.size()) }; stringTrimmed(element); std::vector list{}; stringSplit(element, ' ', list); - if (list.size() < 4) + if(list.size() < 4) return false; bool ok; - int zoneId = strtol(list.at(0).substr(1).c_str(), 0, 16); - int startIndex = strtol(list.at(1).c_str(),0, 16); - int endIndex = strtol(list.at(2).c_str(), 0, 16); - int type = strtol(list.at(3).c_str(), 0 , 16); - if (zoneId == 0) + int zoneId = strtol(list.at(0).substr(1).c_str(), 0, 16); + int startIndex = strtol(list.at(1).c_str(), 0, 16); + int endIndex = strtol(list.at(2).c_str(), 0, 16); + int type = strtol(list.at(3).c_str(), 0, 16); + if(zoneId == 0) ; - else - { + else { m_CellZones[zoneId] = std::make_pair(startIndex, endIndex); - std::string str = list.at(4); - int elementType{ -1 }; + std::string str = list.at(4); + int elementType{ -1 }; std::string etStr = str.substr(0, str.find_first_of(")")); sscanf(etStr.c_str(), "%x", &elementType); - if (elementType == 0) - { + if(elementType == 0) { int bodyEnd = m_ByteArray.find(")", end + 1); - if (bodyEnd != -1) - { + if(bodyEnd != -1) { std::string body{ m_ByteArray.substr(end + 1, bodyEnd - end - 1) }; stringTrimmed(body); - if (body.at(0) == '(') + if(body.at(0) == '(') body = body.substr(1); std::vector types{}; stringSplit(body, ' ', types); - for (const std::string& ty : types) - { + for(const std::string& ty : types) { int type{}; sscanf(ty.c_str(), "%d", &type); m_CellsType[startIndex] = type; @@ -1077,10 +975,8 @@ namespace MeshData } end = bodyEnd; } - } - else - { - for (int i = startIndex; i <= endIndex; ++i) + } else { + for(int i = startIndex; i <= endIndex; ++i) m_CellsType[i] = elementType; } } @@ -1089,111 +985,103 @@ namespace MeshData return true; } - void CFDMshFileParser::parseFaceAndCells(int faceIndex, const std::vector& faceLineSegs, int faceType) + void CFDMshFileParser::parseFaceAndCells(int faceIndex, + const std::vector& faceLineSegs, + int faceType) { bool ok; - switch (faceType) - { - case 0: case 5: - { - if (faceLineSegs.size() >= 5) - { - std::string pnStr = faceLineSegs.front(); - int pointNum{ 0 }; - sscanf(pnStr.c_str(), "%d", &pointNum); - std::vector pointIDs{}; - int i = 1; - for (; i <= pointNum; ++i) - { - std::string idStr = faceLineSegs.at(i); - int id = strtol(idStr.c_str(), 0, 16); - pointIDs.push_back(id); + switch(faceType) { + case 0: + case 5: { + if(faceLineSegs.size() >= 5) { + std::string pnStr = faceLineSegs.front(); + int pointNum{ 0 }; + sscanf(pnStr.c_str(), "%d", &pointNum); + std::vector pointIDs{}; + int i = 1; + for(; i <= pointNum; ++i) { + std::string idStr = faceLineSegs.at(i); + int id = strtol(idStr.c_str(), 0, 16); + pointIDs.push_back(id); + } + m_Faces.insert(make_pair(faceIndex, pointIDs)); + std::string ownerStr = faceLineSegs.at(i); + int owner = strtol(ownerStr.c_str(), 0, 16); + ++i; + std::string nbStr = faceLineSegs.at(i); + int neigbur = strtol(nbStr.c_str(), 0, 16); + if(owner != 0) { + m_Cells[owner].push_back(faceIndex); + m_FaceIdToCellFaceIndex[faceIndex] = + std::make_pair(owner, m_Cells[owner].size()); + } + if(neigbur != 0) { + m_Cells[neigbur].push_back(faceIndex); + m_FaceIdToCellFaceIndex[faceIndex] = + std::make_pair(neigbur, m_Cells[neigbur].size()); + } } - m_Faces.insert(make_pair(faceIndex, pointIDs)); - std::string ownerStr = faceLineSegs.at(i); - int owner = strtol(ownerStr.c_str(), 0, 16); - ++i; - std::string nbStr = faceLineSegs.at(i); - int neigbur = strtol(nbStr.c_str(), 0, 16); - if (owner != 0) - { + } break; + case 3: { + if(faceLineSegs.size() != 5) + return; + std::vector pointIds{}; + for(int i = 0; i < 3; ++i) { + int id = strtol(faceLineSegs.at(i).c_str(), 0, 16); + pointIds.push_back(id); + } + m_Faces.insert(make_pair(faceIndex, pointIds)); + std::string ownerStr{ faceLineSegs.at(3) }; + int owner = strtol(ownerStr.c_str(), 0, 16); + std::string nbStr{ faceLineSegs.at(4) }; + int neighber = strtol(nbStr.c_str(), 0, 16); + if(owner != 0) { m_Cells[owner].push_back(faceIndex); - m_FaceIdToCellFaceIndex[faceIndex] = std::make_pair(owner, m_Cells[owner].size()); + m_FaceIdToCellFaceIndex[faceIndex] = + std::make_pair(owner, m_Cells[owner].size()); } - if (neigbur != 0) - { - m_Cells[neigbur].push_back(faceIndex); - m_FaceIdToCellFaceIndex[faceIndex] = std::make_pair(neigbur, m_Cells[neigbur].size()); + if(neighber != 0) { + m_Cells[neighber].push_back(faceIndex); + m_FaceIdToCellFaceIndex[faceIndex] = + std::make_pair(neighber, m_Cells[neighber].size()); } - } - } - break; - case 3: - { - if (faceLineSegs.size() != 5) - return; - std::vector pointIds{ }; - for (int i = 0; i< 3; ++i) - { - int id = strtol(faceLineSegs.at(i).c_str(), 0, 16); - pointIds.push_back(id); - } - m_Faces.insert(make_pair(faceIndex, pointIds)); - std::string ownerStr{ faceLineSegs.at(3) }; - int owner = strtol(ownerStr.c_str(), 0, 16); - std::string nbStr{ faceLineSegs.at(4) }; - int neighber = strtol(nbStr.c_str(), 0 , 16); - if (owner != 0) - { - m_Cells[owner].push_back(faceIndex); - m_FaceIdToCellFaceIndex[faceIndex] = std::make_pair(owner, m_Cells[owner].size()); - } - if (neighber != 0) - { - m_Cells[neighber].push_back(faceIndex); - m_FaceIdToCellFaceIndex[faceIndex] = std::make_pair(neighber, m_Cells[neighber].size()); - } - } - break; - case 4: - { - if (faceLineSegs.size() != 6) - return; - std::vector pointIds{ }; - for (int i = 0; i < 4; ++i) - { - int id = strtol(faceLineSegs.at(i).c_str(), 0, 16); - pointIds.push_back(id); - } - m_Faces.insert(make_pair(faceIndex, pointIds)); - std::string ownerStr{ faceLineSegs.at(4) }; - int owner = strtol(ownerStr.c_str(), 0, 16); - std::string nbStr{ faceLineSegs.at(5) }; - int neighber = strtol(nbStr.c_str(), 0, 16); - if (owner != 0) - { - m_Cells[owner].push_back(faceIndex); - m_FaceIdToCellFaceIndex[faceIndex] = std::make_pair(owner, m_Cells[owner].size()); - } - if (neighber != 0) - { - m_Cells[neighber].push_back(faceIndex); - m_FaceIdToCellFaceIndex[faceIndex] = std::make_pair(neighber, m_Cells[neighber].size()); - } - } - break; - default: - break; + } break; + case 4: { + if(faceLineSegs.size() != 6) + return; + std::vector pointIds{}; + for(int i = 0; i < 4; ++i) { + int id = strtol(faceLineSegs.at(i).c_str(), 0, 16); + pointIds.push_back(id); + } + m_Faces.insert(make_pair(faceIndex, pointIds)); + std::string ownerStr{ faceLineSegs.at(4) }; + int owner = strtol(ownerStr.c_str(), 0, 16); + std::string nbStr{ faceLineSegs.at(5) }; + int neighber = strtol(nbStr.c_str(), 0, 16); + if(owner != 0) { + m_Cells[owner].push_back(faceIndex); + m_FaceIdToCellFaceIndex[faceIndex] = + std::make_pair(owner, m_Cells[owner].size()); + } + if(neighber != 0) { + m_Cells[neighber].push_back(faceIndex); + m_FaceIdToCellFaceIndex[faceIndex] = + std::make_pair(neighber, m_Cells[neighber].size()); + } + } break; + default: + break; } } - void CFDMshFileParser::stringSplit(const std::string str, const char split, std::vector &vec) + void CFDMshFileParser::stringSplit(const std::string str, const char split, + std::vector& vec) { std::istringstream iss(str); - std::string token; - while (getline(iss, token, split)) - { - if (token.size() != 0) + std::string token; + while(getline(iss, token, split)) { + if(token.size() != 0) vec.push_back(token); } } @@ -1203,7 +1091,7 @@ namespace MeshData int first = str.find_first_not_of(" "); str.erase(0, first); int last = str.find_last_not_of(" "); - if (last+1 < str.size()) + if(last + 1 < str.size()) str.erase(last + 1); } @@ -1214,42 +1102,38 @@ namespace MeshData bool CFDMeshReader::readFile(const std::string& file) { - if (m_Parser == nullptr) + if(m_Parser == nullptr) return false; bool ok = m_Parser->setFile(file); - if (!ok) + if(!ok) return ok; m_ugrid = vtkSmartPointer::New(); - vtkSmartPointer points = vtkSmartPointer::New(); - const std::vector ps = m_Parser->getPoints(); - const std::unordered_map> cells = m_Parser->getCells(); - const std::unordered_map> faces = m_Parser->getFaces(); - const std::unordered_map cellTyps = m_Parser->getCellsType(); - std::set usedFaces{}; - int num = ps.size() / 3; - for (int i = 0; i < num; ++i) - { + vtkSmartPointer points = vtkSmartPointer::New(); + const std::vector ps = m_Parser->getPoints(); + const std::unordered_map> cells = m_Parser->getCells(); + const std::unordered_map> faces = m_Parser->getFaces(); + const std::unordered_map cellTyps = m_Parser->getCellsType(); + std::set usedFaces{}; + int num = ps.size() / 3; + for(int i = 0; i < num; ++i) { double coord[3]{ ps[i * 3], ps[i * 3 + 1], ps[i * 3 + 2] }; points->InsertNextPoint(coord); } m_ugrid->SetPoints(points); std::unordered_map>::const_iterator it = cells.cbegin(); - while (it != cells.cend()) - { - std::vector pointIds{}; + while(it != cells.cend()) { + std::vector pointIds{}; vtkSmartPointer facesIDS = vtkSmartPointer::New(); - std::vector faceids = it->second; - int index = it->first; - for (int id : faceids) - { + std::vector faceids = it->second; + int index = it->first; + for(int id : faceids) { auto it = faces.find(id); - if (it == faces.cend()) + if(it == faces.cend()) continue; - const std::vector pids =it->second; + const std::vector pids = it->second; usedFaces.insert(it->first); facesIDS->InsertNextId(pids.size()); - for (int pid : pids) - { + for(int pid : pids) { pointIds.push_back(pid - 1); facesIDS->InsertNextId(pid - 1); } @@ -1258,7 +1142,8 @@ namespace MeshData std::sort(pointIds.begin(), pointIds.end()); auto ii = std::unique(pointIds.begin(), pointIds.end()); pointIds.erase(ii, pointIds.end()); - m_ugrid->InsertNextCell(VTK_POLYHEDRON, pointIds.size(), pointIds.data(), faceids.size(), facesIDS->GetPointer(0)); + m_ugrid->InsertNextCell(VTK_POLYHEDRON, pointIds.size(), pointIds.data(), + faceids.size(), facesIDS->GetPointer(0)); ++it; } return true; @@ -1269,4 +1154,4 @@ namespace MeshData return m_ugrid; } -} \ No newline at end of file +} // namespace MeshData \ No newline at end of file diff --git a/src/SolverControl/SolverControlerBase.cpp b/src/SolverControl/SolverControlerBase.cpp index a956d0c..bb9884b 100644 --- a/src/SolverControl/SolverControlerBase.cpp +++ b/src/SolverControl/SolverControlerBase.cpp @@ -105,7 +105,8 @@ namespace SolverControl { _processBar = new ModuleBase::ProcessBar(_mainWindow, _description, false); QString args = _solver->getParameter(); - QRegExp regExp("%.*%"); + args.replace("%modelpath%", startPath, Qt::CaseInsensitive); + /*QRegExp regExp("%.*%"); regExp.setMinimal(true); // int pos = regExp.indexIn(args); QStringList variables = regExp.capturedTexts(); @@ -114,8 +115,7 @@ namespace SolverControl { QString va = variable.remove("%"); if(va.toLower() == "modelpath") args.replace(variables.at(i), startPath); - // qDebug() << args; - } + }*/ // QString startProcess = solverPath + " " + args; // if (solverPath.contains(" "))