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