Salome HOME
Modif for salome gui without neither NS nor other servers.
[modules/smesh.git] / src / SMESHClient / SMESH_Client.cxx
index 8526c066867c48e97b3580640c790a8bb11dd845..66d071a07614ca97a4f69e2d2a655bb1930979ea 100644 (file)
@@ -28,6 +28,7 @@
 #include "SMESHDS_Mesh.hxx"
 #include "SMESHDS_Script.hxx"
 #include "SMESH_Mesh.hxx"
+#include "SMESH_Component_Generator.hxx"
 
 #include "SALOME_NamingService.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
@@ -745,34 +746,34 @@ namespace
   //=======================================================================
   //function : ChangePolyhedronNodes
   //=======================================================================
-  inline void ChangePolyhedronNodes (SMDS_Mesh* /*theMesh*/,
-                                     SMESH::log_array_var& /*theSeq*/,
-                                     CORBA::Long /*theId*/)
+  inline void ChangePolyhedronNodes (SMDS_Mesh*            theMesh,
+                                     SMESH::log_array_var& theSeq,
+                                     CORBA::Long           theId)
   {
-    // const SMESH::long_array& anIndexes = theSeq[theId].indexes;
-    // CORBA::Long iind = 0, aNbElems = theSeq[theId].number;
-
-    // for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++)
-    // {
-    //   // find element
-    //   const SMDS_MeshElement* elem = FindElement(theMesh, anIndexes[iind++]);
-    //   // nb nodes
-    //   int nbNodes = anIndexes[iind++];
-    //   // nodes
-    //   std::vector<const SMDS_MeshNode*> aNodes (nbNodes);
-    //   for (int iNode = 0; iNode < nbNodes; iNode++) {
-    //     aNodes[iNode] = FindNode(theMesh, anIndexes[iind++]);
-    //   }
-    //   // nb faces
-    //   int nbFaces = anIndexes[iind++];
-    //   // quantities
-    //   std::vector<int> quantities (nbFaces);
-    //   for (int iFace = 0; iFace < nbFaces; iFace++) {
-    //     quantities[iFace] = anIndexes[iind++];
-    //   }
-    //   // change
-    //   theMesh->ChangePolyhedronNodes(elem, aNodes, quantities);
-    // }
+    const SMESH::long_array& anIndexes = theSeq[theId].indexes;
+    CORBA::Long iind = 0, aNbElems = theSeq[theId].number;
+
+    for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++)
+    {
+      // find element
+      const SMDS_MeshElement* elem = FindElement(theMesh, anIndexes[iind++]);
+      // nb nodes
+      int nbNodes = anIndexes[iind++];
+      // nodes
+      std::vector<const SMDS_MeshNode*> aNodes (nbNodes);
+      for (int iNode = 0; iNode < nbNodes; iNode++) {
+        aNodes[iNode] = FindNode(theMesh, anIndexes[iind++]);
+      }
+      // nb faces
+      int nbFaces = anIndexes[iind++];
+      // quantities
+      std::vector<int> quantities (nbFaces);
+      for (int iFace = 0; iFace < nbFaces; iFace++) {
+        quantities[iFace] = anIndexes[iind++];
+      }
+      // change
+      theMesh->ChangePolyhedronNodes(elem, aNodes, quantities);
+    }
   }
 }
 
@@ -783,26 +784,35 @@ SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB,
 {
   static SMESH::SMESH_Gen_var aMeshGen;
 
-  if(CORBA::is_nil(aMeshGen.in())){
+  if(CORBA::is_nil(aMeshGen.in()))
+  {
+    Engines::EngineComponent_var isCompoInSSLMode = GetSMESHInstanceHasThis();
+    if( CORBA::is_nil(isCompoInSSLMode) )
+    {
 #ifdef WIN32
-    long aClientPID = (long)_getpid();
+      long aClientPID = (long)_getpid();
 #else
-    long aClientPID =  (long)getpid();
+      long aClientPID =  (long)getpid();
 #endif
 
-    SALOME_NamingService aNamingService(theORB);
-    SALOME_LifeCycleCORBA aLifeCycleCORBA(&aNamingService);
-    Engines::EngineComponent_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH");
-    aMeshGen = SMESH::SMESH_Gen::_narrow(aComponent);
+      SALOME_NamingService aNamingService(theORB);
+      SALOME_LifeCycleCORBA aLifeCycleCORBA(&aNamingService);
+      Engines::EngineComponent_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH");
+      aMeshGen = SMESH::SMESH_Gen::_narrow(aComponent);
 
-    std::string aClientHostName = Kernel_Utils::GetHostname();
-    Engines::Container_var aServerContainer = aMeshGen->GetContainerRef();
-    CORBA::String_var aServerHostName = aServerContainer->getHostName();
-    CORBA::Long aServerPID = aServerContainer->getPID();
-    aMeshGen->SetEmbeddedMode((aClientPID == aServerPID) && (aClientHostName == aServerHostName.in()));
+      std::string aClientHostName = Kernel_Utils::GetHostname();
+      Engines::Container_var aServerContainer = aMeshGen->GetContainerRef();
+      CORBA::String_var aServerHostName = aServerContainer->getHostName();
+      CORBA::Long aServerPID = aServerContainer->getPID();
+      aMeshGen->SetEmbeddedMode((aClientPID == aServerPID) && (aClientHostName == aServerHostName.in()));
+    }
+    else
+    {
+      aMeshGen = SMESH::SMESH_Gen::_narrow(isCompoInSSLMode);
+    }
+    
   }
   theIsEmbeddedMode = aMeshGen->IsEmbeddedMode();
-
   return aMeshGen;
 }