Salome HOME
2360fd4d17ea482d0307e8326fd7871056dfebac
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.hxx
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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_Gen.hxx"
40 #include "SMESH_Mesh_i.hxx"
41 #include "SMESH_Hypothesis_i.hxx"
42
43 #include <SALOME_Component_i.hxx>
44 #include <SALOME_NamingService.hxx>
45 #include <Utils_CorbaException.hxx>
46
47 #include <GEOM_Client.hxx>
48
49 #include <TCollection_AsciiString.hxx>
50 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
51 #include <TColStd_HSequenceOfAsciiString.hxx>
52 #include <NCollection_DataMap.hxx>
53
54 #include <map>
55 #include <sstream>
56
57 class SMESH_Mesh_i;
58 class SALOME_LifeCycleCORBA;
59
60 // ===========================================================
61 // Study context - store study-connected objects references
62 // ==========================================================
63 class SMESH_I_EXPORT StudyContext
64 {
65   typedef NCollection_DataMap< int, std::string > TInt2StringMap;
66   typedef NCollection_DataMap< int, int >         TInt2IntMap;
67 public:
68   // constructor
69   StudyContext() {}
70   // register object in the internal map and return its id
71   int         addObject( const std::string& theIOR );
72   // find the object id in the internal map by the IOR
73   int         findId( const std::string& theIOR );
74   // get object's IOR by id
75   std::string getIORbyId( const int theId );
76   // get object's IOR by old id
77   std::string getIORbyOldId( const int theOldId );
78   // maps old object id to the new one (used when restoring data)
79   void        mapOldToNew( const int oldId, const int newId );
80   // get old id by a new one
81   int         getOldId( const int newId );
82
83 private:
84   // get next free object identifier
85   int         getNextId() { return mapIdToIOR.Extent() + 1; }
86
87   TInt2StringMap mapIdToIOR; // persistent-to-transient map
88   TInt2IntMap    mapIdToId;  // to translate object from persistent to transient form
89 };
90
91 // ===========================================================
92 // SMESH module's engine
93 // ==========================================================
94 class SMESH_I_EXPORT SMESH_Gen_i:
95   public virtual POA_SMESH::SMESH_Gen,
96   public virtual Engines_Component_i
97 {
98 public:
99   // Get last created instance of the class
100   static SMESH_Gen_i* GetSMESHGen() { return mySMESHGen;}
101   // Get ORB object
102   static CORBA::ORB_var GetORB() { return myOrb;}
103   // Get SMESH module's POA object
104   static PortableServer::POA_var GetPOA() { return myPoa;}
105   // Get Naming Service object
106   static SALOME_NamingService* GetNS();
107   // Get SALOME_LifeCycleCORBA object
108   static SALOME_LifeCycleCORBA* GetLCC();
109   // Retrieve and get GEOM engine reference
110   static GEOM::GEOM_Gen_var GetGeomEngine();
111   // Get object of the CORBA reference
112   static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
113   // Get CORBA object corresponding to the SALOMEDS::SObject
114   static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject );
115   // Get the SALOMEDS::SObject corresponding to a CORBA object
116   static SALOMEDS::SObject_ptr ObjectToSObject(CORBA::Object_ptr theObject);
117   // Get the SALOMEDS::Study from naming service
118   static SALOMEDS::Study_var getStudyServant();
119   // Get GEOM Object corresponding to TopoDS_Shape
120   GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape );
121   // Get TopoDS_Shape corresponding to GEOM_Object
122   TopoDS_Shape GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject);
123
124   // Default constructor
125   SMESH_Gen_i();
126   // Standard constructor
127   SMESH_Gen_i( CORBA::ORB_ptr            orb,
128                PortableServer::POA_ptr   poa,
129                PortableServer::ObjectId* contId,
130                const char*               instanceName,
131                const char*               interfaceName );
132   // Destructor
133   virtual ~SMESH_Gen_i();
134
135   // *****************************************
136   // Interface methods
137   // *****************************************
138   // Set a new Mesh object name
139   void SetName(const char* theIOR,
140                const char* theName);
141
142   //GEOM::GEOM_Gen_ptr SetGeomEngine( const char* containerLoc );
143   void SetGeomEngine( GEOM::GEOM_Gen_ptr geomcompo );
144
145   // Set embedded mode
146   void SetEmbeddedMode( CORBA::Boolean theMode );
147   // Check embedded mode
148   CORBA::Boolean IsEmbeddedMode();
149
150   // Set enable publishing in the study
151   void SetEnablePublish( CORBA::Boolean theIsEnablePublish );
152
153   // Check enable publishing
154   CORBA::Boolean IsEnablePublish();
155
156   // Update study
157   void UpdateStudy();
158
159   // Create hypothesis/algorothm of given type
160   SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const char* theHypType,
161                                                 const char* theLibName)
162     throw ( SALOME::SALOME_Exception );
163
164   // Return hypothesis of given type holding parameter values of the existing mesh
165   SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char*           theHypType,
166                                                             const char*           theLibName,
167                                                             SMESH::SMESH_Mesh_ptr theMesh,
168                                                             GEOM::GEOM_Object_ptr theGeom,
169                                                             CORBA::Boolean        byMesh)
170     throw ( SALOME::SALOME_Exception );
171
172   /*
173    * Returns True if a hypothesis is assigned to a sole sub-mesh in a current Study
174    */
175   CORBA::Boolean GetSoleSubMeshUsingHyp( SMESH::SMESH_Hypothesis_ptr theHyp,
176                                          SMESH::SMESH_Mesh_out       theMesh,
177                                          GEOM::GEOM_Object_out       theShape);
178
179   // Preferences
180   // ------------
181   /*!
182    * Sets number of segments per diagonal of boundary box of geometry by which
183    * default segment length of appropriate 1D hypotheses is defined
184    */
185   void SetBoundaryBoxSegmentation( CORBA::Long theNbSegments ) throw ( SALOME::SALOME_Exception );
186   /*!
187    * \brief Sets default number of segments per edge
188    */
189   void SetDefaultNbSegments(CORBA::Long theNbSegments) throw ( SALOME::SALOME_Exception );
190
191   /*!
192     Set an option value
193   */
194   virtual void  SetOption(const char*, const char*);
195   /*!
196     Return an option value
197   */
198   virtual char* GetOption(const char*);
199
200   /*!
201    * To load full mesh data from study at hyp modification or not
202    */
203   bool ToForgetMeshDataOnHypModif() const { return myToForgetMeshDataOnHypModif; }
204
205
206   // Create empty mesh on a shape
207   SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Object_ptr theShapeObject )
208     throw ( SALOME::SALOME_Exception );
209
210   // Create empty mesh
211   SMESH::SMESH_Mesh_ptr CreateEmptyMesh()
212     throw ( SALOME::SALOME_Exception );
213
214   //  Create a mesh and import data from an UNV file
215   SMESH::SMESH_Mesh_ptr CreateMeshesFromUNV( const char* theFileName )
216     throw ( SALOME::SALOME_Exception );
217
218   //  Create mesh(es) and import data from MED file
219   SMESH::mesh_array* CreateMeshesFromMED( const char* theFileName,
220                                           SMESH::DriverMED_ReadStatus& theStatus )
221     throw ( SALOME::SALOME_Exception );
222
223   //  Create mesh(es) and import data from MED file
224   SMESH::mesh_array* CreateMeshesFromSAUV( const char* theFileName,
225                                            SMESH::DriverMED_ReadStatus& theStatus )
226     throw ( SALOME::SALOME_Exception );
227
228   //  Create a mesh and import data from a STL file
229   SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const char* theFileName )
230     throw ( SALOME::SALOME_Exception );
231
232   //  Create mesh(es) and import data from CGNS file
233   SMESH::mesh_array* CreateMeshesFromCGNS( const char* theFileName,
234                                            SMESH::DriverMED_ReadStatus& theStatus )
235     throw ( SALOME::SALOME_Exception );
236
237   //  Create a mesh and import data from a GMF file
238   SMESH::SMESH_Mesh_ptr CreateMeshesFromGMF( const char*             theFileName,
239                                              CORBA::Boolean          theMakeRequiredGroups,
240                                              SMESH::ComputeError_out theError)
241     throw ( SALOME::SALOME_Exception );
242
243   // Copy a part of mesh
244   SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
245                                  const char*               meshName,
246                                  CORBA::Boolean            toCopyGroups,
247                                  CORBA::Boolean            toKeepIDs);
248
249   // Compute mesh on a shape
250   CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh,
251                           GEOM::GEOM_Object_ptr theShapeObject )
252     throw ( SALOME::SALOME_Exception );
253
254   // Cancel Compute mesh on a shape
255   void CancelCompute( SMESH::SMESH_Mesh_ptr theMesh,
256                       GEOM::GEOM_Object_ptr theShapeObject );
257
258   /*!
259    * \brief Return errors of mesh computation
260    */
261   SMESH::compute_error_array* GetComputeErrors(SMESH::SMESH_Mesh_ptr theMesh,
262                                                GEOM::GEOM_Object_ptr  theShapeObject )
263     throw ( SALOME::SALOME_Exception );
264
265   /*!
266    * Evaluate mesh on a shape and
267    *  returns statistic of mesh elements
268    * Result array of number enityties
269    */
270   SMESH::long_array* Evaluate(SMESH::SMESH_Mesh_ptr theMesh,
271                               GEOM::GEOM_Object_ptr theShapeObject)
272     throw ( SALOME::SALOME_Exception );
273
274   // Returns true if mesh contains enough data to be computed
275   CORBA::Boolean IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh,
276                                    GEOM::GEOM_Object_ptr theShapeObject )
277     throw ( SALOME::SALOME_Exception );
278
279   /*!
280    * Calculate Mesh as preview till indicated dimension on shape
281    * First, verify list of hypothesis associated with the subShape.
282    * Return mesh preview structure
283    */
284   SMESH::MeshPreviewStruct* Precompute( SMESH::SMESH_Mesh_ptr theMesh,
285                                         GEOM::GEOM_Object_ptr theSubObject,
286                                         SMESH::Dimension      theDimension,
287                                         SMESH::long_array&    theShapesId )
288     throw ( SALOME::SALOME_Exception );
289
290   // Returns errors of hypotheses definition
291   SMESH::algo_error_array* GetAlgoState( SMESH::SMESH_Mesh_ptr theMesh,
292                                          GEOM::GEOM_Object_ptr theSubObject )
293       throw ( SALOME::SALOME_Exception );
294
295   // Return mesh elements preventing computation of a subshape
296   SMESH::MeshPreviewStruct* GetBadInputElements( SMESH::SMESH_Mesh_ptr theMesh,
297                                                  CORBA::Short          theSubShapeID )
298     throw ( SALOME::SALOME_Exception );
299
300   // Create groups of elements preventing computation of a sub-shape
301   SMESH::ListOfGroups* MakeGroupsOfBadInputElements( SMESH::SMESH_Mesh_ptr theMesh,
302                                                      CORBA::Short          theSubShapeID,
303                                                      const char*           theGroupName)
304     throw ( SALOME::SALOME_Exception );
305
306   // Get sub-shapes unique ID's list
307   SMESH::long_array* GetSubShapesId( GEOM::GEOM_Object_ptr      theMainShapeObject,
308                                      const SMESH::object_array& theListOfSubShape )
309     throw ( SALOME::SALOME_Exception );
310
311   // Return geometrical object the given element is built on. Publish it in study.
312   GEOM::GEOM_Object_ptr GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
313                                                   CORBA::Long            theElementID,
314                                                   const char*            theGeomName)
315     throw ( SALOME::SALOME_Exception );
316
317   // Return geometrical object the given element is built on. Don't publish it in study.
318   GEOM::GEOM_Object_ptr FindGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
319                                                    CORBA::Long            theElementID)
320     throw ( SALOME::SALOME_Exception );
321
322   // Concatenate the given meshes into one mesh
323   SMESH::SMESH_Mesh_ptr ConcatenateCommon(const SMESH::ListOfIDSources& meshesArray,
324                                           CORBA::Boolean                uniteIdenticalGroups,
325                                           CORBA::Boolean                mergeNodesAndElements,
326                                           CORBA::Double                 mergeTolerance,
327                                           CORBA::Boolean                commonGroups)
328     throw ( SALOME::SALOME_Exception );
329
330   // Concatenate the given meshes into one mesh
331   SMESH::SMESH_Mesh_ptr Concatenate(const SMESH::ListOfIDSources& meshesArray,
332                                     CORBA::Boolean                uniteIdenticalGroups,
333                                     CORBA::Boolean                mergeNodesAndElements,
334                                     CORBA::Double                 mergeTolerance)
335     throw ( SALOME::SALOME_Exception );
336
337   // Concatenate the given meshes into one mesh
338   // Create the groups of all elements from initial meshes
339   SMESH::SMESH_Mesh_ptr ConcatenateWithGroups(const SMESH::ListOfIDSources& meshesArray,
340                                               CORBA::Boolean                uniteIdenticalGroups,
341                                               CORBA::Boolean                mergeNodesAndElements,
342                                               CORBA::Double                 mergeTolerance)
343     throw ( SALOME::SALOME_Exception );
344
345   // Get version of MED format being used.
346   char* GetMEDFileVersion();
347
348   // Get MED version of the file by its name
349   char* GetMEDVersion(const char* theFileName);
350
351   // Check compatibility of file with MED format being used, read only.
352   CORBA::Boolean CheckCompatibility(const char* theFileName);
353
354   // Check compatibility of file with MED format being used, for append on write.
355   CORBA::Boolean CheckWriteCompatibility(const char* theFileName);
356
357   // Get names of meshes defined in file with the specified name
358   SMESH::string_array* GetMeshNames(const char* theFileName);
359
360   // ****************************************************
361   // Interface inherited methods (from SALOMEDS::Driver)
362   // ****************************************************
363
364   // Save SMESH data
365   SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent,
366                          const char*              theURL,
367                          bool                     isMultiFile );
368   // Load SMESH data
369   bool Load( SALOMEDS::SComponent_ptr theComponent,
370              const SALOMEDS::TMPFile& theStream,
371              const char*              theURL,
372              bool                     isMultiFile );
373   // Save SMESH data in ASCII format
374   SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr theComponent,
375                                 const char*              theURL,
376                                 bool                     isMultiFile );
377   // Load SMESH data in ASCII format
378   bool LoadASCII( SALOMEDS::SComponent_ptr theComponent,
379                   const SALOMEDS::TMPFile& theStream,
380                   const char*              theURL,
381                   bool                     isMultiFile );
382
383   // Create filter manager
384   SMESH::FilterManager_ptr CreateFilterManager();
385
386   // Return a pattern mesher
387   SMESH::SMESH_Pattern_ptr GetPattern();
388
389   // Create measurement instance
390   SMESH::Measurements_ptr  CreateMeasurements();
391
392   // Clears study-connected data when it is closed
393   void Close( SALOMEDS::SComponent_ptr theComponent );
394
395   // Get component data type
396   char* ComponentDataType();
397
398   // Transform data from transient form to persistent
399   char* IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject,
400                                 const char*           IORString,
401                                 CORBA::Boolean        isMultiFile,
402                                 CORBA::Boolean        isASCII );
403   // Transform data from persistent form to transient
404   char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject,
405                                 const char*           aLocalPersistentID,
406                                 CORBA::Boolean        isMultiFile,
407                                 CORBA::Boolean        isASCII );
408
409   // Returns true if object can be published in the study
410   bool CanPublishInStudy( CORBA::Object_ptr theIOR );
411   // Publish object in the study
412   SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::SObject_ptr theSObject,
413                                         CORBA::Object_ptr     theObject,
414                                         const char*           theName )
415     throw ( SALOME::SALOME_Exception );
416
417   // Copy-paste methods - returns true if object can be copied to the clipboard
418   CORBA::Boolean CanCopy( SALOMEDS::SObject_ptr theObject ) { return false; }
419   // Copy-paste methods - copy object to the clipboard
420   SALOMEDS::TMPFile* CopyFrom( SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID ) { return NULL; }
421   // Copy-paste methods - returns true if object can be pasted from the clipboard
422   CORBA::Boolean CanPaste( const char* theComponentName, CORBA::Long theObjectID ) { return false; }
423   // Copy-paste methods - paste object from the clipboard
424   SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile& theStream,
425                                    CORBA::Long              theObjectID,
426                                    SALOMEDS::SObject_ptr    theObject ) {
427     SALOMEDS::SObject_var aResultSO;
428     return aResultSO._retn();
429   }
430
431   // ============
432   // Version information
433   // ============
434
435   virtual char* getVersion();
436
437   // ============
438   // Dump python
439   // ============
440
441   virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
442                                        CORBA::Boolean isMultiFile,
443                                        CORBA::Boolean& isValidScript);
444
445   void AddToPythonScript (const TCollection_AsciiString& theString);
446
447   void RemoveLastFromPythonScript();
448
449   void SavePython();
450
451   TCollection_AsciiString DumpPython_impl (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
452                                            Resource_DataMapOfAsciiStringAsciiString& theNames,
453                                            bool isPublished,
454                                            bool isMultiFile,
455                                            bool isHistoricalDump,
456                                            bool& aValidScript,
457                                            TCollection_AsciiString& theSavedTrace);
458
459   TCollection_AsciiString GetNewPythonLines();
460
461   void CleanPythonTrace();
462
463   // *****************************************
464   // Internal methods
465   // *****************************************
466 public:
467   // Get shape reader
468   GEOM_Client* GetShapeReader();
469
470   // Tags definition
471   static long GetHypothesisRootTag();
472   static long GetAlgorithmsRootTag();
473   static long GetRefOnShapeTag();
474   static long GetRefOnAppliedHypothesisTag();
475   static long GetRefOnAppliedAlgorithmsTag();
476   static long GetSubMeshOnVertexTag();
477   static long GetSubMeshOnEdgeTag();
478   static long GetSubMeshOnFaceTag();
479   static long GetSubMeshOnSolidTag();
480   static long GetSubMeshOnCompoundTag();
481   static long GetSubMeshOnWireTag();
482   static long GetSubMeshOnShellTag();
483   static long GetNodeGroupsTag();
484   static long GetEdgeGroupsTag();
485   static long GetFaceGroupsTag();
486   static long GetVolumeGroupsTag();
487   static long Get0DElementsGroupsTag();
488   static long GetBallElementsGroupsTag();
489
490   // publishing methods
491   SALOMEDS::SComponent_ptr PublishComponent();
492   SALOMEDS::SObject_ptr PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
493                                      const char*           theName = 0);
494   SALOMEDS::SObject_ptr PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
495                                            const char*                 theName = 0);
496   SALOMEDS::SObject_ptr PublishSubMesh (SMESH::SMESH_Mesh_ptr    theMesh,
497                                         SMESH::SMESH_subMesh_ptr theSubMesh,
498                                         GEOM::GEOM_Object_ptr    theShapeObject,
499                                         const char*              theName = 0);
500   SALOMEDS::SObject_ptr PublishGroup (SMESH::SMESH_Mesh_ptr  theMesh,
501                                       SMESH::SMESH_GroupBase_ptr theGroup,
502                                       GEOM::GEOM_Object_ptr  theShapeObject,
503                                       const char*            theName = 0);
504   void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh);
505   bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr       theMesh,
506                             GEOM::GEOM_Object_ptr       theShapeObject,
507                             SMESH::SMESH_Hypothesis_ptr theHyp);
508   bool RemoveHypothesisFromShape(SMESH::SMESH_Mesh_ptr       theMesh,
509                                  GEOM::GEOM_Object_ptr       theShapeObject,
510                                  SMESH::SMESH_Hypothesis_ptr theHyp);
511   SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
512                                                  GEOM::GEOM_Object_ptr theShape);
513   static void SetName(SALOMEDS::SObject_ptr theSObject,
514                       const char*           theName,
515                       const char*           theDefaultName = 0);
516
517   static void SetPixMap(SALOMEDS::SObject_ptr theSObject,
518                         const char*           thePixMap);
519
520   //  Get study context
521   StudyContext* GetStudyContext();
522
523   // Register an object in a StudyContext; return object id
524   int RegisterObject(CORBA::Object_ptr theObject);
525
526   // Return id of registered object
527   CORBA::Long GetObjectId(CORBA::Object_ptr theObject);
528
529   // Return an object that previously had an oldID
530   template<class TInterface>
531     typename TInterface::_var_type GetObjectByOldId( const int oldID )
532   {
533     if ( myStudyContext ) {
534       std::string ior = myStudyContext->getIORbyOldId( oldID );
535       if ( !ior.empty() )
536         return TInterface::_narrow(GetORB()->string_to_object( ior.c_str() ));
537     }
538     return TInterface::_nil();
539   }
540
541   /*!
542    * \brief Find SObject for an algo
543    */
544   SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
545
546   void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters);
547   char* GetParameters(CORBA::Object_ptr theObject);
548   //char* ParseParameters(const char* theParameters);
549   const std::vector< int >&         GetLastParamIndices() const { return myLastParamIndex; }
550   const std::vector< std::string >& GetLastParameters() const { return myLastParameters; }
551   const std::string &               GetLastObjEntry() const { return myLastObj; }
552   std::vector< std::string >        GetAllParameters(const std::string& theObjectEntry) const;
553
554   // Move objects to the specified position
555   void Move( const SMESH::sobject_list& what,
556              SALOMEDS::SObject_ptr where,
557              CORBA::Long row );
558
559   CORBA::Boolean IsApplicable ( const char*           theAlgoType,
560                                 const char*           theLibName,
561                                 GEOM::GEOM_Object_ptr theShapeObject,
562                                 CORBA::Boolean        toCheckAll);
563
564   SMESH::long_array* GetInsideSphere( SMESH::SMESH_IDSource_ptr meshPart,
565                                       SMESH::ElementType        theElemType,
566                                       CORBA::Double             theX,
567                                       CORBA::Double             theY,
568                                       CORBA::Double             theZ,
569                                       CORBA::Double             theR);
570
571   SMESH::long_array* GetInsideBox( SMESH::SMESH_IDSource_ptr meshPart,
572                                    SMESH::ElementType        theElemType,
573                                    CORBA::Double             theX1,
574                                    CORBA::Double             theY1,
575                                    CORBA::Double             theZ1,
576                                    CORBA::Double             theX2,
577                                    CORBA::Double             theY2,
578                                    CORBA::Double             theZ2);
579
580   SMESH::long_array* GetInsideCylinder( SMESH::SMESH_IDSource_ptr meshPart,
581                                         SMESH::ElementType        theElemType,
582                                         CORBA::Double             theX,
583                                         CORBA::Double             theY,
584                                         CORBA::Double             theZ,
585                                         CORBA::Double             theDX,
586                                         CORBA::Double             theDY,
587                                         CORBA::Double             theDZ,
588                                         CORBA::Double             theH,
589                                         CORBA::Double             theR );
590
591   SMESH::long_array* GetInside( SMESH::SMESH_IDSource_ptr meshPart,
592                                 SMESH::ElementType        theElemType,
593                                 GEOM::GEOM_Object_ptr     theGeom,
594                                 CORBA::Double             theTolerance );
595
596 private:
597   // Get hypothesis creator
598   GenericHypothesisCreator_i* getHypothesisCreator( const char*  theHypName,
599                                                     const char*  theLibName,
600                                                     std::string& thePlatformLibName)
601   throw ( SALOME::SALOME_Exception );
602   // Create hypothesis of given type
603   SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName,
604                                                 const char* theLibName);
605   // Create empty mesh on shape
606   SMESH::SMESH_Mesh_ptr createMesh()
607     throw ( SALOME::SALOME_Exception );
608
609   static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
610
611   SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName,
612                                                 SMESH::DriverMED_ReadStatus& theStatus,
613                                                 const char* theCommandNameForPython,
614                                                 const char* theFileNameForPython);
615
616   std::vector<long> _GetInside(SMESH::SMESH_IDSource_ptr meshPart,
617                                SMESH::ElementType     theElemType,
618                                TopoDS_Shape& aShape,
619                                double* theTolerance = NULL);
620
621 private:
622   static GEOM::GEOM_Gen_var      myGeomGen;
623   static CORBA::ORB_var          myOrb;         // ORB reference
624   static PortableServer::POA_var myPoa;         // POA reference
625   static SALOME_NamingService*   myNS;          // Naming Service
626   static SALOME_LifeCycleCORBA*  myLCC;         // Life Cycle CORBA
627   static SMESH_Gen_i*            mySMESHGen;    // Point to last created instance of the class
628   ::SMESH_Gen                    myGen;         // SMESH_Gen local implementation
629
630   // hypotheses managing
631   std::map<std::string, GenericHypothesisCreator_i*> myHypCreatorMap;
632
633   StudyContext*                  myStudyContext;  // study context
634
635   GEOM_Client*                   myShapeReader;      // Shape reader
636   CORBA::Boolean                 myIsEmbeddedMode;   // Current mode
637   CORBA::Boolean                 myIsEnablePublish;  // Enable publishing
638
639   // Default color of groups
640   std::string myDefaultGroupColor;
641
642   // To load full mesh data from study at hyp modification or not
643   bool myToForgetMeshDataOnHypModif;
644
645   // Dump Python: trace of API methods calls
646   Handle(TColStd_HSequenceOfAsciiString) myPythonScript;
647   bool                                   myIsHistoricalPythonDump;
648   std::vector< int >                     myLastParamIndex;
649   std::vector< std::string >             myLastParameters;
650   std::string                            myLastObj;
651 };
652
653
654 namespace SMESH
655 {
656   template<class T>
657   T
658   DownCast(CORBA::Object_ptr theArg)
659   {
660     return dynamic_cast<T>(SMESH_Gen_i::GetServant(theArg).in());
661   }
662
663   /*!
664    * \brief Function used in SMESH_CATCH to convert a caught exception to
665    * SALOME::SALOME_Exception
666    */
667   inline void throwCorbaException(const char* excText)
668   {
669     THROW_SALOME_CORBA_EXCEPTION( excText, SALOME::INTERNAL_ERROR );
670   }
671 }
672
673
674 #endif