-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019 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
#include "SMESH_TypeFilter.hxx"
+#include <LightApp_DataOwner.h>
#include <SUIT_Session.h>
-
+#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
-#include <LightApp_DataOwner.h>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SMESH_Gen)
{
}
+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<SalomeApp_Application*>
+ (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;
_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;
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;