Salome HOME
Merge multi-study removal branch.
[plugins/ghs3dplugin.git] / src / GHS3DPlugin / GHS3DPlugin_Hypothesis_i.cxx
index 3f5bed7e39e39f65114f4aa144fbecd572056496..21af792e85ad661f628cbbd4db373b5dd1e72e3a 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2004-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2004-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 //
 #include "GHS3DPlugin_Hypothesis_i.hxx"
 
-#include "SMESH_Gen.hxx"
-#include "SMESH_PythonDump.hxx"
-//#include "SMESH_Mesh.hxx"
-//#include "SMESH_ProxyMesh.hxx"
-//#include <StdMeshers_QuadToTriaAdaptor.hxx>
+#include <SMESH_Gen.hxx>
+#include <SMESH_PythonDump.hxx>
 
-#include "Utils_CorbaException.hxx"
-#include "utilities.h"
-#include "SMESH_Mesh_i.hxx"
-#include "SMESH_Group_i.hxx"
-#include "SMESH_Gen_i.hxx"
-#include "SMESH_TypeDefs.hxx"
-#include "SMESHDS_GroupBase.hxx"
+#include <Utils_CorbaException.hxx>
+#include <utilities.h>
+#include <SMESH_Mesh_i.hxx>
+#include <SMESH_Group_i.hxx>
+#include <SMESH_Gen_i.hxx>
+//#include <SMESH_TypeDefs.hxx>
+#include <SMESHDS_GroupBase.hxx>
 
 // SALOME KERNEL includes
-#include "SALOMEDSClient.hxx"
-#include <SALOMEDSClient_definitions.hxx>
-// // IDL headers
-// #include <SALOMEconfig.h>
-// #include CORBA_SERVER_HEADER(SALOMEDS)
+// #include <SALOMEDSClient.hxx>
+// #include <SALOMEDSClient_definitions.hxx>
+
+using namespace std;
 
 //=======================================================================
 //function : GHS3DPlugin_Hypothesis_i
 //=======================================================================
 
 GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
-                                                    int                     theStudyId,
                                                     ::SMESH_Gen*            theGenImpl)
   : SALOME::GenericObj_i( thePOA ), 
     SMESH_Hypothesis_i( thePOA )
 {
-  MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
   myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
-                                              theStudyId,
-                                              theGenImpl);
+                                             theGenImpl);
 }
 
 //=======================================================================
@@ -66,7 +59,6 @@ GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr theP
 
 GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
 {
-  MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" );
 }
 
 //=======================================================================
@@ -115,8 +107,8 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMakeGroupsOfDomains()
 //function : SetMaximumMemory
 //=======================================================================
 
-void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB)
-   throw ( SALOME::SALOME_Exception )
+void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Float MB)
+  throw ( SALOME::SALOME_Exception )
 {
   if ( MB == 0 )
     THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM );
@@ -129,7 +121,7 @@ void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB)
 //function : GetMaximumMemory
 //=======================================================================
 
-CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
+CORBA::Float GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
 {
   ASSERT(myBaseImpl);
   return this->GetImpl()->GetMaximumMemory();
@@ -139,7 +131,7 @@ CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
 //function : SetInitialMemory
 //=======================================================================
 
-void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB)
+void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Float MB)
   throw ( SALOME::SALOME_Exception )
 {
   if ( MB == 0 )
@@ -153,7 +145,7 @@ void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB)
 //function : GetInitialMemory
 //=======================================================================
 
-CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory()
+CORBA::Float GHS3DPlugin_Hypothesis_i::GetInitialMemory()
 {
   ASSERT(myBaseImpl);
   return this->GetImpl()->GetInitialMemory();
@@ -167,7 +159,7 @@ void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
   throw ( SALOME::SALOME_Exception )
 {
   ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
-      (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
+    (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
   if ( l < ::GHS3DPlugin_Hypothesis::None ||
        l > ::GHS3DPlugin_Hypothesis::Strong )
     THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
@@ -358,8 +350,8 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
 void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
 {
   ASSERT(myBaseImpl);
-  this->GetImpl()->SetTextOption(option);
-  SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )";
+  this->GetImpl()->SetAdvancedOption(option);
+  SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
 }
 
 //=======================================================================
@@ -369,7 +361,28 @@ void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option)
 char* GHS3DPlugin_Hypothesis_i::GetTextOption()
 {
   ASSERT(myBaseImpl);
-  return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
+  return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
+}
+
+//=======================================================================
+//function : SetAdvancedOption
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetAdvancedOption(const char* option)
+{
+  ASSERT(myBaseImpl);
+  this->GetImpl()->SetAdvancedOption(option);
+  SMESH::TPythonDump() << _this() << ".SetAdvancedOption( '" << option << "' )";
+}
+
+//=======================================================================
+//function : GetAdvancedOption
+//=======================================================================
+
+char* GHS3DPlugin_Hypothesis_i::GetAdvancedOption()
+{
+  ASSERT(myBaseImpl);
+  return CORBA::string_dup( this->GetImpl()->GetAdvancedOption().c_str() );
 }
 
 //=======================================================================
@@ -378,8 +391,6 @@ char* GHS3DPlugin_Hypothesis_i::GetTextOption()
 
 void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation)
 {
-  if (gradation <= 1)
-    THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM );
   ASSERT(myBaseImpl);
   if (gradation != GetGradation()) {
     this->GetImpl()->SetGradation(gradation);
@@ -444,39 +455,34 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetRemoveLogOnSuccess()
 //=======================================================================
 
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
-    throw (SALOME::SALOME_Exception) {
+  throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
-  MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
   return p_SetEnforcedVertex(size, x, y, z);
 }
 
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
-    throw (SALOME::SALOME_Exception) {
+  throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
-  MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
 }
 
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
-    throw (SALOME::SALOME_Exception) {
+  throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
-  MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
   return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
 }
 
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
-    throw (SALOME::SALOME_Exception) {
+  throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
-  MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
   return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
 }
 
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
-    throw (SALOME::SALOME_Exception) {
+  throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
   
   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
-    MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
   }
   
@@ -484,7 +490,6 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVe
   CORBA::Double x = 0, y = 0, z = 0;
   CORBA::Boolean isCompound = false;
   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
-  SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
   if (theVertexEntry.empty()) {
     string aName;
     if (theVertex->GetShapeType() == GEOM::VERTEX) {
@@ -495,7 +500,7 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVe
       isCompound = true;
     }
     aName += theVertex->GetEntry();
-    SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
+    SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
     if (!theSVertex->_is_nil())
       theVertexEntry = theSVertex->GetID();
   }
@@ -503,26 +508,23 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVe
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
 
   if (theVertex->GetShapeType() == GEOM::VERTEX) {
-    GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
+    GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
     if (CORBA::is_nil(measureOp))
       return false;
     
     measureOp->PointCoordinates (theVertex, x, y, z);
-    MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
   }
 
   string theVertexName = theVertex->GetName();
-  MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
   
   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
 }
 
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
-    throw (SALOME::SALOME_Exception) {
+  throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
   
   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
-    MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
   }
   
@@ -530,7 +532,6 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_
   CORBA::Double x = 0, y = 0, z = 0;
   CORBA::Boolean isCompound = false;
   GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
-  SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
   if (theVertexEntry.empty()) {
     string aName;
     if (theVertex->GetShapeType() == GEOM::VERTEX) {
@@ -541,7 +542,7 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_
       isCompound = true;
     }
     aName += theVertex->GetEntry();
-    SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
+    SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
     if (!theSVertex->_is_nil())
       theVertexEntry = theSVertex->GetID();
   }
@@ -549,26 +550,23 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
 
   if (theVertex->GetShapeType() == GEOM::VERTEX) {
-    GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
+    GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
     if (CORBA::is_nil(measureOp))
       return false;
     
     measureOp->PointCoordinates (theVertex, x, y, z);
-    MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
   }
     
   string theVertexName = theVertex->GetName();
-  MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
   
   return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
 }
 
 bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
-                                                   const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
-                                                   CORBA::Boolean isCompound)
-    throw (SALOME::SALOME_Exception) {
+                                                    const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
+                                                    CORBA::Boolean isCompound)
+  throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
-  MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
   bool newValue = false;
 
   ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
@@ -580,20 +578,13 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D
     coords.push_back(y);
     coords.push_back(z);
     if (coordsList.find(coords) == coordsList.end()) {
-      MESSAGE("Coords not found: add it in coordsList");
       newValue = true;
     }
     else {
-      MESSAGE("Coords already found, compare names");
       ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
-        MESSAGE("The names or size are different: update");
-//          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
         newValue = true;
       }
-      else {
-        MESSAGE("The names and size are identical");
-      }
     }
 
     if (newValue) {
@@ -612,24 +603,15 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D
     }
   } 
   else {
-//   if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
     enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
-//     ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
     if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
-      MESSAGE("Geom entry not found: add it in enfVertexEntryList");
       newValue = true;
     }
     else {
-      MESSAGE("Geom entry already found, compare names");
       ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
       if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
-        MESSAGE("The names or size are different: update");
-//          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
         newValue = true;
       }
-      else {
-        MESSAGE("The names and size are identical");
-      }
     }
 
     if (newValue) {
@@ -643,7 +625,6 @@ bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::D
   if (newValue)
     this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
 
-  MESSAGE("IDL : SetEnforcedVertexEntry END");
   return newValue;
 }
 
@@ -661,12 +642,7 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA
     return isDone;
   }
   catch (const std::invalid_argument& ex) {
-    SALOME::ExceptionStruct ExDescription;
-    ExDescription.text = ex.what();
-    ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-    ExDescription.lineNumber = 513;
-    throw SALOME::SALOME_Exception(ExDescription);
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
   }
   catch (SALOME_Exception& ex) {
     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
@@ -683,21 +659,19 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_
   ASSERT(myBaseImpl);
   
   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
-    MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
   }
   
   string theVertexEntry = theVertex->GetStudyEntry();
   if (theVertexEntry.empty()) {
     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
-    SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
     string aName;
     if (theVertex->GetShapeType() == GEOM::VERTEX)
       aName = "Vertex_";
     if (theVertex->GetShapeType() == GEOM::COMPOUND)
       aName = "Compound_";
     aName += theVertex->GetEntry();
-    SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
+    SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
     if (!theSVertex->_is_nil())
       theVertexEntry = theSVertex->GetID();
   }
@@ -712,12 +686,7 @@ CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_
     return isDone;
   }
   catch (const std::invalid_argument& ex) {
-    SALOME::ExceptionStruct ExDescription;
-    ExDescription.text = ex.what();
-    ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-    ExDescription.lineNumber = 538;
-    throw SALOME::SALOME_Exception(ExDescription);
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
   }
   catch (SALOME_Exception& ex) {
     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
@@ -748,7 +717,7 @@ GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVerti
     // Coords
     GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
     coords->length(currentVertex->coords.size());
-    for (int ind = 0; ind < currentVertex->coords.size(); ind++)
+    for ( size_t ind = 0; ind < currentVertex->coords.size(); ind++)
       coords[ind] = currentVertex->coords[ind];
     enfVertex->coords = coords;
     // Group Name
@@ -759,9 +728,9 @@ GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVerti
     enfVertex->isCompound = currentVertex->isCompound;
     
     result[i]=enfVertex;
-    }
+  }
   
-//   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
+  //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
 
   return result._retn();
 }
@@ -780,12 +749,7 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Doub
     return res;
   }
   catch (const std::invalid_argument& ex) {
-    SALOME::ExceptionStruct ExDescription;
-    ExDescription.text = ex.what();
-    ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-    ExDescription.lineNumber = 625;
-    throw SALOME::SALOME_Exception(ExDescription);
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
   }
   catch (SALOME_Exception& ex) {
     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
@@ -798,21 +762,19 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr th
   ASSERT(myBaseImpl);
   
   if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
-    MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
     THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
   }
   
   string theVertexEntry = theVertex->GetStudyEntry();
   if (theVertexEntry.empty()) {
     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
-    SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
     string aName;
     if (theVertex->GetShapeType() == GEOM::VERTEX)
       aName = "Vertex_";
     if (theVertex->GetShapeType() == GEOM::COMPOUND)
       aName = "Compound_";
     aName += theVertex->GetEntry();
-    SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
+    SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
     if (!theSVertex->_is_nil())
       theVertexEntry = theSVertex->GetID();
   }
@@ -825,12 +787,7 @@ bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr th
     return res;
   }
   catch (const std::invalid_argument& ex) {
-    SALOME::ExceptionStruct ExDescription;
-    ExDescription.text = ex.what();
-    ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-    ExDescription.lineNumber = 648;
-    throw SALOME::SALOME_Exception(ExDescription);
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
   }
   catch (SALOME_Exception& ex) {
     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
@@ -886,9 +843,9 @@ GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes(
     enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
     
     result[i]=enfMesh;
-    }
+  }
   
-//   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
+  //   SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
 
   return result._retn();
 }
@@ -899,16 +856,7 @@ GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes(
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName)
   throw (SALOME::SALOME_Exception)
 {
-// #if GHS3D_VERSION >= 42
   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
-// #else
-//   SALOME::ExceptionStruct ExDescription;
-//   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
-//   ExDescription.type = SALOME::BAD_PARAM;
-//   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-//   ExDescription.lineNumber = 719;
-//   throw SALOME::SALOME_Exception(ExDescription);
-// #endif
 }
 
 /*!
@@ -917,17 +865,7 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_pt
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
   throw (SALOME::SALOME_Exception)
 {
-//   MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
-// #if GHS3D_VERSION >= 42
   return p_SetEnforcedMesh(theSource, theType);
-// #else
-//   SALOME::ExceptionStruct ExDescription;
-//   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
-//   ExDescription.type = SALOME::BAD_PARAM;
-//   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-//   ExDescription.lineNumber = 750;
-//   throw SALOME::SALOME_Exception(ExDescription);
-// #endif
 }
 
 /*!
@@ -936,16 +874,7 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSour
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
   throw (SALOME::SALOME_Exception)
 {
-// #if GHS3D_VERSION >= 42
   return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
-// #else
-//   SALOME::ExceptionStruct ExDescription;
-//   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
-//   ExDescription.type = SALOME::BAD_PARAM;
-//   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-//   ExDescription.lineNumber = 750;
-//   throw SALOME::SALOME_Exception(ExDescription);
-// #endif
 }
 
 /*!
@@ -954,67 +883,35 @@ bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSourc
 bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
   throw (SALOME::SALOME_Exception)
 {
-// #if GHS3D_VERSION >= 42
   return p_SetEnforcedMesh(theSource, theType);
-// #else
-//   SALOME::ExceptionStruct ExDescription;
-//   ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
-//   ExDescription.type = SALOME::BAD_PARAM;
-//   ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-//   ExDescription.lineNumber = 750;
-//   throw SALOME::SALOME_Exception(ExDescription);
-// #endif
 }
 
-bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
+bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource,
+                                                 SMESH::ElementType        theType,
+                                                 const char*               theName,
+                                                 const char*               theGroupName)
   throw (SALOME::SALOME_Exception)
 {
-  MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
   ASSERT(myBaseImpl);
-  
+
   if (CORBA::is_nil( theSource ))
-  {
-    SALOME::ExceptionStruct ExDescription;
-    ExDescription.text = "The source mesh CORBA object is NULL";
-    ExDescription.type = SALOME::BAD_PARAM;
-    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-    ExDescription.lineNumber = 840;
-    throw SALOME::SALOME_Exception(ExDescription);
-  }
-  
+    THROW_SALOME_CORBA_EXCEPTION( "The source mesh CORBA object is NULL" ,SALOME::BAD_PARAM );
+
   switch (theType) {
-    case SMESH::NODE:
-      MESSAGE("Required type is NODE");
-      break;
-    case SMESH::EDGE:
-      MESSAGE("Required type is EDGE");
-      break;
-    case SMESH::FACE:
-      MESSAGE("Required type is FACE");
-      break;
-    default:
-        MESSAGE("Incompatible required type: " << theType);
-        return false;
+  case SMESH::NODE:
+  case SMESH::EDGE:
+  case SMESH::FACE: break;
+  default:
+    return false;
   }
-//   MESSAGE("Required type is "<<theType);
   SMESH::array_of_ElementType_var types = theSource->GetTypes();
-  MESSAGE("Available types:");
-  for (int i=0;i<types->length();i++){MESSAGE(types[i]);}
   if ( types->length() >= 1 && types[types->length()-1] <  theType)
   {
-    MESSAGE("Required type not available");
     return false;
-//     SALOME::ExceptionStruct ExDescription;
-//     ExDescription.text = "The source mesh has bad type";
-//     ExDescription.type = SALOME::BAD_PARAM;
-//     ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-//     ExDescription.lineNumber = 840;
-//     throw SALOME::SALOME_Exception(ExDescription);
   }
-  
 
   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
-  SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
+  SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
 
   SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
   SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
@@ -1022,20 +919,20 @@ bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSo
 
   string enfMeshName = theName;
   if (enfMeshName.empty())
-          enfMeshName = SObj->GetName();
+    enfMeshName = SObj->GetName();
 
   if (theMesh_i)
   {
     try {
-        bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
-                if (theGroupName != "") {
-                  SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
-                                                                << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
-                }
-                else {
-                  SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
-                                                                << theSource << ".GetMesh(), " << theType << " )";
-                }
+      bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
+      if (theGroupName && theGroupName[0] ) {
+        SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
+                              << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
+      }
+      else {
+        SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
+                              << theSource << ".GetMesh(), " << theType << " )";
+      }
 
       return res;
     }
@@ -1053,17 +950,16 @@ bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSo
   }
   else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
   {
-    MESSAGE("The source is a group")
     try {
-        bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
-        if (theGroupName != "") {
-          SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " 
-                                << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
-        }
-        else {
-          SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " 
-                                << theSource << ", " << theType << " )";
-        }
+      bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
+      if ( theGroupName && theGroupName[0] ) {
+        SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
+                              << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
+      }
+      else {
+        SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
+                              << theSource << ", " << theType << " )";
+      }
       return res;
     }
     catch (const std::invalid_argument& ex) {
@@ -1080,17 +976,16 @@ bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSo
   }
   else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
   {
-    MESSAGE("The source is a group on geom")
     try {
-        bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
-        if (theGroupName != "") {
-          SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " 
-                                << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
-        }
-        else {
-          SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " 
-                                << theSource << ", " << theType << " )";
-        }
+      bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
+      if ( theGroupName && theGroupName[0] ) {
+        SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
+                              << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
+      }
+      else {
+        SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
+                              << theSource << ", " << theType << " )";
+      }
       return res;
     }
     catch (const std::invalid_argument& ex) {
@@ -1128,4 +1023,3 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
 {
   return type == SMESH::DIM_3D;
 }
-