0021014: EDF 1583 SMESH: Improvement of the Python Dump for the creation of groups

set a more human readable name to the filter
This commit is contained in:
eap 2011-10-12 18:06:28 +00:00
parent 7133933036
commit fb7637f099
2 changed files with 48 additions and 6 deletions

View File

@ -204,10 +204,11 @@ SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScript,
_pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
Resource_DataMapOfAsciiStringAsciiString& theObjectNames)
: _pyObject( new _pyCommand( TPythonDump::SMESHGenName(), 0 )),
myNbCommands( 0 ),
myID2AccessorMethod( theEntry2AccessorMethod ),
myObjectNames( theObjectNames )
myObjectNames( theObjectNames ),
myNbFilters( 0 )
{
myNbCommands = 0;
// make that GetID() to return TPythonDump::SMESHGenName()
GetCreationCmd()->GetString() += "=";
}
@ -309,7 +310,14 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
// aFilterManager.CreateFilter() ?
if ( aCommand->GetMethod() == "CreateFilter" )
{
Handle(_pyObject) filter( new _pyFilter( aCommand ));
// Set a more human readable name to a filter
// aFilter0x7fbf6c71cfb0 -> aFilter_nb
_pyID newID, filterID = aCommand->GetResultValue();
int pos = filterID.Search( "0x" );
if ( pos > 1 )
newID = (filterID.SubString(1,pos-1) + "_") + _pyID( ++myNbFilters );
Handle(_pyObject) filter( new _pyFilter( aCommand, newID ));
AddObject( filter );
}
@ -1585,6 +1593,9 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
else if ( hypType == "Projection_2D" ) {
algo->SetConvMethodAndType( "Projection2D", hypType.ToCString());
}
else if ( hypType == "Projection_1D2D" ) {
algo->SetConvMethodAndType( "Projection1D2D", hypType.ToCString());
}
else if ( hypType == "ProjectionSource2D" ) {
hyp->SetConvMethodAndType( "SourceFace", "Projection_2D");
hyp->AddArgMethod( "SetSourceFace");
@ -2745,6 +2756,17 @@ void _pyGroup::Process( const Handle(_pyCommand)& theCommand)
}
}
//================================================================================
/*!
* \brief Constructor of _pyFilter
*/
//================================================================================
_pyFilter::_pyFilter(const Handle(_pyCommand)& theCreationCmd, const _pyID& newID/*=""*/)
:_pyObject(theCreationCmd), myNewID( newID )
{
}
//================================================================================
/*!
* \brief To convert creation of a filter by criteria
@ -2753,6 +2775,9 @@ void _pyGroup::Process( const Handle(_pyCommand)& theCommand)
void _pyFilter::Process( const Handle(_pyCommand)& theCommand)
{
if ( !myNewID.IsEmpty() )
theCommand->SetObject( myNewID );
// Convert the following set of commands into smesh.GetFilterFromCriteria(criteria)
// aFilter0x2aaab0487080 = aFilterManager.CreateFilter()
// aFilter0x2aaab0487080.SetCriteria(aCriteria)
@ -2761,7 +2786,10 @@ void _pyFilter::Process( const Handle(_pyCommand)& theCommand)
{
// aFilter.SetCriteria(aCriteria) ->
// aFilter = smesh.GetFilterFromCriteria(criteria)
theCommand->SetResultValue( GetID() );
if ( myNewID.IsEmpty() )
theCommand->SetResultValue( GetID() );
else
theCommand->SetResultValue( myNewID );
theCommand->SetObject( SMESH_2smeshpy::GenName() );
theCommand->SetMethod( "GetFilterFromCriteria" );
@ -2773,3 +2801,15 @@ void _pyFilter::Process( const Handle(_pyCommand)& theCommand)
theGen->AddMeshAccessorMethod( theCommand );
}
}
//================================================================================
/*!
* \brief Set new filter name to the creation command
*/
//================================================================================
void _pyFilter::Flush()
{
if ( !myNewID.IsEmpty() && GetCreationCmd()->IsEmpty() )
GetCreationCmd()->SetResultValue( myNewID );
}

View File

@ -215,6 +215,7 @@ private:
Resource_DataMapOfAsciiStringAsciiString& myID2AccessorMethod;
Resource_DataMapOfAsciiStringAsciiString& myObjectNames;
Handle(_pyCommand) myLastCommand;
int myNbFilters;
DEFINE_STANDARD_RTTI (_pyGen)
};
@ -470,10 +471,11 @@ DEFINE_STANDARD_HANDLE (_pyGroup, _pyObject);
// -------------------------------------------------------------------------------------
class _pyFilter: public _pyObject
{
_pyID myNewID;
public:
_pyFilter(const Handle(_pyCommand)& theCreationCmd):_pyObject(theCreationCmd) {}
_pyFilter(const Handle(_pyCommand)& theCreationCmd, const _pyID& newID="");
void Process( const Handle(_pyCommand)& theCommand);
virtual void Flush() {}
virtual void Flush();
DEFINE_STANDARD_RTTI (_pyFilter)
};