X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_2smeshpy.cxx;h=c9d70e0bf315b236e860f33e6dd4314d11dc1e28;hp=998266806c6a5fb5cbf932c74eafd54a1259bb70;hb=07ec002dfd20ec187228e11533e8e2135eca08fd;hpb=856524def1094611dfd996d00a5226cee4b0c3cf diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 998266806..c9d70e0bf 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -81,6 +81,7 @@ static TCollection_AsciiString theEmptyString; #undef DUMP_CONVERSION #endif + namespace { //================================================================================ @@ -250,7 +251,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand AddMeshAccessorMethod( aCommand ); // Add access to a wrapped algorithm - AddAlgoAccessorMethod( aCommand ); // ??? what if algo won't be wrapped at all ??? + // AddAlgoAccessorMethod( aCommand ); // ??? what if algo won't be wrapped at all ??? // PAL12227. PythonDump was not updated at proper time; result is // aCriteria.append(SMESH.Filter.Criterion(17,26,0,'L1',26,25,1e-07,SMESH.EDGE,-1)) @@ -287,16 +288,26 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) // Concatenate( [mesh1, ...], ... ) // CreateHypothesis( theHypType, theLibName ) // Compute( mesh, geom ) - // mesh creation if ( theCommand->GetMethod() == "CreateMesh" || - theCommand->GetMethod() == "CreateEmptyMesh" ) + theCommand->GetMethod() == "CreateEmptyMesh" || + theCommand->GetMethod() == "CreateMeshesFromUNV" || + theCommand->GetMethod() == "CreateMeshesFromSTL") { Handle(_pyMesh) mesh = new _pyMesh( theCommand ); myMeshes.insert( make_pair( mesh->GetID(), mesh )); return; } + if(theCommand->GetMethod() == "CreateMeshesFromMED") + { + for(int ind = 0;indGetNbResultValues();ind++) + { + Handle(_pyMesh) mesh = new _pyMesh( theCommand, theCommand->GetResultValue(ind)); + myMeshes.insert( make_pair( theCommand->GetResultValue(ind), mesh )); + } + } + // CreateHypothesis() if ( theCommand->GetMethod() == "CreateHypothesis" ) { @@ -327,7 +338,8 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) } // Concatenate( [mesh1, ...], ... ) - if ( theCommand->GetMethod() == "Concatenate" ) + if ( theCommand->GetMethod() == "Concatenate" || + theCommand->GetMethod() == "ConcatenateWithGroups") { AddMeshAccessorMethod( theCommand ); } @@ -376,7 +388,7 @@ void _pyGen::Flush() //================================================================================ /*! - * \brief Add access method to mesh that is an object or an argument + * \brief Add access method to mesh that is an argument * \param theCmd - command to add access method * \retval bool - true if added */ @@ -589,12 +601,32 @@ _pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd): { // convert my creation command Handle(_pyCommand) creationCmd = GetCreationCmd(); - creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); - creationCmd->SetMethod( "Mesh" ); + TCollection_AsciiString str = creationCmd->GetMethod(); + + creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); + if(str != "CreateMeshesFromUNV" && + str != "CreateMeshesFromMED" && + str != "CreateMeshesFromSTL") + creationCmd->SetMethod( "Mesh" ); theGen->SetAccessorMethod( GetID(), "GetMesh()" ); } +//================================================================================ +/*! + * \brief + * \param theCreationCmd - + */ +//================================================================================ +_pyMesh::_pyMesh(const Handle(_pyCommand) theCreationCmd, const TCollection_AsciiString& id): + _pyObject(theCreationCmd), myHasEditor(false) +{ + // convert my creation command + Handle(_pyCommand) creationCmd = GetCreationCmd(); + creationCmd->SetObject( SMESH_2smeshpy::SmeshpyName() ); + theGen->SetAccessorMethod( id, "GetMesh()" ); +} + //================================================================================ /*! * \brief Convert a IDL API command of SMESH::Mesh to a method call of python Mesh @@ -676,7 +708,7 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) } } Handle(_pyHypothesis) hyp = theGen->FindHyp( hypID ); - if ( ! hasAddCmd ) { // hypo addition already wrapped + if ( ! hasAddCmd && hypID.Length() != 0 ) { // hypo addition already wrapped // RemoveHypothesis(geom, hyp) --> RemoveHypothesis( hyp, geom=0 ) _pyID geom = theCommand->GetArg( 1 ); theCommand->RemoveArgs(); @@ -720,7 +752,7 @@ bool _pyMesh::NeedMeshAccess( const Handle(_pyCommand)& theCommand ) "GetSubMeshElementsId","GetSubMeshNodesId","GetSubMeshElementType","Dump","GetNodeXYZ", "GetNodeInverseElements","GetShapeID","GetShapeIDForElem","GetElemNbNodes", "GetElemNode","IsMediumNode","IsMediumNodeOfAnyElem","ElemNbEdges","ElemNbFaces", - "IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", + "IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor", "" }; // <- mark of end sameMethods.Insert( names ); } @@ -854,12 +886,20 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand) "MergeElements","MergeEqualElements","SewFreeBorders","SewConformFreeBorders", "SewBorderToSide","SewSideElements","ChangeElemNodes","GetLastCreatedNodes", "GetLastCreatedElems", - "" }; // <- mark of end + "MirrorMakeMesh","MirrorObjectMakeMesh","TranslateMakeMesh", + "TranslateObjectMakeMesh","RotateMakeMesh","RotateObjectMakeMesh", + "" }; // <- mark of the end sameMethods.Insert( names ); } + //theGen->AddMeshAccessorMethod( theCommand ); // for *Object() if ( sameMethods.Contains( theCommand->GetMethod() )) { theCommand->SetObject( myMesh ); + + // meshes made by *MakeMesh() methods are not wrapped by _pyMesh, + // so let _pyMesh care of it (TMP?) + if ( theCommand->GetMethod().Search("MakeMesh") != -1 ) + _pyMesh( new _pyCommand( theCommand->GetString(), 0 )); // for theGen->SetAccessorMethod() } else { // editor creation command is needed only if any editor function is called @@ -1562,6 +1602,54 @@ const TCollection_AsciiString & _pyCommand::GetResultValue() return myRes; } +//================================================================================ +/*! + * \brief Return number of python command result value ResultValue = Obj.Meth() + * \retval const int + */ +//================================================================================ + +const int _pyCommand::GetNbResultValues() +{ + int begPos = 1; + int Nb=0; + int endPos = myString.Location( "=", 1, Length() ); + TCollection_AsciiString str = ""; + while ( begPos < endPos) { + str = GetWord( myString, begPos, true ); + begPos = begPos+ str.Length(); + Nb++; + } + return (Nb-1); +} + + +//================================================================================ +/*! + * \brief Return substring of python command looking like + * ResultValue1 , ResultValue1,... = Obj.Meth() with res index + * \retval const TCollection_AsciiString & - ResultValue with res index substring + */ +//================================================================================ +const TCollection_AsciiString & _pyCommand::GetResultValue(int res) +{ + int begPos = 1; + int Nb=0; + int endPos = myString.Location( "=", 1, Length() ); + while ( begPos < endPos) { + myRes = GetWord( myString, begPos, true ); + begPos = begPos + myRes.Length(); + Nb++; + if(res == Nb){ + myRes.RemoveAll('[');myRes.RemoveAll(']'); + return myRes; + } + if(Nb>res) + break; + } + return theEmptyString; +} + //================================================================================ /*! * \brief Return substring of python command looking like ResVal = Object.Meth()