Back to index

salome-smesh  6.5.0
SMESH_Gen_i.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  File   : SMESH_Gen_i.hxx
00023 //  Author : Paul RASCLE, EDF
00024 //  Module : SMESH
00025 
00026 #ifndef _SMESH_GEN_I_HXX_
00027 #define _SMESH_GEN_I_HXX_
00028 
00029 #include "SMESH.hxx"
00030 
00031 #include <SALOMEconfig.h>
00032 #include CORBA_SERVER_HEADER(SMESH_Gen)
00033 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00034 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
00035 #include CORBA_CLIENT_HEADER(GEOM_Gen)
00036 #include CORBA_CLIENT_HEADER(SALOMEDS)
00037 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
00038 
00039 #include "SMESH_Mesh_i.hxx"
00040 #include "SMESH_Hypothesis_i.hxx"
00041 #include "SALOME_Component_i.hxx"
00042 #include "SALOME_NamingService.hxx"
00043 
00044 #include "SMESH_Gen.hxx"
00045 #include "GEOM_Client.hxx"
00046 
00047 #include <TCollection_AsciiString.hxx>
00048 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
00049 #include <TColStd_HSequenceOfAsciiString.hxx>
00050 
00051 #include <map>
00052 #include <sstream>
00053 
00054 class SMESH_Mesh_i;
00055 class SALOME_LifeCycleCORBA;
00056 
00057 // ===========================================================
00058 // Study context - stores study-connected objects references
00059 // ==========================================================
00060 class SMESH_I_EXPORT StudyContext
00061 {
00062 public:
00063   // constructor
00064   StudyContext() {}
00065   // destructor
00066   ~StudyContext()
00067   {
00068     mapIdToIOR.clear();
00069     mapIdToId.clear();
00070   }
00071   // register object in the internal map and return its id
00072   int addObject( string theIOR )
00073   {
00074     int nextId = getNextId();
00075     mapIdToIOR[ nextId ]  = theIOR;
00076     return nextId;
00077   }
00078   // find the object id in the internal map by the IOR
00079   int findId( string theIOR )
00080   {
00081     map<int, string>::iterator imap;
00082     for ( imap = mapIdToIOR.begin(); imap != mapIdToIOR.end(); ++imap ) {
00083       if ( imap->second == theIOR )
00084         return imap->first;
00085     }
00086     return 0;
00087   }
00088   // get object's IOR by id
00089   string getIORbyId( const int theId )
00090   {
00091     if ( mapIdToIOR.find( theId ) != mapIdToIOR.end() )
00092       return mapIdToIOR[ theId ];
00093     return string( "" );
00094   }
00095   // get object's IOR by old id
00096   string getIORbyOldId( const int theOldId )
00097   {
00098     if ( mapIdToId.find( theOldId ) != mapIdToId.end() )
00099       return getIORbyId( mapIdToId[ theOldId ] );
00100     return string( "" );
00101   }
00102   // maps old object id to the new one (used when restoring data)
00103   void mapOldToNew( const int oldId, const int newId ) {
00104     mapIdToId[ oldId ] = newId;
00105   }
00106   // get old id by a new one
00107   int getOldId( const int newId ) {
00108     map<int, int>::iterator imap;
00109     for ( imap = mapIdToId.begin(); imap != mapIdToId.end(); ++imap ) {
00110       if ( imap->second == newId )
00111         return imap->first;
00112     }
00113     return 0;
00114   }
00115 
00116 private:
00117   // get next free object identifier
00118   int getNextId()
00119   {
00120     int id = 1;
00121     while( mapIdToIOR.find( id ) != mapIdToIOR.end() )
00122       id++;
00123     return id;
00124   }
00125 
00126   map<int, string> mapIdToIOR;      // persistent-to-transient map
00127   map<int, int>    mapIdToId;       // used to translate object from persistent to transient form
00128 };
00129 
00130 // ===========================================================
00131 // SMESH module's engine
00132 // ==========================================================
00133 class SMESH_I_EXPORT SMESH_Gen_i:
00134   public virtual POA_SMESH::SMESH_Gen,
00135   public virtual Engines_Component_i
00136 {
00137 public:
00138   // Get last created instance of the class
00139   static SMESH_Gen_i* GetSMESHGen() { return mySMESHGen;}
00140   // Get ORB object
00141   static CORBA::ORB_var GetORB() { return myOrb;}
00142   // Get SMESH module's POA object
00143   static PortableServer::POA_var GetPOA() { return myPoa;}
00144   // Get Naming Service object
00145   static SALOME_NamingService* GetNS();
00146   // Get SALOME_LifeCycleCORBA object
00147   static SALOME_LifeCycleCORBA* GetLCC();
00148   // Retrieve and get GEOM engine reference
00149   static GEOM::GEOM_Gen_ptr GetGeomEngine();
00150   // Get object of the CORBA reference
00151   static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
00152   // Get CORBA object corresponding to the SALOMEDS::SObject
00153   static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject );
00154   // Get the SALOMEDS::SObject corresponding to a CORBA object
00155   static SALOMEDS::SObject_ptr ObjectToSObject(SALOMEDS::Study_ptr theStudy,
00156                                                CORBA::Object_ptr   theObject);
00157   // Get GEOM Object correspoding to TopoDS_Shape
00158   GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape );
00159   // Get TopoDS_Shape correspoding to GEOM_Object
00160   TopoDS_Shape GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject);
00161 
00162   // Default constructor
00163   SMESH_Gen_i();
00164   // Standard constructor
00165   SMESH_Gen_i( CORBA::ORB_ptr            orb,
00166                PortableServer::POA_ptr   poa,
00167                PortableServer::ObjectId* contId,
00168                const char*               instanceName,
00169                const char*               interfaceName );
00170   // Destructor
00171   virtual ~SMESH_Gen_i();
00172 
00173   // *****************************************
00174   // Interface methods
00175   // *****************************************
00176   // Set a new Mesh object name
00177   void SetName(const char* theIOR,
00178                const char* theName);
00179 
00180   //GEOM::GEOM_Gen_ptr SetGeomEngine( const char* containerLoc );
00181   void SetGeomEngine( GEOM::GEOM_Gen_ptr geomcompo );
00182 
00183   // Set current study
00184   void SetEmbeddedMode( CORBA::Boolean theMode );
00185   // Get current study
00186   CORBA::Boolean IsEmbeddedMode();
00187 
00188   // Set current study
00189   void SetCurrentStudy( SALOMEDS::Study_ptr theStudy );
00190   // Get current study
00191   SALOMEDS::Study_ptr GetCurrentStudy();
00192 
00193   // Create hypothesis/algorothm of given type
00194   SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const char* theHypType,
00195                                                 const char* theLibName)
00196     throw ( SALOME::SALOME_Exception );
00197 
00198   // Return hypothesis of given type holding parameter values of the existing mesh
00199   SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char*           theHypType,
00200                                                             const char*           theLibName,
00201                                                             SMESH::SMESH_Mesh_ptr theMesh,
00202                                                             GEOM::GEOM_Object_ptr theGeom,
00203                                                             CORBA::Boolean        byMesh)
00204     throw ( SALOME::SALOME_Exception );
00205 
00206   // Preferences
00207   // ------------
00212   void SetBoundaryBoxSegmentation( CORBA::Long theNbSegments ) throw ( SALOME::SALOME_Exception );
00216   void SetDefaultNbSegments(CORBA::Long theNbSegments) throw ( SALOME::SALOME_Exception );
00217 
00221   virtual void  SetOption(const char*, const char*);
00225   virtual char* GetOption(const char*);
00226 
00230   bool ToForgetMeshDataOnHypModif() const { return myToForgetMeshDataOnHypModif; }
00231 
00232 
00233   // Create empty mesh on a shape
00234   SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Object_ptr theShapeObject )
00235     throw ( SALOME::SALOME_Exception );
00236 
00237   // Create empty mesh
00238   SMESH::SMESH_Mesh_ptr CreateEmptyMesh()
00239     throw ( SALOME::SALOME_Exception );
00240 
00241   //  Create mesh(es) and import data from UNV fileter
00242   SMESH::SMESH_Mesh_ptr CreateMeshesFromUNV( const char* theFileName )
00243     throw ( SALOME::SALOME_Exception );
00244 
00245   //  Create mesh(es) and import data from MED file
00246   SMESH::mesh_array* CreateMeshesFromMED( const char* theFileName,
00247                                           SMESH::DriverMED_ReadStatus& theStatus )
00248     throw ( SALOME::SALOME_Exception );
00249 
00250   //  Create mesh(es) and import data from MED file
00251   SMESH::mesh_array* CreateMeshesFromSAUV( const char* theFileName,
00252                                            SMESH::DriverMED_ReadStatus& theStatus )
00253     throw ( SALOME::SALOME_Exception );
00254 
00255   //  Create mesh(es) and import data from STL file
00256   SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const char* theFileName )
00257     throw ( SALOME::SALOME_Exception );
00258 
00259   //  Create mesh(es) and import data from CGNS file
00260   SMESH::mesh_array* CreateMeshesFromCGNS( const char* theFileName,
00261                                            SMESH::DriverMED_ReadStatus& theStatus )
00262     throw ( SALOME::SALOME_Exception );
00263 
00264   // Copy a part of mesh
00265   SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
00266                                  const char*               meshName,
00267                                  CORBA::Boolean            toCopyGroups,
00268                                  CORBA::Boolean            toKeepIDs);
00269 
00270   // Compute mesh on a shape
00271   CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh,
00272                           GEOM::GEOM_Object_ptr theShapeObject )
00273     throw ( SALOME::SALOME_Exception );
00274 
00275   // Cancel Compute mesh on a shape
00276   void CancelCompute( SMESH::SMESH_Mesh_ptr theMesh,
00277                       GEOM::GEOM_Object_ptr theShapeObject );
00278 
00282   SMESH::compute_error_array* GetComputeErrors(SMESH::SMESH_Mesh_ptr theMesh,
00283                                                GEOM::GEOM_Object_ptr  theShapeObject )
00284     throw ( SALOME::SALOME_Exception );
00285 
00291   SMESH::long_array* Evaluate(SMESH::SMESH_Mesh_ptr theMesh,
00292                               GEOM::GEOM_Object_ptr theShapeObject)
00293     throw ( SALOME::SALOME_Exception );
00294 
00295   // Returns true if mesh contains enough data to be computed
00296   CORBA::Boolean IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh,
00297                                    GEOM::GEOM_Object_ptr theShapeObject )
00298     throw ( SALOME::SALOME_Exception );
00299 
00305   SMESH::MeshPreviewStruct* Precompute( SMESH::SMESH_Mesh_ptr theMesh,
00306                                         GEOM::GEOM_Object_ptr theSubObject,
00307                                         SMESH::Dimension      theDimension,
00308                                         SMESH::long_array&    theShapesId )
00309     throw ( SALOME::SALOME_Exception );
00310 
00311   // Returns errors of hypotheses definintion
00312   SMESH::algo_error_array* GetAlgoState( SMESH::SMESH_Mesh_ptr theMesh,
00313                                          GEOM::GEOM_Object_ptr theSubObject )
00314       throw ( SALOME::SALOME_Exception );
00315 
00316   // Return mesh elements preventing computation of a subshape
00317   SMESH::MeshPreviewStruct* GetBadInputElements( SMESH::SMESH_Mesh_ptr theMesh,
00318                                                  CORBA::Short          theSubShapeID )
00319     throw ( SALOME::SALOME_Exception );
00320 
00321   // Get sub-shapes unique ID's list
00322   SMESH::long_array* GetSubShapesId( GEOM::GEOM_Object_ptr      theMainShapeObject,
00323                                      const SMESH::object_array& theListOfSubShape )
00324     throw ( SALOME::SALOME_Exception );
00325 
00326   // Return geometrical object the given element is built on. Publish it in study.
00327   GEOM::GEOM_Object_ptr GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
00328                                                   CORBA::Long            theElementID,
00329                                                   const char*            theGeomName)
00330     throw ( SALOME::SALOME_Exception );
00331 
00332   // Return geometrical object the given element is built on. Don't publish it in study.
00333   GEOM::GEOM_Object_ptr FindGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
00334                                                    CORBA::Long            theElementID)
00335     throw ( SALOME::SALOME_Exception );
00336 
00337   // Concatenate the given meshes into one mesh
00338   SMESH::SMESH_Mesh_ptr ConcatenateCommon(const SMESH::mesh_array& theMeshesArray,
00339                                           CORBA::Boolean           theUniteIdenticalGroups,
00340                                           CORBA::Boolean           theMergeNodesAndElements,
00341                                           CORBA::Double            theMergeTolerance,
00342                                           CORBA::Boolean           theCommonGroups)
00343     throw ( SALOME::SALOME_Exception );
00344 
00345   // Concatenate the given meshes into one mesh
00346   SMESH::SMESH_Mesh_ptr Concatenate(const SMESH::mesh_array& theMeshesArray,
00347                                     CORBA::Boolean           theUniteIdenticalGroups,
00348                                     CORBA::Boolean           theMergeNodesAndElements,
00349                                     CORBA::Double            theMergeTolerance)
00350     throw ( SALOME::SALOME_Exception );
00351 
00352   // Concatenate the given meshes into one mesh
00353   // Create the groups of all elements from initial meshes
00354   SMESH::SMESH_Mesh_ptr ConcatenateWithGroups(const SMESH::mesh_array& theMeshesArray,
00355                                               CORBA::Boolean           theUniteIdenticalGroups,
00356                                               CORBA::Boolean           theMergeNodesAndElements,
00357                                               CORBA::Double            theMergeTolerance)
00358     throw ( SALOME::SALOME_Exception );
00359 
00360   // Get MED version of the file by its name
00361   CORBA::Boolean GetMEDVersion(const char* theFileName,
00362                                SMESH::MED_VERSION& theVersion);
00363 
00364   // Get names of meshes defined in file with the specified name
00365   SMESH::string_array* GetMeshNames(const char* theFileName);
00366 
00367   // ****************************************************
00368   // Interface inherited methods (from SALOMEDS::Driver)
00369   // ****************************************************
00370 
00371   // Save SMESH data
00372   SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent,
00373                          const char*              theURL,
00374                          bool                     isMultiFile );
00375   // Load SMESH data
00376   bool Load( SALOMEDS::SComponent_ptr theComponent,
00377              const SALOMEDS::TMPFile& theStream,
00378              const char*              theURL,
00379              bool                     isMultiFile );
00380   // Save SMESH data in ASCII format
00381   SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr theComponent,
00382                                 const char*              theURL,
00383                                 bool                     isMultiFile );
00384   // Load SMESH data in ASCII format
00385   bool LoadASCII( SALOMEDS::SComponent_ptr theComponent,
00386                   const SALOMEDS::TMPFile& theStream,
00387                   const char*              theURL,
00388                   bool                     isMultiFile );
00389 
00390   // Create filter manager
00391   SMESH::FilterManager_ptr CreateFilterManager();
00392 
00393   // Return a pattern mesher
00394   SMESH::SMESH_Pattern_ptr GetPattern();
00395 
00396   // Create measurement instance
00397   SMESH::Measurements_ptr  CreateMeasurements();
00398 
00399   // Clears study-connected data when it is closed
00400   void Close( SALOMEDS::SComponent_ptr theComponent );
00401 
00402   // Get component data type
00403   char* ComponentDataType();
00404 
00405   // Transform data from transient form to persistent
00406   char* IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject,
00407                                 const char*           IORString,
00408                                 CORBA::Boolean        isMultiFile,
00409                                 CORBA::Boolean        isASCII );
00410   // Transform data from persistent form to transient
00411   char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject,
00412                                 const char*           aLocalPersistentID,
00413                                 CORBA::Boolean        isMultiFile,
00414                                 CORBA::Boolean        isASCII );
00415 
00416   // Returns true if object can be published in the study
00417   bool CanPublishInStudy( CORBA::Object_ptr theIOR );
00418   // Publish object in the study
00419   SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::Study_ptr   theStudy,
00420                                         SALOMEDS::SObject_ptr theSObject,
00421                                         CORBA::Object_ptr     theObject,
00422                                         const char*           theName )
00423     throw ( SALOME::SALOME_Exception );
00424 
00425   // Copy-paste methods - returns true if object can be copied to the clipboard
00426   CORBA::Boolean CanCopy( SALOMEDS::SObject_ptr theObject ) { return false; }
00427   // Copy-paste methods - copy object to the clipboard
00428   SALOMEDS::TMPFile* CopyFrom( SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID ) { return false; }
00429   // Copy-paste methods - returns true if object can be pasted from the clipboard
00430   CORBA::Boolean CanPaste( const char* theComponentName, CORBA::Long theObjectID ) { return false; }
00431   // Copy-paste methods - paste object from the clipboard
00432   SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile& theStream,
00433                                    CORBA::Long              theObjectID,
00434                                    SALOMEDS::SObject_ptr    theObject ) {
00435     SALOMEDS::SObject_var aResultSO;
00436     return aResultSO._retn();
00437   }
00438 
00439   // ============
00440   // Dump python
00441   // ============
00442 
00443   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
00444                                        CORBA::Boolean isPublished,
00445                                        CORBA::Boolean isMultiFile,
00446                                        CORBA::Boolean& isValidScript);
00447 
00448   void AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString);
00449 
00450   void RemoveLastFromPythonScript (int theStudyID);
00451 
00452   void SavePython (SALOMEDS::Study_ptr theStudy);
00453 
00454   TCollection_AsciiString DumpPython_impl (SALOMEDS::Study_ptr theStudy,
00455                                            Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
00456                                            Resource_DataMapOfAsciiStringAsciiString& theNames,
00457                                            bool isPublished,
00458                                            bool isMultiFile,
00459                                            bool isHistoricalDump,
00460                                            bool& aValidScript,
00461                                            const TCollection_AsciiString& theSavedTrace);
00462 
00463   TCollection_AsciiString GetNewPythonLines (int theStudyID);
00464 
00465   void CleanPythonTrace (int theStudyID);
00466 
00467 
00468   // *****************************************
00469   // Internal methods
00470   // *****************************************
00471 public:
00472   // Get shape reader
00473   GEOM_Client* GetShapeReader();
00474 
00475   // Tags definition
00476   static long GetHypothesisRootTag();
00477   static long GetAlgorithmsRootTag();
00478   static long GetRefOnShapeTag();
00479   static long GetRefOnAppliedHypothesisTag();
00480   static long GetRefOnAppliedAlgorithmsTag();
00481   static long GetSubMeshOnVertexTag();
00482   static long GetSubMeshOnEdgeTag();
00483   static long GetSubMeshOnFaceTag();
00484   static long GetSubMeshOnSolidTag();
00485   static long GetSubMeshOnCompoundTag();
00486   static long GetSubMeshOnWireTag();
00487   static long GetSubMeshOnShellTag();
00488   static long GetNodeGroupsTag();
00489   static long GetEdgeGroupsTag();
00490   static long GetFaceGroupsTag();
00491   static long GetVolumeGroupsTag();
00492   static long Get0DElementsGroupsTag();
00493 
00494   // publishing methods
00495   SALOMEDS::SComponent_ptr PublishComponent(SALOMEDS::Study_ptr theStudy);
00496   SALOMEDS::SObject_ptr PublishMesh (SALOMEDS::Study_ptr   theStudy,
00497                                      SMESH::SMESH_Mesh_ptr theMesh,
00498                                      const char*           theName = 0);
00499   SALOMEDS::SObject_ptr PublishHypothesis (SALOMEDS::Study_ptr         theStudy,
00500                                            SMESH::SMESH_Hypothesis_ptr theHyp,
00501                                            const char*                 theName = 0);
00502   SALOMEDS::SObject_ptr PublishSubMesh (SALOMEDS::Study_ptr      theStudy,
00503                                         SMESH::SMESH_Mesh_ptr    theMesh,
00504                                         SMESH::SMESH_subMesh_ptr theSubMesh,
00505                                         GEOM::GEOM_Object_ptr    theShapeObject,
00506                                         const char*              theName = 0);
00507   SALOMEDS::SObject_ptr PublishGroup (SALOMEDS::Study_ptr    theStudy,
00508                                       SMESH::SMESH_Mesh_ptr  theMesh,
00509                                       SMESH::SMESH_GroupBase_ptr theGroup,
00510                                       GEOM::GEOM_Object_ptr  theShapeObject,
00511                                       const char*            theName = 0);
00512   bool AddHypothesisToShape(SALOMEDS::Study_ptr         theStudy,
00513                             SMESH::SMESH_Mesh_ptr       theMesh,
00514                             GEOM::GEOM_Object_ptr       theShapeObject,
00515                             SMESH::SMESH_Hypothesis_ptr theHyp);
00516   bool RemoveHypothesisFromShape(SALOMEDS::Study_ptr         theStudy,
00517                                  SMESH::SMESH_Mesh_ptr       theMesh,
00518                                  GEOM::GEOM_Object_ptr       theShapeObject,
00519                                  SMESH::SMESH_Hypothesis_ptr theHyp);
00520   SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr   theStudy,
00521                                                  SMESH::SMESH_Mesh_ptr theMesh,
00522                                                  GEOM::GEOM_Object_ptr theShape);
00523   static void SetName(SALOMEDS::SObject_ptr theSObject,
00524                       const char*           theName,
00525                       const char*           theDefaultName = 0);
00526 
00527   static void SetPixMap(SALOMEDS::SObject_ptr theSObject,
00528                         const char*           thePixMap);
00529 
00530   //  Get study context
00531   StudyContext* GetCurrentStudyContext();
00532 
00533   // Register an object in a StudyContext; return object id
00534   int RegisterObject(CORBA::Object_ptr theObject);
00535 
00536   // Return id of registered object
00537   CORBA::Long GetObjectId(CORBA::Object_ptr theObject);
00538 
00539   // Return an object that previously had an oldID
00540   template<class TInterface>
00541   typename TInterface::_var_type GetObjectByOldId( const int oldID )
00542   {
00543     if ( StudyContext* myStudyContext = GetCurrentStudyContext() ) {
00544       string ior = myStudyContext->getIORbyOldId( oldID );
00545       if ( !ior.empty() )
00546         return TInterface::_narrow(GetORB()->string_to_object( ior.c_str() ));
00547     }
00548     return TInterface::_nil();
00549   }
00550 
00551   // Get current study ID
00552   int GetCurrentStudyID();
00553 
00557   SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
00558 
00559   void UpdateParameters(/*CORBA::Object_ptr theObject,*/ const char* theParameters);
00560   char* GetParameters(CORBA::Object_ptr theObject);
00561   char* ParseParameters(const char* theParameters);
00562   const std::vector< std::string >& GetLastParameters() const { return myLastParameters; }
00563 
00564 private:
00565   // Create hypothesis of given type
00566   SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName,
00567                                                 const char* theLibName)
00568     throw ( SALOME::SALOME_Exception );
00569 
00570   // Create empty mesh on shape
00571   SMESH::SMESH_Mesh_ptr createMesh()
00572     throw ( SALOME::SALOME_Exception );
00573 
00574   static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
00575 
00576   SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName,
00577                                                 SMESH::DriverMED_ReadStatus& theStatus,
00578                                                 const char* theCommandNameForPython,
00579                                                 const char* theFileNameForPython);
00580 
00581 private:
00582   static GEOM::GEOM_Gen_var      myGeomGen;
00583   static CORBA::ORB_var          myOrb;         // ORB reference
00584   static PortableServer::POA_var myPoa;         // POA reference
00585   static SALOME_NamingService*   myNS;          // Naming Service
00586   static SALOME_LifeCycleCORBA*  myLCC;         // Life Cycle CORBA
00587   static SMESH_Gen_i*            mySMESHGen;    // Point to last created instance of the class
00588   ::SMESH_Gen                    myGen;         // SMESH_Gen local implementation
00589 
00590   // hypotheses managing
00591   map<string, GenericHypothesisCreator_i*> myHypCreatorMap;
00592 
00593   map<int, StudyContext*>   myStudyContextMap;  // Map of study context objects
00594 
00595   GEOM_Client*              myShapeReader;      // Shape reader
00596   SALOMEDS::Study_var       myCurrentStudy;     // Current study
00597   CORBA::Boolean            myIsEmbeddedMode;   // Current mode
00598 
00599   // To load full mesh data from study at hyp modification or not
00600   bool myToForgetMeshDataOnHypModif;
00601 
00602   // Dump Python: trace of API methods calls
00603   std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts;
00604   bool                                                     myIsHistoricalPythonDump;
00605   std::vector< std::string >                               myLastParameters;
00606 };
00607 
00608 
00609 namespace SMESH
00610 {
00611   template<class T>
00612   T
00613   DownCast(CORBA::Object_ptr theArg)
00614   {
00615     return dynamic_cast<T>(SMESH_Gen_i::GetServant(theArg).in());
00616   }
00617 }
00618 
00619 
00620 #endif