-// Copyright (C) 2007-2019 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
SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(CORBA::Object_ptr theObject)
{
SALOMEDS::SObject_wrap aSO;
- if ( !CORBA::is_nil( theObject ))
+ try {
+ if ( !CORBA::is_nil( theObject ))
+ {
+ CORBA::String_var objStr = SMESH_Gen_i::GetORB()->object_to_string( theObject );
+ aSO = getStudyServant()->FindObjectIOR( objStr.in() );
+ }
+ }
+ catch (...)
{
- CORBA::String_var objStr = SMESH_Gen_i::GetORB()->object_to_string( theObject );
- aSO = getStudyServant()->FindObjectIOR( objStr.in() );
}
return aSO._retn();
}
GEOM::GEOM_Object_ptr SMESH_Gen_i::ShapeToGeomObject (const TopoDS_Shape& theShape )
{
GEOM::GEOM_Object_var aShapeObj;
- if ( !theShape.IsNull() ) {
- GEOM_Client* aClient = GetShapeReader();
+ if ( !theShape.IsNull() && mySMESHGen ) {
+ GEOM_Client* aClient = mySMESHGen->GetShapeReader();
TCollection_AsciiString IOR;
if ( aClient && aClient->Find( theShape, IOR ))
{
TopoDS_Shape SMESH_Gen_i::GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject)
{
TopoDS_Shape S;
- if ( !theGeomObject->_is_nil() && !theGeomObject->_non_existent() ) {
- GEOM_Client* aClient = GetShapeReader();
- GEOM::GEOM_Gen_ptr aGeomEngine = GetGeomEngine();
+ if ( mySMESHGen && !theGeomObject->_is_nil() && !theGeomObject->_non_existent() )
+ {
+ GEOM_Client* aClient = mySMESHGen->GetShapeReader();
+ GEOM::GEOM_Gen_var aGeomEngine = GetGeomEngine( theGeomObject );
if ( aClient && !aGeomEngine->_is_nil () )
S = aClient->GetShape( aGeomEngine, theGeomObject );
}
return S;
}
+//================================================================================
+/*!
+ * \brief Get GEOM Object by its study entry
+ */
+//================================================================================
+
+GEOM::GEOM_Object_ptr SMESH_Gen_i::GetGeomObjectByEntry( const std::string& entry )
+{
+ GEOM::GEOM_Object_var go;
+ if ( !entry.empty() && mySMESHGen )
+ {
+ SALOMEDS::SObject_wrap so = mySMESHGen->getStudyServant()->FindObjectID( entry.c_str() );
+ CORBA::Object_var obj = SObjectToObject( so );
+ go = GEOM::GEOM_Object::_narrow( obj );
+ }
+ return go._retn();
+}
+
+
//=======================================================================
//function : publish
-//purpose :
+//purpose :
//=======================================================================
static SALOMEDS::SObject_ptr publish(CORBA::Object_ptr theIOR,