mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 18:30:35 +05:00
PAL13639 (EDF PAL 317 : SMESH : Create "0D Hypothesis")
add _pyObject::FatherID(const _pyID & childID) improve _pyHypothesis::Addition2Creation() fix _pySegmentLengthAroundVertexHyp::Addition2Creation()
This commit is contained in:
parent
cd229cc422
commit
4ce06bc8ac
@ -229,7 +229,8 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
|
|||||||
// CreateHypothesis( theHypType, theLibName )
|
// CreateHypothesis( theHypType, theLibName )
|
||||||
// Compute( mesh, geom )
|
// Compute( mesh, geom )
|
||||||
|
|
||||||
if ( theCommand->GetMethod() == "CreateMesh" )
|
if ( theCommand->GetMethod() == "CreateMesh" ||
|
||||||
|
theCommand->GetMethod() == "CreateEmptyMesh" )
|
||||||
{
|
{
|
||||||
Handle(_pyMesh) mesh = new _pyMesh( theCommand );
|
Handle(_pyMesh) mesh = new _pyMesh( theCommand );
|
||||||
myMeshes.insert( make_pair( mesh->GetID(), mesh ));
|
myMeshes.insert( make_pair( mesh->GetID(), mesh ));
|
||||||
@ -715,16 +716,7 @@ void _pyMesh::Flush()
|
|||||||
Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID );
|
Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID );
|
||||||
if ( hyp.IsNull() || hyp->IsAlgo() )
|
if ( hyp.IsNull() || hyp->IsAlgo() )
|
||||||
continue;
|
continue;
|
||||||
const _pyID& geom = addCmd->GetArg( 1 );
|
if ( !hyp->Addition2Creation( addCmd, this->GetID() ))
|
||||||
// find algo created on <geom> for this mesh
|
|
||||||
Handle(_pyHypothesis) algo = theGen->FindAlgo( geom, this->GetID(), hyp->GetType() );
|
|
||||||
//_pyID algoID = algo.IsNull() ? "" : algo->GetID();
|
|
||||||
if ( !algo.IsNull() && hyp->Addition2Creation( addCmd, this->GetID() )) // OK
|
|
||||||
{
|
|
||||||
addCmd->SetObject( algo->GetID() );
|
|
||||||
algo->GetCreationCmd()->AddDependantCmd( addCmd );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
AddMeshAccess( addCmd );
|
AddMeshAccess( addCmd );
|
||||||
// add addition result treatement cmd
|
// add addition result treatement cmd
|
||||||
@ -789,8 +781,13 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
|
|||||||
// 1D Regular_1D ----------
|
// 1D Regular_1D ----------
|
||||||
if ( hypType == "Regular_1D" ) {
|
if ( hypType == "Regular_1D" ) {
|
||||||
// set mesh's method creating algo,
|
// set mesh's method creating algo,
|
||||||
// i.e. convertion result will be "regular1d = Mesh.Segment()"
|
// i.e. convertion result will be "regular1d = Mesh.Segment()",
|
||||||
algo->SetConvMethodAndType("Segment");
|
// and set hypType by which algo creating a hypothesis is searched for
|
||||||
|
algo->SetConvMethodAndType("Segment", hypType.ToCString());
|
||||||
|
}
|
||||||
|
else if ( hypType == "CompositeSegment_1D" ) {
|
||||||
|
algo->SetConvMethodAndType("Segment", "Regular_1D");
|
||||||
|
algo->myArgs.Append( "algo=smesh.COMPOSITE");
|
||||||
}
|
}
|
||||||
else if ( hypType == "LocalLength" ) {
|
else if ( hypType == "LocalLength" ) {
|
||||||
// set algo's method creating hyp, and algo type
|
// set algo's method creating hyp, and algo type
|
||||||
@ -836,7 +833,7 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
|
|||||||
}
|
}
|
||||||
// 1D Python_1D ----------
|
// 1D Python_1D ----------
|
||||||
else if ( hypType == "Python_1D" ) {
|
else if ( hypType == "Python_1D" ) {
|
||||||
algo->SetConvMethodAndType( "Segment");
|
algo->SetConvMethodAndType( "Segment", hypType.ToCString());
|
||||||
algo->myArgs.Append( "algo=smesh.PYTHON");
|
algo->myArgs.Append( "algo=smesh.PYTHON");
|
||||||
}
|
}
|
||||||
else if ( hypType == "PythonSplit1D" ) {
|
else if ( hypType == "PythonSplit1D" ) {
|
||||||
@ -846,7 +843,7 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
|
|||||||
}
|
}
|
||||||
// 2D ----------
|
// 2D ----------
|
||||||
else if ( hypType == "MEFISTO_2D" ) {
|
else if ( hypType == "MEFISTO_2D" ) {
|
||||||
algo->SetConvMethodAndType( "Triangle");
|
algo->SetConvMethodAndType( "Triangle", hypType.ToCString());
|
||||||
}
|
}
|
||||||
else if ( hypType == "MaxElementArea" ) {
|
else if ( hypType == "MaxElementArea" ) {
|
||||||
hyp->SetConvMethodAndType( "MaxElementArea", "MEFISTO_2D");
|
hyp->SetConvMethodAndType( "MaxElementArea", "MEFISTO_2D");
|
||||||
@ -856,14 +853,14 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
|
|||||||
hyp->SetConvMethodAndType( "LengthFromEdges", "MEFISTO_2D");
|
hyp->SetConvMethodAndType( "LengthFromEdges", "MEFISTO_2D");
|
||||||
}
|
}
|
||||||
else if ( hypType == "Quadrangle_2D" ) {
|
else if ( hypType == "Quadrangle_2D" ) {
|
||||||
algo->SetConvMethodAndType( "Quadrangle" );
|
algo->SetConvMethodAndType( "Quadrangle" , hypType.ToCString());
|
||||||
}
|
}
|
||||||
else if ( hypType == "QuadranglePreference" ) {
|
else if ( hypType == "QuadranglePreference" ) {
|
||||||
hyp->SetConvMethodAndType( "QuadranglePreference", "Quadrangle_2D");
|
hyp->SetConvMethodAndType( "QuadranglePreference", "Quadrangle_2D");
|
||||||
}
|
}
|
||||||
// 3D ----------
|
// 3D ----------
|
||||||
else if ( hypType == "NETGEN_3D") {
|
else if ( hypType == "NETGEN_3D") {
|
||||||
algo->SetConvMethodAndType( "Tetrahedron" );
|
algo->SetConvMethodAndType( "Tetrahedron" , hypType.ToCString());
|
||||||
algo->myArgs.Append( "algo=smesh.NETGEN" );
|
algo->myArgs.Append( "algo=smesh.NETGEN" );
|
||||||
}
|
}
|
||||||
else if ( hypType == "MaxElementVolume") {
|
else if ( hypType == "MaxElementVolume") {
|
||||||
@ -871,15 +868,15 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
|
|||||||
hyp->AddArgMethod( "SetMaxElementVolume" );
|
hyp->AddArgMethod( "SetMaxElementVolume" );
|
||||||
}
|
}
|
||||||
else if ( hypType == "GHS3D_3D" ) {
|
else if ( hypType == "GHS3D_3D" ) {
|
||||||
algo->SetConvMethodAndType( "Tetrahedron");
|
algo->SetConvMethodAndType( "Tetrahedron", hypType.ToCString());
|
||||||
algo->myArgs.Append( "algo=smesh.GHS3D" );
|
algo->myArgs.Append( "algo=smesh.GHS3D" );
|
||||||
}
|
}
|
||||||
else if ( hypType == "Hexa_3D" ) {
|
else if ( hypType == "Hexa_3D" ) {
|
||||||
algo->SetConvMethodAndType( "Hexahedron");
|
algo->SetConvMethodAndType( "Hexahedron", hypType.ToCString());
|
||||||
}
|
}
|
||||||
// Repetitive ---------
|
// Repetitive ---------
|
||||||
else if ( hypType == "Projection_1D" ) {
|
else if ( hypType == "Projection_1D" ) {
|
||||||
algo->SetConvMethodAndType( "Projection1D");
|
algo->SetConvMethodAndType( "Projection1D", hypType.ToCString());
|
||||||
}
|
}
|
||||||
else if ( hypType == "ProjectionSource1D" ) {
|
else if ( hypType == "ProjectionSource1D" ) {
|
||||||
hyp->SetConvMethodAndType( "SourceEdge", "Projection_1D");
|
hyp->SetConvMethodAndType( "SourceEdge", "Projection_1D");
|
||||||
@ -889,7 +886,7 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
|
|||||||
hyp->AddArgMethod( "SetVertexAssociation", 2 );
|
hyp->AddArgMethod( "SetVertexAssociation", 2 );
|
||||||
}
|
}
|
||||||
else if ( hypType == "Projection_2D" ) {
|
else if ( hypType == "Projection_2D" ) {
|
||||||
algo->SetConvMethodAndType( "Projection2D");
|
algo->SetConvMethodAndType( "Projection2D", hypType.ToCString());
|
||||||
}
|
}
|
||||||
else if ( hypType == "ProjectionSource2D" ) {
|
else if ( hypType == "ProjectionSource2D" ) {
|
||||||
hyp->SetConvMethodAndType( "SourceFace", "Projection_2D");
|
hyp->SetConvMethodAndType( "SourceFace", "Projection_2D");
|
||||||
@ -898,7 +895,7 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
|
|||||||
hyp->AddArgMethod( "SetVertexAssociation", 4 );
|
hyp->AddArgMethod( "SetVertexAssociation", 4 );
|
||||||
}
|
}
|
||||||
else if ( hypType == "Projection_3D" ) {
|
else if ( hypType == "Projection_3D" ) {
|
||||||
algo->SetConvMethodAndType( "Projection3D");
|
algo->SetConvMethodAndType( "Projection3D", hypType.ToCString());
|
||||||
}
|
}
|
||||||
else if ( hypType == "ProjectionSource3D" ) {
|
else if ( hypType == "ProjectionSource3D" ) {
|
||||||
hyp->SetConvMethodAndType( "SourceShape3D", "Projection_3D");
|
hyp->SetConvMethodAndType( "SourceShape3D", "Projection_3D");
|
||||||
@ -907,10 +904,10 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
|
|||||||
hyp->AddArgMethod( "SetVertexAssociation", 4 );
|
hyp->AddArgMethod( "SetVertexAssociation", 4 );
|
||||||
}
|
}
|
||||||
else if ( hypType == "Prism_3D" ) {
|
else if ( hypType == "Prism_3D" ) {
|
||||||
algo->SetConvMethodAndType( "Prism");
|
algo->SetConvMethodAndType( "Prism", hypType.ToCString());
|
||||||
}
|
}
|
||||||
else if ( hypType == "RadialPrism_3D" ) {
|
else if ( hypType == "RadialPrism_3D" ) {
|
||||||
algo->SetConvMethodAndType( "Prism");
|
algo->SetConvMethodAndType( "Prism", hypType.ToCString());
|
||||||
}
|
}
|
||||||
else if ( hypType == "NumberOfLayers" ) {
|
else if ( hypType == "NumberOfLayers" ) {
|
||||||
hyp->SetConvMethodAndType( "NumberOfLayers", "RadialPrism_3D");
|
hyp->SetConvMethodAndType( "NumberOfLayers", "RadialPrism_3D");
|
||||||
@ -922,7 +919,6 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !algo->GetCreationMethod().IsEmpty() ) {
|
if ( !algo->GetCreationMethod().IsEmpty() ) {
|
||||||
algo->myType = hypType;
|
|
||||||
return algo;
|
return algo;
|
||||||
}
|
}
|
||||||
return hyp;
|
return hyp;
|
||||||
@ -945,39 +941,38 @@ bool _pyHypothesis::Addition2Creation( const Handle(_pyCommand)& theCmd,
|
|||||||
if ( !IsWrappable( theMesh ))
|
if ( !IsWrappable( theMesh ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
myGeom = theCmd->GetArg( 1 );
|
||||||
|
|
||||||
|
Handle(_pyHypothesis) algo;
|
||||||
|
if ( !IsAlgo() ) {
|
||||||
|
// find algo created on myGeom in theMesh
|
||||||
|
algo = theGen->FindAlgo( myGeom, theMesh, GetType() );
|
||||||
|
if ( algo.IsNull() )
|
||||||
|
return false;
|
||||||
|
algo->GetCreationCmd()->AddDependantCmd( theCmd );
|
||||||
|
}
|
||||||
myIsWrapped = true;
|
myIsWrapped = true;
|
||||||
|
|
||||||
if ( myIsWrapped )
|
// mesh.AddHypothesis(geom,hyp) --> hyp = <theMesh or algo>.myCreationMethod(args)
|
||||||
{
|
theCmd->SetResultValue( GetID() );
|
||||||
// mesh.AddHypothesis(geom,hyp) --> hyp = theMesh.myCreationMethod(args)
|
theCmd->SetObject( IsAlgo() ? theMesh : algo->GetID());
|
||||||
theCmd->SetResultValue( GetID() );
|
theCmd->SetMethod( myCreationMethod );
|
||||||
theCmd->SetObject( theMesh );
|
// set args
|
||||||
theCmd->SetMethod( myCreationMethod );
|
theCmd->RemoveArgs();
|
||||||
// set args
|
for ( int i = 1; i <= myArgs.Length(); ++i ) {
|
||||||
theCmd->RemoveArgs();
|
if ( !myArgs( i ).IsEmpty() )
|
||||||
for ( int i = 1; i <= myArgs.Length(); ++i ) {
|
theCmd->SetArg( i, myArgs( i ));
|
||||||
if ( !myArgs( i ).IsEmpty() )
|
else
|
||||||
theCmd->SetArg( i, myArgs( i ));
|
theCmd->SetArg( i, "[]");
|
||||||
else
|
}
|
||||||
theCmd->SetArg( i, "[]");
|
// set a new creation command
|
||||||
}
|
GetCreationCmd()->Clear();
|
||||||
// set a new creation command
|
SetCreationCmd( theCmd );
|
||||||
GetCreationCmd()->Clear();
|
|
||||||
SetCreationCmd( theCmd );
|
|
||||||
|
|
||||||
// clear commands setting arg values
|
// clear commands setting arg values
|
||||||
list < Handle(_pyCommand) >::iterator argCmd = myArgCommands.begin();
|
list < Handle(_pyCommand) >::iterator argCmd = myArgCommands.begin();
|
||||||
for ( ; argCmd != myArgCommands.end(); ++argCmd )
|
for ( ; argCmd != myArgCommands.end(); ++argCmd )
|
||||||
(*argCmd)->Clear();
|
(*argCmd)->Clear();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// // set arg commands after hypo creation
|
|
||||||
// list<Handle(_pyCommand)>::iterator argCmd = myArgCommands.begin();
|
|
||||||
// for ( ; argCmd != myArgCommands.end(); ++argCmd )
|
|
||||||
// if ( !(*argCmd)->IsEmpty() && GetCommandNb() > (*argCmd)->GetOrderNb() )
|
|
||||||
// theGen->ExchangeCommands( GetCreationCmd(), *argCmd );
|
|
||||||
}
|
|
||||||
|
|
||||||
// set unknown arg commands after hypo creation
|
// set unknown arg commands after hypo creation
|
||||||
Handle(_pyCommand) afterCmd = myIsWrapped ? theCmd : GetCreationCmd();
|
Handle(_pyCommand) afterCmd = myIsWrapped ? theCmd : GetCreationCmd();
|
||||||
@ -1289,12 +1284,28 @@ bool _pySegmentLengthAroundVertexHyp::Addition2Creation( const Handle(_pyCommand
|
|||||||
|
|
||||||
_pyID vertex = theCmd->GetArg( 1 );
|
_pyID vertex = theCmd->GetArg( 1 );
|
||||||
|
|
||||||
// mesh.AddHypothesis(vertex, SegmentLengthAroundVertex) --> theMeshID.LengthNearVertex( length )
|
// the problem here is that segment algo will not be found
|
||||||
if ( _pyHypothesis::Addition2Creation( theCmd, theMeshID )) {
|
// by pyHypothesis::Addition2Creation() for <vertex>, so we try to find
|
||||||
// set 2-nd arg
|
// geometry where segment algorithm is assigned
|
||||||
theCmd->SetArg( 2, vertex );
|
Handle(_pyHypothesis) algo;
|
||||||
return true;
|
_pyID geom = vertex;
|
||||||
|
while ( algo.IsNull() && !geom.IsEmpty()) {
|
||||||
|
// try to find geom as a father of <vertex>
|
||||||
|
geom = FatherID( geom );
|
||||||
|
algo = theGen->FindAlgo( geom, theMeshID, GetType() );
|
||||||
}
|
}
|
||||||
|
if ( algo.IsNull() )
|
||||||
|
return false; // also possible to find geom as brother of veretex...
|
||||||
|
// set geom instead of vertex
|
||||||
|
theCmd->SetArg( 1, geom );
|
||||||
|
|
||||||
|
// set vertex as a second arg
|
||||||
|
if ( myArgs.Length() < 1) myArgs.Append( "1" ); // :(
|
||||||
|
myArgs.Append( vertex );
|
||||||
|
|
||||||
|
// mesh.AddHypothesis(vertex, SegmentLengthAroundVertex) -->
|
||||||
|
// theMeshID.LengthNearVertex( length, vertex )
|
||||||
|
return _pyHypothesis::Addition2Creation( theCmd, theMeshID );
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1324,15 +1335,10 @@ _pyAlgorithm::_pyAlgorithm(const Handle(_pyCommand)& theCreationCmd)
|
|||||||
bool _pyAlgorithm::Addition2Creation( const Handle(_pyCommand)& theCmd,
|
bool _pyAlgorithm::Addition2Creation( const Handle(_pyCommand)& theCmd,
|
||||||
const _pyID& theMeshID)
|
const _pyID& theMeshID)
|
||||||
{
|
{
|
||||||
if ( IsWrappable( theMeshID )) {
|
// mesh.AddHypothesis(geom,algo) --> theMeshID.myCreationMethod()
|
||||||
|
if ( _pyHypothesis::Addition2Creation( theCmd, theMeshID )) {
|
||||||
myGeom = theCmd->GetArg( 1 );
|
theGen->SetAccessorMethod( GetID(), "GetAlgorithm()" );
|
||||||
|
return true;
|
||||||
// mesh.AddHypothesis(geom,algo) --> theMeshID.myCreationMethod()
|
|
||||||
if ( _pyHypothesis::Addition2Creation( theCmd, theMeshID )) {
|
|
||||||
theGen->SetAccessorMethod( GetID(), "GetAlgorithm()" );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1750,3 +1756,16 @@ const char* _pyObject::AccessorMethod() const
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Return ID of a father
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
_pyID _pyObject::FatherID(const _pyID & childID)
|
||||||
|
{
|
||||||
|
int colPos = childID.SearchFromEnd(':');
|
||||||
|
if ( colPos > 0 )
|
||||||
|
return childID.SubString( 1, colPos-1 );
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user