]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
Add a visualization component.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Thu, 11 Aug 2016 14:48:38 +0000 (16:48 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Thu, 11 Aug 2016 14:48:38 +0000 (16:48 +0200)
13 files changed:
CMakeLists.txt
idl/CMakeLists.txt [new file with mode: 0644]
idl/PARAVIS.idl [new file with mode: 0644]
resources/PARAVISCatalog.xml.in
src/Insitu/CMakeLists.txt
src/Insitu/VisualizationComponent/CMakeLists.txt [new file with mode: 0644]
src/Insitu/VisualizationComponent/VisualizationComponent.cxx [new file with mode: 0644]
src/Insitu/VisualizationComponent/VisualizationComponent.hxx [new file with mode: 0644]
src/Insitu/VisualizationLibrary/CMakeLists.txt [new file with mode: 0644]
src/Insitu/VisualizationLibrary/visu.cxx [new file with mode: 0755]
src/Insitu/VisualizationLibrary/visu.hxx [new file with mode: 0755]
src/Insitu/visu.cxx [deleted file]
src/Insitu/visu.hxx [deleted file]

index 4871943580e28d87a3157ad2f0265707c58792a3..c4667a0a61b6275fef0d80cb38a00d2ae8c50f85 100644 (file)
@@ -274,6 +274,7 @@ IF(SALOME_BUILD_TESTS AND NOT SALOME_LIGHT_ONLY)
 ENDIF()
 ADD_SUBDIRECTORY(bin)
 ADD_SUBDIRECTORY(examples)
+ADD_SUBDIRECTORY(idl)
 
 # Header configuration
 # ====================
diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4f6a89e
--- /dev/null
@@ -0,0 +1,28 @@
+
+INCLUDE(UseOmniORB)  # Provided by KERNEL
+
+INCLUDE_DIRECTORIES(
+  ${OMNIORB_INCLUDE_DIR}
+  ${KERNEL_INCLUDE_DIRS}
+  ${PROJECT_BINARY_DIR}/idl
+)
+
+SET(SalomeIDLPARAVIS_IDLSOURCES
+  PARAVIS.idl
+  
+)
+
+SET(_idl_include_dirs
+  ${KERNEL_ROOT_DIR}/idl/salome
+  ${MED_ROOT_DIR}/idl/salome
+  
+)
+
+SET(_idl_link_flags
+  ${KERNEL_SalomeIDLKernel}
+  ${MED_SalomeIDLMED}
+  
+)
+
+OMNIORB_ADD_MODULE(SalomeIDLPARAVIS "${SalomeIDLPARAVIS_IDLSOURCES}" "${_idl_include_dirs}" "${_idl_link_flags}")
+INSTALL(TARGETS SalomeIDLPARAVIS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
diff --git a/idl/PARAVIS.idl b/idl/PARAVIS.idl
new file mode 100644 (file)
index 0000000..cc89534
--- /dev/null
@@ -0,0 +1,28 @@
+
+#ifndef _PARAVIS_IDL_
+#define _PARAVIS_IDL_
+
+#include "SALOME_Exception.idl"
+#include "SALOME_Component.idl"
+#include "SALOME_Comm.idl"
+
+
+#include "MEDCouplingCorbaServant.idl"
+#include "SALOME_MPIObject.idl"
+#include "ParaMEDCouplingCorbaServant.idl"
+
+module PARAVIS_ORB
+{
+typedef sequence<string> stringvec;
+typedef sequence<double> dblevec;
+typedef sequence<long> intvec;
+typedef Engines::dataref dataref;
+
+  interface VisualizationComponent: Engines::MPIObject, Engines::EngineComponent
+  {
+    void Visualize(in SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface field,in string path_python_file) raises (SALOME::SALOME_Exception);
+  };
+
+};
+
+#endif
index df256d70e4a6462bd2f15e758cae80238fcc3611..c10b27ef58ee81fea4b8c2cc146e3768c4af3a05 100644 (file)
                 </component-service-list>
             </component-interface-list>
         </component>
+
+        <component>
+              <!-- Component identification -->
+              <component-name>VisualizationComponent</component-name>
+              <component-username>VisualizationComponent</component-username>
+              <component-type>Data</component-type>
+              <component-author>EDF-RD</component-author>
+              <component-version>@SALOMEPARAVIS_VERSION@</component-version>
+              <component-comment></component-comment>
+              <component-multistudy>0</component-multistudy>
+              <component-impltype>SO</component-impltype>
+              <component-implname></component-implname>
+              <component-interface-list>
+                  <component-interface-name>
+                    VisualizationComponent
+                  </component-interface-name>
+                  <component-interface-comment></component-interface-comment>
+                  <component-service-list>
+                      <component-service>
+                          <!-- service-identification -->
+                          <service-name>Visualize</service-name>
+                          <service-author>EDF-RD</service-author>
+                          <service-version>1.0</service-version>
+                          <service-comment></service-comment>
+                          <service-by-default>0</service-by-default>
+                          <!-- service-connexion -->
+                          <inParameter-list>
+                              <inParameter>
+                                <inParameter-name>field</inParameter-name>
+                                <inParameter-type>
+SALOME_MED/ParaMEDCouplingFieldDoubleCorbaInterface
+                                </inParameter-type>
+                            </inParameter>
+                              <inParameter>
+                                <inParameter-name>
+                                  path_python_file
+                                </inParameter-name>
+                                <inParameter-type>string</inParameter-type>
+                            </inParameter>
+                          </inParameter-list>
+                          <outParameter-list>
+
+                          </outParameter-list>
+                          <DataStream-list>
+
+                          </DataStream-list>
+                      </component-service>
+                  </component-service-list>
+              </component-interface-list>
+  </component>
+
     </component-list>
 </begin-catalog>
index 62d1db0642115e20fcc1ba1183e544415bef9c9d..1bc1057f2e308ffe09aac0e6112ef05be8f9db59 100644 (file)
@@ -1,42 +1,3 @@
-
-SET(BUILD_SHARED_LIBS TRUE)
-INCLUDE_DIRECTORIES(
-  ${MEDCOUPLING_INCLUDE_DIRS}
-  ${MPI_INCLUDE_PATH}
-  ${PARAVIS_INCLUDE_DIRS}
-  ${CMAKE_CURRENT_SOURCE_DIR}/../Plugins/MEDReader/IO/
-)
-
-
-SET(_link_LIBRARIES
-  ${MEDCoupling_medcoupling}
-  ${MEDCoupling_interpkernel}
-  ${MPI_LIBRARIES}
-  ${VTK_LIBRARIES}
-  ${PARAVIS_MEDLoaderForPV}
-  #${MEDLoaderForPV}
-  ${MEDCoupling_medloader}
-  ${MEDFILE_C_LIBRARIES}
-  vtkPVCatalyst
-  vtkPVPythonCatalyst
-)
-
-SET(_lib_HEADERS
-  visu.hxx
-)
-
-SET(_lib_SOURCES
-  visu.cxx
-)
-
-ADD_LIBRARY(visulib ${_lib_SOURCES})
-TARGET_LINK_LIBRARIES(visulib ${_link_LIBRARIES} )
-
-INSTALL(TARGETS visulib
-  RUNTIME DESTINATION lib/salome
-  LIBRARY DESTINATION lib/salome
-  ARCHIVE DESTINATION lib/salome
-  )
-INSTALL(FILES ${_lib_HEADERS} DESTINATION include/salome )
-
+ADD_SUBDIRECTORY(VisualizationComponent)
+ADD_SUBDIRECTORY(VisualizationLibrary)
 
diff --git a/src/Insitu/VisualizationComponent/CMakeLists.txt b/src/Insitu/VisualizationComponent/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d3344fa
--- /dev/null
@@ -0,0 +1,67 @@
+
+# --- options ---
+# additional include directories
+INCLUDE_DIRECTORIES(
+  ${KERNEL_INCLUDE_DIRS}
+  ${OMNIORB_INCLUDE_DIR}
+  ${PROJECT_BINARY_DIR}
+  ${PROJECT_BINARY_DIR}/idl
+  ${CMAKE_CURRENT_SOURCE_DIR}/../VisualizationLibrary
+)
+
+# --- definitions ---
+ADD_DEFINITIONS(
+  ${OMNIORB_DEFINITIONS}
+)
+
+# find additional libraries
+FIND_LIBRARY( _userlib_visulib visulib PATH /home/I35256/salome/install/V7_main_git/modules/install/PARAVIS_master/lib/salome)
+#FIND_LIBRARY( _userlib_MEDLoaderForPV MEDLoaderForPV PATH /home/I35256/salome/install/V7_main_git/modules/install/PARAVIS_master/lib/salome)
+
+
+# libraries to link to
+SET(_link_LIBRARIES
+  ${OMNIORB_LIBRARIES}
+  ${KERNEL_SalomeIDLKernel}
+  ${KERNEL_OpUtil}
+  ${KERNEL_SalomeContainer}
+  SalomeIDLPARAVIS
+  ${KERNEL_SalomeMPIContainer}
+  #${_userlib_visulib}
+  #${_userlib_MEDLoaderForPV}
+  ${PARAVIS_MEDLoaderForPV}
+  ${PARAVIS_visulib}
+  ${MED_SalomeIDLMED}
+  ${MED_med}
+  ${MED_medcouplingcorba}
+  ${MED_medcouplingclient}
+
+  ${MED_paramedmemcompo}
+  ${MED_paramedcouplingcorba}  
+)
+
+# --- headers ---
+
+# header files / no moc processing
+
+SET(PARAVIS_HEADERS
+  VisualizationComponent.hxx
+)
+
+# --- sources ---
+
+# sources / static
+SET(PARAVIS_SOURCES
+  VisualizationComponent.cxx
+  
+)
+
+# --- rules ---
+
+ADD_LIBRARY(VisualizationComponentEngine ${PARAVIS_SOURCES})
+TARGET_LINK_LIBRARIES(VisualizationComponentEngine ${_link_LIBRARIES} )
+#SET_TARGET_PROPERTIES( VisualizationComponentEngine PROPERTIES INSTALL_RPATH /home/I35256/salome/install/V7_main_git/modules/install/PARAVIS_master/lib/salome)
+
+INSTALL(TARGETS VisualizationComponentEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+
+INSTALL(FILES ${PARAVIS_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
diff --git a/src/Insitu/VisualizationComponent/VisualizationComponent.cxx b/src/Insitu/VisualizationComponent/VisualizationComponent.cxx
new file mode 100644 (file)
index 0000000..0a9446b
--- /dev/null
@@ -0,0 +1,261 @@
+
+#include "VisualizationComponent.hxx"
+#include <string>
+#include <unistd.h>
+#include <signal.h>
+#include <SALOME_NamingService.hxx>
+#include <Utils_SALOME_Exception.hxx>
+#include "Utils_CorbaException.hxx"
+#include <pthread.h>
+#include <execinfo.h>
+
+typedef struct
+{
+  bool exception;
+  std::string msg;
+} exception_st;
+
+//DEFS
+
+#include "visu.hxx"
+#include "MEDCouplingFieldDoubleClient.hxx"
+#include "ParaMEDCouplingFieldDoubleServant.hxx"
+#include "omniORB4/poa.h"
+
+//ENDDEF
+
+
+using namespace std;
+
+//! Constructor for component "VisualizationComponent" instance
+/*!
+ *
+ */
+VisualizationComponent_i::VisualizationComponent_i(CORBA::ORB_ptr orb,
+                     PortableServer::POA_ptr poa,
+                     PortableServer::ObjectId * contId,
+                     const char *instanceName,
+                     const char *interfaceName,
+                     bool regist)
+          : Engines_Component_i(orb, poa, contId, instanceName, interfaceName,
+                                false, regist)
+{
+  _thisObj = this ;
+  _id = _poa->activate_object(_thisObj);
+}
+
+VisualizationComponent_i::VisualizationComponent_i(CORBA::ORB_ptr orb,
+                     PortableServer::POA_ptr poa,
+                     Engines::Container_ptr container,
+                     const char *instanceName,
+                     const char *interfaceName,
+                     bool regist)
+          : Engines_Component_i(orb, poa, container, instanceName, interfaceName,
+                                false, regist)
+{
+  _thisObj = this ;
+  _id = _poa->activate_object(_thisObj);
+}
+
+//! Destructor for component "VisualizationComponent" instance
+VisualizationComponent_i::~VisualizationComponent_i()
+{
+}
+
+
+void * th_Visualize(void * s)
+{
+  std::ostringstream msg;
+  exception_st *est = new exception_st;
+  est->exception = false;
+  
+  thread_Visualize_struct *st = (thread_Visualize_struct *)s;
+  
+  try
+  {
+    
+    PARAVIS_ORB::VisualizationComponent_var compo = PARAVIS_ORB::VisualizationComponent::_narrow((*(st->tior))[st->ip]);
+    compo->Visualize(st->field,st->path_python_file);
+  }
+  catch(const SALOME::SALOME_Exception &ex)
+  {
+    est->exception = true;
+    est->msg = ex.details.text;
+  }
+  catch(const CORBA::Exception &ex)
+  {
+    est->exception = true;
+    msg << "CORBA::Exception: " << ex;
+    est->msg = msg.str();
+  }
+  
+  delete st;
+  return ((void*)est);
+}
+
+void VisualizationComponent_i::Visualize(SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_ptr field,const char* path_python_file)
+{
+  beginService("VisualizationComponent_i::Visualize");
+  void *ret_th;
+  pthread_t *th;
+  exception_st *est;
+
+  try
+    {
+      // Run the service in every MPI process
+      if(_numproc == 0)
+      {
+        th = new pthread_t[_nbproc];
+        for(int ip=1;ip<_nbproc;ip++)
+        {
+            thread_Visualize_struct *st = new thread_Visualize_struct;
+            st->ip = ip;
+            st->tior = _tior;
+            st->field = field;
+st->path_python_file = path_python_file;
+            pthread_create(&(th[ip]),NULL,th_Visualize,(void*)st);
+        }
+      }
+      
+//BODY
+
+const MEDCoupling::MEDCouplingFieldDouble * local_field(NULL);
+int nb_fields = field->tior()->length();
+if(nb_fields == _nbproc)
+{
+  SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_ptr local_corba_field = 
+               SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface::_narrow((*(field->tior()))[_numproc]);
+
+
+  PortableServer::ServantBase *ret;
+  try {
+    ret=PortableServer::POA::_the_root_poa()->reference_to_servant(local_corba_field);
+    std::cerr << "Servant succeeded!" << std::endl;
+    MEDCoupling::ParaMEDCouplingFieldDoubleServant* servant_field = 
+               dynamic_cast<MEDCoupling::ParaMEDCouplingFieldDoubleServant*>(ret);
+    if(servant_field != NULL)
+    {
+      std::cerr << "In-situ configuration!" << std::endl;
+      // same container, same mpi proc, use the pointer directly.
+      local_field = servant_field->getPointer();
+      ret->_remove_ref();
+    }
+  }
+  catch(...){
+    // different container - need to make a copy of the field.
+    ret = NULL;
+    std::cerr << "Co-processing configuration!" << std::endl;
+    local_field = MEDCoupling::MEDCouplingFieldDoubleClient::New(local_corba_field);
+  }
+}
+else if(nb_fields < _nbproc)
+{
+  if(_numproc < nb_fields)
+  {
+    SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_ptr local_corba_field = 
+               SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface::_narrow((*(field->tior()))[_numproc]);
+    local_field = MEDCoupling::MEDCouplingFieldDoubleClient::New(local_corba_field);
+  }
+}
+else //nb_fields > _nbproc
+{
+  int q = nb_fields / _nbproc; // int division
+  int r = nb_fields - q * _nbproc;
+  int start, end;
+  
+  if(_numproc < r)
+  {
+    // get one more field to process
+    start = _numproc * (q + 1);
+    end = start + q + 1;
+  }
+  else
+  {
+    start = r * (q + 1) + (_numproc - r) * q;
+    end = start + q;
+  }
+  
+  std::cerr << "Proc n° " << _numproc << ". Merge fields from " << start << " to " << end << std::endl;
+  
+  std::vector<const MEDCoupling::MEDCouplingFieldDouble *> fieldsToProcess;
+  for(int i = start; i < end; i++)
+  {
+    SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_ptr local_corba_field = 
+               SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface::_narrow((*(field->tior()))[i]);
+    fieldsToProcess.push_back(MEDCoupling::MEDCouplingFieldDoubleClient::New(local_corba_field));
+  }
+  
+  local_field = MEDCoupling::MEDCouplingFieldDouble::MergeFields(fieldsToProcess);
+}
+
+Visualization v;
+v.run(const_cast<MEDCoupling::MEDCouplingFieldDouble*>(local_field), path_python_file);
+
+//ENDBODY
+      if(_numproc == 0)
+      {
+        for(int ip=1;ip<_nbproc;ip++)
+        {
+          pthread_join(th[ip],&ret_th);
+          est = (exception_st*)ret_th;
+          if(est->exception)
+          {
+              std::ostringstream msg;
+              msg << "[" << ip << "] " << est->msg;
+              delete est;
+              delete[] th;
+              THROW_SALOME_CORBA_EXCEPTION(msg.str().c_str(),SALOME::INTERNAL_ERROR);
+          }
+          delete est;
+        }
+        delete[] th;
+      }
+    }
+  catch ( const SALOME_Exception & ex)
+    {
+      THROW_SALOME_CORBA_EXCEPTION(CORBA::string_dup(ex.what()), SALOME::INTERNAL_ERROR);
+    }
+  catch ( const SALOME::SALOME_Exception & ex)
+    {
+      throw;
+    }
+  catch ( const std::exception& ex)
+    {
+      THROW_SALOME_CORBA_EXCEPTION(CORBA::string_dup(ex.what()), SALOME::INTERNAL_ERROR);
+    }
+  catch (...)
+    {
+      THROW_SALOME_CORBA_EXCEPTION("unknown exception", SALOME::INTERNAL_ERROR);
+    }
+  endService("VisualizationComponent_i::Visualize");
+}
+
+
+
+extern "C"
+{
+  PortableServer::ObjectId * VisualizationComponentEngine_factory( CORBA::ORB_ptr orb,
+                                                    PortableServer::POA_ptr poa,
+                                                    PortableServer::ObjectId * contId,
+                                                    const char *instanceName,
+                                                    const char *interfaceName)
+  {
+    MESSAGE("PortableServer::ObjectId * VisualizationComponentEngine_factory()");
+    int is_mpi_container;
+    bool regist;
+    int numproc;
+    
+    MPI_Initialized(&is_mpi_container);
+    if (!is_mpi_container)
+    {
+      int argc = 0;
+      char ** argv = NULL;
+      MPI_Init(&argc, &argv);
+    }
+    
+    MPI_Comm_rank( MPI_COMM_WORLD, &numproc );
+    regist = ( numproc == 0 );
+    VisualizationComponent_i * myEngine = new VisualizationComponent_i(orb, poa, contId, instanceName, interfaceName, regist);
+    return myEngine->getId() ;
+  }
+}
diff --git a/src/Insitu/VisualizationComponent/VisualizationComponent.hxx b/src/Insitu/VisualizationComponent/VisualizationComponent.hxx
new file mode 100644 (file)
index 0000000..d3b65d8
--- /dev/null
@@ -0,0 +1,51 @@
+
+#ifndef _VisualizationComponent_HXX_
+#define _VisualizationComponent_HXX_
+
+#include <SALOME_Component.hh>
+#include "Superv_Component_i.hxx"
+#include "PARAVIS.hh"
+#include "MPIObject_i.hxx"
+
+//COMPODEFS
+
+
+void * th_Visualize(void * s);
+typedef struct {
+  int ip; // mpi process id
+  Engines::IORTab* tior;
+  SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_ptr field;
+const char* path_python_file;
+} thread_Visualize_struct;
+
+
+//ENDDEF
+
+class VisualizationComponent_i: public virtual POA_PARAVIS_ORB::VisualizationComponent,
+                      
+                      public virtual MPIObject_i,
+                      public virtual Engines_Component_i
+{
+  public:
+    VisualizationComponent_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa,
+              PortableServer::ObjectId * contId,
+              const char *instanceName, const char *interfaceName,
+              bool regist = true);
+    VisualizationComponent_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa,
+              Engines::Container_ptr container,
+              const char *instanceName, const char *interfaceName,
+              bool regist = true);
+    virtual ~VisualizationComponent_i();
+    void Visualize(SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_ptr field,const char* path_python_file);
+};
+
+extern "C"
+{
+    PortableServer::ObjectId * VisualizationComponentEngine_factory( CORBA::ORB_ptr orb,
+                                                      PortableServer::POA_ptr poa,
+                                                      PortableServer::ObjectId * contId,
+                                                      const char *instanceName,
+                                                      const char *interfaceName);
+}
+#endif
+
diff --git a/src/Insitu/VisualizationLibrary/CMakeLists.txt b/src/Insitu/VisualizationLibrary/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5ff0309
--- /dev/null
@@ -0,0 +1,42 @@
+
+SET(BUILD_SHARED_LIBS TRUE)
+INCLUDE_DIRECTORIES(
+  ${MEDCOUPLING_INCLUDE_DIRS}
+  ${MPI_INCLUDE_PATH}
+  ${PARAVIS_INCLUDE_DIRS}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../Plugins/MEDReader/IO/
+)
+
+
+SET(_link_LIBRARIES
+  ${MEDCoupling_medcoupling}
+  ${MEDCoupling_interpkernel}
+  ${MPI_LIBRARIES}
+  ${VTK_LIBRARIES}
+  ${PARAVIS_MEDLoaderForPV}
+  #${MEDLoaderForPV}
+  ${MEDCoupling_medloader}
+  ${MEDFILE_C_LIBRARIES}
+  vtkPVCatalyst
+  vtkPVPythonCatalyst
+)
+
+SET(_lib_HEADERS
+  visu.hxx
+)
+
+SET(_lib_SOURCES
+  visu.cxx
+)
+
+ADD_LIBRARY(visulib ${_lib_SOURCES})
+TARGET_LINK_LIBRARIES(visulib ${_link_LIBRARIES} )
+
+INSTALL(TARGETS visulib
+  RUNTIME DESTINATION lib/salome
+  LIBRARY DESTINATION lib/salome
+  ARCHIVE DESTINATION lib/salome
+  )
+INSTALL(FILES ${_lib_HEADERS} DESTINATION include/salome )
+
+
diff --git a/src/Insitu/VisualizationLibrary/visu.cxx b/src/Insitu/VisualizationLibrary/visu.cxx
new file mode 100755 (executable)
index 0000000..282ac20
--- /dev/null
@@ -0,0 +1,158 @@
+#include "visu.hxx"
+#include "MEDFileField.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingCurveLinearMesh.hxx"
+#include "MEDFileMesh.hxx"
+#include "MEDFileFieldRepresentationTree.hxx"
+#include <iostream>
+#include "mpi.h" 
+
+#include <vtkCPDataDescription.h>
+#include <vtkCPInputDataDescription.h>
+#include <vtkCPPythonScriptPipeline.h>
+#include <vtkCPProcessor.h>
+#include "vtkDataSet.h"
+#include "vtkCellData.h"
+
+#include <vtkSmartPointer.h>
+#include <vtkXMLUnstructuredGridWriter.h>
+#include <vtkUnstructuredGrid.h>
+
+using namespace MEDCoupling;
+
+
+void Visualization::CatalystInitialize(const std::string& script)
+{
+
+  if(Processor == NULL)
+    {
+    Processor = vtkCPProcessor::New();
+    Processor->Initialize();
+    }
+  else
+    {
+    Processor->RemoveAllPipelines();
+    }
+  // Add in the Python script
+  vtkCPPythonScriptPipeline* pipeline = vtkCPPythonScriptPipeline::New();
+  char *c = const_cast<char*>(script.c_str());
+  pipeline->Initialize(c);
+  Processor->AddPipeline(pipeline);
+  pipeline->Delete();
+  return;
+}
+
+void Visualization::CatalystFinalize()
+{
+  if(Processor)
+    {
+    Processor->Delete();
+    Processor = NULL;
+    }
+
+  return;
+}
+
+void Visualization::CatalystCoProcess(vtkDataSet *VTKGrid, double time,
+                                      unsigned int timeStep)
+{
+  vtkCPDataDescription* dataDescription = vtkCPDataDescription::New();
+  // specify the simulation time and time step for Catalyst
+  dataDescription->AddInput("input");
+  dataDescription->SetTimeData(time, timeStep);
+
+  if(Processor->RequestDataDescription(dataDescription) != 0)
+    {
+    // Make a map from input to our VTK grid so that
+    // Catalyst gets the proper input dataset for the pipeline.
+    dataDescription->GetInputDescriptionByName("input")->SetGrid(VTKGrid);
+    // Call Catalyst to execute the desired pipelines.
+    Processor->CoProcess(dataDescription);
+    }
+  dataDescription->Delete();
+}
+
+void Visualization::ConvertToVTK(MEDCoupling::MEDCouplingFieldDouble* field, vtkDataSet *&VTKGrid)
+//vtkDataSet * Visualization::ConvertToVTK(MEDCoupling::MEDCouplingFieldDouble* field)
+{
+  MEDCoupling::MEDCouplingFieldDouble *f = field;
+  MEDCoupling::MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New());
+  ff->setFieldNoProfileSBT(f);
+  MCAuto<MEDFileFieldMultiTS> fmts(MEDFileFieldMultiTS::New());
+  fmts->pushBackTimeStep(ff);
+  MCAuto<MEDFileFields> fs(MEDFileFields::New());
+  fs->pushField(fmts);
+  
+  MEDCouplingMesh *m(f->getMesh());
+  MCAuto<MEDFileMesh> mm;
+  if(dynamic_cast<MEDCouplingUMesh *>(m))
+    {
+      MCAuto<MEDFileUMesh> mmu(MEDFileUMesh::New()); 
+      mmu->setMeshAtLevel(0,dynamic_cast<MEDCouplingUMesh *>(m));
+      mmu->forceComputationOfParts();
+      mm=DynamicCast<MEDFileUMesh,MEDFileMesh>(mmu);
+    }
+  else if(dynamic_cast<MEDCouplingCMesh *>(m))
+    {
+      MCAuto<MEDFileCMesh> mmc(MEDFileCMesh::New()); 
+      mmc->setMesh(dynamic_cast<MEDCouplingCMesh *>(m));
+      mm=DynamicCast<MEDFileCMesh,MEDFileMesh>(mmc);
+    }
+  else if(dynamic_cast<MEDCouplingCurveLinearMesh *>(m))
+    {
+      // MCAuto<MEDFileCLMesh> mmc(MEDFileCLMesh::New()); 
+      MCAuto<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New()); 
+      mmc->setMesh(dynamic_cast<MEDCouplingCurveLinearMesh *>(m));
+      //mm=DynamicCast<MEDCouplingCurveLinearMesh,MEDFileMesh>(mmc);
+      mm=0;
+    }
+  else
+    {
+    throw ;
+    }
+  MCAuto<MEDFileMeshes> ms(MEDFileMeshes::New());
+  ms->pushMesh(mm);
+  ms->getMeshesNames();
+  //
+  int proc_id;
+  MPI_Comm_rank(MPI_COMM_WORLD,&proc_id);
+  //
+  MEDFileFieldRepresentationTree Tree;
+  Tree.loadInMemory(fs,ms);
+  
+  Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(0,true);
+  Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(1,false);
+  Tree.activateTheFirst();//"TS0/Fluid domain/ComSup0/TempC@@][@@P0"
+  std::string meshName;
+  TimeKeeper TK(0);
+  int tmp1,tmp2;
+  double tmp3(f->getTime(tmp1,tmp2));
+  vtkDataSet *ret(Tree.buildVTKInstance(false,tmp3,meshName,TK));
+  VTKGrid = ret;
+}
+
+Visualization::Visualization()
+{
+Processor = NULL;
+}
+
+
+// ajouter en parametre le fichier python qui contient le pipeline
+// enlever le const s'il gene
+void Visualization::run(MEDCoupling::MEDCouplingFieldDouble* field, const std::string& pathPipeline)
+{
+  int proc_id;
+  MPI_Comm_rank(MPI_COMM_WORLD,&proc_id);
+
+  vtkDataSet *VTKGrid = 0;
+  ConvertToVTK(field, VTKGrid);
+
+  const char *fileName = pathPipeline.c_str();
+  CatalystInitialize(fileName);
+  CatalystCoProcess(VTKGrid, 0.0, 0);
+  CatalystFinalize();
+  
+  return ;
+}
+
diff --git a/src/Insitu/VisualizationLibrary/visu.hxx b/src/Insitu/VisualizationLibrary/visu.hxx
new file mode 100755 (executable)
index 0000000..30d408e
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef _VISU_HXX_
+#define _VISU_HXX_
+
+#include <string>
+#include "MEDCouplingFieldDouble.hxx"
+
+namespace MEDCoupling
+{
+  class MEDCouplingFieldDouble;
+}
+
+class vtkCPProcessor;
+class vtkDataSet;
+
+class Visualization
+{
+  vtkCPProcessor* Processor;
+
+  //private :
+  public :
+    void CatalystInitialize(const std::string& pipeline);
+    void CatalystFinalize();
+    void CatalystCoProcess(vtkDataSet *VTKGrid, double time, unsigned int timeStep);
+    void ConvertToVTK(MEDCoupling::MEDCouplingFieldDouble* field, vtkDataSet *&VTKGrid);
+  public :
+    Visualization();
+    void run(MEDCoupling::MEDCouplingFieldDouble*, const std::string& pathPipeline);
+};
+
+#endif //_VISU_HXX_
diff --git a/src/Insitu/visu.cxx b/src/Insitu/visu.cxx
deleted file mode 100755 (executable)
index 9c85828..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-#include "visu.hxx"
-#include "MEDFileField.hxx"
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingCMesh.hxx"
-#include "MEDCouplingCurveLinearMesh.hxx"
-#include "MEDFileMesh.hxx"
-#include "MEDFileFieldRepresentationTree.hxx"
-#include <iostream>
-#include "mpi.h" 
-
-#include <vtkCPDataDescription.h>
-#include <vtkCPInputDataDescription.h>
-#include <vtkCPPythonScriptPipeline.h>
-#include <vtkCPProcessor.h>
-#include "vtkDataSet.h"
-#include "vtkCellData.h"
-
-#include <vtkSmartPointer.h>
-#include <vtkXMLUnstructuredGridWriter.h>
-#include <vtkUnstructuredGrid.h>
-
-using namespace MEDCoupling;
-
-
-void Visualization::CatalystInitialize(const std::string& script)
-{
-
-  if(Processor == NULL)
-    {
-    Processor = vtkCPProcessor::New();
-    Processor->Initialize();
-    }
-  else
-    {
-    Processor->RemoveAllPipelines();
-    }
-  // Add in the Python script
-  vtkCPPythonScriptPipeline* pipeline = vtkCPPythonScriptPipeline::New();
-  char *c = const_cast<char*>(script.c_str());
-  pipeline->Initialize(c);
-  Processor->AddPipeline(pipeline);
-  pipeline->Delete();
-  return;
-}
-
-void Visualization::CatalystFinalize()
-{
-  if(Processor)
-    {
-    Processor->Delete();
-    Processor = NULL;
-    }
-
-  return;
-}
-
-void Visualization::CatalystCoProcess(vtkDataSet *VTKGrid, double time,
-                                      unsigned int timeStep)
-{
-  vtkCPDataDescription* dataDescription = vtkCPDataDescription::New();
-  // specify the simulation time and time step for Catalyst
-  dataDescription->AddInput("input");
-  dataDescription->SetTimeData(time, timeStep);
-
-  if(Processor->RequestDataDescription(dataDescription) != 0)
-    {
-    // Make a map from input to our VTK grid so that
-    // Catalyst gets the proper input dataset for the pipeline.
-    dataDescription->GetInputDescriptionByName("input")->SetGrid(VTKGrid);
-    // Call Catalyst to execute the desired pipelines.
-    Processor->CoProcess(dataDescription);
-    }
-  dataDescription->Delete();
-}
-
-void Visualization::ConvertToVTK(MEDCoupling::MEDCouplingFieldDouble* field, vtkDataSet *&VTKGrid)
-//vtkDataSet * Visualization::ConvertToVTK(MEDCoupling::MEDCouplingFieldDouble* field)
-{
-  MEDCoupling::MEDCouplingFieldDouble *f = field;
-  MEDCoupling::MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New());
-  ff->setFieldNoProfileSBT(f);
-  MCAuto<MEDFileFieldMultiTS> fmts(MEDFileFieldMultiTS::New());
-  fmts->pushBackTimeStep(ff);
-  MCAuto<MEDFileFields> fs(MEDFileFields::New());
-  fs->pushField(fmts);
-  
-  MEDCouplingMesh *m(f->getMesh());
-  MCAuto<MEDFileMesh> mm;
-  if(dynamic_cast<MEDCouplingUMesh *>(m))
-    {
-      MCAuto<MEDFileUMesh> mmu(MEDFileUMesh::New()); 
-      mmu->setMeshAtLevel(0,dynamic_cast<MEDCouplingUMesh *>(m));
-      mmu->forceComputationOfParts();
-      mm=DynamicCast<MEDFileUMesh,MEDFileMesh>(mmu);
-    }
-  else if(dynamic_cast<MEDCouplingCMesh *>(m))
-    {
-      MCAuto<MEDFileCMesh> mmc(MEDFileCMesh::New()); 
-      mmc->setMesh(dynamic_cast<MEDCouplingCMesh *>(m));
-      mm=DynamicCast<MEDFileCMesh,MEDFileMesh>(mmc);
-    }
-  else if(dynamic_cast<MEDCouplingCurveLinearMesh *>(m))
-    {
-      // MCAuto<MEDFileCLMesh> mmc(MEDFileCLMesh::New()); 
-      MCAuto<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New()); 
-      mmc->setMesh(dynamic_cast<MEDCouplingCurveLinearMesh *>(m));
-      //mm=DynamicCast<MEDCouplingCurveLinearMesh,MEDFileMesh>(mmc);
-      mm=0;
-    }
-  else
-    {
-    throw ;
-    }
-  MCAuto<MEDFileMeshes> ms(MEDFileMeshes::New());
-  ms->pushMesh(mm);
-  ms->getMeshesNames();
-  //
-  int proc_id;
-  MPI_Comm_rank(MPI_COMM_WORLD,&proc_id);
-  //
-  MEDFileFieldRepresentationTree Tree;
-  Tree.loadInMemory(fs,ms);
-  
-  Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(0,true);
-  Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(1,false);
-  Tree.activateTheFirst();//"TS0/Fluid domain/ComSup0/TempC@@][@@P0"
-  std::string meshName;
-  TimeKeeper TK(0);
-  int tmp1,tmp2;
-  double tmp3(f->getTime(tmp1,tmp2));
-  vtkDataSet *ret(Tree.buildVTKInstance(false,tmp3,meshName,TK));
-  VTKGrid = ret;
-}
-
-Visualization::Visualization()
-{
-Processor = NULL;
-}
-
-
-// ajouter en parametre le fichier python qui contient le pipeline
-// enlever le const s'il gene
-void Visualization::run(MEDCoupling::MEDCouplingFieldDouble* field, const std::string& pathPipeline)
-{
-  int proc_id;
-  MPI_Comm_rank(MPI_COMM_WORLD,&proc_id);
-
-  if( field == NULL)
-  {
-    std::cerr << "Description n° " << proc_id << ": NULL pointer" << std::endl;
-  }
-  std::cerr << "Description n° " << proc_id << ":"
-            << field->getDescription() << std::endl;
-
-
-  vtkDataSet *VTKGrid = 0;
-  ConvertToVTK(field, VTKGrid);
-
-  const char *fileName = pathPipeline.c_str();
-  CatalystInitialize(fileName);
-  CatalystCoProcess(VTKGrid, 0.0, 0);
-  CatalystFinalize();
-  
-  return ;
-}
-
diff --git a/src/Insitu/visu.hxx b/src/Insitu/visu.hxx
deleted file mode 100755 (executable)
index 30d408e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef _VISU_HXX_
-#define _VISU_HXX_
-
-#include <string>
-#include "MEDCouplingFieldDouble.hxx"
-
-namespace MEDCoupling
-{
-  class MEDCouplingFieldDouble;
-}
-
-class vtkCPProcessor;
-class vtkDataSet;
-
-class Visualization
-{
-  vtkCPProcessor* Processor;
-
-  //private :
-  public :
-    void CatalystInitialize(const std::string& pipeline);
-    void CatalystFinalize();
-    void CatalystCoProcess(vtkDataSet *VTKGrid, double time, unsigned int timeStep);
-    void ConvertToVTK(MEDCoupling::MEDCouplingFieldDouble* field, vtkDataSet *&VTKGrid);
-  public :
-    Visualization();
-    void run(MEDCoupling::MEDCouplingFieldDouble*, const std::string& pathPipeline);
-};
-
-#endif //_VISU_HXX_