Пример #1
0
bool
check_polyhedron_collision_with_dag(SceneNode *node,
	const pp::Matrix& modelMatrix, const pp::Matrix& invModelMatrix,
    const ppogl::Polyhedron& ph)
{
	PP_CHECK_POINTER( node );

    bool hit = false;
    pp::Matrix newModelMatrix=modelMatrix*node->trans;
    pp::Matrix newInvModelMatrix=node->invtrans*invModelMatrix;

    if(node->isSphere == true){
        ppogl::Polyhedron newph(ph);
		trans_polyhedron( newInvModelMatrix, newph );
		hit = intersect_polyhedron( newph );
	}

    if (hit == true) return hit;

	SceneNode* child = node->child;
    while (child != NULL) {

        hit = check_polyhedron_collision_with_dag( 
	    child, newModelMatrix, newInvModelMatrix, ph );

        if ( hit == true ) {
            return hit;
        }

        child = child->next;
    } 

    return false;
}
Пример #2
0
void Area::saveEdit(int del){

    //temporary file for the text edition

    QFile newph("temp.ph");

    newph.open(QIODevice::WriteOnly | QIODevice::Truncate);
    QTextStream flux(&newph);
    flux.setCodec("UTF-8");    

    QString *file = new QString("temp.ph");
    QString fileXML("tempXML.xml");
    std::string phFile = file->toStdString();

    try{

        //Save new text into new file
        if(this->textArea->toPlainText().isEmpty()){

            throw textAreaEmpty_exception();
        }

        flux << this->textArea->toPlainText() << endl;

        newph.close();        

        if(del == 0){

            emit makeTempXML();
        }

        // render graph
        PHPtr myPHPtr = PHIO::parseFile(phFile);
        this->myArea->setPHPtr(myPHPtr);
        myPHPtr->render();
        PHScenePtr scene = myPHPtr->getGraphicsScene();
        this->myArea->setScene(&*scene);

        // delete the current sortsTree and groupsTree
        this->treeArea->sortsTree->clear();
        //this->treeArea->groupsTree->clear();
        // set the pointer of the treeArea
        this->treeArea->myPHPtr = myPHPtr;
        //set the pointer of the treeArea
        this->treeArea->myArea = this->myArea;
        // build the tree in the treeArea
        this->treeArea->build();

        this->indicatorEdit->setVisible(false);       
        this->saveTextEdit->setDefault(false);
        this->textArea->incrementeNberTextChange();        
        this->typeOfCancel = 0;
        this->saveTextEdit->setEnabled(false);        
        this->textArea->setNberEdit(0);
        this->cancelTextEdit->setShortcut(QKeySequence());

        this->setOldText();

        newph.remove();

        this->mainWindow->importXMLMetadata(fileXML);
    }
    catch(textAreaEmpty_exception & e){

        QMessageBox::critical(this, "Error !", "You cannot update from an empty text area !");
    }
    catch(ph_parse_error & argh){

        //Catch a parsing error !
        //Put the exception into a QMessageBox critical

        QString phc = "phc";
        QStringList args;
        args << "-l" << "dump" << "-i" << QString::fromUtf8(phFile.c_str()) << "--no-debug";
        QProcess *phcProcess = new QProcess();
        phcProcess->start(phc, args);
        if (!phcProcess->waitForStarted())
            throw pint_program_not_found() << file_info("phc");

        phcProcess->readChannel();

        // read result
        QByteArray stderr;
        QByteArray stdout;
        while (!phcProcess->waitForFinished()) {
            stderr += phcProcess->readAllStandardError();
            stdout += phcProcess->readAllStandardOutput();
        }
        stderr += phcProcess->readAllStandardError();
        stdout += phcProcess->readAllStandardOutput();
        delete phcProcess;

        //Use split function to only keep the line number

        QStringList list = QString(stderr).split('"');
        QStringList list2 = list[1].split(":");
        QStringList list3 = list2[0].split(" ");

        //One or more of your expressions are wrong !
        newph.remove();
        QMessageBox::critical(this, "Syntax error !", "One or more of your expressions are wrong !\nNear "+list3[0]+" "+list3[1]+" of dump");
        //return NULL;
    }
    catch(sort_not_found& sort){

        //Catch a error if the user delete a sort before associated actions !

        QMessageBox::critical(this, "Error !", "Delete the associated actions before the process !");
    }
}