Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESH_I / SMESH_Filter_i.cxx
index 2feeadf0a18cc2dca507601d9f9e70cad2c4dbfa..189e6cbcc193c6e6c80b811b3957c6cea0870f68 100644 (file)
@@ -1,6 +1,6 @@
-//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  Copyright (C) 2003-2007  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
 //  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
-//
-//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
 //  File   : SMESH_Filter_i.cxx
 //  Author : Alexey Petrov, OCC
 //  Module : SMESH
-
-
+//
 #include "SMESH_Filter_i.hxx"
 
 #include "SMESH_Gen_i.hxx"
 
 #include "SMESHDS_Mesh.hxx"
 
+#include <BRep_Tool.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Plane.hxx>
+#include <LDOMParser.hxx>
+#include <LDOMString.hxx>
 #include <LDOM_Document.hxx>
 #include <LDOM_Element.hxx>
 #include <LDOM_Node.hxx>
-#include <LDOMString.hxx>
-#include <LDOMParser.hxx>
 #include <LDOM_XmlWriter.hxx>
-#include <TCollection_HAsciiString.hxx>
+#include <Precision.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfReal.hxx>
 #include <TColStd_ListOfInteger.hxx>
 #include <TColStd_ListOfReal.hxx>
-#include <TColStd_MapOfInteger.hxx>
 #include <TColStd_SequenceOfHAsciiString.hxx>
-#include <TColStd_ListIteratorOfListOfReal.hxx>
-#include <Precision.hxx>
-#include <BRep_Tool.hxx>
-#include <TopoDS_Shape.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Face.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <TopExp_Explorer.hxx>
-#include <OSD_Path.hxx>
-#include <OSD_File.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
 using namespace SMESH;
 using namespace SMESH::Controls;
@@ -77,23 +74,73 @@ namespace SMESH
 
 /*
   Class       : BelongToGeom
-  Description : Predicate for verifying whether entiy belong to
+  Description : Predicate for verifying whether entity belongs to
                 specified geometrical support
 */
 
 Controls::BelongToGeom::BelongToGeom()
-: myMeshDS(NULL),
-  myType(SMDSAbs_All)
+  : myMeshDS(NULL),
+    myType(SMDSAbs_All),
+    myIsSubshape(false),
+    myTolerance(Precision::Confusion())
 {}
 
 void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh )
 {
   myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
+  init();
 }
 
 void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
 {
   myShape = theShape;
+  init();
+}
+
+static bool IsSubShape (const TopTools_IndexedMapOfShape& theMap,
+                        const TopoDS_Shape& theShape)
+{
+  if (theMap.Contains(theShape)) return true;
+
+  if (theShape.ShapeType() == TopAbs_COMPOUND ||
+      theShape.ShapeType() == TopAbs_COMPSOLID)
+  {
+    TopoDS_Iterator anIt (theShape, Standard_True, Standard_True);
+    for (; anIt.More(); anIt.Next())
+    {
+      if (!IsSubShape(theMap, anIt.Value())) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  return false;
+}
+
+void Controls::BelongToGeom::init()
+{
+  if (!myMeshDS || myShape.IsNull()) return;
+
+  // is subshape of main shape?
+  TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
+  if (aMainShape.IsNull()) {
+    myIsSubshape = false;
+  }
+  else {
+    TopTools_IndexedMapOfShape aMap;
+    TopExp::MapShapes(aMainShape, aMap);
+    myIsSubshape = IsSubShape(aMap, myShape);
+  }
+
+  if (!myIsSubshape)
+  {
+    myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
+    myElementsOnShapePtr->SetTolerance(myTolerance);
+    myElementsOnShapePtr->SetAllNodes(true); // belong, while false means "lays on"
+    myElementsOnShapePtr->SetMesh(myMeshDS);
+    myElementsOnShapePtr->SetShape(myShape, myType);
+  }
 }
 
 static bool IsContains( const SMESHDS_Mesh*     theMeshDS,
@@ -116,12 +163,18 @@ static bool IsContains( const SMESHDS_Mesh*     theMeshDS,
   return false;
 }
 
-bool Controls::BelongToGeom::IsSatisfy( long theId )
+bool Controls::BelongToGeom::IsSatisfy (long theId)
 {
-  if ( myMeshDS == 0 || myShape.IsNull() )
+  if (myMeshDS == 0 || myShape.IsNull())
     return false;
 
-  if( myType == SMDSAbs_Node )
+  if (!myIsSubshape)
+  {
+    return myElementsOnShapePtr->IsSatisfy(theId);
+  }
+
+  // Case of submesh
+  if (myType == SMDSAbs_Node)
   {
     if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
     {
@@ -163,9 +216,10 @@ bool Controls::BelongToGeom::IsSatisfy( long theId )
   return false;
 }
 
-void Controls::BelongToGeom::SetType( SMDSAbs_ElementType theType )
+void Controls::BelongToGeom::SetType (SMDSAbs_ElementType theType)
 {
   myType = theType;
+  init();
 }
 
 SMDSAbs_ElementType Controls::BelongToGeom::GetType() const
@@ -178,13 +232,23 @@ TopoDS_Shape Controls::BelongToGeom::GetShape()
   return myShape;
 }
 
-const SMESHDS_Mesh*
-Controls::BelongToGeom::
-GetMeshDS() const
+const SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() const
 {
   return myMeshDS;
 }
 
+void Controls::BelongToGeom::SetTolerance (double theTolerance)
+{
+  myTolerance = theTolerance;
+  if (!myIsSubshape)
+    init();
+}
+
+double Controls::BelongToGeom::GetTolerance()
+{
+  return myTolerance;
+}
+
 /*
   Class       : LyingOnGeom
   Description : Predicate for verifying whether entiy lying or partially lying on
@@ -192,18 +256,47 @@ GetMeshDS() const
 */
 
 Controls::LyingOnGeom::LyingOnGeom()
-: myMeshDS(NULL),
-  myType(SMDSAbs_All)
+  : myMeshDS(NULL),
+    myType(SMDSAbs_All),
+    myIsSubshape(false),
+    myTolerance(Precision::Confusion())
 {}
 
 void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
 {
   myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
+  init();
 }
 
 void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
 {
   myShape = theShape;
+  init();
+}
+
+void Controls::LyingOnGeom::init()
+{
+  if (!myMeshDS || myShape.IsNull()) return;
+
+  // is subshape of main shape?
+  TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
+  if (aMainShape.IsNull()) {
+    myIsSubshape = false;
+  }
+  else {
+    TopTools_IndexedMapOfShape aMap;
+    TopExp::MapShapes(aMainShape, aMap);
+    myIsSubshape = IsSubShape(aMap, myShape);
+  }
+
+  if (!myIsSubshape)
+  {
+    myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
+    myElementsOnShapePtr->SetTolerance(myTolerance);
+    myElementsOnShapePtr->SetAllNodes(false); // lays on, while true means "belong"
+    myElementsOnShapePtr->SetMesh(myMeshDS);
+    myElementsOnShapePtr->SetShape(myShape, myType);
+  }
 }
 
 bool Controls::LyingOnGeom::IsSatisfy( long theId )
@@ -211,6 +304,12 @@ bool Controls::LyingOnGeom::IsSatisfy( long theId )
   if ( myMeshDS == 0 || myShape.IsNull() )
     return false;
 
+  if (!myIsSubshape)
+  {
+    return myElementsOnShapePtr->IsSatisfy(theId);
+  }
+
+  // Case of submesh
   if( myType == SMDSAbs_Node )
   {
     if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
@@ -256,6 +355,7 @@ bool Controls::LyingOnGeom::IsSatisfy( long theId )
 void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType )
 {
   myType = theType;
+  init();
 }
 
 SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const
@@ -268,13 +368,23 @@ TopoDS_Shape Controls::LyingOnGeom::GetShape()
   return myShape;
 }
 
-const SMESHDS_Mesh*
-Controls::LyingOnGeom::
-GetMeshDS() const
+const SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS() const
 {
   return myMeshDS;
 }
 
+void Controls::LyingOnGeom::SetTolerance (double theTolerance)
+{
+  myTolerance = theTolerance;
+  if (!myIsSubshape)
+    init();
+}
+
+double Controls::LyingOnGeom::GetTolerance()
+{
+  return myTolerance;
+}
+
 bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh*     theMeshDS,
                                       const TopoDS_Shape&     theShape,
                                       const SMDS_MeshElement* theElem,
@@ -363,6 +473,7 @@ static SMESH::Filter::Criterion createCriterion()
   aCriterion.UnaryOp       = FT_Undefined;
   aCriterion.BinaryOp      = FT_Undefined;
   aCriterion.ThresholdStr  = "";
+  aCriterion.ThresholdID   = "";
   aCriterion.Tolerance     = Precision::Confusion();
   aCriterion.TypeOfElement = SMESH::ALL;
   aCriterion.Precision     = -1;
@@ -385,7 +496,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_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
           TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
           return aLocShape;
         }
@@ -395,7 +506,51 @@ static TopoDS_Shape getShapeByName( const char* theName )
   return TopoDS_Shape();
 }
 
+static TopoDS_Shape getShapeByID (const char* theID)
+{
+  if (theID != 0 && theID != "") {
+    SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+    SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+    if (aStudy != 0) {
+      SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
+      SALOMEDS::GenericAttribute_var anAttr;
+      if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
+        SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+        CORBA::String_var aVal = anIOR->Value();
+        CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal);
+        GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
+      
+        if (!aGeomObj->_is_nil()) {
+          GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
+          TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
+          return aLocShape;
+        }
+      }
+    }
+  }
+  return TopoDS_Shape();
+}
+
+static char* getShapeNameByID (const char* theID)
+{
+  char* aName = "";
+
+  if (theID != 0 && theID != "") {
+    SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+    SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
+    if (aStudy != 0) {
+      //SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( theID );
+      SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
+      SALOMEDS::GenericAttribute_var anAttr;
+      if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeName")) {
+        SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr);
+        aName = aNameAttr->Value();
+      }
+    }
+  }
 
+  return aName;
+}
 
 /*
                                 FUNCTORS
@@ -408,13 +563,14 @@ static TopoDS_Shape getShapeByName( const char* theName )
 Functor_i::Functor_i():
   SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
 {
-  PortableServer::ObjectId_var anObjectId =
-    SMESH_Gen_i::GetPOA()->activate_object( this );
+  //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method  
+  //PortableServer::ObjectId_var anObjectId =
+  //  SMESH_Gen_i::GetPOA()->activate_object( this );
 }
 
 Functor_i::~Functor_i()
 {
-  TPythonDump()<<this<<".Destroy()";
+  //TPythonDump()<<this<<".Destroy()";
 }
 
 void Functor_i::SetMesh( SMESH_Mesh_ptr theMesh )
@@ -734,11 +890,13 @@ BelongToGeom_i::BelongToGeom_i()
   myBelongToGeomPtr.reset( new Controls::BelongToGeom() );
   myFunctorPtr = myPredicatePtr = myBelongToGeomPtr;
   myShapeName = 0;
+  myShapeID   = 0;
 }
 
 BelongToGeom_i::~BelongToGeom_i()
 {
   delete myShapeName;
+  delete myShapeID;
 }
 
 void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
@@ -746,7 +904,7 @@ void BelongToGeom_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();
+  GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
   TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
   myBelongToGeomPtr->SetGeom( aLocShape );
   TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
@@ -775,11 +933,43 @@ void BelongToGeom_i::SetShapeName( const char* theName )
   TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
 }
 
+void BelongToGeom_i::SetShape( const char* theID, const char* theName )
+{
+  delete myShapeName;
+  myShapeName = strdup( theName );
+  delete myShapeID;
+  if ( theID )
+    myShapeID = strdup( theID );
+  else
+    myShapeID = 0;
+
+  if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
+    myBelongToGeomPtr->SetGeom( getShapeByID(myShapeID) );
+  else
+    myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+}
+
 char* BelongToGeom_i::GetShapeName()
 {
   return CORBA::string_dup( myShapeName );
 }
 
+char* BelongToGeom_i::GetShapeID()
+{
+  return CORBA::string_dup( myShapeID );
+}
+
+void BelongToGeom_i::SetTolerance( CORBA::Double theToler )
+{
+  myBelongToGeomPtr->SetTolerance( theToler );
+  TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
+}
+
+CORBA::Double BelongToGeom_i::GetTolerance()
+{
+  return myBelongToGeomPtr->GetTolerance();
+}
+
 /*
   Class       : BelongToSurface_i
   Description : Predicate for selection on geometrical support
@@ -789,12 +979,14 @@ BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceTyp
   myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() );
   myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr;
   myShapeName = 0;
+  myShapeID   = 0;
   mySurfaceType = theSurfaceType;
 }
 
 BelongToSurface_i::~BelongToSurface_i()
 {
   delete myShapeName;
+  delete myShapeID;
 }
 
 void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
@@ -802,7 +994,7 @@ void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType t
   if ( theGeom->_is_nil() )
     return;
   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
-  GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
+  GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
   TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
 
   if ( aLocShape.ShapeType() == TopAbs_FACE )
@@ -816,7 +1008,6 @@ 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 )
@@ -827,11 +1018,32 @@ void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
   TPythonDump()<<this<<".SetShapeName('"<<theName<<"',"<<theType<<")";
 }
 
+void BelongToSurface_i::SetShape( const char* theID,  const char* theName, ElementType theType )
+{
+  delete myShapeName;
+  myShapeName = strdup( theName );
+  delete myShapeID;
+  if ( theID )
+    myShapeID = strdup( theID );
+  else
+    myShapeID = 0;
+  
+  if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
+    myElementsOnSurfacePtr->SetSurface( getShapeByID(myShapeID), (SMDSAbs_ElementType)theType );
+  else
+    myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
+}
+
 char* BelongToSurface_i::GetShapeName()
 {
   return CORBA::string_dup( myShapeName );
 }
 
+char* BelongToSurface_i::GetShapeID()
+{
+  return CORBA::string_dup( myShapeID );
+}
+
 void BelongToSurface_i::SetTolerance( CORBA::Double theToler )
 {
   myElementsOnSurfacePtr->SetTolerance( theToler );
@@ -843,6 +1055,18 @@ CORBA::Double BelongToSurface_i::GetTolerance()
   return myElementsOnSurfacePtr->GetTolerance();
 }
 
+void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions )
+{
+  myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions );
+  TPythonDump()<<this<<".SetUseBoundaries( " << theUseBndRestrictions << " )";
+}
+
+CORBA::Boolean BelongToSurface_i::GetUseBoundaries()
+{
+  return myElementsOnSurfacePtr->GetUseBoundaries();
+}
+
+
 /*
   Class       : BelongToPlane_i
   Description : Verify whether mesh element lie in pointed Geom planar object
@@ -885,6 +1109,33 @@ FunctorType BelongToCylinder_i::GetFunctorType()
   return FT_BelongToCylinder;
 }
 
+/*
+  Class       : BelongToGenSurface_i
+  Description : Verify whether mesh element lie in pointed Geom planar object
+*/
+
+BelongToGenSurface_i::BelongToGenSurface_i()
+: BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) )
+{
+}
+
+void BelongToGenSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
+{
+  if ( theGeom->_is_nil() )
+    return;
+  TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom );
+  if ( !aLocShape.IsNull() && aLocShape.ShapeType() != TopAbs_FACE )
+    aLocShape.Nullify();
+  
+  BelongToSurface_i::myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
+  TPythonDump()<<this<<".SetGenSurface("<<theGeom<<","<<theType<<")";
+}
+
+FunctorType BelongToGenSurface_i::GetFunctorType()
+{
+  return FT_BelongToGenSurface;
+}
+
 /*
   Class       : LyingOnGeom_i
   Description : Predicate for selection on geometrical support
@@ -894,11 +1145,13 @@ LyingOnGeom_i::LyingOnGeom_i()
   myLyingOnGeomPtr.reset( new Controls::LyingOnGeom() );
   myFunctorPtr = myPredicatePtr = myLyingOnGeomPtr;
   myShapeName = 0;
+  myShapeID = 0;
 }
 
 LyingOnGeom_i::~LyingOnGeom_i()
 {
   delete myShapeName;
+  delete myShapeID;
 }
 
 void LyingOnGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
@@ -906,7 +1159,7 @@ 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();
+  GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
   TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
   myLyingOnGeomPtr->SetGeom( aLocShape );
   TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
@@ -935,11 +1188,43 @@ void LyingOnGeom_i::SetShapeName( const char* theName )
   TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
 }
 
+void LyingOnGeom_i::SetShape( const char* theID, const char* theName )
+{
+  delete myShapeName;
+  myShapeName = strdup( theName );
+  delete myShapeID;
+  if ( theID )
+    myShapeID = strdup( theID );
+  else
+    myShapeID = 0;
+  
+  if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
+    myLyingOnGeomPtr->SetGeom( getShapeByID(myShapeID) );
+  else
+    myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+}
+
 char* LyingOnGeom_i::GetShapeName()
 {
   return CORBA::string_dup( myShapeName );
 }
 
+char* LyingOnGeom_i::GetShapeID()
+{
+  return CORBA::string_dup( myShapeID );
+}
+
+void LyingOnGeom_i::SetTolerance( CORBA::Double theToler )
+{
+  myLyingOnGeomPtr->SetTolerance( theToler );
+  TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
+}
+
+CORBA::Double LyingOnGeom_i::GetTolerance()
+{
+  return myLyingOnGeomPtr->GetTolerance();
+}
+
 /*
   Class       : FreeBorders_i
   Description : Predicate for free borders
@@ -973,7 +1258,8 @@ SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders()
 
   long i = 0, iEnd = aBorders.size();
 
-  SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders(iEnd);
+  SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders;
+  aResult->length(iEnd);
 
   SMESH::Controls::FreeEdges::TBorders::const_iterator anIter;
   for ( anIter = aBorders.begin() ; anIter != aBorders.end(); anIter++, i++ )
@@ -995,6 +1281,36 @@ FunctorType FreeEdges_i::GetFunctorType()
   return SMESH::FT_FreeEdges;
 }
 
+/*
+  Class       : FreeFaces_i
+  Description : Predicate for free faces
+*/
+FreeFaces_i::FreeFaces_i()
+{
+  myPredicatePtr.reset(new Controls::FreeFaces());
+  myFunctorPtr = myPredicatePtr;
+}
+
+FunctorType FreeFaces_i::GetFunctorType()
+{
+  return SMESH::FT_FreeFaces;
+}
+
+/*
+  Class       : FreeNodes_i
+  Description : Predicate for free nodes
+*/
+FreeNodes_i::FreeNodes_i()
+{
+  myPredicatePtr.reset(new Controls::FreeNodes());
+  myFunctorPtr = myPredicatePtr;
+}
+
+FunctorType FreeNodes_i::GetFunctorType()
+{
+  return SMESH::FT_FreeNodes;
+}
+
 /*
   Class       : RangeOfIds_i
   Description : Predicate for Range of Ids.
@@ -1043,6 +1359,94 @@ FunctorType RangeOfIds_i::GetFunctorType()
   return SMESH::FT_RangeOfIds;
 }
 
+/*
+  Class       : LinearOrQuadratic_i
+  Description : Predicate to verify whether a mesh element is linear
+*/
+LinearOrQuadratic_i::LinearOrQuadratic_i()
+{
+  myLinearOrQuadraticPtr.reset(new Controls::LinearOrQuadratic());
+  myFunctorPtr = myPredicatePtr = myLinearOrQuadraticPtr;
+}
+
+void LinearOrQuadratic_i::SetElementType(ElementType theType)
+{
+  myLinearOrQuadraticPtr->SetType(SMDSAbs_ElementType(theType));
+  TPythonDump()<<this<<".SetElementType("<<theType<<")";
+}
+
+FunctorType LinearOrQuadratic_i::GetFunctorType()
+{
+  return SMESH::FT_LinearOrQuadratic;
+}
+
+/*
+  Class       : GroupColor_i
+  Description : Functor for check color of group to whic mesh element belongs to
+*/
+GroupColor_i::GroupColor_i()
+{
+  myGroupColorPtr.reset(new Controls::GroupColor());
+  myFunctorPtr = myPredicatePtr = myGroupColorPtr;
+}
+
+FunctorType GroupColor_i::GetFunctorType()
+{
+  return SMESH::FT_GroupColor;
+}
+
+void GroupColor_i::SetColorStr( const char* theColor )
+{
+  myGroupColorPtr->SetColorStr(
+    TCollection_AsciiString( (Standard_CString)theColor ) );
+  TPythonDump()<<this<<".SetColorStr('"<<theColor<<"')";
+}
+
+char* GroupColor_i::GetColorStr()
+{
+  TCollection_AsciiString aStr;
+  myGroupColorPtr->GetColorStr( aStr );
+  return CORBA::string_dup( aStr.ToCString() );
+}
+
+void GroupColor_i::SetElementType(ElementType theType)
+{
+  myGroupColorPtr->SetType(SMDSAbs_ElementType(theType));
+  TPythonDump()<<this<<".SetElementType("<<theType<<")";
+}
+
+/*
+  Class       : ElemGeomType_i
+  Description : Predicate check is element has indicated geometry type
+*/
+ElemGeomType_i::ElemGeomType_i()
+{
+  myElemGeomTypePtr.reset(new Controls::ElemGeomType());
+  myFunctorPtr = myPredicatePtr = myElemGeomTypePtr;
+}
+
+void ElemGeomType_i::SetElementType(ElementType theType)
+{
+  myElemGeomTypePtr->SetType(SMDSAbs_ElementType(theType));
+  TPythonDump()<<this<<".SetElementType("<<theType<<")";
+}
+
+void ElemGeomType_i::SetGeometryType(GeometryType theType)
+{
+  myElemGeomTypePtr->SetGeomType(SMDSAbs_GeometryType(theType));
+  TPythonDump()<<this<<".SetGeometryType("<<theType<<")";
+}
+
+GeometryType ElemGeomType_i::GetGeometryType() const
+{
+  return (GeometryType)myElemGeomTypePtr->GetGeomType();;
+}
+
+FunctorType ElemGeomType_i::GetFunctorType()
+{
+  return SMESH::FT_ElemGeomType;
+}
+
 /*
   Class       : Comparator_i
   Description : Base class for comparators
@@ -1303,14 +1707,15 @@ FunctorType LogicalOR_i::GetFunctorType()
 FilterManager_i::FilterManager_i()
 : SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
 {
-  PortableServer::ObjectId_var anObjectId =
-    SMESH_Gen_i::GetPOA()->activate_object( this );
+  //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method
+  //PortableServer::ObjectId_var anObjectId =
+  //  SMESH_Gen_i::GetPOA()->activate_object( this );
 }
 
 
 FilterManager_i::~FilterManager_i()
 {
-  TPythonDump()<<this<<".Destroy()";
+  //TPythonDump()<<this<<".Destroy()";
 }
 
 
@@ -1442,6 +1847,14 @@ BelongToCylinder_ptr FilterManager_i::CreateBelongToCylinder()
   return anObj._retn();
 }
 
+BelongToGenSurface_ptr FilterManager_i::CreateBelongToGenSurface()
+{
+  SMESH::BelongToGenSurface_i* aServant = new SMESH::BelongToGenSurface_i();
+  SMESH::BelongToGenSurface_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGenSurface()";
+  return anObj._retn();
+}
+
 LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
 {
   SMESH::LyingOnGeom_i* aServant = new SMESH::LyingOnGeom_i();
@@ -1466,6 +1879,22 @@ FreeEdges_ptr FilterManager_i::CreateFreeEdges()
   return anObj._retn();
 }
 
+FreeFaces_ptr FilterManager_i::CreateFreeFaces()
+{
+  SMESH::FreeFaces_i* aServant = new SMESH::FreeFaces_i();
+  SMESH::FreeFaces_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateFreeFaces()";
+  return anObj._retn();
+}
+
+FreeNodes_ptr FilterManager_i::CreateFreeNodes()
+{
+  SMESH::FreeNodes_i* aServant = new SMESH::FreeNodes_i();
+  SMESH::FreeNodes_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateFreeNodes()";
+  return anObj._retn();
+}
+
 RangeOfIds_ptr FilterManager_i::CreateRangeOfIds()
 {
   SMESH::RangeOfIds_i* aServant = new SMESH::RangeOfIds_i();
@@ -1490,7 +1919,6 @@ LessThan_ptr FilterManager_i::CreateLessThan()
   return anObj._retn();
 }
 
-
 MoreThan_ptr FilterManager_i::CreateMoreThan()
 {
   SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
@@ -1507,7 +1935,6 @@ EqualTo_ptr FilterManager_i::CreateEqualTo()
   return anObj._retn();
 }
 
-
 LogicalNOT_ptr FilterManager_i::CreateLogicalNOT()
 {
   SMESH::LogicalNOT_i* aServant = new SMESH::LogicalNOT_i();
@@ -1516,7 +1943,6 @@ LogicalNOT_ptr FilterManager_i::CreateLogicalNOT()
   return anObj._retn();
 }
 
-
 LogicalAND_ptr FilterManager_i::CreateLogicalAND()
 {
   SMESH::LogicalAND_i* aServant = new SMESH::LogicalAND_i();
@@ -1525,7 +1951,6 @@ LogicalAND_ptr FilterManager_i::CreateLogicalAND()
   return anObj._retn();
 }
 
-
 LogicalOR_ptr FilterManager_i::CreateLogicalOR()
 {
   SMESH::LogicalOR_i* aServant = new SMESH::LogicalOR_i();
@@ -1534,6 +1959,30 @@ LogicalOR_ptr FilterManager_i::CreateLogicalOR()
   return anObj._retn();
 }
 
+LinearOrQuadratic_ptr FilterManager_i::CreateLinearOrQuadratic()
+{
+  SMESH::LinearOrQuadratic_i* aServant = new SMESH::LinearOrQuadratic_i();
+  SMESH::LinearOrQuadratic_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateLinearOrQuadratic()";
+  return anObj._retn();
+}
+
+GroupColor_ptr FilterManager_i::CreateGroupColor()
+{
+  SMESH::GroupColor_i* aServant = new SMESH::GroupColor_i();
+  SMESH::GroupColor_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateGroupColor()";
+  return anObj._retn();
+}
+
+ElemGeomType_ptr FilterManager_i::CreateElemGeomType()
+{
+  SMESH::ElemGeomType_i* aServant = new SMESH::ElemGeomType_i();
+  SMESH::ElemGeomType_var anObj = aServant->_this();
+  TPythonDump()<<aServant<<" = "<<this<<".CreateElemGeomType()";
+  return anObj._retn();
+}
+
 Filter_ptr FilterManager_i::CreateFilter()
 {
   SMESH::Filter_i* aServant = new SMESH::Filter_i();
@@ -1604,7 +2053,7 @@ Filter_i::~Filter_i()
   if(!CORBA::is_nil(myMesh))
     myMesh->Destroy();
 
-  TPythonDump()<<this<<".Destroy()";
+  //TPythonDump()<<this<<".Destroy()";
 }
 
 //=======================================================================
@@ -1670,7 +2119,8 @@ GetElementsId( Predicate_i* thePredicate,
                const SMDS_Mesh* theMesh,
                Controls::Filter::TIdSequence& theSequence )
 {
-  Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
+  if (thePredicate)
+    Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
 }
 
 void
@@ -1679,8 +2129,9 @@ 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);
+  if (thePredicate) 
+    if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
+      Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence);
 }
 
 SMESH::long_array*
@@ -1688,7 +2139,7 @@ Filter_i::
 GetElementsId( SMESH_Mesh_ptr theMesh )
 {
   SMESH::long_array_var anArray = new SMESH::long_array;
-  if(!CORBA::is_nil(theMesh)){
+  if(!CORBA::is_nil(theMesh) && myPredicate){
     Controls::Filter::TIdSequence aSequence;
     GetElementsId(myPredicate,theMesh,aSequence);
     long i = 0, iEnd = aSequence.size();
@@ -1712,6 +2163,9 @@ static inline bool getCriteria( Predicate_i*                thePred,
   {
   case FT_FreeBorders:
   case FT_FreeEdges:
+  case FT_FreeFaces:
+  case FT_LinearOrQuadratic:
+  case FT_FreeNodes:
     {
       CORBA::ULong i = theCriteria->length();
       theCriteria->length( i + 1 );
@@ -1733,12 +2187,14 @@ static inline bool getCriteria( Predicate_i*                thePred,
 
       theCriteria[ i ].Type          = FT_BelongToGeom;
       theCriteria[ i ].ThresholdStr  = aPred->GetShapeName();
+      theCriteria[ i ].ThresholdID   = aPred->GetShapeID();
       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
 
       return true;
     }
   case FT_BelongToPlane:
   case FT_BelongToCylinder:
+  case FT_BelongToGenSurface:
     {
       BelongToSurface_i* aPred = dynamic_cast<BelongToSurface_i*>( thePred );
 
@@ -1749,6 +2205,7 @@ static inline bool getCriteria( Predicate_i*                thePred,
 
       theCriteria[ i ].Type          = aFType;
       theCriteria[ i ].ThresholdStr  = aPred->GetShapeName();
+      theCriteria[ i ].ThresholdID   = aPred->GetShapeID();
       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
       theCriteria[ i ].Tolerance     = aPred->GetTolerance();
 
@@ -1765,6 +2222,7 @@ static inline bool getCriteria( Predicate_i*                thePred,
 
       theCriteria[ i ].Type          = FT_LyingOnGeom;
       theCriteria[ i ].ThresholdStr  = aPred->GetShapeName();
+      theCriteria[ i ].ThresholdID   = aPred->GetShapeID();
       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
 
       return true;
@@ -1840,6 +2298,33 @@ static inline bool getCriteria( Predicate_i*                thePred,
       theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType;
       return getCriteria( aPred2, theCriteria );
     }
+  case FT_GroupColor:
+    {
+      CORBA::ULong i = theCriteria->length();
+      theCriteria->length( i + 1 );
+
+      theCriteria[ i ] = createCriterion();
+
+      GroupColor_i* aPred = dynamic_cast<GroupColor_i*>( thePred );
+      theCriteria[ i ].Type          = aFType;
+      theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+      theCriteria[ i ].ThresholdStr  = aPred->GetColorStr();
+
+      return true;
+    }
+  case FT_ElemGeomType:
+    {
+      CORBA::ULong i = theCriteria->length();
+      theCriteria->length( i + 1 );
+
+      theCriteria[ i ] = createCriterion();
+
+      ElemGeomType_i* aPred = dynamic_cast<ElemGeomType_i*>( thePred );
+      theCriteria[ i ].Type          = aFType;
+      theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+      theCriteria[ i ].Threshold     = (double)aPred->GetGeometryType();
+      return true;
+    }
 
   case FT_Undefined:
     return false;
@@ -1881,16 +2366,26 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
     int         aCriterion    = theCriteria[ i ].Type;
     int         aCompare      = theCriteria[ i ].Compare;
     double      aThreshold    = theCriteria[ i ].Threshold;
+    const char* aThresholdStr = theCriteria[ i ].ThresholdStr;
+    const char* aThresholdID  = theCriteria[ i ].ThresholdID;
     int         aUnary        = theCriteria[ i ].UnaryOp;
     int         aBinary       = theCriteria[ i ].BinaryOp;
     double      aTolerance    = theCriteria[ i ].Tolerance;
-    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<<"))";
+    {
+      TPythonDump pd;
+      pd << "aCriterion = SMESH.Filter.Criterion(" << aCriterion << "," << aCompare
+         << "," << aThreshold << ",'" << aThresholdStr;
+      if (aThresholdID)
+       pd << "',salome.ObjectToID(" << aThresholdID
+          << ")," << aUnary << "," << aBinary << "," << aTolerance
+          << "," << aTypeOfElem << "," << aPrecision << ")";
+      else
+       pd << "',''," << aUnary << "," << aBinary << "," << aTolerance
+          << "," << aTypeOfElem << "," << aPrecision << ")";
+    }
 
     SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil();
     SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil();
@@ -1944,23 +2439,34 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
       case SMESH::FT_FreeEdges:
         aPredicate = aFilterMgr->CreateFreeEdges();
         break;
+      case SMESH::FT_FreeFaces:
+        aPredicate = aFilterMgr->CreateFreeFaces();
+        break;
+      case SMESH::FT_FreeNodes:
+        aPredicate = aFilterMgr->CreateFreeNodes();
+        break;
       case SMESH::FT_BelongToGeom:
         {
           SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom();
           tmpPred->SetElementType( aTypeOfElem );
-          tmpPred->SetShapeName( aThresholdStr );
+          tmpPred->SetShape( aThresholdID, aThresholdStr );
           aPredicate = tmpPred;
         }
         break;
       case SMESH::FT_BelongToPlane:
       case SMESH::FT_BelongToCylinder:
+      case SMESH::FT_BelongToGenSurface:
         {
           SMESH::BelongToSurface_ptr tmpPred;
-          if ( aCriterion == SMESH::FT_BelongToPlane )
-            tmpPred = aFilterMgr->CreateBelongToPlane();
-          else
-            tmpPred = aFilterMgr->CreateBelongToCylinder();
-          tmpPred->SetShapeName( aThresholdStr, aTypeOfElem );
+          switch ( aCriterion ) {
+          case SMESH::FT_BelongToPlane:
+            tmpPred = aFilterMgr->CreateBelongToPlane(); break;
+          case SMESH::FT_BelongToCylinder:
+            tmpPred = aFilterMgr->CreateBelongToCylinder(); break;
+          default:
+            tmpPred = aFilterMgr->CreateBelongToGenSurface();
+          }
+          tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem );
           tmpPred->SetTolerance( aTolerance );
           aPredicate = tmpPred;
         }
@@ -1969,7 +2475,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
         {
           SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
           tmpPred->SetElementType( aTypeOfElem );
-          tmpPred->SetShapeName( aThresholdStr );
+         tmpPred->SetShape( aThresholdID, aThresholdStr );
           aPredicate = tmpPred;
         }
         break;
@@ -1986,6 +2492,29 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
           aPredicate = aFilterMgr->CreateBadOrientedVolume();
         }
         break;
+      case SMESH::FT_LinearOrQuadratic:
+        {
+          SMESH::LinearOrQuadratic_ptr tmpPred = aFilterMgr->CreateLinearOrQuadratic();
+          tmpPred->SetElementType( aTypeOfElem );
+          aPredicate = tmpPred;
+          break;
+        }
+      case SMESH::FT_GroupColor:
+        {
+          SMESH::GroupColor_ptr tmpPred = aFilterMgr->CreateGroupColor();
+          tmpPred->SetElementType( aTypeOfElem );
+          tmpPred->SetColorStr( aThresholdStr );
+          aPredicate = tmpPred;
+          break;
+        }
+      case SMESH::FT_ElemGeomType:
+        {
+          SMESH::ElemGeomType_ptr tmpPred = aFilterMgr->CreateElemGeomType();
+          tmpPred->SetElementType( aTypeOfElem );
+          tmpPred->SetGeometryType( (GeometryType)(aThreshold + 0.5) );
+          aPredicate = tmpPred;
+          break;
+        }
 
       default:
         continue;
@@ -2030,6 +2559,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
     // logical op
     aPredicates.push_back( aPredicate );
     aBinaries.push_back( aBinary );
+    TPythonDump()<<"aCriteria.append(aCriterion)";
 
   } // end of for
   TPythonDump()<<this<<".SetCriteria(aCriteria)";
@@ -2138,7 +2668,7 @@ Predicate_ptr Filter_i::GetPredicate()
 // name    : toString
 // Purpose : Convert bool to LDOMString
 //=======================================================================
-static inline LDOMString toString( const bool val )
+static inline LDOMString toString( CORBA::Boolean val )
 {
   return val ? "logical not" : "";
 }
@@ -2156,7 +2686,7 @@ static inline bool toBool( const LDOMString& theStr )
 // name    : toString
 // Purpose : Convert double to LDOMString
 //=======================================================================
-static inline LDOMString toString( const double val )
+static inline LDOMString toString( CORBA::Double val )
 {
   char a[ 255 ];
   sprintf( a, "%e", val );
@@ -2176,7 +2706,7 @@ static inline double toDouble( const LDOMString& theStr )
 // name    : toString
 // Purpose : Convert functor type to LDOMString
 //=======================================================================
-static inline LDOMString toString( const long theType )
+static inline LDOMString toString( CORBA::Long theType )
 {
   switch ( theType )
   {
@@ -2190,21 +2720,27 @@ static inline LDOMString toString( const long theType )
     case FT_BelongToGeom    : return "Belong to Geom";
     case FT_BelongToPlane   : return "Belong to Plane";
     case FT_BelongToCylinder: return "Belong to Cylinder";
+    case FT_BelongToGenSurface: return "Belong to Generic Surface";
     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_FreeFaces       : return "Free faces";
+    case FT_FreeNodes       : return "Free nodes";
     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_Length2D        : return "Length 2D";
     case FT_LessThan        : return "Less than";
     case FT_MoreThan        : return "More than";
     case FT_EqualTo         : return "Equal to";
     case FT_LogicalNOT      : return "Not";
     case FT_LogicalAND      : return "And";
     case FT_LogicalOR       : return "Or";
+    case FT_GroupColor      : return "Color of Group";
+    case FT_LinearOrQuadratic : return "Linear or Quadratic";
+    case FT_ElemGeomType    : return "Element geomtry type";
     case FT_Undefined       : return "";
     default                 : return "";
   }
@@ -2226,9 +2762,12 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr )
   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( "Belong to Generic Surface"    ) ) return FT_BelongToGenSurface;
   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( "Free faces"                   ) ) return FT_FreeFaces;
+  else if ( theStr.equals( "Free nodes"                   ) ) return FT_FreeNodes;
   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;
@@ -2241,6 +2780,9 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr )
   else if ( theStr.equals( "Not"                          ) ) return FT_LogicalNOT;
   else if ( theStr.equals( "And"                          ) ) return FT_LogicalAND;
   else if ( theStr.equals( "Or"                           ) ) return FT_LogicalOR;
+  else if ( theStr.equals( "Color of Group"               ) ) return FT_GroupColor;
+  else if ( theStr.equals( "Linear or Quadratic"          ) ) return FT_LinearOrQuadratic;
+  else if ( theStr.equals( "Element geomtry type"         ) ) return FT_ElemGeomType;
   else if ( theStr.equals( ""                             ) ) return FT_Undefined;
   else  return FT_Undefined;
 }
@@ -2392,12 +2934,12 @@ static LDOM_Element createFilterItem( const char*       theName,
   for ( CORBA::ULong i = 0, n = aCriteria->length(); i < n; i++ )
   {
     LDOM_Element aCriterionItem = theDoc.createElement( "criterion" );
-
-    aCriterionItem.setAttribute( ATTR_TYPE         , toString( aCriteria[ i ].Type      ) );
-    aCriterionItem.setAttribute( ATTR_COMPARE      , toString( aCriteria[ i ].Compare   ) );
-    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_TYPE         , toString(  aCriteria[ i ].Type) );
+    aCriterionItem.setAttribute( ATTR_COMPARE      , toString(  aCriteria[ i ].Compare ) );
+    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 ) );
@@ -2458,7 +3000,7 @@ FilterLibrary_i::FilterLibrary_i()
 FilterLibrary_i::~FilterLibrary_i()
 {
   delete myFileName;
-  TPythonDump()<<this<<".Destroy()";
+  //TPythonDump()<<this<<".Destroy()";
 }
 
 //=======================================================================