IMPLEMENT_STANDARD_HANDLE (_pySubMesh ,_pyObject);
IMPLEMENT_STANDARD_HANDLE (_pyMeshEditor ,_pyObject);
IMPLEMENT_STANDARD_HANDLE (_pyHypothesis ,_pyObject);
-IMPLEMENT_STANDARD_HANDLE (_pyFilterManager ,_pyObject);
+IMPLEMENT_STANDARD_HANDLE (_pySelfEraser ,_pyObject);
IMPLEMENT_STANDARD_HANDLE (_pyAlgorithm ,_pyHypothesis);
IMPLEMENT_STANDARD_HANDLE (_pyComplexParamHypo,_pyHypothesis);
IMPLEMENT_STANDARD_HANDLE (_pyNumberOfSegmentsHyp,_pyHypothesis);
IMPLEMENT_STANDARD_RTTIEXT(_pySubMesh ,_pyObject);
IMPLEMENT_STANDARD_RTTIEXT(_pyMeshEditor ,_pyObject);
IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesis ,_pyObject);
-IMPLEMENT_STANDARD_RTTIEXT(_pyFilterManager ,_pyObject);
+IMPLEMENT_STANDARD_RTTIEXT(_pySelfEraser ,_pyObject);
IMPLEMENT_STANDARD_RTTIEXT(_pyAlgorithm ,_pyHypothesis);
IMPLEMENT_STANDARD_RTTIEXT(_pyComplexParamHypo,_pyHypothesis);
IMPLEMENT_STANDARD_RTTIEXT(_pyNumberOfSegmentsHyp,_pyHypothesis);
myObjectNames( theObjectNames )
{
myNbCommands = 0;
- myHasPattern = false;
// make that GetID() to return TPythonDump::SMESHGenName()
GetCreationCmd()->GetString() += "=";
}
return aCommand;
// SMESH_Gen method?
- if ( objID == this->GetID() ) {
+ if ( objID == this->GetID() || objID == SMESH_2smeshpy::GenName()) {
this->Process( aCommand );
return aCommand;
}
-
- // SMESH_subMesh method?
- map< _pyID, Handle(_pySubMesh) >::iterator id_subMesh = mySubMeshes.find( objID );
- if ( id_subMesh != mySubMeshes.end() ) {
- id_subMesh->second->Process( aCommand );
- return aCommand;
- }
// SMESH_Mesh method?
map< _pyID, Handle(_pyMesh) >::iterator id_mesh = myMeshes.find( objID );
else if ( aCommand->GetMethod() == "GetSubMesh" ) { // SubMesh creation
_pyID subMeshID = aCommand->GetResultValue();
Handle(_pySubMesh) subMesh = new _pySubMesh( aCommand );
- mySubMeshes.insert( make_pair( subMeshID, subMesh ));
+ myObjects.insert( make_pair( subMeshID, subMesh ));
}
id_mesh->second->Process( aCommand );
return aCommand;
}
- //SMESH_FilterManager method?
- if ( theCommand.Search( "aFilterManager" ) != -1 ) {
- if ( theCommand.Search( "CreateFilterManager" ) != -1 )
- myFilterManager = new _pyFilterManager( aCommand );
- else if ( !myFilterManager.IsNull() )
- myFilterManager->Process( aCommand );
- return aCommand;
- }
-
// SMESH_MeshEditor method?
map< _pyID, Handle(_pyMeshEditor) >::iterator id_editor = myMeshEditors.find( objID );
if ( id_editor != myMeshEditors.end() ) {
return aCommand;
}
+ // other object method?
+ map< _pyID, Handle(_pyObject) >::iterator id_obj = myObjects.find( objID );
+ if ( id_obj != myObjects.end() ) {
+ id_obj->second->Process( aCommand );
+ return aCommand;
+ }
+// if ( theCommand.Search( "aFilterManager" ) != -1 ) {
+// if ( theCommand.Search( "CreateFilterManager" ) != -1 )
+// myFilterManager = new _pySelfEraser( aCommand );
+// else if ( !myFilterManager.IsNull() )
+// myFilterManager->Process( aCommand );
+// return aCommand;
+// }
+
// Add access to a wrapped mesh
AddMeshAccessorMethod( aCommand );
}
}
- // leave only one smeshgen.GetPattern() in the script
- if ( method == "GetPattern" ) {
- if ( myHasPattern ) {
- theCommand->Clear();
- return;
- }
- myHasPattern = true;
+ // objects erasing creation command if no more it's commands invoked:
+ // SMESH_Pattern, FilterManager
+ if ( method == "GetPattern" || method == "CreateFilterManager" ) {
+ Handle(_pyObject) obj = new _pySelfEraser( theCommand );
+ if ( !myObjects.insert( make_pair( obj->GetID(), obj )).second )
+ theCommand->Clear(); // already created
}
// Concatenate( [mesh1, ...], ... )
// create empty command
myLastCommand = new _pyCommand();
- if ( !myFilterManager.IsNull() )
- myFilterManager->Flush();
-
map< _pyID, Handle(_pyMesh) >::iterator id_mesh = myMeshes.begin();
for ( ; id_mesh != myMeshes.end(); ++id_mesh )
if ( ! id_mesh->second.IsNull() )
(*hyp)->GetCreationCmd()->SetObject( SMESH_2smeshpy::GenName() );
}
- map< _pyID, Handle(_pySubMesh) >::iterator id_subMesh = mySubMeshes.begin();
- for ( ; id_subMesh != mySubMeshes.end(); ++id_subMesh )
- if ( ! id_subMesh->second.IsNull() )
- id_subMesh->second->Flush();
+ map< _pyID, Handle(_pyObject) >::iterator id_obj = myObjects.begin();
+ for ( ; id_obj != myObjects.end(); ++id_obj )
+ if ( ! id_obj->second.IsNull() )
+ id_obj->second->Flush();
myLastCommand->SetOrderNb( ++myNbCommands );
myCommands.push_back( myLastCommand );
Handle(_pySubMesh) _pyGen::FindSubMesh( const _pyID& theSubMeshID )
{
- map< _pyID, Handle(_pySubMesh) >::iterator id_subMesh = mySubMeshes.begin();
- for ( ; id_subMesh != mySubMeshes.end(); ++id_subMesh ) {
- Handle(_pySubMesh) sm = id_subMesh->second;
- if ( !id_subMesh->second.IsNull() && theSubMeshID == id_subMesh->second->GetID() )
- return sm;
- }
+ map< _pyID, Handle(_pyObject) >::iterator id_subMesh = myObjects.find(theSubMeshID);
+ if ( id_subMesh != myObjects.end() )
+ return Handle(_pySubMesh)::DownCast( id_subMesh->second );
return Handle(_pySubMesh)();
}
else if ( hypType == "TrianglePreference" ) {
hyp->SetConvMethodAndType( "TrianglePreference", "Quadrangle_2D");
}
+ // BLSURF ----------
+ else if ( hypType == "BLSURF" ) {
+ algo->SetConvMethodAndType( "Triangle", hypType.ToCString());
+ algo->myArgs.Append( "algo=smesh.BLSURF" );
+ }
+ else if ( hypType == "BLSURF_Parameters") {
+ hyp->SetConvMethodAndType( "Parameters", "BLSURF");
+ }
// NETGEN ----------
-// else if ( hypType == "NETGEN_2D") { // 1D-2D
-// algo->SetConvMethodAndType( "Triangle" , hypType.ToCString());
-// algo->myArgs.Append( "algo=smesh.NETGEN" );
-// }
+ else if ( hypType == "NETGEN_2D") { // 1D-2D
+ algo->SetConvMethodAndType( "Triangle" , hypType.ToCString());
+ algo->myArgs.Append( "algo=smesh.NETGEN" );
+ }
+ else if ( hypType == "NETGEN_Parameters_2D") {
+ hyp->SetConvMethodAndType( "Parameters", "NETGEN_2D");
+ }
+ else if ( hypType == "NETGEN_SimpleParameters_2D") {
+ hyp->SetConvMethodAndType( "Parameters", "NETGEN_2D");
+ hyp->myArgs.Append( "which=SIMPLE" );
+ }
+ else if ( hypType == "NETGEN_2D3D") { // 1D-2D-3D
+ algo->SetConvMethodAndType( "Tetrahedron" , hypType.ToCString());
+ algo->myArgs.Append( "algo=smesh.FULL_NETGEN" );
+ }
+ else if ( hypType == "NETGEN_Parameters") {
+ hyp->SetConvMethodAndType( "Parameters", "NETGEN_2D3D");
+ }
+ else if ( hypType == "NETGEN_SimpleParameters_3D") {
+ hyp->SetConvMethodAndType( "Parameters", "NETGEN_2D3D");
+ hyp->myArgs.Append( "which=SIMPLE" );
+ }
else if ( hypType == "NETGEN_2D_ONLY") { // 2D
algo->SetConvMethodAndType( "Triangle" , hypType.ToCString());
algo->myArgs.Append( "algo=smesh.NETGEN_2D" );
algo->SetConvMethodAndType( "Tetrahedron", hypType.ToCString());
algo->myArgs.Append( "algo=smesh.GHS3D" );
}
+ else if ( hypType == "GHS3D_Parameters") {
+ hyp->SetConvMethodAndType( "Parameters", "GHS3D_3D");
+ }
// Hexa_3D ---------
- else if ( hypType == "Hexa_3D" ) {
+ else if ( hypType == "BLSURF" ) {
algo->SetConvMethodAndType( "Hexahedron", hypType.ToCString());
}
// Repetitive Projection_1D ---------
int nb1 = 0; // number of ' character at the left of =
int nb2 = 0; // number of " character at the left of =
for ( int i = 1; i < begPos-1; i++ ) {
- if ( IsEqual(myString.Value( i ), "'" ) )
+ if ( myString.Value( i )=='\'' )
nb1 += 1;
- else if ( IsEqual( myString.Value( i ), '"' ) )
+ else if ( myString.Value( i )=='"' )
nb2 += 1;
}
// if number of ' or " is not divisible by 2,
if ( nb1 % 2 != 0 || nb2 % 2 != 0 )
begPos = 1;
}
- // store
myObj = GetWord( myString, begPos, true );
+ // check if object is complex,
+ // so far consider case like "smesh.smesh.Method()"
+ if ( int bracketPos = myString.Location( "(", begPos, Length() )) {
+ //if ( bracketPos==0 ) bracketPos = Length();
+ int dotPos = begPos+myObj.Length();
+ while ( dotPos+1 < bracketPos ) {
+ if ( int pos = myString.Location( ".", dotPos+1, bracketPos ))
+ dotPos = pos;
+ else
+ break;
+ }
+ if ( dotPos > begPos+myObj.Length() )
+ myObj = myString.SubString( begPos, dotPos-1 );
+ }
+ // store
SetBegPos( OBJECT_IND, begPos );
}
//SCRUTE(myObj);
//================================================================================
/*!
- * \brief FilterManager creates only if at least one command invoked
- */
-//================================================================================
-
-_pyFilterManager::_pyFilterManager(const Handle(_pyCommand)& theCreationCmd):
- _pyObject( theCreationCmd ),
- myCmdCount( 0 )
-{
-}
-
-//================================================================================
-/*!
- * \brief count invoked commands
- */
-//================================================================================
-
-void _pyFilterManager::Process( const Handle(_pyCommand)& /*theCommand*/)
-{
- myCmdCount++;
-}
-
-//================================================================================
-/*!
- * \brief Clear creatin command if no commands invoked
+ * \brief SelfEraser erases creation command if no more it's commands invoked
*/
//================================================================================
-void _pyFilterManager::Flush()
+void _pySelfEraser::Flush()
{
- if ( !myCmdCount )
+ if ( GetNbCalls() == 0 )
GetCreationCmd()->Clear();
}
-
-//================================================================================
-/*!
- * \brief SubMesh creation can be moved to the end of engine commands
- */
-//================================================================================
-
-_pySubMesh::_pySubMesh(const Handle(_pyCommand)& theCreationCmd):
- _pyObject( theCreationCmd ),
- myCmdCount( 0 )
-{
-}
-
//================================================================================
/*!
* \brief count invoked commands
void _pySubMesh::Process( const Handle(_pyCommand)& theCommand )
{
- myCmdCount++;
+ _pyObject::Process(theCommand); // count calls of Process()
GetCreationCmd()->AddDependantCmd( theCommand );
}
void _pySubMesh::Flush()
{
- if ( !myCmdCount ) // move to the end of all commands
+ if ( GetNbCalls() == 0 ) // move to the end of all commands
theGen->GetLastCommand()->AddDependantCmd( GetCreationCmd() );
else if ( !myCreator.IsNull() )
// move to be just after creator
// -------------------------------------------------------------------------------------
/*!
- * \brief Root of all objects
+ * \brief Root of all objects. It counts calls of Process()
*/
// -------------------------------------------------------------------------------------
class _pyObject: public Standard_Transient
{
- Handle(_pyCommand) myCreationCmd;
+ Handle(_pyCommand) myCreationCmd;
+ int myNbCalls;
public:
- _pyObject(const Handle(_pyCommand)& theCreationCmd): myCreationCmd(theCreationCmd) {}
+ _pyObject(const Handle(_pyCommand)& theCreationCmd)
+ : myCreationCmd(theCreationCmd), myNbCalls(0) {}
const _pyID& GetID() { return myCreationCmd->GetResultValue(); }
static _pyID FatherID(const _pyID & childID);
const Handle(_pyCommand)& GetCreationCmd() { return myCreationCmd; }
+ int GetNbCalls() const { return myNbCalls; }
void SetCreationCmd( Handle(_pyCommand) cmd ) { myCreationCmd = cmd; }
int GetCommandNb() { return myCreationCmd->GetOrderNb(); }
- virtual void Process(const Handle(_pyCommand) & theCommand) = 0;
+ virtual void Process(const Handle(_pyCommand) & theCommand) { myNbCalls++; }
virtual void Flush() = 0;
virtual const char* AccessorMethod() const;
private:
std::map< _pyID, Handle(_pyMesh) > myMeshes;
- std::map< _pyID, Handle(_pySubMesh) > mySubMeshes;
+ //std::map< _pyID, Handle(_pySubMesh) > mySubMeshes;
std::map< _pyID, Handle(_pyMeshEditor) > myMeshEditors;
+ std::map< _pyID, Handle(_pyObject) > myObjects;
std::list< Handle(_pyHypothesis) > myHypos;
std::list< Handle(_pyCommand) > myCommands;
int myNbCommands;
- bool myHasPattern;
Resource_DataMapOfAsciiStringAsciiString& myID2AccessorMethod;
Resource_DataMapOfAsciiStringAsciiString& myObjectNames;
Handle(_pyCommand) myLastCommand;
- Handle(_pyFilterManager) myFilterManager;
DEFINE_STANDARD_RTTI (_pyGen)
};
// -------------------------------------------------------------------------------------
/*!
- * \brief FilterManager creates only if at least one command invoked
+ * \brief SelfEraser erases creation command if no more it's commands invoked
*/
// -------------------------------------------------------------------------------------
-class _pyFilterManager: public _pyObject
+class _pySelfEraser: public _pyObject
{
public:
- _pyFilterManager(const Handle(_pyCommand)& theCreationCmd);
- void Process( const Handle(_pyCommand)& theCommand);
+ _pySelfEraser(const Handle(_pyCommand)& theCreationCmd):_pyObject(theCreationCmd) {}
virtual void Flush();
- DEFINE_STANDARD_RTTI (_pyFilterManager)
-private:
- int myCmdCount;
+ DEFINE_STANDARD_RTTI (_pySelfEraser)
};
+DEFINE_STANDARD_HANDLE (_pySelfEraser, _pyObject);
// -------------------------------------------------------------------------------------
/*!
class _pySubMesh: public _pyObject
{
public:
- _pySubMesh(const Handle(_pyCommand)& theCreationCmd);
+ _pySubMesh(const Handle(_pyCommand)& theCreationCmd):_pyObject(theCreationCmd) {}
void Process( const Handle(_pyCommand)& theCommand);
virtual void Flush();
void SetCreator( const Handle(_pyObject)& theCreator ) { myCreator = theCreator; }
- DEFINE_STANDARD_RTTI (_pyFilterManager)
+ DEFINE_STANDARD_RTTI (_pySubMesh)
private:
- int myCmdCount;
Handle(_pyObject) myCreator;
};