Back to index

salome-smesh  6.5.0
Static Public Member Functions
StdMeshers_ObjRefUlils Class Reference

Class encapsulates methods. More...

#include <StdMeshers_ObjRefUlils.hxx>

List of all members.

Static Public Member Functions

static GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape &theShape)
 Return GEOM Object correspoding to TopoDS_Shape.
static TopoDS_Shape GeomObjectToShape (GEOM::GEOM_Object_ptr theGeomObject)
 Return TopoDS_Shape correspoding to GEOM_Object.
static std::string GeomObjectToEntry (GEOM::GEOM_Object_ptr &theGeomObject)
 Return study entry of GEOM Object.
static GEOM::GEOM_Object_ptr EntryOrShapeToGeomObject (const std::string &theEntry, const TopoDS_Shape &theShape)
 Return GEOM Object by its study entry or TopoDS_Shape.
static void SaveToStream (const TopoDS_Shape &theShape, std::ostream &stream)
 Store the shape in the stream.
static TopoDS_Shape LoadFromStream (std::istream &stream)
 Retrieve a shape from the stream.
static void SaveToStream (CORBA::Object_ptr obj, std::ostream &stream)
 Store the CORBA object in the stream.
template<class TInterface >
static TInterface::_var_type LoadObjectFromStream (std::istream &stream)
 Retrieve a CORBA object from the stream.
static void SaveToStream (const std::string &studyEntry, std::ostream &stream)
 Store the study entry of object in the stream.

Detailed Description

Class encapsulates methods.

These methods are useful for hypotheses referring to other objects like meshes, geom objects, other hypotheses, etc.

Definition at line 41 of file StdMeshers_ObjRefUlils.hxx.


Member Function Documentation

GEOM::GEOM_Object_ptr StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject ( const std::string &  theEntry,
const TopoDS_Shape &  theShape 
) [static]

Return GEOM Object by its study entry or TopoDS_Shape.

Definition at line 54 of file StdMeshers_ObjRefUlils.cxx.

{
  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();
}

Here is the caller graph for this function:

std::string StdMeshers_ObjRefUlils::GeomObjectToEntry ( GEOM::GEOM_Object_ptr &  theGeomObject) [static]

Return study entry of GEOM Object.

Definition at line 39 of file StdMeshers_ObjRefUlils.cxx.

{
  if ( CORBA::is_nil( theGeomObject ))
    return "NULL_OBJECT";

  CORBA::String_var entry = theGeomObject->GetStudyEntry();
  return entry.in();
}

Here is the caller graph for this function:

static TopoDS_Shape StdMeshers_ObjRefUlils::GeomObjectToShape ( GEOM::GEOM_Object_ptr  theGeomObject) [inline, static]

Return TopoDS_Shape correspoding to GEOM_Object.

Parameters:
theGeomObject- input object
Return values:
TopoDS_Shape- result TopoDS_Shape

Definition at line 61 of file StdMeshers_ObjRefUlils.hxx.

                                                                           {
     if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen())
       return gen->GeomObjectToShape( theGeomObject );
     else
       return TopoDS_Shape();
  }

Here is the caller graph for this function:

TopoDS_Shape StdMeshers_ObjRefUlils::LoadFromStream ( std::istream &  stream) [static]

Retrieve a shape from the stream.

Parameters:
stream- the stream
Return values:
TopoDS_Shape- resulting shape

Definition at line 110 of file StdMeshers_ObjRefUlils.cxx.

{
  if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
    SALOMEDS::Study_var study = gen->GetCurrentStudy();
    if ( ! study->_is_nil() ) {
      string str;
      if (stream >> str) {
        SALOMEDS::SObject_var sobj= study->FindObjectID( str.c_str() );
        CORBA::Object_var obj = gen->SObjectToObject( sobj );
        GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj );
        return gen->GeomObjectToShape( geom.in() );
      }
    }
  }
  return TopoDS_Shape();
}

Here is the caller graph for this function:

template<class TInterface >
static TInterface::_var_type StdMeshers_ObjRefUlils::LoadObjectFromStream ( std::istream &  stream) [inline, static]

Retrieve a CORBA object from the stream.

Parameters:
stream- the stream
Return values:
CORBA::Object_ptr- result object

Definition at line 108 of file StdMeshers_ObjRefUlils.hxx.

  {
    if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
      std::string str;
      if (stream >> str) {
        if ( StudyContext* myStudyContext = gen->GetCurrentStudyContext() ) {
          string ior = myStudyContext->getIORbyOldId( atoi( str.c_str() ));
          if ( !ior.empty() )
             return TInterface::_narrow(gen->GetORB()->string_to_object( ior.c_str() ));
        }
      }
    }
    return TInterface::_nil();
  }
void StdMeshers_ObjRefUlils::SaveToStream ( const TopoDS_Shape &  theShape,
std::ostream &  stream 
) [static]

Store the shape in the stream.

Parameters:
theShape- shape to store
stream- the stream

Definition at line 83 of file StdMeshers_ObjRefUlils.cxx.

{
  bool ok = false;
  if ( !theShape.IsNull() ) {
    if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
      GEOM::GEOM_Object_var geom = gen->ShapeToGeomObject( theShape );
      if ( ! geom->_is_nil() ) {
        SALOMEDS::SObject_var sobj = gen->ObjectToSObject( gen->GetCurrentStudy(), geom );
        if ( !sobj->_is_nil() ) {
          stream << " " << sobj->GetID();
          ok = true;
        }
      }
    }
  }
  if ( ! ok )
    stream << " NULL_SHAPE ";
}

Here is the caller graph for this function:

void StdMeshers_ObjRefUlils::SaveToStream ( CORBA::Object_ptr  obj,
std::ostream &  stream 
) [static]

Store the CORBA object in the stream.

Parameters:
obj- object to store
stream- the stream

Definition at line 135 of file StdMeshers_ObjRefUlils.cxx.

{
  bool ok = false;
  if ( !CORBA::is_nil( obj ) ) {
    if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) {
      stream << " " << gen->GetObjectId( obj );
      ok = true;
    }
  }
  if ( ! ok )
    stream << " NULL_OBJECT ";
}
void StdMeshers_ObjRefUlils::SaveToStream ( const std::string &  studyEntry,
std::ostream &  stream 
) [static]

Store the study entry of object in the stream.

Parameters:
studyEntry- the study entry
stream- the stream

Definition at line 154 of file StdMeshers_ObjRefUlils.cxx.

{
  if ( studyEntry.find_first_not_of( ' ' ) == std::string::npos )
    stream << " NULL_OBJECT ";
  else
    stream << " " << studyEntry;
}
static GEOM::GEOM_Object_ptr StdMeshers_ObjRefUlils::ShapeToGeomObject ( const TopoDS_Shape &  theShape) [inline, static]

Return GEOM Object correspoding to TopoDS_Shape.

Parameters:
theShape- input TopoDS_Shape
Return values:
GEOM::GEOM_Object_ptr- result object

Definition at line 49 of file StdMeshers_ObjRefUlils.hxx.

                                                                                {
     if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen())
       return gen->ShapeToGeomObject( theShape );
     else
       return GEOM::GEOM_Object::_nil();
   }

The documentation for this class was generated from the following files: