Personal tools
You are here: Home Forum Extension of the platform Visualizing MEDCoupling field in VISU

Visualizing MEDCoupling field in VISU

Up to Extension of the platform

Visualizing MEDCoupling field in VISU

Posted by Yuefeng Qiu at February 18. 2013

Hello!

I have generated a MED field using MEDCoupling and would like to visualize it in VISU. I do it in this way:

First, Generate the field using ParaMEDMEM::MEDCouplingFieldDouble pointer; 

Second, create an instance of ParaMEDMEM::MEDCouplingFieldDoubleServant using this field;

Third, pass out the field using SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr;

But for visualizing it in VISU, its method ImportMedField(SALOME_MED::Field)  require a SALOME_MED::Field as a parameter. 

Is there any possible way to make this conversion??

Any answer or even hints will be highly appreciated! 

 

Best regards,

Yuefeng Qiu

Re: Visualizing MEDCoupling field in VISU

Posted by Anthony GEAY at February 18. 2013

Hello,

No it is not possible with visu but it is possible with PARAVIS. Using Para MEDCorbaPlugin in Sources Menu (below Mandelbrot) of PARAVIS.

Just copy paste the IOR ref given by.

from MEDCouplingCorba import *

fc=MEDCouplingFieldDoubleServant._this(myField)

import CORBA

orb=CORBA.ORB_init()

print orb.object_to_string(fc)

 

Best regards,

Anthony

Re: Visualizing MEDCoupling field in VISU

Posted by Yuefeng Qiu at February 18. 2013

Thanks, Anthony!

I would like to invoke PARAVIS from my C++ code, pass the IOR of the MEDCoupling field to it and then visualize. Now I understand how to obtain the IOR in MEDCoupling side. 

Could you tell me how to write code to invoke PARAVIS, then how to call this plugin, then which method in this plugin to receive this IOR?

Best regards,

Yuefeng

 

Re: Visualizing MEDCoupling field in VISU

Posted by Anthony GEAY at February 19. 2013

Hello Yuefeng,

 

Before launching your application set the OMNIORB_CONFIG to those of your SALOME/PARAVIS session you want.

$OMNIORB_CONFIG should point to a file that describes the workstation and the port (typically 2810).

Then invoke paravis like the next python script using "ExecuteScript" of PARAVIS salome component.

#####

ref_f=MEDCouplingFieldDoubleServant._this(f)

import CORBA
orb=CORBA.ORB_init()
ior=orb.object_to_string(ref_f)

import PARAVIS_Gen_idl
import salome
salome.salome_init()
paravis=salome.lcc.FindOrLoadComponent("FactoryServer","PARAVIS")

script="""
src1 = ParaMEDCorbaPluginSource()
src1.IORCorba = '%s'
asc=GetAnimationScene()
rw=GetRenderView()
dr=Show()\ndr.Visibility = 1
Render()
"""
content=script%(ior)
paravis.ExecuteScript(content)

#############

The C++ code here : MED_SRC/src/MEDCalculator/MEDCalculatorDBField.cxx performs the job of python code above.

 

Best Regards,

 

Anthony

Re: Visualizing MEDCoupling field in VISU

Posted by Yuefeng Qiu at February 19. 2013
I followed your advice and copy the code in MED_SRC/src/MEDCalculator/MEDCalculatorDBField.cxx to my code, as following:
        int argc=0;
        CORBA::ORB_var orb=CORBA::ORB_init(argc,0);
        CORBA::Object_var obj=orb->resolve_initial_references("RootPOA");
        PortableServer::POA_var poa=PortableServer::POA::_narrow(obj);
        PortableServer::POAManager_var mgr=poa->the_POAManager();
        mgr->activate();

        SALOME_NamingService ns(orb);
        ns.Change_Directory("/Containers");
        std::vector<std::string> subdirs=ns.list_subdirs();
        std::ostringstream path;
        path << "/Containers/" << subdirs[0] << "/FactoryServer/PARAVIS_inst_1";
        CORBA::Object_var paravis=ns.Resolve(path.str().c_str());
        CORBA::Request_var req=paravis->_request("ExecuteScript");
        CORBA::NVList_ptr args=req->arguments();
        CORBA::Any ob;
        std::ostringstream script;
        char *ior=orb->object_to_string(aField);
        script << "src1 = ParaMEDCorbaPluginSource()\nsrc1.IORCorba = '" << ior << "'\nasc=GetAnimationScene()\nrw=GetRenderView()\ndr=Show()\ndr.Visibility = 1\n";
        CORBA::string_free(ior);
        ob <<= script.str().c_str();
        args->add_value("script",ob,CORBA::ARG_IN);
        req->set_return_type(CORBA::_tc_void);
        req->invoke();
I encountered a problem in the line in BOLD. The CORBA return an exception. what could happen in this line?
 
Best regards,
Yuefeng
 

Re: Visualizing MEDCoupling field in VISU

Posted by Anthony GEAY at February 19. 2013

Check that "paravis" variable is not null with is_nil. There"s a great chance to be null ref !

You have to activate PARAVIS component before invoking your external process !

You have to set OMNIORB_CONFIG correctly to the salome session in which PARAVIS has been activated !

Best regards,

Anthony

Re: Visualizing MEDCoupling field in VISU

Posted by Yuefeng Qiu at February 19. 2013

You are right, Anthony. After loading the PARAVIS first and then call it, I can now visualize my MEDCouplingField in PARAVIS. 

A further question: Can I use PARAVIS Engine to finish this job? I think it's convenient if I can use an uniform way to call another component in SALOME. The code above is not so straightforward for me. 

Best regards,

Yuefeng

Re: Visualizing MEDCoupling field in VISU

Posted by Anthony GEAY at February 20. 2013

Hello Yuefeng,

Sorry I don't understand very well your question. What job do you mean ? data processing ?

It's clear that the standart way to communicate meshes and fields between components sequential engines (servers) it is by the use of CORBA interfaces MEDCoupling*CorbaInterfaces like you did successfully in your C++ code. Your code requires more CORBA knowledge because the invokation of remote service (ExecuteScript here) is done dynamically (it is needed for MED component), but you can perform the same thing using standart CORBA invcation because your are not expected to manage depedancies with PARAVIS as MED does.

Best regards

Re: Visualizing MEDCoupling field in VISU

Posted by Yuefeng Qiu at February 20. 2013

Hello Anthony,

Sorry for making the question unclear. I am a novice in CORBA programming so sometimes I feel a little bit lost. 

I know in VISU we can visualized a SALOME_MED::Field in this way:

        Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component("FactoryServer", "VISU" );

        VISU::VISU_Gen_var aVISUGen = VISU::VISU_Gen::_narrow(comp);

        ASSERT( !CORBA::is_nil( aVISUGen ) );

        aVISUGen->ImportMedField(aMEDField);

My question is: can I also call the PARAVIS and the plugin in this way? 

 

Re: Visualizing MEDCoupling field in VISU

Posted by Yuefeng Qiu at February 20. 2013

 

Hello Anthony,

Sorry for making the question unclear. I am a novice in CORBA programming so sometimes I feel a little bit lost. 

I know in VISU we can visualized a SALOME_MED::Field in this way:

 

        Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component("FactoryServer", "VISU" );

        VISU::VISU_Gen_var aVISUGen = VISU::VISU_Gen::_narrow(comp);

        ASSERT( !CORBA::is_nil( aVISUGen ) );

        aVISUGen->ImportMedField(aMEDField);

My question is: can I also call the PARAVIS and the plugin in this way? 

Best regards,

Yuefeng

Re: Visualizing MEDCoupling field in VISU

Posted by Anthony GEAY at February 21. 2013

Hello Yuefeng,

Yes absolutely ! Replace VISU by PARAVIS in you code. The code becomes :

Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component("FactoryServer", "PARAVIS" );

PARAVIS::PARAVIS_Gen_var  aPVGen = PARAVIS::PARAVIS_Gen::_narrow(comp);

        ASSERT( !CORBA::is_nil( aPVGen ) );

aPVGen->ExcecuteScript(...)

 

It is exactly equivalent to the code with "req->invoke()" you written. Except that here you have a static dependancy to PARAVIS_Gen.idl.

Anthony

Re: Visualizing MEDCoupling field in VISU

Posted by Yuefeng Qiu at February 22. 2013

Thanks Anthony!

That's exactly what I like!

 

Best regards,

Yuefeng

Powered by Ploneboard
Document Actions