using namespace std;
+//=======================================================================
+//function : EntryOrShapeToGeomObject
+//purpose : Return GEOM Object by its sytudy entry or TopoDS_Shape
+//=======================================================================
+
+GEOM::GEOM_Object_ptr
+StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject (const std::string& theEntry,
+ const TopoDS_Shape& theShape)
+{
+ GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_nil();
+
+ // try by entry
+ if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
+ SALOMEDS::Study_var study = gen->GetCurrentStudy();
+ if ( ! theEntry.empty() && ! study->_is_nil() ) {
+ SALOMEDS::SObject_var sobj= study->FindObjectID( theEntry.c_str() );
+ CORBA::Object_var obj = gen->SObjectToObject( sobj );
+ geom = GEOM::GEOM_Object::_narrow( obj );
+ }
+ }
+ // try by TopoDS_Shape
+ if ( geom->_is_nil() )
+ geom = ShapeToGeomObject( theShape );
+
+ return geom._retn();
+}
+
//================================================================================
/*!
* \brief Store the shape in the stream
if ( ! ok )
stream << " NULL_OBJECT ";
}
+
+//=======================================================================
+//function : SaveToStream
+//purpose : Store the study entry of object in the stream
+//=======================================================================
+
+void StdMeshers_ObjRefUlils::SaveToStream( const std::string& studyEntry,
+ std::ostream & stream)
+{
+ if ( studyEntry.find_first_not_of( ' ' ) == std::string::npos )
+ stream << " NULL_OBJECT ";
+ else
+ stream << " " << studyEntry;
+}
return TopoDS_Shape();
}
+ /*!
+ * \brief Return GEOM Object by its sytudy entry or TopoDS_Shape
+ */
+ static GEOM::GEOM_Object_ptr EntryOrShapeToGeomObject (const std::string& theEntry,
+ const TopoDS_Shape& theShape);
+
/*!
* \brief Store the shape in the stream
* \param theShape - shape to store
* \param stream - the stream
* \retval TopoDS_Shape - resulting shape
*/
- static TopoDS_Shape LoadFromStream( std::istream & stream);
+ static TopoDS_Shape LoadFromStream( std::istream & stream );
/*!
* \brief Store the CORBA object in the stream
* \param obj - object to store
* \param stream - the stream
*/
- static void SaveToStream( CORBA::Object_ptr obj, std::ostream & stream);
+ static void SaveToStream( CORBA::Object_ptr obj, std::ostream & stream );
/*!
* \brief Retrieve a CORBA object from the stream
}
return TInterface::_nil();
}
+
+ /*!
+ * \brief Store the study entry of object in the stream
+ * \param studyEntry - the study entry
+ * \param stream - the stream
+ */
+ static void SaveToStream( const std::string& studyEntry, std::ostream & stream);
+
};
#endif