mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-03-14 19:51:16 +05:00
Refactoring
This commit is contained in:
parent
44a2277a1a
commit
f5bfce992f
@ -28,6 +28,7 @@
|
||||
|
||||
#include "SALOME_Exception.idl"
|
||||
#include "SALOME_GenericObj.idl"
|
||||
#include "SALOME_Notebook.idl"
|
||||
|
||||
module SMESH
|
||||
{
|
||||
@ -41,7 +42,7 @@ module SMESH
|
||||
|
||||
typedef sequence<string> ListOfParameters;
|
||||
|
||||
interface SMESH_Hypothesis : SALOME::GenericObj
|
||||
interface SMESH_Hypothesis : SALOME::ParameterizedObject
|
||||
{
|
||||
|
||||
/*!
|
||||
@ -59,35 +60,6 @@ module SMESH
|
||||
*/
|
||||
long GetId();
|
||||
|
||||
/*!
|
||||
* Set list of parameters
|
||||
* \param theParameters is a string containing the notebook variables separated by ":" symbol,
|
||||
* used for Hypothesis creation
|
||||
*/
|
||||
void SetParameters (in string theParameters);
|
||||
|
||||
/*!
|
||||
* Return list of notebook variables used for Hypothesis creation separated by ":" symbol
|
||||
*/
|
||||
string GetParameters();
|
||||
|
||||
/*!
|
||||
* Return list of last notebook variables used for Hypothesis creation.
|
||||
*/
|
||||
ListOfParameters GetLastParameters();
|
||||
|
||||
/*!
|
||||
* Set list of parameters
|
||||
* \param theParameters is a string containing the last notebook variables separated by ":" symbol,
|
||||
* used for Hypothesis creation
|
||||
*/
|
||||
void SetLastParameters(in string theParameters);
|
||||
|
||||
/*!
|
||||
* Clear parameters list
|
||||
*/
|
||||
void ClearParameters();
|
||||
|
||||
/*!
|
||||
* Verify whether hypothesis supports given entity type
|
||||
*/
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "SALOME_Exception.idl"
|
||||
#include "SALOME_GenericObj.idl"
|
||||
#include "SALOME_Notebook.idl"
|
||||
#include "GEOM_Gen.idl"
|
||||
#include "MED.idl"
|
||||
|
||||
@ -263,7 +264,7 @@ module SMESH
|
||||
interface SMESH_GroupOnGeom;
|
||||
interface SMESH_subMesh;
|
||||
interface SMESH_MeshEditor;
|
||||
interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource
|
||||
interface SMESH_Mesh : SALOME::ParameterizedObject, SMESH_IDSource
|
||||
{
|
||||
/*!
|
||||
* Return true if there is a geometry to be meshed
|
||||
@ -760,22 +761,6 @@ module SMESH
|
||||
|
||||
/*! Gets information about imported MED file */
|
||||
SALOME_MED::MedFileInfo GetMEDFileInfo();
|
||||
|
||||
/*!
|
||||
* Sets list of notebook variables used for Mesh operations separated by ":" symbol
|
||||
* \param theParameters is a string containing the notebook variables
|
||||
*/
|
||||
void SetParameters (in string theParameters);
|
||||
|
||||
/*!
|
||||
* Returns list of notebook variables used for Mesh operations separated by ":" symbol
|
||||
*/
|
||||
string GetParameters();
|
||||
|
||||
/*!
|
||||
* Returns list of notebook variables used for last Mesh operation
|
||||
*/
|
||||
string_array GetLastParameters();
|
||||
};
|
||||
|
||||
interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
|
||||
|
@ -49,7 +49,6 @@ SMESH_Hypothesis::SMESH_Hypothesis(int hypId,
|
||||
_type = PARAM_ALGO;
|
||||
_shapeType = 0; // to be set by algo with TopAbs_Enum
|
||||
_param_algo_dim = -1; // to be set by algo parameter
|
||||
_parameters = string();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -155,15 +154,9 @@ void SMESH_Hypothesis::SetLibName(const char* theLibName)
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void SMESH_Hypothesis::SetParameters(const char *theParameters)
|
||||
void SMESH_Hypothesis::SetParameters(const std::list<std::string>& theParameters)
|
||||
{
|
||||
string aNewParameters(theParameters);
|
||||
if(aNewParameters.size()==0 && _parameters.size()==0)
|
||||
aNewParameters = " ";
|
||||
if(_parameters.size()>0)
|
||||
_parameters +="|";
|
||||
_parameters +=aNewParameters;
|
||||
SetLastParameters(theParameters);
|
||||
_parameters = theParameters;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -171,37 +164,7 @@ void SMESH_Hypothesis::SetParameters(const char *theParameters)
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void SMESH_Hypothesis::ClearParameters()
|
||||
std::list<std::string> SMESH_Hypothesis::GetParameters() const
|
||||
{
|
||||
_parameters = string();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
char* SMESH_Hypothesis::GetParameters() const
|
||||
{
|
||||
return (char*)_parameters.c_str();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
char* SMESH_Hypothesis::GetLastParameters() const
|
||||
{
|
||||
return (char*)_lastParameters.c_str();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void SMESH_Hypothesis::SetLastParameters(const char* theParameters)
|
||||
{
|
||||
_lastParameters = string(theParameters);
|
||||
return _parameters;
|
||||
}
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
#include "SMESHDS_Hypothesis.hxx"
|
||||
|
||||
#include <list>
|
||||
|
||||
class SMESH_Gen;
|
||||
class TopoDS_Shape;
|
||||
class SMESH_Mesh;
|
||||
@ -77,13 +79,9 @@ public:
|
||||
virtual const char* GetLibName() const;
|
||||
void SetLibName(const char* theLibName);
|
||||
|
||||
void SetParameters(const char *theParameters);
|
||||
char* GetParameters() const;
|
||||
void SetParameters(const std::list<std::string>& theParameters);
|
||||
std::list<std::string> GetParameters() const;
|
||||
|
||||
void SetLastParameters(const char* theParameters);
|
||||
char* GetLastParameters() const;
|
||||
void ClearParameters();
|
||||
|
||||
/*!
|
||||
* \brief Initialize my parameter values by the mesh built on the geometry
|
||||
* \param theMesh - the built mesh
|
||||
@ -122,8 +120,7 @@ protected:
|
||||
|
||||
private:
|
||||
std::string _libName;
|
||||
std::string _parameters;
|
||||
std::string _lastParameters;
|
||||
std::list<std::string> _parameters;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -505,11 +505,6 @@ public:
|
||||
*/
|
||||
SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
|
||||
|
||||
void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters);
|
||||
char* GetParameters(CORBA::Object_ptr theObject);
|
||||
char* ParseParameters(const char* theParameters);
|
||||
|
||||
|
||||
private:
|
||||
// Create hypothesis of given type
|
||||
SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName,
|
||||
|
@ -885,128 +885,3 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
|
||||
{
|
||||
|
||||
if(VARIABLE_DEBUG)
|
||||
cout<<"UpdateParameters : "<<theParameters<<endl;
|
||||
SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
|
||||
if(aStudy->_is_nil() || CORBA::is_nil(theObject))
|
||||
return;
|
||||
|
||||
SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject);
|
||||
if(aSObj->_is_nil())
|
||||
return;
|
||||
|
||||
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
|
||||
|
||||
SALOMEDS::GenericAttribute_var aFindAttr;
|
||||
bool hasAttr = aSObj->FindAttribute(aFindAttr, "AttributeString");
|
||||
if(VARIABLE_DEBUG)
|
||||
cout<<"Find Attribute "<<hasAttr<<endl;
|
||||
|
||||
SALOMEDS::GenericAttribute_var anAttr;
|
||||
anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
|
||||
SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
|
||||
|
||||
CORBA::String_var oldparVar = aStringAttr->Value();
|
||||
CORBA::String_var inpparVar = ParseParameters(theParameters);
|
||||
TCollection_AsciiString aNewParams;
|
||||
TCollection_AsciiString aOldParameters(oldparVar.inout());
|
||||
TCollection_AsciiString anInputParams(inpparVar.inout());
|
||||
if(!hasAttr)
|
||||
aNewParams = anInputParams;
|
||||
else
|
||||
aNewParams = aOldParameters+"|"+anInputParams;
|
||||
|
||||
if(VARIABLE_DEBUG)
|
||||
{
|
||||
cout<<"Input Parameters : "<<anInputParams<<endl;
|
||||
cout<<"Old Parameters : "<<aOldParameters<<endl;
|
||||
cout<<"New Parameters : "<<aNewParams<<endl;
|
||||
}
|
||||
|
||||
aStringAttr->SetValue( aNewParams.ToCString() );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ParseParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
char* SMESH_Gen_i::ParseParameters(const char* theParameters)
|
||||
{
|
||||
/* ouv: temporarily disabled
|
||||
//const char* aParameters = theParameters;
|
||||
// const char* aParameters = CORBA::string_dup(theParameters);
|
||||
TCollection_AsciiString anInputParams;
|
||||
SALOMEDS::Study_var aStudy = GetCurrentStudy();
|
||||
if( !aStudy->_is_nil() ) {
|
||||
// SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(theParameters);
|
||||
// for(int j=0;j<aSections->length();j++) {
|
||||
// SALOMEDS::ListOfStrings aVars= aSections[j];
|
||||
// for(int i=0;i<aVars.length();i++ ) {
|
||||
// anInputParams += aStudy->IsVariable(aVars[i].in()) ?
|
||||
// TCollection_AsciiString(aVars[i].in()) : TCollection_AsciiString("");
|
||||
// if(i != aVars.length()-1)
|
||||
// anInputParams+=":";
|
||||
// }
|
||||
// if(j!=aSections->length()-1)
|
||||
// anInputParams+="|";
|
||||
// }
|
||||
TCollection_AsciiString paramStr( theParameters );
|
||||
static TCollection_AsciiString separators(":|");
|
||||
int beg = 0, end;
|
||||
char sep, *pParams = (char*)paramStr.ToCString();
|
||||
while ( beg < paramStr.Length() )
|
||||
{
|
||||
end = beg-1;
|
||||
while ( ++end < paramStr.Length() )
|
||||
if ( pParams[end] == ':' || pParams[end] == '|')
|
||||
break;
|
||||
if ( end < paramStr.Length())
|
||||
{
|
||||
sep = pParams[end];
|
||||
pParams[end] = '\0';
|
||||
}
|
||||
if ( aStudy->IsVariable( pParams+beg ))
|
||||
anInputParams += pParams+beg;
|
||||
if ( end < paramStr.Length() )
|
||||
anInputParams += sep;
|
||||
else
|
||||
break;
|
||||
beg = end + 1;
|
||||
}
|
||||
}
|
||||
return CORBA::string_dup(anInputParams.ToCString());
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject)
|
||||
{
|
||||
TCollection_AsciiString aResult;
|
||||
|
||||
SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
|
||||
SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject);
|
||||
|
||||
if(!aStudy->_is_nil() &&
|
||||
!CORBA::is_nil(theObject) &&
|
||||
!aSObj->_is_nil()){
|
||||
|
||||
SALOMEDS::GenericAttribute_var anAttr;
|
||||
if ( aSObj->FindAttribute(anAttr, "AttributeString")) {
|
||||
aResult = TCollection_AsciiString(SALOMEDS::AttributeString::_narrow(anAttr)->Value());
|
||||
}
|
||||
}
|
||||
|
||||
return CORBA::string_dup( aResult.ToCString() );
|
||||
}
|
||||
|
@ -144,8 +144,10 @@ bool SMESH_Hypothesis_i::IsPublished(){
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
|
||||
//void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
|
||||
void SMESH_Hypothesis_i::SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters )
|
||||
{
|
||||
/*
|
||||
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
|
||||
char * aParameters = CORBA::string_dup(theParameters);
|
||||
if(gen){
|
||||
@ -156,6 +158,7 @@ void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
|
||||
myBaseImpl->SetParameters(gen->ParseParameters(aParameters));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -164,8 +167,10 @@ void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
char* SMESH_Hypothesis_i::GetParameters()
|
||||
//char* SMESH_Hypothesis_i::GetParameters()
|
||||
SALOME::StringArray* SMESH_Hypothesis_i::GetParameters()
|
||||
{
|
||||
/*
|
||||
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
|
||||
char* aResult;
|
||||
if(IsPublished()) {
|
||||
@ -177,64 +182,8 @@ char* SMESH_Hypothesis_i::GetParameters()
|
||||
aResult = myBaseImpl->GetParameters();
|
||||
}
|
||||
return CORBA::string_dup(aResult);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SMESH_Hypothesis_i::GetLastParameters()
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
SMESH::ListOfParameters* SMESH_Hypothesis_i::GetLastParameters()
|
||||
{
|
||||
SMESH::ListOfParameters_var aResult = new SMESH::ListOfParameters();
|
||||
/* ouv: temporarily disabled
|
||||
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
|
||||
if(gen) {
|
||||
char *aParameters;
|
||||
if(IsPublished())
|
||||
aParameters = GetParameters();
|
||||
else
|
||||
aParameters = myBaseImpl->GetLastParameters();
|
||||
|
||||
SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy();
|
||||
if(!aStudy->_is_nil()) {
|
||||
SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
|
||||
if(aSections->length() > 0) {
|
||||
SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1];
|
||||
aResult->length(aVars.length());
|
||||
for(int i = 0;i < aVars.length();i++)
|
||||
aResult[i] = CORBA::string_dup( aVars[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return aResult._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SMESH_Hypothesis_i::SetLastParameters()
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void SMESH_Hypothesis_i::SetLastParameters(const char* theParameters)
|
||||
{
|
||||
if(!IsPublished()) {
|
||||
myBaseImpl->SetLastParameters(theParameters);
|
||||
}
|
||||
}
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SMESH_Hypothesis_i::ClearParameters()
|
||||
*
|
||||
*/
|
||||
//=============================================================================
|
||||
void SMESH_Hypothesis_i::ClearParameters()
|
||||
{
|
||||
if(!IsPublished()) {
|
||||
myBaseImpl->ClearParameters();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -65,21 +65,11 @@ public:
|
||||
// Get unique id of hypothesis
|
||||
CORBA::Long GetId();
|
||||
|
||||
// Set list of parameters separated by ":" symbol, used for Hypothesis creation
|
||||
void SetParameters (const char* theParameters);
|
||||
// Set list of parameters, used for Hypothesis creation
|
||||
virtual void SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters );
|
||||
|
||||
// Return list of notebook variables used for Hypothesis creation separated by ":" symbol
|
||||
char* GetParameters();
|
||||
|
||||
//Return list of last notebook variables used for Hypothesis creation.
|
||||
SMESH::ListOfParameters* GetLastParameters();
|
||||
|
||||
//Set last parameters for not published hypothesis
|
||||
|
||||
void SetLastParameters(const char* theParameters);
|
||||
|
||||
// Clear parameters list
|
||||
void ClearParameters();
|
||||
// Return list of notebook variables used for Hypothesis creation
|
||||
virtual SALOME::StringArray* GetParameters();
|
||||
|
||||
//Return true if hypothesis was published in study
|
||||
bool IsPublished();
|
||||
|
@ -3383,10 +3383,8 @@ void SMESH_Mesh_i::checkGroupNames()
|
||||
* \brief Sets list of notebook variables used for Mesh operations separated by ":" symbol
|
||||
*/
|
||||
//=============================================================================
|
||||
void SMESH_Mesh_i::SetParameters(const char* theParameters)
|
||||
void SMESH_Mesh_i::SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters )
|
||||
{
|
||||
SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Mesh::_narrow(_this()),
|
||||
CORBA::string_dup(theParameters));
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -3394,37 +3392,9 @@ void SMESH_Mesh_i::SetParameters(const char* theParameters)
|
||||
* \brief Returns list of notebook variables used for Mesh operations separated by ":" symbol
|
||||
*/
|
||||
//=============================================================================
|
||||
char* SMESH_Mesh_i::GetParameters()
|
||||
SALOME::StringArray* SMESH_Mesh_i::GetParameters()
|
||||
{
|
||||
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
|
||||
return CORBA::string_dup(gen->GetParameters(SMESH::SMESH_Mesh::_narrow(_this())));
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* \brief Returns list of notebook variables used for last Mesh operation
|
||||
*/
|
||||
//=============================================================================
|
||||
SMESH::string_array* SMESH_Mesh_i::GetLastParameters()
|
||||
{
|
||||
SMESH::string_array_var aResult = new SMESH::string_array();
|
||||
/* ouv: temporarily disabled
|
||||
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
|
||||
if(gen) {
|
||||
char *aParameters = GetParameters();
|
||||
SALOMEDS::Study_ptr aStudy = gen->GetCurrentStudy();
|
||||
if(!aStudy->_is_nil()) {
|
||||
SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
|
||||
if(aSections->length() > 0) {
|
||||
SALOMEDS::ListOfStrings aVars = aSections[aSections->length()-1];
|
||||
aResult->length(aVars.length());
|
||||
for(int i = 0;i < aVars.length();i++)
|
||||
aResult[i] = CORBA::string_dup( aVars[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return aResult._retn();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -472,20 +472,14 @@ public:
|
||||
virtual SALOME_MED::MedFileInfo* GetMEDFileInfo();
|
||||
|
||||
/*!
|
||||
* Sets list of notebook variables used for Mesh operations separated by ":" symbol
|
||||
* Sets list of notebook variables used for Mesh operations
|
||||
*/
|
||||
void SetParameters (const char* theParameters);
|
||||
virtual void SetParameters( SALOME::Notebook_ptr theNotebook, const SALOME::StringArray& theParameters );
|
||||
|
||||
/*!
|
||||
* Returns list of notebook variables used for Mesh operations separated by ":" symbol
|
||||
* Returns list of notebook variables used for Mesh operations
|
||||
*/
|
||||
char* GetParameters();
|
||||
|
||||
/*!
|
||||
* Returns list of notebook variables used for last Mesh operation
|
||||
*/
|
||||
SMESH::string_array* GetLastParameters();
|
||||
|
||||
virtual SALOME::StringArray* GetParameters();
|
||||
|
||||
/*!
|
||||
* Returns statistic of mesh elements
|
||||
|
Loading…
x
Reference in New Issue
Block a user