Salome HOME
remove commented code
[modules/smesh.git] / src / SMESHClient / SMESH_Client.cxx
index a1374e47f2dd798eacd5afddc1a1f8347b02af8c..64fe283ef8b3000d548c952c69657d4c8cf7a369 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -23,7 +23,7 @@
 //  File   : SMESH_Client.cxx
 //  Author : Pavel TELKOV
 //  Module : SMESH
-//
+
 #include "SMESH_Client.hxx"
 #include "SMESH_Mesh.hxx"
 
@@ -54,7 +54,7 @@
 #endif
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
@@ -83,7 +83,7 @@ namespace
   //=======================================================================
   //function : AddNodesWithID
   //=======================================================================
-  inline void AddNodesWithID(SMDS_Mesh* theMesh, 
+  inline void AddNodesWithID(SMDS_Mesh* theMesh,
                              SMESH::log_array_var& theSeq,
                              CORBA::Long theId)
   {
@@ -106,7 +106,7 @@ namespace
   //=======================================================================
   //function : Add0DElementsWithID
   //=======================================================================
-  inline void Add0DElementsWithID(SMDS_Mesh* theMesh, 
+  inline void Add0DElementsWithID(SMDS_Mesh* theMesh,
                                   SMESH::log_array_var& theSeq,
                                   CORBA::Long theId)
   {
@@ -128,7 +128,7 @@ namespace
   //=======================================================================
   //function : AddEdgesWithID
   //=======================================================================
-  inline void AddEdgesWithID(SMDS_Mesh* theMesh, 
+  inline void AddEdgesWithID(SMDS_Mesh* theMesh,
                              SMESH::log_array_var& theSeq,
                              CORBA::Long theId)
   {
@@ -149,7 +149,7 @@ namespace
   //=======================================================================
   //function : AddTriasWithID
   //=======================================================================
-  inline void AddTriasWithID(SMDS_Mesh* theMesh, 
+  inline void AddTriasWithID(SMDS_Mesh* theMesh,
                              SMESH::log_array_var& theSeq,
                              CORBA::Long theId)
   {
@@ -171,7 +171,7 @@ namespace
   //=======================================================================
   //function : AddQuadsWithID
   //=======================================================================
-  inline void AddQuadsWithID(SMDS_Mesh* theMesh, 
+  inline void AddQuadsWithID(SMDS_Mesh* theMesh,
                              SMESH::log_array_var theSeq,
                              CORBA::Long theId)
   {
@@ -194,7 +194,7 @@ namespace
   //=======================================================================
   //function : AddPolygonsWithID
   //=======================================================================
-  inline void AddPolygonsWithID(SMDS_Mesh* theMesh, 
+  inline void AddPolygonsWithID(SMDS_Mesh* theMesh,
                                 SMESH::log_array_var& theSeq,
                                 CORBA::Long theId)
   {
@@ -221,7 +221,7 @@ namespace
   //=======================================================================
   //function : AddTetrasWithID
   //=======================================================================
-  inline void AddTetrasWithID(SMDS_Mesh* theMesh, 
+  inline void AddTetrasWithID(SMDS_Mesh* theMesh,
                               SMESH::log_array_var& theSeq,
                               CORBA::Long theId)
   {
@@ -244,7 +244,7 @@ namespace
   //=======================================================================
   //function : AddPiramidsWithID
   //=======================================================================
-  inline void AddPiramidsWithID(SMDS_Mesh* theMesh, 
+  inline void AddPiramidsWithID(SMDS_Mesh* theMesh,
                                 SMESH::log_array_var& theSeq,
                                 CORBA::Long theId)
   {
@@ -268,7 +268,7 @@ namespace
   //=======================================================================
   //function : AddPrismsWithID
   //=======================================================================
-  inline void AddPrismsWithID(SMDS_Mesh* theMesh, 
+  inline void AddPrismsWithID(SMDS_Mesh* theMesh,
                               SMESH::log_array_var& theSeq,
                               CORBA::Long theId)
   {
@@ -293,7 +293,7 @@ namespace
   //=======================================================================
   //function : AddHexasWithID
   //=======================================================================
-  inline void AddHexasWithID(SMDS_Mesh* theMesh, 
+  inline void AddHexasWithID(SMDS_Mesh* theMesh,
                              SMESH::log_array_var& theSeq,
                              CORBA::Long theId)
   {
@@ -320,7 +320,7 @@ namespace
   //=======================================================================
   //function : AddPolyhedronsWithID
   //=======================================================================
-  inline void AddPolyhedronsWithID (SMDS_Mesh* theMesh, 
+  inline void AddPolyhedronsWithID (SMDS_Mesh* theMesh,
                                     SMESH::log_array_var& theSeq,
                                     CORBA::Long theId)
   {
@@ -354,7 +354,7 @@ namespace
   //=======================================================================
   //function : AddQuadEdgesWithID
   //=======================================================================
-  inline void AddQuadEdgesWithID(SMDS_Mesh* theMesh, 
+  inline void AddQuadEdgesWithID(SMDS_Mesh* theMesh,
                                  SMESH::log_array_var& theSeq,
                                  CORBA::Long theId)
   {
@@ -376,7 +376,7 @@ namespace
   //=======================================================================
   //function : AddQuadTriasWithID
   //=======================================================================
-  inline void AddQuadTriasWithID(SMDS_Mesh* theMesh, 
+  inline void AddQuadTriasWithID(SMDS_Mesh* theMesh,
                                  SMESH::log_array_var& theSeq,
                                  CORBA::Long theId)
   {
@@ -401,7 +401,7 @@ namespace
   //=======================================================================
   //function : AddQuadQuadsWithID
   //=======================================================================
-  inline void AddQuadQuadsWithID(SMDS_Mesh* theMesh, 
+  inline void AddQuadQuadsWithID(SMDS_Mesh* theMesh,
                                  SMESH::log_array_var theSeq,
                                  CORBA::Long theId)
   {
@@ -428,7 +428,7 @@ namespace
   //=======================================================================
   //function : AddQuadTetrasWithID
   //=======================================================================
-  inline void AddQuadTetrasWithID(SMDS_Mesh* theMesh, 
+  inline void AddQuadTetrasWithID(SMDS_Mesh* theMesh,
                                   SMESH::log_array_var& theSeq,
                                   CORBA::Long theId)
   {
@@ -457,7 +457,7 @@ namespace
   //=======================================================================
   //function : AddQuadPiramidsWithID
   //=======================================================================
-  inline void AddQuadPiramidsWithID(SMDS_Mesh* theMesh, 
+  inline void AddQuadPiramidsWithID(SMDS_Mesh* theMesh,
                                     SMESH::log_array_var& theSeq,
                                     CORBA::Long theId)
   {
@@ -489,7 +489,7 @@ namespace
   //=======================================================================
   //function : AddQuadPentasWithID
   //=======================================================================
-  inline void AddQuadPentasWithID(SMDS_Mesh* theMesh, 
+  inline void AddQuadPentasWithID(SMDS_Mesh* theMesh,
                                   SMESH::log_array_var& theSeq,
                                   CORBA::Long theId)
   {
@@ -523,7 +523,7 @@ namespace
   //=======================================================================
   //function : AddQuadHexasWithID
   //=======================================================================
-  inline void AddQuadHexasWithID(SMDS_Mesh* theMesh, 
+  inline void AddQuadHexasWithID(SMDS_Mesh* theMesh,
                                  SMESH::log_array_var& theSeq,
                                  CORBA::Long theId)
   {
@@ -562,7 +562,7 @@ namespace
   //=======================================================================
   //function : ChangePolyhedronNodes
   //=======================================================================
-  inline void ChangePolyhedronNodes (SMDS_Mesh* theMesh, 
+  inline void ChangePolyhedronNodes (SMDS_Mesh* theMesh,
                                      SMESH::log_array_var& theSeq,
                                      CORBA::Long theId)
   {
@@ -594,13 +594,13 @@ namespace
 }
 
 //=======================================================================
-SMESH::SMESH_Gen_var 
+SMESH::SMESH_Gen_var
 SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB,
                           CORBA::Boolean& theIsEmbeddedMode)
 {
   static SMESH::SMESH_Gen_var aMeshGen;
 
-  if(CORBA::is_nil(aMeshGen.in())){    
+  if(CORBA::is_nil(aMeshGen.in())){
 #ifdef WNT
     long aClientPID = (long)_getpid();
 #else
@@ -609,9 +609,9 @@ SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB,
 
     SALOME_NamingService aNamingService(theORB);
     SALOME_LifeCycleCORBA aLifeCycleCORBA(&aNamingService);
-    Engines::Component_var aComponent = aLifeCycleCORBA.FindOrLoad_Component("FactoryServer","SMESH");
+    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();
@@ -626,7 +626,7 @@ SMESH_Client::GetSMESHGen(CORBA::ORB_ptr theORB,
 
 //=======================================================================
 // function : Create()
-// purpose  : 
+// purpose  :
 //=======================================================================
 SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB,
                            SMESH::SMESH_Mesh_ptr theMesh):
@@ -634,6 +634,7 @@ SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB,
   mySMESHDSMesh(NULL),
   mySMDSMesh(NULL)
 {
+  MESSAGE("SMESH_Client::SMESH_Client");
   myMeshServer->Register();
 
   CORBA::Boolean anIsEmbeddedMode;
@@ -649,7 +650,8 @@ SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB,
     SMESH_Mesh* aMesh = reinterpret_cast<SMESH_Mesh*> (pointeur);
     if ( MYDEBUG )
       MESSAGE("SMESH_Client::SMESH_Client aMesh "<<aMesh);
-    if(aMesh->GetMeshDS()->IsEmbeddedMode()){
+    //if(aMesh->GetMeshDS()->IsEmbeddedMode()){
+    if(anIsEmbeddedMode){
       mySMESHDSMesh = aMesh->GetMeshDS();
       mySMDSMesh = mySMESHDSMesh;
     }
@@ -665,17 +667,17 @@ SMESH_Client::SMESH_Client(CORBA::ORB_ptr theORB,
 //=================================================================================
 SMESH_Client::~SMESH_Client()
 {
-  myMeshServer->Destroy();
+  myMeshServer->UnRegister();
   if(!mySMESHDSMesh)
     delete mySMDSMesh;
 }
 
 
 //=================================================================================
-SMDS_Mesh* 
-SMESH_Client::GetMesh() const 
+SMDS_Mesh*
+SMESH_Client::GetMesh() const
 {
-  return mySMDSMesh; 
+  return mySMDSMesh;
 }
 
 
@@ -691,7 +693,7 @@ SMESH_Client::operator->() const
 SMESH::SMESH_Mesh_ptr
 SMESH_Client::GetMeshServer()
 {
-  return myMeshServer.in(); 
+  return myMeshServer.in();
 }
 
 
@@ -704,16 +706,18 @@ SMESH_Client::Update(bool theIsClear)
 {
   bool anIsModified = true;
   if(mySMESHDSMesh){
+        MESSAGE("Update mySMESHDSMesh");
     SMESHDS_Script* aScript = mySMESHDSMesh->GetScript();
     anIsModified = aScript->IsModified();
     aScript->SetModified(false);
   }else{
+        MESSAGE("Update CORBA");
     SMESH::log_array_var aSeq = myMeshServer->GetLog( theIsClear );
     CORBA::Long aLength = aSeq->length();
     anIsModified = aLength > 0;
     if( MYDEBUG )
       MESSAGE( "Update: length of the script is "<<aLength );
-  
+
     if(!anIsModified)
       return false;
 
@@ -757,7 +761,7 @@ SMESH_Client::Update(bool theIsClear)
           for( ; anElemId < aNbElems; anElemId++ )
             mySMDSMesh->RemoveNode( FindNode( mySMDSMesh, anIndexes[anElemId] ) );
         break;
-        
+
         case SMESH::REMOVE_ELEMENT:
           for( ; anElemId < aNbElems; anElemId++ )
             mySMDSMesh->RemoveElement( FindElement( mySMDSMesh, anIndexes[anElemId] ) );
@@ -798,7 +802,7 @@ SMESH_Client::Update(bool theIsClear)
             mySMDSMesh->Renumber( anIndexes[i], anIndexes[i+1], anIndexes[i+2] );
           }
           break;
-          
+
         default:;
         }
       }
@@ -825,6 +829,6 @@ SMESH_Client::Update(bool theIsClear)
       MESSAGE("Update - mySMDSMesh->NbVolumes() = "<<mySMDSMesh->NbVolumes());
     }
   } // end of update mesh by log script
-  
+
   return anIsModified;
 }