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

    MP mp = sc.load( "/pouet" );
    srand( time( NULL ) );
    // mp.clear();

    static_cast<TypedArray<double> *>( mp.model() )->_data.resize( 4 * 40000 );
    static_cast<TypedArray<double> *>( mp.model() )->_data[ 0 ] = rand();
    static_cast<TypedArray<double> *>( mp.model() )->_size[ 1 ] = 40000;
    mp.signal_change();

    // mp.flush();
}
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" );
}
void Launcher::launch(SodaClient::Event event){
    if(event.event_num == 1){  //evennement issu du timer
        MP input = mp_list[0];

        MP child_24 = input["children[2]"]["children[0].children"];
        MP node_22 = input["children[0]"]["children[1]"];
        QString name_0 = input["name"];

        if(name_0 == "+"){
            child_24 << node_22;
            name_0 = "Noeud 0";
            input["name"] = name_0;
        }
        else if(name_0 == "-"){
            child_24.clear();
            name_0 = "Noeud 0";
            input["name"] = name_0;
            input["children[2]"]["children[0].children"] = child_24;
        }

        qDebug() << child_24;


//        MP nom = input["children[0]"]["children[1]"]["children[0].children"];
//        QString _nom = nom;
//        _nom = "testotest";
//        nom = _nom;


        input.flush();
    }

    if(event.event_num != 1){  //evennement issu d'une modification de l'objet sur le serveur
        MP input = mp_list[0];
    }
};
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();
}
Example #7
0
    void test_with (MP &m1, MP &m2, MP &m3) const {
        {
            value_type t;

            // Default Construct
            default_construct<MP>::test ();
            
            // Copy and swap
            initialize_matrix (m1);
            initialize_matrix (m2);
            m1 = m2;
            std::cout << "m1 = m2 = " << m1 << std::endl;
            m1.assign_temporary (m2);
            std::cout << "m1.assign_temporary (m2) = " << m1 << std::endl;
            m1.swap (m2);
            std::cout << "m1.swap (m2) = " << m1 << " " << m2 << std::endl;

            // Unary matrix operations resulting in a matrix
            initialize_matrix (m1);
            m2 = - m1;
            std::cout << "- m1 = " << m2 << std::endl;
            m2 = ublas::conj (m1);
            std::cout << "conj (m1) = " << m2 << std::endl;

            // Binary matrix operations resulting in a matrix
            initialize_matrix (m1);
            initialize_matrix (m2);
            m3 = m1 + m2;
            std::cout << "m1 + m2 = " << m3 << std::endl;
            m3 = m1 - m2;
            std::cout << "m1 - m2 = " << m3 << std::endl;

            // Scaling a matrix
            t = N;
            initialize_matrix (m1);
            m2 = value_type (1.) * m1;
            std::cout << "1. * m1 = " << m2 << std::endl;
            m2 = t * m1;
            std::cout << "N * m1 = " << m2 << std::endl;
            initialize_matrix (m1);
            m2 = m1 * value_type (1.);
            std::cout << "m1 * 1. = " << m2 << std::endl;
            m2 = m1 * t;
            std::cout << "m1 * N = " << m2 << std::endl;

            // Some assignments
            initialize_matrix (m1);
            initialize_matrix (m2);
            m2 += m1;
            std::cout << "m2 += m1 = " << m2 << std::endl;
            m2 -= m1;
            std::cout << "m2 -= m1 = " << m2 << std::endl;
            m2 = m2 + m1;
            std::cout << "m2 = m2 + m1 = " << m2 << std::endl;
            m2 = m2 - m1;
            std::cout << "m2 = m2 - m1 = " << m2 << std::endl;
            m1 *= value_type (1.);
            std::cout << "m1 *= 1. = " << m1 << std::endl;
            m1 *= t;
            std::cout << "m1 *= N = " << m1 << std::endl;

            // Transpose
            initialize_matrix (m1);
            // Transpose of a triangular isn't triangular of the same kind
            std::cout << "trans (m1) = " << ublas::trans (m1) << std::endl;

            // Hermitian
            initialize_matrix (m1);
            // Hermitian of a triangular isn't hermitian of the same kind
            std::cout << "herm (m1) = " << ublas::herm (m1) << std::endl;

            // Matrix multiplication
            initialize_matrix (m1);
            initialize_matrix (m2);
            m3 = ublas::prod (m1, m2);
            std::cout << "prod (m1, m2) = " << m3 << std::endl;
        }
    }
Example #8
0
    void operator () (MP &m1, MP &m2, MP &m3) const {
        try {
            value_type t;

            // Copy and swap
            initialize_matrix (m1);
            initialize_matrix (m2);
            m1 = m2;
            std::cout << "m1 = m2 = " << m1 << std::endl;
            m1.assign_temporary (m2);
            std::cout << "m1.assign_temporary (m2) = " << m1 << std::endl;
            m1.swap (m2);
            std::cout << "m1.swap (m2) = " << m1 << " " << m2 << std::endl;

            // Unary matrix operations resulting in a matrix
            initialize_matrix (m1);
            m2 = - m1;
            std::cout << "- m1 = " << m2 << std::endl;
            m2 = ublas::conj (m1);
            std::cout << "conj (m1) = " << m2 << std::endl;

            // Binary matrix operations resulting in a matrix
            initialize_matrix (m1);
            initialize_matrix (m2);
            m3 = m1 + m2;
            std::cout << "m1 + m2 = " << m3 << std::endl;
            m3 = m1 - m2;
            std::cout << "m1 - m2 = " << m3 << std::endl;

            // Scaling a matrix
            t = N;
            initialize_matrix (m1);
            m2 = value_type (1.) * m1;
            std::cout << "1. * m1 = " << m2 << std::endl;
            m2 = t * m1;
            std::cout << "N * m1 = " << m2 << std::endl;
            initialize_matrix (m1);
            m2 = m1 * value_type (1.);
            std::cout << "m1 * 1. = " << m2 << std::endl;
            m2 = m1 * t;
            std::cout << "m1 * N = " << m2 << std::endl;

            // Some assignments
            initialize_matrix (m1);
            initialize_matrix (m2);
#ifdef BOOST_UBLAS_USE_ET
            m2 += m1;
            std::cout << "m2 += m1 = " << m2 << std::endl;
            m2 -= m1;
            std::cout << "m2 -= m1 = " << m2 << std::endl;
#else
            m2 = m2 + m1;
            std::cout << "m2 += m1 = " << m2 << std::endl;
            m2 = m2 - m1;
            std::cout << "m2 -= m1 = " << m2 << std::endl;
#endif
            m1 *= value_type (1.);
            std::cout << "m1 *= 1. = " << m1 << std::endl;
            m1 *= t;
            std::cout << "m1 *= N = " << m1 << std::endl;

            // Transpose
            initialize_matrix (m1);
            m2 = ublas::trans (m1);
            std::cout << "trans (m1) = " << m2 << std::endl;

            // Hermitean
            initialize_matrix (m1);
            m2 = ublas::herm (m1);
            std::cout << "herm (m1) = " << m2 << std::endl;

            // Matrix multiplication
            initialize_matrix (m1);
            initialize_matrix (m2);
            m3 = ublas::prod (m1, m2);
            std::cout << "prod (m1, m2) = " << m3 << std::endl;
        }
        catch (std::exception &e) {
            std::cout << e.what () << std::endl;
        }
        catch (...) {
            std::cout << "unknown exception" << std::endl;
        }
    }
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 );
//         }
//     }
}
Example #10
0
    void test_expression_with (MP &m1, MP &m2, MP &m3) const {
        value_type t;

        // Default Construct
        default_construct<MP>::test ();
        
        // Copy and swap
        initialize_matrix (m1);
        initialize_matrix (m2);
        m1 = m2;
        std::cout << "m1 = m2 = " << m1 << std::endl;
        m1.assign_temporary (m2);
        std::cout << "m1.assign_temporary (m2) = " << m1 << std::endl;
        m1.swap (m2);
        std::cout << "m1.swap (m2) = " << m1 << " " << m2 << std::endl;

        // Zero assignment
        m1 = ublas::zero_matrix<> (m1.size1 (), m1.size2 ());
        std::cout << "m1.zero_matrix = " << m1 << std::endl;
        m1 = m2;

#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
            // Project range and slice
        initialize_matrix (m1);
        initialize_matrix (m2);
        project (m1, ublas::range(0,1),ublas::range(0,1)) = project (m2, ublas::range(0,1),ublas::range(0,1));
        project (m1, ublas::range(0,1),ublas::range(0,1)) = project (m2, ublas::slice(0,1,1),ublas::slice(0,1,1));
        project (m1, ublas::slice(2,-1,2),ublas::slice(2,-1,2)) = project (m2, ublas::slice(0,1,2),ublas::slice(0,1,2));
        project (m1, ublas::slice(2,-1,2),ublas::slice(2,-1,2)) = project (m2, ublas::range(0,2),ublas::range(0,2));
        std::cout << "m1 = range/slice " << m1 << std::endl;
#endif

            // Unary matrix operations resulting in a matrix
        initialize_matrix (m1);
        m2 = - m1;
        std::cout << "- m1 = " << m2 << std::endl;
        m2 = ublas::conj (m1);
        std::cout << "conj (m1) = " << m2 << std::endl;

        // Binary matrix operations resulting in a matrix
        initialize_matrix (m1);
        initialize_matrix (m2);
        m3 = m1 + m2;
        std::cout << "m1 + m2 = " << m3 << std::endl;
        m3 = m1 - m2;
        std::cout << "m1 - m2 = " << m3 << std::endl;
        m3 = ublas::element_prod (m1, m2);
        std::cout << "element_prod (m1, m2) = " << m3 << std::endl;

        // Scaling a matrix
        t = N;
        initialize_matrix (m1);
        m2 = value_type (1.) * m1;
        std::cout << "1. * m1 = " << m2 << std::endl;
        m2 = t * m1;
        std::cout << "N * m1 = " << m2 << std::endl;
        initialize_matrix (m1);
        m2 = m1 * value_type (1.);
        std::cout << "m1 * 1. = " << m2 << std::endl;
        m2 = m1 * t;
        std::cout << "m1 * N = " << m2 << std::endl;
        m2 = m1 / value_type (2.);
        std::cout << "m1 / 2. = " << m2 << std::endl;
        m2 = m1 / t;
        std::cout << "m1 / N = " << m2 << std::endl;

        // Some assignments
        initialize_matrix (m1);
        initialize_matrix (m2);
        m2 += m1;
        std::cout << "m2 += m1 = " << m2 << std::endl;
        m2 -= m1;
        std::cout << "m2 -= m1 = " << m2 << std::endl;
        m2 = m2 + m1;
        std::cout << "m2 = m2 + m1 = " << m2 << std::endl;
        m2 = m2 - m1;
        std::cout << "m2 = m2 - m1 = " << m2 << std::endl;
        m1 *= value_type (1.);
        std::cout << "m1 *= 1. = " << m1 << std::endl;
        m1 *= t;
        std::cout << "m1 *= N = " << m1 << std::endl;

        // Transpose
        initialize_matrix (m1);
        m2 = ublas::trans (m1);
        std::cout << "trans (m1) = " << m2 << std::endl;

        // Hermitean
        initialize_matrix (m1);
        m2 = ublas::herm (m1);
        std::cout << "herm (m1) = " << m2 << std::endl;

        // Matrix multiplication
        initialize_matrix (m1);
        initialize_matrix (m2);
        m3 = ublas::prod (m1, m2);
        std::cout << "prod (m1, m2) = " << m3 << std::endl;
    }
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 ScillsResultUpdater::run( MP mp ) {
    // add_message( mp, ET_Info, "Test info msg" );
    int nb_parts_ = mp[ "nb_parts" ];
    qDebug() << nb_parts_;
    double id_model = mp[ "id_model" ];
    if ( id_model == -1 ) {
        add_message( mp, ET_Error, "Model is not available" );
        //return false;
    }

    double id_calcul = mp[ "id_calcul" ];
    if ( id_calcul <= -2 ) {
        add_message( mp, ET_Error, "Data are not available" );
    } else if( id_calcul == -1 and nb_parts_ == 0) {
        add_message( mp, ET_Info, "You choose to visualize the base mesh" );
//           using namespace Metil;
//           using namespace LMT;


        // version 1------------------------------------------------------------------
        Sc2String str_id_model;
        str_id_model << id_model;
        Sc2String str_id_calcul;
        str_id_calcul << id_calcul;

        GeometryUser        geometry_user;                                    /// structure de stockage des informations du fichier HDF5
        geometry_user.initialisation(str_id_model, str_id_calcul);
        geometry_user.read_hdf5(false,true,"test");                           /// true si on lit les info micro, true si on lit toutes les infos

        MP opc = mp[ "_children[ 0 ]" ];            // output Part collection
        MP oic = mp[ "_children[ 1 ]" ];            // output Interface collection
        MP oec = mp[ "_children[ 2 ]" ];            // output Edge collection
        //qDebug() << oec[ "_edge_profile" ];

        int nb_parts = 0;
        int nb_interfaces = 0;
        int nb_edges = 0;
        int dimention;
        if(geometry_user.group_elements[0].pattern_id == 0 or geometry_user.group_elements[0].pattern_id == 1) {
            dimention = 2;
        } else {
            dimention = 3;
        }

        for (int i_group=0; i_group<geometry_user.group_elements.size(); i_group++) {
            MP part_profile = oic[ "_part_profile" ];
            MP part = MP::new_obj( "ScillsPartItem" );
            new_scills_obg(part, part_profile, geometry_user.group_elements[i_group].id, "Part");

            //création du sous maillage de part ------
            part[ "_mesh" ] = MP::new_obj( "Mesh" );
            MP om = part[ "_mesh" ];
            new_mesh(om);
            part[ "visualization" ] = om[ "visualization" ];
            part[ "id" ] = geometry_user.group_elements[i_group].id;

            if(dimention == 2) {
                //liste des points du maillage------------
                new_list_points_mesh_2D(om, geometry_user.group_elements[i_group]);

                //liste des éléments du maillage----------
                new_list_elements_mesh_2D(om, geometry_user.group_elements[i_group]);

            } else if(dimention == 3) {
                new_mesh_part_3D(om, geometry_user, i_group);
            }
            nb_parts += 1;
            opc[ "_children" ] << part;
        }

        for (int i_group=0; i_group<geometry_user.group_interfaces.size(); i_group++) {
            if(geometry_user.group_interfaces[i_group].type == 2) {
                //création de l'interface-------------------------
                MP interface_profile = oic[ "_interface_profile" ];
                MP interface = MP::new_obj( "ScillsInterfaceItem" );
                new_scills_obg(interface, interface_profile, geometry_user.group_interfaces[i_group].id, "Interface");

                //création du sous maillage de interface ------
                interface[ "_mesh" ] = MP::new_obj( "Mesh" );
                MP om = interface[ "_mesh" ];
                new_mesh(om);
                interface[ "visualization" ] = om[ "visualization" ];
                interface[ "id" ] = geometry_user.group_interfaces[i_group].id;

                if(dimention == 2) {
                    //liste des points du maillage------------
                    new_list_points_mesh_2D(om, geometry_user.group_interfaces[i_group]);

                    //liste des éléments du maillage----------
                    new_list_elements_mesh_2D(om, geometry_user.group_interfaces[i_group]);

                } else if(dimention == 3) {
                    //liste des points du maillage------------
                    new_list_points_mesh_3D(om, geometry_user.group_interfaces[i_group]);

                    //liste des éléments du maillage----------
                    new_list_elements_mesh_3D(om, geometry_user.group_interfaces[i_group]);
                }

                //ajout de l'interface à l'assemblage------------
                nb_interfaces += 1;
                oic[ "_children" ] << interface;
            } else if(geometry_user.group_interfaces[i_group].type == 0) {
                //création du edge-------------------------
                MP edge_profile = oec[ "_edge_profile" ];
                MP edge = MP::new_obj( "ScillsEdgeItem" );
                new_scills_obg(edge, edge_profile, geometry_user.group_interfaces[i_group].id, "Edge");

                //création du sous maillage de edge ------
                edge[ "_mesh" ] = MP::new_obj( "Mesh" );
                MP om = edge[ "_mesh" ];
                new_mesh(om);
                edge[ "visualization" ] = om[ "visualization" ];
                edge[ "id" ] = geometry_user.group_interfaces[i_group].id;

                if(dimention == 2) {
                    //liste des points du maillage------------
                    new_list_points_mesh_2D(om, geometry_user.group_interfaces[i_group]);

                    //liste des éléments du maillage----------
                    new_list_elements_mesh_2D(om, geometry_user.group_interfaces[i_group]);

                } else if(dimention == 3) {
                    //liste des points du maillage------------
                    new_list_points_mesh_3D(om, geometry_user.group_interfaces[i_group]);

                    //liste des éléments du maillage----------
                    new_list_elements_mesh_3D(om, geometry_user.group_interfaces[i_group]);
                }

                //ajout du edge à l'assemblage------------
                nb_edges += 1;
                oec[ "_children" ] << edge;
            }
        }

        mp[ "nb_parts" ] = nb_parts;
        mp[ "nb_interfaces" ] = nb_interfaces;
        mp[ "nb_edges" ] = nb_edges;

        mp.flush();
    } else {
        add_message( mp, ET_Info, "You choose to visualize a result" );
    }
    add_message( mp, ET_Info, "ScillsResult just finish" );

}
void Updater::exec( const MP &mp ) {
    // nothing to compute ?
    quint64 req = mp[ "_computation_req_date" ];
    quint64 rep = mp[ "_computation_rep_date" ];
    qDebug() << req << rep;
    if ( req <= rep )
        return;

    quint64 cm = mp[ "_computation_mode" ];
    quint64 cs = mp[ "_computation_state" ];
    qDebug() << cm << " s=" << cs;
    if ( cm == false && cs == false )
        return;

    // waiting for another computation ?
    ++Model::_cur_op_id;
    if ( has_something_to_compute_else_than( mp.model(), mp.model() ) ) {
        qDebug() << "something to compute !";
        //mp[ "_computation_mode" ] = true;
//         sleep(1);
//         quint64 mp_server_id = mp.get_server_id();
//         mp = sc.load_ptr(mp_server_id);
        return;
    }

    //
    clear_error_list( mp );

    qDebug() << "run" << type();

    // sdl::set( "toto", "1" );
    // QHttp
    // system( "wget ..." );

    quint64 ac = mp[ "auto_compute" ];
    mp[ "_ready_state" ]       = false;
    mp[ "_computation_state" ] = false;
    mp[ "_pending_state" ]     = false;
    mp[ "_processing_state" ]  = true;
    mp[ "_finish_state" ]      = false;
    mp[ "_stop_state" ]        = false;
    if ( ac == 0 )
        mp[ "_computation_mode" ]  = 0;
    
    
    run( mp );

    mp[ "_computation_rep_date" ] = req;
    //         add_message( mp, ET_Info, "done" );
    if ( cm == false and cs == true )
        mp[ "_computation_state" ] = false;
    
    mp[ "_ready_state" ]        = false;
    mp[ "_computation_state" ]  = false;
    mp[ "_pending_state" ]      = false;
    mp[ "_processing_state" ]   = false;
    mp[ "_finish_state" ]       = true;
    mp[ "_stop_state" ]         = false;
    if ( ac == 0 )
        mp[ "_computation_mode" ] = 0; 
    //sdl::set( "done", "1" );
    
    
    qDebug() << "model_computation_state : " << mp[ "_computation_state" ];
    qDebug() << "model_computation_mode : " << mp[ "_computation_mode" ];
}
Example #14
0
    void test_with (MP &m1, MP &m2, MP &m3) const {
        {
            value_type t;

            // Copy and swap
            initialize_matrix (m1);
            initialize_matrix (m2);
            m1 = m2;
            std::cout << "m1 = m2 = " << m1 << std::endl;
            m1.assign_temporary (m2);
            std::cout << "m1.assign_temporary (m2) = " << m1 << std::endl;
            m1.swap (m2);
            std::cout << "m1.swap (m2) = " << m1 << " " << m2 << std::endl;

            // Zero assignment
            m1 = ublas::zero_matrix<value_type> (m1.size1 (), m1.size2 ());
            std::cout << "m1.zero_matrix = " << m1 << std::endl;
            m1 = m2;

            // Unary matrix operations resulting in a matrix
            initialize_matrix (m1);
            m2 = - m1;
            std::cout << "- m1 = " << m2 << std::endl;
            m2 = ublas::conj (m1);
            std::cout << "conj (m1) = " << m2 << std::endl;

            // Binary matrix operations resulting in a matrix
            initialize_matrix (m1);
            initialize_matrix (m2);
            m3 = m1 + m2;
            std::cout << "m1 + m2 = " << m3 << std::endl;
            m3 = m1 - m2;
            std::cout << "m1 - m2 = " << m3 << std::endl;

            // Scaling a matrix
            t = N;
            initialize_matrix (m1);
            m2 = value_type (1.) * m1;
            std::cout << "1. * m1 = " << m2 << std::endl;
            m2 = t * m1;
            std::cout << "N * m1 = " << m2 << std::endl;
            initialize_matrix (m1);
            m2 = m1 * value_type (1.);
            std::cout << "m1 * 1. = " << m2 << std::endl;
            m2 = m1 * t;
            std::cout << "m1 * N = " << m2 << std::endl;

            // Some assignments
            initialize_matrix (m1);
            initialize_matrix (m2);
            m2 += m1;
            std::cout << "m2 += m1 = " << m2 << std::endl;
            m2 -= m1;
            std::cout << "m2 -= m1 = " << m2 << std::endl;
            m2 = m2 + m1;
            std::cout << "m2 = m2 + m1 = " << m2 << std::endl;
            m2 = m2 - m1;
            std::cout << "m2 = m1 - m1 = " << m2 << std::endl;
            m1 *= value_type (1.);
            std::cout << "m1 *= 1. = " << m1 << std::endl;
            m1 *= t;
            std::cout << "m1 *= N = " << m1 << std::endl;

            // Transpose
            initialize_matrix (m1);
            m2 = ublas::trans (m1);
            std::cout << "trans (m1) = " << m2 << std::endl;

            // Hermitean
            initialize_matrix (m1);
            m2 = ublas::herm (m1);
            std::cout << "herm (m1) = " << m2 << std::endl;

            // Matrix multiplication
            initialize_matrix (m1);
            initialize_matrix (m2);
            m3 = ublas::prod (m1, m2);
            std::cout << "prod (m1, m2) = " << m3 << std::endl;
        }
    }
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";
}