0021557: EDF 2161 SMESH: Duplicate elements and nodes

1) Convert DoubleNodeElemGroup2New()
2) Fix  _pyCommand::GetResultValue(int res);
3) Add _pyGroup::Flush() to prevent clearing "DoubleNode...() command if a group created by it is removed
This commit is contained in:
eap 2012-04-26 07:05:13 +00:00
parent de9006cf44
commit d6352114af
2 changed files with 53 additions and 21 deletions

View File

@ -511,7 +511,10 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
method == "DoubleNodeGroupNew" || method == "DoubleNodeGroupNew" ||
method == "DoubleNodeGroupsNew" || method == "DoubleNodeGroupsNew" ||
method == "DoubleNodeElemGroupNew" || method == "DoubleNodeElemGroupNew" ||
method == "DoubleNodeElemGroupsNew" ) method == "DoubleNodeElemGroupsNew"||
method == "DoubleNodeElemGroup2New"||
method == "DoubleNodeElemGroups2New"
)
groups = aCommand->GetResultValue(); groups = aCommand->GetResultValue();
else if ( method == "MakeBoundaryMesh" ) else if ( method == "MakeBoundaryMesh" )
groups = aCommand->GetResultValue(2); groups = aCommand->GetResultValue(2);
@ -718,7 +721,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
{ {
for(int ind = 0;ind<theCommand->GetNbResultValues();ind++) for(int ind = 0;ind<theCommand->GetNbResultValues();ind++)
{ {
const _pyID& meshID = theCommand->GetResultValue(ind+1); _pyID meshID = theCommand->GetResultValue(ind+1);
if ( !theCommand->IsStudyEntry( meshID ) ) continue; if ( !theCommand->IsStudyEntry( meshID ) ) continue;
Handle(_pyMesh) mesh = new _pyMesh( theCommand, theCommand->GetResultValue(ind+1)); Handle(_pyMesh) mesh = new _pyMesh( theCommand, theCommand->GetResultValue(ind+1));
myMeshes.insert( make_pair( mesh->GetID(), mesh )); myMeshes.insert( make_pair( mesh->GetID(), mesh ));
@ -1962,18 +1965,29 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
isPyMeshMethod=true; isPyMeshMethod=true;
theCommand->SetMethod("FindCoincidentNodesOnPart"); theCommand->SetMethod("FindCoincidentNodesOnPart");
} }
// DoubleNodeElemGroupNew() -> DoubleNodeElemGroup() // DoubleNode...New(...) -> DoubleNode...(...,True)
// DoubleNodeGroupNew() -> DoubleNodeGroup()
// DoubleNodeGroupsNew() -> DoubleNodeGroups()
// DoubleNodeElemGroupsNew() -> DoubleNodeElemGroups()
if ( !isPyMeshMethod && ( method == "DoubleNodeElemGroupNew" || if ( !isPyMeshMethod && ( method == "DoubleNodeElemGroupNew" ||
method == "DoubleNodeElemGroupsNew" || method == "DoubleNodeElemGroupsNew" ||
method == "DoubleNodeGroupNew" || method == "DoubleNodeGroupNew" ||
method == "DoubleNodeGroupsNew")) method == "DoubleNodeGroupsNew" ||
method == "DoubleNodeElemGroup2New" ||
method == "DoubleNodeElemGroups2New"))
{ {
isPyMeshMethod=true; isPyMeshMethod=true;
theCommand->SetMethod( method.SubString( 1, method.Length()-3)); const int excessLen = 3 + int( method.Value( method.Length()-3 ) == '2' );
theCommand->SetArg(theCommand->GetNbArgs()+1,"True"); theCommand->SetMethod( method.SubString( 1, method.Length()-excessLen));
if ( excessLen == 3 )
{
theCommand->SetArg(theCommand->GetNbArgs()+1,"True");
}
else if ( theCommand->GetArg(4) == "0" ||
theCommand->GetArg(5) == "0" )
{
// [ nothing, Group ] = DoubleNodeGroup2New(,,,False, True) ->
// Group = DoubleNodeGroup2New(,,,False, True)
_pyID groupID = theCommand->GetResultValue( 1 + int( theCommand->GetArg(4) == "0"));
theCommand->SetResultValue( groupID );
}
} }
// ConvertToQuadraticObject(bool,obj) -> ConvertToQuadratic(bool,obj) // ConvertToQuadraticObject(bool,obj) -> ConvertToQuadratic(bool,obj)
// ConvertFromQuadraticObject(obj) -> ConvertFromQuadratic(obj) // ConvertFromQuadraticObject(obj) -> ConvertFromQuadratic(obj)
@ -3027,22 +3041,25 @@ const int _pyCommand::GetNbResultValues()
//================================================================================ //================================================================================
/*! /*!
* \brief Return substring of python command looking like * \brief Return substring of python command looking like
* ResultValue1 , ResultValue1,... = Obj.Meth() with res index * ResultValue1 , ResultValue2,... = Obj.Meth() with res index
* \retval const TCollection_AsciiString & - ResultValue with res index substring * \retval const TCollection_AsciiString & - ResultValue with res index substring
*/ */
//================================================================================ //================================================================================
const TCollection_AsciiString & _pyCommand::GetResultValue(int res) TCollection_AsciiString _pyCommand::GetResultValue(int res)
{ {
int begPos = 1; int begPos = 1;
int Nb=0; if ( SkipSpaces( myString, begPos ) && myString.Value( begPos ) == '[' )
++begPos; // skip [, else the whole list is returned
int endPos = myString.Location( "=", 1, Length() ); int endPos = myString.Location( "=", 1, Length() );
int Nb=0;
while ( begPos < endPos) { while ( begPos < endPos) {
myRes = GetWord( myString, begPos, true ); _AString result = GetWord( myString, begPos, true );
begPos = begPos + myRes.Length(); begPos = begPos + result.Length();
Nb++; Nb++;
if(res == Nb){ if(res == Nb) {
myRes.RemoveAll('[');myRes.RemoveAll(']'); result.RemoveAll('[');
return myRes; result.RemoveAll(']');
return result;
} }
if(Nb>res) if(Nb>res)
break; break;
@ -3350,8 +3367,6 @@ std::list< _pyID > _pyCommand::GetStudyEntries( const TCollection_AsciiString& s
* \param theString - The string * \param theString - The string
* \param thePos - The position to search from and which returns result * \param thePos - The position to search from and which returns result
* \retval bool - false if there are only space after thePos in theString * \retval bool - false if there are only space after thePos in theString
*
*
*/ */
//================================================================================ //================================================================================
@ -3803,6 +3818,23 @@ void _pyGroup::Process( const Handle(_pyCommand)& theCommand)
theGen->AddMeshAccessorMethod( theCommand ); theGen->AddMeshAccessorMethod( theCommand );
} }
//================================================================================
/*!
* \brief Prevent clearing "DoubleNode...() command if a group created by it is removed
*
*
*/
//================================================================================
void _pyGroup::Flush()
{
if ( !theGen->IsToKeepAllCommands() &&
myCreationCmd && myCreationCmd->MethodStartsFrom("DoubleNode") )
{
myCreationCmd.Nullify();
}
}
//================================================================================ //================================================================================
/*! /*!
* \brief Constructor of _pyFilter * \brief Constructor of _pyFilter

View File

@ -123,7 +123,7 @@ public:
_AString GetIndentation(); _AString GetIndentation();
const _AString & GetResultValue(); const _AString & GetResultValue();
const int GetNbResultValues(); const int GetNbResultValues();
const _AString & GetResultValue(int res); _AString GetResultValue(int res);
const _AString & GetObject(); const _AString & GetObject();
const _AString & GetMethod(); const _AString & GetMethod();
const _AString & GetArg( int index ); const _AString & GetArg( int index );
@ -582,7 +582,7 @@ class _pyGroup: public _pySubMesh
public: public:
_pyGroup(const Handle(_pyCommand)& theCreationCmd, const _pyID & id=_pyID()); _pyGroup(const Handle(_pyCommand)& theCreationCmd, const _pyID & id=_pyID());
virtual void Process( const Handle(_pyCommand)& theCommand); virtual void Process( const Handle(_pyCommand)& theCommand);
virtual void Flush() {} virtual void Flush();
virtual void Free() { myFilter.Nullify(); } virtual void Free() { myFilter.Nullify(); }
DEFINE_STANDARD_RTTI (_pyGroup) DEFINE_STANDARD_RTTI (_pyGroup)