X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESH_I%2FSMESH_2smeshpy.cxx;h=42358009e60b9a81fc86162554b2156319182337;hb=b03a1e600155a03e2ae01e31960837e51831db70;hp=be494755b28c174179b200e69b054300767cd71a;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index be494755b..42358009e 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -45,7 +45,7 @@ IMPLEMENT_STANDARD_HANDLE (_pyMesh ,_pyObject); 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); @@ -57,7 +57,7 @@ IMPLEMENT_STANDARD_RTTIEXT(_pyMesh ,_pyObject); 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); @@ -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,13 +196,12 @@ 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 ) { myNbCommands = 0; - myHasPattern = false; // make that GetID() to return TPythonDump::SMESHGenName() GetCreationCmd()->GetString() += "="; } @@ -241,17 +240,10 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand 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 ); @@ -267,21 +259,13 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand 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() ) { @@ -303,6 +287,20 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand 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 ); @@ -397,13 +395,12 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) } } - // 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, ...], ... ) @@ -448,9 +445,6 @@ void _pyGen::Flush() // 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() ) @@ -465,10 +459,10 @@ void _pyGen::Flush() (*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 ); @@ -548,7 +542,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; @@ -564,12 +558,9 @@ Handle(_pyHypothesis) _pyGen::FindAlgo( const _pyID& theGeom, const _pyID& theMe 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)(); } @@ -634,8 +625,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 ); @@ -690,8 +681,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; } @@ -895,6 +886,34 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) // 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();indFindSubMesh( theCommand->GetResultValue(ind) ); + // SetMeshOrder + //for(int ind = 0, n = theCommand->GetNbArgs();indFindSubMesh( 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 { @@ -929,7 +948,7 @@ bool _pyMesh::NeedMeshAccess( const Handle(_pyCommand)& theCommand ) "GetNodeInverseElements","GetShapeID","GetShapeIDForElem","GetElemNbNodes", "GetElemNode","IsMediumNode","IsMediumNodeOfAnyElem","ElemNbEdges","ElemNbFaces", "IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor", - "Clear", "ConvertToStandalone" + "Clear", "ConvertToStandalone", "GetMeshOrder", "SetMeshOrder" ,"" }; // <- mark of end sameMethods.Insert( names ); } @@ -962,21 +981,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() ); @@ -992,14 +1011,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 ); } } } @@ -1076,7 +1095,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", @@ -1217,14 +1236,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"); @@ -1274,16 +1300,42 @@ 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()); + 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=smesh.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=smesh.SIMPLE" ); + } else if ( hypType == "NETGEN_2D_ONLY") { // 2D algo->SetConvMethodAndType( "Triangle" , hypType.ToCString()); algo->myArgs.Append( "algo=smesh.NETGEN_2D" ); @@ -1301,8 +1353,11 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th 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 --------- @@ -1506,7 +1561,7 @@ void _pyHypothesis::ClearAllCommands() //================================================================================ void _pyHypothesis::Assign( const Handle(_pyHypothesis)& theOther, - const _pyID& theMesh ) + const _pyID& theMesh ) { myIsWrapped = false; myMesh = theMesh; @@ -1531,15 +1586,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(); + } } //================================================================================ @@ -1710,6 +1788,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 }; @@ -1944,18 +2024,32 @@ 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 ( IsEqual(myString.Value( i ), "'" ) ) - nb1 += 1; - else if ( IsEqual( 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; } - // 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); @@ -2008,16 +2102,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 ); @@ -2074,9 +2168,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 @@ -2085,9 +2189,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; @@ -2307,52 +2420,16 @@ _pyID _pyObject::FatherID(const _pyID & childID) //================================================================================ /*! - * \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 @@ -2361,7 +2438,7 @@ _pySubMesh::_pySubMesh(const Handle(_pyCommand)& theCreationCmd): void _pySubMesh::Process( const Handle(_pyCommand)& theCommand ) { - myCmdCount++; + _pyObject::Process(theCommand); // count calls of Process() GetCreationCmd()->AddDependantCmd( theCommand ); } @@ -2373,7 +2450,7 @@ void _pySubMesh::Process( const Handle(_pyCommand)& 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