LAMPCAE/src/PluginMeshDataExchange/meshDataExchangePlugin.cpp

392 lines
15 KiB
C++
Raw Normal View History

2023-05-08 06:32:41 +00:00
#include "meshDataExchangePlugin.h"
2023-05-09 11:00:22 +00:00
#include "BDFdataExchange.h"
2023-05-08 06:32:41 +00:00
#include "CGNSdataExchange.h"
#include "CNTMdataExchange.h"
#include "INPdataExchange.h"
#include "IO/IOConfig.h"
2023-05-09 11:00:22 +00:00
#include "KEYdataExchange.h"
2023-05-08 06:32:41 +00:00
#include "ModelData/modelDataBase.h"
#include "ModuleBase/ThreadControl.h"
2023-05-09 11:00:22 +00:00
#include "ModuleBase/ThreadTaskManager.h"
#include "MSHdataExchange.h"
#include "NEUdataExchange.h"
2023-05-08 06:32:41 +00:00
#include "PDBdataExchange.h"
2023-05-09 11:00:22 +00:00
#include "SU2dataExchange.h"
#include "VTKdataExchange.h"
#include "FoamDataExchange.h"
#include "PointClouddataExchange.h"
2023-05-09 11:00:22 +00:00
2023-05-08 06:32:41 +00:00
#include <QFileInfo>
2023-05-09 11:00:22 +00:00
GUI::MainWindow* MeshData::MeshDataExchangePlugin::_mainwindow = nullptr;
namespace MeshData {
MeshDataExchangePlugin::MeshDataExchangePlugin(GUI::MainWindow* m)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
_describe = "MeshDataExchangePlugin Installed Successfully";
2023-05-08 06:32:41 +00:00
_mainwindow = m;
}
bool MeshDataExchangePlugin::install()
{
IO::IOConfigure::RegisterMeshImporter("CGNS(*.cgns)", CGNSimportMesh);
IO::IOConfigure::RegisterMeshImporter("Fluent(*.msh)", MSHimportMesh);
IO::IOConfigure::RegisterMeshImporter("OpenFOAM(*.foam)", FOAMimportMesh);
2023-05-08 06:32:41 +00:00
IO::IOConfigure::RegisterMeshImporter("Gambit(*.neu)", NEUimportMesh);
IO::IOConfigure::RegisterMeshImporter("STL(*.stl)", VTK_DAT_STL_importMesh);
IO::IOConfigure::RegisterMeshImporter("Tecplot(*.dat)", VTK_DAT_STL_importMesh);
IO::IOConfigure::RegisterMeshImporter("VTK(*.vtk)", VTK_DAT_STL_importMesh);
IO::IOConfigure::RegisterMeshImporter("Abaqus(*.inp)", INPimportMesh);
IO::IOConfigure::RegisterMeshImporter("CNTM(*.cntm)", CNTMimportMesh);
IO::IOConfigure::RegisterMeshImporter("SU2(*.su2)", SU2importMesh);
IO::IOConfigure::RegisterMeshImporter("LS-DYNA(*.k)", KEYimportMesh);
IO::IOConfigure::RegisterMeshImporter("PDB(*.pdb)", PDBimportMesh);
IO::IOConfigure::RegisterMeshImporter("Patran(*.bdf)", BDFimportMesh);
IO::IOConfigure::RegisterPclImporter("VegetationPointCloud(*.xyz)", XYZimportPCL); // 点云
IO::IOConfigure::RegisterPclImporter("Point Cloud Data(*.pcd)",PCDimportPCL);
IO::IOConfigure::RegisterPclImporter("Polygon File Format(*.ply)",PLYimportPCL);
2023-05-08 06:32:41 +00:00
IO::IOConfigure::RegisterMeshExporter("CGNS(*.cgns)", CGNSexportMesh);
IO::IOConfigure::RegisterMeshExporter("Fluent(*.msh)", MSHexportMesh);
IO::IOConfigure::RegisterMeshExporter("OpenFOAM(*.foam)", FOAMexportMesh);
2023-05-08 06:32:41 +00:00
IO::IOConfigure::RegisterMeshExporter("Gambit(*.neu)", NEUexportMesh);
IO::IOConfigure::RegisterMeshExporter("STL(*.stl)", VTK_DAT_STL_exportMesh);
IO::IOConfigure::RegisterMeshExporter("Tecplot(*.dat)", VTK_DAT_STL_exportMesh);
IO::IOConfigure::RegisterMeshExporter("VTK(*.vtk)", VTK_DAT_STL_exportMesh);
IO::IOConfigure::RegisterMeshExporter("Abaqus(*.inp)", INPexportMesh);
IO::IOConfigure::RegisterMeshExporter("CNTM(*.cntm)", CNTMexportMesh);
IO::IOConfigure::RegisterMeshExporter("SU2(*.su2)", SU2exportMesh);
IO::IOConfigure::RegisterMeshExporter("LS-DYNA(*.key)", KEYexportMesh);
IO::IOConfigure::RegisterMeshExporter("PDB(*.pdb)", PDBexportMesh);
IO::IOConfigure::RegisterPclExporter("Point Cloud Data(*.pcd)",PCDexportPCL);
IO::IOConfigure::RegisterPclExporter("vtk polygon Data(*.ply)",PLYexportPCL);
2023-05-08 06:32:41 +00:00
return true;
}
bool MeshDataExchangePlugin::uninstall()
{
IO::IOConfigure::RemoveMeshImporter("CGNS(*.cgns)");
IO::IOConfigure::RemoveMeshImporter("Fluent(*.msh)");
IO::IOConfigure::RemoveMeshImporter("Gambit(*.neu)");
IO::IOConfigure::RemoveMeshImporter("STL(*.stl)");
IO::IOConfigure::RemoveMeshImporter("Tecplot(*.dat)");
IO::IOConfigure::RemoveMeshImporter("VTK(*.vtk)");
IO::IOConfigure::RemoveMeshImporter("Abaqus(*.inp)");
IO::IOConfigure::RemoveMeshImporter("CNTM(*.cntm)");
IO::IOConfigure::RemoveMeshImporter("SU2(*.su2)");
IO::IOConfigure::RemoveMeshImporter("LS-DYNA(*.key)");
IO::IOConfigure::RemoveMeshImporter("PDB(*.pdb)");
IO::IOConfigure::RemoveMeshImporter("Patran(*.bdf)");
IO::IOConfigure::RemovePclImporter("VegetationPointCloud(*.xyz)"); // 点云
IO::IOConfigure::RemovePclImporter("Point Cloud Data(*.pcd)");
IO::IOConfigure::RemovePclImporter("Polygon File Format(*.ply)");
2023-05-08 06:32:41 +00:00
IO::IOConfigure::RemoveMeshExporter("CGNS(*.cgns)");
IO::IOConfigure::RemoveMeshExporter("Fluent(*.msh)");
IO::IOConfigure::RemoveMeshExporter("Gambit(*.neu)");
IO::IOConfigure::RemoveMeshExporter("STL(*.stl)");
IO::IOConfigure::RemoveMeshExporter("Tecplot(*.dat)");
IO::IOConfigure::RemoveMeshExporter("VTK(*.vtk)");
IO::IOConfigure::RemoveMeshExporter("Abaqus(*.inp)");
IO::IOConfigure::RemoveMeshExporter("CNTM(*.cntm)");
IO::IOConfigure::RemoveMeshExporter("SU2(*.su2)");
IO::IOConfigure::RemoveMeshExporter("LS-DYNA(*.key)");
IO::IOConfigure::RemovePclExporter("PDB(*.pdb)");
IO::IOConfigure::RemovePclExporter("vtk polygon Data(*.ply)");
2023-05-08 06:32:41 +00:00
return true;
}
2023-05-09 11:00:22 +00:00
void MeshDataExchangePlugin::reTranslate(QString) {}
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
GUI::MainWindow* MeshDataExchangePlugin::getMWpt()
2023-05-08 06:32:41 +00:00
{
return _mainwindow;
}
2023-05-09 11:00:22 +00:00
} // namespace MeshData
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
void Register(GUI::MainWindow* m, QList<Plugins::PluginBase*>* ps)
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
Plugins::PluginBase* p = new MeshData::MeshDataExchangePlugin(m);
2023-05-08 06:32:41 +00:00
ps->append(p);
}
bool CGNSimportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto CGNSreader = new MeshData::CGNSdataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(CGNSreader);
emit tc->threadStart(); // emit CGNSreader->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool CGNSexportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto CGNSwriter = new MeshData::CGNSdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(CGNSwriter);
emit tc->threadStart(); // emit CGNSwriter->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool MSHimportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto MSHreader = new MeshData::MSHdataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(MSHreader);
emit tc->threadStart(); // emit MSHreader->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool MSHexportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto MSHwriter = new MeshData::MSHdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(MSHwriter);
emit tc->threadStart(); // emit MSHwriter->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool NEUimportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto NEUreader = new MeshData::NEUdataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(NEUreader);
emit tc->threadStart(); // emit NEUreader->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool NEUexportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto NEUwriter = new MeshData::NEUdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(NEUwriter);
emit tc->threadStart(); // emit NEUwriter->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool VTK_DAT_STL_importMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto VTK_DAT_STL_reader = new MeshData::VTKdataExchange(
AbFileName, MeshData::MESH_READ, MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(VTK_DAT_STL_reader);
emit tc->threadStart(); // emit VTK_DAT_STL_reader->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool VTK_DAT_STL_exportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto VTK_DAT_STL_writer = new MeshData::VTKdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(VTK_DAT_STL_writer);
emit tc->threadStart(); // emit VTK_DAT_STL_writer->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool INPimportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto INPreader = new MeshData::INPdataExchange(
AbFileName, MeshData::MESH_READ, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(INPreader);
emit tc->threadStart(); // emit INPreader->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool INPexportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto INPwriter = new MeshData::INPdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(INPwriter);
emit tc->threadStart(); // emit INPwriter->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool CNTMimportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto CNTMreader = new MeshData::CNTMdataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(CNTMreader);
emit tc->threadStart(); // emit CNTMreader->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool CNTMexportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto CNTMwriter = new MeshData::CNTMdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(CNTMwriter);
emit tc->threadStart(); // emit CNTMwriter->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool SU2importMesh(QString AbFileName, int modelId)
{
QFileInfo info(AbFileName);
2023-05-09 11:00:22 +00:00
QString fileName = info.fileName();
2023-05-08 06:32:41 +00:00
2023-05-09 11:00:22 +00:00
if(fileName.startsWith("xxx")) // su2的另外一种格式
2023-05-08 06:32:41 +00:00
{
AnotherSU2importMesh(AbFileName);
2023-05-09 11:00:22 +00:00
} else // su2的正常格式
2023-05-08 06:32:41 +00:00
{
2023-05-09 11:00:22 +00:00
auto SU2reader = new MeshData::SU2dataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(SU2reader);
emit tc->threadStart(); // emit SU2reader->start();
2023-05-08 06:32:41 +00:00
return false;
}
return false;
}
bool SU2exportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto SU2writer = new MeshData::CNTMdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(SU2writer);
emit tc->threadStart(); // emit SU2writer->start();
2023-05-08 06:32:41 +00:00
return false;
}
bool AnotherSU2importMesh(QString AbFileName)
{
2023-05-09 11:00:22 +00:00
auto SU2reader = new MeshData::SU2dataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(SU2reader);
emit tc->threadStart();
2023-05-08 06:32:41 +00:00
// emit SU2reader->start();
return false;
}
bool AnotherSU2exportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto SU2writer = new MeshData::CNTMdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(SU2writer);
emit tc->threadStart();
2023-05-08 06:32:41 +00:00
// emit SU2writer->start();
return false;
}
bool KEYimportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto KEYreader = new MeshData::KEYdataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(KEYreader);
emit tc->threadStart();
2023-05-08 06:32:41 +00:00
// emit KEYreader->start();
return false;
}
bool KEYexportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto KEYwirter = new MeshData::KEYdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(KEYwirter);
emit tc->threadStart();
2023-05-08 06:32:41 +00:00
// emit KEYwirter->start();
return false;
}
bool MESHDATAEXCHANGEPLUGINAPI PDBimportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto PDBReader = new MeshData::PDBdataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(PDBReader);
emit tc->threadStart();
2023-05-08 06:32:41 +00:00
/*emit PDBReader->start();*/
return false;
}
bool MESHDATAEXCHANGEPLUGINAPI BDFimportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto PDBReader = new MeshData::BDFDataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(PDBReader);
emit tc->threadStart();
2023-05-08 06:32:41 +00:00
/*emit PDBReader->start();*/
return false;
}
bool MESHDATAEXCHANGEPLUGINAPI PDBexportMesh(QString AbFileName, int modelId)
{
2023-05-09 11:00:22 +00:00
auto PDBWriter = new MeshData::PDBdataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(PDBWriter);
emit tc->threadStart();
2023-05-08 06:32:41 +00:00
// emit PDBWriter->start();
return false;
}
bool MESHDATAEXCHANGEPLUGINAPI FOAMimportMesh(QString AbFileName, int modelId)
{
auto foamReader = new MeshData::FoamDataExchange(AbFileName, MeshData::MESH_READ,
MeshData::MeshDataExchangePlugin::getMWpt());
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(foamReader);
emit tc->threadStart(); // emit MSHreader->start();
return false;
}
bool MESHDATAEXCHANGEPLUGINAPI FOAMexportMesh(QString AbFileName, int id)
{
auto FoamWriter = new MeshData::FoamDataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), id);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(FoamWriter);
emit tc->threadStart(); // emit MSHwriter->start();
return false;
}
bool MESHDATAEXCHANGEPLUGINAPI XYZimportPCL(QString AbFileName, int id)
{
auto xyzReader = new MeshData::PointClouddataExchange(
AbFileName, MeshData::MESH_READ, MeshData::MeshDataExchangePlugin::getMWpt(), id);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(xyzReader);
emit tc->threadStart(); // emit MSHwriter->start();
return false;
}
bool MESHDATAEXCHANGEPLUGINAPI PCDimportPCL(QString AbFileName, int id)
{
auto pcdReader = new MeshData::PointClouddataExchange(
AbFileName, MeshData::MESH_READ, MeshData::MeshDataExchangePlugin::getMWpt(), id);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(pcdReader);
emit tc->threadStart(); // emit MSHwriter->start();
return false;
}
bool MESHDATAEXCHANGEPLUGINAPI PLYimportPCL(QString AbFileName, int id)
{
auto plyReader = new MeshData::PointClouddataExchange(
AbFileName, MeshData::MESH_READ, MeshData::MeshDataExchangePlugin::getMWpt(), id);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(plyReader);
emit tc->threadStart(); // emit MSHwriter->start();
return false;
}
//bool MESHDATAEXCHANGEPLUGINAPI XYZexportPCL(QString AbFileName, int modelId)
//{
//
// return false;
//}
bool MESHDATAEXCHANGEPLUGINAPI PCDexportPCL(QString AbFileName, int modelId)
{
auto pcdWriter = new MeshData::PointClouddataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(pcdWriter);
emit tc->threadStart(); // emit MSHwriter->start();
return false;
}
bool MESHDATAEXCHANGEPLUGINAPI PLYexportPCL(QString AbFileName, int modelId)
{
auto pcdWriter = new MeshData::PointClouddataExchange(
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(pcdWriter);
emit tc->threadStart(); // emit MSHwriter->start();
return false;
}