Root class for hypothesis. More...
#include <SMESH_2smeshpy.hxx>

Public Member Functions | |
| _pyHypothesis (const Handle(_pyCommand)&theCreationCmd) | |
| _pyHypothesis constructor | |
| void | SetConvMethodAndType (const char *creationMethod, const char *type) |
| void | AddArgMethod (const char *method, const int nbArgs=1) |
| const TColStd_SequenceOfAsciiString & | GetArgs () const |
| const std::list< Handle(_pyCommand)> & | GetArgCommands () const |
| void | ClearAllCommands () |
| clear creation, arg and unkown commands | |
| virtual bool | IsAlgo () const |
| bool | IsValid () const |
| bool | IsWrapped () const |
| const _pyID & | GetGeom () const |
| void | SetMesh (const _pyID &theMeshId) |
| const _pyID & | GetMesh () const |
| const TCollection_AsciiString & | GetAlgoType () const |
| const TCollection_AsciiString & | GetAlgoCreationMethod () const |
| bool | CanBeCreatedBy (const TCollection_AsciiString &algoType) const |
| const TCollection_AsciiString & | GetCreationMethod (const TCollection_AsciiString &algoType) const |
| virtual bool | IsWrappable (const _pyID &theMesh) |
| virtual bool | Addition2Creation (const Handle(_pyCommand)&theAdditionCmd, const _pyID &theMesh) |
| Convert the command adding a hypothesis to mesh into a smesh command. | |
| void | Process (const Handle(_pyCommand)&theCommand) |
| Remember hypothesis parameter values. | |
| void | Flush () |
| Finish conversion. | |
| virtual void | Assign (const Handle(_pyHypothesis)&theOther, const _pyID &theMesh) |
| Assign fields of theOther to me except myIsWrapped. | |
| const | Handle (_pyCommand)&GetCreationCmd() |
| const _pyID & | GetID () |
| int | GetNbCalls () const |
| void | SetCreationCmd (Handle(_pyCommand) cmd) |
| int | GetCommandNb () |
| virtual const char * | AccessorMethod () const |
| Return method name giving access to an interaface object wrapped by python class. | |
Static Public Member Functions | |
| static | Handle (_pyHypothesis) NewHypothesis(const Handle(_pyCommand)&theCreationCmd) |
| static _pyID | FatherID (const _pyID &childID) |
| Return ID of a father. | |
Protected Attributes | |
| bool | myIsAlgo |
| bool | myIsWrapped |
| _pyID | myGeom |
| _pyID | myMesh |
| std::map < TCollection_AsciiString, TCollection_AsciiString > | myType2CreationMethod |
| TColStd_SequenceOfAsciiString | myArgs |
| TColStd_SequenceOfAsciiString | myArgMethods |
| TColStd_SequenceOfInteger | myNbArgsByMethod |
| std::list< Handle(_pyCommand)> | myArgCommands |
| std::list< Handle(_pyCommand)> | myUnknownCommands |
Root class for hypothesis.
HOWTO assure convertion of a new type of hypothesis In _pyHypothesis.NewHypothesis(): 1. add a case for the name of the new hypothesis 2. use SetConvMethodAndType() to set . for algo: algorithm name and method of Mesh creating the algo . for hypo: name of the algorithm and method creating the hypothesis 3. append to myArgMethods interface methods setting param values in the order they are used when creation method is called. If arguments of the creation method can't be easily got from calls of hypothesis methods, you are to derive a specific class from _pyHypothesis that would redefine Process(), see _pyComplexParamHypo for example
Definition at line 288 of file SMESH_2smeshpy.hxx.
| _pyHypothesis::_pyHypothesis | ( | const Handle(_pyCommand)& | theCreationCmd | ) |
_pyHypothesis constructor
| theCreationCmd | - |
Definition at line 1249 of file SMESH_2smeshpy.cxx.
References myIsAlgo, and myIsWrapped.
: _pyObject( theCreationCmd ) { myIsAlgo = myIsWrapped = /*myIsConverted = myIsLocal = myDim = */false; }
| const char * _pyObject::AccessorMethod | ( | ) | const [virtual, inherited] |
Return method name giving access to an interaface object wrapped by python class.
| const | char* - method name |
Reimplemented in _pyGen, _pyMesh, and _pyAlgorithm.
Definition at line 2484 of file SMESH_2smeshpy.cxx.
{
return 0;
}
| void _pyHypothesis.AddArgMethod | ( | const char * | method, |
| const int | nbArgs = 1 |
||
| ) |
Definition at line 305 of file SMESH_2smeshpy.hxx.
{ myArgMethods.Append( (char*)method ); myNbArgsByMethod.Append( nbArgs ); }
| bool _pyHypothesis::Addition2Creation | ( | const Handle(_pyCommand)& | theCmd, |
| const _pyID & | theMesh | ||
| ) | [virtual] |
Convert the command adding a hypothesis to mesh into a smesh command.
| theCmd | - The command like mesh.AddHypothesis( geom, hypo ) |
| theAlgo | - The algo that can create this hypo |
| bool | - false if the command cant be converted |
Reimplemented in _pyAlgorithm, _pyLayerDistributionHypo, _pyNumberOfSegmentsHyp, and _pySegmentLengthAroundVertexHyp.
Definition at line 1510 of file SMESH_2smeshpy.cxx.
References ex01_cube2build.algo, GetAlgoCreationMethod(), GetAlgoType(), _pyCommand.GetArg(), GetCreationMethod(), _pyObject.GetID(), _pyCommand.GetMethod(), Handle(), IsAlgo(), IsWrappable(), myArgCommands, myArgs, myGeom, myIsWrapped, myUnknownCommands, _pyCommand.RemoveArgs(), _pyCommand.SetArg(), _pyObject.SetCreationCmd(), _pyCommand.SetMethod(), _pyCommand.SetObject(), and _pyCommand.SetResultValue().
Referenced by _pyAlgorithm.Addition2Creation().
{
ASSERT(( theCmd->GetMethod() == "AddHypothesis" ));
if ( !IsWrappable( theMesh ))
return false;
myGeom = theCmd->GetArg( 1 );
Handle(_pyHypothesis) algo;
if ( !IsAlgo() ) {
// find algo created on myGeom in theMesh
algo = theGen->FindAlgo( myGeom, theMesh, this );
if ( algo.IsNull() )
return false;
// attach hypothesis creation command to be after algo creation command
// because it can be new created instance of algorithm
algo->GetCreationCmd()->AddDependantCmd( theCmd );
}
myIsWrapped = true;
// mesh.AddHypothesis(geom,hyp) --> hyp = <theMesh or algo>.myCreationMethod(args)
theCmd->SetResultValue( GetID() );
theCmd->SetObject( IsAlgo() ? theMesh : algo->GetID());
theCmd->SetMethod( IsAlgo() ? GetAlgoCreationMethod() : GetCreationMethod( algo->GetAlgoType() ));
// set args
theCmd->RemoveArgs();
for ( int i = 1; i <= myArgs.Length(); ++i ) {
if ( !myArgs( i ).IsEmpty() )
theCmd->SetArg( i, myArgs( i ));
else
theCmd->SetArg( i, "[]");
}
// set a new creation command
GetCreationCmd()->Clear();
// replace creation command by wrapped instance
// please note, that hypothesis attaches to algo creation command (see upper)
SetCreationCmd( theCmd );
// clear commands setting arg values
list < Handle(_pyCommand) >::iterator argCmd = myArgCommands.begin();
for ( ; argCmd != myArgCommands.end(); ++argCmd )
(*argCmd)->Clear();
// set unknown arg commands after hypo creation
Handle(_pyCommand) afterCmd = myIsWrapped ? theCmd : GetCreationCmd();
list<Handle(_pyCommand)>::iterator cmd = myUnknownCommands.begin();
for ( ; cmd != myUnknownCommands.end(); ++cmd ) {
afterCmd->AddDependantCmd( *cmd );
}
return myIsWrapped;
}
| void _pyHypothesis::Assign | ( | const Handle(_pyHypothesis)& | theOther, |
| const _pyID & | theMesh | ||
| ) | [virtual] |
Assign fields of theOther to me except myIsWrapped.
Definition at line 1647 of file SMESH_2smeshpy.cxx.
References myArgCommands, myArgMethods, myArgs, myGeom, myIsAlgo, myIsWrapped, myMesh, myNbArgsByMethod, myType2CreationMethod, and myUnknownCommands.
{
myIsWrapped = false;
myMesh = theMesh;
// myCreationCmd = theOther->myCreationCmd;
myIsAlgo = theOther->myIsAlgo;
myGeom = theOther->myGeom;
myType2CreationMethod = theOther->myType2CreationMethod;
myArgs = theOther->myArgs;
myArgMethods = theOther->myArgMethods;
myNbArgsByMethod = theOther->myNbArgsByMethod;
myArgCommands = theOther->myArgCommands;
myUnknownCommands = theOther->myUnknownCommands;
}
| bool _pyHypothesis.CanBeCreatedBy | ( | const TCollection_AsciiString & | algoType | ) | const |
Definition at line 320 of file SMESH_2smeshpy.hxx.
{ return myType2CreationMethod.find( algoType ) != myType2CreationMethod.end(); }
| void _pyHypothesis::ClearAllCommands | ( | ) |
clear creation, arg and unkown commands
Definition at line 1629 of file SMESH_2smeshpy.cxx.
References myArgCommands, and myUnknownCommands.
{
GetCreationCmd()->Clear();
list<Handle(_pyCommand)>::iterator cmd = myArgCommands.begin();
for ( ; cmd != myArgCommands.end(); ++cmd )
( *cmd )->Clear();
cmd = myUnknownCommands.begin();
for ( ; cmd != myUnknownCommands.end(); ++cmd )
( *cmd )->Clear();
}
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 _pyHypothesis::Flush | ( | ) | [virtual] |
Finish conversion.
Implements _pyObject.
Reimplemented in _pyComplexParamHypo, _pyLayerDistributionHypo, and _pyNumberOfSegmentsHyp.
Definition at line 1598 of file SMESH_2smeshpy.cxx.
References _pyGen.AddAlgoAccessorMethod(), _pyGen.AddMeshAccessorMethod(), IsWrapped(), myArgCommands, and myUnknownCommands.
{
if ( IsWrapped() ) {
}
else {
list < Handle(_pyCommand) >::iterator cmd = myArgCommands.begin();
for ( ; cmd != myArgCommands.end(); ++cmd ) {
// Add access to a wrapped mesh
theGen->AddMeshAccessorMethod( *cmd );
// Add access to a wrapped algorithm
theGen->AddAlgoAccessorMethod( *cmd );
}
cmd = myUnknownCommands.begin();
for ( ; cmd != myUnknownCommands.end(); ++cmd ) {
// Add access to a wrapped mesh
theGen->AddMeshAccessorMethod( *cmd );
// Add access to a wrapped algorithm
theGen->AddAlgoAccessorMethod( *cmd );
}
}
// forget previous hypothesis modifications
myArgCommands.clear();
myUnknownCommands.clear();
}
| const TCollection_AsciiString& _pyHypothesis.GetAlgoCreationMethod | ( | ) | const |
Definition at line 318 of file SMESH_2smeshpy.hxx.
Referenced by Addition2Creation().
{ return myType2CreationMethod.begin()->second; }
| const TCollection_AsciiString& _pyHypothesis.GetAlgoType | ( | ) | const |
Definition at line 316 of file SMESH_2smeshpy.hxx.
Referenced by _pyLayerDistributionHypo.Addition2Creation(), and Addition2Creation().
{ return myType2CreationMethod.begin()->first; }
| const std::list<Handle(_pyCommand)>& _pyHypothesis.GetArgCommands | ( | ) | const |
Definition at line 308 of file SMESH_2smeshpy.hxx.
{ return myArgCommands; }
| const TColStd_SequenceOfAsciiString& _pyHypothesis.GetArgs | ( | ) | const |
Definition at line 307 of file SMESH_2smeshpy.hxx.
{ return myArgs; }
| int _pyObject.GetCommandNb | ( | ) | [inherited] |
Definition at line 167 of file SMESH_2smeshpy.hxx.
{ return myCreationCmd->GetOrderNb(); }
| const TCollection_AsciiString& _pyHypothesis.GetCreationMethod | ( | const TCollection_AsciiString & | algoType | ) | const |
Definition at line 322 of file SMESH_2smeshpy.hxx.
Referenced by Addition2Creation().
{ return myType2CreationMethod.find( algoType )->second; }
| const _pyID& _pyHypothesis.GetGeom | ( | ) | const |
Definition at line 313 of file SMESH_2smeshpy.hxx.
{ return myGeom; }
| const _pyID& _pyObject.GetID | ( | ) | [inherited] |
Definition at line 162 of file SMESH_2smeshpy.hxx.
Referenced by _pyMesh._pyMesh(), _pyAlgorithm.Addition2Creation(), _pyLayerDistributionHypo.Addition2Creation(), Addition2Creation(), and _pyMesh.Flush().
{ return myCreationCmd->GetResultValue(); }
| const _pyID& _pyHypothesis.GetMesh | ( | ) | const |
Definition at line 315 of file SMESH_2smeshpy.hxx.
{ return myMesh; }
| 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; }
| static _pyHypothesis.Handle | ( | _pyHypothesis | ) | const [static] |
Referenced by _pySegmentLengthAroundVertexHyp.Addition2Creation(), and Addition2Creation().
| const _pyObject.Handle | ( | _pyCommand | ) | [inherited] |
Reimplemented in _pyGen, and _pyGen.
Definition at line 164 of file SMESH_2smeshpy.hxx.
{ return myCreationCmd; }
| virtual bool _pyHypothesis.IsAlgo | ( | ) | const [virtual] |
Definition at line 310 of file SMESH_2smeshpy.hxx.
Referenced by Addition2Creation().
{ return myIsAlgo; }
| bool _pyHypothesis.IsValid | ( | ) | const |
Definition at line 311 of file SMESH_2smeshpy.hxx.
{ return !myType2CreationMethod.empty(); }
Reimplemented in _pyAlgorithm.
Definition at line 324 of file SMESH_2smeshpy.hxx.
References _pyGen.theMesh.
Referenced by _pySegmentLengthAroundVertexHyp.Addition2Creation(), _pyNumberOfSegmentsHyp.Addition2Creation(), and Addition2Creation().
{ return !myIsWrapped && myMesh == theMesh; }
| bool _pyHypothesis.IsWrapped | ( | ) | const |
Definition at line 312 of file SMESH_2smeshpy.hxx.
Referenced by _pyNumberOfSegmentsHyp.Flush(), _pyComplexParamHypo.Flush(), and Flush().
{ return myIsWrapped; }
| void _pyHypothesis::Process | ( | const Handle(_pyCommand)& | theCommand | ) | [virtual] |
Remember hypothesis parameter values.
| theCommand | - The called hypothesis method |
Reimplemented from _pyObject.
Reimplemented in _pyComplexParamHypo, and _pyLayerDistributionHypo.
Definition at line 1573 of file SMESH_2smeshpy.cxx.
References _pyCommand.GetArg(), _pyCommand.GetMethod(), myArgCommands, myArgMethods, myArgs, myIsAlgo, myNbArgsByMethod, and myUnknownCommands.
{
ASSERT( !myIsAlgo );
// set args
int nbArgs = 0;
for ( int i = 1; i <= myArgMethods.Length(); ++i ) {
if ( myArgMethods( i ) == theCommand->GetMethod() ) {
while ( myArgs.Length() < nbArgs + myNbArgsByMethod( i ))
myArgs.Append( "[]" );
for ( int iArg = 1; iArg <= myNbArgsByMethod( i ); ++iArg )
myArgs( nbArgs + iArg ) = theCommand->GetArg( iArg ); // arg value
myArgCommands.push_back( theCommand );
return;
}
nbArgs += myNbArgsByMethod( i );
}
myUnknownCommands.push_back( theCommand );
}
| void _pyHypothesis.SetConvMethodAndType | ( | const char * | creationMethod, |
| const char * | type | ||
| ) |
Definition at line 303 of file SMESH_2smeshpy.hxx.
{ myType2CreationMethod[ (char*)type ] = (char*)creationMethod; }
| void _pyObject.SetCreationCmd | ( | Handle(_pyCommand) | cmd | ) | [inherited] |
Definition at line 166 of file SMESH_2smeshpy.hxx.
Referenced by Addition2Creation().
{ myCreationCmd = cmd; }
| void _pyHypothesis.SetMesh | ( | const _pyID & | theMeshId | ) |
Definition at line 314 of file SMESH_2smeshpy.hxx.
std::list<Handle(_pyCommand)> _pyHypothesis.myArgCommands [protected] |
Definition at line 299 of file SMESH_2smeshpy.hxx.
Referenced by _pyLayerDistributionHypo.Addition2Creation(), Addition2Creation(), Assign(), ClearAllCommands(), _pyNumberOfSegmentsHyp.Flush(), _pyLayerDistributionHypo.Flush(), Flush(), _pyLayerDistributionHypo.Process(), _pyComplexParamHypo.Process(), and Process().
TColStd_SequenceOfAsciiString _pyHypothesis.myArgMethods [protected] |
Definition at line 297 of file SMESH_2smeshpy.hxx.
TColStd_SequenceOfAsciiString _pyHypothesis.myArgs [protected] |
Definition at line 296 of file SMESH_2smeshpy.hxx.
Referenced by _pySegmentLengthAroundVertexHyp.Addition2Creation(), _pyNumberOfSegmentsHyp.Addition2Creation(), Addition2Creation(), Assign(), _pyComplexParamHypo.Process(), and Process().
_pyID _pyHypothesis.myGeom [protected] |
Definition at line 292 of file SMESH_2smeshpy.hxx.
Referenced by Addition2Creation(), and Assign().
bool _pyHypothesis.myIsAlgo [protected] |
Definition at line 291 of file SMESH_2smeshpy.hxx.
Referenced by _pyAlgorithm._pyAlgorithm(), _pyHypothesis(), Assign(), and Process().
bool _pyHypothesis.myIsWrapped [protected] |
Definition at line 291 of file SMESH_2smeshpy.hxx.
Referenced by _pyHypothesis(), _pyLayerDistributionHypo.Addition2Creation(), Addition2Creation(), and Assign().
_pyID _pyHypothesis.myMesh [protected] |
Definition at line 292 of file SMESH_2smeshpy.hxx.
Referenced by Assign().
TColStd_SequenceOfInteger _pyHypothesis.myNbArgsByMethod [protected] |
Definition at line 298 of file SMESH_2smeshpy.hxx.
std::map<TCollection_AsciiString, TCollection_AsciiString > _pyHypothesis.myType2CreationMethod [protected] |
Definition at line 294 of file SMESH_2smeshpy.hxx.
Referenced by Assign().
std::list<Handle(_pyCommand)> _pyHypothesis.myUnknownCommands [protected] |
Definition at line 300 of file SMESH_2smeshpy.hxx.
Referenced by _pyNumberOfSegmentsHyp.Addition2Creation(), Addition2Creation(), Assign(), ClearAllCommands(), _pyNumberOfSegmentsHyp.Flush(), _pyComplexParamHypo.Flush(), Flush(), and Process().