1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
24 // File : SMESH_Group_i.cxx
25 // Author : Sergey ANIKIN, OCC
28 #include "SMESH_Group_i.hxx"
30 #include "SMDSAbs_ElementType.hxx"
31 #include "SMESHDS_Group.hxx"
32 #include "SMESHDS_GroupOnFilter.hxx"
33 #include "SMESHDS_GroupOnGeom.hxx"
34 #include "SMESH_Comment.hxx"
35 #include "SMESH_Filter_i.hxx"
36 #include "SMESH_Gen_i.hxx"
37 #include "SMESH_Group.hxx"
38 #include "SMESH_Mesh_i.hxx"
39 #include "SMESH_PythonDump.hxx"
40 #include "SMESH_PreMeshInfo.hxx"
42 #include CORBA_SERVER_HEADER(SMESH_Filter)
44 #include "utilities.h"
46 using namespace SMESH;
48 //=============================================================================
52 //=============================================================================
54 SMESH_GroupBase_i::SMESH_GroupBase_i( PortableServer::POA_ptr thePOA,
55 SMESH_Mesh_i* theMeshServant,
56 const int theLocalID )
57 : SALOME::GenericObj_i( thePOA ),
58 myMeshServant( theMeshServant ),
59 myLocalID( theLocalID ),
64 // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i,
65 // servant activation is performed by SMESH_Mesh_i::createGroup()
66 // thePOA->activate_object( this );
69 SMESH_Group_i::SMESH_Group_i( PortableServer::POA_ptr thePOA,
70 SMESH_Mesh_i* theMeshServant,
71 const int theLocalID )
72 : SALOME::GenericObj_i( thePOA ),
73 SMESH_GroupBase_i( thePOA, theMeshServant, theLocalID )
75 //MESSAGE("SMESH_Group_i; this = "<<this );
78 SMESH_GroupOnGeom_i::SMESH_GroupOnGeom_i( PortableServer::POA_ptr thePOA,
79 SMESH_Mesh_i* theMeshServant,
80 const int theLocalID )
81 : SALOME::GenericObj_i( thePOA ),
82 SMESH_GroupBase_i( thePOA, theMeshServant, theLocalID )
84 //MESSAGE("SMESH_GroupOnGeom_i; this = "<<this );
87 SMESH_GroupOnFilter_i::SMESH_GroupOnFilter_i( PortableServer::POA_ptr thePOA,
88 SMESH_Mesh_i* theMeshServant,
89 const int theLocalID )
90 : SALOME::GenericObj_i( thePOA ),
91 SMESH_GroupBase_i( thePOA, theMeshServant, theLocalID )
93 //MESSAGE("SMESH_GroupOnGeom_i; this = "<<this );
96 //=============================================================================
100 //=============================================================================
102 SMESH_GroupBase_i::~SMESH_GroupBase_i()
104 MESSAGE("~SMESH_GroupBase_i; this = "<<this );
106 myMeshServant->removeGroup(myLocalID);
108 if ( myPreMeshInfo ) delete myPreMeshInfo; myPreMeshInfo = NULL;
111 //=======================================================================
112 //function : GetSmeshGroup
114 //=======================================================================
116 ::SMESH_Group* SMESH_GroupBase_i::GetSmeshGroup() const
118 if ( myMeshServant ) {
119 ::SMESH_Mesh& aMesh = myMeshServant->GetImpl();
120 return aMesh.GetGroup(myLocalID);
125 //=======================================================================
126 //function : GetGroupDS
128 //=======================================================================
130 SMESHDS_GroupBase* SMESH_GroupBase_i::GetGroupDS() const
132 ::SMESH_Group* aGroup = GetSmeshGroup();
134 return aGroup->GetGroupDS();
138 //=============================================================================
142 //=============================================================================
144 void SMESH_GroupBase_i::SetName( const char* theName )
147 ::SMESH_Group* aGroup = GetSmeshGroup();
149 MESSAGE("can't set name of a vague group");
153 if ( aGroup->GetName() && !strcmp( aGroup->GetName(), theName ) )
154 return; // nothing to rename
156 aGroup->SetName(theName);
158 // Update group name in a study
159 SMESH_Gen_i* aGen = myMeshServant->GetGen();
160 aGen->SetName( aGen->ObjectToSObject( aGen->GetCurrentStudy(), _this() ), theName );
162 // Update Python script
163 TPythonDump() << _this() << ".SetName( '" << theName << "' )";
166 //=============================================================================
170 //=============================================================================
172 char* SMESH_GroupBase_i::GetName()
174 ::SMESH_Group* aGroup = GetSmeshGroup();
176 return CORBA::string_dup (aGroup->GetName());
177 MESSAGE("get name of a vague group");
178 return CORBA::string_dup( "NO_NAME" );
181 //=============================================================================
185 //=============================================================================
187 SMESH::ElementType SMESH_GroupBase_i::GetType()
189 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
191 SMDSAbs_ElementType aSMDSType = aGroupDS->GetType();
192 SMESH::ElementType aType;
194 case SMDSAbs_Node: aType = SMESH::NODE; break;
195 case SMDSAbs_Edge: aType = SMESH::EDGE; break;
196 case SMDSAbs_Face: aType = SMESH::FACE; break;
197 case SMDSAbs_Volume: aType = SMESH::VOLUME; break;
198 case SMDSAbs_0DElement: aType = SMESH::ELEM0D; break;
199 case SMDSAbs_Ball: aType = SMESH::BALL; break;
200 default: aType = SMESH::ALL; break;
204 MESSAGE("get type of a vague group");
209 //=============================================================================
213 //=============================================================================
215 CORBA::Long SMESH_GroupBase_i::Size()
218 return GetType() == SMESH::NODE ? myPreMeshInfo->NbNodes() : myPreMeshInfo->NbElements();
220 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
222 return aGroupDS->Extent();
223 MESSAGE("get size of a vague group");
227 //=============================================================================
231 //=============================================================================
233 CORBA::Boolean SMESH_GroupBase_i::IsEmpty()
238 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
240 return aGroupDS->IsEmpty();
241 MESSAGE("checking IsEmpty of a vague group");
245 //=============================================================================
249 //=============================================================================
251 void SMESH_Group_i::Clear()
254 myPreMeshInfo->FullLoadFromFile();
256 // Update Python script
257 TPythonDump() << _this() << ".Clear()";
260 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
265 MESSAGE("attempt to clear a vague group");
268 //=============================================================================
272 //=============================================================================
274 CORBA::Boolean SMESH_GroupBase_i::Contains( CORBA::Long theID )
277 myPreMeshInfo->FullLoadFromFile();
279 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
281 return aGroupDS->Contains(theID);
282 MESSAGE("attempt to check contents of a vague group");
286 //=============================================================================
290 //=============================================================================
292 CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs )
295 myPreMeshInfo->FullLoadFromFile();
297 // Update Python script
298 TPythonDump() << "nbAdd = " << _this() << ".Add( " << theIDs << " )";
300 // Add elements to the group
301 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
304 for (int i = 0; i < theIDs.length(); i++) {
305 int anID = (int) theIDs[i];
306 if (aGroupDS->Add(anID))
311 MESSAGE("attempt to add elements to a vague group");
315 //=============================================================================
319 //=============================================================================
321 CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
324 myPreMeshInfo->FullLoadFromFile();
326 // Update Python script
327 TPythonDump() << "nbDel = " << _this() << ".Remove( " << theIDs << " )";
329 // Remove elements from the group
330 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
333 for (int i = 0; i < theIDs.length(); i++) {
334 int anID = (int) theIDs[i];
335 if (aGroupDS->Remove(anID))
340 MESSAGE("attempt to remove elements from a vague group");
344 //=============================================================================
348 //=============================================================================
350 typedef bool (SMESHDS_Group::*TFunChangeGroup)(const int);
353 ChangeByPredicate( SMESH::Predicate_i* thePredicate,
354 SMESHDS_GroupBase* theGroupBase,
355 TFunChangeGroup theFun)
358 if(SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>(theGroupBase)){
359 SMESH::Controls::Filter::TIdSequence aSequence;
360 const SMDS_Mesh* aMesh = theGroupBase->GetMesh();
361 SMESH::Filter_i::GetElementsId(thePredicate,aMesh,aSequence);
363 CORBA::Long i = 0, iEnd = aSequence.size();
365 if((aGroupDS->*theFun)(aSequence[i]))
374 AddByPredicate( SMESH::Predicate_ptr thePredicate )
377 myPreMeshInfo->FullLoadFromFile();
379 if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
380 TPythonDump()<<_this()<<".AddByPredicate("<<aPredicate<<")";
381 return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Add);
388 RemoveByPredicate( SMESH::Predicate_ptr thePredicate )
391 myPreMeshInfo->FullLoadFromFile();
393 if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
394 TPythonDump()<<_this()<<".RemoveByPredicate("<<aPredicate<<")";
395 return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Remove);
400 CORBA::Long SMESH_Group_i::AddFrom( SMESH::SMESH_IDSource_ptr theSource )
403 myPreMeshInfo->FullLoadFromFile();
407 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
409 SMESH::long_array_var anIds;
410 SMESH::SMESH_GroupBase_var group = SMESH::SMESH_GroupBase::_narrow(theSource);
411 SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow(theSource);
412 SMESH::SMESH_subMesh_var submesh = SMESH::SMESH_subMesh::_narrow(theSource);
413 SMESH::Filter_var filter = SMESH::Filter::_narrow(theSource);
414 if ( !group->_is_nil())
415 anIds = group->GetType()==GetType() ? theSource->GetIDs() : new SMESH::long_array();
416 else if ( !mesh->_is_nil() )
417 anIds = mesh->GetElementsByType( GetType() );
418 else if ( !submesh->_is_nil())
419 anIds = submesh->GetElementsByType( GetType() );
420 else if ( !filter->_is_nil() ) {
421 filter->SetMesh( GetMeshServant()->_this() );
422 anIds = filter->GetElementType()==GetType() ? theSource->GetIDs() : new SMESH::long_array();
425 anIds = theSource->GetIDs();
426 for ( int i = 0, total = anIds->length(); i < total; i++ ) {
427 if ( aGroupDS->Add((int)anIds[i]) ) nbAdd++;
431 // Update Python script
432 pd << "nbAdd = " << _this() << ".AddFrom( " << theSource << " )";
437 //=============================================================================
441 //=============================================================================
443 CORBA::Long SMESH_GroupBase_i::GetID( CORBA::Long theIndex )
446 myPreMeshInfo->FullLoadFromFile();
448 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
450 return aGroupDS->GetID(theIndex);
451 MESSAGE("attempt to iterate on a vague group");
455 //=============================================================================
459 //=============================================================================
461 SMESH::long_array* SMESH_GroupBase_i::GetListOfID()
464 myPreMeshInfo->FullLoadFromFile();
466 SMESH::long_array_var aRes = new SMESH::long_array();
467 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
470 int aSize = aGroupDS->Extent();
472 for (int i = 0; i < aSize; i++)
473 aRes[i] = aGroupDS->GetID(i+1);
475 if ( 0 < aSize && aSize < 100 ) // for comfortable testing ;)
476 std::sort( &aRes[0], &aRes[0]+aSize );
478 MESSAGE("get list of IDs of a vague group");
484 //================================================================================
486 * \brief return nodes of elements pointered by iterator
488 //================================================================================
490 void getNodesOfElements(SMDS_ElemIteratorPtr elemIt,
491 set<const SMDS_MeshNode* >& nodes)
493 while ( elemIt->more() )
495 const SMDS_MeshElement* e = elemIt->next();
496 nodes.insert( e->begin_nodes(), e->end_nodes() );
501 //================================================================================
503 * \brief return the number of nodes of cells included to the group
505 //================================================================================
507 CORBA::Long SMESH_GroupBase_i::GetNumberOfNodes()
509 if ( GetType() == SMESH::NODE )
513 myPreMeshInfo->FullLoadFromFile();
515 if ( SMESHDS_GroupBase* g = GetGroupDS())
517 if ( myNbNodes < 0 || g->GetTic() != myGroupDSTic )
519 set<const SMDS_MeshNode* > nodes;
520 getNodesOfElements( g->GetElements(), nodes );
521 myNbNodes = nodes.size();
522 myGroupDSTic = g->GetTic();
528 //================================================================================
530 * \brief Return true if GetNumberOfNodes() won't take a long time for computation
532 //================================================================================
534 CORBA::Boolean SMESH_GroupBase_i::IsNodeInfoAvailable()
536 if ( GetType() == SMESH::NODE/* || Size() < 100000 */)
540 if ( SMESHDS_GroupBase* g = GetGroupDS())
541 return ( myNbNodes > -1 && g->GetTic() == myGroupDSTic);
545 //================================================================================
547 * \brief Return IDs of nodes of cells included to the group
549 //================================================================================
551 SMESH::long_array* SMESH_GroupBase_i::GetNodeIDs()
553 if ( GetType() == SMESH::NODE )
554 return GetListOfID();
557 myPreMeshInfo->FullLoadFromFile();
559 SMESH::long_array_var aRes = new SMESH::long_array();
560 if ( SMESHDS_GroupBase* g = GetGroupDS())
562 set<const SMDS_MeshNode* > nodes;
563 getNodesOfElements( g->GetElements(), nodes );
564 aRes->length( nodes.size() );
565 set<const SMDS_MeshNode*>::iterator nIt = nodes.begin(), nEnd = nodes.end();
566 for ( int i = 0; nIt != nEnd; ++nIt, ++i )
567 aRes[i] = (*nIt)->GetID();
572 //=============================================================================
576 //=============================================================================
577 SMESH::SMESH_Mesh_ptr SMESH_GroupBase_i::GetMesh()
579 SMESH::SMESH_Mesh_var aMesh;
581 aMesh = SMESH::SMESH_Mesh::_narrow( myMeshServant->_this() );
582 return aMesh._retn();
585 //=======================================================================
586 //function : GetShape
588 //=======================================================================
590 GEOM::GEOM_Object_ptr SMESH_GroupOnGeom_i::GetShape()
592 GEOM::GEOM_Object_var aGeomObj;
593 SMESHDS_GroupOnGeom* aGroupDS = dynamic_cast<SMESHDS_GroupOnGeom*>( GetGroupDS() );
595 SMESH_Gen_i* aGen = GetMeshServant()->GetGen();
596 aGeomObj = aGen->ShapeToGeomObject( aGroupDS->GetShape() );
598 return aGeomObj._retn();
601 //=============================================================================
605 //=============================================================================
606 SALOMEDS::Color SMESH_GroupBase_i::GetColor()
608 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
611 Quantity_Color aQColor = aGroupDS->GetColor();
612 SALOMEDS::Color aColor;
613 aColor.R = aQColor.Red();
614 aColor.G = aQColor.Green();
615 aColor.B = aQColor.Blue();
619 MESSAGE("get color of a group");
620 return SALOMEDS::Color();
623 //=============================================================================
627 //=============================================================================
628 void SMESH_GroupBase_i::SetColor(const SALOMEDS::Color& color)
630 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
633 Quantity_Color aQColor( color.R, color.G, color.B, Quantity_TOC_RGB );
634 Quantity_Color oldColor = aGroupDS->GetColor();
635 if ( oldColor != aQColor )
637 aGroupDS->SetColor(aQColor);
638 TPythonDump()<<_this()<<".SetColor( SALOMEDS.Color( "<<color.R<<", "<<color.G<<", "<<color.B<<" ))";
643 //=============================================================================
647 //=============================================================================
648 CORBA::Long SMESH_GroupBase_i::GetColorNumber()
650 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
652 return aGroupDS->GetColorGroup();
653 MESSAGE("get color number of a group");
657 //=============================================================================
661 //=============================================================================
662 void SMESH_GroupBase_i::SetColorNumber(CORBA::Long color)
664 SMESHDS_GroupBase* aGroupDS = GetGroupDS();
667 aGroupDS->SetColorGroup(color);
668 TPythonDump()<<_this()<<".SetColorNumber( "<<color<<" )";
670 MESSAGE("set color number of a group");
674 //=============================================================================
676 * Returns statistic of mesh elements
677 * Result array of number enityties
678 * Inherited from SMESH_IDSource
680 //=============================================================================
681 SMESH::long_array* SMESH_GroupBase_i::GetMeshInfo()
684 return myPreMeshInfo->GetMeshInfo();
686 SMESH::long_array_var aRes = new SMESH::long_array();
687 aRes->length(SMESH::Entity_Last);
688 for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++)
691 if ( SMESHDS_GroupBase* g = GetGroupDS())
693 if ( g->GetType() == SMDSAbs_Node || ( myNbNodes > -1 && g->GetTic() == myGroupDSTic))
694 aRes[ SMDSEntity_Node ] = GetNumberOfNodes();
696 if ( g->GetType() != SMDSAbs_Node )
697 SMESH_Mesh_i::CollectMeshInfo( g->GetElements(), aRes);
703 //=======================================================================
705 //purpose : Returns ids of members
706 //=======================================================================
708 SMESH::long_array* SMESH_GroupBase_i::GetIDs()
710 return GetListOfID();
713 //=======================================================================
714 //function : GetTypes
715 //purpose : Returns types of elements it contains
716 //=======================================================================
718 SMESH::array_of_ElementType* SMESH_GroupBase_i::GetTypes()
720 SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
724 types[0] = GetType();
726 return types._retn();
729 //=======================================================================
730 //function : IsMeshInfoCorrect
731 //purpose : * Returns false if GetMeshInfo() returns incorrect information that may
732 // * happen if mesh data is not yet fully loaded from the file of study.
733 //=======================================================================
735 bool SMESH_GroupBase_i::IsMeshInfoCorrect()
737 return myPreMeshInfo ? myPreMeshInfo->IsMeshInfoCorrect() : true;
740 //================================================================================
742 * \brief Retrieves the predicate from the filter
744 //================================================================================
746 SMESH_PredicatePtr SMESH_GroupOnFilter_i::GetPredicate( SMESH::Filter_ptr filter )
748 SMESH_PredicatePtr predicate;
750 if ( SMESH::Filter_i* filt_i = SMESH::DownCast< SMESH::Filter_i* >( filter ))
751 if ( SMESH::Predicate_i* predic_i= filt_i->GetPredicate_i() )
752 predicate = predic_i->GetPredicate();
757 //================================================================================
759 * \brief Sets the filter defining group contents
761 //================================================================================
763 void SMESH_GroupOnFilter_i::SetFilter(SMESH::Filter_ptr theFilter)
766 myPreMeshInfo->FullLoadFromFile();
768 if ( ! myFilter->_is_nil() )
769 myFilter->UnRegister();
771 myFilter = SMESH::Filter::_duplicate( theFilter );
773 if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() ))
774 grDS->SetPredicate( GetPredicate( myFilter ));
776 TPythonDump()<< _this() <<".SetFilter( "<<theFilter<<" )";
780 myFilter->Register();
781 SMESH::DownCast< SMESH::Filter_i* >( myFilter )->AddWaiter( this );
785 //================================================================================
787 * \brief Returns the filter defining group contents
789 //================================================================================
791 SMESH::Filter_ptr SMESH_GroupOnFilter_i::GetFilter()
793 SMESH::Filter_var f = myFilter;
794 TPythonDump() << f << " = " << _this() << ".GetFilter()";
800 //================================================================================
802 * \brief Return a string to be used to store group definition in the study
804 //================================================================================
806 std::string SMESH_GroupOnFilter_i::FilterToString() const
808 SMESH_Comment result;
809 SMESH::Filter::Criteria_var criteria;
810 if ( !myFilter->_is_nil() && myFilter->GetCriteria( criteria.out() ))
812 result << criteria->length() << SEPAR;
813 for ( unsigned i = 0; i < criteria->length(); ++i )
815 // write FunctorType as string but not as number to assure correct
816 // persistence if enum FunctorType is modified by insertion in the middle
817 SMESH::Filter::Criterion& crit = criteria[ i ];
818 result << SMESH::FunctorTypeToString( SMESH::FunctorType( crit.Type )) << SEPAR;
819 result << SMESH::FunctorTypeToString( SMESH::FunctorType( crit.Compare )) << SEPAR;
820 result << crit.Threshold << SEPAR;
821 result << crit.ThresholdStr << SEPAR;
822 result << crit.ThresholdID << SEPAR;
823 result << SMESH::FunctorTypeToString( SMESH::FunctorType( crit.UnaryOp )) << SEPAR;
824 result << SMESH::FunctorTypeToString( SMESH::FunctorType( crit.BinaryOp ))<< SEPAR;
825 result << crit.Tolerance << SEPAR;
826 result << crit.TypeOfElement << SEPAR;
827 result << crit.Precision << SEPAR;
833 //================================================================================
835 * \brief Restore the filter by the persistent string
837 //================================================================================
839 SMESH::Filter_ptr SMESH_GroupOnFilter_i::StringToFilter(const std::string& thePersistStr )
841 SMESH::Filter_var filter;
843 // divide thePersistStr into sub-strings
844 std::vector< std::string > strVec;
845 std::string::size_type from = 0, to;
846 while ( from < thePersistStr.size() )
848 to = thePersistStr.find( SEPAR, from );
849 if ( to == std::string::npos )
851 strVec.push_back( thePersistStr.substr( from, to-from ));
854 if ( strVec.empty() || strVec[0] == "0" )
855 return filter._retn();
859 int nbCrit = atoi( strVec[0].c_str() );
860 SMESH::Filter::Criteria_var criteria = new SMESH::Filter::Criteria;
861 criteria->length( nbCrit );
862 int nbStrPerCrit = ( strVec.size() - 1 ) / nbCrit;
863 for ( int i = 0; i < nbCrit; ++i )
865 SMESH::Filter::Criterion& crit = criteria[ i ];
866 int iStr = 1 + i * nbStrPerCrit;
867 crit.Type = SMESH::StringToFunctorType( strVec[ iStr++ ].c_str() );
868 crit.Compare = SMESH::StringToFunctorType( strVec[ iStr++ ].c_str() );
869 crit.Threshold = atof( strVec[ iStr++ ].c_str() );
870 crit.ThresholdStr = strVec[ iStr++ ].c_str();
871 crit.ThresholdID = strVec[ iStr++ ].c_str();
872 crit.UnaryOp = SMESH::StringToFunctorType( strVec[ iStr++ ].c_str() );
873 crit.BinaryOp = SMESH::StringToFunctorType( strVec[ iStr++ ].c_str() );
874 crit.Tolerance = atof( strVec[ iStr++ ].c_str() );
875 crit.TypeOfElement= SMESH::ElementType( atoi( strVec[ iStr++ ].c_str() ));
876 crit.Precision = atoi( strVec[ iStr++ ].c_str() );
881 SMESH::FilterManager_i* aFilterMgr = new SMESH::FilterManager_i();
882 filter = aFilterMgr->CreateFilter();
883 filter->SetCriteria( criteria.inout() );
885 aFilterMgr->UnRegister();
887 pd << ""; // to avoid optimizing pd out
889 return filter._retn();
892 //================================================================================
894 * \brief Destructor of SMESH_GroupOnFilter_i
896 //================================================================================
898 SMESH_GroupOnFilter_i::~SMESH_GroupOnFilter_i()
900 if ( ! myFilter->_is_nil() )
902 SMESH::DownCast< SMESH::Filter_i* >( myFilter )->RemoveWaiter( this );
903 myFilter->UnRegister();
907 //================================================================================
909 * \brief Method calleds when a predicate of myFilter changes
911 //================================================================================
913 void SMESH_GroupOnFilter_i::PredicateChanged()
916 myPreMeshInfo->FullLoadFromFile();
918 if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() ))
919 grDS->SetPredicate( GetPredicate( myFilter ));