Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef StdMeshers_ObjRefUlils_HeaderFile
00029 #define StdMeshers_ObjRefUlils_HeaderFile
00030
00031 #include "SMESH_Gen_i.hxx"
00032
00041 class StdMeshers_ObjRefUlils
00042 {
00043 public:
00049 static GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape ) {
00050 if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen())
00051 return gen->ShapeToGeomObject( theShape );
00052 else
00053 return GEOM::GEOM_Object::_nil();
00054 }
00055
00061 static TopoDS_Shape GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject) {
00062 if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen())
00063 return gen->GeomObjectToShape( theGeomObject );
00064 else
00065 return TopoDS_Shape();
00066 }
00067
00073 static void SaveToStream( const TopoDS_Shape& theShape, std::ostream & stream);
00074
00080 static TopoDS_Shape LoadFromStream( std::istream & stream);
00081
00087 static void SaveToStream( CORBA::Object_ptr obj, std::ostream & stream);
00088
00094 template<class TInterface>
00095 static
00096 typename TInterface::_var_type LoadObjectFromStream( std::istream & stream )
00097 {
00098 if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
00099 std::string str;
00100 if (stream >> str) {
00101 if ( StudyContext* myStudyContext = gen->GetCurrentStudyContext() ) {
00102 string ior = myStudyContext->getIORbyOldId( atoi( str.c_str() ));
00103 if ( !ior.empty() )
00104 return TInterface::_narrow(gen->GetORB()->string_to_object( ior.c_str() ));
00105 }
00106 }
00107 }
00108 return TInterface::_nil();
00109 }
00110 };
00111
00112 #endif