Salome HOME
Restore change of mesh icon depending on its status
[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.
352   CORBA::Boolean CheckCompatibility(const char* theFileName);
353
354   // Get names of meshes defined in file with the specified name
355   SMESH::string_array* GetMeshNames(const char* theFileName);
356
357   // ****************************************************
358   // Interface inherited methods (from SALOMEDS::Driver)
359   // ****************************************************
360
361   // Save SMESH data
362   SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent,
363                          const char*              theURL,
364                          bool                     isMultiFile );
365   // Load SMESH data
366   bool Load( SALOMEDS::SComponent_ptr theComponent,
367              const SALOMEDS::TMPFile& theStream,
368              const char*              theURL,
369              bool                     isMultiFile );
370   // Save SMESH data in ASCII format
371   SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr theComponent,
372                                 const char*              theURL,
373                                 bool                     isMultiFile );
374   // Load SMESH data in ASCII format
375   bool LoadASCII( SALOMEDS::SComponent_ptr theComponent,
376                   const SALOMEDS::TMPFile& theStream,
377                   const char*              theURL,
378                   bool                     isMultiFile );
379
380   // Create filter manager
381   SMESH::FilterManager_ptr CreateFilterManager();
382
383   // Return a pattern mesher
384   SMESH::SMESH_Pattern_ptr GetPattern();
385
386   // Create measurement instance
387   SMESH::Measurements_ptr  CreateMeasurements();
388
389   // Clears study-connected data when it is closed
390   void Close( SALOMEDS::SComponent_ptr theComponent );
391
392   // Get component data type
393   char* ComponentDataType();
394
395   // Transform data from transient form to persistent
396   char* IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject,
397                                 const char*           IORString,
398                                 CORBA::Boolean        isMultiFile,
399                                 CORBA::Boolean        isASCII );
400   // Transform data from persistent form to transient
401   char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject,
402                                 const char*           aLocalPersistentID,
403                                 CORBA::Boolean        isMultiFile,
404                                 CORBA::Boolean        isASCII );
405
406   // Returns true if object can be published in the study
407   bool CanPublishInStudy( CORBA::Object_ptr theIOR );
408   // Publish object in the study
409   SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::SObject_ptr theSObject,
410                                         CORBA::Object_ptr     theObject,
411                                         const char*           theName )
412     throw ( SALOME::SALOME_Exception );
413
414   // Copy-paste methods - returns true if object can be copied to the clipboard
415   CORBA::Boolean CanCopy( SALOMEDS::SObject_ptr theObject ) { return false; }
416   // Copy-paste methods - copy object to the clipboard
417   SALOMEDS::TMPFile* CopyFrom( SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID ) { return NULL; }
418   // Copy-paste methods - returns true if object can be pasted from the clipboard
419   CORBA::Boolean CanPaste( const char* theComponentName, CORBA::Long theObjectID ) { return false; }
420   // Copy-paste methods - paste object from the clipboard
421   SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile& theStream,
422                                    CORBA::Long              theObjectID,
423                                    SALOMEDS::SObject_ptr    theObject ) {
424     SALOMEDS::SObject_var aResultSO;
425     return aResultSO._retn();
426   }
427
428   // ============
429   // Version information
430   // ============
431
432   virtual char* getVersion();
433
434   // ============
435   // Dump python
436   // ============
437
438   virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
439                                        CORBA::Boolean isMultiFile,
440                                        CORBA::Boolean& isValidScript);
441
442   void AddToPythonScript (const TCollection_AsciiString& theString);
443
444   void RemoveLastFromPythonScript();
445
446   void SavePython();
447
448   TCollection_AsciiString DumpPython_impl (Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
449                                            Resource_DataMapOfAsciiStringAsciiString& theNames,
450                                            bool isPublished,
451                                            bool isMultiFile,
452                                            bool isHistoricalDump,
453                                            bool& aValidScript,
454                                            TCollection_AsciiString& theSavedTrace);
455
456   TCollection_AsciiString GetNewPythonLines();
457
458   void CleanPythonTrace();
459
460   // *****************************************
461   // Internal methods
462   // *****************************************
463 public:
464   // Get shape reader
465   GEOM_Client* GetShapeReader();
466
467   // Tags definition
468   static long GetHypothesisRootTag();
469   static long GetAlgorithmsRootTag();
470   static long GetRefOnShapeTag();
471   static long GetRefOnAppliedHypothesisTag();
472   static long GetRefOnAppliedAlgorithmsTag();
473   static long GetSubMeshOnVertexTag();
474   static long GetSubMeshOnEdgeTag();
475   static long GetSubMeshOnFaceTag();
476   static long GetSubMeshOnSolidTag();
477   static long GetSubMeshOnCompoundTag();
478   static long GetSubMeshOnWireTag();
479   static long GetSubMeshOnShellTag();
480   static long GetNodeGroupsTag();
481   static long GetEdgeGroupsTag();
482   static long GetFaceGroupsTag();
483   static long GetVolumeGroupsTag();
484   static long Get0DElementsGroupsTag();
485   static long GetBallElementsGroupsTag();
486
487   // publishing methods
488   SALOMEDS::SComponent_ptr PublishComponent();
489   SALOMEDS::SObject_ptr PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
490                                      const char*           theName = 0);
491   SALOMEDS::SObject_ptr PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
492                                            const char*                 theName = 0);
493   SALOMEDS::SObject_ptr PublishSubMesh (SMESH::SMESH_Mesh_ptr    theMesh,
494                                         SMESH::SMESH_subMesh_ptr theSubMesh,
495                                         GEOM::GEOM_Object_ptr    theShapeObject,
496                                         const char*              theName = 0);
497   SALOMEDS::SObject_ptr PublishGroup (SMESH::SMESH_Mesh_ptr  theMesh,
498                                       SMESH::SMESH_GroupBase_ptr theGroup,
499                                       GEOM::GEOM_Object_ptr  theShapeObject,
500                                       const char*            theName = 0);
501   void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh);
502   bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr       theMesh,
503                             GEOM::GEOM_Object_ptr       theShapeObject,
504                             SMESH::SMESH_Hypothesis_ptr theHyp);
505   bool RemoveHypothesisFromShape(SMESH::SMESH_Mesh_ptr       theMesh,
506                                  GEOM::GEOM_Object_ptr       theShapeObject,
507                                  SMESH::SMESH_Hypothesis_ptr theHyp);
508   SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SMESH::SMESH_Mesh_ptr theMesh,
509                                                  GEOM::GEOM_Object_ptr theShape);
510   static void SetName(SALOMEDS::SObject_ptr theSObject,
511                       const char*           theName,
512                       const char*           theDefaultName = 0);
513
514   static void SetPixMap(SALOMEDS::SObject_ptr theSObject,
515                         const char*           thePixMap);
516
517   //  Get study context
518   StudyContext* GetStudyContext();
519
520   // Register an object in a StudyContext; return object id
521   int RegisterObject(CORBA::Object_ptr theObject);
522
523   // Return id of registered object
524   CORBA::Long GetObjectId(CORBA::Object_ptr theObject);
525
526   // Return an object that previously had an oldID
527   template<class TInterface>
528     typename TInterface::_var_type GetObjectByOldId( const int oldID )
529   {
530     if ( myStudyContext ) {
531       std::string ior = myStudyContext->getIORbyOldId( oldID );
532       if ( !ior.empty() )
533         return TInterface::_narrow(GetORB()->string_to_object( ior.c_str() ));
534     }
535     return TInterface::_nil();
536   }
537
538   /*!
539    * \brief Find SObject for an algo
540    */
541   SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
542
543   void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters);
544   char* GetParameters(CORBA::Object_ptr theObject);
545   //char* ParseParameters(const char* theParameters);
546   const std::vector< int >&         GetLastParamIndices() const { return myLastParamIndex; }
547   const std::vector< std::string >& GetLastParameters() const { return myLastParameters; }
548   const std::string &               GetLastObjEntry() const { return myLastObj; }
549   std::vector< std::string >        GetAllParameters(const std::string& theObjectEntry) const;
550
551   // Move objects to the specified position
552   void Move( const SMESH::sobject_list& what,
553              SALOMEDS::SObject_ptr where,
554              CORBA::Long row );
555
556   CORBA::Boolean IsApplicable ( const char*           theAlgoType,
557                                 const char*           theLibName,
558                                 GEOM::GEOM_Object_ptr theShapeObject,
559                                 CORBA::Boolean        toCheckAll);
560
561   SMESH::long_array* GetInsideSphere( SMESH::SMESH_IDSource_ptr meshPart,
562                                       SMESH::ElementType        theElemType,
563                                       CORBA::Double             theX,
564                                       CORBA::Double             theY,
565                                       CORBA::Double             theZ,
566                                       CORBA::Double             theR);
567
568   SMESH::long_array* GetInsideBox( SMESH::SMESH_IDSource_ptr meshPart,
569                                    SMESH::ElementType        theElemType,
570                                    CORBA::Double             theX1,
571                                    CORBA::Double             theY1,
572                                    CORBA::Double             theZ1,
573                                    CORBA::Double             theX2,
574                                    CORBA::Double             theY2,
575                                    CORBA::Double             theZ2);
576
577   SMESH::long_array* GetInsideCylinder( SMESH::SMESH_IDSource_ptr meshPart,
578                                         SMESH::ElementType        theElemType,
579                                         CORBA::Double             theX,
580                                         CORBA::Double             theY,
581                                         CORBA::Double             theZ,
582                                         CORBA::Double             theDX,
583                                         CORBA::Double             theDY,
584                                         CORBA::Double             theDZ,
585                                         CORBA::Double             theH,
586                                         CORBA::Double             theR );
587
588   SMESH::long_array* GetInside( SMESH::SMESH_IDSource_ptr meshPart,
589                                 SMESH::ElementType        theElemType,
590                                 GEOM::GEOM_Object_ptr     theGeom,
591                                 CORBA::Double             theTolerance );
592
593 private:
594   // Get hypothesis creator
595   GenericHypothesisCreator_i* getHypothesisCreator( const char*  theHypName,
596                                                     const char*  theLibName,
597                                                     std::string& thePlatformLibName)
598   throw ( SALOME::SALOME_Exception );
599   // Create hypothesis of given type
600   SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName,
601                                                 const char* theLibName);
602   // Create empty mesh on shape
603   SMESH::SMESH_Mesh_ptr createMesh()
604     throw ( SALOME::SALOME_Exception );
605
606   static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
607
608   SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName,
609                                                 SMESH::DriverMED_ReadStatus& theStatus,
610                                                 const char* theCommandNameForPython,
611                                                 const char* theFileNameForPython);
612
613   std::vector<long> _GetInside(SMESH::SMESH_IDSource_ptr meshPart,
614                                SMESH::ElementType     theElemType,
615                                TopoDS_Shape& aShape,
616                                double* theTolerance = NULL);
617
618 private:
619   static GEOM::GEOM_Gen_var      myGeomGen;
620   static CORBA::ORB_var          myOrb;         // ORB reference
621   static PortableServer::POA_var myPoa;         // POA reference
622   static SALOME_NamingService*   myNS;          // Naming Service
623   static SALOME_LifeCycleCORBA*  myLCC;         // Life Cycle CORBA
624   static SMESH_Gen_i*            mySMESHGen;    // Point to last created instance of the class
625   ::SMESH_Gen                    myGen;         // SMESH_Gen local implementation
626
627   // hypotheses managing
628   std::map<std::string, GenericHypothesisCreator_i*> myHypCreatorMap;
629
630   StudyContext*                  myStudyContext;  // study context
631
632   GEOM_Client*                   myShapeReader;      // Shape reader
633   CORBA::Boolean                 myIsEmbeddedMode;   // Current mode
634   CORBA::Boolean                 myIsEnablePublish;  // Enable publishing
635
636   // Default color of groups
637   std::string myDefaultGroupColor;
638
639   // To load full mesh data from study at hyp modification or not
640   bool myToForgetMeshDataOnHypModif;
641
642   // Dump Python: trace of API methods calls
643   Handle(TColStd_HSequenceOfAsciiString) myPythonScript;
644   bool                                   myIsHistoricalPythonDump;
645   std::vector< int >                     myLastParamIndex;
646   std::vector< std::string >             myLastParameters;
647   std::string                            myLastObj;
648 };
649
650
651 namespace SMESH
652 {
653   template<class T>
654   T
655   DownCast(CORBA::Object_ptr theArg)
656   {
657     return dynamic_cast<T>(SMESH_Gen_i::GetServant(theArg).in());
658   }
659
660   /*!
661    * \brief Function used in SMESH_CATCH to convert a caught exception to
662    * SALOME::SALOME_Exception
663    */
664   inline void throwCorbaException(const char* excText)
665   {
666     THROW_SALOME_CORBA_EXCEPTION( excText, SALOME::INTERNAL_ERROR );
667   }
668 }
669
670
671 #endif