int main( int argc, char **argv ) {
    // connection
    SodaClient sc( QHostAddress::Any, 8890 );
    if ( not sc.connected() ) return 1;

    qDebug() << "argv : " << argv;
    //id du model à traiter
    quint64 model_id = atoi(argv[1]);
    //qDebug() << "model_id : " << model_id;
    // type d'item observé
    sc.reg_type( "UnvReaderItem2D" );
    sc.reg_type( "UnvReaderItem3D" );
    sc.reg_type( "Scult2DItem" );
    sc.reg_type( "Scult3DItem" );
    sc.reg_type( "Scills3DItem" );
    sc.reg_type( "CorrelationItem" );
    sc.reg_type( "MesherItem" );
    sc.reg_type( "GmshItem" );
    sc.reg_type( "File" );
    sc.reg_type( "Img" );
    sc.reg_type( "ServerAssistedVisualization" );
    sc.reg_type( "AcquisitionItem" );
    
    //chargement du model
    MP mp = sc.load_ptr(model_id);
    
    // lancement de la bonne commade
    std::stringstream str_model_id;
    str_model_id << model_id;
    std::string temp_str = str_model_id.str();
    std::string commande;
    
   
    if(mp.type() == "CorrelationItem" or mp.type() == "MesherItem" or mp.type() == "File" or mp.type() == "Img" or mp.type() == "ServerAssistedVisualization" ){
        commande = "../../CorreliPlugin/Analytics/src/compilations/src_main_cpp.exe " + temp_str ;
        std::system(commande.c_str());        
    }
    else if(mp.type() == "GmshItem" ){
        commande = "../../GmshPlugin/Analytics/src/compilations/src_main_cpp.exe " + temp_str ;
        std::system(commande.c_str());
    }
    
    sleep(1);
    mp[ "_computation_mode" ] = false;
    mp[ "_computation_state" ] = false;
    mp[ "_processing_state" ] = false;
    mp.flush();
    SodaClient::Event event = sc.event();
}
int main( int argc, char **argv ) {
    // connection
    SodaClient sc( QHostAddress::Any, 8890 );
    if ( not sc.connected() ) return 1;

    //
    sc.reg_type( "ScillsAssemblyComputeItem" );

    // attente
    while ( SodaClient::Event event = sc.event() ) {
        MP mp = event.mp();
        if ( mp.type() == "ScillsAssemblyComputeItem" ) {
            ScillsResultUpdater scru;
            scru.sc = &sc;
            scru.exec( mp );
        } 
    }
}
int main( int argc, char **argv ) {
    // connection
    SodaClient sc( QHostAddress::Any, 8890 );
    if ( not sc.connected() ) return 1;

//     //id du model à traiter
//     quint64 model_id = atoi(argv[1]);
//     sc.reg_type( "Scills3DItem" );
//     //chargement du model
//     MP mp = sc.load_ptr(model_id);
//     qDebug() << "model_id : " << model_id;
//
//     Scills3DUpdater updater;
//     updater.sc = &sc;
//     updater.exec( mp );
//
//     mp[ "_computation_mode" ] = false;
//     mp[ "_computation_state" ] = false;
//     mp[ "_processing_state" ] = false;
//     mp.flush();


//id du model à traiter
    quint64 model_id = atoi(argv[1]);
    sc.reg_type( "Scills3DItem" );
    // attente
    while ( SodaClient::Event event = sc.event() ) {
        MP mp = event.mp();
        if ( mp.type() == "Scills3DItem" and mp.get_server_id() == model_id ) {
            quint64 model_stop_state = mp[ "_stop_state" ];
            if( model_stop_state == true ) {
                qDebug() << "###############   finish Scills3DItem ###############" ;
                break;
            } else {
                qDebug() << "###############   launch Scills3DItem ###############" ;
                Scills3DUpdater updater;
                updater.argc = argc;
                updater.argv = argv;
                updater.sc = &sc;
                updater.exec( mp );
            }
        }
    }
}
bool UnvReaderUpdater3D::run( MP mp ) {
    MP  file_unv = mp[ "_children[ 0 ]" ];
    qDebug() << file_unv;
    QString file_unv_name = file_unv[ "_name" ];
    qDebug() << file_unv_name;
    if (file_unv.ok()){
        quint64 ptr = file_unv[ "_ptr" ];
        QString name = file_unv[ "_name" ];
        MP data = sc->load_ptr( ptr );
        qDebug() << "on lit le path";
        QString path_unv;
        if( data.ok() and data.type() == "Path") {
            QString path_temp = data;
            path_unv = path_temp;
            qDebug() << path_unv; 
        }

        //lecture du maillage utilisateur -------------------------------------------
        //lecture du maillage utilisateur -------------------------------------------
        QByteArray byteArray = path_unv.toUtf8();
        const char* c_path_unv = byteArray.constData();
        Sc2String file;
        file << c_path_unv;
        
        MeshUser mesh_user( file, "0" );
        mesh_user.create_mesh_unv( file, ".unv");
        
        MP om = mp[  "_output[ 0 ].mesh" ];
        om[ "points" ].clear();
        om[ "_elements" ].clear();
        //liste des points du maillage------------
        new_list_points_mesh_3D(om, mesh_user);
        //liste des éléments du maillage----------
        new_list_elements_mesh_3D(om, mesh_user);
    }
    add_message( mp, ET_Info, "UnvReaderUpdater3D just finish" );
}
示例#5
0
int main( int argc, char **argv ) {
    // connection
    SodaClient sc( QHostAddress::Any, 8890 );
    if ( not sc.connected() ) return 1;

    //id du model à traiter
/*    quint64 model_id = atoi(argv[1]); */  
    sc.reg_type( "CorrelationItem" );
    
    
//     MP mp = sc.load_ptr(model_id);
//     qDebug() << "###############   launch CorrelationItem ###############" ;
//     CorreliUpdater updater;
//     updater.sc = &sc;
//     updater.exec( mp );
//     qDebug() << "###############   finish stand alone CorrelationItem ###############" ;
//      
   
    // attente
    while ( SodaClient::Event event = sc.event() ) {
        MP mp = event.mp();
        if ( mp.type() == "CorrelationItem" ){ //and mp.get_server_id() == model_id ) {
            quint64 model_stop_state = mp[ "_stop_state" ];  
//             if( model_stop_state == true ){
//                 qDebug() << "###############   finish CorrelationItem ###############" ;
//                 break;
//             }else{
                qDebug() << "###############   launch CorrelationItem ###############" ;
                CorreliUpdater updater;
                updater.sc = &sc;
                updater.exec( mp );
                quint64 model_finish_state = mp[ "_finish_state" ];
                //if computation is finished, if not, there is somthing to compute
//                 if(model_finish_state == true){
//                     qDebug() << "###############   finish normal CorrelationItem ###############" ;
//                     break;
//                 }
//             }
        }
    }
    
    

//     // attente
//     while ( SodaClient::Event event = sc.event() ) {
//         MP mp = event.mp();
//         if ( mp.type() == "CorrelationItem" ) {
//             CorreliUpdater cu;
//             cu.sc = &sc;
//             cu.exec( mp );
//         } else if ( mp.type() == "ServerAssistedVisualization" ) {
//             ServerAssistedVisualizationUpdater mu;
//             mu.sc = &sc;
//             mu.exec( mp );
//         } else if ( mp.type() == "MesherItem" ) {
//             MeshUpdater mu;
//             mu.exec( mp );
//         } else if ( mp.type() == "File" ) {
//             FileUpdater fu;
//             fu.sc = &sc;
//             fu.exec( mp );
//         } else if ( mp.type() == "Img" ) {
//             ImgUpdater iu;
//             iu.sc = &sc;
//             iu.exec( mp );
//         }
//     }
}
bool IpolACEUpdater::run( MP mp ) {
    MP lst_img = mp[ "_children[ 0 ]._children" ];  // La liste des images
    const int nb_img = lst_img.size();              // Le nombre d'images
    for(int i = 0; i < nb_img; ++i) {
        MP img = lst_img[i];                        // La i-eme image
        QString name = img["_name"];
        
        if(img.type() == "ImgItem"){
            /// Load ImgItem into a QImage
            QString name = img[ "_name" ];
            QImage tmp_input;
            load_img(img,tmp_input);
            /// Save it into a processable file
            QString tmp_input_name = name + ".tmp.png";
            tmp_input.save(tmp_input_name,"PNG");
            
            QString tmp_output_name = "ACE_" + name + ".tmp.png";
            
            std::stringstream commandes;
            commandes << "../IpolACEPlugin/ServerPlugin/src_ace/ace";
            
            commandes << " -a " << (double) mp["alpha.val"];
            
            int num_weight = mp["weight.num"];
            switch(num_weight) {
                case 0:
                    commandes << " -w 1/r";
                    break;
                case 1:
                    commandes << " -w 1";
                    break;
                case 2:
                    commandes << " -w G:" << (double) mp["weight.lst"][num_weight]["_sigma.val"];
                    break;
                default:
                    add_message( mp, ET_Error, "Invalid weight type" );
                    return false;
            }
            
            int num_method = mp["method.num"];
            MP method = mp["method.lst"][num_method];
            switch(num_method) {
                case 0:
                    commandes << " -m interp:" << (int) method["_level.val"];
                    break;
                case 1:
                {
                    int num_poly = method["_degree.num"];
                    commandes << " -m poly:"   << ((QString) method["_degree.lst"][num_poly]).toStdString();
                    break;
                }
                default:
                    add_message( mp, ET_Error, "Invalid method type" );
                    return false;
            }
            
            commandes << " \"" << tmp_input_name.toStdString()  << "\"";
            commandes << " \"" << tmp_output_name.toStdString() << "\"";
            std::string cmd = commandes.str();
            int output = std::system(cmd.c_str());
            qDebug() << cmd.c_str();
            qDebug() << "Returned " << output;
            
            if(not output) {
                /// Retrieve image data into a ImgItem
                QImage tmp_output(tmp_output_name);
                MP new_img = MP::new_obj("ImgItem");
                new_treeitem(new_img , "ACE_" + name);
                new_img["img"] = MP::new_obj("Img");
                save_img(new_img["img"], tmp_output);
                
                /// Add result image to output set
                mp["_output[0]._children"] << new_img;
            }
            else {
                add_message( mp, ET_Error, "Error while running the application" );
            }
            
            /// clean temporary files
            QFile::remove(tmp_input_name);
            QFile::remove(tmp_output_name);
        }
        else {
            add_message( mp, ET_Error, "Unable to find image file in tree" );
        }
    }

    add_message( mp, ET_Info, "Ipol LSD -> OK" );
    qDebug() << "Ipol LSD just finish";
}
bool IpolLSDUpdater::run( MP mp ) {
    MP lst_img = mp[ "_children[ 0 ]._children" ];  // La liste des images
    const int nb_img = lst_img.size();              // Le nombre d'images
    for(int i = 0; i < nb_img; ++i) {
        MP img = lst_img[i];                        // La i-eme image
        QString name = img["_name"];
        
        if(img.type() == "ImgItem"){
            /// Load ImgItem into a QImage
            QString name = img[ "_name" ];
            QImage tmp_input;
            load_img(img,tmp_input);
            /// Save it into a processable file
            QString tmp_input_name = name + ".pgm";
            tmp_input.save(tmp_input_name,"PGM");
            
            QString tmp_output_name = "LSD_" + name + ".pgm";
            
            std::stringstream commandes;
            commandes << "../IpolLSDPlugin/ServerPlugin/src_lsd/lsd";
            commandes << " -s " << (double) mp["scale.val"];
            commandes << " -c " << (double) mp["sigma_coef.val"];
            commandes << " -q " << (double) mp["quant.val"];
            commandes << " -a " << (double) mp["ang_th.val"];
            commandes << " -e " << (double) mp["log_eps.val"];
            commandes << " -d " << (double) mp["density_th.val"];
            commandes << " -b " << (int)    mp["n_bins.val"];
            commandes << " -W " << (double) mp["width.val"];
            commandes << " -R \"" << tmp_output_name.toStdString() << "\"";
            commandes << "    \"" << tmp_input_name.toStdString()  << "\"";
            commandes << " results.txt";    /// Unused results file
            //commandes << " > log.txt";      /// for error management
            std::string cmd = commandes.str();
            int output = std::system(cmd.c_str());
            //qDebug() << cmd.c_str();
            //qDebug() << "Returned " << output;
            
            if(not output) {
                /// Retrieve image data into a ImgItem
                QImage tmp_output(tmp_output_name);
                MP new_img = MP::new_obj("ImgItem");
                new_treeitem(new_img , "LSD_" + name);
                new_img["img"] = MP::new_obj("Img");
                save_img(new_img["img"], tmp_output);
                
                /// Add result image to output set
                mp["_output[0]._children"] << new_img;
            }
            else {
                add_message( mp, ET_Error, "Error while running the application" );
            }
            
            /// clean temporary files
            QFile::remove(tmp_input_name);
            QFile::remove(tmp_output_name);
            QFile::remove("results.txt");
        }
        else {
            add_message( mp, ET_Error, "Unable to find image file in tree" );
        }
    }

    add_message( mp, ET_Info, "Ipol LSD -> OK" );
    qDebug() << "Ipol LSD just finish";
}