Salome HOME
IMP 10199 (add Volume Control). Add Volume3D NumericalFunctor.
[modules/smesh.git] / src / SMESH_I / SMESH_Filter_i.cxx
index 05205350042ef21ba124e8ca65a5ad0c3af6d653..2feeadf0a18cc2dca507601d9f9e70cad2c4dbfa 100644 (file)
@@ -1,22 +1,22 @@
 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
 //
 //  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 
+//  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, 
+//  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 
+//  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 
-// 
+//
+//  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
 //
 //
@@ -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 )
+  {
+    return DownCast<Predicate_i*>(thePredicate);
+  }
+}
+
+
 /*
   Class       : BelongToGeom
   Description : Predicate for verifying whether entiy belong to
@@ -74,9 +86,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 +96,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,
@@ -147,7 +159,7 @@ bool Controls::BelongToGeom::IsSatisfy( long theId )
       }
     }
   }
-    
+
   return false;
 }
 
@@ -166,24 +178,156 @@ TopoDS_Shape Controls::BelongToGeom::GetShape()
   return myShape;
 }
 
-SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS()
+const SMESHDS_Mesh*
+Controls::BelongToGeom::
+GetMeshDS() const
 {
   return myMeshDS;
 }
 
+/*
+  Class       : LyingOnGeom
+  Description : Predicate for verifying whether entiy lying or partially lying on
+                specified geometrical support
+*/
+
+Controls::LyingOnGeom::LyingOnGeom()
+: myMeshDS(NULL),
+  myType(SMDSAbs_All)
+{}
+
+void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
+{
+  myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
+}
+
+void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
+{
+  myShape = theShape;
+}
+
+bool Controls::LyingOnGeom::IsSatisfy( long theId )
+{
+  if ( myMeshDS == 0 || myShape.IsNull() )
+    return false;
+
+  if( myType == SMDSAbs_Node )
+  {
+    if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
+    {
+      const SMDS_PositionPtr& aPosition = aNode->GetPosition();
+      SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
+      switch( aTypeOfPosition )
+      {
+      case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
+      case SMDS_TOP_EDGE   : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
+      case SMDS_TOP_FACE   : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
+      case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
+      }
+    }
+  }
+  else
+  {
+    if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
+    {
+      if( myType == SMDSAbs_All )
+      {
+        return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
+               Contains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
+               Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
+               Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
+      }
+      else if( myType == anElem->GetType() )
+      {
+        switch( myType )
+        {
+        case SMDSAbs_Edge  : return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE );
+        case SMDSAbs_Face  : return Contains( myMeshDS,myShape,anElem,TopAbs_FACE );
+        case SMDSAbs_Volume: return Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
+                                    Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
+        }
+      }
+    }
+  }
+
+  return false;
+}
+
+void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType )
+{
+  myType = theType;
+}
+
+SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const
+{
+  return myType;
+}
+
+TopoDS_Shape Controls::LyingOnGeom::GetShape()
+{
+  return myShape;
+}
+
+const SMESHDS_Mesh*
+Controls::LyingOnGeom::
+GetMeshDS() const
+{
+  return myMeshDS;
+}
+
+bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh*     theMeshDS,
+                                      const TopoDS_Shape&     theShape,
+                                      const SMDS_MeshElement* theElem,
+                                      TopAbs_ShapeEnum        theFindShapeEnum,
+                                      TopAbs_ShapeEnum        theAvoidShapeEnum )
+{
+  if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum))
+    return true;
+
+  TopTools_IndexedMapOfShape aSubShapes;
+  TopExp::MapShapes( theShape, aSubShapes );
+
+  for (int i = 1; i <= aSubShapes.Extent(); i++)
+  {
+    const TopoDS_Shape& aShape = aSubShapes.FindKey(i);
+
+    if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
+      if( aSubMesh->Contains( theElem ) )
+        return true;
+
+      SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
+      while ( aNodeIt->more() )
+      {
+        const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
+        SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
+        while ( anElemIt->more() )
+        {
+          const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
+          if (anElement == theElem)
+            return true;
+        }
+      }
+    }
+  }
+  return false;
+}
+
 
 /*
                             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() );
+  SMESH_Mesh_i* anImplPtr = DownCast<SMESH_Mesh_i*>(theMesh);
   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() );
@@ -195,7 +339,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() );
@@ -230,7 +376,7 @@ static TopoDS_Shape getShapeByName( const char* theName )
   {
     SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
     SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
-    if ( aStudy != 0 )
+    if (!CORBA::is_nil(aStudy))
     {
       SALOMEDS::Study::ListOfSObject_var aList =
         aStudy->FindObjectByName( theName, "GEOM" );
@@ -239,7 +385,7 @@ static TopoDS_Shape getShapeByName( const char* theName )
         GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() );
         if ( !aGeomObj->_is_nil() )
         {
-         GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
+          GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
           TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
           return aLocShape;
         }
@@ -257,18 +403,24 @@ static TopoDS_Shape getShapeByName( const char* theName )
 
 /*
   Class       : Functor_i
-  Description : An abstact class for all functors 
+  Description : An abstact class for all functors
 */
-Functor_i::Functor_i(): 
+Functor_i::Functor_i():
   SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
 {
-  SMESH_Gen_i::GetPOA()->activate_object( this );
+  PortableServer::ObjectId_var anObjectId =
+    SMESH_Gen_i::GetPOA()->activate_object( this );
+}
+
+Functor_i::~Functor_i()
+{
+  TPythonDump()<<this<<".Destroy()";
 }
 
 void Functor_i::SetMesh( SMESH_Mesh_ptr theMesh )
 {
   myFunctorPtr->SetMesh( MeshPtr2SMDSMesh( theMesh ) );
-  INFOS("Functor_i::SetMesh~");
+  TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
 }
 
 ElementType Functor_i::GetElementType()
@@ -289,6 +441,7 @@ CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId )
 void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision )
 {
   myNumericalFunctorPtr->SetPrecision( thePrecision );
+  TPythonDump()<<this<<".SetPrecision("<<thePrecision<<")";
 }
 
 CORBA::Long NumericalFunctor_i::GetPrecision()
@@ -334,6 +487,22 @@ FunctorType AspectRatio_i::GetFunctorType()
 }
 
 
+/*
+  Class       : AspectRatio3D
+  Description : Functor for calculating aspect ratio 3D
+*/
+AspectRatio3D_i::AspectRatio3D_i()
+{
+  myNumericalFunctorPtr.reset( new Controls::AspectRatio3D() );
+  myFunctorPtr = myNumericalFunctorPtr;
+}
+
+FunctorType AspectRatio3D_i::GetFunctorType()
+{
+  return SMESH::FT_AspectRatio3D;
+}
+
+
 /*
   Class       : Warping_i
   Description : Functor for calculating warping
@@ -396,6 +565,21 @@ FunctorType Area_i::GetFunctorType()
   return SMESH::FT_Area;
 }
 
+/*
+  Class       : Volume3D_i
+  Description : Functor for calculating volume of 3D element
+*/
+Volume3D_i::Volume3D_i()
+{
+  myNumericalFunctorPtr.reset( new Controls::Volume() );
+  myFunctorPtr = myNumericalFunctorPtr;
+}
+
+FunctorType Volume3D_i::GetFunctorType()
+{
+  return SMESH::FT_Volume3D;
+}
+
 /*
   Class       : Length_i
   Description : Functor for calculating length off edge
@@ -411,6 +595,46 @@ FunctorType Length_i::GetFunctorType()
   return SMESH::FT_Length;
 }
 
+/*
+  Class       : Length2D_i
+  Description : Functor for calculating length of edge
+*/
+Length2D_i::Length2D_i()
+{
+  myNumericalFunctorPtr.reset( new Controls::Length2D() );
+  myFunctorPtr = myNumericalFunctorPtr;
+}
+
+FunctorType Length2D_i::GetFunctorType()
+{
+  return SMESH::FT_Length2D;
+}
+
+SMESH::Length2D::Values* Length2D_i::GetValues()
+{
+  INFOS("Length2D_i::GetValues");
+  SMESH::Controls::Length2D::TValues aValues;
+  myLength2DPtr->GetValues( aValues );
+
+  long i = 0, iEnd = aValues.size();
+
+  SMESH::Length2D::Values_var aResult = new SMESH::Length2D::Values(iEnd);
+
+  SMESH::Controls::Length2D::TValues::const_iterator anIter;
+  for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
+  {
+    const SMESH::Controls::Length2D::Value&  aVal = *anIter;
+    SMESH::Length2D::Value &aValue = aResult[ i ];
+
+    aValue.myLength = aVal.myLength;
+    aValue.myPnt1 = aVal.myPntId[ 0 ];
+    aValue.myPnt2 = aVal.myPntId[ 1 ];
+  }
+
+  INFOS("Length2D_i::GetValuess~");
+  return aResult._retn();
+}
+
 /*
   Class       : MultiConnection_i
   Description : Functor for calculating number of faces conneted to the edge
@@ -426,6 +650,45 @@ FunctorType MultiConnection_i::GetFunctorType()
   return SMESH::FT_MultiConnection;
 }
 
+/*
+  Class       : MultiConnection2D_i
+  Description : Functor for calculating number of faces conneted to the edge
+*/
+MultiConnection2D_i::MultiConnection2D_i()
+{
+  myNumericalFunctorPtr.reset( new Controls::MultiConnection2D() );
+  myFunctorPtr = myNumericalFunctorPtr;
+}
+
+FunctorType MultiConnection2D_i::GetFunctorType()
+{
+  return SMESH::FT_MultiConnection2D;
+}
+
+SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues()
+{
+  INFOS("MultiConnection2D_i::GetValues");
+  SMESH::Controls::MultiConnection2D::MValues aValues;
+  myMulticonnection2DPtr->GetValues( aValues );
+
+  long i = 0, iEnd = aValues.size();
+
+  SMESH::MultiConnection2D::Values_var aResult = new SMESH::MultiConnection2D::Values(iEnd);
+
+  SMESH::Controls::MultiConnection2D::MValues::const_iterator anIter;
+  for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
+  {
+    const SMESH::Controls::MultiConnection2D::Value&  aVal = (*anIter).first;
+    SMESH::MultiConnection2D::Value &aValue = aResult[ i ];
+
+    aValue.myPnt1 = aVal.myPntId[ 0 ];
+    aValue.myPnt2 = aVal.myPntId[ 1 ];
+    aValue.myNbConnects = (*anIter).second;
+  }
+
+  INFOS("Multiconnection2D_i::GetValuess~");
+  return aResult._retn();
+}
 
 /*
                             PREDICATES
@@ -446,6 +709,21 @@ Controls::PredicatePtr Predicate_i::GetPredicate()
   return myPredicatePtr;
 }
 
+/*
+  Class       : BadOrientedVolume_i
+  Description : Verify whether a mesh volume is incorrectly oriented from
+                the point of view of MED convention
+*/
+BadOrientedVolume_i::BadOrientedVolume_i()
+{
+  Controls::PredicatePtr control( new Controls::BadOrientedVolume() );
+  myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType BadOrientedVolume_i::GetFunctorType()
+{
+  return SMESH::FT_BadOrientedVolume;
+}
 
 /*
   Class       : BelongToGeom_i
@@ -471,6 +749,7 @@ void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
   GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
   TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
   myBelongToGeomPtr->SetGeom( aLocShape );
+  TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
 }
 
 void BelongToGeom_i::SetGeom( const TopoDS_Shape& theShape )
@@ -480,6 +759,7 @@ void BelongToGeom_i::SetGeom( const TopoDS_Shape& theShape )
 
 void BelongToGeom_i::SetElementType(ElementType theType){
   myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType));
+  TPythonDump()<<this<<".SetElementType("<<theType<<")";
 }
 
 FunctorType BelongToGeom_i::GetFunctorType()
@@ -492,6 +772,7 @@ void BelongToGeom_i::SetShapeName( const char* theName )
   delete myShapeName;
   myShapeName = strdup( theName );
   myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+  TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
 }
 
 char* BelongToGeom_i::GetShapeName()
@@ -535,6 +816,7 @@ void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType t
   }
 
   myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType );
+  TPythonDump()<<this<<".SetSurface("<<theGeom<<",'"<<theType<<"')";
 }
 
 void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
@@ -542,6 +824,7 @@ void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
   delete myShapeName;
   myShapeName = strdup( theName );
   myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
+  TPythonDump()<<this<<".SetShapeName('"<<theName<<"',"<<theType<<")";
 }
 
 char* BelongToSurface_i::GetShapeName()
@@ -552,6 +835,7 @@ char* BelongToSurface_i::GetShapeName()
 void BelongToSurface_i::SetTolerance( CORBA::Double theToler )
 {
   myElementsOnSurfacePtr->SetTolerance( theToler );
+  TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
 }
 
 CORBA::Double BelongToSurface_i::GetTolerance()
@@ -572,6 +856,7 @@ BelongToPlane_i::BelongToPlane_i()
 void BelongToPlane_i::SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
 {
   BelongToSurface_i::SetSurface( theGeom, theType );
+  TPythonDump()<<this<<".SetPlane("<<theGeom<<","<<theType<<")";
 }
 
 FunctorType BelongToPlane_i::GetFunctorType()
@@ -592,6 +877,7 @@ BelongToCylinder_i::BelongToCylinder_i()
 void BelongToCylinder_i::SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
 {
   BelongToSurface_i::SetSurface( theGeom, theType );
+  TPythonDump()<<this<<".SetCylinder("<<theGeom<<","<<theType<<")";
 }
 
 FunctorType BelongToCylinder_i::GetFunctorType()
@@ -599,7 +885,60 @@ FunctorType BelongToCylinder_i::GetFunctorType()
   return FT_BelongToCylinder;
 }
 
+/*
+  Class       : LyingOnGeom_i
+  Description : Predicate for selection on geometrical support
+*/
+LyingOnGeom_i::LyingOnGeom_i()
+{
+  myLyingOnGeomPtr.reset( new Controls::LyingOnGeom() );
+  myFunctorPtr = myPredicatePtr = myLyingOnGeomPtr;
+  myShapeName = 0;
+}
+
+LyingOnGeom_i::~LyingOnGeom_i()
+{
+  delete myShapeName;
+}
+
+void LyingOnGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
+{
+  if ( theGeom->_is_nil() )
+    return;
+  SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+  GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
+  TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
+  myLyingOnGeomPtr->SetGeom( aLocShape );
+  TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
+}
+
+void LyingOnGeom_i::SetGeom( const TopoDS_Shape& theShape )
+{
+  myLyingOnGeomPtr->SetGeom( theShape );
+}
+
+void LyingOnGeom_i::SetElementType(ElementType theType){
+  myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType));
+  TPythonDump()<<this<<".SetElementType("<<theType<<")";
+}
+
+FunctorType LyingOnGeom_i::GetFunctorType()
+{
+  return SMESH::FT_LyingOnGeom;
+}
+
+void LyingOnGeom_i::SetShapeName( const char* theName )
+{
+  delete myShapeName;
+  myShapeName = strdup( theName );
+  myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+  TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
+}
 
+char* LyingOnGeom_i::GetShapeName()
+{
+  return CORBA::string_dup( myShapeName );
+}
 
 /*
   Class       : FreeBorders_i
@@ -631,7 +970,7 @@ SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders()
   INFOS("FreeEdges_i::GetBorders");
   SMESH::Controls::FreeEdges::TBorders aBorders;
   myFreeEdgesPtr->GetBoreders( aBorders );
-  
+
   long i = 0, iEnd = aBorders.size();
 
   SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders(iEnd);
@@ -641,7 +980,7 @@ SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders()
   {
     const SMESH::Controls::FreeEdges::Border&  aBord = *anIter;
     SMESH::FreeEdges::Border &aBorder = aResult[ i ];
-    
+
     aBorder.myElemId = aBord.myElemId;
     aBorder.myPnt1 = aBord.myPntId[ 0 ];
     aBorder.myPnt2 = aBord.myPntId[ 1 ];
@@ -676,10 +1015,12 @@ void RangeOfIds_i::SetRange( const SMESH::long_array& theIds )
   CORBA::Long iEnd = theIds.length();
   for ( CORBA::Long i = 0; i < iEnd; i++ )
     myRangeOfIdsPtr->AddToRange( theIds[ i ] );
+  TPythonDump()<<this<<".SetRange("<<theIds<<")";
 }
 
 CORBA::Boolean RangeOfIds_i::SetRangeStr( const char* theRange )
 {
+  TPythonDump()<<this<<".SetRangeStr('"<<theRange<<"')";
   return myRangeOfIdsPtr->SetRangeStr(
     TCollection_AsciiString( (Standard_CString)theRange ) );
 }
@@ -694,6 +1035,7 @@ char* RangeOfIds_i::GetRangeStr()
 void RangeOfIds_i::SetElementType( ElementType theType )
 {
   myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) );
+  TPythonDump()<<this<<".SetElementType("<<theType<<")";
 }
 
 FunctorType RangeOfIds_i::GetFunctorType()
@@ -718,6 +1060,7 @@ Comparator_i::~Comparator_i()
 void Comparator_i::SetMargin( CORBA::Double theValue )
 {
   myComparatorPtr->SetMargin( theValue );
+  TPythonDump()<<this<<".SetMargin("<<theValue<<")";
 }
 
 CORBA::Double Comparator_i::GetMargin()
@@ -730,12 +1073,13 @@ void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct )
   if ( myNumericalFunctor )
     myNumericalFunctor->Destroy();
 
-  myNumericalFunctor = dynamic_cast<NumericalFunctor_i*>( SMESH_Gen_i::GetServant( theFunct ).in() );
+  myNumericalFunctor = DownCast<NumericalFunctor_i*>(theFunct);
 
   if ( myNumericalFunctor )
   {
     myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() );
     myNumericalFunctor->Register();
+    TPythonDump()<<this<<".SetNumFunctor("<<myNumericalFunctor<<")";
   }
 }
 
@@ -795,6 +1139,7 @@ EqualTo_i::EqualTo_i()
 void EqualTo_i::SetTolerance( CORBA::Double theToler )
 {
   myEqualToPtr->SetTolerance( theToler );
+  TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
 }
 
 CORBA::Double EqualTo_i::GetTolerance()
@@ -824,16 +1169,17 @@ 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());
     myPredicate->Register();
+    TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
   }
 }
 
@@ -880,11 +1226,12 @@ 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());
     myPredicate1->Register();
+    TPythonDump()<<this<<".SetPredicate1("<<myPredicate1<<")";
   }
 }
 
@@ -893,11 +1240,12 @@ 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());
     myPredicate2->Register();
+    TPythonDump()<<this<<".SetPredicate2("<<myPredicate2<<")";
   }
 }
 
@@ -955,13 +1303,22 @@ FunctorType LogicalOR_i::GetFunctorType()
 FilterManager_i::FilterManager_i()
 : SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
 {
-  SMESH_Gen_i::GetPOA()->activate_object( this );
+  PortableServer::ObjectId_var anObjectId =
+    SMESH_Gen_i::GetPOA()->activate_object( this );
+}
+
+
+FilterManager_i::~FilterManager_i()
+{
+  TPythonDump()<<this<<".Destroy()";
 }
 
+
 MinimumAngle_ptr FilterManager_i::CreateMinimumAngle()
 {
   SMESH::MinimumAngle_i* aServant = new SMESH::MinimumAngle_i();
   SMESH::MinimumAngle_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateMinimumAngle()";
   return anObj._retn();
 }
 
@@ -970,6 +1327,16 @@ AspectRatio_ptr FilterManager_i::CreateAspectRatio()
 {
   SMESH::AspectRatio_i* aServant = new SMESH::AspectRatio_i();
   SMESH::AspectRatio_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio()";
+  return anObj._retn();
+}
+
+
+AspectRatio3D_ptr FilterManager_i::CreateAspectRatio3D()
+{
+  SMESH::AspectRatio3D_i* aServant = new SMESH::AspectRatio3D_i();
+  SMESH::AspectRatio3D_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio3D()";
   return anObj._retn();
 }
 
@@ -978,6 +1345,7 @@ Warping_ptr FilterManager_i::CreateWarping()
 {
   SMESH::Warping_i* aServant = new SMESH::Warping_i();
   SMESH::Warping_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateWarping()";
   return anObj._retn();
 }
 
@@ -986,6 +1354,7 @@ Taper_ptr FilterManager_i::CreateTaper()
 {
   SMESH::Taper_i* aServant = new SMESH::Taper_i();
   SMESH::Taper_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateTaper()";
   return anObj._retn();
 }
 
@@ -994,6 +1363,7 @@ Skew_ptr FilterManager_i::CreateSkew()
 {
   SMESH::Skew_i* aServant = new SMESH::Skew_i();
   SMESH::Skew_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateSkew()";
   return anObj._retn();
 }
 
@@ -1002,6 +1372,16 @@ 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();
+}
+
+
+Volume3D_ptr FilterManager_i::CreateVolume3D()
+{
+  SMESH::Volume3D_i* aServant = new SMESH::Volume3D_i();
+  SMESH::Volume3D_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateVolume3D()";
   return anObj._retn();
 }
 
@@ -1010,22 +1390,39 @@ Length_ptr FilterManager_i::CreateLength()
 {
   SMESH::Length_i* aServant = new SMESH::Length_i();
   SMESH::Length_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLength()";
   return anObj._retn();
 }
 
+Length2D_ptr FilterManager_i::CreateLength2D()
+{
+  SMESH::Length2D_i* aServant = new SMESH::Length2D_i();
+  SMESH::Length2D_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLength2D()";
+  return anObj._retn();
+}
 
 MultiConnection_ptr FilterManager_i::CreateMultiConnection()
 {
   SMESH::MultiConnection_i* aServant = new SMESH::MultiConnection_i();
   SMESH::MultiConnection_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection()";
   return anObj._retn();
 }
 
+MultiConnection2D_ptr FilterManager_i::CreateMultiConnection2D()
+{
+  SMESH::MultiConnection2D_i* aServant = new SMESH::MultiConnection2D_i();
+  SMESH::MultiConnection2D_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection2D()";
+  return anObj._retn();
+}
 
 BelongToGeom_ptr FilterManager_i::CreateBelongToGeom()
 {
   SMESH::BelongToGeom_i* aServant = new SMESH::BelongToGeom_i();
   SMESH::BelongToGeom_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGeom()";
   return anObj._retn();
 }
 
@@ -1033,6 +1430,7 @@ BelongToPlane_ptr FilterManager_i::CreateBelongToPlane()
 {
   SMESH::BelongToPlane_i* aServant = new SMESH::BelongToPlane_i();
   SMESH::BelongToPlane_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToPlane()";
   return anObj._retn();
 }
 
@@ -1040,6 +1438,15 @@ BelongToCylinder_ptr FilterManager_i::CreateBelongToCylinder()
 {
   SMESH::BelongToCylinder_i* aServant = new SMESH::BelongToCylinder_i();
   SMESH::BelongToCylinder_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToCylinder()";
+  return anObj._retn();
+}
+
+LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
+{
+  SMESH::LyingOnGeom_i* aServant = new SMESH::LyingOnGeom_i();
+  SMESH::LyingOnGeom_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLyingOnGeom()";
   return anObj._retn();
 }
 
@@ -1047,6 +1454,7 @@ FreeBorders_ptr FilterManager_i::CreateFreeBorders()
 {
   SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
   SMESH::FreeBorders_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateFreeBorders()";
   return anObj._retn();
 }
 
@@ -1054,6 +1462,7 @@ FreeEdges_ptr FilterManager_i::CreateFreeEdges()
 {
   SMESH::FreeEdges_i* aServant = new SMESH::FreeEdges_i();
   SMESH::FreeEdges_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateFreeEdges()";
   return anObj._retn();
 }
 
@@ -1061,6 +1470,15 @@ RangeOfIds_ptr FilterManager_i::CreateRangeOfIds()
 {
   SMESH::RangeOfIds_i* aServant = new SMESH::RangeOfIds_i();
   SMESH::RangeOfIds_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateRangeOfIds()";
+  return anObj._retn();
+}
+
+BadOrientedVolume_ptr FilterManager_i::CreateBadOrientedVolume()
+{
+  SMESH::BadOrientedVolume_i* aServant = new SMESH::BadOrientedVolume_i();
+  SMESH::BadOrientedVolume_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateBadOrientedVolume()";
   return anObj._retn();
 }
 
@@ -1068,6 +1486,7 @@ LessThan_ptr FilterManager_i::CreateLessThan()
 {
   SMESH::LessThan_i* aServant = new SMESH::LessThan_i();
   SMESH::LessThan_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLessThan()";
   return anObj._retn();
 }
 
@@ -1076,6 +1495,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();
 }
 
@@ -1083,6 +1503,7 @@ EqualTo_ptr FilterManager_i::CreateEqualTo()
 {
   SMESH::EqualTo_i* aServant = new SMESH::EqualTo_i();
   SMESH::EqualTo_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateEqualTo()";
   return anObj._retn();
 }
 
@@ -1091,6 +1512,7 @@ LogicalNOT_ptr FilterManager_i::CreateLogicalNOT()
 {
   SMESH::LogicalNOT_i* aServant = new SMESH::LogicalNOT_i();
   SMESH::LogicalNOT_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalNOT()";
   return anObj._retn();
 }
 
@@ -1099,6 +1521,7 @@ LogicalAND_ptr FilterManager_i::CreateLogicalAND()
 {
   SMESH::LogicalAND_i* aServant = new SMESH::LogicalAND_i();
   SMESH::LogicalAND_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalAND()";
   return anObj._retn();
 }
 
@@ -1107,6 +1530,7 @@ LogicalOR_ptr FilterManager_i::CreateLogicalOR()
 {
   SMESH::LogicalOR_i* aServant = new SMESH::LogicalOR_i();
   SMESH::LogicalOR_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalOR()";
   return anObj._retn();
 }
 
@@ -1114,6 +1538,7 @@ Filter_ptr FilterManager_i::CreateFilter()
 {
   SMESH::Filter_i* aServant = new SMESH::Filter_i();
   SMESH::Filter_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateFilter()";
   return anObj._retn();
 }
 
@@ -1121,6 +1546,7 @@ FilterLibrary_ptr FilterManager_i::LoadLibrary( const char* aFileName )
 {
   SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i( aFileName );
   SMESH::FilterLibrary_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".LoadLibrary("<<aFileName<<")";
   return anObj._retn();
 }
 
@@ -1128,11 +1554,13 @@ FilterLibrary_ptr FilterManager_i::CreateLibrary()
 {
   SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i();
   SMESH::FilterLibrary_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLibrary()";
   return anObj._retn();
 }
 
 CORBA::Boolean FilterManager_i::DeleteLibrary( const char* aFileName )
 {
+  TPythonDump()<<this<<".DeleteLibrary("<<aFileName<<")";
   return remove( aFileName ) ? false : true;
 }
 
@@ -1172,6 +1600,11 @@ Filter_i::~Filter_i()
 {
   if ( myPredicate )
     myPredicate->Destroy();
+
+  if(!CORBA::is_nil(myMesh))
+    myMesh->Destroy();
+
+  TPythonDump()<<this<<".Destroy()";
 }
 
 //=======================================================================
@@ -1183,12 +1616,13 @@ 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 )
   {
     myFilter.SetPredicate( myPredicate->GetPredicate() );
     myPredicate->Register();
+    TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
   }
 }
 
@@ -1205,28 +1639,63 @@ SMESH::ElementType Filter_i::GetElementType()
 // name    : Filter_i::SetMesh
 // Purpose : Set mesh
 //=======================================================================
-void Filter_i::SetMesh( SMESH_Mesh_ptr theMesh )
+void
+Filter_i::
+SetMesh( SMESH_Mesh_ptr theMesh )
 {
-  if ( myPredicate )
-    myPredicate->SetMesh( theMesh );
+  if(!CORBA::is_nil(theMesh))
+    theMesh->Register();
+
+  if(!CORBA::is_nil(myMesh))
+    myMesh->Destroy();
+
+  myMesh = theMesh;
+  TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
+}
+
+SMESH::long_array*
+Filter_i::
+GetIDs()
+{
+  return GetElementsId(myMesh);
 }
 
 //=======================================================================
 // name    : Filter_i::GetElementsId
 // Purpose : Get ids of entities
 //=======================================================================
-SMESH::long_array* Filter_i::GetElementsId( SMESH_Mesh_ptr theMesh )
+void
+Filter_i::
+GetElementsId( Predicate_i* thePredicate,
+               const SMDS_Mesh* theMesh,
+               Controls::Filter::TIdSequence& theSequence )
 {
-  SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh);
-  Controls::Filter::TIdSequence aSequence = myFilter.GetElementsId(aMesh);
-
-  SMESH::long_array_var anArray = new SMESH::long_array;
-  long i = 0, iEnd = aSequence.size();
+  Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
+}
 
-  anArray->length( iEnd );
-  for ( ; i < iEnd; i++ )
-    anArray[ i ] = aSequence[i];
+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 )
+{
+  SMESH::long_array_var anArray = new SMESH::long_array;
+  if(!CORBA::is_nil(theMesh)){
+    Controls::Filter::TIdSequence aSequence;
+    GetElementsId(myPredicate,theMesh,aSequence);
+    long i = 0, iEnd = aSequence.size();
+    anArray->length( iEnd );
+    for ( ; i < iEnd; i++ )
+      anArray[ i ] = aSequence[i];
+  }
   return anArray._retn();
 }
 
@@ -1283,6 +1752,21 @@ static inline bool getCriteria( Predicate_i*                thePred,
       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
       theCriteria[ i ].Tolerance     = aPred->GetTolerance();
 
+      return true;
+    }
+   case FT_LyingOnGeom:
+    {
+      LyingOnGeom_i* aPred = dynamic_cast<LyingOnGeom_i*>( thePred );
+
+      CORBA::ULong i = theCriteria->length();
+      theCriteria->length( i + 1 );
+
+      theCriteria[ i ] = createCriterion();
+
+      theCriteria[ i ].Type          = FT_LyingOnGeom;
+      theCriteria[ i ].ThresholdStr  = aPred->GetShapeName();
+      theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+
       return true;
     }
   case FT_RangeOfIds:
@@ -1298,6 +1782,20 @@ static inline bool getCriteria( Predicate_i*                thePred,
       theCriteria[ i ].ThresholdStr  = aPred->GetRangeStr();
       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
 
+      return true;
+    }
+  case FT_BadOrientedVolume:
+    {
+      BadOrientedVolume_i* aPred = dynamic_cast<BadOrientedVolume_i*>( thePred );
+
+      CORBA::ULong i = theCriteria->length();
+      theCriteria->length( i + 1 );
+
+      theCriteria[ i ] = createCriterion();
+
+      theCriteria[ i ].Type          = FT_BadOrientedVolume;
+      theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+
       return true;
     }
   case FT_LessThan:
@@ -1369,12 +1867,13 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
   if ( myPredicate != 0 )
     myPredicate->Destroy();
 
-    SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
-    FilterManager_ptr aFilterMgr = aFilter->_this();
+  SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
+  FilterManager_ptr aFilterMgr = aFilter->_this();
 
   // CREATE two lists ( PREDICATES  and LOG OP )
 
   // Criterion
+  TPythonDump()<<"aCriteria = []";
   std::list<SMESH::Predicate_ptr> aPredicates;
   std::list<int>                  aBinaries;
   for ( int i = 0, n = theCriteria.length(); i < n; i++ )
@@ -1388,23 +1887,36 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
     const char* aThresholdStr = theCriteria[ i ].ThresholdStr;
     ElementType aTypeOfElem   = theCriteria[ i ].TypeOfElement;
     long        aPrecision    = theCriteria[ i ].Precision;
-    
+
+    TPythonDump()<<"aCriteria.append(SMESH.Filter.Criterion("<<
+      aCriterion<<","<<aCompare<<","<<aThreshold<<",'"<<aThresholdStr<<"',"<<
+      aUnary<<","<<aBinary<<","<<aTolerance<<","<<aTypeOfElem<<","<<aPrecision<<"))";
+
     SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil();
     SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil();
 
     switch ( aCriterion )
     {
       // Functors
-      
+
       case SMESH::FT_MultiConnection:
         aFunctor = aFilterMgr->CreateMultiConnection();
         break;
+      case SMESH::FT_MultiConnection2D:
+        aFunctor = aFilterMgr->CreateMultiConnection2D();
+        break;
       case SMESH::FT_Length:
         aFunctor = aFilterMgr->CreateLength();
         break;
+      case SMESH::FT_Length2D:
+        aFunctor = aFilterMgr->CreateLength2D();
+        break;
       case SMESH::FT_AspectRatio:
         aFunctor = aFilterMgr->CreateAspectRatio();
         break;
+      case SMESH::FT_AspectRatio3D:
+        aFunctor = aFilterMgr->CreateAspectRatio3D();
+        break;
       case SMESH::FT_Warping:
         aFunctor = aFilterMgr->CreateWarping();
         break;
@@ -1420,6 +1932,9 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
       case SMESH::FT_Area:
         aFunctor = aFilterMgr->CreateArea();
         break;
+      case SMESH::FT_Volume3D:
+        aFunctor = aFilterMgr->CreateVolume3D();
+        break;
 
       // Predicates
 
@@ -1450,6 +1965,14 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
           aPredicate = tmpPred;
         }
         break;
+      case SMESH::FT_LyingOnGeom:
+        {
+          SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
+          tmpPred->SetElementType( aTypeOfElem );
+          tmpPred->SetShapeName( aThresholdStr );
+          aPredicate = tmpPred;
+        }
+        break;
       case SMESH::FT_RangeOfIds:
         {
           SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds();
@@ -1458,7 +1981,12 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
           aPredicate = tmpPred;
         }
         break;
-              
+      case SMESH::FT_BadOrientedVolume:
+        {
+          aPredicate = aFilterMgr->CreateBadOrientedVolume();
+        }
+        break;
+
       default:
         continue;
     }
@@ -1504,6 +2032,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
     aBinaries.push_back( aBinary );
 
   } // end of for
+  TPythonDump()<<this<<".SetCriteria(aCriteria)";
 
   // CREATE ONE PREDICATE FROM PREVIOUSLY CREATED MAP
 
@@ -1657,14 +2186,19 @@ static inline LDOMString toString( const long theType )
     case FT_Taper           : return "Taper";
     case FT_Skew            : return "Skew";
     case FT_Area            : return "Area";
+    case FT_Volume3D        : return "Volume3D";
     case FT_BelongToGeom    : return "Belong to Geom";
     case FT_BelongToPlane   : return "Belong to Plane";
     case FT_BelongToCylinder: return "Belong to Cylinder";
+    case FT_LyingOnGeom     : return "Lying on Geom";
+    case FT_BadOrientedVolume: return "Bad Oriented Volume";
     case FT_RangeOfIds      : return "Range of IDs";
     case FT_FreeBorders     : return "Free borders";
     case FT_FreeEdges       : return "Free edges";
     case FT_MultiConnection : return "Borders at multi-connections";
+    case FT_MultiConnection2D: return "Borders at multi-connections 2D";
     case FT_Length          : return "Length";
+    case FT_Length2D        : return "Length2D";
     case FT_LessThan        : return "Less than";
     case FT_MoreThan        : return "More than";
     case FT_EqualTo         : return "Equal to";
@@ -1688,14 +2222,19 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr )
   else if ( theStr.equals( "Taper"                        ) ) return FT_Taper;
   else if ( theStr.equals( "Skew"                         ) ) return FT_Skew;
   else if ( theStr.equals( "Area"                         ) ) return FT_Area;
+  else if ( theStr.equals( "Volume3D"                     ) ) return FT_Volume3D;
   else if ( theStr.equals( "Belong to Geom"               ) ) return FT_BelongToGeom;
   else if ( theStr.equals( "Belong to Plane"              ) ) return FT_BelongToPlane;
   else if ( theStr.equals( "Belong to Cylinder"           ) ) return FT_BelongToCylinder;
+  else if ( theStr.equals( "Lying on Geom"                ) ) return FT_LyingOnGeom;
   else if ( theStr.equals( "Free borders"                 ) ) return FT_FreeBorders;
   else if ( theStr.equals( "Free edges"                   ) ) return FT_FreeEdges;
   else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection;
+  //  else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D;
   else if ( theStr.equals( "Length"                       ) ) return FT_Length;
+  //  else if ( theStr.equals( "Length2D"                     ) ) return FT_Length2D;
   else if ( theStr.equals( "Range of IDs"                 ) ) return FT_RangeOfIds;
+  else if ( theStr.equals( "Bad Oriented Volume"          ) ) return FT_BadOrientedVolume;
   else if ( theStr.equals( "Less than"                    ) ) return FT_LessThan;
   else if ( theStr.equals( "More than"                    ) ) return FT_MoreThan;
   else if ( theStr.equals( "Equal to"                     ) ) return FT_EqualTo;
@@ -1801,7 +2340,7 @@ static LDOM_Node getSection( const ElementType theType,
   const char* aSectionName = getSectionName( theType );
   if ( strcmp( aSectionName, "" ) == 0 )
     return LDOM_Node();
-  
+
   LDOM_NodeList aSections = theDoc.getElementsByTagName( "section" );
   LDOM_Node aNode;
   for ( int i = 0, n = aSections.getLength(); i < n; i++ )
@@ -1859,7 +2398,7 @@ static LDOM_Element createFilterItem( const char*       theName,
     aCriterionItem.setAttribute( ATTR_THRESHOLD    , toString( aCriteria[ i ].Threshold ) );
     aCriterionItem.setAttribute( ATTR_UNARY        , toString( aCriteria[ i ].UnaryOp   ) );
     aCriterionItem.setAttribute( ATTR_BINARY       , toString( aCriteria[ i ].BinaryOp  ) );
-    
+
     aCriterionItem.setAttribute( ATTR_THRESHOLD_STR, (const char*)aCriteria[ i ].ThresholdStr );
     aCriterionItem.setAttribute( ATTR_TOLERANCE    , toString( aCriteria[ i ].Tolerance ) );
     aCriterionItem.setAttribute( ATTR_ELEMENT_TYPE ,
@@ -1919,6 +2458,7 @@ FilterLibrary_i::FilterLibrary_i()
 FilterLibrary_i::~FilterLibrary_i()
 {
   delete myFileName;
+  TPythonDump()<<this<<".Destroy()";
 }
 
 //=======================================================================
@@ -1927,14 +2467,14 @@ FilterLibrary_i::~FilterLibrary_i()
 //=======================================================================
 Filter_ptr FilterLibrary_i::Copy( const char* theFilterName )
 {
-  Filter_ptr aRes;
+  Filter_ptr aRes = Filter::_nil();
   LDOM_Node aFilter = findFilter( theFilterName, myDoc );
 
   if ( aFilter.isNull() )
     return aRes;
 
   std::list<SMESH::Filter::Criterion> aCriteria;
-    
+
   for ( LDOM_Node aCritNode = aFilter.getFirstChild();
         !aCritNode.isNull() ; aCritNode = aCritNode.getNextSibling() )
   {
@@ -1945,14 +2485,14 @@ Filter_ptr FilterLibrary_i::Copy( const char* theFilterName )
     const char* aUnaryStr     = aCrit->getAttribute( ATTR_UNARY         ).GetString();
     const char* aBinaryStr    = aCrit->getAttribute( ATTR_BINARY        ).GetString();
     const char* anElemTypeStr = aCrit->getAttribute( ATTR_ELEMENT_TYPE  ).GetString();
-    
+
     SMESH::Filter::Criterion aCriterion = createCriterion();
 
     aCriterion.Type          = toFunctorType( aTypeStr );
     aCriterion.Compare       = toFunctorType( aCompareStr );
     aCriterion.UnaryOp       = toFunctorType( aUnaryStr );
     aCriterion.BinaryOp      = toFunctorType( aBinaryStr );
-    
+
     aCriterion.TypeOfElement = toElementType( anElemTypeStr );
 
     LDOMString str = aCrit->getAttribute( ATTR_THRESHOLD );
@@ -1979,16 +2519,18 @@ Filter_ptr FilterLibrary_i::Copy( const char* theFilterName )
 
   SMESH::Filter::Criteria_var aCriteriaVar = new SMESH::Filter::Criteria;
   aCriteriaVar->length( aCriteria.size() );
-  
+
   CORBA::ULong i = 0;
   std::list<SMESH::Filter::Criterion>::iterator anIter = aCriteria.begin();
-  
+
   for( ; anIter != aCriteria.end(); ++anIter )
     aCriteriaVar[ i++ ] = *anIter;
 
   aRes = myFilterMgr->CreateFilter();
   aRes->SetCriteria( aCriteriaVar.inout() );
 
+  TPythonDump()<<this<<".Copy('"<<theFilterName<<"')";
+
   return aRes;
 }
 
@@ -2000,6 +2542,7 @@ void FilterLibrary_i::SetFileName( const char* theFileName )
 {
   delete myFileName;
   myFileName = strdup( theFileName );
+  TPythonDump()<<this<<".SetFileName('"<<theFileName<<"')";
 }
 
 //=======================================================================
@@ -2036,6 +2579,8 @@ CORBA::Boolean FilterLibrary_i::Add( const char* theFilterName, Filter_ptr theFi
   else
   {
     aSection.appendChild( aFilterItem );
+    if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
+      TPythonDump()<<this<<".Add('"<<theFilterName<<"',"<<aFilter<<")";
     return true;
   }
 }
@@ -2057,13 +2602,14 @@ CORBA::Boolean FilterLibrary_i::AddEmpty( const char* theFilterName, ElementType
 
   // create filter item
   Filter_var aFilter = myFilterMgr->CreateFilter();
-  
+
   LDOM_Element aFilterItem = createFilterItem( theFilterName, aFilter, myDoc );
   if ( aFilterItem.isNull() )
     return false;
   else
   {
     aSection.appendChild( aFilterItem );
+    TPythonDump()<<this<<".AddEmpty('"<<theFilterName<<"',"<<theType<<")";
     return true;
   }
 }
@@ -2080,16 +2626,17 @@ CORBA::Boolean FilterLibrary_i::Delete ( const char* theFilterName )
     return false;
 
   aParentNode.removeChild( aFilterNode );
+  TPythonDump()<<this<<".Delete('"<<theFilterName<<"')";
   return true;
 }
 
 //=======================================================================
-// name      : FilterLibrary_i::Replace 
+// name      : FilterLibrary_i::Replace
 // Purpose   : Replace existing filter with entry filter.
 // IMPORTANT : If filter does not exist it is not created
 //=======================================================================
 CORBA::Boolean FilterLibrary_i::Replace( const char* theFilterName,
-                                         const char* theNewName,                 
+                                         const char* theNewName,
                                          Filter_ptr  theFilter )
 {
   LDOM_Element aFilterItem = findFilter( theFilterName, myDoc );
@@ -2099,9 +2646,11 @@ CORBA::Boolean FilterLibrary_i::Replace( const char* theFilterName,
   LDOM_Element aNewItem = createFilterItem( theNewName, theFilter, myDoc );
   if ( aNewItem.isNull() )
     return false;
-  else                                                                                          
+  else
   {
     aFilterItem.ReplaceElement( aNewItem );
+    if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
+      TPythonDump()<<this<<".Replace('"<<theFilterName<<"',"<<theNewName<<"',"<<aFilter<<")";
     return true;
   }
 }
@@ -2114,7 +2663,7 @@ CORBA::Boolean FilterLibrary_i::Save()
 {
   if ( myFileName == 0 || strlen( myFileName ) == 0 )
     return false;
-          
+
   FILE* aOutFile = fopen( myFileName, "wt" );
   if ( !aOutFile )
     return false;
@@ -2124,6 +2673,7 @@ CORBA::Boolean FilterLibrary_i::Save()
   aWriter << myDoc;
   fclose( aOutFile );
 
+  TPythonDump()<<this<<".Save()";
   return true;
 }
 
@@ -2134,6 +2684,7 @@ CORBA::Boolean FilterLibrary_i::Save()
 CORBA::Boolean FilterLibrary_i::SaveAs( const char* aFileName )
 {
   myFileName = strdup ( aFileName );
+  TPythonDump()<<this<<".SaveAs('"<<aFileName<<"')";
   return Save();
 }
 
@@ -2204,23 +2755,3 @@ string_array* FilterLibrary_i::GetAllNames()
 
   return aResArray._retn();
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-