Salome HOME
PythonDump for SMESH Controls / Filter
authorapo <apo@opencascade.com>
Tue, 29 Mar 2005 14:29:33 +0000 (14:29 +0000)
committerapo <apo@opencascade.com>
Tue, 29 Mar 2005 14:29:33 +0000 (14:29 +0000)
13 files changed:
idl/SMESH_Group.idl
src/Controls/SMESH_Controls.cxx
src/Controls/SMESH_ControlsDef.hxx
src/SMESHDS/SMESHDS_Mesh.cxx
src/SMESHDS/SMESHDS_Mesh.hxx
src/SMESH_I/Makefile.in
src/SMESH_I/SMESH_DumpPython.cxx [new file with mode: 0644]
src/SMESH_I/SMESH_Filter_i.cxx
src/SMESH_I/SMESH_Filter_i.hxx
src/SMESH_I/SMESH_Gen_i_DumpPython.cxx [deleted file]
src/SMESH_I/SMESH_Group_i.cxx
src/SMESH_I/SMESH_Group_i.hxx
src/SMESH_I/SMESH_PythonDump.hxx [new file with mode: 0644]

index a39c3445d00f2e876350a289bca476abcc79ab6f..37657674bf4f41da09810991f347e283cfa83f62 100644 (file)
@@ -33,6 +33,8 @@
 
 module SMESH
 {
+  interface Predicate;
+
   /*!
    * SMESH_Group: base interface of group object
    */
@@ -98,11 +100,13 @@ module SMESH
      * Adds elements to the group
      */
     long Add( in long_array elem_ids );
+    long AddByPredicate( in Predicate thePredicate );
 
     /*!
      * Removes elements from the group
      */
     long Remove( in long_array elem_ids );
+    long RemoveByPredicate( in Predicate thePredicate );
 
   };
   /*!
index bfb3f8215bbaed4a5218114e1d702c059555097a..ccae605458ed4b0b941cb390e3e7c57f3c98497f 100644 (file)
@@ -81,7 +81,7 @@ namespace{
     return aDist;
   }
 
-  int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId )
+  int getNbMultiConnection( const SMDS_Mesh* theMesh, const int theId )
   {
     if ( theMesh == 0 )
       return 0;
@@ -137,7 +137,7 @@ NumericalFunctor::NumericalFunctor():
   myPrecision = -1;
 }
 
-void NumericalFunctor::SetMesh( SMDS_Mesh* theMesh )
+void NumericalFunctor::SetMesh( const SMDS_Mesh* theMesh )
 {
   myMesh = theMesh;
 }
@@ -1030,7 +1030,6 @@ double MultiConnection2D::GetValue( long theElementId )
   int aResult = 0;
   
   if (GetPoints(theElementId,P)){
-    double  aVal;
     const SMDS_MeshElement* anFaceElem = myMesh->FindElement( theElementId );
     SMDSAbs_ElementType aType = anFaceElem->GetType();
     
@@ -1112,7 +1111,6 @@ void MultiConnection2D::GetValues(MValues& theValues){
   SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
   for(; anIter->more(); ){
     const SMDS_MeshFace* anElem = anIter->next();
-    long anElemId = anElem->GetID();
     SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
     long aNodeId[3];
 
@@ -1172,7 +1170,7 @@ BadOrientedVolume::BadOrientedVolume()
   myMesh = 0;
 }
 
-void BadOrientedVolume::SetMesh( SMDS_Mesh* theMesh )
+void BadOrientedVolume::SetMesh( const SMDS_Mesh* theMesh )
 {
   myMesh = theMesh;
 }
@@ -1203,7 +1201,7 @@ FreeBorders::FreeBorders()
   myMesh = 0;
 }
 
-void FreeBorders::SetMesh( SMDS_Mesh* theMesh )
+void FreeBorders::SetMesh( const SMDS_Mesh* theMesh )
 {
   myMesh = theMesh;
 }
@@ -1228,7 +1226,7 @@ FreeEdges::FreeEdges()
   myMesh = 0;
 }
 
-void FreeEdges::SetMesh( SMDS_Mesh* theMesh )
+void FreeEdges::SetMesh( const SMDS_Mesh* theMesh )
 {
   myMesh = theMesh;
 }
@@ -1375,7 +1373,7 @@ RangeOfIds::RangeOfIds()
 // name    : SetMesh
 // Purpose : Set mesh 
 //=======================================================================
-void RangeOfIds::SetMesh( SMDS_Mesh* theMesh )
+void RangeOfIds::SetMesh( const SMDS_Mesh* theMesh )
 {
   myMesh = theMesh;
 }
@@ -1577,7 +1575,7 @@ Comparator::Comparator():
 Comparator::~Comparator()
 {}
 
-void Comparator::SetMesh( SMDS_Mesh* theMesh )
+void Comparator::SetMesh( const SMDS_Mesh* theMesh )
 {
   if ( myFunctor )
     myFunctor->SetMesh( theMesh );
@@ -1662,7 +1660,7 @@ bool LogicalNOT::IsSatisfy( long theId )
   return myPredicate && !myPredicate->IsSatisfy( theId );
 }
 
-void LogicalNOT::SetMesh( SMDS_Mesh* theMesh )
+void LogicalNOT::SetMesh( const SMDS_Mesh* theMesh )
 {
   if ( myPredicate )
     myPredicate->SetMesh( theMesh );
@@ -1689,7 +1687,7 @@ LogicalBinary::LogicalBinary()
 LogicalBinary::~LogicalBinary()
 {}
 
-void LogicalBinary::SetMesh( SMDS_Mesh* theMesh )
+void LogicalBinary::SetMesh( const SMDS_Mesh* theMesh )
 {
   if ( myPredicate1 )
     myPredicate1->SetMesh( theMesh );
@@ -1763,11 +1761,10 @@ void Filter::SetPredicate( PredicatePtr thePredicate )
   myPredicate = thePredicate;
 }
 
-
 template<class TElement, class TIterator, class TPredicate> 
-void FillSequence(const TIterator& theIterator,
-                 TPredicate& thePredicate,
-                 Filter::TIdSequence& theSequence)
+inline void FillSequence(const TIterator& theIterator,
+                        TPredicate& thePredicate,
+                        Filter::TIdSequence& theSequence)
 {
   if ( theIterator ) {
     while( theIterator->more() ) {
@@ -1779,40 +1776,46 @@ void FillSequence(const TIterator& theIterator,
   }
 }
 
-Filter::TIdSequence
-Filter::GetElementsId( SMDS_Mesh* theMesh )
+void
+Filter::
+GetElementsId( const SMDS_Mesh* theMesh, 
+              PredicatePtr thePredicate, 
+              TIdSequence& theSequence )
 {
-  TIdSequence aSequence;
-  if ( !theMesh || !myPredicate ) return aSequence;
+  theSequence.clear();
+
+  if ( !theMesh || !thePredicate ) 
+    return;
 
-  myPredicate->SetMesh( theMesh );
+  thePredicate->SetMesh( theMesh );
 
-  SMDSAbs_ElementType aType = myPredicate->GetType();
+  SMDSAbs_ElementType aType = thePredicate->GetType();
   switch(aType){
-  case SMDSAbs_Node:{
-    FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),myPredicate,aSequence);
+  case SMDSAbs_Node:
+    FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),thePredicate,theSequence);
     break;
-  }
-  case SMDSAbs_Edge:{
-    FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
+  case SMDSAbs_Edge:
+    FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
     break;
-  }
-  case SMDSAbs_Face:{
-    FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence);
+  case SMDSAbs_Face:
+    FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
     break;
-  }
-  case SMDSAbs_Volume:{
-    FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
+  case SMDSAbs_Volume:
+    FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
     break;
-  }
-  case SMDSAbs_All:{
-    FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
-    FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence);
-    FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
+  case SMDSAbs_All:
+    FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
+    FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
+    FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
     break;
   }
-  }
-  return aSequence;
+}
+
+void
+Filter::GetElementsId( const SMDS_Mesh* theMesh,
+                      Filter::TIdSequence& theSequence )
+{
+  GetElementsId(theMesh,myPredicate,theSequence);
 }
 
 /*
@@ -1876,7 +1879,7 @@ ManifoldPart::~ManifoldPart()
   myMesh = 0;
 }
 
-void ManifoldPart::SetMesh( SMDS_Mesh* theMesh )
+void ManifoldPart::SetMesh( const SMDS_Mesh* theMesh )
 {
   myMesh = theMesh;
   process();
@@ -2205,7 +2208,7 @@ ElementsOnSurface::~ElementsOnSurface()
   myMesh = 0;
 }
 
-void ElementsOnSurface::SetMesh( SMDS_Mesh* theMesh )
+void ElementsOnSurface::SetMesh( const SMDS_Mesh* theMesh )
 { 
   if ( myMesh == theMesh )
     return;
index 339157e6cc12e262d5cbc61d1112a3663dfd6cf1..02336ebbcec1e286f6842afd7939f56eb54bc513 100644 (file)
@@ -97,14 +97,14 @@ namespace SMESH{
     {
     public:
       ~Functor(){}
-      virtual void SetMesh( SMDS_Mesh* theMesh ) = 0;
+      virtual void SetMesh( const SMDS_Mesh* theMesh ) = 0;
       virtual SMDSAbs_ElementType GetType() const = 0;
     };
 
     class NumericalFunctor: public virtual Functor{
     public:
       NumericalFunctor();
-      virtual void SetMesh( SMDS_Mesh* theMesh );
+      virtual void SetMesh( const SMDS_Mesh* theMesh );
       virtual double GetValue( long theElementId );
       virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
       virtual SMDSAbs_ElementType GetType() const = 0;
@@ -117,7 +117,7 @@ namespace SMESH{
       static bool GetPoints(const SMDS_MeshElement* theElem, 
                            TSequenceOfXYZ& theRes);
     protected:
-      SMDS_Mesh* myMesh;
+      const SMDS_Mesh* myMesh;
       long       myPrecision;
     };
   
@@ -295,12 +295,12 @@ namespace SMESH{
     class FreeBorders: public virtual Predicate{
     public:
       FreeBorders();
-      virtual void SetMesh( SMDS_Mesh* theMesh );
+      virtual void SetMesh( const SMDS_Mesh* theMesh );
       virtual bool IsSatisfy( long theElementId );
       virtual SMDSAbs_ElementType GetType() const;
             
     protected:
-      SMDS_Mesh* myMesh;
+      const SMDS_Mesh* myMesh;
     };
    
 
@@ -311,12 +311,12 @@ namespace SMESH{
     class BadOrientedVolume: public virtual Predicate{
     public:
       BadOrientedVolume();
-      virtual void SetMesh( SMDS_Mesh* theMesh );
+      virtual void SetMesh( const SMDS_Mesh* theMesh );
       virtual bool IsSatisfy( long theElementId );
       virtual SMDSAbs_ElementType GetType() const;
             
     protected:
-      SMDS_Mesh* myMesh;
+      const SMDS_Mesh* myMesh;
     };
    
 
@@ -327,7 +327,7 @@ namespace SMESH{
     class FreeEdges: public virtual Predicate{
     public:
       FreeEdges();
-      virtual void SetMesh( SMDS_Mesh* theMesh );
+      virtual void SetMesh( const SMDS_Mesh* theMesh );
       virtual bool IsSatisfy( long theElementId );
       virtual SMDSAbs_ElementType GetType() const;
       static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId  );
@@ -342,7 +342,7 @@ namespace SMESH{
       void GetBoreders(TBorders& theBorders);
       
     protected:
-      SMDS_Mesh* myMesh;
+      const SMDS_Mesh* myMesh;
     };
     typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
 
@@ -359,7 +359,7 @@ namespace SMESH{
     {
     public:
                                     RangeOfIds();
-      virtual void                  SetMesh( SMDS_Mesh* theMesh );
+      virtual void                  SetMesh( const SMDS_Mesh* theMesh );
       virtual bool                  IsSatisfy( long theNodeId );
       virtual SMDSAbs_ElementType   GetType() const;
       virtual void                  SetType( SMDSAbs_ElementType theType );
@@ -369,7 +369,7 @@ namespace SMESH{
       bool                          SetRangeStr( const TCollection_AsciiString& );
 
     protected:
-      SMDS_Mesh*                    myMesh;
+      const SMDS_Mesh*              myMesh;
 
       TColStd_SequenceOfInteger     myMin;
       TColStd_SequenceOfInteger     myMax;
@@ -389,7 +389,7 @@ namespace SMESH{
     public:
       Comparator();
       virtual ~Comparator();
-      virtual void SetMesh( SMDS_Mesh* theMesh );
+      virtual void SetMesh( const SMDS_Mesh* theMesh );
       virtual void SetMargin(double theValue);
       virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
       virtual bool IsSatisfy( long theElementId ) = 0;
@@ -449,7 +449,7 @@ namespace SMESH{
       LogicalNOT();
       virtual ~LogicalNOT();
       virtual bool IsSatisfy( long theElementId );
-      virtual void SetMesh( SMDS_Mesh* theMesh );
+      virtual void SetMesh( const SMDS_Mesh* theMesh );
       virtual void SetPredicate(PredicatePtr thePred);
       virtual SMDSAbs_ElementType GetType() const;
   
@@ -467,7 +467,7 @@ namespace SMESH{
     public:
       LogicalBinary();
       virtual ~LogicalBinary();
-      virtual void SetMesh( SMDS_Mesh* theMesh );
+      virtual void SetMesh( const SMDS_Mesh* theMesh );
       virtual void SetPredicate1(PredicatePtr thePred);
       virtual void SetPredicate2(PredicatePtr thePred);
       virtual SMDSAbs_ElementType GetType() const;
@@ -532,7 +532,7 @@ namespace SMESH{
       
       ManifoldPart();
       ~ManifoldPart();
-      virtual void SetMesh( SMDS_Mesh* theMesh );
+      virtual void SetMesh( const SMDS_Mesh* theMesh );
       // inoke when all parameters already set
       virtual bool IsSatisfy( long theElementId );
       virtual      SMDSAbs_ElementType GetType() const;
@@ -560,7 +560,7 @@ namespace SMESH{
                               TVectorOfFacePtr& theFaces ) const;
 
     private:
-      SMDS_Mesh*            myMesh;
+      const SMDS_Mesh*      myMesh;
       TColStd_MapOfInteger  myMapIds;
       TColStd_MapOfInteger  myMapBadGeomIds;
       TVectorOfFacePtr      myAllFacePtr;
@@ -582,7 +582,7 @@ namespace SMESH{
     public:
       ElementsOnSurface();
       ~ElementsOnSurface();
-      virtual void SetMesh( SMDS_Mesh* theMesh );
+      virtual void SetMesh( const SMDS_Mesh* theMesh );
       virtual bool IsSatisfy( long theElementId );
       virtual      SMDSAbs_ElementType GetType() const;
 
@@ -597,7 +597,7 @@ namespace SMESH{
       bool    isOnSurface( const SMDS_MeshNode* theNode ) const;
 
     private:
-      SMDS_Mesh*            myMesh;
+      const SMDS_Mesh*      myMesh;
       TColStd_MapOfInteger  myIds;
       SMDSAbs_ElementType   myType;
       Handle(Geom_Surface)  mySurf;
@@ -615,9 +615,20 @@ namespace SMESH{
       Filter();
       virtual ~Filter();
       virtual void SetPredicate(PredicatePtr thePred);
+
       typedef std::vector<long> TIdSequence;
-      virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh );
-  
+
+      virtual 
+      void
+      GetElementsId( const SMDS_Mesh* theMesh,
+                    TIdSequence& theSequence );
+
+      static
+      void
+      GetElementsId( const SMDS_Mesh* theMesh, 
+                    PredicatePtr thePredicate,
+                    TIdSequence& theSequence );
+      
     protected:
       PredicatePtr myPredicate;
     };
index b72a6b6b31f950b981c48a1012a8081aa37de336..4fd9d5df88c12086eda6a56e029714fceb2383e0 100644 (file)
@@ -876,13 +876,14 @@ bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
 /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
 /// TopoDS_Shape is unknown
 ///////////////////////////////////////////////////////////////////////////////
-SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S)
+SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
 {
   if (myShape.IsNull()) MESSAGE("myShape is NULL");
 
   int Index = ShapeToIndex(S);
-  if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end())
-    return myShapeIndexToSubMesh[Index];
+  TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
+  if (anIter != myShapeIndexToSubMesh.end())
+    return anIter->second;
   else
     return NULL;
 }
@@ -1033,7 +1034,7 @@ TopoDS_Shape SMESHDS_Mesh::IndexToShape(int ShapeIndex)
 //function : ShapeToIndex
 //purpose  : 
 //=======================================================================
-int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S)
+int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
 {
   if (myShape.IsNull())
     MESSAGE("myShape is NULL");
index 5da0423b05e2279bb6aa290da0b91ca0e43f4132..86b9071c114cac6251169a2ef3d00da43c5b0c06 100644 (file)
@@ -204,7 +204,7 @@ public:
                               const TopoDS_Shape & S);
   TopoDS_Shape ShapeToMesh() const;
   bool HasMeshElements(const TopoDS_Shape & S);
-  SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S);
+  SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S) const;
   SMESHDS_SubMesh * MeshElements(const int Index);
   std::list<int> SubMeshIndices();
   const std::map<int,SMESHDS_SubMesh*>& SubMeshes()
@@ -214,7 +214,7 @@ public:
   const std::list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
   SMESHDS_Script * GetScript();
   void ClearScript();
-  int ShapeToIndex(const TopoDS_Shape & aShape);
+  int ShapeToIndex(const TopoDS_Shape & aShape) const;
   TopoDS_Shape IndexToShape(int ShapeIndex);
 
   SMESHDS_SubMesh * NewSubMesh(int Index);
@@ -246,9 +246,15 @@ private:
 
   int                        myMeshID;
   TopoDS_Shape               myShape;
+
+  typedef std::map<int,SMESHDS_SubMesh*> TShapeIndexToSubMesh;
+  TShapeIndexToSubMesh myShapeIndexToSubMesh;
+
   TopTools_IndexedMapOfShape myIndexToShape;
-  std::map<int,SMESHDS_SubMesh*>  myShapeIndexToSubMesh;
-  std::set<SMESHDS_GroupBase*>    myGroups;
+
+  typedef std::set<SMESHDS_GroupBase*> TGroups;
+  TGroups myGroups;
+
   SMESHDS_Script*            myScript;
 };
 
index 032fbfd4382f967b764cd3f0ea1e59b58d6f5011..af407e6e9458d332c326abebe5cff6c18b885d08 100644 (file)
@@ -56,7 +56,7 @@ LIB= libSMESHEngine.la
 LIB_SRC = \
        SMESH_Gen_i.cxx \
        SMESH_Gen_i_1.cxx \
-       SMESH_Gen_i_DumpPython.cxx \
+       SMESH_DumpPython.cxx \
        SMESH_Mesh_i.cxx \
        SMESH_MEDMesh_i.cxx \
         SMESH_MEDFamily_i.cxx \
diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx
new file mode 100644 (file)
index 0000000..cd9da63
--- /dev/null
@@ -0,0 +1,561 @@
+// File    : SMESH_Gen_i_DumpPython.cxx
+// Created : Thu Mar 24 17:17:59 2005
+// Author  : Julia DOROVSKIKH
+// Module  : SMESH
+// $Header : $
+
+#include "SMESH_PythonDump.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_Filter_i.hxx"
+
+#include <TColStd_HSequenceOfInteger.hxx>
+
+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;
+  }
+
+  TCollection_AsciiString& 
+  operator<<(TCollection_AsciiString& theString, float theArg){
+    theString += TCollection_AsciiString(theArg);
+    return theString;
+  }
+
+  TCollection_AsciiString& 
+  operator<<(TCollection_AsciiString& theString, 
+            const SMESH::long_array& theArg)
+  {
+    theString<<"[ ";
+    CORBA::Long i = 1, iEnd = theArg.length();
+    for(; i <= iEnd; i++) {
+      theString<<int(theArg[i-1]);
+      if(i < iEnd)
+       theString<< ", ";
+    }
+    theString<<" ]";
+    return theString;
+  }
+
+
+  TCollection_AsciiString& 
+  operator<<(TCollection_AsciiString& theString, 
+            CORBA::Object_ptr theArg)
+  {
+    CORBA::String_var aString("None");
+    SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+    SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+    SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
+    if(!aSObject->_is_nil()){
+      aString = aSObject->GetID();
+    }else if(!CORBA::is_nil(theArg)){
+      aString = SMESH_Gen_i::GetORB()->object_to_string(theArg);
+    }
+    theString<<aString.in();
+    return theString;
+  }
+
+  TCollection_AsciiString& 
+  operator<<(TCollection_AsciiString& theString, 
+            SMESH::FilterLibrary_i* theArg)
+  {
+    theString += TCollection_AsciiString("aFilterLibrary_");
+    theString += TCollection_AsciiString(int(theArg));
+    return theString;
+  }
+
+  TCollection_AsciiString& 
+  operator<<(TCollection_AsciiString& theString, 
+            SMESH::FilterManager_i* theArg)
+  {
+    theString += TCollection_AsciiString("aFilterManager_");
+    theString += TCollection_AsciiString(int(theArg));
+    return theString;
+  }
+
+  TCollection_AsciiString& 
+  operator<<(TCollection_AsciiString& theString, 
+            SMESH::Functor_i* theArg)
+  {
+    FunctorType aFunctorType = theArg->GetFunctorType();
+    switch(aFunctorType){
+    case FT_AspectRatio:
+      theString += TCollection_AsciiString("anAspectRatio");
+      break;
+    case FT_AspectRatio3D:
+      theString += TCollection_AsciiString("anAspectRatio3D");
+      break;
+    case FT_Warping:
+      theString += TCollection_AsciiString("aWarping");
+      break;
+    case FT_MinimumAngle:
+      theString += TCollection_AsciiString("aMinimumAngle");
+      break;
+    case FT_Taper:
+      theString += TCollection_AsciiString("aTaper");
+      break;
+    case FT_Skew:
+      theString += TCollection_AsciiString("aSkew");
+      break;
+    case FT_Area:
+      theString += TCollection_AsciiString("aArea");
+      break;
+    case FT_FreeBorders:
+      theString += TCollection_AsciiString("aFreeBorders");
+      break;
+    case FT_FreeEdges:
+      theString += TCollection_AsciiString("aFreeEdges");
+      break;
+    case FT_MultiConnection:
+      theString += TCollection_AsciiString("aMultiConnection");
+      break;
+    case FT_MultiConnection2D:
+      theString += TCollection_AsciiString("aMultiConnection2D");
+      break;
+    case FT_Length:
+      theString += TCollection_AsciiString("aLength");
+      break;
+    case FT_Length2D:
+      theString += TCollection_AsciiString("aLength");
+      break;
+    case FT_BelongToGeom:
+      theString += TCollection_AsciiString("aBelongToGeom");
+      break;
+    case FT_BelongToPlane:
+      theString += TCollection_AsciiString("aBelongToPlane");
+      break;
+    case FT_BelongToCylinder:
+      theString += TCollection_AsciiString("aBelongToCylinder");
+      break;
+    case FT_LyingOnGeom:
+      theString += TCollection_AsciiString("aLyingOnGeom");
+      break;
+    case FT_RangeOfIds:
+      theString += TCollection_AsciiString("aRangeOfIds");
+      break;
+    case FT_BadOrientedVolume:
+      theString += TCollection_AsciiString("aBadOrientedVolume");
+      break;
+    case FT_LessThan:
+      theString += TCollection_AsciiString("aLessThan");
+      break;
+    case FT_MoreThan:
+      theString += TCollection_AsciiString("aMoreThan");
+      break;
+    case FT_EqualTo:
+      theString += TCollection_AsciiString("anEqualTo");
+      break;
+    case FT_LogicalNOT:
+      theString += TCollection_AsciiString("aLogicalNOT");
+      break;
+    case FT_LogicalAND:
+      theString += TCollection_AsciiString("aLogicalAND");
+      break;
+    case FT_LogicalOR:
+      theString += TCollection_AsciiString("aLogicalOR");
+      break;
+    case FT_Undefined:
+      theString += TCollection_AsciiString("anUndefined");
+      break;
+    }
+    theString += Standard_CString("_");
+    theString += TCollection_AsciiString(int(theArg));
+    return theString;
+  }
+
+  TPythonDump::
+  ~TPythonDump()
+  {
+    SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+    SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+    if(!aStudy->_is_nil()){
+      aSMESHGen->AddToPythonScript(aStudy->StudyId(),myString);
+    }
+  }
+}
+
+//=======================================================================
+//function : DumpPython
+//purpose  : 
+//=======================================================================
+Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
+                                           CORBA::Boolean isPublished,
+                                           CORBA::Boolean& isValidScript)
+{
+  SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
+  if (CORBA::is_nil(aStudy))
+    return new Engines::TMPFile(0);
+
+  SALOMEDS::SObject_var aSO = aStudy->FindComponent(ComponentDataType());
+  if (CORBA::is_nil(aSO))
+    return new Engines::TMPFile(0);
+
+  // Map study entries to object names
+  Resource_DataMapOfAsciiStringAsciiString aMap;
+  TCollection_AsciiString s ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_");
+
+  SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
+  for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
+    SALOMEDS::SObject_var aValue = Itr->Value();
+
+    TCollection_AsciiString aName (aValue->GetName());
+    if (aName.Length() > 0) {
+      int p, p2 = 1, e = aName.Length();
+      while ((p = aName.FirstLocationNotInSet(s, p2, e))) {
+        aName.SetValue(p, '_');
+        p2 = p;
+      }
+      aMap.Bind(TCollection_AsciiString(aValue->GetID()), aName);
+    }
+  }
+
+  // Get trace of restored study
+  //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this());
+  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+  SALOMEDS::GenericAttribute_var anAttr =
+    aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+  char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject();
+  TCollection_AsciiString aSavedTrace (oldValue);
+
+  // Add trace of API methods calls and replace study entries by names
+  bool aValidScript;
+  //TCollection_AsciiString aScript = myGen.DumpPython
+  TCollection_AsciiString aScript = DumpPython_impl
+    (aStudy->StudyId(), aMap, isPublished, aValidScript, aSavedTrace);
+
+  int aLen = aScript.Length(); 
+  unsigned char* aBuffer = new unsigned char[aLen+1];
+  strcpy((char*)aBuffer, aScript.ToCString());
+
+  CORBA::Octet* anOctetBuf =  (CORBA::Octet*)aBuffer;
+  Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1); 
+  isValidScript = aValidScript;
+
+  return aStreamFile._retn(); 
+}
+
+//=============================================================================
+/*!
+ *  AddToPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString)
+{
+  if (myPythonScripts.find(theStudyID) == myPythonScripts.end()) {
+    myPythonScripts[theStudyID] = new TColStd_HSequenceOfAsciiString;
+  }
+  myPythonScripts[theStudyID]->Append(theString);
+}
+
+//=============================================================================
+/*!
+ *  RemoveLastFromPythonScript
+ */
+//=============================================================================
+void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID)
+{
+  if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
+    int aLen = myPythonScripts[theStudyID]->Length();
+    myPythonScripts[theStudyID]->Remove(aLen);
+  }
+}
+
+//=======================================================================
+//function : AddToCurrentPyScript
+//purpose  : 
+//=======================================================================
+
+void SMESH_Gen_i::AddToCurrentPyScript (const TCollection_AsciiString& theString)
+{
+  SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+  SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+  if (aStudy->_is_nil()) return;
+  aSMESHGen->AddToPythonScript(aStudy->StudyId(), theString);
+}
+
+
+//=======================================================================
+//function : AddObject
+//purpose  : add object to script string
+//=======================================================================
+
+TCollection_AsciiString& SMESH_Gen_i::AddObject(TCollection_AsciiString& theStr,
+                                                CORBA::Object_ptr        theObject)
+{
+  SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+  SALOMEDS::SObject_var aSO =
+    aSMESHGen->ObjectToSObject(aSMESHGen->GetCurrentStudy(), theObject);
+  if ( !aSO->_is_nil() )
+    theStr += aSO->GetID();
+  else if ( !CORBA::is_nil( theObject ) )
+    theStr += GetORB()->object_to_string( theObject );
+  else
+    theStr += "None";
+
+  return theStr;
+}
+
+//=======================================================================
+//function : SavePython
+//purpose  : 
+//=======================================================================
+void SMESH_Gen_i::SavePython (SALOMEDS::Study_ptr theStudy)
+{
+  // Dump trace of API methods calls
+  TCollection_AsciiString aScript = GetNewPythonLines(theStudy->StudyId());
+
+  // Check contents of PythonObject attribute
+  SALOMEDS::SObject_var aSO = theStudy->FindComponent(ComponentDataType());
+  //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this());
+  SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+  SALOMEDS::GenericAttribute_var anAttr =
+    aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
+
+  char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject();
+  TCollection_AsciiString oldScript (oldValue);
+
+  if (oldScript.Length() > 0) {
+    oldScript += "\n";
+    oldScript += aScript;
+  } else {
+    oldScript = aScript;
+  }
+
+  // Store in PythonObject attribute
+  SALOMEDS::AttributePythonObject::_narrow(anAttr)->SetObject(oldScript.ToCString(), 1);
+
+  // Clean trace of API methods calls
+  CleanPythonTrace(theStudy->StudyId());
+}
+
+
+// impl
+
+
+//=============================================================================
+/*!
+ *  FindEntries: Returns a sequence of start/end positions of entries in the string
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
+{
+  Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+  Standard_Integer aLen = theString.Length();
+  Standard_Boolean isFound = Standard_False;
+
+  char* arr = theString.ToCString();
+  Standard_Integer i = 0, j;
+
+  while(i < aLen) {
+    int c = (int)arr[i];
+    j = i+1;
+    if(c >= 48 && c <= 57) { //Is digit?
+      isFound = Standard_False;
+      while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry
+       c = (int)arr[j++];  
+       if(c == 58) isFound = Standard_True;
+      }
+
+      if (isFound) {
+        int prev = (i < 1) ? 0 : (int)arr[i - 1];
+        // last char should be a diggit,
+        // previous char should not be '"'.
+        if (arr[j-2] != 58 && prev != 34) {
+          aSeq->Append(i+1); // +1 because AsciiString starts from 1
+          aSeq->Append(j-1);
+        }
+      }
+    }
+
+    i = j;
+  }
+
+  return aSeq;
+}
+
+//=============================================================================
+/*!
+ *  DumpPython
+ */
+//=============================================================================
+TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
+                        (int theStudyID, 
+                         Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
+                         bool isPublished, 
+                         bool& aValidScript,
+                         const TCollection_AsciiString& theSavedTrace)
+{
+  TCollection_AsciiString aScript;
+  aScript += "import salome\n";
+  aScript += "import geompy\n\n";
+  aScript += "import SMESH\n";
+  aScript += "import StdMeshers\n\n";
+  aScript += "#import GEOM module\n";
+  aScript += "import string\n";
+  aScript += "import os\n";
+  aScript += "import sys\n";
+  aScript += "sys.path.append( os.path.dirname(__file__) )\n";
+  aScript += "exec(\"from \"+string.replace(__name__,\"SMESH\",\"GEOM\")+\" import *\")\n\n";
+  
+  aScript += "def RebuildData(theStudy):";
+  aScript += "\n\tsmesh = salome.lcc.FindOrLoadComponent(\"FactoryServer\", \"SMESH\")";
+  if ( isPublished )
+    aScript += "\n\tsmesh.SetCurrentStudy(theStudy)";
+  else
+    aScript += "\n\tsmesh.SetCurrentStudy(None)";
+
+  Standard_Integer posToInertGlobalVars = aScript.Length();
+  TCollection_AsciiString globalVars;
+
+  // Dump trace of restored study
+  if (theSavedTrace.Length() > 0) {
+    aScript += "\n";
+    aScript += theSavedTrace;
+  }
+
+  // Dump trace of API methods calls
+  TCollection_AsciiString aNewLines = GetNewPythonLines(theStudyID);
+  if (aNewLines.Length() > 0) {
+    aScript += "\n";
+    aScript += aNewLines;
+  }
+
+  // Find entries to be replaced by names
+  Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
+  Standard_Integer aLen = aSeq->Length();
+
+  if (aLen == 0)
+    return aScript;
+
+  // Replace entries by the names
+  GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
+  TColStd_SequenceOfAsciiString seqRemoved;
+  Resource_DataMapOfAsciiStringAsciiString mapRemoved;
+  Resource_DataMapOfAsciiStringAsciiString aNames;
+  Standard_Integer objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
+  TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("smeshObj_");
+
+  for (Standard_Integer i = 1; i <= aLen; i += 2) {
+    anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i) - 1);
+    anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
+    if (theObjectNames.IsBound(anEntry)) {
+      aName = theObjectNames.Find(anEntry);
+      if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
+        // diff objects have same name - make a new name
+        TCollection_AsciiString aName2;
+        Standard_Integer i = 0;
+        do {
+          aName2 = aName + "_" + ++i;
+        } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
+        aName = aName2;
+        theObjectNames(anEntry) = aName;
+      }
+    } else {
+      // is a GEOM object?
+      aName = geom->GetDumpName( anEntry.ToCString() );
+      if ( aName.IsEmpty() ) {
+      // ? Removed Object ?
+        do {
+          aName = aBaseName + TCollection_AsciiString(++objectCounter);
+        } while (theObjectNames.IsBound(aName));
+        seqRemoved.Append(aName);
+        mapRemoved.Bind(anEntry, "1");
+      }
+      theObjectNames.Bind(anEntry, aName);
+    }
+    theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
+
+    anUpdatedScript += aName;
+    aNames.Bind(aName, "1");
+    aStart = aSeq->Value(i + 1) + 1;
+  }
+
+  // add final part of aScript
+  if (aSeq->Value(aLen) < aScriptLength)
+    anUpdatedScript += aScript.SubString(aSeq->Value(aLen) + 1, aScriptLength);
+
+  // Remove removed objects
+  anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()";
+  for (int ir = 1; ir <= seqRemoved.Length(); ir++) {
+    anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(";
+    anUpdatedScript += seqRemoved.Value(ir);
+    anUpdatedScript += "))\n\tif SO is not None: aStudyBuilder.RemoveObjectWithChildren(SO)";
+  }
+  anUpdatedScript += "\n";
+
+  // Set object names
+  anUpdatedScript += "\n\tisGUIMode = ";
+  anUpdatedScript += isPublished;
+  anUpdatedScript += "\n\tif isGUIMode:";
+  anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")";
+  anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())";
+  anUpdatedScript += "\n";
+
+  Resource_DataMapOfAsciiStringAsciiString mapEntries;
+  for (Standard_Integer i = 1; i <= aLen; i += 2) {
+    anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
+    if (theObjectNames.IsBound(anEntry) &&
+        !mapEntries.IsBound(anEntry) &&
+        !mapRemoved.IsBound(anEntry)) {
+      aName = theObjectNames.Find(anEntry);
+      mapEntries.Bind(anEntry, aName);
+      anUpdatedScript += "\n\t\tsmeshgui.SetName(salome.ObjectToID(";
+      anUpdatedScript += aName + "), \"" + aName + "\")";
+    }
+  }
+  anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)";
+
+  anUpdatedScript += "\n\n\tpass\n";
+
+  aValidScript = true;
+
+  return anUpdatedScript;
+}
+
+//=============================================================================
+/*!
+ *  GetNewPythonLines
+ */
+//=============================================================================
+TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines (int theStudyID)
+{
+  TCollection_AsciiString aScript;
+
+  // Dump trace of API methods calls
+  if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
+    Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[theStudyID];
+    Standard_Integer istr, aLen = aPythonScript->Length();
+    for (istr = 1; istr <= aLen; istr++) {
+      aScript += "\n\t";
+      aScript += aPythonScript->Value(istr);
+    }
+    aScript += "\n";
+  }
+
+  return aScript;
+}
+
+//=============================================================================
+/*!
+ *  CleanPythonTrace
+ */
+//=============================================================================
+void SMESH_Gen_i::CleanPythonTrace (int theStudyID)
+{
+  TCollection_AsciiString aScript;
+
+  // Clean trace of API methods calls
+  if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
+    myPythonScripts[theStudyID]->Clear();
+  }
+}
index 1348b83ef63c799bd0c0b455656344228c4b6afb..fedb37bb2fab59a37e7cfdb9bf3c7947a9c40897 100644 (file)
@@ -29,6 +29,7 @@
 #include "SMESH_Filter_i.hxx"
 
 #include "SMESH_Gen_i.hxx"
+#include "SMESH_PythonDump.hxx"
 
 #include "SMDS_Mesh.hxx"
 #include "SMDS_MeshNode.hxx"
 using namespace SMESH;
 using namespace SMESH::Controls;
 
+
+namespace SMESH
+{
+  Predicate_i* 
+  GetPredicate( Predicate_ptr thePredicate )
+  {
+    PortableServer::ServantBase_var aServant = SMESH_Gen_i::GetServant( thePredicate );
+    return dynamic_cast<Predicate_i*>(aServant.in());
+  }
+}
+
+
 /*
   Class       : BelongToGeom
   Description : Predicate for verifying whether entiy belong to
@@ -74,9 +87,9 @@ Controls::BelongToGeom::BelongToGeom()
   myType(SMDSAbs_All)
 {}
 
-void Controls::BelongToGeom::SetMesh( SMDS_Mesh* theMesh )
+void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh )
 {
-  myMeshDS = dynamic_cast<SMESHDS_Mesh*>(theMesh);
+  myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
 }
 
 void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
@@ -84,7 +97,7 @@ void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
   myShape = theShape;
 }
 
-static bool IsContains( SMESHDS_Mesh*           theMeshDS,
+static bool IsContains( const SMESHDS_Mesh*     theMeshDS,
                         const TopoDS_Shape&     theShape,
                         const SMDS_MeshElement* theElem,
                         TopAbs_ShapeEnum        theFindShapeEnum,
@@ -166,7 +179,9 @@ TopoDS_Shape Controls::BelongToGeom::GetShape()
   return myShape;
 }
 
-SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS()
+const SMESHDS_Mesh* 
+Controls::BelongToGeom::
+GetMeshDS() const
 {
   return myMeshDS;
 }
@@ -182,9 +197,9 @@ Controls::LyingOnGeom::LyingOnGeom()
   myType(SMDSAbs_All)
 {}
 
-void Controls::LyingOnGeom::SetMesh( SMDS_Mesh* theMesh )
+void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
 {
myMeshDS = dynamic_cast<SMESHDS_Mesh*>(theMesh);
 myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
 }
 
 void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
@@ -254,12 +269,14 @@ TopoDS_Shape Controls::LyingOnGeom::GetShape()
   return myShape;
 }
 
-SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS()
+const SMESHDS_Mesh* 
+Controls::LyingOnGeom::
+GetMeshDS() const
 {
   return myMeshDS;
 }
 
-bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh*           theMeshDS,
+bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh*     theMeshDS,
                                      const TopoDS_Shape&     theShape,
                                      const SMDS_MeshElement* theElem,
                                      TopAbs_ShapeEnum        theFindShapeEnum,
@@ -301,14 +318,18 @@ bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh*           theMeshDS,
                             AUXILIARY METHODS
 */
 
-static inline SMDS_Mesh* MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
+inline 
+const SMDS_Mesh* 
+MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
 {
   SMESH_Mesh_i* anImplPtr = 
     dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( theMesh ).in() );
   return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
 }
 
-static inline SMESH::long_array* toArray( const TColStd_ListOfInteger& aList )
+inline 
+SMESH::long_array* 
+toArray( const TColStd_ListOfInteger& aList )
 {
   SMESH::long_array_var anArray = new SMESH::long_array;
   anArray->length( aList.Extent() );
@@ -320,7 +341,9 @@ static inline SMESH::long_array* toArray( const TColStd_ListOfInteger& aList )
   return anArray._retn();
 }
 
-static inline SMESH::double_array* toArray( const TColStd_ListOfReal& aList )
+inline 
+SMESH::double_array* 
+toArray( const TColStd_ListOfReal& aList )
 {
   SMESH::double_array_var anArray = new SMESH::double_array;
   anArray->length( aList.Extent() );
@@ -1005,6 +1028,7 @@ Comparator_i::~Comparator_i()
 void Comparator_i::SetMargin( CORBA::Double theValue )
 {
   myComparatorPtr->SetMargin( theValue );
+  TPythonDump()<<this<<".SetMargin("<<float(theValue)<<")";
 }
 
 CORBA::Double Comparator_i::GetMargin()
@@ -1023,6 +1047,7 @@ void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct )
   {
     myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() );
     myNumericalFunctor->Register();
+    TPythonDump()<<this<<".SetNumFunctor("<<myNumericalFunctor<<")";
   }
 }
 
@@ -1111,12 +1136,12 @@ LogicalNOT_i::~LogicalNOT_i()
     myPredicate->Destroy();
 }
 
-void LogicalNOT_i::SetPredicate( Predicate_ptr thePred )
+void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate )
 {
   if ( myPredicate )
     myPredicate->Destroy();
 
-  myPredicate = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePred ).in() );
+  myPredicate = SMESH::GetPredicate(thePredicate);
 
   if ( myPredicate ){
     myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate());
@@ -1167,7 +1192,7 @@ void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate )
   if ( myPredicate1 )
     myPredicate1->Destroy();
 
-  myPredicate1 = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() );
+  myPredicate1 = SMESH::GetPredicate(thePredicate);
 
   if ( myPredicate1 ){
     myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate());
@@ -1180,7 +1205,7 @@ void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate )
   if ( myPredicate2 )
     myPredicate2->Destroy();
 
-  myPredicate2 = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() );
+  myPredicate2 = SMESH::GetPredicate(thePredicate);
 
   if ( myPredicate2 ){
     myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate());
@@ -1297,6 +1322,7 @@ Area_ptr FilterManager_i::CreateArea()
 {
   SMESH::Area_i* aServant = new SMESH::Area_i();
   SMESH::Area_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateArea()";
   return anObj._retn();
 }
 
@@ -1397,6 +1423,7 @@ MoreThan_ptr FilterManager_i::CreateMoreThan()
 {
   SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
   SMESH::MoreThan_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateMoreThan()";
   return anObj._retn();
 }
 
@@ -1469,6 +1496,7 @@ SMESH::FilterManager_ptr SMESH_Gen_i::CreateFilterManager()
 {
   SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
   SMESH::FilterManager_var anObj = aFilter->_this();
+  TPythonDump()<<aFilter<<" = smesh.CreateFilterManager()";
   return anObj._retn();
 }
 
@@ -1504,7 +1532,7 @@ void Filter_i::SetPredicate( Predicate_ptr thePredicate )
   if ( myPredicate )
     myPredicate->Destroy();
 
-  myPredicate = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() );
+  myPredicate = SMESH::GetPredicate(thePredicate);
 
   if ( myPredicate )
   {
@@ -1536,10 +1564,29 @@ void Filter_i::SetMesh( SMESH_Mesh_ptr theMesh )
 // name    : Filter_i::GetElementsId
 // Purpose : Get ids of entities
 //=======================================================================
+void
+Filter_i::
+GetElementsId( Predicate_i* thePredicate,
+              const SMDS_Mesh* theMesh,
+              Controls::Filter::TIdSequence& theSequence )
+{
+  Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
+}
+
+void
+Filter_i::
+GetElementsId( Predicate_i* thePredicate,
+              SMESH_Mesh_ptr theMesh,
+              Controls::Filter::TIdSequence& theSequence )
+{
+  if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
+    Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence);
+}
+
 SMESH::long_array* Filter_i::GetElementsId( SMESH_Mesh_ptr theMesh )
 {
-  SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh);
-  Controls::Filter::TIdSequence aSequence = myFilter.GetElementsId(aMesh);
+  Controls::Filter::TIdSequence aSequence;
+  GetElementsId(myPredicate,theMesh,aSequence);
 
   SMESH::long_array_var anArray = new SMESH::long_array;
   long i = 0, iEnd = aSequence.size();
index 7a09289e05fbc6563a1e1cf789d95cc9ff421867..34656f075b554845927ea0b7ecbb85eff188275a 100644 (file)
@@ -42,703 +42,712 @@ class SMESHDS_Mesh;
 namespace SMESH
 {
 
-namespace Controls
-{
-
-/*
-  Class       : BelongToGeom
-  Description : Predicate for verifying whether entiy belong to
-                specified geometrical support
-*/
-class BelongToGeom: public virtual Predicate
-{
-public:
-                                  BelongToGeom();
-
-  virtual void                    SetMesh( SMDS_Mesh* theMesh );
-  virtual void                    SetGeom( const TopoDS_Shape& theShape );
-
-  virtual bool                    IsSatisfy( long theElementId );
-
-  virtual void                    SetType( SMDSAbs_ElementType theType );
-  virtual                         SMDSAbs_ElementType GetType() const;
-
-  TopoDS_Shape                    GetShape();
-  SMESHDS_Mesh*                   GetMeshDS();
-
-private:
-  TopoDS_Shape                    myShape;
-  SMESHDS_Mesh*                   myMeshDS;
-  SMDSAbs_ElementType             myType;
-};
-typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
-
-/*
-  Class       : LyingOnGeom
-  Description : Predicate for verifying whether entiy lying or partially lying on
-                specified geometrical support
-*/
-class LyingOnGeom: public virtual Predicate
-{
-public:
-                                  LyingOnGeom();
+  namespace Controls
+  {
+    
+    /*
+      Class       : BelongToGeom
+      Description : Predicate for verifying whether entiy belong to
+      specified geometrical support
+    */
+    class BelongToGeom: public virtual Predicate
+    {
+    public:
+      BelongToGeom();
+      
+      virtual void                    SetMesh( const SMDS_Mesh* theMesh );
+      virtual void                    SetGeom( const TopoDS_Shape& theShape );
+      
+      virtual bool                    IsSatisfy( long theElementId );
+      
+      virtual void                    SetType( SMDSAbs_ElementType theType );
+      virtual                         SMDSAbs_ElementType GetType() const;
+      
+      TopoDS_Shape                    GetShape();
+      const SMESHDS_Mesh*             GetMeshDS() const;
+      
+    private:
+      TopoDS_Shape                    myShape;
+      const SMESHDS_Mesh*             myMeshDS;
+      SMDSAbs_ElementType             myType;
+    };
+    typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
+    
+    /*
+      Class       : LyingOnGeom
+      Description : Predicate for verifying whether entiy lying or partially lying on
+      specified geometrical support
+    */
+    class LyingOnGeom: public virtual Predicate
+    {
+    public:
+      LyingOnGeom();
+      
+      virtual void                    SetMesh( const SMDS_Mesh* theMesh );
+      virtual void                    SetGeom( const TopoDS_Shape& theShape );
+      
+      virtual bool                    IsSatisfy( long theElementId );
+      
+      virtual void                    SetType( SMDSAbs_ElementType theType );
+      virtual                         SMDSAbs_ElementType GetType() const;
+      
+      TopoDS_Shape                    GetShape();
+      const SMESHDS_Mesh*             GetMeshDS() const;
+      
+      virtual bool                    Contains( const SMESHDS_Mesh*     theMeshDS,
+                                               const TopoDS_Shape&     theShape,
+                                               const SMDS_MeshElement* theElem,
+                                               TopAbs_ShapeEnum        theFindShapeEnum,
+                                               TopAbs_ShapeEnum        theAvoidShapeEnum = TopAbs_SHAPE );
+    private:
+      TopoDS_Shape                    myShape;
+      const SMESHDS_Mesh*             myMeshDS;
+      SMDSAbs_ElementType             myType;
+    };
+    typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
+  }
   
-  virtual void                    SetMesh( SMDS_Mesh* theMesh );
-  virtual void                    SetGeom( const TopoDS_Shape& theShape );
-
-  virtual bool                    IsSatisfy( long theElementId );
-
-  virtual void                    SetType( SMDSAbs_ElementType theType );
-  virtual                         SMDSAbs_ElementType GetType() const;
-
-  TopoDS_Shape                    GetShape();
-  SMESHDS_Mesh*                   GetMeshDS();
-  
-  virtual bool                    Contains( SMESHDS_Mesh*           theMeshDS,
-                                           const TopoDS_Shape&     theShape,
-                                           const SMDS_MeshElement* theElem,
-                                           TopAbs_ShapeEnum        theFindShapeEnum,
-                                           TopAbs_ShapeEnum        theAvoidShapeEnum = TopAbs_SHAPE );
-private:
-  TopoDS_Shape                    myShape;
-  SMESHDS_Mesh*                   myMeshDS;
-  SMDSAbs_ElementType             myType;
-};
-typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
-}
-
-/*
-                                FUNCTORS
-*/
-
-/*
-  Class       : Functor_i
-  Description : An abstact class for all functors 
-*/
-class Functor_i: public virtual POA_SMESH::Functor,
-                 public virtual SALOME::GenericObj_i
-{
-public:
-  void                            SetMesh( SMESH_Mesh_ptr theMesh );
-  Controls::FunctorPtr            GetFunctor(){ return myFunctorPtr;}
-  ElementType                     GetElementType();
-  
-protected:
-                                  Functor_i();
-protected:                                
-  Controls::FunctorPtr            myFunctorPtr;
-};
-
-
-/*
-  Class       : NumericalFunctor_i
-  Description : Base class for numerical functors 
-*/
-class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor,
-                          public virtual Functor_i
-{
-public:
-  CORBA::Double                   GetValue( CORBA::Long theElementId );
-  void                            SetPrecision( CORBA::Long thePrecision );
-  CORBA::Long                     GetPrecision();
-  Controls::NumericalFunctorPtr   GetNumericalFunctor();
-  
-protected:
-  Controls::NumericalFunctorPtr   myNumericalFunctorPtr;
-};
-
-
-/*
-  Class       : SMESH_MinimumAngleFunct
-  Description : Functor for calculation of minimum angle
-*/
-class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle,
-                      public virtual NumericalFunctor_i
-{
-public:
-                                  MinimumAngle_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : AspectRatio_i
-  Description : Functor for calculating aspect ratio
-*/
-class AspectRatio_i: public virtual POA_SMESH::AspectRatio,
-                     public virtual NumericalFunctor_i
-{
-public:
-                                  AspectRatio_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : AspectRatio3D_i
-  Description : Functor for calculating aspect ratio for 3D
-*/
-class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D,
+  /*
+    FUNCTORS
+  */
+  
+  /*
+    Class       : Functor_i
+    Description : An abstact class for all functors 
+  */
+  class Functor_i: public virtual POA_SMESH::Functor,
+                  public virtual SALOME::GenericObj_i
+  {
+  public:
+    void                            SetMesh( SMESH_Mesh_ptr theMesh );
+    Controls::FunctorPtr            GetFunctor(){ return myFunctorPtr;}
+    ElementType                     GetElementType();
+    
+  protected:
+    Functor_i();
+  protected:                                
+    Controls::FunctorPtr            myFunctorPtr;
+  };
+  
+  /*
+    Class       : NumericalFunctor_i
+    Description : Base class for numerical functors 
+  */
+  class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor,
+                           public virtual Functor_i
+  {
+  public:
+    CORBA::Double                   GetValue( CORBA::Long theElementId );
+    void                            SetPrecision( CORBA::Long thePrecision );
+    CORBA::Long                     GetPrecision();
+    Controls::NumericalFunctorPtr   GetNumericalFunctor();
+    
+  protected:
+    Controls::NumericalFunctorPtr   myNumericalFunctorPtr;
+  };
+  
+  
+  /*
+    Class       : SMESH_MinimumAngleFunct
+    Description : Functor for calculation of minimum angle
+  */
+  class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle,
+                       public virtual NumericalFunctor_i
+  {
+  public:
+    MinimumAngle_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    Class       : AspectRatio_i
+    Description : Functor for calculating aspect ratio
+  */
+  class AspectRatio_i: public virtual POA_SMESH::AspectRatio,
                       public virtual NumericalFunctor_i
-{
-public:
-                                  AspectRatio3D_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : Warping_i
-  Description : Functor for calculating warping
-*/
-class Warping_i: public virtual POA_SMESH::Warping,
-                 public virtual NumericalFunctor_i
-{
-public:
-                                  Warping_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : Taper_i
-  Description : Functor for calculating taper
-*/
-class Taper_i: public virtual POA_SMESH::Taper,
-               public virtual NumericalFunctor_i
-{
-public:
-                                  Taper_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : Skew_i
-  Description : Functor for calculating skew in degrees
-*/
-class Skew_i: public virtual POA_SMESH::Skew,
-              public virtual NumericalFunctor_i
-{
-public:
-                                  Skew_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : Area_i
-  Description : Functor for calculating area
-*/
-class Area_i: public virtual POA_SMESH::Area,
-              public virtual NumericalFunctor_i
-{
-public:
-                                  Area_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : Length_i
-  Description : Functor for calculating length of edge
-*/
-class Length_i: public virtual POA_SMESH::Length,
-                public virtual NumericalFunctor_i
-{
-public:
-                                  Length_i();
-  FunctorType                     GetFunctorType();
-};
+  {
+  public:
+    AspectRatio_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    Class       : AspectRatio3D_i
+    Description : Functor for calculating aspect ratio for 3D
+  */
+  class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D,
+                        public virtual NumericalFunctor_i
+  {
+  public:
+    AspectRatio3D_i();
+    FunctorType                     GetFunctorType();
+  };
+  
 
-/*
-  Class       : Length2D_i
-  Description : Functor for calculating length of edge
-*/
-class Length2D_i: public virtual POA_SMESH::Length2D,
+  /*
+    Class       : Warping_i
+    Description : Functor for calculating warping
+  */
+  class Warping_i: public virtual POA_SMESH::Warping,
+                  public virtual NumericalFunctor_i
+  {
+  public:
+    Warping_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    Class       : Taper_i
+    Description : Functor for calculating taper
+  */
+  class Taper_i: public virtual POA_SMESH::Taper,
+                public virtual NumericalFunctor_i
+  {
+  public:
+    Taper_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    Class       : Skew_i
+    Description : Functor for calculating skew in degrees
+  */
+  class Skew_i: public virtual POA_SMESH::Skew,
+               public virtual NumericalFunctor_i
+  {
+  public:
+    Skew_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    Class       : Area_i
+    Description : Functor for calculating area
+  */
+  class Area_i: public virtual POA_SMESH::Area,
+               public virtual NumericalFunctor_i
+  {
+  public:
+    Area_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    Class       : Length_i
+    Description : Functor for calculating length of edge
+  */
+  class Length_i: public virtual POA_SMESH::Length,
                  public virtual NumericalFunctor_i
-{
-public:
-                                  Length2D_i();
-  SMESH::Length2D::Values*        GetValues();
-  FunctorType                     GetFunctorType();
-
-protected:
-  Controls::Length2DPtr          myLength2DPtr;
-};
-
-
-/*
-  Class       : MultiConnection_i
-  Description : Functor for calculating number of faces conneted to the edge
-*/
-class MultiConnection_i: public virtual POA_SMESH::MultiConnection,
-                         public virtual NumericalFunctor_i
-{
-public:
-                                  MultiConnection_i();
-  FunctorType                     GetFunctorType();
-};
-
-/*
-  Class       : MultiConnection2D_i
-  Description : Functor for calculating number of faces conneted to the edge
-*/
-class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D,
+  {
+  public:
+    Length_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  /*
+    Class       : Length2D_i
+    Description : Functor for calculating length of edge
+  */
+  class Length2D_i: public virtual POA_SMESH::Length2D,
+                   public virtual NumericalFunctor_i
+  {
+  public:
+    Length2D_i();
+    SMESH::Length2D::Values*        GetValues();
+    FunctorType                     GetFunctorType();
+    
+  protected:
+    Controls::Length2DPtr          myLength2DPtr;
+  };
+  
+  
+  /*
+    Class       : MultiConnection_i
+    Description : Functor for calculating number of faces conneted to the edge
+  */
+  class MultiConnection_i: public virtual POA_SMESH::MultiConnection,
                           public virtual NumericalFunctor_i
-{
-public:
-                                     MultiConnection2D_i();
-  SMESH::MultiConnection2D::Values*  GetValues();
-  FunctorType                        GetFunctorType();
-
-protected:
-  Controls::MultiConnection2DPtr     myMulticonnection2DPtr;
-};
-
-
-/*
-                            PREDICATES
-*/
-/*
-  Class       : Predicate_i
-  Description : Base class for all predicates
-*/
-class Predicate_i: public virtual POA_SMESH::Predicate,
-                   public virtual Functor_i
-{
-public:
-  CORBA::Boolean                  IsSatisfy( CORBA::Long theElementId );
-  Controls::PredicatePtr          GetPredicate();
+  {
+  public:
+    MultiConnection_i();
+    FunctorType                     GetFunctorType();
+  };
   
-protected:
-  Controls::PredicatePtr          myPredicatePtr;
-};
-
-
-/*
-  Class       : BadOrientedVolume_i
-  Description : Verify whether a mesh volume is incorrectly oriented from
-                the point of view of MED convention
-*/
-class BadOrientedVolume_i: public virtual POA_SMESH::BadOrientedVolume,
-                           public virtual Predicate_i
-{
- public:
-  BadOrientedVolume_i();
-  FunctorType                     GetFunctorType();
-};
-
-/*
-  Class       : BelongToGeom_i
-  Description : Predicate for selection on geometrical support
-*/
-class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom,
-                      public virtual Predicate_i
-{
-public:
-                                  BelongToGeom_i();
-  virtual                         ~BelongToGeom_i();
-                                  
-  void                            SetGeom( GEOM::GEOM_Object_ptr theGeom );
-  void                            SetElementType( ElementType theType );
-  FunctorType                     GetFunctorType();
-
-  void                            SetGeom( const TopoDS_Shape& theShape );
-
-  void                            SetShapeName( const char* theName );
-  char*                           GetShapeName();
-
-protected:
-  Controls::BelongToGeomPtr       myBelongToGeomPtr;
-  char*                           myShapeName;
-};
-
-/*
-  Class       : BelongToSurface_i
-  Description : Verify whether mesh element lie in pointed Geom planar object
-*/
-class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface,
-                         public virtual Predicate_i
-{
-public:
-                                  BelongToSurface_i( const Handle(Standard_Type)& );
-  virtual                         ~BelongToSurface_i();
-
-  void                            SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
-
-  void                            SetShapeName( const char* theName, ElementType theType );
-  char*                           GetShapeName();
-
-  void                            SetTolerance( CORBA::Double );
-  CORBA::Double                   GetTolerance();
-
-protected:
-  Controls::ElementsOnSurfacePtr  myElementsOnSurfacePtr;
-  char*                           myShapeName;
-  Handle(Standard_Type)           mySurfaceType;
-};
-
-/*
-  Class       : BelongToPlane_i
-  Description : Verify whether mesh element lie in pointed Geom planar object
-*/
-class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane,
-                       public virtual BelongToSurface_i
-{
-public:
-                                  BelongToPlane_i();
-  void                            SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
-  FunctorType                     GetFunctorType();
-};
-
-/*
-  Class       : BelongToCylinder_i
-  Description : Verify whether mesh element lie in pointed Geom cylindrical object
-*/
-class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder,
-                          public virtual BelongToSurface_i
-{
-public:
-                                  BelongToCylinder_i();
-  void                            SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
-  FunctorType                     GetFunctorType();
-};
-
-/*
-  Class       : LyingOnGeom_i
-  Description : Predicate for selection on geometrical support(lying or partially lying)
-*/
-class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom,
+  /*
+    Class       : MultiConnection2D_i
+    Description : Functor for calculating number of faces conneted to the edge
+  */
+  class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D,
+                            public virtual NumericalFunctor_i
+  {
+  public:
+    MultiConnection2D_i();
+    SMESH::MultiConnection2D::Values*  GetValues();
+    FunctorType                        GetFunctorType();
+    
+  protected:
+    Controls::MultiConnection2DPtr     myMulticonnection2DPtr;
+  };
+  
+  
+  /*
+    PREDICATES
+  */
+  /*
+    Class       : Predicate_i
+    Description : Base class for all predicates
+  */
+  class Predicate_i: public virtual POA_SMESH::Predicate,
+                    public virtual Functor_i
+  {
+  public:
+    CORBA::Boolean                  IsSatisfy( CORBA::Long theElementId );
+    Controls::PredicatePtr          GetPredicate();
+    
+  protected:
+    Controls::PredicatePtr          myPredicatePtr;
+  };
+  
+  
+  /*
+    Class       : BadOrientedVolume_i
+    Description : Verify whether a mesh volume is incorrectly oriented from
+    the point of view of MED convention
+  */
+  class BadOrientedVolume_i: public virtual POA_SMESH::BadOrientedVolume,
+                            public virtual Predicate_i
+  {
+  public:
+    BadOrientedVolume_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  /*
+    Class       : BelongToGeom_i
+    Description : Predicate for selection on geometrical support
+  */
+  class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom,
+                       public virtual Predicate_i
+  {
+  public:
+    BelongToGeom_i();
+    virtual                         ~BelongToGeom_i();
+    
+    void                            SetGeom( GEOM::GEOM_Object_ptr theGeom );
+    void                            SetElementType( ElementType theType );
+    FunctorType                     GetFunctorType();
+    
+    void                            SetGeom( const TopoDS_Shape& theShape );
+    
+    void                            SetShapeName( const char* theName );
+    char*                           GetShapeName();
+    
+  protected:
+    Controls::BelongToGeomPtr       myBelongToGeomPtr;
+    char*                           myShapeName;
+  };
+  
+  /*
+    Class       : BelongToSurface_i
+    Description : Verify whether mesh element lie in pointed Geom planar object
+  */
+  class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface,
+                          public virtual Predicate_i
+  {
+  public:
+    BelongToSurface_i( const Handle(Standard_Type)& );
+    virtual                         ~BelongToSurface_i();
+    
+    void                            SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
+    
+    void                            SetShapeName( const char* theName, ElementType theType );
+    char*                           GetShapeName();
+    
+    void                            SetTolerance( CORBA::Double );
+    CORBA::Double                   GetTolerance();
+    
+  protected:
+    Controls::ElementsOnSurfacePtr  myElementsOnSurfacePtr;
+    char*                           myShapeName;
+    Handle(Standard_Type)           mySurfaceType;
+  };
+  
+  /*
+    Class       : BelongToPlane_i
+    Description : Verify whether mesh element lie in pointed Geom planar object
+  */
+  class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane,
+                        public virtual BelongToSurface_i
+  {
+  public:
+    BelongToPlane_i();
+    void                            SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
+    FunctorType                     GetFunctorType();
+  };
+  
+  /*
+    Class       : BelongToCylinder_i
+    Description : Verify whether mesh element lie in pointed Geom cylindrical object
+  */
+  class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder,
+                           public virtual BelongToSurface_i
+  {
+  public:
+    BelongToCylinder_i();
+    void                            SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
+    FunctorType                     GetFunctorType();
+  };
+  
+  /*
+    Class       : LyingOnGeom_i
+    Description : Predicate for selection on geometrical support(lying or partially lying)
+  */
+  class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom,
+                      public virtual Predicate_i
+  {
+  public:
+    LyingOnGeom_i();
+    virtual                         ~LyingOnGeom_i();
+    
+    void                            SetGeom( GEOM::GEOM_Object_ptr theGeom );
+    void                            SetElementType( ElementType theType );
+    FunctorType                     GetFunctorType();
+    
+    void                            SetGeom( const TopoDS_Shape& theShape );
+    
+    void                            SetShapeName( const char* theName );
+    char*                           GetShapeName();
+    
+  protected:
+    Controls::LyingOnGeomPtr        myLyingOnGeomPtr;
+    char*                           myShapeName;
+  };
+  
+  /*
+    Class       : FreeBorders_i
+    Description : Predicate for free borders
+  */
+  class FreeBorders_i: public virtual POA_SMESH::FreeBorders,
+                      public virtual Predicate_i
+  {
+  public:
+    FreeBorders_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    Class       : FreeEdges_i
+    Description : Predicate for free edges
+  */
+  class FreeEdges_i: public virtual POA_SMESH::FreeEdges,
                     public virtual Predicate_i
-{
-public:
-                                  LyingOnGeom_i();
-  virtual                         ~LyingOnGeom_i();
+  {
+  public:
+    FreeEdges_i();
+    SMESH::FreeEdges::Borders*      GetBorders();
+    FunctorType                     GetFunctorType();
     
-  void                            SetGeom( GEOM::GEOM_Object_ptr theGeom );
-  void                            SetElementType( ElementType theType );
-  FunctorType                     GetFunctorType();
+  protected:
+    Controls::FreeEdgesPtr          myFreeEdgesPtr;
+  };
   
-  void                            SetGeom( const TopoDS_Shape& theShape );
   
-  void                            SetShapeName( const char* theName );
-  char*                           GetShapeName();
+  /*
+    Class       : RangeOfIds_i
+    Description : Predicate for Range of Ids
+  */
+  class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds,
+                     public virtual Predicate_i
+  {
+  public:
+    RangeOfIds_i();
+    void                            SetRange( const SMESH::long_array& theIds );
+    CORBA::Boolean                  SetRangeStr( const char* theRange );
+    char*                           GetRangeStr();
+    
+    void                            SetElementType( ElementType theType );
+    FunctorType                     GetFunctorType();
+    
+  protected:
+    Controls::RangeOfIdsPtr         myRangeOfIdsPtr;
+  };
   
-protected:
-  Controls::LyingOnGeomPtr        myLyingOnGeomPtr;
-  char*                           myShapeName;
-};
-
-/*
-  Class       : FreeBorders_i
-  Description : Predicate for free borders
-*/
-class FreeBorders_i: public virtual POA_SMESH::FreeBorders,
-                     public virtual Predicate_i
-{
-public:
-                                  FreeBorders_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : FreeEdges_i
-  Description : Predicate for free edges
-*/
-class FreeEdges_i: public virtual POA_SMESH::FreeEdges,
-                   public virtual Predicate_i
-{
-public:
-                                  FreeEdges_i();
-  SMESH::FreeEdges::Borders*      GetBorders();
-  FunctorType                     GetFunctorType();
-  
-protected:
-  Controls::FreeEdgesPtr          myFreeEdgesPtr;
-};
-
-
-/*
-  Class       : RangeOfIds_i
-  Description : Predicate for Range of Ids
-*/
-class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds,
-                    public virtual Predicate_i
-{
-public:
-                                  RangeOfIds_i();
-  void                            SetRange( const SMESH::long_array& theIds );
-  CORBA::Boolean                  SetRangeStr( const char* theRange );
-  char*                           GetRangeStr();
-
-  void                            SetElementType( ElementType theType );
-  FunctorType                     GetFunctorType();
-
-protected:
-  Controls::RangeOfIdsPtr         myRangeOfIdsPtr;
-};
-
-/*
-  Class       : Comparator_i
-  Description : Base class for comparators
-*/
-class Comparator_i: public virtual POA_SMESH::Comparator,
-                    public virtual Predicate_i
-{
-public:
-  virtual                         ~Comparator_i();
-  
-  virtual void                    SetMargin( CORBA::Double );
-  virtual void                    SetNumFunctor( NumericalFunctor_ptr );
-  
-  Controls::ComparatorPtr         GetComparator();
-  NumericalFunctor_i*             GetNumFunctor_i();
-  CORBA::Double                   GetMargin();
-  
-protected:
-                                  Comparator_i();
-protected:                                  
-  Controls::ComparatorPtr         myComparatorPtr;
-  NumericalFunctor_i*             myNumericalFunctor;
-};
-
-
-/*
-  Class       : LessThan_i
-  Description : Comparator "<"
-*/
-class LessThan_i: public virtual POA_SMESH::LessThan,
-                  public virtual Comparator_i
-{
-public:
-                                  LessThan_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : MoreThan_i
-  Description : Comparator ">"
-*/
-class MoreThan_i: public virtual POA_SMESH::MoreThan,
-                  public virtual Comparator_i
-{
-public:
-                                  MoreThan_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : EqualTo_i
-  Description : Comparator "="
-*/
-class EqualTo_i: public virtual POA_SMESH::EqualTo,
-                 public virtual Comparator_i
-{
-public:
-                                  EqualTo_i();
-  virtual void                    SetTolerance( CORBA::Double );
-  CORBA::Double                   GetTolerance();
-  FunctorType                     GetFunctorType();
-  
-protected:
-  Controls::EqualToPtr            myEqualToPtr;
-};
-
-
-/*
-  Class       : LogicalNOT_i
-  Description : Logical NOT predicate
-*/
-class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT,
-                    public virtual Predicate_i
-{
-public:
-                                  LogicalNOT_i();
+  /*
+    Class       : Comparator_i
+    Description : Base class for comparators
+  */
+  class Comparator_i: public virtual POA_SMESH::Comparator,
+                     public virtual Predicate_i
+  {
+  public:
+    virtual                         ~Comparator_i();
+    
+    virtual void                    SetMargin( CORBA::Double );
+    virtual void                    SetNumFunctor( NumericalFunctor_ptr );
+    
+    Controls::ComparatorPtr         GetComparator();
+    NumericalFunctor_i*             GetNumFunctor_i();
+    CORBA::Double                   GetMargin();
+    
+  protected:
+    Comparator_i();
+  protected:                                  
+    Controls::ComparatorPtr         myComparatorPtr;
+    NumericalFunctor_i*             myNumericalFunctor;
+  };
+  
+  
+  /*
+    Class       : LessThan_i
+    Description : Comparator "<"
+  */
+  class LessThan_i: public virtual POA_SMESH::LessThan,
+                   public virtual Comparator_i
+  {
+  public:
+    LessThan_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    Class       : MoreThan_i
+    Description : Comparator ">"
+  */
+  class MoreThan_i: public virtual POA_SMESH::MoreThan,
+                   public virtual Comparator_i
+  {
+  public:
+    MoreThan_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    Class       : EqualTo_i
+    Description : Comparator "="
+  */
+  class EqualTo_i: public virtual POA_SMESH::EqualTo,
+                  public virtual Comparator_i
+  {
+  public:
+    EqualTo_i();
+    virtual void                    SetTolerance( CORBA::Double );
+    CORBA::Double                   GetTolerance();
+    FunctorType                     GetFunctorType();
+    
+  protected:
+    Controls::EqualToPtr            myEqualToPtr;
+  };
+  
+  
+  /*
+    Class       : LogicalNOT_i
+    Description : Logical NOT predicate
+  */
+  class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT,
+                     public virtual Predicate_i
+  {
+  public:
+    LogicalNOT_i();
   virtual                         ~LogicalNOT_i();
+    
+    virtual void                    SetPredicate( Predicate_ptr );
+    Predicate_i*                    GetPredicate_i();
+    FunctorType                     GetFunctorType();
+    
+  protected:
+    Controls::LogicalNOTPtr         myLogicalNOTPtr;
+    Predicate_i*                    myPredicate;
+  };
   
-  virtual void                    SetPredicate( Predicate_ptr );
-  Predicate_i*                    GetPredicate_i();
-  FunctorType                     GetFunctorType();
   
-protected:
-  Controls::LogicalNOTPtr         myLogicalNOTPtr;
-  Predicate_i*                    myPredicate;
-};
-
-
-/*
-  Class       : LogicalBinary_i
-  Description : Base class for binary logical predicate
-*/
-class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary,
-                       public virtual Predicate_i
-{
-public:
-  virtual                         ~LogicalBinary_i();
-  virtual void                    SetMesh( SMESH_Mesh_ptr theMesh );
-  virtual void                    SetPredicate1( Predicate_ptr );
-  virtual void                    SetPredicate2( Predicate_ptr );
-  
-  Controls::LogicalBinaryPtr      GetLogicalBinary();
-  Predicate_i*                    GetPredicate1_i();
-  Predicate_i*                    GetPredicate2_i();
-  
-protected:
-                                  LogicalBinary_i();
-protected:  
-  Controls::LogicalBinaryPtr      myLogicalBinaryPtr;
-  Predicate_i*                    myPredicate1;
-  Predicate_i*                    myPredicate2;
-};
-
-
-/*
-  Class       : LogicalAND_i
-  Description : Logical AND
-*/
-class LogicalAND_i: public virtual POA_SMESH::LogicalAND,
-                    public virtual LogicalBinary_i
-{
-public:
-                                  LogicalAND_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-  Class       : LogicalOR_i
-  Description : Logical OR
-*/
-class LogicalOR_i: public virtual POA_SMESH::LogicalOR,
-                   public virtual LogicalBinary_i
-{
-public:
-                                  LogicalOR_i();
-  FunctorType                     GetFunctorType();
-};
-
-
-/*
-                               FILTER
-*/
-class Filter_i: public virtual POA_SMESH::Filter,
-                public virtual SALOME::GenericObj_i
-{
-public:
-                                  Filter_i();
-  virtual                         ~Filter_i();
+  /*
+    Class       : LogicalBinary_i
+    Description : Base class for binary logical predicate
+  */
+  class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary,
+                        public virtual Predicate_i
+  {
+  public:
+    virtual                         ~LogicalBinary_i();
+    virtual void                    SetMesh( SMESH_Mesh_ptr theMesh );
+    virtual void                    SetPredicate1( Predicate_ptr );
+    virtual void                    SetPredicate2( Predicate_ptr );
+    
+    Controls::LogicalBinaryPtr      GetLogicalBinary();
+    Predicate_i*                    GetPredicate1_i();
+    Predicate_i*                    GetPredicate2_i();
+    
+  protected:
+    LogicalBinary_i();
+  protected:  
+    Controls::LogicalBinaryPtr      myLogicalBinaryPtr;
+    Predicate_i*                    myPredicate1;
+    Predicate_i*                    myPredicate2;
+  };
   
-  void                            SetPredicate( Predicate_ptr );
-  void                            SetMesh( SMESH_Mesh_ptr );
-
-  long_array*                     GetElementsId( SMESH_Mesh_ptr );
-  ElementType                     GetElementType();
-
-  CORBA::Boolean                  GetCriteria( SMESH::Filter::Criteria_out theCriteria );
-  CORBA::Boolean                  SetCriteria( const SMESH::Filter::Criteria& theCriteria );
   
-  Predicate_ptr                   GetPredicate();
-  Predicate_i*                    GetPredicate_i();
-
-private:
-  Controls::Filter                myFilter;
-  Predicate_i*                    myPredicate;
-};
-
-
-/*
-                            FILTER LIBRARY
-*/
-class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary,
-                       public virtual SALOME::GenericObj_i
-{
-public:
-                          FilterLibrary_i( const char* theFileName );
-                          FilterLibrary_i();
-                          ~FilterLibrary_i();
-
-  Filter_ptr              Copy( const char* theFilterName );
-
-  CORBA::Boolean          Add     ( const char* theFilterName, Filter_ptr theFilter );
-  CORBA::Boolean          AddEmpty( const char* theFilterName, ElementType theType );
-  CORBA::Boolean          Delete  ( const char* theFilterName );
-  CORBA::Boolean          Replace ( const char* theFilterName, 
-                                    const char* theNewName, 
-                                    Filter_ptr  theFilter );
-
-  CORBA::Boolean          Save();
-  CORBA::Boolean          SaveAs( const char* aFileName );
-  
-  CORBA::Boolean          IsPresent( const char* aFilterName );
-  CORBA::Long             NbFilters( ElementType );
-  string_array*           GetNames( ElementType );
-  string_array*           GetAllNames();
-  void                    SetFileName( const char* theFileName );
-  char*                   GetFileName();
-
-private:
-  char*                   myFileName;
-  LDOM_Document           myDoc;
-  FilterManager_var       myFilterMgr;
-};
-
-
-/*
-                            FILTER MANAGER
-*/
-
-class FilterManager_i: public virtual POA_SMESH::FilterManager,
-                       public virtual SALOME::GenericObj_i
-{
-public:
-                            FilterManager_i();
-  MinimumAngle_ptr          CreateMinimumAngle();
-  AspectRatio_ptr           CreateAspectRatio();
-  AspectRatio3D_ptr         CreateAspectRatio3D();
-  Warping_ptr               CreateWarping();
-  Taper_ptr                 CreateTaper();
-  Skew_ptr                  CreateSkew();
-  Area_ptr                  CreateArea();
-  Length_ptr                CreateLength();
-  Length2D_ptr              CreateLength2D();
-  MultiConnection_ptr       CreateMultiConnection();
-  MultiConnection2D_ptr     CreateMultiConnection2D();
-  
-  BelongToGeom_ptr          CreateBelongToGeom();
-  BelongToPlane_ptr         CreateBelongToPlane();
-  BelongToCylinder_ptr      CreateBelongToCylinder();
-
-  LyingOnGeom_ptr           CreateLyingOnGeom();
-
-  FreeBorders_ptr           CreateFreeBorders();
-  FreeEdges_ptr             CreateFreeEdges();
-
-  RangeOfIds_ptr            CreateRangeOfIds();
-
-  BadOrientedVolume_ptr     CreateBadOrientedVolume();
-
-  LessThan_ptr              CreateLessThan();
-  MoreThan_ptr              CreateMoreThan();
-  EqualTo_ptr               CreateEqualTo();
+  /*
+    Class       : LogicalAND_i
+    Description : Logical AND
+  */
+  class LogicalAND_i: public virtual POA_SMESH::LogicalAND,
+                     public virtual LogicalBinary_i
+  {
+  public:
+    LogicalAND_i();
+    FunctorType                     GetFunctorType();
+  };
   
-  LogicalNOT_ptr            CreateLogicalNOT();
-  LogicalAND_ptr            CreateLogicalAND();
-  LogicalOR_ptr             CreateLogicalOR();
-
-  Filter_ptr                CreateFilter();
-
-  FilterLibrary_ptr         LoadLibrary( const char* aFileName );
-  FilterLibrary_ptr         CreateLibrary();
-  CORBA::Boolean            DeleteLibrary( const char* aFileName );
-};
-
-
+  
+  /*
+    Class       : LogicalOR_i
+    Description : Logical OR
+  */
+  class LogicalOR_i: public virtual POA_SMESH::LogicalOR,
+                    public virtual LogicalBinary_i
+  {
+  public:
+    LogicalOR_i();
+    FunctorType                     GetFunctorType();
+  };
+  
+  
+  /*
+    FILTER
+  */
+  class Filter_i: public virtual POA_SMESH::Filter,
+                 public virtual SALOME::GenericObj_i
+  {
+  public:
+    Filter_i();
+    virtual          ~Filter_i();
+    
+    void             SetPredicate( Predicate_ptr );
+    void             SetMesh( SMESH_Mesh_ptr );
+    
+    static
+    void             GetElementsId( Predicate_i*,
+                                   const SMDS_Mesh*,
+                                   Controls::Filter::TIdSequence& );
+    static
+    void             GetElementsId( Predicate_i*,
+                                   SMESH_Mesh_ptr,
+                                   Controls::Filter::TIdSequence& );
+
+    long_array*      GetElementsId( SMESH_Mesh_ptr );
+    ElementType      GetElementType();
+    
+    CORBA::Boolean   GetCriteria( SMESH::Filter::Criteria_out theCriteria );
+    CORBA::Boolean   SetCriteria( const SMESH::Filter::Criteria& theCriteria );
+    
+    Predicate_ptr    GetPredicate();
+    Predicate_i*     GetPredicate_i();
 
-};
+  private:
+    Controls::Filter myFilter;
+    Predicate_i*     myPredicate;
+  };
+  
+  
+  /*
+    FILTER LIBRARY
+  */
+  class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary,
+                        public virtual SALOME::GenericObj_i
+  {
+  public:
+    FilterLibrary_i( const char* theFileName );
+    FilterLibrary_i();
+    ~FilterLibrary_i();
+    
+    Filter_ptr              Copy( const char* theFilterName );
+    
+    CORBA::Boolean          Add     ( const char* theFilterName, Filter_ptr theFilter );
+    CORBA::Boolean          AddEmpty( const char* theFilterName, ElementType theType );
+    CORBA::Boolean          Delete  ( const char* theFilterName );
+    CORBA::Boolean          Replace ( const char* theFilterName, 
+                                     const char* theNewName, 
+                                     Filter_ptr  theFilter );
+    
+    CORBA::Boolean          Save();
+    CORBA::Boolean          SaveAs( const char* aFileName );
+    
+    CORBA::Boolean          IsPresent( const char* aFilterName );
+    CORBA::Long             NbFilters( ElementType );
+    string_array*           GetNames( ElementType );
+    string_array*           GetAllNames();
+    void                    SetFileName( const char* theFileName );
+    char*                   GetFileName();
+    
+  private:
+    char*                   myFileName;
+    LDOM_Document           myDoc;
+    FilterManager_var       myFilterMgr;
+  };
+  
+  
+  /*
+    FILTER MANAGER
+  */
+  
+  class FilterManager_i: public virtual POA_SMESH::FilterManager,
+                        public virtual SALOME::GenericObj_i
+  {
+  public:
+    FilterManager_i();
+    MinimumAngle_ptr          CreateMinimumAngle();
+    AspectRatio_ptr           CreateAspectRatio();
+    AspectRatio3D_ptr         CreateAspectRatio3D();
+    Warping_ptr               CreateWarping();
+    Taper_ptr                 CreateTaper();
+    Skew_ptr                  CreateSkew();
+    Area_ptr                  CreateArea();
+    Length_ptr                CreateLength();
+    Length2D_ptr              CreateLength2D();
+    MultiConnection_ptr       CreateMultiConnection();
+    MultiConnection2D_ptr     CreateMultiConnection2D();
+    
+    BelongToGeom_ptr          CreateBelongToGeom();
+    BelongToPlane_ptr         CreateBelongToPlane();
+    BelongToCylinder_ptr      CreateBelongToCylinder();
+    
+    LyingOnGeom_ptr           CreateLyingOnGeom();
+    
+    FreeBorders_ptr           CreateFreeBorders();
+    FreeEdges_ptr             CreateFreeEdges();
+    
+    RangeOfIds_ptr            CreateRangeOfIds();
+    
+    BadOrientedVolume_ptr     CreateBadOrientedVolume();
+    
+    LessThan_ptr              CreateLessThan();
+    MoreThan_ptr              CreateMoreThan();
+    EqualTo_ptr               CreateEqualTo();
+    
+    LogicalNOT_ptr            CreateLogicalNOT();
+    LogicalAND_ptr            CreateLogicalAND();
+    LogicalOR_ptr             CreateLogicalOR();
+    
+    Filter_ptr                CreateFilter();
+    
+    FilterLibrary_ptr         LoadLibrary( const char* aFileName );
+    FilterLibrary_ptr         CreateLibrary();
+    CORBA::Boolean            DeleteLibrary( const char* aFileName );
+  };
+  
+  
+  Predicate_i* 
+  GetPredicate( SMESH::Predicate_ptr thePredicate );
+}
 
 
 #endif
diff --git a/src/SMESH_I/SMESH_Gen_i_DumpPython.cxx b/src/SMESH_I/SMESH_Gen_i_DumpPython.cxx
deleted file mode 100644 (file)
index 16ae06a..0000000
+++ /dev/null
@@ -1,387 +0,0 @@
-// File    : SMESH_Gen_i_DumpPython.cxx
-// Created : Thu Mar 24 17:17:59 2005
-// Author  : Julia DOROVSKIKH
-// Module  : SMESH
-// $Header : $
-
-#include "SMESH_Gen_i.hxx"
-
-#include <TColStd_HSequenceOfInteger.hxx>
-
-//=======================================================================
-//function : DumpPython
-//purpose  : 
-//=======================================================================
-Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
-                                           CORBA::Boolean isPublished,
-                                           CORBA::Boolean& isValidScript)
-{
-  SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
-  if (CORBA::is_nil(aStudy))
-    return new Engines::TMPFile(0);
-
-  SALOMEDS::SObject_var aSO = aStudy->FindComponent(ComponentDataType());
-  if (CORBA::is_nil(aSO))
-    return new Engines::TMPFile(0);
-
-  // Map study entries to object names
-  Resource_DataMapOfAsciiStringAsciiString aMap;
-  TCollection_AsciiString s ("qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_");
-
-  SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
-  for (Itr->InitEx(true); Itr->More(); Itr->Next()) {
-    SALOMEDS::SObject_var aValue = Itr->Value();
-
-    TCollection_AsciiString aName (aValue->GetName());
-    if (aName.Length() > 0) {
-      int p, p2 = 1, e = aName.Length();
-      while ((p = aName.FirstLocationNotInSet(s, p2, e))) {
-        aName.SetValue(p, '_');
-        p2 = p;
-      }
-      aMap.Bind(TCollection_AsciiString(aValue->GetID()), aName);
-    }
-  }
-
-  // Get trace of restored study
-  //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this());
-  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-  SALOMEDS::GenericAttribute_var anAttr =
-    aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
-
-  char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject();
-  TCollection_AsciiString aSavedTrace (oldValue);
-
-  // Add trace of API methods calls and replace study entries by names
-  bool aValidScript;
-  //TCollection_AsciiString aScript = myGen.DumpPython
-  TCollection_AsciiString aScript = DumpPython_impl
-    (aStudy->StudyId(), aMap, isPublished, aValidScript, aSavedTrace);
-
-  int aLen = aScript.Length(); 
-  unsigned char* aBuffer = new unsigned char[aLen+1];
-  strcpy((char*)aBuffer, aScript.ToCString());
-
-  CORBA::Octet* anOctetBuf =  (CORBA::Octet*)aBuffer;
-  Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1); 
-  isValidScript = aValidScript;
-
-  return aStreamFile._retn(); 
-}
-
-//=============================================================================
-/*!
- *  AddToPythonScript
- */
-//=============================================================================
-void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString)
-{
-  if (myPythonScripts.find(theStudyID) == myPythonScripts.end()) {
-    myPythonScripts[theStudyID] = new TColStd_HSequenceOfAsciiString;
-  }
-  myPythonScripts[theStudyID]->Append(theString);
-}
-
-//=============================================================================
-/*!
- *  RemoveLastFromPythonScript
- */
-//=============================================================================
-void SMESH_Gen_i::RemoveLastFromPythonScript (int theStudyID)
-{
-  if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
-    int aLen = myPythonScripts[theStudyID]->Length();
-    myPythonScripts[theStudyID]->Remove(aLen);
-  }
-}
-
-//=======================================================================
-//function : AddToCurrentPyScript
-//purpose  : 
-//=======================================================================
-
-void SMESH_Gen_i::AddToCurrentPyScript (const TCollection_AsciiString& theString)
-{
-  SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
-  SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
-  if (aStudy->_is_nil()) return;
-  aSMESHGen->AddToPythonScript(aStudy->StudyId(), theString);
-}
-
-
-//=======================================================================
-//function : AddObject
-//purpose  : add object to script string
-//=======================================================================
-
-TCollection_AsciiString& SMESH_Gen_i::AddObject(TCollection_AsciiString& theStr,
-                                                CORBA::Object_ptr        theObject)
-{
-  SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
-  SALOMEDS::SObject_var aSO =
-    aSMESHGen->ObjectToSObject(aSMESHGen->GetCurrentStudy(), theObject);
-  if ( !aSO->_is_nil() )
-    theStr += aSO->GetID();
-  else if ( !CORBA::is_nil( theObject ) )
-    theStr += GetORB()->object_to_string( theObject );
-  else
-    theStr += "None";
-
-  return theStr;
-}
-
-//=======================================================================
-//function : SavePython
-//purpose  : 
-//=======================================================================
-void SMESH_Gen_i::SavePython (SALOMEDS::Study_ptr theStudy)
-{
-  // Dump trace of API methods calls
-  TCollection_AsciiString aScript = GetNewPythonLines(theStudy->StudyId());
-
-  // Check contents of PythonObject attribute
-  SALOMEDS::SObject_var aSO = theStudy->FindComponent(ComponentDataType());
-  //SALOMEDS::SObject_var aSO = SMESH_Gen_i::ObjectToSObject(theStudy, _this());
-  SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
-  SALOMEDS::GenericAttribute_var anAttr =
-    aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePythonObject");
-
-  char* oldValue = SALOMEDS::AttributePythonObject::_narrow(anAttr)->GetObject();
-  TCollection_AsciiString oldScript (oldValue);
-
-  if (oldScript.Length() > 0) {
-    oldScript += "\n";
-    oldScript += aScript;
-  } else {
-    oldScript = aScript;
-  }
-
-  // Store in PythonObject attribute
-  SALOMEDS::AttributePythonObject::_narrow(anAttr)->SetObject(oldScript.ToCString(), 1);
-
-  // Clean trace of API methods calls
-  CleanPythonTrace(theStudy->StudyId());
-}
-
-
-// impl
-
-
-//=============================================================================
-/*!
- *  FindEntries: Returns a sequence of start/end positions of entries in the string
- */
-//=============================================================================
-Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theString)
-{
-  Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
-  Standard_Integer aLen = theString.Length();
-  Standard_Boolean isFound = Standard_False;
-
-  char* arr = theString.ToCString();
-  Standard_Integer i = 0, j;
-
-  while(i < aLen) {
-    int c = (int)arr[i];
-    j = i+1;
-    if(c >= 48 && c <= 57) { //Is digit?
-      isFound = Standard_False;
-      while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry
-       c = (int)arr[j++];  
-       if(c == 58) isFound = Standard_True;
-      }
-
-      if (isFound) {
-        int prev = (i < 1) ? 0 : (int)arr[i - 1];
-        // last char should be a diggit,
-        // previous char should not be '"'.
-        if (arr[j-2] != 58 && prev != 34) {
-          aSeq->Append(i+1); // +1 because AsciiString starts from 1
-          aSeq->Append(j-1);
-        }
-      }
-    }
-
-    i = j;
-  }
-
-  return aSeq;
-}
-
-//=============================================================================
-/*!
- *  DumpPython
- */
-//=============================================================================
-TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
-                        (int theStudyID, 
-                         Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
-                         bool isPublished, 
-                         bool& aValidScript,
-                         const TCollection_AsciiString& theSavedTrace)
-{
-  TCollection_AsciiString aScript;
-  aScript += "import salome\n";
-  aScript += "import geompy\n\n";
-  aScript += "import SMESH\n";
-  aScript += "import StdMeshers\n\n";
-  aScript += "#import GEOM module\n";
-  aScript += "import string\n";
-  aScript += "import os\n";
-  aScript += "import sys\n";
-  aScript += "sys.path.append( os.path.dirname(__file__) )\n";
-  aScript += "exec(\"from \"+string.replace(__name__,\"SMESH\",\"GEOM\")+\" import *\")\n\n";
-  
-  aScript += "def RebuildData(theStudy):";
-  aScript += "\n\tsmesh = salome.lcc.FindOrLoadComponent(\"FactoryServer\", \"SMESH\")";
-  if ( isPublished )
-    aScript += "\n\tsmesh.SetCurrentStudy(theStudy)";
-  else
-    aScript += "\n\tsmesh.SetCurrentStudy(None)";
-
-  Standard_Integer posToInertGlobalVars = aScript.Length();
-  TCollection_AsciiString globalVars;
-
-  // Dump trace of restored study
-  if (theSavedTrace.Length() > 0) {
-    aScript += "\n";
-    aScript += theSavedTrace;
-  }
-
-  // Dump trace of API methods calls
-  TCollection_AsciiString aNewLines = GetNewPythonLines(theStudyID);
-  if (aNewLines.Length() > 0) {
-    aScript += "\n";
-    aScript += aNewLines;
-  }
-
-  // Find entries to be replaced by names
-  Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
-  Standard_Integer aLen = aSeq->Length();
-
-  if (aLen == 0)
-    return aScript;
-
-  // Replace entries by the names
-  GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
-  TColStd_SequenceOfAsciiString seqRemoved;
-  Resource_DataMapOfAsciiStringAsciiString mapRemoved;
-  Resource_DataMapOfAsciiStringAsciiString aNames;
-  Standard_Integer objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
-  TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("smeshObj_");
-
-  for (Standard_Integer i = 1; i <= aLen; i += 2) {
-    anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i) - 1);
-    anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
-    if (theObjectNames.IsBound(anEntry)) {
-      aName = theObjectNames.Find(anEntry);
-      if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
-        // diff objects have same name - make a new name
-        TCollection_AsciiString aName2;
-        Standard_Integer i = 0;
-        do {
-          aName2 = aName + "_" + ++i;
-        } while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
-        aName = aName2;
-        theObjectNames(anEntry) = aName;
-      }
-    } else {
-      // is a GEOM object?
-      aName = geom->GetDumpName( anEntry.ToCString() );
-      if ( aName.IsEmpty() ) {
-      // ? Removed Object ?
-        do {
-          aName = aBaseName + TCollection_AsciiString(++objectCounter);
-        } while (theObjectNames.IsBound(aName));
-        seqRemoved.Append(aName);
-        mapRemoved.Bind(anEntry, "1");
-      }
-      theObjectNames.Bind(anEntry, aName);
-    }
-    theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
-
-    anUpdatedScript += aName;
-    aNames.Bind(aName, "1");
-    aStart = aSeq->Value(i + 1) + 1;
-  }
-
-  // add final part of aScript
-  if (aSeq->Value(aLen) < aScriptLength)
-    anUpdatedScript += aScript.SubString(aSeq->Value(aLen) + 1, aScriptLength);
-
-  // Remove removed objects
-  anUpdatedScript += "\n\taStudyBuilder = theStudy.NewBuilder()";
-  for (int ir = 1; ir <= seqRemoved.Length(); ir++) {
-    anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR(";
-    anUpdatedScript += seqRemoved.Value(ir);
-    anUpdatedScript += "))\n\tif SO is not None: aStudyBuilder.RemoveObjectWithChildren(SO)";
-  }
-  anUpdatedScript += "\n";
-
-  // Set object names
-  anUpdatedScript += "\n\tisGUIMode = ";
-  anUpdatedScript += isPublished;
-  anUpdatedScript += "\n\tif isGUIMode:";
-  anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")";
-  anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())";
-  anUpdatedScript += "\n";
-
-  Resource_DataMapOfAsciiStringAsciiString mapEntries;
-  for (Standard_Integer i = 1; i <= aLen; i += 2) {
-    anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
-    if (theObjectNames.IsBound(anEntry) &&
-        !mapEntries.IsBound(anEntry) &&
-        !mapRemoved.IsBound(anEntry)) {
-      aName = theObjectNames.Find(anEntry);
-      mapEntries.Bind(anEntry, aName);
-      anUpdatedScript += "\n\t\tsmeshgui.SetName(salome.ObjectToID(";
-      anUpdatedScript += aName + "), \"" + aName + "\")";
-    }
-  }
-  anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)";
-
-  anUpdatedScript += "\n\n\tpass\n";
-
-  aValidScript = true;
-
-  return anUpdatedScript;
-}
-
-//=============================================================================
-/*!
- *  GetNewPythonLines
- */
-//=============================================================================
-TCollection_AsciiString SMESH_Gen_i::GetNewPythonLines (int theStudyID)
-{
-  TCollection_AsciiString aScript;
-
-  // Dump trace of API methods calls
-  if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
-    Handle(TColStd_HSequenceOfAsciiString) aPythonScript = myPythonScripts[theStudyID];
-    Standard_Integer istr, aLen = aPythonScript->Length();
-    for (istr = 1; istr <= aLen; istr++) {
-      aScript += "\n\t";
-      aScript += aPythonScript->Value(istr);
-    }
-    aScript += "\n";
-  }
-
-  return aScript;
-}
-
-//=============================================================================
-/*!
- *  CleanPythonTrace
- */
-//=============================================================================
-void SMESH_Gen_i::CleanPythonTrace (int theStudyID)
-{
-  TCollection_AsciiString aScript;
-
-  // Clean trace of API methods calls
-  if (myPythonScripts.find(theStudyID) != myPythonScripts.end()) {
-    myPythonScripts[theStudyID]->Clear();
-  }
-}
index a262d795bd134f7506720cffe223dc5cb967bbf4..beb1578cc4fdb051ce1b427abfe7618671a0b818 100644 (file)
 #include "SMESHDS_Group.hxx"
 #include "SMESHDS_GroupOnGeom.hxx"
 #include "SMDSAbs_ElementType.hxx"
+
+#include "SMESH_Filter_i.hxx"
+#include "SMESH_PythonDump.hxx"
+
 #include "utilities.h"
 
+using namespace SMESH;
+
 //=============================================================================
 /*!
  *  
@@ -270,6 +276,86 @@ CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs )
  */
 //=============================================================================
 
+CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
+{
+  // Update Python script
+  TCollection_AsciiString aStr ("nbDel = ");
+  SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove(";
+  SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
+
+  SMESH_Gen_i::AddToCurrentPyScript(aStr);
+
+  // Remove elements from the group
+  SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
+  if (aGroupDS) {
+    int nbDel = 0;
+    for (int i = 0; i < theIDs.length(); i++) {
+      int anID = (int) theIDs[i];
+      if (aGroupDS->Remove(anID))
+        nbDel++;
+    }
+    return nbDel;
+  }
+  MESSAGE("attempt to remove elements from a vague group");
+  return 0;
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+typedef bool (SMESHDS_Group::*TFunChangeGroup)(const int);
+
+CORBA::Long 
+ChangeByPredicate( SMESH::Predicate_i* thePredicate,
+                  SMESHDS_GroupBase* theGroupBase,
+                  TFunChangeGroup theFun)
+{
+  CORBA::Long aNb = 0;
+  if(SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>(theGroupBase)){
+    SMESH::Controls::Filter::TIdSequence aSequence;
+    const SMDS_Mesh* aMesh = theGroupBase->GetMesh();
+    SMESH::Filter_i::GetElementsId(thePredicate,aMesh,aSequence);
+    
+    CORBA::Long i = 0, iEnd = aSequence.size();
+    for(; i < iEnd; i++)
+      if((aGroupDS->*theFun)(aSequence[i]))
+       aNb++;
+    return aNb;
+  }
+  return aNb;
+}
+
+CORBA::Long 
+SMESH_Group_i::
+AddByPredicate( SMESH::Predicate_ptr thePredicate )
+{
+  if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
+    TPythonDump()<<_this()<<".AddByPredicate("<<aPredicate<<")";
+    return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Add);
+  }
+  return 0;
+}
+
+CORBA::Long 
+SMESH_Group_i::
+RemoveByPredicate( SMESH::Predicate_ptr thePredicate )
+{
+  if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
+    TPythonDump()<<_this()<<".RemoveByPredicate("<<aPredicate<<")";
+    return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Remove);
+  }
+  return 0;
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
 CORBA::Long SMESH_GroupBase_i::GetID( CORBA::Long theIndex )
 {
   SMESHDS_GroupBase* aGroupDS = GetGroupDS();
@@ -300,36 +386,6 @@ SMESH::long_array* SMESH_GroupBase_i::GetListOfID()
   return aRes._retn();
 }
 
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
-{
-  // Update Python script
-  TCollection_AsciiString aStr ("nbDel = ");
-  SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove(";
-  SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
-
-  SMESH_Gen_i::AddToCurrentPyScript(aStr);
-
-  // Remove elements from the group
-  SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
-  if (aGroupDS) {
-    int nbDel = 0;
-    for (int i = 0; i < theIDs.length(); i++) {
-      int anID = (int) theIDs[i];
-      if (aGroupDS->Remove(anID))
-        nbDel++;
-    }
-    return nbDel;
-  }
-  MESSAGE("attempt to remove elements from a vague group");
-  return 0;
-}
-
 //=============================================================================
 /*!
  *  
index 48fb1c036f5627e1b6e51e8a7484636157c65656..724b9ccf74657d034a5437684f39b42f13f2830c 100644 (file)
@@ -93,6 +93,9 @@ class SMESH_Group_i:
   void Clear();
   CORBA::Long Add( const SMESH::long_array& theIDs );
   CORBA::Long Remove( const SMESH::long_array& theIDs );
+
+  CORBA::Long AddByPredicate( SMESH::Predicate_ptr thePredicate );
+  CORBA::Long RemoveByPredicate( SMESH::Predicate_ptr thePredicate );
 };
 
 // =========================
diff --git a/src/SMESH_I/SMESH_PythonDump.hxx b/src/SMESH_I/SMESH_PythonDump.hxx
new file mode 100644 (file)
index 0000000..7e1080e
--- /dev/null
@@ -0,0 +1,80 @@
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+
+#ifndef _SMESH_PYTHONDUMP_HXX_
+#define _SMESH_PYTHONDUMP_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+#include <TCollection_AsciiString.hxx>
+
+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 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;
+  public:
+    virtual ~TPythonDump();
+    
+    template<class T>
+    TCollection_AsciiString& 
+    operator<<(T theArg){
+      return myString<<theArg;
+    }
+  };
+}
+
+
+#endif