X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Filter_i.cxx;h=e52d29b558c5259311793762df8a11de1961aa31;hb=3ecdf53dff60a9fd77128cfdb792dc18705f74a8;hp=ac5273396741e51615d7d3a25b0a1526ce7df638;hpb=7aebb99e42c6b0c3c056a5eecb0f29033db2231a;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index ac5273396..e52d29b55 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -18,6 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses // File : SMESH_Filter_i.cxx @@ -32,9 +33,11 @@ #include "SMDS_MeshNode.hxx" #include "SMESHDS_Mesh.hxx" #include "SMESH_Gen_i.hxx" +#include "SMESH_Group_i.hxx" #include "SMESH_PythonDump.hxx" #include +#include #include #include @@ -586,12 +589,63 @@ SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals, COR std::vector elements; myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic); -#ifdef WIN32 - nbIntervals = CORBA::Short( min( nbEvents.size(), funValues.size() - 1)); -#else - nbIntervals = CORBA::Short( std::min( nbEvents.size(), funValues.size() - 1)); -#endif SMESH::Histogram_var histogram = new SMESH::Histogram; + + nbIntervals = CORBA::Short( Min( int( nbEvents.size()), + int( funValues.size() - 1 ))); + if ( nbIntervals > 0 ) + { + histogram->length( nbIntervals ); + for ( int i = 0; i < nbIntervals; ++i ) + { + HistogramRectangle& rect = histogram[i]; + rect.nbEvents = nbEvents[i]; + rect.min = funValues[i]; + rect.max = funValues[i+1]; + } + } + return histogram._retn(); +} + +SMESH::Histogram* NumericalFunctor_i::GetLocalHistogram(CORBA::Short nbIntervals, + CORBA::Boolean isLogarithmic, + SMESH::SMESH_IDSource_ptr object) +{ + SMESH::Histogram_var histogram = new SMESH::Histogram; + + std::vector nbEvents; + std::vector funValues; + std::vector elements; + + SMDS_ElemIteratorPtr elemIt; + if ( SMESH::DownCast< SMESH_GroupOnFilter_i* >( object ) || + SMESH::DownCast< SMESH::Filter_i* >( object )) + { + elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() ); + } + else + { + SMESH::SMESH_Mesh_var mesh = object->GetMesh(); + SMESH::long_array_var objNbElems = object->GetNbElementsByType(); + SMESH::long_array_var meshNbElems = mesh-> GetNbElementsByType(); + if ( meshNbElems[ GetElementType() ] != + objNbElems [ GetElementType() ] ) + { + elements.reserve( objNbElems[ GetElementType() ]); + elemIt = SMESH_Mesh_i::GetElements( object, GetElementType() ); + } + } + if ( elemIt ) + { + while ( elemIt->more() ) + elements.push_back( elemIt->next()->GetID() ); + if ( elements.empty() ) return histogram._retn(); + } + + myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic); + + nbIntervals = CORBA::Short( Min( int( nbEvents.size()), + int( funValues.size() - 1 ))); if ( nbIntervals > 0 ) { histogram->length( nbIntervals ); @@ -918,6 +972,29 @@ CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId ) return myPredicatePtr->IsSatisfy( theId ); } +CORBA::Long Predicate_i::NbSatisfying( SMESH::SMESH_IDSource_ptr obj ) +{ + SMESH::SMESH_Mesh_var meshVar = obj->GetMesh(); + const SMDS_Mesh* meshDS = MeshPtr2SMDSMesh( meshVar ); + if ( !meshDS ) + return 0; + myPredicatePtr->SetMesh( meshDS ); + + SMDSAbs_ElementType elemType = SMDSAbs_ElementType( GetElementType() ); + + int nb = 0; + SMDS_ElemIteratorPtr elemIt = + SMESH::DownCast( meshVar )->GetElements( obj, GetElementType() ); + if ( elemIt ) + while ( elemIt->more() ) + { + const SMDS_MeshElement* e = elemIt->next(); + if ( e && e->GetType() == elemType ) + nb += myPredicatePtr->IsSatisfy( e->GetID() ); + } + return nb; +} + Controls::PredicatePtr Predicate_i::GetPredicate() { return myPredicatePtr; @@ -1710,6 +1787,172 @@ FunctorType CoplanarFaces_i::GetFunctorType() return SMESH::FT_CoplanarFaces; } +/* + * Class : ConnectedElements_i + * Description : Returns true if an element is connected via other elements to the element + * located at a given point. + */ +ConnectedElements_i::ConnectedElements_i() +{ + myConnectedElementsPtr.reset(new Controls::ConnectedElements()); + myFunctorPtr = myPredicatePtr = myConnectedElementsPtr; +} + +FunctorType ConnectedElements_i::GetFunctorType() +{ + return FT_ConnectedElements; +} + +void ConnectedElements_i::SetElementType( ElementType theType ) +{ + myConnectedElementsPtr->SetType( SMDSAbs_ElementType( theType )); + TPythonDump() << this << ".SetElementType( " << theType << " )"; +} + +void ConnectedElements_i::SetPoint( CORBA::Double x, CORBA::Double y, CORBA::Double z ) +{ + myConnectedElementsPtr->SetPoint( x,y,z ); + myVertexID.clear(); + TPythonDump() << this << ".SetPoint( " << x << ", " << y << ", " << z << " )"; +} + +void ConnectedElements_i::SetVertex( GEOM::GEOM_Object_ptr vertex ) + throw (SALOME::SALOME_Exception) +{ + TopoDS_Shape shape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( vertex ); + if ( shape.IsNull() ) + THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetVertex(): NULL Vertex", + SALOME::BAD_PARAM ); + + TopExp_Explorer v( shape, TopAbs_VERTEX ); + if ( !v.More() ) + THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetVertex(): empty vertex", + SALOME::BAD_PARAM ); + + gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( v.Current() )); + myConnectedElementsPtr->SetPoint( p.X(), p.Y(), p.Z() ); + // + CORBA::String_var id = vertex->GetStudyEntry(); + myVertexID = id.in(); + + TPythonDump() << this << ".SetVertex( " << vertex << " )"; +} + +void ConnectedElements_i::SetNode ( CORBA::Long nodeID ) + throw (SALOME::SALOME_Exception) +{ + if ( nodeID < 1 ) + THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetNode(): nodeID must be > 0", + SALOME::BAD_PARAM ); + + myConnectedElementsPtr->SetNode( nodeID ); + myVertexID.clear(); + TPythonDump() << this << ".SetNode( " << nodeID << " )"; +} + +/*! + * \brief This is a comfort method for Filter dialog + */ +void ConnectedElements_i::SetThreshold ( const char* threshold, + SMESH::ConnectedElements::ThresholdType type ) + throw (SALOME::SALOME_Exception) +{ + if ( !threshold ) + THROW_SALOME_CORBA_EXCEPTION( "ConnectedElements_i::SetThreshold(): NULL threshold", + SALOME::BAD_PARAM ); + switch ( type ) + { + case SMESH::ConnectedElements::POINT: // read 3 node coordinates /////////////////// + { + vector< double > xyz; + char* endptr; + do + { + // skip a separator + while ( *threshold && + *threshold != '+' && + *threshold != '-' && + !isdigit( *threshold )) + ++threshold; + if ( !*threshold ) + break; + // read a coordinate + xyz.push_back( strtod( threshold, &endptr )); + if ( threshold == endptr ) + { + xyz.resize( xyz.size() - 1 ); + break; + } + threshold = endptr; + } + while ( xyz.size() < 3 ); + + if ( xyz.size() < 3 ) + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): invalid point coordinates", SALOME::BAD_PARAM ); + + SetPoint( xyz[0], xyz[1], xyz[2] ); + break; + } + case SMESH::ConnectedElements::VERTEX: // get a VERTEX by its entry ///////////////// + { + SALOMEDS::Study_var study = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy(); + if ( study->_is_nil() ) + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): NULL current study", SALOME::BAD_PARAM ); + SALOMEDS::SObject_wrap sobj = study->FindObjectID( threshold ); + if ( sobj->_is_nil() ) + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): invalid vertex study entry", SALOME::BAD_PARAM ); + CORBA::Object_var obj = sobj->GetObject(); + GEOM::GEOM_Object_wrap vertex = GEOM::GEOM_Object::_narrow( obj ); + if ( vertex->_is_nil() ) + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): no GEOM_Object in SObject", SALOME::BAD_PARAM ); + SetVertex( vertex ); + break; + } + case SMESH::ConnectedElements::NODE: // read a node ID //////////////////////////// + { + char* endptr; + int id = strtol( threshold, &endptr, 10 ); + if ( threshold == endptr ) + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): invalid node ID", SALOME::BAD_PARAM ); + SetNode( id ); + break; + } + default: + THROW_SALOME_CORBA_EXCEPTION + ( "ConnectedElements_i::SetThreshold(): invalid ThresholdType", SALOME::BAD_PARAM ); + } +} + +char* ConnectedElements_i::GetThreshold ( SMESH::ConnectedElements::ThresholdType& type ) +{ + std::string threshold; + if ( !myVertexID.empty() ) + { + threshold = myVertexID; + type = SMESH::ConnectedElements::VERTEX; + } + else + { + std::vector xyz = myConnectedElementsPtr->GetPoint(); + if ( xyz.size() == 3 ) + { + threshold = SMESH_Comment( xyz[0] ) << "; " << xyz[1] << "; " << xyz[2]; + type = SMESH::ConnectedElements::POINT; + } + else + { + threshold = SMESH_Comment( myConnectedElementsPtr->GetNode() ); + type = SMESH::ConnectedElements::NODE; + } + } + return CORBA::string_dup( threshold.c_str() ); +} + /* Class : Comparator_i Description : Base class for comparators @@ -2160,6 +2403,14 @@ CoplanarFaces_ptr FilterManager_i::CreateCoplanarFaces() return anObj._retn(); } +ConnectedElements_ptr FilterManager_i::CreateConnectedElements() +{ + SMESH::ConnectedElements_i* aServant = new SMESH::ConnectedElements_i(); + SMESH::ConnectedElements_var anObj = aServant->_this(); + TPythonDump()< -static void collectMeshInfo(const TIterator& theItr, - TPredicate& thePred, - SMESH::long_array& theRes) -{ - if (!theItr) - return; - while (theItr->more()) { - const SMDS_MeshElement* anElem = theItr->next(); - if ( thePred->IsSatisfy( anElem->GetID() ) ) - theRes[ anElem->GetEntityType() ]++; +//============================================================================= +/*! + * \brief Returns number of mesh elements per each \a EntityType + */ +//============================================================================= + +SMESH::long_array* ::Filter_i::GetMeshInfo() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::Entity_Last); + for (int i = 0; i < SMESH::Entity_Last; i++) + aRes[i] = 0; + + if ( !CORBA::is_nil(myMesh) && myPredicate ) + { + const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); + SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); + while ( it->more() ) + { + const SMDS_MeshElement* anElem = it->next(); + if ( myPredicate->IsSatisfy( anElem->GetID() ) ) + aRes[ anElem->GetEntityType() ]++; + } } + + return aRes._retn(); } //============================================================================= /*! - * \brief Returns statistic of mesh elements + * \brief Returns number of mesh elements of each \a ElementType */ //============================================================================= -SMESH::long_array* ::Filter_i::GetMeshInfo() + +SMESH::long_array* ::Filter_i::GetNbElementsByType() { SMESH::long_array_var aRes = new SMESH::long_array(); - aRes->length(SMESH::Entity_Last); - for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) + aRes->length(SMESH::NB_ELEMENT_TYPES); + for (int i = 0; i < SMESH::NB_ELEMENT_TYPES; i++) aRes[i] = 0; - if(!CORBA::is_nil(myMesh) && myPredicate) { - const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); - SMDS_ElemIteratorPtr it; - switch( GetElementType() ) + if ( !CORBA::is_nil(myMesh) && myPredicate ) { + const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); + SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() )); + CORBA::Long& nbElems = aRes[ GetElementType() ]; + while ( it->more() ) { - case SMDSAbs_Node: - collectMeshInfo(aMesh->nodesIterator(),myPredicate,aRes); - break; - case SMDSAbs_Edge: - collectMeshInfo(aMesh->edgesIterator(),myPredicate,aRes); - break; - case SMDSAbs_Face: - collectMeshInfo(aMesh->facesIterator(),myPredicate,aRes); - break; - case SMDSAbs_Volume: - collectMeshInfo(aMesh->volumesIterator(),myPredicate,aRes); - break; - case SMDSAbs_All: - default: - collectMeshInfo(aMesh->elementsIterator(),myPredicate,aRes); - break; + const SMDS_MeshElement* anElem = it->next(); + if ( myPredicate->IsSatisfy( anElem->GetID() ) ) + nbElems++; } } return aRes._retn(); } + //================================================================================ /*! * \brief Return GetElementType() within an array @@ -2648,6 +2903,40 @@ static inline bool getCriteria( Predicate_i* thePred, { int aFType = thePred->GetFunctorType(); + switch ( aFType ) + { + case FT_LogicalNOT: + { + Predicate_i* aPred = ( dynamic_cast( thePred ) )->GetPredicate_i(); + getCriteria( aPred, theCriteria ); + theCriteria[ theCriteria->length() - 1 ].UnaryOp = FT_LogicalNOT; + } + return true; + + case FT_LogicalAND: + case FT_LogicalOR: + { + Predicate_i* aPred1 = ( dynamic_cast( thePred ) )->GetPredicate1_i(); + Predicate_i* aPred2 = ( dynamic_cast( thePred ) )->GetPredicate2_i(); + if ( !getCriteria( aPred1, theCriteria ) ) + return false; + theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType; + return getCriteria( aPred2, theCriteria ); + } + case FT_Undefined: + return false; + } + + // resize theCriteria + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + theCriteria[ i ] = createCriterion(); + + // set members of the added Criterion + + theCriteria[ i ].Type = aFType; + theCriteria[ i ].TypeOfElement = thePred->GetElementType(); + switch ( aFType ) { case FT_FreeBorders: @@ -2664,30 +2953,14 @@ static inline bool getCriteria( Predicate_i* thePred, case FT_OverConstrainedVolume: case FT_OverConstrainedFace: { - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = aFType; - theCriteria[ i ].TypeOfElement = thePred->GetElementType(); return true; } case FT_BelongToGeom: { BelongToGeom_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = FT_BelongToGeom; theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); theCriteria[ i ].ThresholdID = aPred->GetShapeID(); - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); theCriteria[ i ].Tolerance = aPred->GetTolerance(); - return true; } case FT_BelongToPlane: @@ -2695,80 +2968,52 @@ static inline bool getCriteria( Predicate_i* thePred, case FT_BelongToGenSurface: { BelongToSurface_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = aFType; theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); theCriteria[ i ].ThresholdID = aPred->GetShapeID(); - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); theCriteria[ i ].Tolerance = aPred->GetTolerance(); - return true; } - case FT_LyingOnGeom: + case FT_LyingOnGeom: { LyingOnGeom_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = FT_LyingOnGeom; theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); theCriteria[ i ].ThresholdID = aPred->GetShapeID(); - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); theCriteria[ i ].Tolerance = aPred->GetTolerance(); - return true; } - case FT_CoplanarFaces: + case FT_CoplanarFaces: { CoplanarFaces_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - CORBA::String_var faceId = aPred->GetFaceAsString(); - - theCriteria[ i ].Type = FT_CoplanarFaces; - theCriteria[ i ].ThresholdID = faceId; + theCriteria[ i ].ThresholdID = aPred->GetFaceAsString(); theCriteria[ i ].Tolerance = aPred->GetTolerance(); - + return true; + } + case FT_ConnectedElements: + { + ConnectedElements_i* aPred = dynamic_cast( thePred ); + SMESH::ConnectedElements::ThresholdType type; + CORBA::String_var threshold = aPred->GetThreshold( type ); + switch ( type ) { + case SMESH::ConnectedElements::POINT: + theCriteria[ i ].ThresholdStr = threshold; break; + case SMESH::ConnectedElements::VERTEX: + theCriteria[ i ].ThresholdID = threshold; break; + case SMESH::ConnectedElements::NODE: + theCriteria[ i ].Threshold = atof( threshold.in() ); break; + default:; + } return true; } case FT_EqualNodes: { EqualNodes_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = FT_EqualNodes; - theCriteria[ i ].Tolerance = aPred->GetTolerance(); - + theCriteria[ i ].Tolerance = aPred->GetTolerance(); return true; } case FT_RangeOfIds: { RangeOfIds_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = FT_RangeOfIds; theCriteria[ i ].ThresholdStr = aPred->GetRangeStr(); - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); - return true; } case FT_LessThan: @@ -2776,85 +3021,34 @@ static inline bool getCriteria( Predicate_i* thePred, case FT_EqualTo: { Comparator_i* aCompar = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - theCriteria[ i ].Type = aCompar->GetNumFunctor_i()->GetFunctorType(); theCriteria[ i ].Compare = aFType; theCriteria[ i ].Threshold = aCompar->GetMargin(); - theCriteria[ i ].TypeOfElement = aCompar->GetElementType(); - if ( aFType == FT_EqualTo ) { EqualTo_i* aCompar = dynamic_cast( thePred ); theCriteria[ i ].Tolerance = aCompar->GetTolerance(); } - } - return true; - - case FT_LogicalNOT: - { - Predicate_i* aPred = ( dynamic_cast( thePred ) )->GetPredicate_i(); - getCriteria( aPred, theCriteria ); - theCriteria[ theCriteria->length() - 1 ].UnaryOp = FT_LogicalNOT; - } - return true; - - case FT_LogicalAND: - case FT_LogicalOR: - { - Predicate_i* aPred1 = ( dynamic_cast( thePred ) )->GetPredicate1_i(); - Predicate_i* aPred2 = ( dynamic_cast( thePred ) )->GetPredicate2_i(); - if ( !getCriteria( aPred1, theCriteria ) ) - return false; - theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType; - return getCriteria( aPred2, theCriteria ); + return true; } case FT_GroupColor: { - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - GroupColor_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].Type = aFType; - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); - theCriteria[ i ].ThresholdStr = aPred->GetColorStr(); - + theCriteria[ i ].ThresholdStr = aPred->GetColorStr(); return true; } case FT_ElemGeomType: { - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - ElemGeomType_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].Type = aFType; - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); - theCriteria[ i ].Threshold = (double)aPred->GetGeometryType(); + theCriteria[ i ].Threshold = (double)aPred->GetGeometryType(); return true; } case FT_EntityType: { - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - ElemEntityType_i* aPred = dynamic_cast( thePred ); - theCriteria[ i ].Type = aFType; - theCriteria[ i ].Threshold = (double)aPred->GetEntityType(); + theCriteria[ i ].Threshold = (double)aPred->GetEntityType(); return true; } - - case FT_Undefined: - return false; default: return false; } @@ -2876,8 +3070,7 @@ CORBA::Boolean Filter_i::GetCriteria( SMESH::Filter::Criteria_out theCriteria ) //======================================================================= CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria ) { - if ( myPredicate != 0 ) - myPredicate->UnRegister(); + SetPredicate( SMESH::Predicate::_nil() ); SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); FilterManager_ptr aFilterMgr = aFilter->_this(); @@ -2907,9 +3100,8 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria << aCriterion << ", " << aCompare << ", " << aThreshold << ", '" - << aThresholdStr << "', '"; - if (aThresholdID) pd << aThresholdID; - pd << "', " + << aThresholdStr << "', '" + << aThresholdID << "', " << aUnary << ", " << aBinary << ", " << aTolerance << ", " @@ -3109,6 +3301,19 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria aPredicate = tmpPred; break; } + case SMESH::FT_ConnectedElements: + { + SMESH::ConnectedElements_ptr tmpPred = aFilterMgr->CreateConnectedElements(); + if ( strlen( aThresholdID ) > 0 ) // shape ID + tmpPred->SetThreshold( aThresholdID, SMESH::ConnectedElements::VERTEX ); + else if ( strlen( aThresholdStr ) > 0 ) // point coords + tmpPred->SetThreshold( aThresholdStr, SMESH::ConnectedElements::POINT ); + else if ( aThreshold >= 1 ) + tmpPred->SetNode( (CORBA::Long) aThreshold ); // node ID + tmpPred->SetElementType( aTypeOfElem ); + aPredicate = tmpPred; + break; + } default: continue; @@ -3218,6 +3423,8 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria SetPredicate( aResPredicate ); + aResPredicate->UnRegister(); + return !aResPredicate->_is_nil(); } @@ -3966,6 +4173,7 @@ static const char** getFunctNames() "FT_EntityType", "FT_CoplanarFaces", "FT_BallDiameter", + "FT_ConnectedElements", "FT_LessThan", "FT_MoreThan", "FT_EqualTo",