Version: 6.3.1
Static Public Member Functions

StdMeshers_ObjRefUlils Class Reference

Class encapsulates methods

More...

#include <StdMeshers_ObjRefUlils.hxx>

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 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.

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

static TopoDS_Shape StdMeshers_ObjRefUlils.GeomObjectToShape ( GEOM::GEOM_Object_ptr  theGeomObject) [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.

References SMESH_Gen_i.GetSMESHGen().

Referenced by StdMeshers_ProjectionSource3D_i.SetSource3DShape(), StdMeshers_ProjectionSource1D_i.SetSourceEdge(), StdMeshers_ProjectionSource2D_i.SetSourceFace(), StdMeshers_ProjectionSource3D_i.SetVertexAssociation(), StdMeshers_ProjectionSource2D_i.SetVertexAssociation(), and StdMeshers_ProjectionSource1D_i.SetVertexAssociation().

                                                                           {
     if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen())
       return gen->GeomObjectToShape( theGeomObject );
     else
       return TopoDS_Shape();
  }
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 69 of file StdMeshers_ObjRefUlils.cxx.

References SMESH_box.geom, and SMESH_Gen_i.GetSMESHGen().

Referenced by StdMeshers_ProjectionSource2D_i.LoadFrom(), and StdMeshers_ProjectionSource1D_i.LoadFrom().

{
  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();
}
template<class TInterface >
static TInterface::_var_type StdMeshers_ObjRefUlils.LoadObjectFromStream ( std::istream &  stream) [static]

Retrieve a CORBA object from the stream.

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

Definition at line 96 of file StdMeshers_ObjRefUlils.hxx.

References SMESH_Gen_i.GetSMESHGen().

  {
    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 42 of file StdMeshers_ObjRefUlils.cxx.

References SMESH_box.geom, and SMESH_Gen_i.GetSMESHGen().

Referenced by StdMeshers_ProjectionSource2D_i.SaveTo(), StdMeshers_ProjectionSource1D_i.SaveTo(), StdMeshers_ImportSource2D_i.SaveTo(), and StdMeshers_ImportSource1D_i.SaveTo().

{
  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 ";
}
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 94 of file StdMeshers_ObjRefUlils.cxx.

References SMESH_Gen_i.GetSMESHGen().

{
  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 ";
}
static GEOM::GEOM_Object_ptr StdMeshers_ObjRefUlils.ShapeToGeomObject ( const TopoDS_Shape &  theShape) [static]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS