0021308: Remove hard-coded dependency of the external mesh plugins from the SMESH module

1) Use TVar structure to dump arguments that can be defined via notebook variables
2)
+  // method intended to remove explicit treatment of Netgen hypotheses from
+  // SMESH_NoteBook to assure backward compatibility after implemeneting
+  // issue 0021308: Remove hard-coded dependency of the external mesh plugins
+  virtual int getParamIndex(const TCollection_AsciiString& method, int nbVars) const;
+
+  // method used to convert variable parameters stored in an old study
+  // into myMethod2VarParams. It should return a method name for an index of
+  // variable parameters. Index is countered from zero
+  virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
This commit is contained in:
eap 2012-03-07 15:22:27 +00:00
parent c63b5761ca
commit 8923d63e34
5 changed files with 112 additions and 11 deletions

View File

@ -96,7 +96,7 @@ void NETGENPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue)
if ( isToSetParameter( GetMaxSize(), theValue, METH_SetMaxSize ))
{
this->GetImpl()->SetMaxSize(theValue);
SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )";
SMESH::TPythonDump() << _this() << ".SetMaxSize( " << SMESH::TVar(theValue) << " )";
}
}
@ -124,7 +124,7 @@ void NETGENPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue)
if ( isToSetParameter( GetMinSize(), theValue, METH_SetMinSize ))
{
this->GetImpl()->SetMinSize(theValue);
SMESH::TPythonDump() << _this() << ".SetMinSize( " << theValue << " )";
SMESH::TPythonDump() << _this() << ".SetMinSize( " << SMESH::TVar(theValue) << " )";
}
}
@ -236,7 +236,7 @@ void NETGENPlugin_Hypothesis_i::SetGrowthRate (CORBA::Double theValue)
if ( isToSetParameter( GetGrowthRate(), theValue, METH_SetGrowthRate ))
{
this->GetImpl()->SetGrowthRate(theValue);
SMESH::TPythonDump() << _this() << ".SetGrowthRate( " << theValue << " )";
SMESH::TPythonDump() << _this() << ".SetGrowthRate( " << SMESH::TVar(theValue) << " )";
}
}
@ -264,7 +264,7 @@ void NETGENPlugin_Hypothesis_i::SetNbSegPerEdge (CORBA::Double theValue)
if ( isToSetParameter( GetNbSegPerEdge(), theValue, METH_SetNbSegPerEdge ))
{
this->GetImpl()->SetNbSegPerEdge(theValue);
SMESH::TPythonDump() << _this() << ".SetNbSegPerEdge( " << theValue << " )";
SMESH::TPythonDump() << _this() << ".SetNbSegPerEdge( " << SMESH::TVar(theValue) << " )";
}
}
@ -292,7 +292,7 @@ void NETGENPlugin_Hypothesis_i::SetNbSegPerRadius (CORBA::Double theValue)
if ( isToSetParameter( GetNbSegPerRadius(), theValue, METH_SetNbSegPerRadius ))
{
this->GetImpl()->SetNbSegPerRadius(theValue);
SMESH::TPythonDump() << _this() << ".SetNbSegPerRadius( " << theValue << " )";
SMESH::TPythonDump() << _this() << ".SetNbSegPerRadius( " << SMESH::TVar(theValue) << " )";
}
}
@ -388,3 +388,42 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type
{
return type == SMESH::DIM_3D;
}
//================================================================================
/*!
* \brief method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook
*/
//================================================================================
int NETGENPlugin_Hypothesis_i::getParamIndex(const TCollection_AsciiString& method,
int nbVars) const
{
if ( method == "SetMaxSize" ) return 0;
if ( method == "SetGrowthRate" ) return 1;
if ( method == "SetNbSegPerEdge" ) return 2;
if ( method == "SetNbSegPerRadius" ) return 3;
if ( method == "SetMinSize" ) return nbVars-1;
return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value
}
//================================================================================
/*!
* \brief Method used to convert variable parameters stored in an old study
* into myMethod2VarParams. It should return a method name for an index of
* variable parameters. Index is countered from zero
*/
//================================================================================
std::string NETGENPlugin_Hypothesis_i::getMethodOfParameter(const int paramIndex,
int nbVars) const
{
switch ( paramIndex ) {
case 0: return "SetMaxSize";
case 1: return nbVars == 2 ? "SetMinSize" : "SetGrowthRate";
case 2: return "SetNbSegPerEdge";
case 3: return "SetNbSegPerRadius";
case 4: return "SetMinSize";
}
return "";
}

View File

@ -122,6 +122,17 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i:
else
return ( mySetMethodFlags |= meth ); // == return true
}
public:
// method intended to remove explicit treatment of Netgen hypotheses from
// SMESH_NoteBook to assure backward compatibility after implemeneting
// issue 0021308: Remove hard-coded dependency of the external mesh plugins
virtual int getParamIndex(const TCollection_AsciiString& method, int nbVars) const;
// method used to convert variable parameters stored in an old study
// into myMethod2VarParams. It should return a method name for an index of
// variable parameters. Index is countered from zero
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
#endif

View File

@ -32,6 +32,8 @@
#include <Utils_CorbaException.hxx>
#include <utilities.h>
#include <TCollection_AsciiString.hxx>
using namespace std;
//=============================================================================
@ -82,7 +84,7 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb)
catch (SALOME_Exception& S_ex) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
}
SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << nb << " )";
SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(nb) << " )";
}
//=============================================================================
@ -113,7 +115,7 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetLocalLength(CORBA::Double segmentLen
catch (SALOME_Exception& S_ex) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
}
SMESH::TPythonDump() << _this() << ".SetLocalLength( " << segmentLength << " )";
SMESH::TPythonDump() << _this() << ".SetLocalLength( " << SMESH::TVar(segmentLength) << " )";
}
//================================================================================
@ -152,7 +154,7 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area)
MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea");
ASSERT(myBaseImpl);
this->GetImpl()->SetMaxElementArea(area);
SMESH::TPythonDump() << _this() << ".SetMaxElementArea( " << area << " )";
SMESH::TPythonDump() << _this() << ".SetMaxElementArea( " << SMESH::TVar(area) << " )";
}
@ -197,7 +199,7 @@ CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::GetAllowQuadrangles()
* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl
*/
//=============================================================================
::NETGENPlugin_SimpleHypothesis_2D* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl()
::NETGENPlugin_SimpleHypothesis_2D* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl() const
{
MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetImpl");
return (::NETGENPlugin_SimpleHypothesis_2D*)myBaseImpl;
@ -216,3 +218,41 @@ CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::IsDimSupported( SMESH::Dimens
{
return type == SMESH::DIM_2D;
}
//================================================================================
/*!
* \brief method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook
*/
//================================================================================
int NETGENPlugin_SimpleHypothesis_2D_i::getParamIndex(const TCollection_AsciiString& method,
int nbVars) const
{
if ( method == "SetLocalLength" ) return 0;
if ( method == "SetNumberOfSegments" ) return 0;
if ( method == "SetMaxElementArea" ) return 1;
if ( method == "LengthFromEdges" ) return 10; // just to go to the next state
if ( method == "SetMaxElementVolume" ) return 2;
if ( method == "LengthFromFaces" ) return 10; // just to go to the next state
return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value
}
//================================================================================
/*!
* \brief Method used to convert variable parameters stored in an old study
* into myMethod2VarParams. It should return a method name for an index of
* variable parameters. Index is countered from zero
*/
//================================================================================
std::string NETGENPlugin_SimpleHypothesis_2D_i::getMethodOfParameter(const int paramIndex,
int nbVars) const
{
switch ( paramIndex ) {
case 0: return GetImpl()->GetNumberOfSegments() ? "SetNumberOfSegments" : "SetLocalLength";
case 1: return "SetMaxElementArea";
case 2: return "SetMaxElementVolume";
}
return "";
}

View File

@ -66,10 +66,21 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_SimpleHypothesis_2D_i:
CORBA::Boolean GetAllowQuadrangles();
// Get implementation
::NETGENPlugin_SimpleHypothesis_2D* GetImpl();
::NETGENPlugin_SimpleHypothesis_2D* GetImpl() const;
// Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type );
public:
// method intended to remove explicit treatment of Netgen hypotheses from
// SMESH_NoteBook to assure backward compatibility after implemeneting
// issue 0021308: Remove hard-coded dependency of the external mesh plugins
virtual int getParamIndex(const TCollection_AsciiString& method, int nbVars) const;
// method used to convert variable parameters stored in an old study
// into myMethod2VarParams. It should return a method name for an index of
// variable parameters. Index is countered from zero
virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const;
};
#endif

View File

@ -92,7 +92,7 @@ void NETGENPlugin_SimpleHypothesis_3D_i::SetMaxElementVolume(CORBA::Double value
MESSAGE("NETGENPlugin_SimpleHypothesis_3D_i::SetMaxElementVolume");
ASSERT(myBaseImpl);
this->GetImpl()->SetMaxElementVolume(value);
SMESH::TPythonDump() << _this() << ".SetMaxElementVolume( " << value << " )";
SMESH::TPythonDump() << _this() << ".SetMaxElementVolume( " << SMESH::TVar(value) << " )";
}