-// Copyright (C) 2007-2016 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 ))
{
CORBA::Object_var obj = GetORB()->string_to_object( IOR.ToCString() );
- aShapeObj = GEOM::GEOM_Object::_narrow ( obj );
+ if ( !obj->_non_existent() )
+ aShapeObj = GEOM::GEOM_Object::_narrow ( obj );
}
}
return aShapeObj._retn();
TopoDS_Shape SMESH_Gen_i::GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject)
{
TopoDS_Shape S;
- if ( !theGeomObject->_is_nil() ) {
- 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,
SetName( aRootSO, aRootNames[aType] );
// Add new group to corresponding sub-tree
- int isEmpty = false;
+ int isEmpty = ( theMesh->NbNodes() == 0 );
std::string pm[2] = { "ICON_SMESH_TREE_GROUP", "ICON_SMESH_TREE_MESH_WARN" };
- if ( SMESH::DownCast< SMESH_GroupOnFilter_i* > ( theGroup ))
- {
- pm[0] = "ICON_SMESH_TREE_GROUP_ON_FILTER";
- }
- else if ( SMESH::DownCast< SMESH_Group_i* > ( theGroup ))
+ if ( !isEmpty )
{
- if ( theGroup->GetType() == SMESH::NODE )
- isEmpty = ( theMesh->NbNodes() == 0 );
- else
+ if ( SMESH::DownCast< SMESH_GroupOnFilter_i* > ( theGroup )) // on filter
+ {
+ pm[0] = "ICON_SMESH_TREE_GROUP_ON_FILTER";
+
+ if ( theGroup->GetType() != SMESH::NODE )
+ {
+ isEmpty = true;
+ SMESH::array_of_ElementType_var allElemTypes = theMesh->GetTypes();
+ for ( size_t i =0; i < allElemTypes->length() && isEmpty; ++i )
+ isEmpty = ( allElemTypes[i] != theGroup->GetType() );
+ }
+ }
+ else // standalone or on geometry
{
- SMESH::array_of_ElementType_var allElemTypes = theMesh->GetTypes();
- for ( size_t i =0; i < allElemTypes->length() && isEmpty; ++i )
- isEmpty = ( allElemTypes[i] != theGroup->GetType() );
+ isEmpty = ( theGroup->Size() == 0 );
}
}
aGroupSO = publish ( theGroup, aRootSO, 0, pm[isEmpty].c_str() );
//=======================================================================
//function : PublishHypothesis
-//purpose :
+//purpose :
//=======================================================================
SALOMEDS::SObject_ptr
- SMESH_Gen_i::PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
- const char* theName)
+SMESH_Gen_i::PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
+ const char* theName)
{
- if(MYDEBUG) MESSAGE("PublishHypothesis")
+ if(MYDEBUG) MESSAGE("PublishHypothesis");
if ( !myIsEnablePublish )
return SALOMEDS::SObject::_nil();
if (theHyp->_is_nil())
}
}
+//=======================================================================
+//function : IsInvalid
+//purpose : Check object validity == absence of AttributeTextColor=(178,34,34)
+//=======================================================================
+
+bool SMESH_Gen_i::IsInvalid( SALOMEDS::SObject_ptr theSObject )
+{
+ bool isValid = true;
+ if ( !theSObject->_is_nil() )
+ {
+ SALOMEDS::GenericAttribute_wrap attr;
+ SALOMEDS::StudyBuilder_var studyBuilder = getStudyServant()->NewBuilder();
+ if ( studyBuilder->FindAttribute( theSObject, attr.inout(), "AttributeTextColor" ))
+ {
+ SALOMEDS::AttributeTextColor_wrap colorAttr = attr;
+ SALOMEDS::Color color = colorAttr->TextColor();
+ isValid = ( color.R != 178 || color.G != 34 || color.B != 34 );
+ }
+ }
+ return isValid;
+}
+
//=======================================================================
//function : GetMeshOrSubmeshByShape
//purpose :