X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHFiltersSelection%2FSMESH_TypeFilter.cxx;h=8630ab6d9ca979dd57f8b9d40f58380a67dab33c;hp=9df3ed861ebc83c2ecb3bda035f79302d1c7308f;hb=0fc0831670e27a5611b941c52dc152fd63964515;hpb=1067ffa6e7e5c394e3a1b17219d8b355a57607cd diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx index 9df3ed861..8630ab6d9 100644 --- a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2020 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 @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,10 +22,10 @@ #include "SMESH_TypeFilter.hxx" +#include #include - +#include #include -#include #include #include CORBA_CLIENT_HEADER(SMESH_Gen) @@ -39,6 +39,40 @@ SMESH_TypeFilter::~SMESH_TypeFilter() { } +namespace +{ + //================================================================================ + /*! + * \brief Returns true if \a obj is SMESH_IDSource including elements of a given \a type + */ + //================================================================================ + + bool isIDSourceOfType( _PTR(SObject) obj, SMESH::ElementType type ) + { + bool Ok = false; + SalomeApp_Application* app = dynamic_cast + (SUIT_Session::session()->activeApplication()); + _PTR(GenericAttribute) anAttr; + if ( obj->FindAttribute(anAttr, "AttributeIOR")) + { + _PTR(AttributeIOR) anIOR = anAttr; + std::string aVal = anIOR->Value(); + if ( aVal.size() > 0 ) + { + CORBA::Object_var corbaObj = app->orb()->string_to_object( aVal.c_str() ); + SMESH::SMESH_IDSource_var ids = SMESH::SMESH_IDSource::_narrow( corbaObj ); + if ( ! ids->_is_nil() ) + { + SMESH::array_of_ElementType_var types = ids->GetTypes(); + for ( int i = 0, nb = types->length(); i < nb && !Ok; ++i ) + Ok = ( types[i] == type ); + } + } + } + return Ok; + } +} + bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const { bool Ok = false, extractReference = true; @@ -52,7 +86,7 @@ bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const _PTR(Study) study = appStudy->studyDS(); QString entry = owner->entry(); - _PTR(SObject) obj (study->FindObjectID(entry.toLatin1().data())), aRefSO; + _PTR(SObject) obj (study->FindObjectID(entry.toUtf8().data())), aRefSO; if( extractReference && obj && obj->ReferencedObject( aRefSO ) ) obj = aRefSO; if (!obj) return false; @@ -215,6 +249,22 @@ bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const SMESH_TypeFilter(SMESH::GROUP) .isOk( theDataOwner )); break; } + case SMESH::IDSOURCE_EDGE: + { + Ok = isIDSourceOfType( obj, SMESH::EDGE ); + break; + } + case SMESH::IDSOURCE_FACE: + { + Ok = isIDSourceOfType( obj, SMESH::FACE ); + break; + } + case SMESH::IDSOURCE_VOLUME: + { + Ok = isIDSourceOfType( obj, SMESH::VOLUME ); + break; + } + default:; } } return Ok;