X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_2smeshpy.cxx;h=e966c781aafeca730549c6477ab2189bc64bade5;hb=1724cd310e878cad4c2f89cacea8761303d52668;hp=95fbcd78835bd345a4708102aa00016d65865d70;hpb=2534543b1e753cfa3cf12001e35d83f63f9cfb6d;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 95fbcd788..e966c781a 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -121,7 +121,7 @@ namespace { TCollection_AsciiString SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScript, Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod, - Resource_DataMapOfAsciiStringAsciiString& theObjectNames) + Resource_DataMapOfAsciiStringAsciiString& theObjectNames) { theGen = new _pyGen( theEntry2AccessorMethod, theObjectNames ); @@ -196,7 +196,7 @@ SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScript, //================================================================================ _pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod, - Resource_DataMapOfAsciiStringAsciiString& theObjectNames) + Resource_DataMapOfAsciiStringAsciiString& theObjectNames) : _pyObject( new _pyCommand( TPythonDump::SMESHGenName(), 0 )), myID2AccessorMethod( theEntry2AccessorMethod ), myObjectNames( theObjectNames ) @@ -541,7 +541,7 @@ Handle(_pyHypothesis) _pyGen::FindAlgo( const _pyID& theGeom, const _pyID& theMe if ( !hyp->IsNull() && (*hyp)->IsAlgo() && theHypothesis->CanBeCreatedBy( (*hyp)->GetAlgoType() ) && - (*hyp)->GetGeom() == theGeom && + (*hyp)->GetGeom() == theGeom && (*hyp)->GetMesh() == theMesh ) return *hyp; return 0; @@ -624,8 +624,8 @@ void _pyGen::SetCommandBefore( Handle(_pyCommand) theCmd, Handle(_pyCommand) the //================================================================================ void _pyGen::setNeighbourCommand( Handle(_pyCommand)& theCmd, - Handle(_pyCommand)& theOtherCmd, - const bool theIsAfter ) + Handle(_pyCommand)& theOtherCmd, + const bool theIsAfter ) { list< Handle(_pyCommand) >::iterator pos; pos = find( myCommands.begin(), myCommands.end(), theCmd ); @@ -680,8 +680,8 @@ _pyID _pyGen::GenerateNewID( const _pyID& theID ) while ( myObjectNames.IsBound( aNewID ) ); myObjectNames.Bind( aNewID, myObjectNames.IsBound( theID ) - ? (myObjectNames.Find( theID ) + _pyID( "_" ) + _pyID( index-1 )) - : _pyID( "A" ) + aNewID ); + ? (myObjectNames.Find( theID ) + _pyID( "_" ) + _pyID( index-1 )) + : _pyID( "A" ) + aNewID ); return aNewID; } @@ -952,21 +952,21 @@ void _pyMesh::Flush() if ( algo->IsWrapped() ) { _pyID localAlgoID = theGen->GenerateNewID( algoID ); TCollection_AsciiString aNewCmdStr = localAlgoID + - TCollection_AsciiString( " = " ) + theGen->GetID() + - TCollection_AsciiString( ".CreateHypothesis( \"" ) + algo->GetAlgoType() + - TCollection_AsciiString( "\" )" ); + 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 ); + newAlgo->Assign( algo, this->GetID() ); + newAlgo->SetCreationCmd( newCmd ); + algo = newAlgo; + // set algorithm creation + theGen->SetCommandBefore( newCmd, addCmd ); } else - newCmd->Clear(); + newCmd->Clear(); } _pyID geom = addCmd->GetArg( 1 ); bool isLocalAlgo = ( geom != GetGeom() ); @@ -982,14 +982,14 @@ void _pyMesh::Flush() addCmd->SetArg( addCmd->GetNbArgs() + 1, TCollection_AsciiString( "geom=" ) + geom ); // sm = mesh.GetSubMesh(geom, name) --> sm = ALGO.GetSubMesh() - list < Handle(_pySubMesh) >::iterator smIt; + list < Handle(_pySubMesh) >::iterator smIt; for ( smIt = mySubmeshes.begin(); smIt != mySubmeshes.end(); ++smIt ) { - Handle(_pySubMesh) subMesh = *smIt; + Handle(_pySubMesh) subMesh = *smIt; Handle(_pyCommand) subCmd = subMesh->GetCreationCmd(); if ( geom == subCmd->GetArg( 1 )) { subCmd->SetObject( algo->GetID() ); subCmd->RemoveArgs(); - subMesh->SetCreator( algo ); + subMesh->SetCreator( algo ); } } } @@ -1066,7 +1066,7 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) static TStringSet sameMethods; if ( sameMethods.empty() ) { const char * names[] = { - "RemoveElements","RemoveNodes","AddNode","AddEdge","AddFace","AddPolygonalFace", + "RemoveElements","RemoveNodes","AddNode","Add0DElement","AddEdge","AddFace","AddPolygonalFace", "AddVolume","AddPolyhedralVolume","AddPolyhedralVolumeByFaces","MoveNode", "MoveClosestNodeToPoint", "InverseDiag","DeleteDiag","Reorient","ReorientObject","TriToQuad","SplitQuad","SplitQuadObject", "BestSplit","Smooth","SmoothObject","SmoothParametric","SmoothParametricObject", @@ -1074,6 +1074,7 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) "RotationSweep","RotationSweepObject","RotationSweepObject1D","RotationSweepObject2D", "ExtrusionSweep","AdvancedExtrusion","ExtrusionSweepObject","ExtrusionSweepObject1D","ExtrusionSweepObject2D", "ExtrusionAlongPath","ExtrusionAlongPathObject","ExtrusionAlongPathObject1D","ExtrusionAlongPathObject2D", + "ExtrusionAlongPathX","ExtrusionAlongPathObjX", "Mirror","MirrorObject","Translate","TranslateObject","Rotate","RotateObject", "FindCoincidentNodes","FindCoincidentNodesOnPart","MergeNodes","FindEqualElements", "MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders", @@ -1207,14 +1208,21 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th hyp->AddArgMethod( "SetNumberOfSegments" ); // arg of SetScaleFactor() will become the 2-nd arg of hyp creation command hyp->AddArgMethod( "SetScaleFactor" ); + hyp->AddArgMethod( "SetReversedEdges" ); } else if ( hypType == "Arithmetic1D" ) { hyp = new _pyComplexParamHypo( theCreationCmd ); hyp->SetConvMethodAndType( "Arithmetic1D", "Regular_1D"); + hyp->AddArgMethod( "SetStartLength" ); + hyp->AddArgMethod( "SetEndLength" ); + hyp->AddArgMethod( "SetReversedEdges" ); } else if ( hypType == "StartEndLength" ) { hyp = new _pyComplexParamHypo( theCreationCmd ); hyp->SetConvMethodAndType( "StartEndLength", "Regular_1D"); + hyp->AddArgMethod( "SetStartLength" ); + hyp->AddArgMethod( "SetEndLength" ); + hyp->AddArgMethod( "SetReversedEdges" ); } else if ( hypType == "Deflection1D" ) { hyp->SetConvMethodAndType( "Deflection1D", "Regular_1D"); @@ -1264,11 +1272,11 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th } else if ( hypType == "QuadranglePreference" ) { hyp->SetConvMethodAndType( "QuadranglePreference", "Quadrangle_2D"); - hyp->SetConvMethodAndType( "QuadranglePreference", "NETGEN_2D_ONLY"); + hyp->SetConvMethodAndType( "SetQuadAllowed", "NETGEN_2D_ONLY"); } else if ( hypType == "TrianglePreference" ) { hyp->SetConvMethodAndType( "TrianglePreference", "Quadrangle_2D"); - } + } // BLSURF ---------- else if ( hypType == "BLSURF" ) { algo->SetConvMethodAndType( "Triangle", hypType.ToCString()); @@ -1371,6 +1379,10 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th hyp = new _pyLayerDistributionHypo( theCreationCmd ); hyp->SetConvMethodAndType( "LayerDistribution", "RadialPrism_3D"); } + else if ( hypType == "LayerDistribution2D" ) { + hyp = new _pyLayerDistributionHypo( theCreationCmd ); + hyp->SetConvMethodAndType( "LayerDistribution2D", "RadialQuadrangle_1D2D"); + } if ( algo->IsValid() ) { return algo; @@ -1525,7 +1537,7 @@ void _pyHypothesis::ClearAllCommands() //================================================================================ void _pyHypothesis::Assign( const Handle(_pyHypothesis)& theOther, - const _pyID& theMesh ) + const _pyID& theMesh ) { myIsWrapped = false; myMesh = theMesh; @@ -1550,15 +1562,38 @@ void _pyHypothesis::Assign( const Handle(_pyHypothesis)& theOther, void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand) { - // ex: hyp.SetLength(start, 1) - // hyp.SetLength(end, 0) - ASSERT(( theCommand->GetMethod() == "SetLength" )); - ASSERT(( theCommand->GetArg( 2 ).IsIntegerValue() )); - int i = 2 - theCommand->GetArg( 2 ).IntegerValue(); - while ( myArgs.Length() < i ) - myArgs.Append( "[]" ); - myArgs( i ) = theCommand->GetArg( 1 ); // arg value - myArgCommands.push_back( theCommand ); + if( theCommand->GetMethod() == "SetLength" ) + { + // NOW it becomes OBSOLETE + // ex: hyp.SetLength(start, 1) + // hyp.SetLength(end, 0) + ASSERT(( theCommand->GetArg( 2 ).IsIntegerValue() )); + int i = 2 - theCommand->GetArg( 2 ).IntegerValue(); + while ( myArgs.Length() < i ) + myArgs.Append( "[]" ); + myArgs( i ) = theCommand->GetArg( 1 ); // arg value + myArgCommands.push_back( theCommand ); + } + else + { + _pyHypothesis::Process( theCommand ); + } +} +//================================================================================ +/*! + * \brief Clear SetObjectEntry() as it is called by methods of Mesh_Segment + */ +//================================================================================ + +void _pyComplexParamHypo::Flush() +{ + if ( IsWrapped() ) + { + list < Handle(_pyCommand) >::iterator cmd = myUnknownCommands.begin(); + for ( ; cmd != myUnknownCommands.end(); ++cmd ) + if ((*cmd)->GetMethod() == "SetObjectEntry" ) + (*cmd)->Clear(); + } } //================================================================================ @@ -1729,6 +1764,8 @@ void _pyNumberOfSegmentsHyp::Flush() for ( ; !distrTypeNb && cmd != myUnknownCommands.rend(); ++cmd ) if ( (*cmd)->GetMethod() == "SetDistrType" ) distrTypeNb = (*cmd)->GetOrderNb(); + else if (IsWrapped() && (*cmd)->GetMethod() == "SetObjectEntry" ) + (*cmd)->Clear(); // clear commands before the last SetDistrType() list * cmds[2] = { &myArgCommands, &myUnknownCommands }; @@ -1963,15 +2000,15 @@ const TCollection_AsciiString & _pyCommand::GetObject() 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 ( myString.Value( i )=='\'' ) - nb1 += 1; - else if ( myString.Value( i )=='"' ) - nb2 += 1; + if ( myString.Value( i )=='\'' ) + nb1 += 1; + else if ( myString.Value( i )=='"' ) + nb2 += 1; } // if number of ' or " is not divisible by 2, // then get an object at the start of the command if ( nb1 % 2 != 0 || nb2 % 2 != 0 ) - begPos = 1; + begPos = 1; } myObj = GetWord( myString, begPos, true ); // check if object is complex, @@ -2041,16 +2078,16 @@ const TCollection_AsciiString & _pyCommand::GetArg( int index ) while ( begPos != EMPTY ) { begPos += prevLen; if( myString.Value( begPos ) == '(' ) - nbNestings++; + nbNestings++; // check if we are looking at the closing parenthesis while ( begPos <= Length() && isspace( myString.Value( begPos ))) ++begPos; if ( begPos > Length() ) break; if ( myString.Value( begPos ) == ')' ) { - nbNestings--; - if( nbNestings == 0 ) - break; + nbNestings--; + if( nbNestings == 0 ) + break; } myArgs.Append( GetWord( myString, begPos, true, true )); SetBegPos( ARG1_IND + i, begPos ); @@ -2107,9 +2144,19 @@ TCollection_AsciiString _pyCommand::GetWord( const TCollection_AsciiString & the return theEmptyString; // no word found // end end = beg + 1; - while ( end <= theString.Length() && isWord( theString.Value( end ), dotIsWord)) - ++end; - --end; + char begChar = theString.Value( beg ); + if ( begChar == '"' || begChar == '\'' || begChar == '[') { + char endChar = ( begChar == '[' ) ? ']' : begChar; + // end is at the corresponding quoting mark or bracket + while ( end < theString.Length() && + ( theString.Value( end ) != endChar || theString.Value( end-1 ) == '\\')) + ++end; + } + else { + while ( end <= theString.Length() && isWord( theString.Value( end ), dotIsWord)) + ++end; + --end; + } } else { // search backward // end @@ -2118,9 +2165,18 @@ TCollection_AsciiString _pyCommand::GetWord( const TCollection_AsciiString & the if ( end == 0 ) return theEmptyString; // no word found beg = end - 1; - while ( beg > 0 && isWord( theString.Value( beg ), dotIsWord)) - --beg; - ++beg; + char endChar = theString.Value( end ); + if ( endChar == '"' || endChar == '\'' ) { + // beg is at the corresponding quoting mark + while ( beg > 1 && + ( theString.Value( beg ) != endChar || theString.Value( beg-1 ) == '\\')) + --beg; + } + else { + while ( beg > 0 && isWord( theString.Value( beg ), dotIsWord)) + --beg; + ++beg; + } } theStartPos = beg; //cout << theString << " ---- " << beg << " - " << end << endl;