0021530: EDF 2176 SMESH: Projection 1D-2D with compounds

+  static GEOM::GEOM_Object_ptr EntryOrShapeToGeomObject (const std::string&  theEntry,
+                                                         const TopoDS_Shape& theShape);

+  static void SaveToStream( const std::string& studyEntry, std::ostream & stream);
This commit is contained in:
eap 2012-04-11 08:20:17 +00:00
parent 08e8a82bb2
commit b9b021a25d
2 changed files with 57 additions and 2 deletions

View File

@ -31,6 +31,33 @@
using namespace std; 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 * \brief Store the shape in the stream
@ -104,3 +131,17 @@ void StdMeshers_ObjRefUlils::SaveToStream( CORBA::Object_ptr obj,
if ( ! ok ) if ( ! ok )
stream << " NULL_OBJECT "; 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;
}

View File

@ -65,6 +65,12 @@ public:
return TopoDS_Shape(); 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 * \brief Store the shape in the stream
* \param theShape - shape to store * \param theShape - shape to store
@ -77,14 +83,14 @@ public:
* \param stream - the stream * \param stream - the stream
* \retval TopoDS_Shape - resulting shape * \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 * \brief Store the CORBA object in the stream
* \param obj - object to store * \param obj - object to store
* \param stream - the stream * \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 * \brief Retrieve a CORBA object from the stream
@ -107,6 +113,14 @@ public:
} }
return TInterface::_nil(); 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 #endif