Version: 6.3.1

src/SMESH_I/SMESH_Filter_i.cxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
00024 //  File   : SMESH_Filter_i.cxx
00025 //  Author : Alexey Petrov, OCC
00026 //  Module : SMESH
00027 //
00028 #include "SMESH_Filter_i.hxx"
00029 
00030 #include "SMESH_Gen_i.hxx"
00031 #include "SMESH_PythonDump.hxx"
00032 
00033 #include "SMDS_Mesh.hxx"
00034 #include "SMDS_MeshNode.hxx"
00035 #include "SMDS_MeshElement.hxx"
00036 #include "SMDS_ElemIterator.hxx"
00037 #include "SMDS_VolumeTool.hxx"
00038 
00039 #include "SMESHDS_Mesh.hxx"
00040 
00041 #include <BRep_Tool.hxx>
00042 #include <Geom_CylindricalSurface.hxx>
00043 #include <Geom_Plane.hxx>
00044 #include <LDOMParser.hxx>
00045 #include <LDOMString.hxx>
00046 #include <LDOM_Document.hxx>
00047 #include <LDOM_Element.hxx>
00048 #include <LDOM_Node.hxx>
00049 #include <LDOM_XmlWriter.hxx>
00050 #include <Precision.hxx>
00051 #include <TColStd_ListIteratorOfListOfInteger.hxx>
00052 #include <TColStd_ListIteratorOfListOfReal.hxx>
00053 #include <TColStd_ListOfInteger.hxx>
00054 #include <TColStd_ListOfReal.hxx>
00055 #include <TColStd_SequenceOfHAsciiString.hxx>
00056 #include <TCollection_HAsciiString.hxx>
00057 #include <TopExp.hxx>
00058 #include <TopExp_Explorer.hxx>
00059 #include <TopoDS.hxx>
00060 #include <TopoDS_Face.hxx>
00061 #include <TopoDS_Shape.hxx>
00062 #include <TopTools_IndexedMapOfShape.hxx>
00063 
00064 using namespace SMESH;
00065 using namespace SMESH::Controls;
00066 
00067 
00068 namespace SMESH
00069 {
00070   Predicate_i*
00071   GetPredicate( Predicate_ptr thePredicate )
00072   {
00073     return DownCast<Predicate_i*>(thePredicate);
00074   }
00075 }
00076 
00077 
00078 /*
00079   Class       : BelongToGeom
00080   Description : Predicate for verifying whether entity belongs to
00081                 specified geometrical support
00082 */
00083 
00084 Controls::BelongToGeom::BelongToGeom()
00085   : myMeshDS(NULL),
00086     myType(SMDSAbs_All),
00087     myIsSubshape(false),
00088     myTolerance(Precision::Confusion())
00089 {}
00090 
00091 void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh )
00092 {
00093   myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
00094   init();
00095 }
00096 
00097 void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
00098 {
00099   myShape = theShape;
00100   init();
00101 }
00102 
00103 static bool IsSubShape (const TopTools_IndexedMapOfShape& theMap,
00104                         const TopoDS_Shape& theShape)
00105 {
00106   if (theMap.Contains(theShape)) return true;
00107 
00108   if (theShape.ShapeType() == TopAbs_COMPOUND ||
00109       theShape.ShapeType() == TopAbs_COMPSOLID)
00110   {
00111     TopoDS_Iterator anIt (theShape, Standard_True, Standard_True);
00112     for (; anIt.More(); anIt.Next())
00113     {
00114       if (!IsSubShape(theMap, anIt.Value())) {
00115         return false;
00116       }
00117     }
00118     return true;
00119   }
00120 
00121   return false;
00122 }
00123 
00124 void Controls::BelongToGeom::init()
00125 {
00126   if (!myMeshDS || myShape.IsNull()) return;
00127 
00128   // is subshape of main shape?
00129   TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
00130   if (aMainShape.IsNull()) {
00131     myIsSubshape = false;
00132   }
00133   else {
00134     TopTools_IndexedMapOfShape aMap;
00135     TopExp::MapShapes(aMainShape, aMap);
00136     myIsSubshape = IsSubShape(aMap, myShape);
00137   }
00138 
00139   if (!myIsSubshape)
00140   {
00141     myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
00142     myElementsOnShapePtr->SetTolerance(myTolerance);
00143     myElementsOnShapePtr->SetAllNodes(true); // belong, while false means "lays on"
00144     myElementsOnShapePtr->SetMesh(myMeshDS);
00145     myElementsOnShapePtr->SetShape(myShape, myType);
00146   }
00147 }
00148 
00149 static bool IsContains( const SMESHDS_Mesh*     theMeshDS,
00150                         const TopoDS_Shape&     theShape,
00151                         const SMDS_MeshElement* theElem,
00152                         TopAbs_ShapeEnum        theFindShapeEnum,
00153                         TopAbs_ShapeEnum        theAvoidShapeEnum = TopAbs_SHAPE )
00154 {
00155   TopExp_Explorer anExp( theShape,theFindShapeEnum,theAvoidShapeEnum );
00156 
00157   while( anExp.More() )
00158   {
00159     const TopoDS_Shape& aShape = anExp.Current();
00160     if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
00161       if( aSubMesh->Contains( theElem ) )
00162         return true;
00163     }
00164     anExp.Next();
00165   }
00166   return false;
00167 }
00168 
00169 bool Controls::BelongToGeom::IsSatisfy (long theId)
00170 {
00171   if (myMeshDS == 0 || myShape.IsNull())
00172     return false;
00173 
00174   if (!myIsSubshape)
00175   {
00176     return myElementsOnShapePtr->IsSatisfy(theId);
00177   }
00178 
00179   // Case of submesh
00180   if (myType == SMDSAbs_Node)
00181   {
00182     if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
00183     {
00184       const SMDS_PositionPtr& aPosition = aNode->GetPosition();
00185       SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
00186       switch( aTypeOfPosition )
00187       {
00188       case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
00189       case SMDS_TOP_EDGE   : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
00190       case SMDS_TOP_FACE   : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
00191       case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
00192       }
00193     }
00194   }
00195   else
00196   {
00197     if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
00198     {
00199       if( myType == SMDSAbs_All )
00200       {
00201         return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
00202                IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
00203                IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
00204                IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
00205       }
00206       else if( myType == anElem->GetType() )
00207       {
00208         switch( myType )
00209         {
00210         case SMDSAbs_Edge  : return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE );
00211         case SMDSAbs_Face  : return IsContains( myMeshDS,myShape,anElem,TopAbs_FACE );
00212         case SMDSAbs_Volume: return IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
00213                                     IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
00214         }
00215       }
00216     }
00217   }
00218 
00219   return false;
00220 }
00221 
00222 void Controls::BelongToGeom::SetType (SMDSAbs_ElementType theType)
00223 {
00224   myType = theType;
00225   init();
00226 }
00227 
00228 SMDSAbs_ElementType Controls::BelongToGeom::GetType() const
00229 {
00230   return myType;
00231 }
00232 
00233 TopoDS_Shape Controls::BelongToGeom::GetShape()
00234 {
00235   return myShape;
00236 }
00237 
00238 const SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() const
00239 {
00240   return myMeshDS;
00241 }
00242 
00243 void Controls::BelongToGeom::SetTolerance (double theTolerance)
00244 {
00245   myTolerance = theTolerance;
00246   if (!myIsSubshape)
00247     init();
00248 }
00249 
00250 double Controls::BelongToGeom::GetTolerance()
00251 {
00252   return myTolerance;
00253 }
00254 
00255 /*
00256   Class       : LyingOnGeom
00257   Description : Predicate for verifying whether entiy lying or partially lying on
00258                 specified geometrical support
00259 */
00260 
00261 Controls::LyingOnGeom::LyingOnGeom()
00262   : myMeshDS(NULL),
00263     myType(SMDSAbs_All),
00264     myIsSubshape(false),
00265     myTolerance(Precision::Confusion())
00266 {}
00267 
00268 void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
00269 {
00270   myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
00271   init();
00272 }
00273 
00274 void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
00275 {
00276   myShape = theShape;
00277   init();
00278 }
00279 
00280 void Controls::LyingOnGeom::init()
00281 {
00282   if (!myMeshDS || myShape.IsNull()) return;
00283 
00284   // is subshape of main shape?
00285   TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
00286   if (aMainShape.IsNull()) {
00287     myIsSubshape = false;
00288   }
00289   else {
00290     TopTools_IndexedMapOfShape aMap;
00291     TopExp::MapShapes(aMainShape, aMap);
00292     myIsSubshape = IsSubShape(aMap, myShape);
00293   }
00294 
00295   if (!myIsSubshape)
00296   {
00297     myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
00298     myElementsOnShapePtr->SetTolerance(myTolerance);
00299     myElementsOnShapePtr->SetAllNodes(false); // lays on, while true means "belong"
00300     myElementsOnShapePtr->SetMesh(myMeshDS);
00301     myElementsOnShapePtr->SetShape(myShape, myType);
00302   }
00303 }
00304 
00305 bool Controls::LyingOnGeom::IsSatisfy( long theId )
00306 {
00307   if ( myMeshDS == 0 || myShape.IsNull() )
00308     return false;
00309 
00310   if (!myIsSubshape)
00311   {
00312     return myElementsOnShapePtr->IsSatisfy(theId);
00313   }
00314 
00315   // Case of submesh
00316   if( myType == SMDSAbs_Node )
00317   {
00318     if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
00319     {
00320       const SMDS_PositionPtr& aPosition = aNode->GetPosition();
00321       SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
00322       switch( aTypeOfPosition )
00323       {
00324       case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
00325       case SMDS_TOP_EDGE   : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
00326       case SMDS_TOP_FACE   : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
00327       case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
00328       }
00329     }
00330   }
00331   else
00332   {
00333     if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
00334     {
00335       if( myType == SMDSAbs_All )
00336       {
00337         return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
00338                Contains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
00339                Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
00340                Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
00341       }
00342       else if( myType == anElem->GetType() )
00343       {
00344         switch( myType )
00345         {
00346         case SMDSAbs_Edge  : return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE );
00347         case SMDSAbs_Face  : return Contains( myMeshDS,myShape,anElem,TopAbs_FACE );
00348         case SMDSAbs_Volume: return Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
00349                                     Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
00350         }
00351       }
00352     }
00353   }
00354 
00355   return false;
00356 }
00357 
00358 void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType )
00359 {
00360   myType = theType;
00361   init();
00362 }
00363 
00364 SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const
00365 {
00366   return myType;
00367 }
00368 
00369 TopoDS_Shape Controls::LyingOnGeom::GetShape()
00370 {
00371   return myShape;
00372 }
00373 
00374 const SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS() const
00375 {
00376   return myMeshDS;
00377 }
00378 
00379 void Controls::LyingOnGeom::SetTolerance (double theTolerance)
00380 {
00381   myTolerance = theTolerance;
00382   if (!myIsSubshape)
00383     init();
00384 }
00385 
00386 double Controls::LyingOnGeom::GetTolerance()
00387 {
00388   return myTolerance;
00389 }
00390 
00391 bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh*     theMeshDS,
00392                                       const TopoDS_Shape&     theShape,
00393                                       const SMDS_MeshElement* theElem,
00394                                       TopAbs_ShapeEnum        theFindShapeEnum,
00395                                       TopAbs_ShapeEnum        theAvoidShapeEnum )
00396 {
00397   if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum))
00398     return true;
00399 
00400   TopTools_IndexedMapOfShape aSubShapes;
00401   TopExp::MapShapes( theShape, aSubShapes );
00402 
00403   for (int i = 1; i <= aSubShapes.Extent(); i++)
00404   {
00405     const TopoDS_Shape& aShape = aSubShapes.FindKey(i);
00406 
00407     if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
00408       if( aSubMesh->Contains( theElem ) )
00409         return true;
00410 
00411       SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
00412       while ( aNodeIt->more() )
00413       {
00414         const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
00415         SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
00416         while ( anElemIt->more() )
00417         {
00418           const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
00419           if (anElement == theElem)
00420             return true;
00421         }
00422       }
00423     }
00424   }
00425   return false;
00426 }
00427 
00428 
00429 /*
00430                             AUXILIARY METHODS
00431 */
00432 
00433 inline
00434 const SMDS_Mesh*
00435 MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
00436 {
00437   SMESH_Mesh_i* anImplPtr = DownCast<SMESH_Mesh_i*>(theMesh);
00438   return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
00439 }
00440 
00441 inline
00442 SMESH::long_array*
00443 toArray( const TColStd_ListOfInteger& aList )
00444 {
00445   SMESH::long_array_var anArray = new SMESH::long_array;
00446   anArray->length( aList.Extent() );
00447   TColStd_ListIteratorOfListOfInteger anIter( aList );
00448   int i = 0;
00449   for( ; anIter.More(); anIter.Next() )
00450     anArray[ i++ ] = anIter.Value();
00451 
00452   return anArray._retn();
00453 }
00454 
00455 inline
00456 SMESH::double_array*
00457 toArray( const TColStd_ListOfReal& aList )
00458 {
00459   SMESH::double_array_var anArray = new SMESH::double_array;
00460   anArray->length( aList.Extent() );
00461   TColStd_ListIteratorOfListOfReal anIter( aList );
00462   int i = 0;
00463   for( ; anIter.More(); anIter.Next() )
00464     anArray[ i++ ] = anIter.Value();
00465 
00466   return anArray._retn();
00467 }
00468 
00469 static SMESH::Filter::Criterion createCriterion()
00470 {
00471   SMESH::Filter::Criterion aCriterion;
00472 
00473   aCriterion.Type          = FT_Undefined;
00474   aCriterion.Compare       = FT_Undefined;
00475   aCriterion.Threshold     = 0;
00476   aCriterion.UnaryOp       = FT_Undefined;
00477   aCriterion.BinaryOp      = FT_Undefined;
00478   aCriterion.ThresholdStr  = "";
00479   aCriterion.ThresholdID   = "";
00480   aCriterion.Tolerance     = Precision::Confusion();
00481   aCriterion.TypeOfElement = SMESH::ALL;
00482   aCriterion.Precision     = -1;
00483 
00484   return aCriterion;
00485 }
00486 
00487 static TopoDS_Shape getShapeByName( const char* theName )
00488 {
00489   if ( theName != 0 )
00490   {
00491     SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
00492     SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
00493     if (!CORBA::is_nil(aStudy))
00494     {
00495       SALOMEDS::Study::ListOfSObject_var aList =
00496         aStudy->FindObjectByName( theName, "GEOM" );
00497       if ( aList->length() > 0 )
00498       {
00499         GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() );
00500         if ( !aGeomObj->_is_nil() )
00501         {
00502           GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
00503           TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
00504           return aLocShape;
00505         }
00506       }
00507     }
00508   }
00509   return TopoDS_Shape();
00510 }
00511 
00512 static TopoDS_Shape getShapeByID (const char* theID)
00513 {
00514   if (theID != 0 && theID != "") {
00515     SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
00516     SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
00517     if (aStudy != 0) {
00518       SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
00519       SALOMEDS::GenericAttribute_var anAttr;
00520       if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
00521         SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
00522         CORBA::String_var aVal = anIOR->Value();
00523         CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal);
00524         GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
00525       
00526         if (!aGeomObj->_is_nil()) {
00527           GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
00528           TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
00529           return aLocShape;
00530         }
00531       }
00532     }
00533   }
00534   return TopoDS_Shape();
00535 }
00536 
00537 static char* getShapeNameByID (const char* theID)
00538 {
00539   char* aName = (char*)"";
00540 
00541   if (theID != 0 && theID != "") {
00542     SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
00543     SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
00544     if (aStudy != 0) {
00545       //SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( theID );
00546       SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
00547       SALOMEDS::GenericAttribute_var anAttr;
00548       if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeName")) {
00549         SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr);
00550         aName = aNameAttr->Value();
00551       }
00552     }
00553   }
00554 
00555   return aName;
00556 }
00557 
00558 /*
00559                                 FUNCTORS
00560 */
00561 
00562 /*
00563   Class       : Functor_i
00564   Description : An abstact class for all functors
00565 */
00566 Functor_i::Functor_i():
00567   SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
00568 {
00569   //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method  
00570   //PortableServer::ObjectId_var anObjectId =
00571   //  SMESH_Gen_i::GetPOA()->activate_object( this );
00572 }
00573 
00574 Functor_i::~Functor_i()
00575 {
00576   //TPythonDump()<<this<<".UnRegister()";
00577 }
00578 
00579 void Functor_i::SetMesh( SMESH_Mesh_ptr theMesh )
00580 {
00581   myFunctorPtr->SetMesh( MeshPtr2SMDSMesh( theMesh ) );
00582   TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
00583 }
00584 
00585 ElementType Functor_i::GetElementType()
00586 {
00587   return ( ElementType )myFunctorPtr->GetType();
00588 }
00589 
00590 
00591 /*
00592   Class       : NumericalFunctor_i
00593   Description : Base class for numerical functors
00594 */
00595 CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId )
00596 {
00597   return myNumericalFunctorPtr->GetValue( theId );
00598 }
00599 
00600 SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals)
00601 {
00602   std::vector<int> nbEvents;
00603   std::vector<double> funValues;
00604   std::vector<int> elements;
00605   myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements);
00606 
00607   nbIntervals = CORBA::Short( std::min( nbEvents.size(), funValues.size() - 1));
00608   SMESH::Histogram_var histogram = new SMESH::Histogram;
00609   if ( nbIntervals > 0 )
00610   {
00611     histogram->length( nbIntervals );
00612     for ( int i = 0; i < nbIntervals; ++i )
00613     {
00614       HistogramRectangle& rect = histogram[i];
00615       rect.nbEvents = nbEvents[i];
00616       rect.min = funValues[i];
00617       rect.max = funValues[i+1];
00618     }
00619   }
00620   return histogram._retn();
00621 }
00622 
00623 void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision )
00624 {
00625   myNumericalFunctorPtr->SetPrecision( thePrecision );
00626   TPythonDump()<<this<<".SetPrecision("<<thePrecision<<")";
00627 }
00628 
00629 CORBA::Long NumericalFunctor_i::GetPrecision()
00630 {
00631  return myNumericalFunctorPtr->GetPrecision();
00632 }
00633 
00634 Controls::NumericalFunctorPtr NumericalFunctor_i::GetNumericalFunctor()
00635 {
00636   return myNumericalFunctorPtr;
00637 }
00638 
00639 
00640 /*
00641   Class       : SMESH_MinimumAngle
00642   Description : Functor for calculation of minimum angle
00643 */
00644 MinimumAngle_i::MinimumAngle_i()
00645 {
00646   myNumericalFunctorPtr.reset( new Controls::MinimumAngle() );
00647   myFunctorPtr = myNumericalFunctorPtr;
00648 }
00649 
00650 FunctorType MinimumAngle_i::GetFunctorType()
00651 {
00652   return SMESH::FT_MinimumAngle;
00653 }
00654 
00655 
00656 /*
00657   Class       : AspectRatio
00658   Description : Functor for calculating aspect ratio
00659 */
00660 AspectRatio_i::AspectRatio_i()
00661 {
00662   myNumericalFunctorPtr.reset( new Controls::AspectRatio() );
00663   myFunctorPtr = myNumericalFunctorPtr;
00664 }
00665 
00666 FunctorType AspectRatio_i::GetFunctorType()
00667 {
00668   return SMESH::FT_AspectRatio;
00669 }
00670 
00671 
00672 /*
00673   Class       : AspectRatio3D
00674   Description : Functor for calculating aspect ratio 3D
00675 */
00676 AspectRatio3D_i::AspectRatio3D_i()
00677 {
00678   myNumericalFunctorPtr.reset( new Controls::AspectRatio3D() );
00679   myFunctorPtr = myNumericalFunctorPtr;
00680 }
00681 
00682 FunctorType AspectRatio3D_i::GetFunctorType()
00683 {
00684   return SMESH::FT_AspectRatio3D;
00685 }
00686 
00687 
00688 /*
00689   Class       : Warping_i
00690   Description : Functor for calculating warping
00691 */
00692 Warping_i::Warping_i()
00693 {
00694   myNumericalFunctorPtr.reset( new Controls::Warping() );
00695   myFunctorPtr = myNumericalFunctorPtr;
00696 }
00697 
00698 FunctorType Warping_i::GetFunctorType()
00699 {
00700   return SMESH::FT_Warping;
00701 }
00702 
00703 
00704 /*
00705   Class       : Taper_i
00706   Description : Functor for calculating taper
00707 */
00708 Taper_i::Taper_i()
00709 {
00710   myNumericalFunctorPtr.reset( new Controls::Taper() );
00711   myFunctorPtr = myNumericalFunctorPtr;
00712 }
00713 
00714 FunctorType Taper_i::GetFunctorType()
00715 {
00716   return SMESH::FT_Taper;
00717 }
00718 
00719 
00720 /*
00721   Class       : Skew_i
00722   Description : Functor for calculating skew in degrees
00723 */
00724 Skew_i::Skew_i()
00725 {
00726   myNumericalFunctorPtr.reset( new Controls::Skew() );
00727   myFunctorPtr = myNumericalFunctorPtr;
00728 }
00729 
00730 FunctorType Skew_i::GetFunctorType()
00731 {
00732   return SMESH::FT_Skew;
00733 }
00734 
00735 /*
00736   Class       : Area_i
00737   Description : Functor for calculating area
00738 */
00739 Area_i::Area_i()
00740 {
00741   myNumericalFunctorPtr.reset( new Controls::Area() );
00742   myFunctorPtr = myNumericalFunctorPtr;
00743 }
00744 
00745 FunctorType Area_i::GetFunctorType()
00746 {
00747   return SMESH::FT_Area;
00748 }
00749 
00750 /*
00751   Class       : Volume3D_i
00752   Description : Functor for calculating volume of 3D element
00753 */
00754 Volume3D_i::Volume3D_i()
00755 {
00756   myNumericalFunctorPtr.reset( new Controls::Volume() );
00757   myFunctorPtr = myNumericalFunctorPtr;
00758 }
00759 
00760 FunctorType Volume3D_i::GetFunctorType()
00761 {
00762   return SMESH::FT_Volume3D;
00763 }
00764 
00765 /*
00766   Class       : MaxElementLength2D_i
00767   Description : Functor for calculating maximum length of 2D element
00768 */
00769 MaxElementLength2D_i::MaxElementLength2D_i()
00770 {
00771   myNumericalFunctorPtr.reset( new Controls::MaxElementLength2D() );
00772   myFunctorPtr = myNumericalFunctorPtr;
00773 }
00774 
00775 FunctorType MaxElementLength2D_i::GetFunctorType()
00776 {
00777   return SMESH::FT_MaxElementLength2D;
00778 }
00779 
00780 /*
00781   Class       : MaxElementLength3D_i
00782   Description : Functor for calculating maximum length of 3D element
00783 */
00784 MaxElementLength3D_i::MaxElementLength3D_i()
00785 {
00786   myNumericalFunctorPtr.reset( new Controls::MaxElementLength3D() );
00787   myFunctorPtr = myNumericalFunctorPtr;
00788 }
00789 
00790 FunctorType MaxElementLength3D_i::GetFunctorType()
00791 {
00792   return SMESH::FT_MaxElementLength3D;
00793 }
00794 
00795 /*
00796   Class       : Length_i
00797   Description : Functor for calculating length off edge
00798 */
00799 Length_i::Length_i()
00800 {
00801   myNumericalFunctorPtr.reset( new Controls::Length() );
00802   myFunctorPtr = myNumericalFunctorPtr;
00803 }
00804 
00805 FunctorType Length_i::GetFunctorType()
00806 {
00807   return SMESH::FT_Length;
00808 }
00809 
00810 /*
00811   Class       : Length2D_i
00812   Description : Functor for calculating length of edge
00813 */
00814 Length2D_i::Length2D_i()
00815 {
00816   myNumericalFunctorPtr.reset( new Controls::Length2D() );
00817   myFunctorPtr = myNumericalFunctorPtr;
00818 }
00819 
00820 FunctorType Length2D_i::GetFunctorType()
00821 {
00822   return SMESH::FT_Length2D;
00823 }
00824 
00825 SMESH::Length2D::Values* Length2D_i::GetValues()
00826 {
00827   INFOS("Length2D_i::GetValues");
00828   SMESH::Controls::Length2D::TValues aValues;
00829   (dynamic_cast<SMESH::Controls::Length2D*>(myFunctorPtr.get()))->GetValues( aValues );
00830 
00831   long i = 0, iEnd = aValues.size();
00832 
00833   SMESH::Length2D::Values_var aResult = new SMESH::Length2D::Values(iEnd);
00834   aResult->length(iEnd);
00835 
00836   SMESH::Controls::Length2D::TValues::const_iterator anIter;
00837   for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
00838   {
00839     const SMESH::Controls::Length2D::Value&  aVal = *anIter;
00840     SMESH::Length2D::Value &aValue = aResult[ i ];
00841 
00842     aValue.myLength = aVal.myLength;
00843     aValue.myPnt1 = aVal.myPntId[ 0 ];
00844     aValue.myPnt2 = aVal.myPntId[ 1 ];
00845   }
00846 
00847   INFOS("Length2D_i::GetValuess~");
00848   return aResult._retn();
00849 }
00850 
00851 /*
00852   Class       : MultiConnection_i
00853   Description : Functor for calculating number of faces conneted to the edge
00854 */
00855 MultiConnection_i::MultiConnection_i()
00856 {
00857   myNumericalFunctorPtr.reset( new Controls::MultiConnection() );
00858   myFunctorPtr = myNumericalFunctorPtr;
00859 }
00860 
00861 FunctorType MultiConnection_i::GetFunctorType()
00862 {
00863   return SMESH::FT_MultiConnection;
00864 }
00865 
00866 /*
00867   Class       : MultiConnection2D_i
00868   Description : Functor for calculating number of faces conneted to the edge
00869 */
00870 MultiConnection2D_i::MultiConnection2D_i()
00871 {
00872   myNumericalFunctorPtr.reset( new Controls::MultiConnection2D() );
00873   myFunctorPtr = myNumericalFunctorPtr;
00874 }
00875 
00876 FunctorType MultiConnection2D_i::GetFunctorType()
00877 {
00878   return SMESH::FT_MultiConnection2D;
00879 }
00880 
00881 SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues()
00882 {
00883   INFOS("MultiConnection2D_i::GetValues");
00884   SMESH::Controls::MultiConnection2D::MValues aValues;
00885   (dynamic_cast<SMESH::Controls::MultiConnection2D*>(myFunctorPtr.get()))->GetValues( aValues );
00886   
00887   long i = 0, iEnd = aValues.size();
00888 
00889   SMESH::MultiConnection2D::Values_var aResult = new SMESH::MultiConnection2D::Values(iEnd);
00890   aResult->length(iEnd);
00891 
00892   SMESH::Controls::MultiConnection2D::MValues::const_iterator anIter;
00893   for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
00894   {
00895     const SMESH::Controls::MultiConnection2D::Value&  aVal = (*anIter).first;
00896     SMESH::MultiConnection2D::Value &aValue = aResult[ i ];
00897 
00898     aValue.myPnt1 = aVal.myPntId[ 0 ];
00899     aValue.myPnt2 = aVal.myPntId[ 1 ];
00900     aValue.myNbConnects = (*anIter).second;
00901   }
00902 
00903   INFOS("Multiconnection2D_i::GetValuess~");
00904   return aResult._retn();
00905 }
00906 
00907 /*
00908                             PREDICATES
00909 */
00910 
00911 
00912 /*
00913   Class       : Predicate_i
00914   Description : Base class for all predicates
00915 */
00916 CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId )
00917 {
00918   return myPredicatePtr->IsSatisfy( theId );
00919 }
00920 
00921 Controls::PredicatePtr Predicate_i::GetPredicate()
00922 {
00923   return myPredicatePtr;
00924 }
00925 
00926 /*
00927   Class       : BadOrientedVolume_i
00928   Description : Verify whether a mesh volume is incorrectly oriented from
00929                 the point of view of MED convention
00930 */
00931 BadOrientedVolume_i::BadOrientedVolume_i()
00932 {
00933   Controls::PredicatePtr control( new Controls::BadOrientedVolume() );
00934   myFunctorPtr = myPredicatePtr = control;
00935 };
00936 
00937 FunctorType BadOrientedVolume_i::GetFunctorType()
00938 {
00939   return SMESH::FT_BadOrientedVolume;
00940 }
00941 
00942 /*
00943   Class       : BareBorderVolume_i
00944   Description : Verify whether a mesh volume has a free facet without a face on it
00945 */
00946 BareBorderVolume_i::BareBorderVolume_i()
00947 {
00948   Controls::PredicatePtr control( new Controls::BareBorderVolume() );
00949   myFunctorPtr = myPredicatePtr = control;
00950 };
00951 
00952 FunctorType BareBorderVolume_i::GetFunctorType()
00953 {
00954   return SMESH::FT_BareBorderVolume;
00955 }
00956 
00957 /*
00958   Class       : BareBorderFace_i
00959   Description : Verify whether a mesh face has a free border without an edge on it
00960 */
00961 BareBorderFace_i::BareBorderFace_i()
00962 {
00963   Controls::PredicatePtr control( new Controls::BareBorderFace() );
00964   myFunctorPtr = myPredicatePtr = control;
00965 };
00966 
00967 FunctorType BareBorderFace_i::GetFunctorType()
00968 {
00969   return SMESH::FT_BareBorderFace;
00970 }
00971 
00972 /*
00973   Class       : OverConstrainedVolume_i
00974   Description : Verify whether a mesh volume has only one facet shared with other volumes
00975 */
00976 OverConstrainedVolume_i::OverConstrainedVolume_i()
00977 {
00978   Controls::PredicatePtr control( new Controls::OverConstrainedVolume() );
00979   myFunctorPtr = myPredicatePtr = control;
00980 };
00981 
00982 FunctorType OverConstrainedVolume_i::GetFunctorType()
00983 {
00984   return SMESH::FT_OverConstrainedVolume;
00985 }
00986 
00987 /*
00988   Class       : OverConstrainedFace_i
00989   Description : Verify whether a mesh face has only one border shared with other faces
00990 */
00991 OverConstrainedFace_i::OverConstrainedFace_i()
00992 {
00993   Controls::PredicatePtr control( new Controls::OverConstrainedFace() );
00994   myFunctorPtr = myPredicatePtr = control;
00995 };
00996 
00997 FunctorType OverConstrainedFace_i::GetFunctorType()
00998 {
00999   return SMESH::FT_OverConstrainedFace;
01000 }
01001 
01002 /*
01003   Class       : BelongToGeom_i
01004   Description : Predicate for selection on geometrical support
01005 */
01006 BelongToGeom_i::BelongToGeom_i()
01007 {
01008   myBelongToGeomPtr.reset( new Controls::BelongToGeom() );
01009   myFunctorPtr = myPredicatePtr = myBelongToGeomPtr;
01010   myShapeName = 0;
01011   myShapeID   = 0;
01012 }
01013 
01014 BelongToGeom_i::~BelongToGeom_i()
01015 {
01016   delete myShapeName;
01017   delete myShapeID;
01018 }
01019 
01020 void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
01021 {
01022   if ( theGeom->_is_nil() )
01023     return;
01024   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
01025   GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
01026   TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
01027   myBelongToGeomPtr->SetGeom( aLocShape );
01028   TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
01029 }
01030 
01031 void BelongToGeom_i::SetGeom( const TopoDS_Shape& theShape )
01032 {
01033   myBelongToGeomPtr->SetGeom( theShape );
01034 }
01035 
01036 void BelongToGeom_i::SetElementType(ElementType theType){
01037   myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType));
01038   TPythonDump()<<this<<".SetElementType("<<theType<<")";
01039 }
01040 
01041 FunctorType BelongToGeom_i::GetFunctorType()
01042 {
01043   return SMESH::FT_BelongToGeom;
01044 }
01045 
01046 void BelongToGeom_i::SetShapeName( const char* theName )
01047 {
01048   delete myShapeName;
01049   myShapeName = strdup( theName );
01050   myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
01051   TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
01052 }
01053 
01054 void BelongToGeom_i::SetShape( const char* theID, const char* theName )
01055 {
01056   delete myShapeName;
01057   myShapeName = strdup( theName );
01058   delete myShapeID;
01059   if ( theID )
01060     myShapeID = strdup( theID );
01061   else
01062     myShapeID = 0;
01063 
01064   if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
01065     myBelongToGeomPtr->SetGeom( getShapeByID(myShapeID) );
01066   else
01067     myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
01068 }
01069 
01070 char* BelongToGeom_i::GetShapeName()
01071 {
01072   return CORBA::string_dup( myShapeName );
01073 }
01074 
01075 char* BelongToGeom_i::GetShapeID()
01076 {
01077   return CORBA::string_dup( myShapeID );
01078 }
01079 
01080 void BelongToGeom_i::SetTolerance( CORBA::Double theToler )
01081 {
01082   myBelongToGeomPtr->SetTolerance( theToler );
01083   TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
01084 }
01085 
01086 CORBA::Double BelongToGeom_i::GetTolerance()
01087 {
01088   return myBelongToGeomPtr->GetTolerance();
01089 }
01090 
01091 /*
01092   Class       : BelongToSurface_i
01093   Description : Predicate for selection on geometrical support
01094 */
01095 BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceType )
01096 {
01097   myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() );
01098   myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr;
01099   myShapeName = 0;
01100   myShapeID   = 0;
01101   mySurfaceType = theSurfaceType;
01102 }
01103 
01104 BelongToSurface_i::~BelongToSurface_i()
01105 {
01106   delete myShapeName;
01107   delete myShapeID;
01108 }
01109 
01110 void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
01111 {
01112   if ( theGeom->_is_nil() )
01113     return;
01114   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
01115   GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
01116   TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
01117 
01118   if ( aLocShape.ShapeType() == TopAbs_FACE )
01119   {
01120     Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aLocShape ) );
01121     if ( !aSurf.IsNull() && aSurf->DynamicType() == mySurfaceType )
01122     {
01123       myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
01124       return;
01125     }
01126   }
01127 
01128   myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType );
01129 }
01130 
01131 void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
01132 {
01133   delete myShapeName;
01134   myShapeName = strdup( theName );
01135   myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
01136   TPythonDump()<<this<<".SetShapeName('"<<theName<<"',"<<theType<<")";
01137 }
01138 
01139 void BelongToSurface_i::SetShape( const char* theID,  const char* theName, ElementType theType )
01140 {
01141   delete myShapeName;
01142   myShapeName = strdup( theName );
01143   delete myShapeID;
01144   if ( theID )
01145     myShapeID = strdup( theID );
01146   else
01147     myShapeID = 0;
01148   
01149   if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
01150     myElementsOnSurfacePtr->SetSurface( getShapeByID(myShapeID), (SMDSAbs_ElementType)theType );
01151   else
01152     myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
01153 }
01154 
01155 char* BelongToSurface_i::GetShapeName()
01156 {
01157   return CORBA::string_dup( myShapeName );
01158 }
01159 
01160 char* BelongToSurface_i::GetShapeID()
01161 {
01162   return CORBA::string_dup( myShapeID );
01163 }
01164 
01165 void BelongToSurface_i::SetTolerance( CORBA::Double theToler )
01166 {
01167   myElementsOnSurfacePtr->SetTolerance( theToler );
01168   TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
01169 }
01170 
01171 CORBA::Double BelongToSurface_i::GetTolerance()
01172 {
01173   return myElementsOnSurfacePtr->GetTolerance();
01174 }
01175 
01176 void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions )
01177 {
01178   myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions );
01179   TPythonDump()<<this<<".SetUseBoundaries( " << theUseBndRestrictions << " )";
01180 }
01181 
01182 CORBA::Boolean BelongToSurface_i::GetUseBoundaries()
01183 {
01184   return myElementsOnSurfacePtr->GetUseBoundaries();
01185 }
01186 
01187 
01188 /*
01189   Class       : BelongToPlane_i
01190   Description : Verify whether mesh element lie in pointed Geom planar object
01191 */
01192 
01193 BelongToPlane_i::BelongToPlane_i()
01194 : BelongToSurface_i( STANDARD_TYPE( Geom_Plane ) )
01195 {
01196 }
01197 
01198 void BelongToPlane_i::SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
01199 {
01200   BelongToSurface_i::SetSurface( theGeom, theType );
01201   TPythonDump()<<this<<".SetPlane("<<theGeom<<","<<theType<<")";
01202 }
01203 
01204 FunctorType BelongToPlane_i::GetFunctorType()
01205 {
01206   return FT_BelongToPlane;
01207 }
01208 
01209 /*
01210   Class       : BelongToCylinder_i
01211   Description : Verify whether mesh element lie in pointed Geom planar object
01212 */
01213 
01214 BelongToCylinder_i::BelongToCylinder_i()
01215 : BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) )
01216 {
01217 }
01218 
01219 void BelongToCylinder_i::SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
01220 {
01221   BelongToSurface_i::SetSurface( theGeom, theType );
01222   TPythonDump()<<this<<".SetCylinder("<<theGeom<<","<<theType<<")";
01223 }
01224 
01225 FunctorType BelongToCylinder_i::GetFunctorType()
01226 {
01227   return FT_BelongToCylinder;
01228 }
01229 
01230 /*
01231   Class       : BelongToGenSurface_i
01232   Description : Verify whether mesh element lie in pointed Geom planar object
01233 */
01234 
01235 BelongToGenSurface_i::BelongToGenSurface_i()
01236 : BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) )
01237 {
01238 }
01239 
01240 void BelongToGenSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
01241 {
01242   if ( theGeom->_is_nil() )
01243     return;
01244   TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom );
01245   if ( !aLocShape.IsNull() && aLocShape.ShapeType() != TopAbs_FACE )
01246     aLocShape.Nullify();
01247   
01248   BelongToSurface_i::myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
01249   TPythonDump()<<this<<".SetGenSurface("<<theGeom<<","<<theType<<")";
01250 }
01251 
01252 FunctorType BelongToGenSurface_i::GetFunctorType()
01253 {
01254   return FT_BelongToGenSurface;
01255 }
01256 
01257 /*
01258   Class       : LyingOnGeom_i
01259   Description : Predicate for selection on geometrical support
01260 */
01261 LyingOnGeom_i::LyingOnGeom_i()
01262 {
01263   myLyingOnGeomPtr.reset( new Controls::LyingOnGeom() );
01264   myFunctorPtr = myPredicatePtr = myLyingOnGeomPtr;
01265   myShapeName = 0;
01266   myShapeID = 0;
01267 }
01268 
01269 LyingOnGeom_i::~LyingOnGeom_i()
01270 {
01271   delete myShapeName;
01272   delete myShapeID;
01273 }
01274 
01275 void LyingOnGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
01276 {
01277   if ( theGeom->_is_nil() )
01278     return;
01279   SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
01280   GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
01281   TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
01282   myLyingOnGeomPtr->SetGeom( aLocShape );
01283   TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
01284 }
01285 
01286 void LyingOnGeom_i::SetGeom( const TopoDS_Shape& theShape )
01287 {
01288   myLyingOnGeomPtr->SetGeom( theShape );
01289 }
01290 
01291 void LyingOnGeom_i::SetElementType(ElementType theType){
01292   myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType));
01293   TPythonDump()<<this<<".SetElementType("<<theType<<")";
01294 }
01295 
01296 FunctorType LyingOnGeom_i::GetFunctorType()
01297 {
01298   return SMESH::FT_LyingOnGeom;
01299 }
01300 
01301 void LyingOnGeom_i::SetShapeName( const char* theName )
01302 {
01303   delete myShapeName;
01304   myShapeName = strdup( theName );
01305   myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
01306   TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
01307 }
01308 
01309 void LyingOnGeom_i::SetShape( const char* theID, const char* theName )
01310 {
01311   delete myShapeName;
01312   myShapeName = strdup( theName );
01313   delete myShapeID;
01314   if ( theID )
01315     myShapeID = strdup( theID );
01316   else
01317     myShapeID = 0;
01318   
01319   if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
01320     myLyingOnGeomPtr->SetGeom( getShapeByID(myShapeID) );
01321   else
01322     myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
01323 }
01324 
01325 char* LyingOnGeom_i::GetShapeName()
01326 {
01327   return CORBA::string_dup( myShapeName );
01328 }
01329 
01330 char* LyingOnGeom_i::GetShapeID()
01331 {
01332   return CORBA::string_dup( myShapeID );
01333 }
01334 
01335 void LyingOnGeom_i::SetTolerance( CORBA::Double theToler )
01336 {
01337   myLyingOnGeomPtr->SetTolerance( theToler );
01338   TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
01339 }
01340 
01341 CORBA::Double LyingOnGeom_i::GetTolerance()
01342 {
01343   return myLyingOnGeomPtr->GetTolerance();
01344 }
01345 
01346 /*
01347   Class       : FreeBorders_i
01348   Description : Predicate for free borders
01349 */
01350 FreeBorders_i::FreeBorders_i()
01351 {
01352   myPredicatePtr.reset(new Controls::FreeBorders());
01353   myFunctorPtr = myPredicatePtr;
01354 }
01355 
01356 FunctorType FreeBorders_i::GetFunctorType()
01357 {
01358   return SMESH::FT_FreeBorders;
01359 }
01360 
01361 /*
01362   Class       : FreeEdges_i
01363   Description : Predicate for free borders
01364 */
01365 FreeEdges_i::FreeEdges_i()
01366 : myFreeEdgesPtr( new Controls::FreeEdges() )
01367 {
01368   myFunctorPtr = myPredicatePtr = myFreeEdgesPtr;
01369 }
01370 
01371 SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders()
01372 {
01373   INFOS("FreeEdges_i::GetBorders");
01374   SMESH::Controls::FreeEdges::TBorders aBorders;
01375   myFreeEdgesPtr->GetBoreders( aBorders );
01376 
01377   long i = 0, iEnd = aBorders.size();
01378 
01379   SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders;
01380   aResult->length(iEnd);
01381 
01382   SMESH::Controls::FreeEdges::TBorders::const_iterator anIter;
01383   for ( anIter = aBorders.begin() ; anIter != aBorders.end(); anIter++, i++ )
01384   {
01385     const SMESH::Controls::FreeEdges::Border&  aBord = *anIter;
01386     SMESH::FreeEdges::Border &aBorder = aResult[ i ];
01387 
01388     aBorder.myElemId = aBord.myElemId;
01389     aBorder.myPnt1 = aBord.myPntId[ 0 ];
01390     aBorder.myPnt2 = aBord.myPntId[ 1 ];
01391   }
01392 
01393   INFOS("FreeEdges_i::GetBorders~");
01394   return aResult._retn();
01395 }
01396 
01397 FunctorType FreeEdges_i::GetFunctorType()
01398 {
01399   return SMESH::FT_FreeEdges;
01400 }
01401 
01402 /*
01403   Class       : FreeFaces_i
01404   Description : Predicate for free faces
01405 */
01406 FreeFaces_i::FreeFaces_i()
01407 {
01408   myPredicatePtr.reset(new Controls::FreeFaces());
01409   myFunctorPtr = myPredicatePtr;
01410 }
01411 
01412 FunctorType FreeFaces_i::GetFunctorType()
01413 {
01414   return SMESH::FT_FreeFaces;
01415 }
01416 
01417 /*
01418   Class       : FreeNodes_i
01419   Description : Predicate for free nodes
01420 */
01421 FreeNodes_i::FreeNodes_i()
01422 {
01423   myPredicatePtr.reset(new Controls::FreeNodes());
01424   myFunctorPtr = myPredicatePtr;
01425 }
01426 
01427 FunctorType FreeNodes_i::GetFunctorType()
01428 {
01429   return SMESH::FT_FreeNodes;
01430 }
01431 
01432 /*
01433   Class       : RangeOfIds_i
01434   Description : Predicate for Range of Ids.
01435                 Range may be specified with two ways.
01436                 1. Using AddToRange method
01437                 2. With SetRangeStr method. Parameter of this method is a string
01438                    like as "1,2,3,50-60,63,67,70-"
01439 */
01440 
01441 RangeOfIds_i::RangeOfIds_i()
01442 {
01443   myRangeOfIdsPtr.reset( new Controls::RangeOfIds() );
01444   myFunctorPtr = myPredicatePtr = myRangeOfIdsPtr;
01445 }
01446 
01447 void RangeOfIds_i::SetRange( const SMESH::long_array& theIds )
01448 {
01449   CORBA::Long iEnd = theIds.length();
01450   for ( CORBA::Long i = 0; i < iEnd; i++ )
01451     myRangeOfIdsPtr->AddToRange( theIds[ i ] );
01452   TPythonDump()<<this<<".SetRange("<<theIds<<")";
01453 }
01454 
01455 CORBA::Boolean RangeOfIds_i::SetRangeStr( const char* theRange )
01456 {
01457   TPythonDump()<<this<<".SetRangeStr('"<<theRange<<"')";
01458   return myRangeOfIdsPtr->SetRangeStr(
01459     TCollection_AsciiString( (Standard_CString)theRange ) );
01460 }
01461 
01462 char* RangeOfIds_i::GetRangeStr()
01463 {
01464   TCollection_AsciiString aStr;
01465   myRangeOfIdsPtr->GetRangeStr( aStr );
01466   return CORBA::string_dup( aStr.ToCString() );
01467 }
01468 
01469 void RangeOfIds_i::SetElementType( ElementType theType )
01470 {
01471   myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) );
01472   TPythonDump()<<this<<".SetElementType("<<theType<<")";
01473 }
01474 
01475 FunctorType RangeOfIds_i::GetFunctorType()
01476 {
01477   return SMESH::FT_RangeOfIds;
01478 }
01479 
01480 /*
01481   Class       : LinearOrQuadratic_i
01482   Description : Predicate to verify whether a mesh element is linear
01483 */
01484 LinearOrQuadratic_i::LinearOrQuadratic_i()
01485 {
01486   myLinearOrQuadraticPtr.reset(new Controls::LinearOrQuadratic());
01487   myFunctorPtr = myPredicatePtr = myLinearOrQuadraticPtr;
01488 }
01489 
01490 void LinearOrQuadratic_i::SetElementType(ElementType theType)
01491 {
01492   myLinearOrQuadraticPtr->SetType(SMDSAbs_ElementType(theType));
01493   TPythonDump()<<this<<".SetElementType("<<theType<<")";
01494 }
01495 
01496 FunctorType LinearOrQuadratic_i::GetFunctorType()
01497 {
01498   return SMESH::FT_LinearOrQuadratic;
01499 }
01500 
01501 /*
01502   Class       : GroupColor_i
01503   Description : Functor for check color of group to whic mesh element belongs to
01504 */
01505 GroupColor_i::GroupColor_i()
01506 {
01507   myGroupColorPtr.reset(new Controls::GroupColor());
01508   myFunctorPtr = myPredicatePtr = myGroupColorPtr;
01509 }
01510 
01511 FunctorType GroupColor_i::GetFunctorType()
01512 {
01513   return SMESH::FT_GroupColor;
01514 }
01515 
01516 void GroupColor_i::SetColorStr( const char* theColor )
01517 {
01518   myGroupColorPtr->SetColorStr(
01519     TCollection_AsciiString( (Standard_CString)theColor ) );
01520   TPythonDump()<<this<<".SetColorStr('"<<theColor<<"')";
01521 }
01522 
01523 char* GroupColor_i::GetColorStr()
01524 {
01525   TCollection_AsciiString aStr;
01526   myGroupColorPtr->GetColorStr( aStr );
01527   return CORBA::string_dup( aStr.ToCString() );
01528 }
01529 
01530 void GroupColor_i::SetElementType(ElementType theType)
01531 {
01532   myGroupColorPtr->SetType(SMDSAbs_ElementType(theType));
01533   TPythonDump()<<this<<".SetElementType("<<theType<<")";
01534 }
01535 
01536 /*
01537   Class       : ElemGeomType_i
01538   Description : Predicate check is element has indicated geometry type
01539 */
01540 ElemGeomType_i::ElemGeomType_i()
01541 {
01542   myElemGeomTypePtr.reset(new Controls::ElemGeomType());
01543   myFunctorPtr = myPredicatePtr = myElemGeomTypePtr;
01544 }
01545 
01546 void ElemGeomType_i::SetElementType(ElementType theType)
01547 {
01548   myElemGeomTypePtr->SetType(SMDSAbs_ElementType(theType));
01549   TPythonDump()<<this<<".SetElementType("<<theType<<")";
01550 }
01551 
01552 void ElemGeomType_i::SetGeometryType(GeometryType theType)
01553 {
01554   myElemGeomTypePtr->SetGeomType(SMDSAbs_GeometryType(theType));
01555   TPythonDump()<<this<<".SetGeometryType("<<theType<<")";
01556 }
01557 
01558 GeometryType ElemGeomType_i::GetGeometryType() const
01559 {
01560   return (GeometryType)myElemGeomTypePtr->GetGeomType();
01561 }
01562 
01563 FunctorType ElemGeomType_i::GetFunctorType()
01564 {
01565   return SMESH::FT_ElemGeomType;
01566 }
01567 
01568 /*
01569   Class       : CoplanarFaces_i
01570   Description : Returns true if a mesh face is a coplanar neighbour to a given one
01571 */
01572 CoplanarFaces_i::CoplanarFaces_i()
01573 {
01574   myCoplanarFacesPtr.reset(new Controls::CoplanarFaces());
01575   myFunctorPtr = myPredicatePtr = myCoplanarFacesPtr;
01576 }
01577 
01578 void CoplanarFaces_i::SetFace ( CORBA::Long theFaceID )
01579 {
01580   myCoplanarFacesPtr->SetFace(theFaceID);
01581   TPythonDump()<<this<<".SetFace("<<theFaceID<<")";
01582 }
01583 
01584 void CoplanarFaces_i::SetTolerance( CORBA::Double theToler )
01585 {
01586   myCoplanarFacesPtr->SetTolerance(theToler);
01587   TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
01588 }
01589 
01590 CORBA::Long CoplanarFaces_i::GetFace () const
01591 {
01592   return myCoplanarFacesPtr->GetFace();
01593 }
01594 
01595 char* CoplanarFaces_i::GetFaceAsString () const
01596 {
01597   TCollection_AsciiString str(Standard_Integer(myCoplanarFacesPtr->GetFace()));
01598   return CORBA::string_dup( str.ToCString() );
01599 }
01600 
01601 CORBA::Double CoplanarFaces_i::GetTolerance() const
01602 {
01603   return myCoplanarFacesPtr->GetTolerance();
01604 }
01605 
01606 FunctorType CoplanarFaces_i::GetFunctorType()
01607 {
01608   return SMESH::FT_CoplanarFaces;
01609 }
01610 
01611 /*
01612   Class       : Comparator_i
01613   Description : Base class for comparators
01614 */
01615 Comparator_i::Comparator_i():
01616   myNumericalFunctor( NULL )
01617 {}
01618 
01619 Comparator_i::~Comparator_i()
01620 {
01621   if ( myNumericalFunctor )
01622     myNumericalFunctor->UnRegister();
01623 }
01624 
01625 void Comparator_i::SetMargin( CORBA::Double theValue )
01626 {
01627   myComparatorPtr->SetMargin( theValue );
01628   TPythonDump()<<this<<".SetMargin("<<theValue<<")";
01629 }
01630 
01631 CORBA::Double Comparator_i::GetMargin()
01632 {
01633   return myComparatorPtr->GetMargin();
01634 }
01635 
01636 void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct )
01637 {
01638   if ( myNumericalFunctor )
01639     myNumericalFunctor->UnRegister();
01640 
01641   myNumericalFunctor = DownCast<NumericalFunctor_i*>(theFunct);
01642 
01643   if ( myNumericalFunctor )
01644   {
01645     myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() );
01646     myNumericalFunctor->Register();
01647     TPythonDump()<<this<<".SetNumFunctor("<<myNumericalFunctor<<")";
01648   }
01649 }
01650 
01651 Controls::ComparatorPtr Comparator_i::GetComparator()
01652 {
01653   return myComparatorPtr;
01654 }
01655 
01656 NumericalFunctor_i* Comparator_i::GetNumFunctor_i()
01657 {
01658   return myNumericalFunctor;
01659 }
01660 
01661 
01662 /*
01663   Class       : LessThan_i
01664   Description : Comparator "<"
01665 */
01666 LessThan_i::LessThan_i()
01667 {
01668   myComparatorPtr.reset( new Controls::LessThan() );
01669   myFunctorPtr = myPredicatePtr = myComparatorPtr;
01670 }
01671 
01672 FunctorType LessThan_i::GetFunctorType()
01673 {
01674   return SMESH::FT_LessThan;
01675 }
01676 
01677 
01678 /*
01679   Class       : MoreThan_i
01680   Description : Comparator ">"
01681 */
01682 MoreThan_i::MoreThan_i()
01683 {
01684   myComparatorPtr.reset( new Controls::MoreThan() );
01685   myFunctorPtr = myPredicatePtr = myComparatorPtr;
01686 }
01687 
01688 FunctorType MoreThan_i::GetFunctorType()
01689 {
01690   return SMESH::FT_MoreThan;
01691 }
01692 
01693 
01694 /*
01695   Class       : EqualTo_i
01696   Description : Comparator "="
01697 */
01698 EqualTo_i::EqualTo_i()
01699 : myEqualToPtr( new Controls::EqualTo() )
01700 {
01701   myFunctorPtr = myPredicatePtr = myComparatorPtr = myEqualToPtr;
01702 }
01703 
01704 void EqualTo_i::SetTolerance( CORBA::Double theToler )
01705 {
01706   myEqualToPtr->SetTolerance( theToler );
01707   TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
01708 }
01709 
01710 CORBA::Double EqualTo_i::GetTolerance()
01711 {
01712   return myEqualToPtr->GetTolerance();
01713 }
01714 
01715 FunctorType EqualTo_i::GetFunctorType()
01716 {
01717   return SMESH::FT_EqualTo;
01718 }
01719 
01720 /*
01721   Class       : LogicalNOT_i
01722   Description : Logical NOT predicate
01723 */
01724 LogicalNOT_i::LogicalNOT_i()
01725 : myPredicate( NULL ),
01726   myLogicalNOTPtr( new Controls::LogicalNOT() )
01727 {
01728   myFunctorPtr = myPredicatePtr = myLogicalNOTPtr;
01729 }
01730 
01731 LogicalNOT_i::~LogicalNOT_i()
01732 {
01733   if ( myPredicate )
01734     myPredicate->UnRegister();
01735 }
01736 
01737 void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate )
01738 {
01739   if ( myPredicate )
01740     myPredicate->UnRegister();
01741 
01742   myPredicate = SMESH::GetPredicate(thePredicate);
01743 
01744   if ( myPredicate ){
01745     myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate());
01746     myPredicate->Register();
01747     TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
01748   }
01749 }
01750 
01751 FunctorType LogicalNOT_i::GetFunctorType()
01752 {
01753   return SMESH::FT_LogicalNOT;
01754 }
01755 
01756 Predicate_i* LogicalNOT_i::GetPredicate_i()
01757 {
01758   return myPredicate;
01759 }
01760 
01761 
01762 /*
01763   Class       : LogicalBinary_i
01764   Description : Base class for binary logical predicate
01765 */
01766 LogicalBinary_i::LogicalBinary_i()
01767 : myPredicate1( NULL ),
01768   myPredicate2( NULL )
01769 {}
01770 
01771 LogicalBinary_i::~LogicalBinary_i()
01772 {
01773   if ( myPredicate1 )
01774     myPredicate1->UnRegister();
01775 
01776   if ( myPredicate2 )
01777     myPredicate2->UnRegister();
01778 }
01779 
01780 void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh )
01781 {
01782   if ( myPredicate1 )
01783     myPredicate1->SetMesh( theMesh );
01784 
01785   if ( myPredicate2 )
01786     myPredicate2->SetMesh( theMesh );
01787 }
01788 
01789 void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate )
01790 {
01791   if ( myPredicate1 )
01792     myPredicate1->UnRegister();
01793 
01794   myPredicate1 = SMESH::GetPredicate(thePredicate);
01795 
01796   if ( myPredicate1 ){
01797     myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate());
01798     myPredicate1->Register();
01799     TPythonDump()<<this<<".SetPredicate1("<<myPredicate1<<")";
01800   }
01801 }
01802 
01803 void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate )
01804 {
01805   if ( myPredicate2 )
01806     myPredicate2->UnRegister();
01807 
01808   myPredicate2 = SMESH::GetPredicate(thePredicate);
01809 
01810   if ( myPredicate2 ){
01811     myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate());
01812     myPredicate2->Register();
01813     TPythonDump()<<this<<".SetPredicate2("<<myPredicate2<<")";
01814   }
01815 }
01816 
01817 Controls::LogicalBinaryPtr LogicalBinary_i::GetLogicalBinary()
01818 {
01819   return myLogicalBinaryPtr;
01820 }
01821 
01822 Predicate_i* LogicalBinary_i::GetPredicate1_i()
01823 {
01824   return myPredicate1;
01825 }
01826 Predicate_i* LogicalBinary_i::GetPredicate2_i()
01827 {
01828   return myPredicate2;
01829 }
01830 
01831 
01832 /*
01833   Class       : LogicalAND_i
01834   Description : Logical AND
01835 */
01836 LogicalAND_i::LogicalAND_i()
01837 {
01838   myLogicalBinaryPtr.reset( new Controls::LogicalAND() );
01839   myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr;
01840 }
01841 
01842 FunctorType LogicalAND_i::GetFunctorType()
01843 {
01844   return SMESH::FT_LogicalAND;
01845 }
01846 
01847 
01848 /*
01849   Class       : LogicalOR_i
01850   Description : Logical OR
01851 */
01852 LogicalOR_i::LogicalOR_i()
01853 {
01854   myLogicalBinaryPtr.reset( new Controls::LogicalOR() );
01855   myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr;
01856 }
01857 
01858 FunctorType LogicalOR_i::GetFunctorType()
01859 {
01860   return SMESH::FT_LogicalOR;
01861 }
01862 
01863 
01864 /*
01865                             FILTER MANAGER
01866 */
01867 
01868 FilterManager_i::FilterManager_i()
01869 : SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
01870 {
01871   //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method
01872   //PortableServer::ObjectId_var anObjectId =
01873   //  SMESH_Gen_i::GetPOA()->activate_object( this );
01874 }
01875 
01876 
01877 FilterManager_i::~FilterManager_i()
01878 {
01879   //TPythonDump()<<this<<".UnRegister()";
01880 }
01881 
01882 
01883 MinimumAngle_ptr FilterManager_i::CreateMinimumAngle()
01884 {
01885   SMESH::MinimumAngle_i* aServant = new SMESH::MinimumAngle_i();
01886   SMESH::MinimumAngle_var anObj = aServant->_this();
01887   TPythonDump()<<aServant<<" = "<<this<<".CreateMinimumAngle()";
01888   return anObj._retn();
01889 }
01890 
01891 
01892 AspectRatio_ptr FilterManager_i::CreateAspectRatio()
01893 {
01894   SMESH::AspectRatio_i* aServant = new SMESH::AspectRatio_i();
01895   SMESH::AspectRatio_var anObj = aServant->_this();
01896   TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio()";
01897   return anObj._retn();
01898 }
01899 
01900 
01901 AspectRatio3D_ptr FilterManager_i::CreateAspectRatio3D()
01902 {
01903   SMESH::AspectRatio3D_i* aServant = new SMESH::AspectRatio3D_i();
01904   SMESH::AspectRatio3D_var anObj = aServant->_this();
01905   TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio3D()";
01906   return anObj._retn();
01907 }
01908 
01909 
01910 Warping_ptr FilterManager_i::CreateWarping()
01911 {
01912   SMESH::Warping_i* aServant = new SMESH::Warping_i();
01913   SMESH::Warping_var anObj = aServant->_this();
01914   TPythonDump()<<aServant<<" = "<<this<<".CreateWarping()";
01915   return anObj._retn();
01916 }
01917 
01918 
01919 Taper_ptr FilterManager_i::CreateTaper()
01920 {
01921   SMESH::Taper_i* aServant = new SMESH::Taper_i();
01922   SMESH::Taper_var anObj = aServant->_this();
01923   TPythonDump()<<aServant<<" = "<<this<<".CreateTaper()";
01924   return anObj._retn();
01925 }
01926 
01927 
01928 Skew_ptr FilterManager_i::CreateSkew()
01929 {
01930   SMESH::Skew_i* aServant = new SMESH::Skew_i();
01931   SMESH::Skew_var anObj = aServant->_this();
01932   TPythonDump()<<aServant<<" = "<<this<<".CreateSkew()";
01933   return anObj._retn();
01934 }
01935 
01936 
01937 Area_ptr FilterManager_i::CreateArea()
01938 {
01939   SMESH::Area_i* aServant = new SMESH::Area_i();
01940   SMESH::Area_var anObj = aServant->_this();
01941   TPythonDump()<<aServant<<" = "<<this<<".CreateArea()";
01942   return anObj._retn();
01943 }
01944 
01945 
01946 Volume3D_ptr FilterManager_i::CreateVolume3D()
01947 {
01948   SMESH::Volume3D_i* aServant = new SMESH::Volume3D_i();
01949   SMESH::Volume3D_var anObj = aServant->_this();
01950   TPythonDump()<<aServant<<" = "<<this<<".CreateVolume3D()";
01951   return anObj._retn();
01952 }
01953 
01954 
01955 MaxElementLength2D_ptr FilterManager_i::CreateMaxElementLength2D()
01956 {
01957   SMESH::MaxElementLength2D_i* aServant = new SMESH::MaxElementLength2D_i();
01958   SMESH::MaxElementLength2D_var anObj = aServant->_this();
01959   TPythonDump()<<aServant<<" = "<<this<<".CreateMaxElementLength2D()";
01960   return anObj._retn();
01961 }
01962 
01963 
01964 MaxElementLength3D_ptr FilterManager_i::CreateMaxElementLength3D()
01965 {
01966   SMESH::MaxElementLength3D_i* aServant = new SMESH::MaxElementLength3D_i();
01967   SMESH::MaxElementLength3D_var anObj = aServant->_this();
01968   TPythonDump()<<aServant<<" = "<<this<<".CreateMaxElementLength3D()";
01969   return anObj._retn();
01970 }
01971 
01972 
01973 Length_ptr FilterManager_i::CreateLength()
01974 {
01975   SMESH::Length_i* aServant = new SMESH::Length_i();
01976   SMESH::Length_var anObj = aServant->_this();
01977   TPythonDump()<<aServant<<" = "<<this<<".CreateLength()";
01978   return anObj._retn();
01979 }
01980 
01981 Length2D_ptr FilterManager_i::CreateLength2D()
01982 {
01983   SMESH::Length2D_i* aServant = new SMESH::Length2D_i();
01984   SMESH::Length2D_var anObj = aServant->_this();
01985   TPythonDump()<<aServant<<" = "<<this<<".CreateLength2D()";
01986   return anObj._retn();
01987 }
01988 
01989 MultiConnection_ptr FilterManager_i::CreateMultiConnection()
01990 {
01991   SMESH::MultiConnection_i* aServant = new SMESH::MultiConnection_i();
01992   SMESH::MultiConnection_var anObj = aServant->_this();
01993   TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection()";
01994   return anObj._retn();
01995 }
01996 
01997 MultiConnection2D_ptr FilterManager_i::CreateMultiConnection2D()
01998 {
01999   SMESH::MultiConnection2D_i* aServant = new SMESH::MultiConnection2D_i();
02000   SMESH::MultiConnection2D_var anObj = aServant->_this();
02001   TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection2D()";
02002   return anObj._retn();
02003 }
02004 
02005 BelongToGeom_ptr FilterManager_i::CreateBelongToGeom()
02006 {
02007   SMESH::BelongToGeom_i* aServant = new SMESH::BelongToGeom_i();
02008   SMESH::BelongToGeom_var anObj = aServant->_this();
02009   TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGeom()";
02010   return anObj._retn();
02011 }
02012 
02013 BelongToPlane_ptr FilterManager_i::CreateBelongToPlane()
02014 {
02015   SMESH::BelongToPlane_i* aServant = new SMESH::BelongToPlane_i();
02016   SMESH::BelongToPlane_var anObj = aServant->_this();
02017   TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToPlane()";
02018   return anObj._retn();
02019 }
02020 
02021 BelongToCylinder_ptr FilterManager_i::CreateBelongToCylinder()
02022 {
02023   SMESH::BelongToCylinder_i* aServant = new SMESH::BelongToCylinder_i();
02024   SMESH::BelongToCylinder_var anObj = aServant->_this();
02025   TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToCylinder()";
02026   return anObj._retn();
02027 }
02028 
02029 BelongToGenSurface_ptr FilterManager_i::CreateBelongToGenSurface()
02030 {
02031   SMESH::BelongToGenSurface_i* aServant = new SMESH::BelongToGenSurface_i();
02032   SMESH::BelongToGenSurface_var anObj = aServant->_this();
02033   TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGenSurface()";
02034   return anObj._retn();
02035 }
02036 
02037 LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
02038 {
02039   SMESH::LyingOnGeom_i* aServant = new SMESH::LyingOnGeom_i();
02040   SMESH::LyingOnGeom_var anObj = aServant->_this();
02041   TPythonDump()<<aServant<<" = "<<this<<".CreateLyingOnGeom()";
02042   return anObj._retn();
02043 }
02044 
02045 CoplanarFaces_ptr FilterManager_i::CreateCoplanarFaces()
02046 {
02047   SMESH::CoplanarFaces_i* aServant = new SMESH::CoplanarFaces_i();
02048   SMESH::CoplanarFaces_var anObj = aServant->_this();
02049   TPythonDump()<<aServant<<" = "<<this<<".CreateCoplanarFaces()";
02050   return anObj._retn();
02051 }
02052 
02053 FreeBorders_ptr FilterManager_i::CreateFreeBorders()
02054 {
02055   SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
02056   SMESH::FreeBorders_var anObj = aServant->_this();
02057   TPythonDump()<<aServant<<" = "<<this<<".CreateFreeBorders()";
02058   return anObj._retn();
02059 }
02060 
02061 FreeEdges_ptr FilterManager_i::CreateFreeEdges()
02062 {
02063   SMESH::FreeEdges_i* aServant = new SMESH::FreeEdges_i();
02064   SMESH::FreeEdges_var anObj = aServant->_this();
02065   TPythonDump()<<aServant<<" = "<<this<<".CreateFreeEdges()";
02066   return anObj._retn();
02067 }
02068 
02069 FreeFaces_ptr FilterManager_i::CreateFreeFaces()
02070 {
02071   SMESH::FreeFaces_i* aServant = new SMESH::FreeFaces_i();
02072   SMESH::FreeFaces_var anObj = aServant->_this();
02073   TPythonDump()<<aServant<<" = "<<this<<".CreateFreeFaces()";
02074   return anObj._retn();
02075 }
02076 
02077 FreeNodes_ptr FilterManager_i::CreateFreeNodes()
02078 {
02079   SMESH::FreeNodes_i* aServant = new SMESH::FreeNodes_i();
02080   SMESH::FreeNodes_var anObj = aServant->_this();
02081   TPythonDump()<<aServant<<" = "<<this<<".CreateFreeNodes()";
02082   return anObj._retn();
02083 }
02084 
02085 RangeOfIds_ptr FilterManager_i::CreateRangeOfIds()
02086 {
02087   SMESH::RangeOfIds_i* aServant = new SMESH::RangeOfIds_i();
02088   SMESH::RangeOfIds_var anObj = aServant->_this();
02089   TPythonDump()<<aServant<<" = "<<this<<".CreateRangeOfIds()";
02090   return anObj._retn();
02091 }
02092 
02093 BadOrientedVolume_ptr FilterManager_i::CreateBadOrientedVolume()
02094 {
02095   SMESH::BadOrientedVolume_i* aServant = new SMESH::BadOrientedVolume_i();
02096   SMESH::BadOrientedVolume_var anObj = aServant->_this();
02097   TPythonDump()<<aServant<<" = "<<this<<".CreateBadOrientedVolume()";
02098   return anObj._retn();
02099 }
02100 
02101 BareBorderVolume_ptr FilterManager_i::CreateBareBorderVolume()
02102 {
02103   SMESH::BareBorderVolume_i* aServant = new SMESH::BareBorderVolume_i();
02104   SMESH::BareBorderVolume_var anObj = aServant->_this();
02105   TPythonDump()<<aServant<<" = "<<this<<".CreateBareBorderVolume()";
02106   return anObj._retn();
02107 }
02108 
02109 BareBorderFace_ptr FilterManager_i::CreateBareBorderFace()
02110 {
02111   SMESH::BareBorderFace_i* aServant = new SMESH::BareBorderFace_i();
02112   SMESH::BareBorderFace_var anObj = aServant->_this();
02113   TPythonDump()<<aServant<<" = "<<this<<".CreateBareBorderFace()";
02114   return anObj._retn();
02115 }
02116 
02117 OverConstrainedVolume_ptr FilterManager_i::CreateOverConstrainedVolume()
02118 {
02119   SMESH::OverConstrainedVolume_i* aServant = new SMESH::OverConstrainedVolume_i();
02120   SMESH::OverConstrainedVolume_var anObj = aServant->_this();
02121   TPythonDump()<<aServant<<" = "<<this<<".CreateOverConstrainedVolume()";
02122   return anObj._retn();
02123 }
02124 
02125 OverConstrainedFace_ptr FilterManager_i::CreateOverConstrainedFace()
02126 {
02127   SMESH::OverConstrainedFace_i* aServant = new SMESH::OverConstrainedFace_i();
02128   SMESH::OverConstrainedFace_var anObj = aServant->_this();
02129   TPythonDump()<<aServant<<" = "<<this<<".CreateOverConstrainedFace()";
02130   return anObj._retn();
02131 }
02132 
02133 LessThan_ptr FilterManager_i::CreateLessThan()
02134 {
02135   SMESH::LessThan_i* aServant = new SMESH::LessThan_i();
02136   SMESH::LessThan_var anObj = aServant->_this();
02137   TPythonDump()<<aServant<<" = "<<this<<".CreateLessThan()";
02138   return anObj._retn();
02139 }
02140 
02141 MoreThan_ptr FilterManager_i::CreateMoreThan()
02142 {
02143   SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
02144   SMESH::MoreThan_var anObj = aServant->_this();
02145   TPythonDump()<<aServant<<" = "<<this<<".CreateMoreThan()";
02146   return anObj._retn();
02147 }
02148 
02149 EqualTo_ptr FilterManager_i::CreateEqualTo()
02150 {
02151   SMESH::EqualTo_i* aServant = new SMESH::EqualTo_i();
02152   SMESH::EqualTo_var anObj = aServant->_this();
02153   TPythonDump()<<aServant<<" = "<<this<<".CreateEqualTo()";
02154   return anObj._retn();
02155 }
02156 
02157 LogicalNOT_ptr FilterManager_i::CreateLogicalNOT()
02158 {
02159   SMESH::LogicalNOT_i* aServant = new SMESH::LogicalNOT_i();
02160   SMESH::LogicalNOT_var anObj = aServant->_this();
02161   TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalNOT()";
02162   return anObj._retn();
02163 }
02164 
02165 LogicalAND_ptr FilterManager_i::CreateLogicalAND()
02166 {
02167   SMESH::LogicalAND_i* aServant = new SMESH::LogicalAND_i();
02168   SMESH::LogicalAND_var anObj = aServant->_this();
02169   TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalAND()";
02170   return anObj._retn();
02171 }
02172 
02173 LogicalOR_ptr FilterManager_i::CreateLogicalOR()
02174 {
02175   SMESH::LogicalOR_i* aServant = new SMESH::LogicalOR_i();
02176   SMESH::LogicalOR_var anObj = aServant->_this();
02177   TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalOR()";
02178   return anObj._retn();
02179 }
02180 
02181 LinearOrQuadratic_ptr FilterManager_i::CreateLinearOrQuadratic()
02182 {
02183   SMESH::LinearOrQuadratic_i* aServant = new SMESH::LinearOrQuadratic_i();
02184   SMESH::LinearOrQuadratic_var anObj = aServant->_this();
02185   TPythonDump()<<aServant<<" = "<<this<<".CreateLinearOrQuadratic()";
02186   return anObj._retn();
02187 }
02188 
02189 GroupColor_ptr FilterManager_i::CreateGroupColor()
02190 {
02191   SMESH::GroupColor_i* aServant = new SMESH::GroupColor_i();
02192   SMESH::GroupColor_var anObj = aServant->_this();
02193   TPythonDump()<<aServant<<" = "<<this<<".CreateGroupColor()";
02194   return anObj._retn();
02195 }
02196 
02197 ElemGeomType_ptr FilterManager_i::CreateElemGeomType()
02198 {
02199   SMESH::ElemGeomType_i* aServant = new SMESH::ElemGeomType_i();
02200   SMESH::ElemGeomType_var anObj = aServant->_this();
02201   TPythonDump()<<aServant<<" = "<<this<<".CreateElemGeomType()";
02202   return anObj._retn();
02203 }
02204 
02205 Filter_ptr FilterManager_i::CreateFilter()
02206 {
02207   SMESH::Filter_i* aServant = new SMESH::Filter_i();
02208   SMESH::Filter_var anObj = aServant->_this();
02209   TPythonDump()<<aServant<<" = "<<this<<".CreateFilter()";
02210   return anObj._retn();
02211 }
02212 
02213 FilterLibrary_ptr FilterManager_i::LoadLibrary( const char* aFileName )
02214 {
02215   SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i( aFileName );
02216   SMESH::FilterLibrary_var anObj = aServant->_this();
02217   TPythonDump()<<aServant<<" = "<<this<<".LoadLibrary('"<<aFileName<<"')";
02218   return anObj._retn();
02219 }
02220 
02221 FilterLibrary_ptr FilterManager_i::CreateLibrary()
02222 {
02223   SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i();
02224   SMESH::FilterLibrary_var anObj = aServant->_this();
02225   TPythonDump()<<aServant<<" = "<<this<<".CreateLibrary()";
02226   return anObj._retn();
02227 }
02228 
02229 CORBA::Boolean FilterManager_i::DeleteLibrary( const char* aFileName )
02230 {
02231   TPythonDump()<<this<<".DeleteLibrary("<<aFileName<<")";
02232   return remove( aFileName ) ? false : true;
02233 }
02234 
02235 //=============================================================================
02241 //=============================================================================
02242 
02243 SMESH::FilterManager_ptr SMESH_Gen_i::CreateFilterManager()
02244 {
02245   SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
02246   SMESH::FilterManager_var anObj = aFilter->_this();
02247   return anObj._retn();
02248 }
02249 
02250 
02251 /*
02252                               FILTER
02253 */
02254 
02255 //=======================================================================
02256 // name    : Filter_i::Filter_i
02257 // Purpose : Constructor
02258 //=======================================================================
02259 Filter_i::Filter_i()
02260 : myPredicate( NULL )
02261 {}
02262 
02263 //=======================================================================
02264 // name    : Filter_i::~Filter_i
02265 // Purpose : Destructor
02266 //=======================================================================
02267 Filter_i::~Filter_i()
02268 {
02269   if ( myPredicate )
02270     myPredicate->UnRegister();
02271 
02272   if(!CORBA::is_nil(myMesh))
02273     myMesh->UnRegister();
02274 
02275   //TPythonDump()<<this<<".UnRegister()";
02276 }
02277 
02278 //=======================================================================
02279 // name    : Filter_i::SetPredicate
02280 // Purpose : Set predicate
02281 //=======================================================================
02282 void Filter_i::SetPredicate( Predicate_ptr thePredicate )
02283 {
02284   if ( myPredicate )
02285     myPredicate->UnRegister();
02286 
02287   myPredicate = SMESH::GetPredicate(thePredicate);
02288 
02289   if ( myPredicate )
02290   {
02291     myFilter.SetPredicate( myPredicate->GetPredicate() );
02292     myPredicate->Register();
02293     TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
02294   }
02295 }
02296 
02297 //=======================================================================
02298 // name    : Filter_i::GetElementType
02299 // Purpose : Get entity type
02300 //=======================================================================
02301 SMESH::ElementType Filter_i::GetElementType()
02302 {
02303   return myPredicate != 0 ? myPredicate->GetElementType() : SMESH::ALL;
02304 }
02305 
02306 //=======================================================================
02307 // name    : Filter_i::SetMesh
02308 // Purpose : Set mesh
02309 //=======================================================================
02310 void
02311 Filter_i::
02312 SetMesh( SMESH_Mesh_ptr theMesh )
02313 {
02314   if(!CORBA::is_nil(theMesh))
02315     theMesh->Register();
02316 
02317   if(!CORBA::is_nil(myMesh))
02318     myMesh->UnRegister();
02319 
02320   myMesh = SMESH_Mesh::_duplicate( theMesh );
02321   TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
02322 }
02323 
02324 SMESH::long_array*
02325 Filter_i::
02326 GetIDs()
02327 {
02328   return GetElementsId(myMesh);
02329 }
02330 
02331 //=======================================================================
02332 // name    : Filter_i::GetElementsId
02333 // Purpose : Get ids of entities
02334 //=======================================================================
02335 void
02336 Filter_i::
02337 GetElementsId( Predicate_i* thePredicate,
02338                const SMDS_Mesh* theMesh,
02339                Controls::Filter::TIdSequence& theSequence )
02340 {
02341   if (thePredicate)
02342     Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
02343 }
02344 
02345 void
02346 Filter_i::
02347 GetElementsId( Predicate_i* thePredicate,
02348                SMESH_Mesh_ptr theMesh,
02349                Controls::Filter::TIdSequence& theSequence )
02350 {
02351   if (thePredicate) 
02352     if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
02353       Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence);
02354 }
02355 
02356 SMESH::long_array*
02357 Filter_i::
02358 GetElementsId( SMESH_Mesh_ptr theMesh )
02359 {
02360   SMESH::long_array_var anArray = new SMESH::long_array;
02361   if(!CORBA::is_nil(theMesh) && myPredicate){
02362     Controls::Filter::TIdSequence aSequence;
02363     GetElementsId(myPredicate,theMesh,aSequence);
02364     long i = 0, iEnd = aSequence.size();
02365     anArray->length( iEnd );
02366     for ( ; i < iEnd; i++ )
02367       anArray[ i ] = aSequence[i];
02368   }
02369   return anArray._retn();
02370 }
02371 
02372 template<class TElement, class TIterator, class TPredicate>
02373 static void collectMeshInfo(const TIterator& theItr,
02374                             TPredicate& thePred,
02375                             SMESH::long_array& theRes)
02376 {         
02377   if (!theItr)
02378     return;
02379   while (theItr->more()) {
02380     const SMDS_MeshElement* anElem = theItr->next();
02381     if ( thePred->IsSatisfy( anElem->GetID() ) )
02382       theRes[ anElem->GetEntityType() ]++;
02383   }
02384 }
02385 
02386 //=============================================================================
02390 //=============================================================================
02391 SMESH::long_array* ::Filter_i::GetMeshInfo()
02392 {
02393   SMESH::long_array_var aRes = new SMESH::long_array();
02394   aRes->length(SMESH::Entity_Last);
02395   for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++)
02396     aRes[i] = 0;
02397 
02398   if(!CORBA::is_nil(myMesh) && myPredicate) {
02399     const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh);
02400     SMDS_ElemIteratorPtr it;
02401     switch( GetElementType() )
02402     {
02403   case SMDSAbs_Node:
02404     collectMeshInfo<const SMDS_MeshNode*>(aMesh->nodesIterator(),myPredicate,aRes);
02405     break;
02406   case SMDSAbs_Edge:
02407     collectMeshInfo<const SMDS_MeshElement*>(aMesh->edgesIterator(),myPredicate,aRes);
02408     break;
02409   case SMDSAbs_Face:
02410     collectMeshInfo<const SMDS_MeshElement*>(aMesh->facesIterator(),myPredicate,aRes);
02411     break;
02412   case SMDSAbs_Volume:
02413     collectMeshInfo<const SMDS_MeshElement*>(aMesh->volumesIterator(),myPredicate,aRes);
02414     break;
02415   case SMDSAbs_All:
02416   default:
02417     collectMeshInfo<const SMDS_MeshElement*>(aMesh->elementsIterator(),myPredicate,aRes);
02418     break;
02419     }
02420   }
02421 
02422 
02423   return aRes._retn();  
02424 }
02425 
02426 //================================================================================
02431 //================================================================================
02432 
02433 SMESH::array_of_ElementType* Filter_i::GetTypes()
02434 {
02435   SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
02436   types->length( 1 );
02437   types[0] = GetElementType();
02438   return types._retn();
02439 }
02440 
02441 //=======================================================================
02442 //function : GetMesh
02443 //purpose  : Returns mesh
02444 //=======================================================================
02445 
02446 SMESH::SMESH_Mesh_ptr Filter_i::GetMesh()
02447 {
02448   return SMESH_Mesh::_duplicate( myMesh );
02449 }
02450 
02451 //=======================================================================
02452 // name    : getCriteria
02453 // Purpose : Retrieve criterions from predicate
02454 //=======================================================================
02455 static inline bool getCriteria( Predicate_i*                thePred,
02456                                 SMESH::Filter::Criteria_out theCriteria )
02457 {
02458   int aFType = thePred->GetFunctorType();
02459 
02460   switch ( aFType )
02461   {
02462   case FT_FreeBorders:
02463   case FT_FreeEdges:
02464   case FT_FreeFaces:
02465   case FT_LinearOrQuadratic:
02466   case FT_FreeNodes:
02467     {
02468       CORBA::ULong i = theCriteria->length();
02469       theCriteria->length( i + 1 );
02470 
02471       theCriteria[ i ] = createCriterion();
02472 
02473       theCriteria[ i ].Type = aFType;
02474       theCriteria[ i ].TypeOfElement = thePred->GetElementType();
02475       return true;
02476     }
02477   case FT_BelongToGeom:
02478     {
02479       BelongToGeom_i* aPred = dynamic_cast<BelongToGeom_i*>( thePred );
02480 
02481       CORBA::ULong i = theCriteria->length();
02482       theCriteria->length( i + 1 );
02483 
02484       theCriteria[ i ] = createCriterion();
02485 
02486       theCriteria[ i ].Type          = FT_BelongToGeom;
02487       theCriteria[ i ].ThresholdStr  = aPred->GetShapeName();
02488       theCriteria[ i ].ThresholdID   = aPred->GetShapeID();
02489       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02490       theCriteria[ i ].Tolerance     = aPred->GetTolerance();
02491 
02492       return true;
02493     }
02494   case FT_BelongToPlane:
02495   case FT_BelongToCylinder:
02496   case FT_BelongToGenSurface:
02497     {
02498       BelongToSurface_i* aPred = dynamic_cast<BelongToSurface_i*>( thePred );
02499 
02500       CORBA::ULong i = theCriteria->length();
02501       theCriteria->length( i + 1 );
02502 
02503       theCriteria[ i ] = createCriterion();
02504 
02505       theCriteria[ i ].Type          = aFType;
02506       theCriteria[ i ].ThresholdStr  = aPred->GetShapeName();
02507       theCriteria[ i ].ThresholdID   = aPred->GetShapeID();
02508       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02509       theCriteria[ i ].Tolerance     = aPred->GetTolerance();
02510 
02511       return true;
02512     }
02513    case FT_LyingOnGeom:
02514     {
02515       LyingOnGeom_i* aPred = dynamic_cast<LyingOnGeom_i*>( thePred );
02516 
02517       CORBA::ULong i = theCriteria->length();
02518       theCriteria->length( i + 1 );
02519 
02520       theCriteria[ i ] = createCriterion();
02521 
02522       theCriteria[ i ].Type          = FT_LyingOnGeom;
02523       theCriteria[ i ].ThresholdStr  = aPred->GetShapeName();
02524       theCriteria[ i ].ThresholdID   = aPred->GetShapeID();
02525       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02526       theCriteria[ i ].Tolerance     = aPred->GetTolerance();
02527 
02528       return true;
02529     }
02530    case FT_CoplanarFaces:
02531     {
02532       CoplanarFaces_i* aPred = dynamic_cast<CoplanarFaces_i*>( thePred );
02533 
02534       CORBA::ULong i = theCriteria->length();
02535       theCriteria->length( i + 1 );
02536 
02537       theCriteria[ i ] = createCriterion();
02538       CORBA::String_var faceId = aPred->GetFaceAsString();
02539 
02540       theCriteria[ i ].Type          = FT_CoplanarFaces;
02541       theCriteria[ i ].ThresholdID   = faceId;
02542       theCriteria[ i ].Tolerance     = aPred->GetTolerance();
02543 
02544       return true;
02545     }
02546   case FT_RangeOfIds:
02547     {
02548       RangeOfIds_i* aPred = dynamic_cast<RangeOfIds_i*>( thePred );
02549 
02550       CORBA::ULong i = theCriteria->length();
02551       theCriteria->length( i + 1 );
02552 
02553       theCriteria[ i ] = createCriterion();
02554 
02555       theCriteria[ i ].Type          = FT_RangeOfIds;
02556       theCriteria[ i ].ThresholdStr  = aPred->GetRangeStr();
02557       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02558 
02559       return true;
02560     }
02561   case FT_BadOrientedVolume:
02562     {
02563       BadOrientedVolume_i* aPred = dynamic_cast<BadOrientedVolume_i*>( thePred );
02564 
02565       CORBA::ULong i = theCriteria->length();
02566       theCriteria->length( i + 1 );
02567 
02568       theCriteria[ i ] = createCriterion();
02569 
02570       theCriteria[ i ].Type          = FT_BadOrientedVolume;
02571       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02572 
02573       return true;
02574     }
02575   case FT_BareBorderVolume:
02576     {
02577       BareBorderVolume_i* aPred = dynamic_cast<BareBorderVolume_i*>( thePred );
02578 
02579       CORBA::ULong i = theCriteria->length();
02580       theCriteria->length( i + 1 );
02581 
02582       theCriteria[ i ] = createCriterion();
02583 
02584       theCriteria[ i ].Type          = FT_BareBorderVolume;
02585       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02586 
02587       return true;
02588     }
02589   case FT_BareBorderFace:
02590     {
02591       BareBorderFace_i* aPred = dynamic_cast<BareBorderFace_i*>( thePred );
02592 
02593       CORBA::ULong i = theCriteria->length();
02594       theCriteria->length( i + 1 );
02595 
02596       theCriteria[ i ] = createCriterion();
02597 
02598       theCriteria[ i ].Type          = FT_BareBorderFace;
02599       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02600 
02601       return true;
02602     }
02603   case FT_OverConstrainedVolume:
02604     {
02605       OverConstrainedVolume_i* aPred = dynamic_cast<OverConstrainedVolume_i*>( thePred );
02606 
02607       CORBA::ULong i = theCriteria->length();
02608       theCriteria->length( i + 1 );
02609 
02610       theCriteria[ i ] = createCriterion();
02611 
02612       theCriteria[ i ].Type          = FT_OverConstrainedVolume;
02613       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02614 
02615       return true;
02616     }
02617   case FT_OverConstrainedFace:
02618     {
02619       OverConstrainedFace_i* aPred = dynamic_cast<OverConstrainedFace_i*>( thePred );
02620 
02621       CORBA::ULong i = theCriteria->length();
02622       theCriteria->length( i + 1 );
02623 
02624       theCriteria[ i ] = createCriterion();
02625 
02626       theCriteria[ i ].Type          = FT_OverConstrainedFace;
02627       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02628 
02629       return true;
02630     }
02631   case FT_LessThan:
02632   case FT_MoreThan:
02633   case FT_EqualTo:
02634     {
02635       Comparator_i* aCompar = dynamic_cast<Comparator_i*>( thePred );
02636 
02637       CORBA::ULong i = theCriteria->length();
02638       theCriteria->length( i + 1 );
02639 
02640       theCriteria[ i ] = createCriterion();
02641 
02642       theCriteria[ i ].Type      = aCompar->GetNumFunctor_i()->GetFunctorType();
02643       theCriteria[ i ].Compare   = aFType;
02644       theCriteria[ i ].Threshold = aCompar->GetMargin();
02645       theCriteria[ i ].TypeOfElement = aCompar->GetElementType();
02646 
02647       if ( aFType == FT_EqualTo )
02648       {
02649         EqualTo_i* aCompar = dynamic_cast<EqualTo_i*>( thePred );
02650         theCriteria[ i ].Tolerance = aCompar->GetTolerance();
02651       }
02652     }
02653     return true;
02654 
02655   case FT_LogicalNOT:
02656     {
02657       Predicate_i* aPred = ( dynamic_cast<LogicalNOT_i*>( thePred ) )->GetPredicate_i();
02658       getCriteria( aPred, theCriteria );
02659       theCriteria[ theCriteria->length() - 1 ].UnaryOp = FT_LogicalNOT;
02660     }
02661     return true;
02662 
02663   case FT_LogicalAND:
02664   case FT_LogicalOR:
02665     {
02666       Predicate_i* aPred1 = ( dynamic_cast<LogicalBinary_i*>( thePred ) )->GetPredicate1_i();
02667       Predicate_i* aPred2 = ( dynamic_cast<LogicalBinary_i*>( thePred ) )->GetPredicate2_i();
02668       if ( !getCriteria( aPred1, theCriteria ) )
02669         return false;
02670       theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType;
02671       return getCriteria( aPred2, theCriteria );
02672     }
02673   case FT_GroupColor:
02674     {
02675       CORBA::ULong i = theCriteria->length();
02676       theCriteria->length( i + 1 );
02677 
02678       theCriteria[ i ] = createCriterion();
02679 
02680       GroupColor_i* aPred = dynamic_cast<GroupColor_i*>( thePred );
02681       theCriteria[ i ].Type          = aFType;
02682       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02683       theCriteria[ i ].ThresholdStr  = aPred->GetColorStr();
02684 
02685       return true;
02686     }
02687   case FT_ElemGeomType:
02688     {
02689       CORBA::ULong i = theCriteria->length();
02690       theCriteria->length( i + 1 );
02691 
02692       theCriteria[ i ] = createCriterion();
02693 
02694       ElemGeomType_i* aPred = dynamic_cast<ElemGeomType_i*>( thePred );
02695       theCriteria[ i ].Type          = aFType;
02696       theCriteria[ i ].TypeOfElement = aPred->GetElementType();
02697       theCriteria[ i ].Threshold     = (double)aPred->GetGeometryType();
02698       return true;
02699     }
02700 
02701   case FT_Undefined:
02702     return false;
02703   default:
02704     return false;
02705   }
02706 }
02707 
02708 //=======================================================================
02709 // name    : Filter_i::GetCriteria
02710 // Purpose : Retrieve criterions from predicate
02711 //=======================================================================
02712 CORBA::Boolean Filter_i::GetCriteria( SMESH::Filter::Criteria_out theCriteria )
02713 {
02714   theCriteria = new SMESH::Filter::Criteria;
02715   return myPredicate != 0 ? getCriteria( myPredicate, theCriteria ) : true;
02716 }
02717 
02718 //=======================================================================
02719 // name    : Filter_i::SetCriteria
02720 // Purpose : Create new predicate and set criterions in it
02721 //=======================================================================
02722 CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria )
02723 {
02724   if ( myPredicate != 0 )
02725     myPredicate->UnRegister();
02726 
02727   SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
02728   FilterManager_ptr aFilterMgr = aFilter->_this();
02729 
02730   // CREATE two lists ( PREDICATES  and LOG OP )
02731 
02732   // Criterion
02733   TPythonDump()<<"aCriteria = []";
02734   std::list<SMESH::Predicate_ptr> aPredicates;
02735   std::list<int>                  aBinaries;
02736   for ( int i = 0, n = theCriteria.length(); i < n; i++ )
02737   {
02738     int         aCriterion    = theCriteria[ i ].Type;
02739     int         aCompare      = theCriteria[ i ].Compare;
02740     double      aThreshold    = theCriteria[ i ].Threshold;
02741     const char* aThresholdStr = theCriteria[ i ].ThresholdStr;
02742     const char* aThresholdID  = theCriteria[ i ].ThresholdID;
02743     int         aUnary        = theCriteria[ i ].UnaryOp;
02744     int         aBinary       = theCriteria[ i ].BinaryOp;
02745     double      aTolerance    = theCriteria[ i ].Tolerance;
02746     ElementType aTypeOfElem   = theCriteria[ i ].TypeOfElement;
02747     long        aPrecision    = theCriteria[ i ].Precision;
02748 
02749     {
02750       TPythonDump pd;
02751       pd << "aCriterion = SMESH.Filter.Criterion(" << aCriterion << "," << aCompare
02752          << "," << aThreshold << ",'" << aThresholdStr;
02753       if (aThresholdID && strlen(aThresholdID))
02754         //pd << "',salome.ObjectToID(" << aThresholdID
02755         pd << "','" << aThresholdID
02756            << "'," << aUnary << "," << aBinary << "," << aTolerance
02757            << "," << aTypeOfElem << "," << aPrecision << ")";
02758       else
02759         pd << "',''," << aUnary << "," << aBinary << "," << aTolerance
02760            << "," << aTypeOfElem << "," << aPrecision << ")";
02761     }
02762 
02763     SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil();
02764     SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil();
02765 
02766     switch ( aCriterion )
02767     {
02768       // Functors
02769 
02770       case SMESH::FT_MultiConnection:
02771         aFunctor = aFilterMgr->CreateMultiConnection();
02772         break;
02773       case SMESH::FT_MultiConnection2D:
02774         aFunctor = aFilterMgr->CreateMultiConnection2D();
02775         break;
02776       case SMESH::FT_Length:
02777         aFunctor = aFilterMgr->CreateLength();
02778         break;
02779       case SMESH::FT_Length2D:
02780         aFunctor = aFilterMgr->CreateLength2D();
02781         break;
02782       case SMESH::FT_AspectRatio:
02783         aFunctor = aFilterMgr->CreateAspectRatio();
02784         break;
02785       case SMESH::FT_AspectRatio3D:
02786         aFunctor = aFilterMgr->CreateAspectRatio3D();
02787         break;
02788       case SMESH::FT_Warping:
02789         aFunctor = aFilterMgr->CreateWarping();
02790         break;
02791       case SMESH::FT_MinimumAngle:
02792         aFunctor = aFilterMgr->CreateMinimumAngle();
02793         break;
02794       case SMESH::FT_Taper:
02795         aFunctor = aFilterMgr->CreateTaper();
02796         break;
02797       case SMESH::FT_Skew:
02798         aFunctor = aFilterMgr->CreateSkew();
02799         break;
02800       case SMESH::FT_Area:
02801         aFunctor = aFilterMgr->CreateArea();
02802         break;
02803       case SMESH::FT_Volume3D:
02804         aFunctor = aFilterMgr->CreateVolume3D();
02805         break;
02806       case SMESH::FT_MaxElementLength2D:
02807         aFunctor = aFilterMgr->CreateMaxElementLength2D();
02808         break;
02809       case SMESH::FT_MaxElementLength3D:
02810         aFunctor = aFilterMgr->CreateMaxElementLength3D();
02811         break;
02812 
02813       // Predicates
02814 
02815       case SMESH::FT_FreeBorders:
02816         aPredicate = aFilterMgr->CreateFreeBorders();
02817         break;
02818       case SMESH::FT_FreeEdges:
02819         aPredicate = aFilterMgr->CreateFreeEdges();
02820         break;
02821       case SMESH::FT_FreeFaces:
02822         aPredicate = aFilterMgr->CreateFreeFaces();
02823         break;
02824       case SMESH::FT_FreeNodes:
02825         aPredicate = aFilterMgr->CreateFreeNodes();
02826         break;
02827       case SMESH::FT_BelongToGeom:
02828         {
02829           SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom();
02830           tmpPred->SetElementType( aTypeOfElem );
02831           tmpPred->SetShape( aThresholdID, aThresholdStr );
02832           tmpPred->SetTolerance( aTolerance );
02833           aPredicate = tmpPred;
02834         }
02835         break;
02836       case SMESH::FT_BelongToPlane:
02837       case SMESH::FT_BelongToCylinder:
02838       case SMESH::FT_BelongToGenSurface:
02839         {
02840           SMESH::BelongToSurface_ptr tmpPred;
02841           switch ( aCriterion ) {
02842           case SMESH::FT_BelongToPlane:
02843             tmpPred = aFilterMgr->CreateBelongToPlane(); break;
02844           case SMESH::FT_BelongToCylinder:
02845             tmpPred = aFilterMgr->CreateBelongToCylinder(); break;
02846           default:
02847             tmpPred = aFilterMgr->CreateBelongToGenSurface();
02848           }
02849           tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem );
02850           tmpPred->SetTolerance( aTolerance );
02851           aPredicate = tmpPred;
02852         }
02853         break;
02854       case SMESH::FT_LyingOnGeom:
02855         {
02856           SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
02857           tmpPred->SetElementType( aTypeOfElem );
02858           tmpPred->SetShape( aThresholdID, aThresholdStr );
02859           tmpPred->SetTolerance( aTolerance );
02860           aPredicate = tmpPred;
02861         }
02862         break;
02863       case SMESH::FT_RangeOfIds:
02864         {
02865           SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds();
02866           tmpPred->SetRangeStr( aThresholdStr );
02867           tmpPred->SetElementType( aTypeOfElem );
02868           aPredicate = tmpPred;
02869         }
02870         break;
02871       case SMESH::FT_BadOrientedVolume:
02872         {
02873           aPredicate = aFilterMgr->CreateBadOrientedVolume();
02874         }
02875         break;
02876       case SMESH::FT_BareBorderVolume:
02877         {
02878           aPredicate = aFilterMgr->CreateBareBorderVolume();
02879         }
02880         break;
02881       case SMESH::FT_BareBorderFace:
02882         {
02883           aPredicate = aFilterMgr->CreateBareBorderFace();
02884         }
02885         break;
02886       case SMESH::FT_OverConstrainedVolume:
02887         {
02888           aPredicate = aFilterMgr->CreateOverConstrainedVolume();
02889         }
02890         break;
02891       case SMESH::FT_OverConstrainedFace:
02892         {
02893           aPredicate = aFilterMgr->CreateOverConstrainedFace();
02894         }
02895         break;
02896       case SMESH::FT_LinearOrQuadratic:
02897         {
02898           SMESH::LinearOrQuadratic_ptr tmpPred = aFilterMgr->CreateLinearOrQuadratic();
02899           tmpPred->SetElementType( aTypeOfElem );
02900           aPredicate = tmpPred;
02901           break;
02902         }
02903       case SMESH::FT_GroupColor:
02904         {
02905           SMESH::GroupColor_ptr tmpPred = aFilterMgr->CreateGroupColor();
02906           tmpPred->SetElementType( aTypeOfElem );
02907           tmpPred->SetColorStr( aThresholdStr );
02908           aPredicate = tmpPred;
02909           break;
02910         }
02911       case SMESH::FT_ElemGeomType:
02912         {
02913           SMESH::ElemGeomType_ptr tmpPred = aFilterMgr->CreateElemGeomType();
02914           tmpPred->SetElementType( aTypeOfElem );
02915           tmpPred->SetGeometryType( (GeometryType)(int)(aThreshold + 0.5) );
02916           aPredicate = tmpPred;
02917           break;
02918         }
02919       case SMESH::FT_CoplanarFaces:
02920         {
02921           SMESH::CoplanarFaces_ptr tmpPred = aFilterMgr->CreateCoplanarFaces();
02922           tmpPred->SetFace( atol (aThresholdID ));
02923           tmpPred->SetTolerance( aTolerance );
02924           aPredicate = tmpPred;
02925           break;
02926         }
02927 
02928       default:
02929         continue;
02930     }
02931 
02932     // Comparator
02933     if ( !aFunctor->_is_nil() && aPredicate->_is_nil() )
02934     {
02935       SMESH::Comparator_ptr aComparator = SMESH::Comparator::_nil();
02936 
02937       if ( aCompare == SMESH::FT_LessThan )
02938         aComparator = aFilterMgr->CreateLessThan();
02939       else if ( aCompare == SMESH::FT_MoreThan )
02940         aComparator = aFilterMgr->CreateMoreThan();
02941       else if ( aCompare == SMESH::FT_EqualTo )
02942         aComparator = aFilterMgr->CreateEqualTo();
02943       else
02944         continue;
02945 
02946       aComparator->SetNumFunctor( aFunctor );
02947       aComparator->SetMargin( aThreshold );
02948 
02949       if ( aCompare == FT_EqualTo )
02950       {
02951         SMESH::EqualTo_var anEqualTo = SMESH::EqualTo::_narrow( aComparator );
02952         anEqualTo->SetTolerance( aTolerance );
02953       }
02954 
02955       aPredicate = aComparator;
02956 
02957       aFunctor->SetPrecision( aPrecision );
02958     }
02959 
02960     // Logical not
02961     if ( aUnary == FT_LogicalNOT )
02962     {
02963       SMESH::LogicalNOT_ptr aNotPred = aFilterMgr->CreateLogicalNOT();
02964       aNotPred->SetPredicate( aPredicate );
02965       aPredicate = aNotPred;
02966     }
02967 
02968     // logical op
02969     aPredicates.push_back( aPredicate );
02970     aBinaries.push_back( aBinary );
02971     TPythonDump()<<"aCriteria.append(aCriterion)";
02972 
02973   } // end of for
02974   TPythonDump()<<this<<".SetCriteria(aCriteria)";
02975 
02976   // CREATE ONE PREDICATE FROM PREVIOUSLY CREATED MAP
02977 
02978   // combine all "AND" operations
02979 
02980   std::list<SMESH::Predicate_ptr> aResList;
02981 
02982   std::list<SMESH::Predicate_ptr>::iterator aPredIter;
02983   std::list<int>::iterator                  aBinaryIter;
02984 
02985   SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil();
02986   int aPrevBinary = SMESH::FT_Undefined;
02987 
02988   for ( aPredIter = aPredicates.begin(), aBinaryIter = aBinaries.begin();
02989         aPredIter != aPredicates.end() && aBinaryIter != aBinaries.end();
02990         ++aPredIter, ++aBinaryIter )
02991   {
02992     int aCurrBinary = *aBinaryIter;
02993 
02994     SMESH::Predicate_ptr aCurrPred = SMESH::Predicate::_nil();
02995 
02996     if ( aPrevBinary == SMESH::FT_LogicalAND )
02997     {
02998 
02999       SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalAND();
03000       aBinaryPred->SetPredicate1( aPrevPredicate );
03001       aBinaryPred->SetPredicate2( *aPredIter );
03002       aCurrPred = aBinaryPred;
03003     }
03004     else
03005       aCurrPred = *aPredIter;
03006 
03007     if ( aCurrBinary != SMESH::FT_LogicalAND )
03008       aResList.push_back( aCurrPred );
03009 
03010     aPrevPredicate = aCurrPred;
03011     aPrevBinary = aCurrBinary;
03012   }
03013 
03014   // combine all "OR" operations
03015 
03016   SMESH::Predicate_ptr aResPredicate = SMESH::Predicate::_nil();
03017 
03018   if ( aResList.size() == 1 )
03019     aResPredicate = *aResList.begin();
03020   else if ( aResList.size() > 1 )
03021   {
03022     std::list<SMESH::Predicate_ptr>::iterator anIter = aResList.begin();
03023     aResPredicate = *anIter;
03024     anIter++;
03025     for ( ; anIter != aResList.end(); ++anIter )
03026     {
03027       SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalOR();
03028       aBinaryPred->SetPredicate1( aResPredicate );
03029       aBinaryPred->SetPredicate2( *anIter );
03030       aResPredicate = aBinaryPred;
03031     }
03032   }
03033 
03034   SetPredicate( aResPredicate );
03035 
03036   return !aResPredicate->_is_nil();
03037 }
03038 
03039 //=======================================================================
03040 // name    : Filter_i::GetPredicate_i
03041 // Purpose : Get implementation of predicate
03042 //=======================================================================
03043 Predicate_i* Filter_i::GetPredicate_i()
03044 {
03045   return myPredicate;
03046 }
03047 
03048 //=======================================================================
03049 // name    : Filter_i::GetPredicate
03050 // Purpose : Get predicate
03051 //=======================================================================
03052 Predicate_ptr Filter_i::GetPredicate()
03053 {
03054   if ( myPredicate == 0 )
03055     return SMESH::Predicate::_nil();
03056   else
03057   {
03058     SMESH::Predicate_var anObj = myPredicate->_this();
03059     return anObj._retn();
03060   }
03061 }
03062 
03063 /*
03064                             FILTER LIBRARY
03065 */
03066 
03067 #define ATTR_TYPE          "type"
03068 #define ATTR_COMPARE       "compare"
03069 #define ATTR_THRESHOLD     "threshold"
03070 #define ATTR_UNARY         "unary"
03071 #define ATTR_BINARY        "binary"
03072 #define ATTR_THRESHOLD_STR "threshold_str"
03073 #define ATTR_TOLERANCE     "tolerance"
03074 #define ATTR_ELEMENT_TYPE  "ElementType"
03075 
03076 //=======================================================================
03077 // name    : toString
03078 // Purpose : Convert bool to LDOMString
03079 //=======================================================================
03080 static inline LDOMString toString( CORBA::Boolean val )
03081 {
03082   return val ? "logical not" : "";
03083 }
03084 
03085 //=======================================================================
03086 // name    : toBool
03087 // Purpose : Convert LDOMString to bool
03088 //=======================================================================
03089 static inline bool toBool( const LDOMString& theStr )
03090 {
03091   return theStr.equals( "logical not" );
03092 }
03093 
03094 //=======================================================================
03095 // name    : toString
03096 // Purpose : Convert double to LDOMString
03097 //=======================================================================
03098 static inline LDOMString toString( CORBA::Double val )
03099 {
03100   char a[ 255 ];
03101   sprintf( a, "%e", val );
03102   return LDOMString( a );
03103 }
03104 
03105 //=======================================================================
03106 // name    : toDouble
03107 // Purpose : Convert LDOMString to double
03108 //=======================================================================
03109 static inline double toDouble( const LDOMString& theStr )
03110 {
03111   return atof( theStr.GetString() );
03112 }
03113 
03114 //=======================================================================
03115 // name    : toString
03116 // Purpose : Convert functor type to LDOMString
03117 //=======================================================================
03118 static inline LDOMString toString( CORBA::Long theType )
03119 {
03120   switch ( theType )
03121   {
03122     case FT_AspectRatio     : return "Aspect ratio";
03123     case FT_Warping         : return "Warping";
03124     case FT_MinimumAngle    : return "Minimum angle";
03125     case FT_Taper           : return "Taper";
03126     case FT_Skew            : return "Skew";
03127     case FT_Area            : return "Area";
03128     case FT_Volume3D        : return "Volume3D";
03129     case FT_MaxElementLength2D: return "Max element length 2D";
03130     case FT_MaxElementLength3D: return "Max element length 3D";
03131     case FT_BelongToGeom    : return "Belong to Geom";
03132     case FT_BelongToPlane   : return "Belong to Plane";
03133     case FT_BelongToCylinder: return "Belong to Cylinder";
03134     case FT_BelongToGenSurface: return "Belong to Generic Surface";
03135     case FT_LyingOnGeom     : return "Lying on Geom";
03136     case FT_BadOrientedVolume:return "Bad Oriented Volume";
03137     case FT_BareBorderVolume: return "Volumes with bare border";
03138     case FT_BareBorderFace  : return "Faces with bare border";
03139     case FT_OverConstrainedVolume: return "Over-constrained Volumes";
03140     case FT_OverConstrainedFace  : return "Over-constrained Faces";
03141     case FT_RangeOfIds      : return "Range of IDs";
03142     case FT_FreeBorders     : return "Free borders";
03143     case FT_FreeEdges       : return "Free edges";
03144     case FT_FreeFaces       : return "Free faces";
03145     case FT_FreeNodes       : return "Free nodes";
03146     case FT_MultiConnection : return "Borders at multi-connections";
03147     case FT_MultiConnection2D: return "Borders at multi-connections 2D";
03148     case FT_Length          : return "Length";
03149     case FT_Length2D        : return "Length 2D";
03150     case FT_LessThan        : return "Less than";
03151     case FT_MoreThan        : return "More than";
03152     case FT_EqualTo         : return "Equal to";
03153     case FT_LogicalNOT      : return "Not";
03154     case FT_LogicalAND      : return "And";
03155     case FT_LogicalOR       : return "Or";
03156     case FT_GroupColor      : return "Color of Group";
03157     case FT_LinearOrQuadratic : return "Linear or Quadratic";
03158     case FT_ElemGeomType    : return "Element geomtry type";
03159     case FT_Undefined       : return "";
03160     default                 : return "";
03161   }
03162 }
03163 
03164 //=======================================================================
03165 // name    : toFunctorType
03166 // Purpose : Convert LDOMString to functor type
03167 //=======================================================================
03168 static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr )
03169 {
03170   if      ( theStr.equals( "Aspect ratio"                 ) ) return FT_AspectRatio;
03171   else if ( theStr.equals( "Warping"                      ) ) return FT_Warping;
03172   else if ( theStr.equals( "Minimum angle"                ) ) return FT_MinimumAngle;
03173   else if ( theStr.equals( "Taper"                        ) ) return FT_Taper;
03174   else if ( theStr.equals( "Skew"                         ) ) return FT_Skew;
03175   else if ( theStr.equals( "Area"                         ) ) return FT_Area;
03176   else if ( theStr.equals( "Volume3D"                     ) ) return FT_Volume3D;
03177   else if ( theStr.equals( "Max element length 2D"        ) ) return FT_MaxElementLength2D;
03178   else if ( theStr.equals( "Max element length 3D"        ) ) return FT_MaxElementLength3D;
03179   else if ( theStr.equals( "Belong to Geom"               ) ) return FT_BelongToGeom;
03180   else if ( theStr.equals( "Belong to Plane"              ) ) return FT_BelongToPlane;
03181   else if ( theStr.equals( "Belong to Cylinder"           ) ) return FT_BelongToCylinder;
03182   else if ( theStr.equals( "Belong to Generic Surface"    ) ) return FT_BelongToGenSurface;
03183   else if ( theStr.equals( "Lying on Geom"                ) ) return FT_LyingOnGeom;
03184   else if ( theStr.equals( "Free borders"                 ) ) return FT_FreeBorders;
03185   else if ( theStr.equals( "Free edges"                   ) ) return FT_FreeEdges;
03186   else if ( theStr.equals( "Free faces"                   ) ) return FT_FreeFaces;
03187   else if ( theStr.equals( "Free nodes"                   ) ) return FT_FreeNodes;
03188   else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection;
03189   //  else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D;
03190   else if ( theStr.equals( "Length"                       ) ) return FT_Length;
03191   //  else if ( theStr.equals( "Length2D"                     ) ) return FT_Length2D;
03192   else if ( theStr.equals( "Range of IDs"                 ) ) return FT_RangeOfIds;
03193   else if ( theStr.equals( "Bad Oriented Volume"          ) ) return FT_BadOrientedVolume;
03194   else if ( theStr.equals( "Volumes with bare border"     ) ) return FT_BareBorderVolume;
03195   else if ( theStr.equals( "Faces with bare border"       ) ) return FT_BareBorderFace;
03196   else if ( theStr.equals( "Over-constrained Volumes"     ) ) return FT_OverConstrainedVolume;
03197   else if ( theStr.equals( "Over-constrained Faces"       ) ) return FT_OverConstrainedFace;
03198   else if ( theStr.equals( "Less than"                    ) ) return FT_LessThan;
03199   else if ( theStr.equals( "More than"                    ) ) return FT_MoreThan;
03200   else if ( theStr.equals( "Equal to"                     ) ) return FT_EqualTo;
03201   else if ( theStr.equals( "Not"                          ) ) return FT_LogicalNOT;
03202   else if ( theStr.equals( "And"                          ) ) return FT_LogicalAND;
03203   else if ( theStr.equals( "Or"                           ) ) return FT_LogicalOR;
03204   else if ( theStr.equals( "Color of Group"               ) ) return FT_GroupColor;
03205   else if ( theStr.equals( "Linear or Quadratic"          ) ) return FT_LinearOrQuadratic;
03206   else if ( theStr.equals( "Element geomtry type"         ) ) return FT_ElemGeomType;
03207   else if ( theStr.equals( ""                             ) ) return FT_Undefined;
03208   else  return FT_Undefined;
03209 }
03210 
03211 //=======================================================================
03212 // name    : toFunctorType
03213 // Purpose : Convert LDOMString to value of ElementType enumeration
03214 //=======================================================================
03215 static inline SMESH::ElementType toElementType( const LDOMString& theStr )
03216 {
03217   if      ( theStr.equals( "NODE"   ) ) return SMESH::NODE;
03218   else if ( theStr.equals( "EDGE"   ) ) return SMESH::EDGE;
03219   else if ( theStr.equals( "FACE"   ) ) return SMESH::FACE;
03220   else if ( theStr.equals( "VOLUME" ) ) return SMESH::VOLUME;
03221   else                                  return SMESH::ALL;
03222 }
03223 
03224 //=======================================================================
03225 // name    : toString
03226 // Purpose : Convert ElementType to string
03227 //=======================================================================
03228 static inline LDOMString toString( const SMESH::ElementType theType )
03229 {
03230   switch ( theType )
03231   {
03232     case SMESH::NODE   : return "NODE";
03233     case SMESH::EDGE   : return "EDGE";
03234     case SMESH::FACE   : return "FACE";
03235     case SMESH::VOLUME : return "VOLUME";
03236     case SMESH::ALL    : return "ALL";
03237     default            : return "";
03238   }
03239 }
03240 
03241 //=======================================================================
03242 // name    : findFilter
03243 // Purpose : Find filter in document
03244 //=======================================================================
03245 static LDOM_Element findFilter( const char* theFilterName,
03246                                 const LDOM_Document& theDoc,
03247                                 LDOM_Node* theParent = 0 )
03248 {
03249   LDOM_Element aRootElement = theDoc.getDocumentElement();
03250   if ( aRootElement.isNull() || !aRootElement.hasChildNodes() )
03251     return LDOM_Element();
03252 
03253   for ( LDOM_Node aTypeNode = aRootElement.getFirstChild();
03254         !aTypeNode.isNull(); aTypeNode = aTypeNode.getNextSibling() )
03255   {
03256     for ( LDOM_Node aFilter = aTypeNode.getFirstChild();
03257           !aFilter.isNull(); aFilter = aFilter.getNextSibling() )
03258     {
03259       LDOM_Element* anElem = ( LDOM_Element* )&aFilter;
03260       if ( anElem->getTagName().equals( LDOMString( "filter" ) ) &&
03261            anElem->getAttribute( "name" ).equals( LDOMString( theFilterName ) ) )
03262       {
03263         if ( theParent != 0  )
03264           *theParent = aTypeNode;
03265         return (LDOM_Element&)aFilter;
03266       }
03267     }
03268   }
03269   return LDOM_Element();
03270 }
03271 
03272 //=======================================================================
03273 // name    : getSectionName
03274 // Purpose : Get name of section of filters
03275 //=======================================================================
03276 static const char* getSectionName( const ElementType theType )
03277 {
03278   switch ( theType )
03279   {
03280     case SMESH::NODE   : return "Filters for nodes";
03281     case SMESH::EDGE   : return "Filters for edges";
03282     case SMESH::FACE   : return "Filters for faces";
03283     case SMESH::VOLUME : return "Filters for volumes";
03284     case SMESH::ALL    : return "Filters for elements";
03285     default            : return "";
03286   }
03287 }
03288 
03289 //=======================================================================
03290 // name    : getSection
03291 // Purpose : Create section for filters corresponding to the entity type
03292 //=======================================================================
03293 static LDOM_Node getSection( const ElementType theType,
03294                              LDOM_Document&    theDoc,
03295                              const bool        toCreate = false )
03296 {
03297   LDOM_Element aRootElement = theDoc.getDocumentElement();
03298   if ( aRootElement.isNull() )
03299     return LDOM_Node();
03300 
03301   // Find section
03302   bool anExist = false;
03303   const char* aSectionName = getSectionName( theType );
03304   if ( strcmp( aSectionName, "" ) == 0 )
03305     return LDOM_Node();
03306 
03307   LDOM_NodeList aSections = theDoc.getElementsByTagName( "section" );
03308   LDOM_Node aNode;
03309   for ( int i = 0, n = aSections.getLength(); i < n; i++ )
03310   {
03311     aNode = aSections.item( i );
03312     LDOM_Element& anItem = ( LDOM_Element& )aNode;
03313     if ( anItem.getAttribute( "name" ).equals( LDOMString( aSectionName ) ) )
03314     {
03315       anExist = true;
03316       break;
03317     }
03318   }
03319 
03320   // Create new section if necessary
03321   if ( !anExist )
03322   {
03323     if ( toCreate )
03324     {
03325       LDOM_Element aNewItem = theDoc.createElement( "section" );
03326       aNewItem.setAttribute( "name", aSectionName );
03327       aRootElement.appendChild( aNewItem );
03328       return aNewItem;
03329     }
03330     else
03331       return LDOM_Node();
03332   }
03333   return
03334     aNode;
03335 }
03336 
03337 //=======================================================================
03338 // name    : createFilterItem
03339 // Purpose : Create filter item or LDOM document
03340 //=======================================================================
03341 static LDOM_Element createFilterItem( const char*       theName,
03342                                       SMESH::Filter_ptr theFilter,
03343                                       LDOM_Document&    theDoc )
03344 {
03345   // create new filter in document
03346   LDOM_Element aFilterItem = theDoc.createElement( "filter" );
03347   aFilterItem.setAttribute( "name", theName );
03348 
03349   // save filter criterions
03350   SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
03351 
03352   if ( !theFilter->GetCriteria( aCriteria ) )
03353     return LDOM_Element();
03354 
03355   for ( CORBA::ULong i = 0, n = aCriteria->length(); i < n; i++ )
03356   {
03357     LDOM_Element aCriterionItem = theDoc.createElement( "criterion" );
03358     
03359     aCriterionItem.setAttribute( ATTR_TYPE         , toString(  aCriteria[ i ].Type) );
03360     aCriterionItem.setAttribute( ATTR_COMPARE      , toString(  aCriteria[ i ].Compare ) );
03361     aCriterionItem.setAttribute( ATTR_THRESHOLD    , toString(  aCriteria[ i ].Threshold ) );
03362     aCriterionItem.setAttribute( ATTR_UNARY        , toString(  aCriteria[ i ].UnaryOp ) );
03363     aCriterionItem.setAttribute( ATTR_BINARY       , toString(  aCriteria[ i ].BinaryOp ) );
03364 
03365     aCriterionItem.setAttribute( ATTR_THRESHOLD_STR, (const char*)aCriteria[ i ].ThresholdStr );
03366     aCriterionItem.setAttribute( ATTR_TOLERANCE    , toString( aCriteria[ i ].Tolerance ) );
03367     aCriterionItem.setAttribute( ATTR_ELEMENT_TYPE ,
03368       toString( (SMESH::ElementType)aCriteria[ i ].TypeOfElement ) );
03369 
03370     aFilterItem.appendChild( aCriterionItem );
03371   }
03372 
03373   return aFilterItem;
03374 }
03375 
03376 //=======================================================================
03377 // name    : FilterLibrary_i::FilterLibrary_i
03378 // Purpose : Constructor
03379 //=======================================================================
03380 FilterLibrary_i::FilterLibrary_i( const char* theFileName )
03381 {
03382   myFileName = strdup( theFileName );
03383   SMESH::FilterManager_i* aFilterMgr = new SMESH::FilterManager_i();
03384   myFilterMgr = aFilterMgr->_this();
03385 
03386   LDOMParser aParser;
03387 
03388   // Try to use existing library file
03389   bool anExists = false;
03390   if ( !aParser.parse( myFileName ) )
03391   {
03392     myDoc = aParser.getDocument();
03393     anExists = true;
03394   }
03395   // Create a new XML document if it doesn't exist
03396   else
03397     myDoc = LDOM_Document::createDocument( LDOMString() );
03398 
03399   LDOM_Element aRootElement = myDoc.getDocumentElement();
03400   if ( aRootElement.isNull() )
03401   {
03402     // If the existing document is empty --> try to create a new one
03403     if ( anExists )
03404       myDoc = LDOM_Document::createDocument( LDOMString() );
03405   }
03406 }
03407 
03408 //=======================================================================
03409 // name    : FilterLibrary_i::FilterLibrary_i
03410 // Purpose : Constructor
03411 //=======================================================================
03412 FilterLibrary_i::FilterLibrary_i()
03413 {
03414   myFileName = 0;
03415   SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
03416   myFilterMgr = aFilter->_this();
03417 
03418   myDoc = LDOM_Document::createDocument( LDOMString() );
03419 }
03420 
03421 FilterLibrary_i::~FilterLibrary_i()
03422 {
03423   delete myFileName;
03424   //TPythonDump()<<this<<".UnRegister()";
03425 }
03426 
03427 //=======================================================================
03428 // name    : FilterLibrary_i::Copy
03429 // Purpose : Create filter and initialize it with values from library
03430 //=======================================================================
03431 Filter_ptr FilterLibrary_i::Copy( const char* theFilterName )
03432 {
03433   Filter_ptr aRes = Filter::_nil();
03434   LDOM_Node aFilter = findFilter( theFilterName, myDoc );
03435 
03436   if ( aFilter.isNull() )
03437     return aRes;
03438 
03439   std::list<SMESH::Filter::Criterion> aCriteria;
03440 
03441   for ( LDOM_Node aCritNode = aFilter.getFirstChild();
03442         !aCritNode.isNull() ; aCritNode = aCritNode.getNextSibling() )
03443   {
03444     LDOM_Element* aCrit = (LDOM_Element*)&aCritNode;
03445 
03446     const char* aTypeStr      = aCrit->getAttribute( ATTR_TYPE          ).GetString();
03447     const char* aCompareStr   = aCrit->getAttribute( ATTR_COMPARE       ).GetString();
03448     const char* aUnaryStr     = aCrit->getAttribute( ATTR_UNARY         ).GetString();
03449     const char* aBinaryStr    = aCrit->getAttribute( ATTR_BINARY        ).GetString();
03450     const char* anElemTypeStr = aCrit->getAttribute( ATTR_ELEMENT_TYPE  ).GetString();
03451 
03452     SMESH::Filter::Criterion aCriterion = createCriterion();
03453 
03454     aCriterion.Type          = toFunctorType( aTypeStr );
03455     aCriterion.Compare       = toFunctorType( aCompareStr );
03456     aCriterion.UnaryOp       = toFunctorType( aUnaryStr );
03457     aCriterion.BinaryOp      = toFunctorType( aBinaryStr );
03458 
03459     aCriterion.TypeOfElement = toElementType( anElemTypeStr );
03460 
03461     LDOMString str = aCrit->getAttribute( ATTR_THRESHOLD );
03462     int val = 0;
03463     aCriterion.Threshold = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val )
03464       ? val : atof( str.GetString() );
03465 
03466     str = aCrit->getAttribute( ATTR_TOLERANCE );
03467     aCriterion.Tolerance = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val )
03468       ? val : atof( str.GetString() );
03469 
03470     str = aCrit->getAttribute( ATTR_THRESHOLD_STR );
03471     if ( str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) )
03472     {
03473       char a[ 255 ];
03474       sprintf( a, "%d", val );
03475       aCriterion.ThresholdStr = strdup( a );
03476     }
03477     else
03478       aCriterion.ThresholdStr = str.GetString();
03479 
03480     aCriteria.push_back( aCriterion );
03481   }
03482 
03483   SMESH::Filter::Criteria_var aCriteriaVar = new SMESH::Filter::Criteria;
03484   aCriteriaVar->length( aCriteria.size() );
03485 
03486   CORBA::ULong i = 0;
03487   std::list<SMESH::Filter::Criterion>::iterator anIter = aCriteria.begin();
03488 
03489   for( ; anIter != aCriteria.end(); ++anIter )
03490     aCriteriaVar[ i++ ] = *anIter;
03491 
03492   aRes = myFilterMgr->CreateFilter();
03493   aRes->SetCriteria( aCriteriaVar.inout() );
03494 
03495   TPythonDump()<<this<<".Copy('"<<theFilterName<<"')";
03496 
03497   return aRes;
03498 }
03499 
03500 //=======================================================================
03501 // name    : FilterLibrary_i::SetFileName
03502 // Purpose : Set file name for library
03503 //=======================================================================
03504 void FilterLibrary_i::SetFileName( const char* theFileName )
03505 {
03506   delete myFileName;
03507   myFileName = strdup( theFileName );
03508   TPythonDump()<<this<<".SetFileName('"<<theFileName<<"')";
03509 }
03510 
03511 //=======================================================================
03512 // name    : FilterLibrary_i::GetFileName
03513 // Purpose : Get file name of library
03514 //=======================================================================
03515 char* FilterLibrary_i::GetFileName()
03516 {
03517   return CORBA::string_dup( myFileName );
03518 }
03519 
03520 //=======================================================================
03521 // name    : FilterLibrary_i::Add
03522 // Purpose : Add new filter to library
03523 //=======================================================================
03524 CORBA::Boolean FilterLibrary_i::Add( const char* theFilterName, Filter_ptr theFilter )
03525 {
03526   // if filter already in library or entry filter is null do nothing
03527   LDOM_Node aFilterNode = findFilter( theFilterName, myDoc );
03528   if ( !aFilterNode.isNull() || theFilter->_is_nil() )
03529     return false;
03530 
03531   // get section corresponding to the filter type
03532   ElementType anEntType = theFilter->GetElementType();
03533 
03534   LDOM_Node aSection = getSection( anEntType, myDoc, true );
03535   if ( aSection.isNull() )
03536     return false;
03537 
03538   // create filter item
03539   LDOM_Element aFilterItem = createFilterItem( theFilterName, theFilter, myDoc );
03540   if ( aFilterItem.isNull() )
03541     return false;
03542   else
03543   {
03544     aSection.appendChild( aFilterItem );
03545     if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
03546       TPythonDump()<<this<<".Add('"<<theFilterName<<"',"<<aFilter<<")";
03547     return true;
03548   }
03549 }
03550 
03551 //=======================================================================
03552 // name    : FilterLibrary_i::Add
03553 // Purpose : Add new filter to library
03554 //=======================================================================
03555 CORBA::Boolean FilterLibrary_i::AddEmpty( const char* theFilterName, ElementType theType )
03556 {
03557   // if filter already in library or entry filter is null do nothing
03558   LDOM_Node aFilterNode = findFilter( theFilterName, myDoc );
03559   if ( !aFilterNode.isNull() )
03560     return false;
03561 
03562   LDOM_Node aSection = getSection( theType, myDoc, true );
03563   if ( aSection.isNull() )
03564     return false;
03565 
03566   // create filter item
03567   Filter_var aFilter = myFilterMgr->CreateFilter();
03568 
03569   LDOM_Element aFilterItem = createFilterItem( theFilterName, aFilter, myDoc );
03570   if ( aFilterItem.isNull() )
03571     return false;
03572   else
03573   {
03574     aSection.appendChild( aFilterItem );
03575     TPythonDump()<<this<<".AddEmpty('"<<theFilterName<<"',"<<theType<<")";
03576     return true;
03577   }
03578 }
03579 
03580 //=======================================================================
03581 // name    : FilterLibrary_i::Delete
03582 // Purpose : Delete filter from library
03583 //=======================================================================
03584 CORBA::Boolean FilterLibrary_i::Delete ( const char* theFilterName )
03585 {
03586   LDOM_Node aParentNode;
03587   LDOM_Node aFilterNode = findFilter( theFilterName, myDoc, &aParentNode );
03588   if ( aFilterNode.isNull() || aParentNode.isNull() )
03589     return false;
03590 
03591   aParentNode.removeChild( aFilterNode );
03592   TPythonDump()<<this<<".Delete('"<<theFilterName<<"')";
03593   return true;
03594 }
03595 
03596 //=======================================================================
03597 // name      : FilterLibrary_i::Replace
03598 // Purpose   : Replace existing filter with entry filter.
03599 // IMPORTANT : If filter does not exist it is not created
03600 //=======================================================================
03601 CORBA::Boolean FilterLibrary_i::Replace( const char* theFilterName,
03602                                          const char* theNewName,
03603                                          Filter_ptr  theFilter )
03604 {
03605   LDOM_Element aFilterItem = findFilter( theFilterName, myDoc );
03606   if ( aFilterItem.isNull() || theFilter->_is_nil() )
03607     return false;
03608 
03609   LDOM_Element aNewItem = createFilterItem( theNewName, theFilter, myDoc );
03610   if ( aNewItem.isNull() )
03611     return false;
03612   else
03613   {
03614     aFilterItem.ReplaceElement( aNewItem );
03615     if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
03616       TPythonDump()<<this<<".Replace('"<<theFilterName<<"',"<<theNewName<<"',"<<aFilter<<")";
03617     return true;
03618   }
03619 }
03620 
03621 //=======================================================================
03622 // name    : FilterLibrary_i::Save
03623 // Purpose : Save library on disk
03624 //=======================================================================
03625 CORBA::Boolean FilterLibrary_i::Save()
03626 {
03627   if ( myFileName == 0 || strlen( myFileName ) == 0 )
03628     return false;
03629 
03630   FILE* aOutFile = fopen( myFileName, "wt" );
03631   if ( !aOutFile )
03632     return false;
03633 
03634   LDOM_XmlWriter aWriter( aOutFile );
03635   aWriter.SetIndentation( 2 );
03636   aWriter << myDoc;
03637   fclose( aOutFile );
03638 
03639   TPythonDump()<<this<<".Save()";
03640   return true;
03641 }
03642 
03643 //=======================================================================
03644 // name    : FilterLibrary_i::SaveAs
03645 // Purpose : Save library on disk
03646 //=======================================================================
03647 CORBA::Boolean FilterLibrary_i::SaveAs( const char* aFileName )
03648 {
03649   myFileName = strdup ( aFileName );
03650   TPythonDump()<<this<<".SaveAs('"<<aFileName<<"')";
03651   return Save();
03652 }
03653 
03654 //=======================================================================
03655 // name    : FilterLibrary_i::IsPresent
03656 // Purpose : Verify whether filter is in library
03657 //=======================================================================
03658 CORBA::Boolean FilterLibrary_i::IsPresent( const char* theFilterName )
03659 {
03660   return !findFilter( theFilterName, myDoc ).isNull();
03661 }
03662 
03663 //=======================================================================
03664 // name    : FilterLibrary_i::NbFilters
03665 // Purpose : Return amount of filters in library
03666 //=======================================================================
03667 CORBA::Long FilterLibrary_i::NbFilters( ElementType theType )
03668 {
03669   string_array_var aNames = GetNames( theType );
03670   return aNames->length();
03671 }
03672 
03673 //=======================================================================
03674 // name    : FilterLibrary_i::GetNames
03675 // Purpose : Get names of filters from library
03676 //=======================================================================
03677 string_array* FilterLibrary_i::GetNames( ElementType theType )
03678 {
03679   string_array_var anArray = new string_array;
03680   TColStd_SequenceOfHAsciiString aSeq;
03681 
03682   LDOM_Node aSection = getSection( theType, myDoc, false );
03683 
03684   if ( !aSection.isNull() )
03685   {
03686     for ( LDOM_Node aFilter = aSection.getFirstChild();
03687           !aFilter.isNull(); aFilter = aFilter.getNextSibling() )
03688     {
03689       LDOM_Element& anElem = ( LDOM_Element& )aFilter;
03690       aSeq.Append( new TCollection_HAsciiString(
03691          (Standard_CString)anElem.getAttribute( "name" ).GetString() ) );
03692     }
03693   }
03694 
03695   anArray->length( aSeq.Length() );
03696   for ( int i = 1, n = aSeq.Length(); i <= n; i++ )
03697     anArray[ i - 1 ] = CORBA::string_dup( aSeq( i )->ToCString() );
03698 
03699   return anArray._retn();
03700 }
03701 
03702 //=======================================================================
03703 // name    : FilterLibrary_i::GetAllNames
03704 // Purpose : Get names of filters from library
03705 //=======================================================================
03706 string_array* FilterLibrary_i::GetAllNames()
03707 {
03708   string_array_var aResArray = new string_array;
03709   for ( int type = SMESH::ALL; type <= SMESH::VOLUME; type++ )
03710   {
03711     SMESH::string_array_var aNames = GetNames( (SMESH::ElementType)type );
03712 
03713     int aPrevLength = aResArray->length();
03714     aResArray->length( aPrevLength + aNames->length() );
03715     for ( int i = 0, n = aNames->length(); i < n; i++ )
03716       aResArray[ aPrevLength + i ] = aNames[ i ];
03717   }
03718 
03719   return aResArray._retn();
03720 }
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS