From: apo Date: Wed, 30 Mar 2005 06:58:37 +0000 (+0000) Subject: PythonDump for SMESH Controls / Filter X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e5c454adf00cdf7b9459742fa43609a503756f20;p=modules%2Fsmesh.git PythonDump for SMESH Controls / Filter --- diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx index 5a5d3c25a..d6700df0c 100644 --- a/src/SMESH_I/SMESH_DumpPython.cxx +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -9,46 +9,77 @@ #include "SMESH_Filter_i.hxx" #include +#include namespace SMESH { - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, const char* theArg){ - theString += Standard_CString(theArg); - return theString; - } - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, int theArg){ - theString += TCollection_AsciiString(theArg); - return theString; + size_t TPythonDump::myCounter = 0; + + TPythonDump:: + TPythonDump() + { + ++myCounter; + } + TPythonDump:: + ~TPythonDump() + { + if(--myCounter == 0){ + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); + if(!aStudy->_is_nil()){ + std::string aString = myStream.str(); + TCollection_AsciiString aCollection(Standard_CString(aString.c_str())); + aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection); + } + } } - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, float theArg){ - theString += TCollection_AsciiString(theArg); - return theString; + TPythonDump& + TPythonDump:: + operator<<(const SMESH::ElementType& theArg) + { + myStream<<"SMESH."; + switch(theArg){ + case ALL: + myStream<<"ALL"; + break; + case NODE: + myStream<<"NODE"; + break; + case EDGE: + myStream<<"EDGE"; + break; + case FACE: + myStream<<"FACE"; + break; + case VOLUME: + myStream<<"VOLUME"; + break; + } + return *this; } - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - const SMESH::long_array& theArg) + + TPythonDump& + TPythonDump:: + operator<<(const SMESH::long_array& theArg) { - theString<<"[ "; + myStream<<"[ "; CORBA::Long i = 1, iEnd = theArg.length(); for(; i <= iEnd; i++) { - theString<object_to_string(theArg); } - theString<GetFunctorType(); switch(aFunctorType){ case FT_AspectRatio: - theString += TCollection_AsciiString("anAspectRatio"); + myStream<<"anAspectRatio"; break; case FT_AspectRatio3D: - theString += TCollection_AsciiString("anAspectRatio3D"); + myStream<<"anAspectRatio3D"; break; case FT_Warping: - theString += TCollection_AsciiString("aWarping"); + myStream<<"aWarping"; break; case FT_MinimumAngle: - theString += TCollection_AsciiString("aMinimumAngle"); + myStream<<"aMinimumAngle"; break; case FT_Taper: - theString += TCollection_AsciiString("aTaper"); + myStream<<"aTaper"; break; case FT_Skew: - theString += TCollection_AsciiString("aSkew"); + myStream<<"aSkew"; break; case FT_Area: - theString += TCollection_AsciiString("aArea"); + myStream<<"aArea"; break; case FT_FreeBorders: - theString += TCollection_AsciiString("aFreeBorders"); + myStream<<"aFreeBorders"; break; case FT_FreeEdges: - theString += TCollection_AsciiString("aFreeEdges"); + myStream<<"aFreeEdges"; break; case FT_MultiConnection: - theString += TCollection_AsciiString("aMultiConnection"); + myStream<<"aMultiConnection"; break; case FT_MultiConnection2D: - theString += TCollection_AsciiString("aMultiConnection2D"); + myStream<<"aMultiConnection2D"; break; case FT_Length: - theString += TCollection_AsciiString("aLength"); + myStream<<"aLength"; break; case FT_Length2D: - theString += TCollection_AsciiString("aLength"); + myStream<<"aLength"; break; case FT_BelongToGeom: - theString += TCollection_AsciiString("aBelongToGeom"); + myStream<<"aBelongToGeom"; break; case FT_BelongToPlane: - theString += TCollection_AsciiString("aBelongToPlane"); + myStream<<"aBelongToPlane"; break; case FT_BelongToCylinder: - theString += TCollection_AsciiString("aBelongToCylinder"); + myStream<<"aBelongToCylinder"; break; case FT_LyingOnGeom: - theString += TCollection_AsciiString("aLyingOnGeom"); + myStream<<"aLyingOnGeom"; break; case FT_RangeOfIds: - theString += TCollection_AsciiString("aRangeOfIds"); + myStream<<"aRangeOfIds"; break; case FT_BadOrientedVolume: - theString += TCollection_AsciiString("aBadOrientedVolume"); + myStream<<"aBadOrientedVolume"; break; case FT_LessThan: - theString += TCollection_AsciiString("aLessThan"); + myStream<<"aLessThan"; break; case FT_MoreThan: - theString += TCollection_AsciiString("aMoreThan"); + myStream<<"aMoreThan"; break; case FT_EqualTo: - theString += TCollection_AsciiString("anEqualTo"); + myStream<<"anEqualTo"; break; case FT_LogicalNOT: - theString += TCollection_AsciiString("aLogicalNOT"); + myStream<<"aLogicalNOT"; break; case FT_LogicalAND: - theString += TCollection_AsciiString("aLogicalAND"); + myStream<<"aLogicalAND"; break; case FT_LogicalOR: - theString += TCollection_AsciiString("aLogicalOR"); + myStream<<"aLogicalOR"; break; case FT_Undefined: - theString += TCollection_AsciiString("anUndefined"); + myStream<<"anUndefined"; break; } - theString += Standard_CString("_"); - theString += TCollection_AsciiString(int(theArg)); - return theString; - } - - size_t TPythonDump::myCounter = 0; - - TPythonDump:: - TPythonDump() - { - ++myCounter; - } - TPythonDump:: - ~TPythonDump() - { - if(--myCounter == 0){ - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); - if(!aStudy->_is_nil()){ - aSMESHGen->AddToPythonScript(aStudy->StudyId(),myString); - } - } + myStream<(aServant.in()); + return DownCast(thePredicate); } } @@ -322,8 +321,7 @@ inline const SMDS_Mesh* MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh ) { - SMESH_Mesh_i* anImplPtr = - dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); + SMESH_Mesh_i* anImplPtr = DownCast(theMesh); return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0; } @@ -437,6 +435,7 @@ CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId ) void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision ) { myNumericalFunctorPtr->SetPrecision( thePrecision ); + TPythonDump()<GetShapeReader()->GetShape( aGEOMGen, theGeom ); myBelongToGeomPtr->SetGeom( aLocShape ); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); + TPythonDump()<SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType ); + TPythonDump()<SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType ); + TPythonDump()<SetTolerance( theToler ); + TPythonDump()<GetShapeReader()->GetShape( aGEOMGen, theGeom ); myLyingOnGeomPtr->SetGeom( aLocShape ); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); + TPythonDump()<AddToRange( theIds[ i ] ); + TPythonDump()<SetRangeStr( TCollection_AsciiString( (Standard_CString)theRange ) ); } @@ -1004,6 +1016,7 @@ char* RangeOfIds_i::GetRangeStr() void RangeOfIds_i::SetElementType( ElementType theType ) { myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) ); + TPythonDump()<SetMargin( theValue ); - TPythonDump()<Destroy(); - myNumericalFunctor = dynamic_cast( SMESH_Gen_i::GetServant( theFunct ).in() ); + myNumericalFunctor = DownCast(theFunct); if ( myNumericalFunctor ) { @@ -1107,7 +1120,7 @@ EqualTo_i::EqualTo_i() void EqualTo_i::SetTolerance( CORBA::Double theToler ) { myEqualToPtr->SetTolerance( theToler ); - TPythonDump()<CreateFilter(); aRes->SetCriteria( aCriteriaVar.inout() ); - + + TPythonDump()<(theFilter)) + TPythonDump()<(theFilter)) + TPythonDump()< myPythonScripts; }; + +namespace SMESH +{ + template + T + DownCast(CORBA::Object_ptr theArg) + { + return dynamic_cast(SMESH_Gen_i::GetServant(theArg).in()); + } +} + + #endif diff --git a/src/SMESH_I/SMESH_PythonDump.hxx b/src/SMESH_I/SMESH_PythonDump.hxx index 4894c7159..34545cf65 100644 --- a/src/SMESH_I/SMESH_PythonDump.hxx +++ b/src/SMESH_I/SMESH_PythonDump.hxx @@ -23,63 +23,79 @@ #include #include CORBA_SERVER_HEADER(SMESH_Mesh) -#include +#include namespace SMESH { - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - const char* theArg); - - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - int theArg); - - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - float theArg); - class FilterLibrary_i; - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - SMESH::FilterLibrary_i* theArg); - class FilterManager_i; - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - SMESH::FilterManager_i* theArg); - class Filter_i; - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - SMESH::Filter_i* theArg); - class Functor_i; - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - SMESH::Functor_i* theArg); - - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - CORBA::Object_ptr theArg); - - TCollection_AsciiString& - operator<<(TCollection_AsciiString& theString, - const SMESH::long_array& theArg); class TPythonDump { - TCollection_AsciiString myString; + std::ostringstream myStream; static size_t myCounter; public: TPythonDump(); virtual ~TPythonDump(); - template - TCollection_AsciiString& - operator<<(T theArg){ - return myString<