#include <SMESH_2smeshpy.hxx>

Public Member Functions | |
| _pyMesh (const Handle(_pyCommand) creationCmd) | |
| Find out type of geom group. | |
| _pyMesh (const Handle(_pyCommand) theCreationCmd, const TCollection_AsciiString &id) | |
| const _pyID & | GetGeom () |
| void | Process (const Handle(_pyCommand)&theCommand) |
| Convert a IDL API command of SMESH.Mesh to a method call of python Mesh. | |
| void | Flush () |
| Convert creation and addition of all algos and hypos. | |
| const char * | AccessorMethod () const |
| Return method name giving access to an interaface object wrapped by python class. | |
| const | Handle (_pyCommand)&GetCreationCmd() |
| const _pyID & | GetID () |
| int | GetNbCalls () const |
| void | SetCreationCmd (Handle(_pyCommand) cmd) |
| int | GetCommandNb () |
Static Public Member Functions | |
| static _pyID | FatherID (const _pyID &childID) |
| Return ID of a father. | |
Static Private Member Functions | |
| static bool | NeedMeshAccess (const Handle(_pyCommand)&theCommand) |
| Return True if addition of accesor method is needed. | |
| static void | AddMeshAccess (const Handle(_pyCommand)&theCommand) |
Private Attributes | |
| std::list< Handle(_pyHypothesis) > | myHypos |
| std::list< Handle(_pyCommand) > | myAddHypCmds |
| std::list< Handle(_pySubMesh) > | mySubmeshes |
| bool | myHasEditor |
Definition at line 231 of file SMESH_2smeshpy.hxx.
| _pyMesh::_pyMesh | ( | const Handle(_pyCommand) | theCreationCmd | ) |
Find out type of geom group.
| grpID | - The geom group entry |
| int | - The type |
| theCreationCmd | - |
Definition at line 783 of file SMESH_2smeshpy.cxx.
References _pyObject.GetID(), _pyObject.Handle(), _pyGen.SetAccessorMethod(), and SMESH_2smeshpy.SmeshpyName().
: _pyObject(theCreationCmd), myHasEditor(false) { // convert my creation command Handle(_pyCommand) creationCmd = GetCreationCmd(); //TCollection_AsciiString str = creationCmd->GetMethod(); // if(str != "CreateMeshesFromUNV" && // str != "CreateMeshesFromMED" && // str != "CreateMeshesFromSTL") creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); creationCmd->SetMethod( "Mesh" ); theGen->SetAccessorMethod( GetID(), "GetMesh()" ); }
| _pyMesh::_pyMesh | ( | const Handle(_pyCommand) | theCreationCmd, |
| const TCollection_AsciiString & | id | ||
| ) |
| theCreationCmd | - |
Definition at line 804 of file SMESH_2smeshpy.cxx.
References _pyObject.Handle(), _pyGen.SetAccessorMethod(), and SMESH_2smeshpy.SmeshpyName().
: _pyObject(theCreationCmd), myHasEditor(false) { // convert my creation command Handle(_pyCommand) creationCmd = GetCreationCmd(); creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); theGen->SetAccessorMethod( id, "GetMesh()" ); }
| const char* _pyMesh.AccessorMethod | ( | ) | const [virtual] |
Return method name giving access to an interaface object wrapped by python class.
| const | char* - method name |
Reimplemented from _pyObject.
Definition at line 243 of file SMESH_2smeshpy.hxx.
References _pyMesh_ACCESS_METHOD.
{ return _pyMesh_ACCESS_METHOD; }
| static void _pyMesh.AddMeshAccess | ( | const Handle(_pyCommand)& | theCommand | ) | [static, private] |
Definition at line 246 of file SMESH_2smeshpy.hxx.
References _pyMesh_ACCESS_METHOD, _pyCommand.GetObject(), and _pyCommand.SetObject().
Referenced by Process().
{ theCommand->SetObject( theCommand->GetObject() + "." _pyMesh_ACCESS_METHOD ); }
Return ID of a father.
Definition at line 2494 of file SMESH_2smeshpy.cxx.
Referenced by _pySegmentLengthAroundVertexHyp.Addition2Creation().
{
int colPos = childID.SearchFromEnd(':');
if ( colPos > 0 )
return childID.SubString( 1, colPos-1 );
return "";
}
| void _pyMesh::Flush | ( | ) | [virtual] |
Convert creation and addition of all algos and hypos.
Implements _pyObject.
Definition at line 994 of file SMESH_2smeshpy.cxx.
References ex01_cube2build.algo, SMESH.DownCast(), _pyGen.GenerateNewID(), SMESH_box.geom, GetGeom(), _pyObject.GetID(), _pyObject.Handle(), SMESH_demo_hexa2_upd.hyp, myAddHypCmds, myHypos, mySubmeshes, and _pyGen.SetCommandBefore().
{
list < Handle(_pyCommand) >::iterator cmd;
// try to convert algo addition like this:
// mesh.AddHypothesis(geom, ALGO ) --> ALGO = mesh.Algo()
for ( cmd = myAddHypCmds.begin(); cmd != myAddHypCmds.end(); ++cmd )
{
Handle(_pyCommand) addCmd = *cmd;
_pyID algoID = addCmd->GetArg( 2 );
Handle(_pyHypothesis) algo = theGen->FindHyp( algoID );
if ( algo.IsNull() || !algo->IsAlgo() )
continue;
// check and create new algorithm instance if it is already wrapped
if ( algo->IsWrapped() ) {
_pyID localAlgoID = theGen->GenerateNewID( algoID );
TCollection_AsciiString aNewCmdStr = localAlgoID +
TCollection_AsciiString( " = " ) + theGen->GetID() +
TCollection_AsciiString( ".CreateHypothesis( \"" ) + algo->GetAlgoType() +
TCollection_AsciiString( "\" )" );
Handle(_pyCommand) newCmd = theGen->AddCommand( aNewCmdStr );
Handle(_pyAlgorithm) newAlgo = Handle(_pyAlgorithm)::DownCast(theGen->FindHyp( localAlgoID ));
if ( !newAlgo.IsNull() ) {
newAlgo->Assign( algo, this->GetID() );
newAlgo->SetCreationCmd( newCmd );
algo = newAlgo;
// set algorithm creation
theGen->SetCommandBefore( newCmd, addCmd );
}
else
newCmd->Clear();
}
_pyID geom = addCmd->GetArg( 1 );
bool isLocalAlgo = ( geom != GetGeom() );
// try to convert
if ( algo->Addition2Creation( addCmd, this->GetID() )) // OK
{
// wrapped algo is created atfer mesh creation
GetCreationCmd()->AddDependantCmd( addCmd );
if ( isLocalAlgo ) {
// mesh.AddHypothesis(geom, ALGO ) --> mesh.AlgoMethod(geom)
addCmd->SetArg( addCmd->GetNbArgs() + 1,
TCollection_AsciiString( "geom=" ) + geom );
// sm = mesh.GetSubMesh(geom, name) --> sm = ALGO.GetSubMesh()
list < Handle(_pySubMesh) >::iterator smIt;
for ( smIt = mySubmeshes.begin(); smIt != mySubmeshes.end(); ++smIt ) {
Handle(_pySubMesh) subMesh = *smIt;
Handle(_pyCommand) subCmd = subMesh->GetCreationCmd();
if ( geom == subCmd->GetArg( 1 )) {
subCmd->SetObject( algo->GetID() );
subCmd->RemoveArgs();
subMesh->SetCreator( algo );
}
}
}
}
else // KO - ALGO was already created
{
// mesh.AddHypothesis(geom, ALGO) --> mesh.AddHypothesis(ALGO, geom=0)
addCmd->RemoveArgs();
addCmd->SetArg( 1, algoID );
if ( isLocalAlgo )
addCmd->SetArg( 2, geom );
}
}
// try to convert hypo addition like this:
// mesh.AddHypothesis(geom, HYPO ) --> HYPO = algo.Hypo()
for ( cmd = myAddHypCmds.begin(); cmd != myAddHypCmds.end(); ++cmd )
{
Handle(_pyCommand) addCmd = *cmd;
_pyID hypID = addCmd->GetArg( 2 );
Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID );
if ( hyp.IsNull() || hyp->IsAlgo() )
continue;
bool converted = hyp->Addition2Creation( addCmd, this->GetID() );
if ( !converted ) {
// mesh.AddHypothesis(geom, HYP) --> mesh.AddHypothesis(HYP, geom=0)
_pyID geom = addCmd->GetArg( 1 );
addCmd->RemoveArgs();
addCmd->SetArg( 1, hypID );
if ( geom != GetGeom() )
addCmd->SetArg( 2, geom );
}
}
// sm = mesh.GetSubMesh(geom, name) --> sm = mesh.GetMesh().GetSubMesh(geom, name)
// for ( cmd = mySubmeshes.begin(); cmd != mySubmeshes.end(); ++cmd ) {
// Handle(_pyCommand) subCmd = *cmd;
// if ( subCmd->GetNbArgs() > 0 )
// AddMeshAccess( subCmd );
// }
myAddHypCmds.clear();
mySubmeshes.clear();
// flush hypotheses
list< Handle(_pyHypothesis) >::iterator hyp = myHypos.begin();
for ( ; hyp != myHypos.end(); ++hyp )
(*hyp)->Flush();
}
| int _pyObject.GetCommandNb | ( | ) | [inherited] |
Definition at line 167 of file SMESH_2smeshpy.hxx.
{ return myCreationCmd->GetOrderNb(); }
| const _pyID& _pyMesh.GetGeom | ( | ) |
Definition at line 240 of file SMESH_2smeshpy.hxx.
Referenced by Flush(), and Process().
{ return GetCreationCmd()->GetArg(1); }
| const _pyID& _pyObject.GetID | ( | ) | [inherited] |
Definition at line 162 of file SMESH_2smeshpy.hxx.
Referenced by _pyMesh(), _pyAlgorithm.Addition2Creation(), _pyLayerDistributionHypo.Addition2Creation(), _pyHypothesis.Addition2Creation(), and Flush().
{ return myCreationCmd->GetResultValue(); }
| int _pyObject.GetNbCalls | ( | ) | const [inherited] |
Definition at line 165 of file SMESH_2smeshpy.hxx.
References _pyObject.myNbCalls.
Referenced by _pySubMesh.Flush(), and _pySelfEraser.Flush().
{ return myNbCalls; }
| const _pyObject.Handle | ( | _pyCommand | ) | [inherited] |
Reimplemented in _pyGen, and _pyGen.
Definition at line 164 of file SMESH_2smeshpy.hxx.
{ return myCreationCmd; }
| bool _pyMesh::NeedMeshAccess | ( | const Handle(_pyCommand)& | theCommand | ) | [static, private] |
Return True if addition of accesor method is needed.
Definition at line 961 of file SMESH_2smeshpy.cxx.
References _pyCommand.GetMethod(), and SMESH_reg.names.
Referenced by Process().
{
// names of SMESH_Mesh methods fully equal to methods of class Mesh, so
// no conversion is needed for them at all:
static TStringSet sameMethods;
if ( sameMethods.empty() ) {
const char * names[] =
{ "ExportDAT","ExportUNV","ExportSTL", "RemoveGroup","RemoveGroupWithContents",
"GetGroups","UnionGroups","IntersectGroups","CutGroups","GetLog","GetId","ClearLog",
"GetStudyId","HasDuplicatedGroupNamesMED","GetMEDMesh","NbNodes","NbElements",
"NbEdges","NbEdgesOfOrder","NbFaces","NbFacesOfOrder","NbTriangles",
"NbTrianglesOfOrder","NbQuadrangles","NbQuadranglesOfOrder","NbPolygons","NbVolumes",
"NbVolumesOfOrder","NbTetras","NbTetrasOfOrder","NbHexas","NbHexasOfOrder",
"NbPyramids","NbPyramidsOfOrder","NbPrisms","NbPrismsOfOrder","NbPolyhedrons",
"NbSubMesh","GetElementsId","GetElementsByType","GetNodesId","GetElementType",
"GetSubMeshElementsId","GetSubMeshNodesId","GetSubMeshElementType","Dump","GetNodeXYZ",
"GetNodeInverseElements","GetShapeID","GetShapeIDForElem","GetElemNbNodes",
"GetElemNode","IsMediumNode","IsMediumNodeOfAnyElem","ElemNbEdges","ElemNbFaces",
"IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor",
"Clear", "ConvertToStandalone", "GetMeshOrder", "SetMeshOrder"
,"" }; // <- mark of end
sameMethods.Insert( names );
}
return !sameMethods.Contains( theCommand->GetMethod() );
}
| void _pyMesh::Process | ( | const Handle(_pyCommand)& | theCommand | ) | [virtual] |
Convert a IDL API command of SMESH.Mesh to a method call of python Mesh.
| theCommand | - Engine method called for this mesh |
Reimplemented from _pyObject.
Definition at line 820 of file SMESH_2smeshpy.cxx.
References AddMeshAccess(), _pyCommand.Clear(), SMESH_box.geom, _pyCommand.GetArg(), GetGeom(), _pyCommand.GetMethod(), _pyCommand.GetResultValue(), _pyCommand.GetString(), _pyObject.Handle(), myAddHypCmds, myHypos, mySubmeshes, ex21_lamp.name, NeedMeshAccess(), _pyGen.Process(), _pyCommand.RemoveArgs(), _pyCommand.SetArg(), and _pyCommand.SetMethod().
{
// some methods of SMESH_Mesh interface needs special conversion
// to methods of Mesh python class
//
// 1. GetSubMesh(geom, name) + AddHypothesis(geom, algo)
// --> in Mesh_Algorithm.Create(mesh, geom, hypo, so)
// 2. AddHypothesis(geom, hyp)
// --> in Mesh_Algorithm.Hypothesis(hyp, args, so)
// 3. CreateGroupFromGEOM(type, name, grp)
// --> in Mesh.Group(grp, name="")
// 4. ExportToMED(f, auto_groups, version)
// --> in Mesh.ExportMED( f, auto_groups, version )
// 5. etc
const TCollection_AsciiString method = theCommand->GetMethod();
// ----------------------------------------------------------------------
if ( method == "GetSubMesh" ) {
Handle(_pySubMesh) subMesh = theGen->FindSubMesh( theCommand->GetResultValue() );
if ( !subMesh.IsNull() ) {
subMesh->SetCreator( this );
mySubmeshes.push_back( subMesh );
}
}
// ----------------------------------------------------------------------
else if ( method == "AddHypothesis" ) { // mesh.AddHypothesis(geom, HYPO )
myAddHypCmds.push_back( theCommand );
// set mesh to hypo
const _pyID& hypID = theCommand->GetArg( 2 );
Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID );
if ( !hyp.IsNull() ) {
myHypos.push_back( hyp );
if ( hyp->GetMesh().IsEmpty() )
hyp->SetMesh( this->GetID() );
}
}
// ----------------------------------------------------------------------
else if ( method == "CreateGroupFromGEOM" ) {// (type, name, grp)
_pyID grp = theCommand->GetArg( 3 );
// VSR 24/12/2010. PAL21106: always use GroupOnGeom() function on dump
// next if(){...} section is commented
//if ( sameGroupType( grp, theCommand->GetArg( 1 )) ) { // --> Group(grp)
// theCommand->SetMethod( "Group" );
// theCommand->RemoveArgs();
// theCommand->SetArg( 1, grp );
//}
//else {
_pyID type = theCommand->GetArg( 1 );
_pyID name = theCommand->GetArg( 2 );
theCommand->SetMethod( "GroupOnGeom" );
theCommand->RemoveArgs();
theCommand->SetArg( 1, grp );
theCommand->SetArg( 2, name );
theCommand->SetArg( 3, type );
//}
}
// ----------------------------------------------------------------------
else if ( method == "ExportToMED" || // ExportToMED() --> ExportMED()
method == "ExportToMEDX" ) { // ExportToMEDX() --> ExportMED()
theCommand->SetMethod( "ExportMED" );
}
// ----------------------------------------------------------------------
else if ( method == "CreateGroup" ) { // CreateGroup() --> CreateEmptyGroup()
theCommand->SetMethod( "CreateEmptyGroup" );
}
// ----------------------------------------------------------------------
else if ( method == "RemoveHypothesis" ) // (geom, hyp)
{
_pyID hypID = theCommand->GetArg( 2 );
// check if this mesh still has corresponding addition command
bool hasAddCmd = false;
list< Handle(_pyCommand) >::iterator cmd = myAddHypCmds.begin();
while ( cmd != myAddHypCmds.end() )
{
// AddHypothesis(geom, hyp)
if ( hypID == (*cmd)->GetArg( 2 )) { // erase both (add and remove) commands
theCommand->Clear();
(*cmd)->Clear();
cmd = myAddHypCmds.erase( cmd );
hasAddCmd = true;
}
else {
++cmd;
}
}
Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID );
if ( ! hasAddCmd && hypID.Length() != 0 ) { // hypo addition already wrapped
// RemoveHypothesis(geom, hyp) --> RemoveHypothesis( hyp, geom=0 )
_pyID geom = theCommand->GetArg( 1 );
theCommand->RemoveArgs();
theCommand->SetArg( 1, hypID );
if ( geom != GetGeom() )
theCommand->SetArg( 2, geom );
}
// remove hyp from myHypos
myHypos.remove( hyp );
}
// check for SubMesh order commands
else if ( theCommand->GetMethod() == "GetMeshOrder" ||
theCommand->GetMethod() == "SetMeshOrder" ) {
// In fact arguments and result values does not support complex containers
// such as list of list
// So, here we parse it manually
// GetMeshOrder
//for(int ind = 0, n = theCommand->GetNbResultValues();ind<n;ind++) {
// Handle(_pySubMesh) subMesh = theGen->FindSubMesh( theCommand->GetResultValue(ind) );
// SetMeshOrder
//for(int ind = 0, n = theCommand->GetNbArgs();ind<n;ind++) {
// Handle(_pySubMesh) subMesh = theGen->FindSubMesh( theCommand->GetArg(ind) );
const bool isArg = theCommand->GetMethod() == "SetMeshOrder";
const TCollection_AsciiString& cmdStr = theCommand->GetString();
int begPos = (/*isArg ? cmdStr.Search( "(" ) :*/ cmdStr.Search( "[" )) + 1;
int endPos = (isArg ? cmdStr.Search( ")" ) : cmdStr.Search( "=" )) - 1;
if ( begPos != -1 && begPos < endPos && endPos <= cmdStr.Length() ) {
TCollection_AsciiString aSubStr = cmdStr.SubString( begPos, endPos );
Standard_Integer index = 1;
TCollection_AsciiString anIDStr = aSubStr.Token("\t ,[]", index++);
while ( !anIDStr.IsEmpty() ) {
Handle(_pySubMesh) subMesh = theGen->FindSubMesh( anIDStr );
if ( !subMesh.IsNull() )
subMesh->Process( theCommand );
anIDStr = aSubStr.Token("\t ,[]", index++);
}
}
}
// add accessor method if necessary
else
{
if ( NeedMeshAccess( theCommand ))
// apply theCommand to the mesh wrapped by smeshpy mesh
AddMeshAccess( theCommand );
}
}
| void _pyObject.SetCreationCmd | ( | Handle(_pyCommand) | cmd | ) | [inherited] |
Definition at line 166 of file SMESH_2smeshpy.hxx.
Referenced by _pyHypothesis.Addition2Creation().
{ myCreationCmd = cmd; }
std::list< Handle(_pyCommand) > _pyMesh.myAddHypCmds [private] |
Definition at line 234 of file SMESH_2smeshpy.hxx.
bool _pyMesh.myHasEditor [private] |
Definition at line 236 of file SMESH_2smeshpy.hxx.
std::list< Handle(_pyHypothesis) > _pyMesh.myHypos [private] |
Definition at line 233 of file SMESH_2smeshpy.hxx.
std::list< Handle(_pySubMesh) > _pyMesh.mySubmeshes [private] |
Definition at line 235 of file SMESH_2smeshpy.hxx.