Ejemplo n.º 1
0
bool MeshGeneratorGMSH::mesh()
{
    m_isError = !prepare();

    // create gmsh files
    if (writeToGmsh())
    {
        // exec GMSH
        m_process = QSharedPointer<QProcess>(new QProcess());
        m_process.data()->setStandardOutputFile(tempProblemFileName() + ".gmsh.out");
        m_process.data()->setStandardErrorFile(tempProblemFileName() + ".gmsh.err");
        connect(m_process.data(), SIGNAL(error(QProcess::ProcessError)), this, SLOT(meshGmshError(QProcess::ProcessError)));
        connect(m_process.data(), SIGNAL(finished(int)), this, SLOT(meshGmshCreated(int)));

        QString gmshBinary = "gmsh";
        if (QFile::exists(QApplication::applicationDirPath() + QDir::separator() + "gmsh.exe"))
            gmshBinary = "\"" + QApplication::applicationDirPath() + QDir::separator() + "gmsh.exe\"";
        if (QFile::exists(QApplication::applicationDirPath() + QDir::separator() + "gmsh"))
            gmshBinary = QApplication::applicationDirPath() + QDir::separator() + "gmsh";

        QString triangleGMSH = "%1 -2 \"%2.geo\"";
        m_process.data()->start(triangleGMSH.
                                arg(gmshBinary).
                                arg(tempProblemFileName()), QIODevice::ReadOnly);

        // execute an event loop to process the request (nearly-synchronous)
        QEventLoop eventLoop;
        connect(m_process.data(), SIGNAL(finished(int)), &eventLoop, SLOT(quit()));
        connect(m_process.data(), SIGNAL(error(QProcess::ProcessError)), &eventLoop, SLOT(quit()));
        eventLoop.exec();
    }
    else
    {
Ejemplo n.º 2
0
bool MeshGeneratorGMSH::mesh()
{
    m_isError = !prepare();

    // create gmsh files
    if (writeToGmsh())
    {
        Agros2D::log()->printDebug(tr("Mesh generator"), tr("GMSH geometry file was created"));

        // exec triangle
        m_process = new QProcess();
        m_process->setStandardOutputFile(tempProblemFileName() + ".gmsh.out");
        m_process->setStandardErrorFile(tempProblemFileName() + ".gmsh.err");
        connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(meshGmshError(QProcess::ProcessError)));
        connect(m_process, SIGNAL(finished(int)), this, SLOT(meshGmshCreated(int)));

        QString gmshBinary = "gmsh";
        if (QFile::exists(QApplication::applicationDirPath() + QDir::separator() + "gmsh.exe"))
            gmshBinary = "\"" + QApplication::applicationDirPath() + QDir::separator() + "gmsh.exe\"";
        if (QFile::exists(QApplication::applicationDirPath() + QDir::separator() + "gmsh"))
            gmshBinary = QApplication::applicationDirPath() + QDir::separator() + "gmsh";

        QString triangleGMSH = "%1 -2 \"%2.geo\"";
        m_process->start(triangleGMSH.
                         arg(gmshBinary).
                         arg(tempProblemFileName()));

        // execute an event loop to process the request (nearly-synchronous)
        QEventLoop eventLoop;
        connect(m_process, SIGNAL(finished(int)), &eventLoop, SLOT(quit()));
        eventLoop.exec();
    }
    else
    {