Salome HOME
Merge from V6_main (04/10/2012)
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.hxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SMESH_Gen_i.hxx
23 //  Author : Paul RASCLE, EDF
24 //  Module : SMESH
25
26 #ifndef _SMESH_GEN_I_HXX_
27 #define _SMESH_GEN_I_HXX_
28
29 #include "SMESH.hxx"
30
31 #include <SALOMEconfig.h>
32 #include CORBA_SERVER_HEADER(SMESH_Gen)
33 #include CORBA_SERVER_HEADER(SMESH_Mesh)
34 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
35 #include CORBA_CLIENT_HEADER(GEOM_Gen)
36 #include CORBA_CLIENT_HEADER(SALOMEDS)
37 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
38
39 #include "SMESH_Mesh_i.hxx"
40 #include "SMESH_Hypothesis_i.hxx"
41 #include "SALOME_Component_i.hxx"
42 #include "SALOME_NamingService.hxx"
43
44 #include "SMESH_Gen.hxx"
45 #include "GEOM_Client.hxx"
46
47 #include <TCollection_AsciiString.hxx>
48 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
49 #include <TColStd_HSequenceOfAsciiString.hxx>
50
51 #include <map>
52 #include <sstream>
53
54 class SMESH_Mesh_i;
55 class SALOME_LifeCycleCORBA;
56
57 // ===========================================================
58 // Study context - stores study-connected objects references
59 // ==========================================================
60 class SMESH_I_EXPORT StudyContext
61 {
62 public:
63   // constructor
64   StudyContext() {}
65   // destructor
66   ~StudyContext()
67   {
68     mapIdToIOR.clear();
69     mapIdToId.clear();
70   }
71   // register object in the internal map and return its id
72   int addObject( string theIOR )
73   {
74     int nextId = getNextId();
75     mapIdToIOR[ nextId ]  = theIOR;
76     return nextId;
77   }
78   // find the object id in the internal map by the IOR
79   int findId( string theIOR )
80   {
81     map<int, string>::iterator imap;
82     for ( imap = mapIdToIOR.begin(); imap != mapIdToIOR.end(); ++imap ) {
83       if ( imap->second == theIOR )
84         return imap->first;
85     }
86     return 0;
87   }
88   // get object's IOR by id
89   string getIORbyId( const int theId )
90   {
91     if ( mapIdToIOR.find( theId ) != mapIdToIOR.end() )
92       return mapIdToIOR[ theId ];
93     return string( "" );
94   }
95   // get object's IOR by old id
96   string getIORbyOldId( const int theOldId )
97   {
98     if ( mapIdToId.find( theOldId ) != mapIdToId.end() )
99       return getIORbyId( mapIdToId[ theOldId ] );
100     return string( "" );
101   }
102   // maps old object id to the new one (used when restoring data)
103   void mapOldToNew( const int oldId, const int newId ) {
104     mapIdToId[ oldId ] = newId;
105   }
106   // get old id by a new one
107   int getOldId( const int newId ) {
108     map<int, int>::iterator imap;
109     for ( imap = mapIdToId.begin(); imap != mapIdToId.end(); ++imap ) {
110       if ( imap->second == newId )
111         return imap->first;
112     }
113     return 0;
114   }
115
116 private:
117   // get next free object identifier
118   int getNextId()
119   {
120     int id = 1;
121     while( mapIdToIOR.find( id ) != mapIdToIOR.end() )
122       id++;
123     return id;
124   }
125
126   map<int, string> mapIdToIOR;      // persistent-to-transient map
127   map<int, int>    mapIdToId;       // used to translate object from persistent to transient form
128 };
129
130 // ===========================================================
131 // SMESH module's engine
132 // ==========================================================
133 class SMESH_I_EXPORT SMESH_Gen_i:
134   public virtual POA_SMESH::SMESH_Gen,
135   public virtual Engines_Component_i
136 {
137 public:
138   // Get last created instance of the class
139   static SMESH_Gen_i* GetSMESHGen() { return mySMESHGen;}
140   // Get ORB object
141   static CORBA::ORB_var GetORB() { return myOrb;}
142   // Get SMESH module's POA object
143   static PortableServer::POA_var GetPOA() { return myPoa;}
144   // Get Naming Service object
145   static SALOME_NamingService* GetNS();
146   // Get SALOME_LifeCycleCORBA object
147   static SALOME_LifeCycleCORBA* GetLCC();
148   // Retrieve and get GEOM engine reference
149   static GEOM::GEOM_Gen_ptr GetGeomEngine();
150   // Get object of the CORBA reference
151   static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
152   // Get CORBA object corresponding to the SALOMEDS::SObject
153   static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject );
154   // Get the SALOMEDS::SObject corresponding to a CORBA object
155   static SALOMEDS::SObject_ptr ObjectToSObject(SALOMEDS::Study_ptr theStudy,
156                                                CORBA::Object_ptr   theObject);
157   // Get GEOM Object correspoding to TopoDS_Shape
158   GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape );
159   // Get TopoDS_Shape correspoding to GEOM_Object
160   TopoDS_Shape GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject);
161
162   // Default constructor
163   SMESH_Gen_i();
164   // Standard constructor
165   SMESH_Gen_i( CORBA::ORB_ptr            orb,
166                PortableServer::POA_ptr   poa,
167                PortableServer::ObjectId* contId,
168                const char*               instanceName,
169                const char*               interfaceName );
170   // Destructor
171   virtual ~SMESH_Gen_i();
172
173   // *****************************************
174   // Interface methods
175   // *****************************************
176   // Set a new Mesh object name
177   void SetName(const char* theIOR,
178                const char* theName);
179
180   //GEOM::GEOM_Gen_ptr SetGeomEngine( const char* containerLoc );
181   void SetGeomEngine( GEOM::GEOM_Gen_ptr geomcompo );
182
183   // Set current study
184   void SetEmbeddedMode( CORBA::Boolean theMode );
185   // Get current study
186   CORBA::Boolean IsEmbeddedMode();
187
188   // Set current study
189   void SetCurrentStudy( SALOMEDS::Study_ptr theStudy );
190   // Get current study
191   SALOMEDS::Study_ptr GetCurrentStudy();
192
193   // Create hypothesis/algorothm of given type
194   SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const char* theHypType,
195                                                 const char* theLibName)
196     throw ( SALOME::SALOME_Exception );
197
198   // Return hypothesis of given type holding parameter values of the existing mesh
199   SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char*           theHypType,
200                                                             const char*           theLibName,
201                                                             SMESH::SMESH_Mesh_ptr theMesh,
202                                                             GEOM::GEOM_Object_ptr theGeom,
203                                                             CORBA::Boolean        byMesh)
204     throw ( SALOME::SALOME_Exception );
205
206   // Preferences
207   // ------------
208   /*!
209    * Sets number of segments per diagonal of boundary box of geometry by which
210    * default segment length of appropriate 1D hypotheses is defined
211    */
212   void SetBoundaryBoxSegmentation( CORBA::Long theNbSegments ) throw ( SALOME::SALOME_Exception );
213   /*!
214    * \brief Sets default number of segments per edge
215    */
216   void SetDefaultNbSegments(CORBA::Long theNbSegments) throw ( SALOME::SALOME_Exception );
217
218   /*!
219     Set an option value
220   */
221   virtual void  SetOption(const char*, const char*);
222   /*!
223     Return an option value
224   */
225   virtual char* GetOption(const char*);
226
227   /*!
228    * To load full mesh data from study at hyp modification or not
229    */
230   bool ToForgetMeshDataOnHypModif() const { return myToForgetMeshDataOnHypModif; }
231
232
233   // Create empty mesh on a shape
234   SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Object_ptr theShapeObject )
235     throw ( SALOME::SALOME_Exception );
236
237   // Create empty mesh
238   SMESH::SMESH_Mesh_ptr CreateEmptyMesh()
239     throw ( SALOME::SALOME_Exception );
240
241   //  Create a mesh and import data from an UNV file
242   SMESH::SMESH_Mesh_ptr CreateMeshesFromUNV( const char* theFileName )
243     throw ( SALOME::SALOME_Exception );
244
245   //  Create mesh(es) and import data from MED file
246   SMESH::mesh_array* CreateMeshesFromMED( const char* theFileName,
247                                           SMESH::DriverMED_ReadStatus& theStatus )
248     throw ( SALOME::SALOME_Exception );
249
250   //  Create mesh(es) and import data from MED file
251   SMESH::mesh_array* CreateMeshesFromSAUV( const char* theFileName,
252                                            SMESH::DriverMED_ReadStatus& theStatus )
253     throw ( SALOME::SALOME_Exception );
254
255   //  Create a mesh and import data from a STL file
256   SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const char* theFileName )
257     throw ( SALOME::SALOME_Exception );
258
259   //  Create mesh(es) and import data from CGNS file
260   SMESH::mesh_array* CreateMeshesFromCGNS( const char* theFileName,
261                                            SMESH::DriverMED_ReadStatus& theStatus )
262     throw ( SALOME::SALOME_Exception );
263
264   //  Create a mesh and import data from a GMF file
265   SMESH::SMESH_Mesh_ptr CreateMeshesFromGMF( const char*             theFileName,
266                                              SMESH::ComputeError_out theError)
267     throw ( SALOME::SALOME_Exception );
268
269   // Copy a part of mesh
270   SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
271                                  const char*               meshName,
272                                  CORBA::Boolean            toCopyGroups,
273                                  CORBA::Boolean            toKeepIDs);
274
275   // Compute mesh on a shape
276   CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh,
277                           GEOM::GEOM_Object_ptr theShapeObject )
278     throw ( SALOME::SALOME_Exception );
279
280   // Cancel Compute mesh on a shape
281   void CancelCompute( SMESH::SMESH_Mesh_ptr theMesh,
282                       GEOM::GEOM_Object_ptr theShapeObject );
283
284   /*!
285    * \brief Return errors of mesh computation
286    */
287   SMESH::compute_error_array* GetComputeErrors(SMESH::SMESH_Mesh_ptr theMesh,
288                                                GEOM::GEOM_Object_ptr  theShapeObject )
289     throw ( SALOME::SALOME_Exception );
290
291   /*!
292    * Evaluate mesh on a shape and
293    *  returns statistic of mesh elements
294    * Result array of number enityties
295    */
296   SMESH::long_array* Evaluate(SMESH::SMESH_Mesh_ptr theMesh,
297                               GEOM::GEOM_Object_ptr theShapeObject)
298     throw ( SALOME::SALOME_Exception );
299
300   // Returns true if mesh contains enough data to be computed
301   CORBA::Boolean IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh,
302                                    GEOM::GEOM_Object_ptr theShapeObject )
303     throw ( SALOME::SALOME_Exception );
304
305   /*!
306    * Calculate Mesh as preview till indicated dimension on shape
307    * First, verify list of hypothesis associated with the subShape.
308    * Return mesh preview structure
309    */
310   SMESH::MeshPreviewStruct* Precompute( SMESH::SMESH_Mesh_ptr theMesh,
311                                         GEOM::GEOM_Object_ptr theSubObject,
312                                         SMESH::Dimension      theDimension,
313                                         SMESH::long_array&    theShapesId )
314     throw ( SALOME::SALOME_Exception );
315
316   // Returns errors of hypotheses definintion
317   SMESH::algo_error_array* GetAlgoState( SMESH::SMESH_Mesh_ptr theMesh,
318                                          GEOM::GEOM_Object_ptr theSubObject )
319       throw ( SALOME::SALOME_Exception );
320
321   // Return mesh elements preventing computation of a subshape
322   SMESH::MeshPreviewStruct* GetBadInputElements( SMESH::SMESH_Mesh_ptr theMesh,
323                                                  CORBA::Short          theSubShapeID )
324     throw ( SALOME::SALOME_Exception );
325
326   // Get sub-shapes unique ID's list
327   SMESH::long_array* GetSubShapesId( GEOM::GEOM_Object_ptr      theMainShapeObject,
328                                      const SMESH::object_array& theListOfSubShape )
329     throw ( SALOME::SALOME_Exception );
330
331   // Return geometrical object the given element is built on. Publish it in study.
332   GEOM::GEOM_Object_ptr GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
333                                                   CORBA::Long            theElementID,
334                                                   const char*            theGeomName)
335     throw ( SALOME::SALOME_Exception );
336
337   // Return geometrical object the given element is built on. Don't publish it in study.
338   GEOM::GEOM_Object_ptr FindGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
339                                                    CORBA::Long            theElementID)
340     throw ( SALOME::SALOME_Exception );
341
342   // Concatenate the given meshes into one mesh
343   SMESH::SMESH_Mesh_ptr ConcatenateCommon(const SMESH::mesh_array& theMeshesArray,
344                                           CORBA::Boolean           theUniteIdenticalGroups,
345                                           CORBA::Boolean           theMergeNodesAndElements,
346                                           CORBA::Double            theMergeTolerance,
347                                           CORBA::Boolean           theCommonGroups)
348     throw ( SALOME::SALOME_Exception );
349
350   // Concatenate the given meshes into one mesh
351   SMESH::SMESH_Mesh_ptr Concatenate(const SMESH::mesh_array& theMeshesArray,
352                                     CORBA::Boolean           theUniteIdenticalGroups,
353                                     CORBA::Boolean           theMergeNodesAndElements,
354                                     CORBA::Double            theMergeTolerance)
355     throw ( SALOME::SALOME_Exception );
356
357   // Concatenate the given meshes into one mesh
358   // Create the groups of all elements from initial meshes
359   SMESH::SMESH_Mesh_ptr ConcatenateWithGroups(const SMESH::mesh_array& theMeshesArray,
360                                               CORBA::Boolean           theUniteIdenticalGroups,
361                                               CORBA::Boolean           theMergeNodesAndElements,
362                                               CORBA::Double            theMergeTolerance)
363     throw ( SALOME::SALOME_Exception );
364
365   // Get MED version of the file by its name
366   CORBA::Boolean GetMEDVersion(const char* theFileName,
367                                SMESH::MED_VERSION& theVersion);
368
369   // Get names of meshes defined in file with the specified name
370   SMESH::string_array* GetMeshNames(const char* theFileName);
371
372   // ****************************************************
373   // Interface inherited methods (from SALOMEDS::Driver)
374   // ****************************************************
375
376   // Save SMESH data
377   SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent,
378                          const char*              theURL,
379                          bool                     isMultiFile );
380   // Load SMESH data
381   bool Load( SALOMEDS::SComponent_ptr theComponent,
382              const SALOMEDS::TMPFile& theStream,
383              const char*              theURL,
384              bool                     isMultiFile );
385   // Save SMESH data in ASCII format
386   SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr theComponent,
387                                 const char*              theURL,
388                                 bool                     isMultiFile );
389   // Load SMESH data in ASCII format
390   bool LoadASCII( SALOMEDS::SComponent_ptr theComponent,
391                   const SALOMEDS::TMPFile& theStream,
392                   const char*              theURL,
393                   bool                     isMultiFile );
394
395   // Create filter manager
396   SMESH::FilterManager_ptr CreateFilterManager();
397
398   // Return a pattern mesher
399   SMESH::SMESH_Pattern_ptr GetPattern();
400
401   // Create measurement instance
402   SMESH::Measurements_ptr  CreateMeasurements();
403
404   // Clears study-connected data when it is closed
405   void Close( SALOMEDS::SComponent_ptr theComponent );
406
407   // Get component data type
408   char* ComponentDataType();
409
410   // Transform data from transient form to persistent
411   char* IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject,
412                                 const char*           IORString,
413                                 CORBA::Boolean        isMultiFile,
414                                 CORBA::Boolean        isASCII );
415   // Transform data from persistent form to transient
416   char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject,
417                                 const char*           aLocalPersistentID,
418                                 CORBA::Boolean        isMultiFile,
419                                 CORBA::Boolean        isASCII );
420
421   // Returns true if object can be published in the study
422   bool CanPublishInStudy( CORBA::Object_ptr theIOR );
423   // Publish object in the study
424   SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::Study_ptr   theStudy,
425                                         SALOMEDS::SObject_ptr theSObject,
426                                         CORBA::Object_ptr     theObject,
427                                         const char*           theName )
428     throw ( SALOME::SALOME_Exception );
429
430   // Copy-paste methods - returns true if object can be copied to the clipboard
431   CORBA::Boolean CanCopy( SALOMEDS::SObject_ptr theObject ) { return false; }
432   // Copy-paste methods - copy object to the clipboard
433   SALOMEDS::TMPFile* CopyFrom( SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID ) { return false; }
434   // Copy-paste methods - returns true if object can be pasted from the clipboard
435   CORBA::Boolean CanPaste( const char* theComponentName, CORBA::Long theObjectID ) { return false; }
436   // Copy-paste methods - paste object from the clipboard
437   SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile& theStream,
438                                    CORBA::Long              theObjectID,
439                                    SALOMEDS::SObject_ptr    theObject ) {
440     SALOMEDS::SObject_var aResultSO;
441     return aResultSO._retn();
442   }
443
444   // ============
445   // Dump python
446   // ============
447
448   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
449                                        CORBA::Boolean isPublished,
450                                        CORBA::Boolean isMultiFile,
451                                        CORBA::Boolean& isValidScript);
452
453   void AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString);
454
455   void RemoveLastFromPythonScript (int theStudyID);
456
457   void SavePython (SALOMEDS::Study_ptr theStudy);
458
459   TCollection_AsciiString DumpPython_impl (SALOMEDS::Study_ptr theStudy,
460                                            Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
461                                            Resource_DataMapOfAsciiStringAsciiString& theNames,
462                                            bool isPublished,
463                                            bool isMultiFile,
464                                            bool isHistoricalDump,
465                                            bool& aValidScript,
466                                            const TCollection_AsciiString& theSavedTrace);
467
468   TCollection_AsciiString GetNewPythonLines (int theStudyID);
469
470   void CleanPythonTrace (int theStudyID);
471
472
473   // *****************************************
474   // Internal methods
475   // *****************************************
476 public:
477   // Get shape reader
478   GEOM_Client* GetShapeReader();
479
480   // Tags definition
481   static long GetHypothesisRootTag();
482   static long GetAlgorithmsRootTag();
483   static long GetRefOnShapeTag();
484   static long GetRefOnAppliedHypothesisTag();
485   static long GetRefOnAppliedAlgorithmsTag();
486   static long GetSubMeshOnVertexTag();
487   static long GetSubMeshOnEdgeTag();
488   static long GetSubMeshOnFaceTag();
489   static long GetSubMeshOnSolidTag();
490   static long GetSubMeshOnCompoundTag();
491   static long GetSubMeshOnWireTag();
492   static long GetSubMeshOnShellTag();
493   static long GetNodeGroupsTag();
494   static long GetEdgeGroupsTag();
495   static long GetFaceGroupsTag();
496   static long GetVolumeGroupsTag();
497   static long Get0DElementsGroupsTag();
498   static long GetBallElementsGroupsTag();
499
500   // publishing methods
501   SALOMEDS::SComponent_ptr PublishComponent(SALOMEDS::Study_ptr theStudy);
502   SALOMEDS::SObject_ptr PublishMesh (SALOMEDS::Study_ptr   theStudy,
503                                      SMESH::SMESH_Mesh_ptr theMesh,
504                                      const char*           theName = 0);
505   SALOMEDS::SObject_ptr PublishHypothesis (SALOMEDS::Study_ptr         theStudy,
506                                            SMESH::SMESH_Hypothesis_ptr theHyp,
507                                            const char*                 theName = 0);
508   SALOMEDS::SObject_ptr PublishSubMesh (SALOMEDS::Study_ptr      theStudy,
509                                         SMESH::SMESH_Mesh_ptr    theMesh,
510                                         SMESH::SMESH_subMesh_ptr theSubMesh,
511                                         GEOM::GEOM_Object_ptr    theShapeObject,
512                                         const char*              theName = 0);
513   SALOMEDS::SObject_ptr PublishGroup (SALOMEDS::Study_ptr    theStudy,
514                                       SMESH::SMESH_Mesh_ptr  theMesh,
515                                       SMESH::SMESH_GroupBase_ptr theGroup,
516                                       GEOM::GEOM_Object_ptr  theShapeObject,
517                                       const char*            theName = 0);
518   bool AddHypothesisToShape(SALOMEDS::Study_ptr         theStudy,
519                             SMESH::SMESH_Mesh_ptr       theMesh,
520                             GEOM::GEOM_Object_ptr       theShapeObject,
521                             SMESH::SMESH_Hypothesis_ptr theHyp);
522   bool RemoveHypothesisFromShape(SALOMEDS::Study_ptr         theStudy,
523                                  SMESH::SMESH_Mesh_ptr       theMesh,
524                                  GEOM::GEOM_Object_ptr       theShapeObject,
525                                  SMESH::SMESH_Hypothesis_ptr theHyp);
526   SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr   theStudy,
527                                                  SMESH::SMESH_Mesh_ptr theMesh,
528                                                  GEOM::GEOM_Object_ptr theShape);
529   static void SetName(SALOMEDS::SObject_ptr theSObject,
530                       const char*           theName,
531                       const char*           theDefaultName = 0);
532
533   static void SetPixMap(SALOMEDS::SObject_ptr theSObject,
534                         const char*           thePixMap);
535
536   //  Get study context
537   StudyContext* GetCurrentStudyContext();
538
539   // Register an object in a StudyContext; return object id
540   int RegisterObject(CORBA::Object_ptr theObject);
541
542   // Return id of registered object
543   CORBA::Long GetObjectId(CORBA::Object_ptr theObject);
544
545   // Return an object that previously had an oldID
546   template<class TInterface>
547   typename TInterface::_var_type GetObjectByOldId( const int oldID )
548   {
549     if ( StudyContext* myStudyContext = GetCurrentStudyContext() ) {
550       string ior = myStudyContext->getIORbyOldId( oldID );
551       if ( !ior.empty() )
552         return TInterface::_narrow(GetORB()->string_to_object( ior.c_str() ));
553     }
554     return TInterface::_nil();
555   }
556
557   // Get current study ID
558   int GetCurrentStudyID();
559
560   /*!
561    * \brief Find SObject for an algo
562    */
563   SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
564
565   void UpdateParameters(/*CORBA::Object_ptr theObject,*/ const char* theParameters);
566   char* GetParameters(CORBA::Object_ptr theObject);
567   char* ParseParameters(const char* theParameters);
568   const std::vector< std::string >& GetLastParameters() const { return myLastParameters; }
569
570 private:
571   // Create hypothesis of given type
572   SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName,
573                                                 const char* theLibName)
574     throw ( SALOME::SALOME_Exception );
575
576   // Create empty mesh on shape
577   SMESH::SMESH_Mesh_ptr createMesh()
578     throw ( SALOME::SALOME_Exception );
579
580   static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
581
582   SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName,
583                                                 SMESH::DriverMED_ReadStatus& theStatus,
584                                                 const char* theCommandNameForPython,
585                                                 const char* theFileNameForPython);
586
587   void setCurrentStudy( SALOMEDS::Study_ptr theStudy,
588                         bool                theStudyIsBeingClosed=false);
589
590 private:
591   static GEOM::GEOM_Gen_var      myGeomGen;
592   static CORBA::ORB_var          myOrb;         // ORB reference
593   static PortableServer::POA_var myPoa;         // POA reference
594   static SALOME_NamingService*   myNS;          // Naming Service
595   static SALOME_LifeCycleCORBA*  myLCC;         // Life Cycle CORBA
596   static SMESH_Gen_i*            mySMESHGen;    // Point to last created instance of the class
597   ::SMESH_Gen                    myGen;         // SMESH_Gen local implementation
598
599   // hypotheses managing
600   map<string, GenericHypothesisCreator_i*> myHypCreatorMap;
601
602   map<int, StudyContext*>   myStudyContextMap;  // Map of study context objects
603
604   GEOM_Client*              myShapeReader;      // Shape reader
605   SALOMEDS::Study_var       myCurrentStudy;     // Current study
606   CORBA::Boolean            myIsEmbeddedMode;   // Current mode
607
608   // To load full mesh data from study at hyp modification or not
609   bool myToForgetMeshDataOnHypModif;
610
611   // Dump Python: trace of API methods calls
612   std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts;
613   bool                                                     myIsHistoricalPythonDump;
614   std::vector< std::string >                               myLastParameters;
615 };
616
617
618 namespace SMESH
619 {
620   template<class T>
621   T
622   DownCast(CORBA::Object_ptr theArg)
623   {
624     return dynamic_cast<T>(SMESH_Gen_i::GetServant(theArg).in());
625   }
626 }
627
628
629 #endif