Implementation notebook in the SMESH module.

This commit is contained in:
rnv 2008-11-28 10:30:11 +00:00
parent 490a83efa8
commit 882884f679
12 changed files with 442 additions and 112 deletions

View File

@ -51,6 +51,7 @@ 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();
}
//=============================================================================
@ -150,3 +151,23 @@ void SMESH_Hypothesis::SetLibName(const char* theLibName)
{
_libName = string(theLibName);
}
//=============================================================================
/*!
*
*/
//=============================================================================
void SMESH_Hypothesis::SetParameters(const char *theParameters)
{
_parameters = string(theParameters);
}
//=============================================================================
/*!
*
*/
//=============================================================================
char* SMESH_Hypothesis::GetParameters() const
{
return (char*)_parameters.c_str();
}

View File

@ -70,6 +70,9 @@ public:
virtual const char* GetLibName() const;
void SetLibName(const char* theLibName);
void SetParameters(const char *theParameters);
char* GetParameters() const;
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
* \param theMesh - the built mesh
@ -97,6 +100,7 @@ protected:
private:
std::string _libName;
std::string _parameters;
};
#endif

View File

@ -125,15 +125,30 @@ SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScript,
{
theGen = new _pyGen( theEntry2AccessorMethod );
SMESH_NoteBook * aNoteBook = new SMESH_NoteBook( theGen );
SMESH_NoteBook * aNoteBook = new SMESH_NoteBook();
// split theScript into separate commands
int from = 1, end = theScript.Length(), to;
while ( from < end && ( to = theScript.Location( "\n", from, end )))
{
if ( to != from )
// cut out and store a command
aNoteBook->AddCommand( theScript.SubString( from, to - 1 ));
from = to + 1;
}
aNoteBook->ReplaceVariables();
TCollection_AsciiString aNoteScript = aNoteBook->GetResultScript();
delete aNoteBook;
aNoteBook = 0;
// split theScript into separate commands
from = 1, end = aNoteScript.Length();
while ( from < end && ( to = aNoteScript.Location( "\n", from, end )))
{
if ( to != from )
// cut out and store a command
theGen->AddCommand( aNoteBook->ReplaceVariables(theScript.SubString( from, to - 1 )));
theGen->AddCommand( aNoteScript.SubString( from, to - 1 ));
from = to + 1;
}
// finish conversion

View File

@ -186,7 +186,6 @@ public:
bool AddMeshAccessorMethod( Handle(_pyCommand) theCmd ) const;
bool AddAlgoAccessorMethod( Handle(_pyCommand) theCmd ) const;
const char* AccessorMethod() const;
const std::map< _pyID, Handle(_pyMeshEditor) >& getMeshEditors() const { return myMeshEditors; }
private:
std::map< _pyID, Handle(_pyMesh) > myMeshes;
std::map< _pyID, Handle(_pyMeshEditor) > myMeshEditors;

View File

@ -472,6 +472,7 @@ public:
void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters);
char* GetParameters(CORBA::Object_ptr theObject);
char* ParseParameters(const char* theParameters);
private:

View File

@ -876,32 +876,47 @@ void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theP
SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject);
if(aSObj->_is_nil())
return;
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
TCollection_AsciiString aNewParams;
TCollection_AsciiString anInputParams;
SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(theParameters);
SALOMEDS::GenericAttribute_var anAttr;
anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
TCollection_AsciiString aNewParams;
TCollection_AsciiString aOldParameters(aStringAttr->Value());
SALOMEDS::ListOfStrings aVars= aSections[0];
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+=":";
}
TCollection_AsciiString anInputParams(ParseParameters(theParameters));
if(!aOldParameters.Length())
aNewParams = anInputParams;
else
aNewParams = aOldParameters+"|"+anInputParams;
aStringAttr->SetValue( aNewParams.ToCString() );
}
//=======================================================================
//function : GetParameters
//purpose :
//=======================================================================
char* SMESH_Gen_i::ParseParameters(const char* theParameters)
{
const char* aParameters = CORBA::string_dup(theParameters);
TCollection_AsciiString anInputParams;
SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
if( !aStudy->_is_nil() ) {
SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
if(aSections->length() > 0) {
SALOMEDS::ListOfStrings aVars= aSections[0];
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+=":";
}
}
}
return CORBA::string_dup(anInputParams.ToCString());
}
//=======================================================================
//function : GetParameters

View File

@ -122,6 +122,23 @@ CORBA::Long SMESH_Hypothesis_i::GetId()
return myBaseImpl->GetID();
}
//=============================================================================
/*!
* SMESH_Hypothesis_i::IsPublished()
*
*/
//=============================================================================
bool SMESH_Hypothesis_i::IsPublished(){
bool res = false;
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
if(gen){
SALOMEDS::SObject_var SO =
SMESH_Gen_i::ObjectToSObject(gen->GetCurrentStudy() , SMESH::SMESH_Hypothesis::_narrow(_this()));
res = !SO->_is_nil();
}
return res;
}
//=============================================================================
/*!
* SMESH_Hypothesis_i::SetParameters()
@ -130,8 +147,16 @@ CORBA::Long SMESH_Hypothesis_i::GetId()
//=============================================================================
void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
{
SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),
CORBA::string_dup(theParameters));
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
char * aParameters = CORBA::string_dup(theParameters);
if(gen){
if(IsPublished()) {
SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),aParameters);
}
else {
myBaseImpl->SetParameters(gen->ParseParameters(aParameters));
}
}
}
//=============================================================================
@ -143,7 +168,16 @@ void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
char* SMESH_Hypothesis_i::GetParameters()
{
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
return CORBA::string_dup(gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this())));
char* aResult;
if(IsPublished()) {
MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get Parameters from SObject");
aResult = gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this()));
}
else {
MESSAGE("SMESH_Hypothesis_i::GetParameters() : Get local parameters");
aResult = myBaseImpl->GetParameters();
}
return CORBA::string_dup(aResult);
}
//=============================================================================

View File

@ -65,7 +65,7 @@ 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);
@ -74,7 +74,10 @@ public:
//Return list of last notebook variables used for Hypothesis creation.
SMESH::ListOfParameters* GetLastParameters();
//Return true if hypothesis was published in study
bool IsPublished();
// Get implementation
::SMESH_Hypothesis* GetImpl();

View File

@ -33,9 +33,9 @@
#include <string>
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
static int MYDEBUG = 1;
#endif
using namespace std;
@ -114,13 +114,79 @@ TCollection_AsciiString ObjectStates::GetObjectType() const{
return _type;
}
//================================================================================
/*!
* \brief Constructor
*/
//================================================================================
SMESH_NoteBook::SMESH_NoteBook(Handle(_pyGen) theGen):
myGen( theGen )
LayerDistributionStates::LayerDistributionStates():
ObjectStates("LayerDistribution")
{
}
//================================================================================
/*!
* \brief Destructor
*/
//================================================================================
LayerDistributionStates::~LayerDistributionStates()
{
}
//================================================================================
/*!
* \brief AddDistribution
*/
//================================================================================
void LayerDistributionStates::AddDistribution(const TCollection_AsciiString& theDistribution)
{
_distributions.insert(pair<TCollection_AsciiString,TCollection_AsciiString>(theDistribution,""));
}
//================================================================================
/*!
* \brief HasDistribution
*/
//================================================================================
bool LayerDistributionStates::HasDistribution(const TCollection_AsciiString& theDistribution) const
{
return _distributions.find(theDistribution) != _distributions.end();
}
//================================================================================
/*!
* \brief SetDistributionType
*/
//================================================================================
bool LayerDistributionStates::SetDistributionType(const TCollection_AsciiString& theDistribution,
const TCollection_AsciiString& theType)
{
TDistributionMap::iterator it = _distributions.find(theDistribution);
if(it == _distributions.end())
return false;
(*it).second = theType;
return true;
}
//================================================================================
/*!
* \brief GetDistributionType
*/
//================================================================================
TCollection_AsciiString LayerDistributionStates::
GetDistributionType(const TCollection_AsciiString& theDistribution) const
{
TDistributionMap::const_iterator it = _distributions.find(theDistribution);
return (it == _distributions.end()) ? TCollection_AsciiString() : (*it).second;
}
//================================================================================
/*!
* \brief Constructor
*/
//================================================================================
SMESH_NoteBook::SMESH_NoteBook()
{
InitObjectMap();
}
@ -146,82 +212,99 @@ SMESH_NoteBook::~SMESH_NoteBook()
* \retval TCollection_AsciiString - Convertion result
*/
//================================================================================
TCollection_AsciiString SMESH_NoteBook::ReplaceVariables(const TCollection_AsciiString& theString) const
void SMESH_NoteBook::ReplaceVariables()
{
_pyCommand aCmd( theString, -1);
TCollection_AsciiString aMethod = aCmd.GetMethod();
TCollection_AsciiString aObject = aCmd.GetObject();
TCollection_AsciiString aResultValue = aCmd.GetResultValue();
if(aMethod.IsEmpty())
return theString;
// check if method modifies the object itself
TVariablesMap::const_iterator it = _objectMap.find(aObject);
if(it == _objectMap.end()) // check if method returns a new object
it = _objectMap.find(aResultValue);
if(it == _objectMap.end()) { // check if method modifies a mesh using mesh editor
const std::map< _pyID, Handle(_pyMeshEditor) >& aMeshEditors = myGen->getMeshEditors();
std::map< _pyID, Handle(_pyMeshEditor) >::const_iterator meIt = aMeshEditors.find(aObject);
if(meIt != aMeshEditors.end()) {
Handle(_pyMeshEditor) aMeshEditor = (*meIt).second;
if(!aMeshEditor.IsNull()) {
Handle(_pyCommand) aCreationCommand = aMeshEditor->GetCreationCmd();
if(!aCreationCommand.IsNull()) {
TCollection_AsciiString aMesh = aCreationCommand->GetObject();
it = _objectMap.find(aMesh);
}
for(int i=0;i<_commands.size();i++) {
Handle(_pyCommand) aCmd = _commands[i];
TCollection_AsciiString aMethod = aCmd->GetMethod();
TCollection_AsciiString aObject = aCmd->GetObject();
TCollection_AsciiString aResultValue = aCmd->GetResultValue();
if(MYDEBUG) {
cout<<"Command before : "<< aCmd->GetString()<<endl;
cout<<"Method : "<< aMethod<<endl;
cout<<"Object : "<< aObject<<endl;
cout<<"Result : "<< aResultValue<<endl;
}
// check if method modifies the object itself
TVariablesMap::const_iterator it = _objectMap.find(aObject);
if(it == _objectMap.end()) // check if method returns a new object
it = _objectMap.find(aResultValue);
if(it == _objectMap.end()) { // check if method modifies a mesh using mesh editor
TMeshEditorMap::const_iterator meIt = myMeshEditors.find(aObject);
if(meIt != myMeshEditors.end()) {
TCollection_AsciiString aMesh = (*meIt).second;
it = _objectMap.find(aMesh);
}
}
if(it != _objectMap.end() && !aMethod.IsEmpty()) {
ObjectStates *aStates = (*it).second;
// Case for LocalLength hypothesis
if(aStates->GetObjectType().IsEqual("LocalLength")) {
if(aMethod.IsEqual("SetLength")) {
if(!aStates->GetCurrectState().at(0).IsEmpty() )
aCmd->SetArg(1,aStates->GetCurrectState().at(0));
aStates->IncrementState();
}
else if(aMethod.IsEqual("SetPrecision")) {
if(!aStates->GetCurrectState().at(1).IsEmpty() )
aCmd->SetArg(1,aStates->GetCurrectState().at(1));
aStates->IncrementState();
}
}
// Case for SegmentLengthAroundVertex hypothesis
else if(aStates->GetObjectType().IsEqual("SegmentLengthAroundVertex")) {
if(aMethod == "SetLength") {
if(!aStates->GetCurrectState().at(0).IsEmpty() )
aCmd->SetArg(1,aStates->GetCurrectState().at(0));
aStates->IncrementState();
}
}
// Case for LayerDistribution hypothesis (not finished yet)
else if(aStates->GetObjectType() == "LayerDistribution") {
if(aMethod == "SetLayerDistribution"){
LayerDistributionStates* aLDStates = (LayerDistributionStates*)(aStates);
aLDStates->AddDistribution(aCmd->GetArg(1));
}
}
else if(aStates->GetObjectType().IsEqual("Mesh")) {
if(aMethod.IsEqual("Translate") ||
aMethod.IsEqual("TranslateMakeGroups") ||
aMethod.IsEqual("TranslateMakeMesh")) {
bool isVariableFound = false;
int anArgIndex = 0;
for(int i = 1, n = aCmd->GetNbArgs(); i <= n; i++) {
if(aCmd->GetArg(i).IsEqual("SMESH.PointStruct")) {
anArgIndex = i+1;
break;
}
}
if(anArgIndex > 0) {
for(int j = 0; j <= 2; j++) {
if(!aStates->GetCurrectState().at(j).IsEmpty()) {
isVariableFound = true;
aCmd->SetArg(anArgIndex+j, aStates->GetCurrectState().at(j));
}
}
}
if(isVariableFound) {
aCmd->SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr");
aCmd->SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr");
}
aStates->IncrementState();
}
}
}
if(MYDEBUG) {
cout<<"Command after: "<< aCmd->GetString()<<endl;
}
}
if(it != _objectMap.end()) {
ObjectStates *aStates = (*it).second;
if(MYDEBUG)
cout<<"SMESH_NoteBook::ReplaceVariables :Object Type : "<<aStates->GetObjectType()<<endl;
if(aStates->GetObjectType().IsEqual("LocalLength")) {
if(aMethod.IsEqual("SetLength")) {
if(!aStates->GetCurrectState().at(0).IsEmpty() )
aCmd.SetArg(1,aStates->GetCurrectState().at(0));
aStates->IncrementState();
}
else if(aMethod.IsEqual("SetPrecision")) {
if(!aStates->GetCurrectState().at(1).IsEmpty() )
aCmd.SetArg(1,aStates->GetCurrectState().at(1));
aStates->IncrementState();
}
}
else if(aStates->GetObjectType().IsEqual("Mesh")) {
if(aMethod.IsEqual("Translate") ||
aMethod.IsEqual("TranslateMakeGroups") ||
aMethod.IsEqual("TranslateMakeMesh")) {
bool isVariableFound = false;
int anArgIndex = 0;
for(int i = 1, n = aCmd.GetNbArgs(); i <= n; i++) {
if(aCmd.GetArg(i).IsEqual("SMESH.PointStruct")) {
anArgIndex = i+1;
break;
}
}
if(anArgIndex > 0) {
for(int j = 0; j <= 2; j++) {
if(!aStates->GetCurrectState().at(j).IsEmpty()) {
isVariableFound = true;
aCmd.SetArg(anArgIndex+j, aStates->GetCurrectState().at(j));
}
}
}
if(isVariableFound) {
aCmd.SetArg(anArgIndex - 1, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".PointStructStr");
aCmd.SetArg(anArgIndex - 2, TCollection_AsciiString(SMESH_2smeshpy::SmeshpyName())+".DirStructStr");
}
aStates->IncrementState();
}
}
return aCmd.GetString();
}
return theString;
// ProcessLayerDistribution();
}
//================================================================================
/*!
@ -265,8 +348,12 @@ void SMESH_NoteBook::InitObjectMap()
}
if(MYDEBUG)
cout<<"The object Type : "<<anObjType<<endl;
ObjectStates *aState = NULL;
if(anObjType == "LayerDistribution")
aState = new LayerDistributionStates();
else
aState = new ObjectStates(anObjType);
ObjectStates *aState = new ObjectStates(anObjType);
for(int i = 0; i < aSections->length(); i++) {
TState aVars;
SALOMEDS::ListOfStrings aListOfVars = aSections[i];
@ -287,3 +374,84 @@ void SMESH_NoteBook::InitObjectMap()
}
}
}
//================================================================================
/*!
*
*/
//================================================================================
void SMESH_NoteBook::AddCommand(const TCollection_AsciiString& theString)
{
Handle(_pyCommand) aCommand = new _pyCommand( theString, -1);
_commands.push_back(aCommand);
if ( aCommand->GetMethod() == "GetMeshEditor" ) { // MeshEditor creation
myMeshEditors.insert( make_pair( aCommand->GetResultValue(),
aCommand->GetObject() ) );
}
}
//================================================================================
/*!
*
*/
//================================================================================
void SMESH_NoteBook::ProcessLayerDistribution()
{
// 1) Find all LayerDistribution states
vector<LayerDistributionStates*> aLDS;
TVariablesMap::const_iterator it = _objectMap.begin();
for(;it != _objectMap.end();it++)
if(LayerDistributionStates* aLDStates = (LayerDistributionStates*)((*it).second)) {
aLDS.push_back(aLDStates);
}
// 2) Initialize all type of 1D Distribution hypothesis
for(int i=0;i<_commands.size();i++){
for(int j =0;j < aLDS.size();j++){
TCollection_AsciiString aResultValue = _commands[i]->GetResultValue();
if(_commands[i]->GetMethod() == "CreateHypothesis" &&
aLDS[j]->HasDistribution(aResultValue)){
TCollection_AsciiString aType = _commands[i]->GetArg(1);
aType.RemoveAll('\'');
aLDS[j]->SetDistributionType(aResultValue,aType);
}
}
}
// 3) ... and replase variables ...
for(int i=0;i<_commands.size();i++){
for(int j =0;j < aLDS.size();j++){
TCollection_AsciiString anObject = _commands[i]->GetObject();
if(aLDS[j]->HasDistribution(anObject)) {
TCollection_AsciiString aType = aLDS[j]->GetDistributionType(anObject);
TCollection_AsciiString aMethod = _commands[i]->GetMethod();
if(aType == "LocalLength") {
if(aMethod == "SetLength") {
if(!aLDS[j]->GetCurrectState().at(0).IsEmpty() )
_commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(0));
aLDS[j]->IncrementState();
}
else if(aMethod == "SetPrecision") {
if(!aLDS[j]->GetCurrectState().at(1).IsEmpty() )
_commands[i]->SetArg(1,aLDS[j]->GetCurrectState().at(1));
aLDS[j]->IncrementState();
}
}
}
}
}
}
//================================================================================
/*!
* \brief Return result script
*/
//================================================================================
TCollection_AsciiString SMESH_NoteBook::GetResultScript() const
{
TCollection_AsciiString aResult;
for(int i=0;i<_commands.size();i++)
aResult+=_commands[i]->GetString()+"\n";
return aResult;
}

View File

@ -26,12 +26,15 @@
#include <TCollection_AsciiString.hxx>
#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
class _pyCommand;
#include <vector>
#include <string>
typedef std::vector<TCollection_AsciiString> TState;
typedef std::vector<TState> TAllStates;
typedef TCollection_AsciiString _pyID;
class ObjectStates{
@ -55,21 +58,47 @@ private:
int _dumpstate;
};
class LayerDistributionStates : public ObjectStates
{
public:
typedef std::map<TCollection_AsciiString,TCollection_AsciiString> TDistributionMap;
LayerDistributionStates();
~LayerDistributionStates();
void AddDistribution(const TCollection_AsciiString& theDistribution);
bool HasDistribution(const TCollection_AsciiString& theDistribution) const;
bool SetDistributionType(const TCollection_AsciiString& theDistribution,
const TCollection_AsciiString& theType);
TCollection_AsciiString GetDistributionType(const TCollection_AsciiString& theDistribution) const;
private:
TDistributionMap _distributions;
};
class SMESH_NoteBook
{
public:
SMESH_NoteBook(Handle(_pyGen) theGen);
~SMESH_NoteBook();
TCollection_AsciiString ReplaceVariables(const TCollection_AsciiString& theString) const;
typedef std::map<TCollection_AsciiString,ObjectStates*> TVariablesMap;
typedef std::map<TCollection_AsciiString,TCollection_AsciiString> TMeshEditorMap;
SMESH_NoteBook();
~SMESH_NoteBook();
void ReplaceVariables();
void AddCommand(const TCollection_AsciiString& theString);
TCollection_AsciiString GetResultScript() const;
private:
void InitObjectMap();
void ProcessLayerDistribution();
private:
TVariablesMap _objectMap;
Handle(_pyGen) myGen;
std::vector<Handle(_pyCommand)> _commands;
TMeshEditorMap myMeshEditors;
};
#endif //SMESH_NoteBook_HeaderFile

View File

@ -4093,13 +4093,18 @@ def ParseParameters(last, nbParams,nbParam, value):
counter = counter+1
return result, strResult
#Wrapper class for StdMeshers_LocalLength hypothesis
class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
## Set length parameter value
# @param length numerical value or name of variable from notebook
def SetLength(self, length):
length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
## Set precision parameter value
# @param precision numerical value or name of variable from notebook
def SetPrecision(self, precision):
precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
@ -4107,3 +4112,18 @@ class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
#Registering the new proxy for LocalLength
omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
#Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
parent = StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex
## Set length parameter value
# @param length numerical value or name of variable from notebook
def SetLength(self, length):
length,parameters = ParseParameters(parent.GetLastParameters(self),1,1,length)
parent.SetParameters(self,parameters)
parent.SetLength(self,length)
#Registering the new proxy for LocalLength
omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, LocalLength)

View File

@ -421,6 +421,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
h->SetLength( params[0].myValue.toDouble() );
h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList));
}
else if( hypType()=="Arithmetic1D" )
{
@ -479,8 +480,12 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() );
StdMeshersGUI_LayerDistributionParamWdg* w =
widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
h->SetLayerDistribution( w->GetHypothesis() );
/* h->SetParameters(w->GetHypothesis()->GetParameters());
if(QString(w->GetHypothesis()->GetName()) == "LocalLength")
h->SetParameters(w->GetHypothesis()->GetParameters());
*/
}
else if( hypType()=="ProjectionSource1D" )
{
@ -552,16 +557,17 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
}
SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
QString aVaribaleName;
if( hypType()=="LocalLength" )
{
StdMeshers::StdMeshers_LocalLength_var h =
StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
QString aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
item.isVariable = !aVaribaleName.isEmpty();
if(item.isVariable)
item.myValue = aVaribaleName;
@ -583,9 +589,15 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
{
StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hyp );
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
item.myValue = h->GetLength();
aVaribaleName = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString("");
item.isVariable = !aVaribaleName.isEmpty();
if(item.isVariable)
item.myValue = aVaribaleName;
else
item.myValue = h->GetLength();
p.append( item );
}
else if( hypType()=="Arithmetic1D" )
@ -660,11 +672,20 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
p.append( item );
}
else if( hypType()=="LayerDistribution" )
{
StdMeshers::StdMeshers_LayerDistribution_var h =
{
StdMeshers::StdMeshers_LayerDistribution_var h =
StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp );
item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item );
//Set into not published hypo last variables
/* QStringList aLastVarsList;
for(int i = 0;i<aParameters->length();i++)
aLastVarsList.append(QString(aParameters[i].in()));
if(!aLastVarsList.isEmpty())
h->GetLayerDistribution()->SetParameters(SMESHGUI::JoinObjectParameters(aLastVarsList));
*/
customWidgets()->append
( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), hypName(), dlg()));
}