Salome HOME
131993a40c8ddbac76c5e21e36149ebb2bd2d9c8
[modules/smesh.git] / src / SMESH_I / SMESH_Mesh_i.hxx
1 // Copyright (C) 2007-2024  CEA, EDF, 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_Mesh_i.hxx
23 //  Author : Paul RASCLE, EDF
24 //  Module : SMESH
25
26 #ifndef _SMESH_MESH_I_HXX_
27 #define _SMESH_MESH_I_HXX_
28
29 #include "SMESH.hxx"
30
31 #include "SMESH_Hypothesis.hxx"
32 #include "SMESH_Mesh.hxx"
33 #include "SMESH_subMesh.hxx"
34 #include "SMDS_ElemIterator.hxx"
35
36 #include <SALOME_GenericObj_i.hh>
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(SMESH_Gen)
39 #include CORBA_SERVER_HEADER(SMESH_Mesh)
40 #include CORBA_SERVER_HEADER(SMESH_Group)
41 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
42 #include CORBA_CLIENT_HEADER(GEOM_Gen)
43
44 #include <map>
45
46 class SMESH_Gen_i;
47 class SMESH_GroupBase_i;
48 class SMESH_subMesh_i;
49 class SMESH_PreMeshInfo;
50 class SMESH_MeshEditor_i;
51 class DriverMED_W_Field;
52 class SMESHDS_Mesh;
53
54 class SMESH_I_EXPORT SMESH_Mesh_i:
55   public virtual POA_SMESH::SMESH_Mesh,
56   public virtual SALOME::GenericObj_i
57 {
58   SMESH_Mesh_i();
59   SMESH_Mesh_i(const SMESH_Mesh_i&);
60 public:
61   SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
62                 SMESH_Gen_i*            myGen_i );
63
64   virtual ~SMESH_Mesh_i();
65
66   // --- CORBA
67
68   void SetShape( GEOM::GEOM_Object_ptr theShapeObject );
69
70   CORBA::Boolean HasShapeToMesh();
71
72   GEOM::GEOM_Object_ptr GetShapeToMesh();
73
74   virtual void ReplaceShape(GEOM::GEOM_Object_ptr theNewGeom);
75
76   CORBA::Boolean IsLoaded();
77
78   void Load();
79
80   void Clear();
81
82   void ClearSubMesh(CORBA::Long ShapeID);
83
84   SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr       aSubShape,
85                                          SMESH::SMESH_Hypothesis_ptr anHyp,
86                                          CORBA::String_out           anErrorText);
87
88   SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Object_ptr       aSubShape,
89                                             SMESH::SMESH_Hypothesis_ptr anHyp);
90
91   SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Object_ptr aSubShape);
92
93   SMESH::submesh_array* GetSubMeshes();
94
95   SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Object_ptr aSubShape, const char* theName);
96
97   void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh );
98
99   SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName );
100
101   SMESH::SMESH_GroupOnGeom_ptr CreateGroupFromGEOM(SMESH::ElementType    theElemType,
102                                                    const char*           theName,
103                                                    GEOM::GEOM_Object_ptr theGeomObj );
104
105   SMESH::SMESH_GroupOnFilter_ptr CreateGroupFromFilter(SMESH::ElementType theElemType,
106                                                        const char*        theName,
107                                                        SMESH::Filter_ptr  theFilter );
108
109   void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup );
110
111   void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup );
112
113   SMESH::ListOfGroups* GetGroups();
114
115   CORBA::Long NbGroups();
116
117   SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
118                                       SMESH::SMESH_GroupBase_ptr theGroup2,
119                                       const char* theName );
120
121   SMESH::SMESH_Group_ptr UnionListOfGroups( const SMESH::ListOfGroups& theGroups,
122                                             const char* theName);
123
124   SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
125                                           SMESH::SMESH_GroupBase_ptr theGroup2,
126                                           const char* theName );
127
128   SMESH::SMESH_Group_ptr IntersectListOfGroups( const SMESH::ListOfGroups&  theGroups,
129                                                 const char* theName );
130
131   SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
132                                     SMESH::SMESH_GroupBase_ptr theGroup2,
133                                     const char* theName );
134
135   SMESH::SMESH_Group_ptr CutListOfGroups( const SMESH::ListOfGroups& theMainGroups,
136                                           const SMESH::ListOfGroups& theToolGroups,
137                                           const char* theName );
138
139   SMESH::SMESH_Group_ptr CreateDimGroup( const SMESH::ListOfIDSources& theGroups,
140                                          SMESH::ElementType            theElemType,
141                                          const char*                   theName,
142                                          SMESH::NB_COMMON_NODES_ENUM   theNbCommonNodes,
143                                          CORBA::Boolean                theUnderlyingOnly );
144
145   SMESH::ListOfGroups* FaceGroupsSeparatedByEdges( CORBA::Double  theSharpAngle,
146                                                    CORBA::Boolean theCreateEdges,
147                                                    CORBA::Boolean theUseExistingEdges );
148
149   SMESH::SMESH_Group_ptr ConvertToStandalone( SMESH::SMESH_GroupBase_ptr theGroupOn );
150
151   SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet);
152
153   SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
154
155   SMESH::SMESH_MeshEditor_ptr GetMeshEditPreviewer();
156
157   CORBA::Boolean HasModificationsToDiscard();
158
159   void ClearLog();
160
161   CORBA::Long GetId();
162
163   // --- C++ interface
164
165   void SetImpl(::SMESH_Mesh* impl);
166   ::SMESH_Mesh& GetImpl();         // :: force no namespace here
167
168   SMESH_Gen_i* GetGen() { return _gen_i; }
169
170   int ImportUNVFile( const char* theFileName );
171
172   int ImportSTLFile( const char* theFileName );
173
174   SMESH::ComputeError* ImportGMFFile( const char* theFileName,
175                                       bool        theMakeRequiredGroups);
176
177   /*!
178    * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
179    */
180   SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName );
181
182   SMESH::DriverMED_ReadStatus ImportCGNSFile( const char*  theFileName,
183                                               const int    theMeshIndex,
184                                               std::string& theMeshName);
185
186   /*!
187    *  Auto color
188    */
189   void SetAutoColor(CORBA::Boolean theAutoColor);
190
191   CORBA::Boolean GetAutoColor();
192
193   /*! Check group names for duplications.
194    *  Consider maximum group name length stored in MED file.
195    */
196   CORBA::Boolean HasDuplicatedGroupNamesMED();
197
198   /*!
199    * Return string representation of a MED file version comprising nbDigits
200    */
201   char* GetVersionString(CORBA::Long minor, CORBA::Short nbDigits);
202
203   /*!
204    *  Return the list of med versions compatibles for write/append,
205    *  encoded in 10*major+minor (for instance, code for med 3.2.1 is 32)
206    */
207   SMESH::long_array* GetMEDVersionsCompatibleForAppend();
208
209   void ExportMED( const char*        file,
210                   CORBA::Boolean     auto_groups,
211                   CORBA::Long        version,
212                   CORBA::Boolean     overwrite,
213                   CORBA::Boolean     autoDimension = true);
214
215   CORBA::LongLong ExportMEDCoupling(CORBA::Boolean auto_groups,
216                                     CORBA::Boolean autoDimension = true);
217
218   void ExportDAT( const char* file, const CORBA::Boolean renumber );
219   void ExportUNV( const char* file, const CORBA::Boolean renumber  );
220   void ExportSTL( const char* file, bool isascii );
221   void ExportCGNS(SMESH::SMESH_IDSource_ptr meshPart,
222                   const char*               file,
223                   CORBA::Boolean            overwrite,
224                   CORBA::Boolean            groupElemsByType);
225   void ExportGMF(SMESH::SMESH_IDSource_ptr meshPart,
226                  const char*               file,
227                  CORBA::Boolean            withRequiredGroups);
228
229
230   template<class SPECLS>
231     void ExportPartToMEDCommon(SPECLS&                   speCls,
232                                SMESH::SMESH_IDSource_ptr meshPart,
233                                CORBA::Boolean            auto_groups,
234                                CORBA::Boolean            autoDim,
235                                const GEOM::ListOfFields& fields,
236                                const char*               geomAssocFields,
237                                CORBA::Double             ZTolerance,
238                                CORBA::Boolean            saveNumbers );
239
240   void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
241                        const char*               file,
242                        CORBA::Boolean            auto_groups,
243                        CORBA::Long               version,
244                        CORBA::Boolean            overwrite,
245                        CORBA::Boolean            autoDim,
246                        const GEOM::ListOfFields& fields,
247                        const char*               geomAssocFields,
248                        CORBA::Double             ZTolerance,
249                        CORBA::Boolean            saveNumbers );
250
251   void ExportPartToMESHIO(SMESH::SMESH_IDSource_ptr meshPart,
252                           const char*               file,
253                           const char*               selectedFilter);
254
255   CORBA::LongLong ExportPartToMEDCoupling(SMESH::SMESH_IDSource_ptr meshPart,
256                                           CORBA::Boolean            auto_groups,
257                                           CORBA::Boolean            autoDim,
258                                           const GEOM::ListOfFields& fields,
259                                           const char*               geomAssocFields,
260                                           CORBA::Double             ZTolerance,
261                                           CORBA::Boolean            saveNumbers);
262
263   void ExportPartToDAT(SMESH::SMESH_IDSource_ptr meshPart,
264                        const char*               file,
265                        CORBA::Boolean            renumber);
266   void ExportPartToUNV(SMESH::SMESH_IDSource_ptr meshPart,
267                        const char*               file,
268                        CORBA::Boolean            renumber);
269   void ExportPartToSTL(SMESH::SMESH_IDSource_ptr meshPart,
270                        const char*               file,
271                        CORBA::Boolean            isascii);
272
273   CORBA::Double GetComputeProgress();
274
275   SMESH::smIdType NbNodes();
276
277   SMESH::smIdType NbElements();
278
279   SMESH::smIdType Nb0DElements();
280
281   SMESH::smIdType NbBalls();
282
283   SMESH::smIdType NbEdges();
284
285   SMESH::smIdType NbEdgesOfOrder(SMESH::ElementOrder order);
286
287   SMESH::smIdType NbFaces();
288
289   SMESH::smIdType NbFacesOfOrder(SMESH::ElementOrder order);
290
291   SMESH::smIdType NbTriangles();
292
293   SMESH::smIdType NbTrianglesOfOrder(SMESH::ElementOrder order);
294
295   SMESH::smIdType NbBiQuadTriangles();
296
297   SMESH::smIdType NbQuadrangles();
298
299   SMESH::smIdType NbQuadranglesOfOrder(SMESH::ElementOrder order);
300
301   SMESH::smIdType NbBiQuadQuadrangles();
302
303   SMESH::smIdType NbPolygons();
304
305   SMESH::smIdType NbPolygonsOfOrder(SMESH::ElementOrder order = SMESH::ORDER_ANY);
306
307   SMESH::smIdType NbVolumes();
308
309   SMESH::smIdType NbVolumesOfOrder(SMESH::ElementOrder order);
310
311   SMESH::smIdType NbTetras();
312
313   SMESH::smIdType NbTetrasOfOrder(SMESH::ElementOrder order);
314
315   SMESH::smIdType NbHexas();
316
317   SMESH::smIdType NbHexasOfOrder(SMESH::ElementOrder order);
318
319   SMESH::smIdType NbTriQuadraticHexas();
320
321   SMESH::smIdType NbPyramids();
322
323   SMESH::smIdType NbPyramidsOfOrder(SMESH::ElementOrder order);
324
325   SMESH::smIdType NbPrisms();
326
327   SMESH::smIdType NbPrismsOfOrder(SMESH::ElementOrder order);
328
329   SMESH::smIdType NbHexagonalPrisms();
330
331   SMESH::smIdType NbPolyhedrons();
332
333   SMESH::smIdType NbSubMesh();
334
335   SMESH::smIdType_array* GetElementsId();
336
337   SMESH::smIdType_array* GetElementsByType( SMESH::ElementType theElemType );
338
339   SMESH::smIdType_array* GetNodesId();
340
341   SMESH::ElementType GetElementType( SMESH::smIdType id, bool iselem );
342
343   SMESH::EntityType GetElementGeomType( SMESH::smIdType id );
344
345   SMESH::GeometryType GetElementShape( SMESH::smIdType id );
346
347   /*!
348    * Returns ID of elements for given submesh
349    */
350   SMESH::smIdType_array* GetSubMeshElementsId(CORBA::Long ShapeID);
351
352   /*!
353    * Returns ID of nodes for given submesh
354    * If param all==true - returns all nodes, else -
355    * returns only nodes on shapes.
356    */
357   SMESH::smIdType_array* GetSubMeshNodesId(CORBA::Long ShapeID, CORBA::Boolean all);
358
359   /*!
360    * Returns type of elements for given submesh
361    */
362   SMESH::ElementType GetSubMeshElementType(CORBA::Long ShapeID);
363
364   char* Dump();
365
366   // Create groups of elements preventing computation of a sub-shape
367   SMESH::ListOfGroups* MakeGroupsOfBadInputElements( int         theSubShapeID,
368                                                      const char* theGroupName);
369
370   // ===================================================
371   // Internal methods not available through CORBA
372   // They are called by corresponding interface methods
373   // ===================================================
374
375   SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr       aSubShape,
376                                                     SMESH::SMESH_Hypothesis_ptr anHyp,
377                                                     std::string*                anErrorText=0);
378
379   SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShape,
380                                                        SMESH::SMESH_Hypothesis_ptr anHyp);
381
382   static SMESH::Hypothesis_Status
383   ConvertHypothesisStatus (SMESH_Hypothesis::Hypothesis_Status theStatus);
384
385   static void PrepareForWriting (const char* file, bool overwrite = true);
386
387   //int importMEDFile( const char* theFileName, const char* theMeshName );
388
389   SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject );
390
391   bool removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
392                      GEOM::GEOM_Object_ptr theSubShapeObject );
393
394   SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType        theElemType,
395                                          const char*               theName,
396                                          const int                 theID = -1,
397                                          const TopoDS_Shape&       theShape = TopoDS_Shape(),
398                                          const SMESH_PredicatePtr& thePred = SMESH_PredicatePtr());
399
400   void removeGroup( const int theId );
401
402   SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID);
403   // return an existing subMesh object for the shapeID. shapeID == submeshID.
404
405   const std::map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
406   // return existing group objects
407
408   void onHypothesisModified(int theHypID, bool updateIcons);
409   // callback from _impl to forget not loaded mesh data (issue 0021208)
410
411   /*!
412    * \brief Update data if geometry changes
413    *
414    * Issue 0022501
415    */
416   void CheckGeomModif( bool isBreakLink = false );
417   /*!
418    * \brief Update hypotheses assigned to geom groups if the latter change
419    *
420    * NPAL16168: "geometrical group edition from a submesh don't modify mesh computation"
421    */
422   void CheckGeomGroupModif();
423
424   CORBA::LongLong GetMeshPtr();
425
426   /*!
427    * \brief Assure that all groups are published
428    */
429   void CreateGroupServants();
430
431
432
433   // ====================================
434   // SMESH_Mesh interface (continuation)
435   // ====================================
436   /*!
437    * \brief Return true if all sub-meshes are computed OK - to update an icon
438    */
439   CORBA::Boolean IsComputedOK();
440
441   /*!
442    * \brief Return groups cantained in _mapGroups by their IDs
443    */
444   SMESH::ListOfGroups* GetGroups(const std::list<int>& groupIDs) const;
445
446   /*!
447    * Get XYZ coordinates of node as list of double
448    * If there is not node for given ID - returns empty list
449    */
450   SMESH::double_array* GetNodeXYZ(SMESH::smIdType id);
451
452   /*!
453    * For given node returns list of IDs of inverse elements
454    * If there is not node for given ID - returns empty list
455    */
456   SMESH::smIdType_array* GetNodeInverseElements(SMESH::smIdType    id,
457                                             SMESH::ElementType elemType);
458
459   /*!
460    * \brief Return position of a node on shape
461    */
462   SMESH::NodePosition* GetNodePosition(SMESH::smIdType NodeID);
463
464   /*!
465    * \brief Return position of an element on shape
466    */
467   SMESH::ElementPosition GetElementPosition(SMESH::smIdType ElemID);
468
469   /*!
470    * If given element is node returns IDs of shape from position
471    * If there is not node for given ID - returns -1
472    */
473   CORBA::Long GetShapeID(SMESH::smIdType id);
474
475   /*!
476    * For given element returns ID of result shape after
477    * ::FindShape() from SMESH_MeshEditor
478    * If there is not element for given ID - returns -1
479    */
480   CORBA::Long GetShapeIDForElem(SMESH::smIdType id);
481
482   /*!
483    * Returns number of nodes for given element
484    * If there is not element for given ID - returns -1
485    */
486   CORBA::Short GetElemNbNodes(SMESH::smIdType id);
487
488   /*!
489    * Returns IDs of nodes of given element
490    */
491   SMESH::smIdType_array* GetElemNodes(SMESH::smIdType id);
492
493   /*!
494    * Returns ID of node by given index for given element
495    * If there is not element for given ID - returns -1
496    * If there is not node for given index - returns -2
497    */
498   SMESH::smIdType GetElemNode(SMESH::smIdType id, CORBA::Short index);
499
500   /*!
501    * Returns true if given node is medium node
502    * in given quadratic element
503    */
504   CORBA::Boolean IsMediumNode(SMESH::smIdType ide, SMESH::smIdType idn);
505
506   /*!
507    * Returns true if given node is medium node
508    * in one of quadratic elements
509    */
510   CORBA::Boolean IsMediumNodeOfAnyElem(SMESH::smIdType    idn,
511                                        SMESH::ElementType elemType);
512
513   /*!
514    * Returns number of edges for given element
515    */
516   CORBA::Long ElemNbEdges(SMESH::smIdType id);
517
518   /*!
519    * Returns number of faces for given element
520    */
521   CORBA::Long ElemNbFaces(SMESH::smIdType id);
522   /*!
523    * Returns nodes of given face (counted from zero) for given element.
524    */
525   SMESH::smIdType_array* GetElemFaceNodes(SMESH::smIdType elemId, CORBA::Short faceIndex);
526
527   /*!
528    * Returns three components of normal of given mesh face (or an empty array in KO case)
529    */
530   SMESH::double_array* GetFaceNormal(CORBA::Long faceId, CORBA::Boolean normalized);
531
532   /*!
533    * Returns an element based on all given nodes.
534    */
535   SMESH::smIdType FindElementByNodes(const SMESH::smIdType_array& nodes);
536
537   /*!
538    * Return elements including all given nodes.
539    */
540   SMESH::smIdType_array* GetElementsByNodes(const SMESH::smIdType_array& nodes,
541                                         SMESH::ElementType       elemType);
542
543   /*!
544    * Returns true if given element is polygon
545    */
546   CORBA::Boolean IsPoly(SMESH::smIdType id);
547
548   /*!
549    * Returns true if given element is quadratic
550    */
551   CORBA::Boolean IsQuadratic(SMESH::smIdType id);
552
553   /*!
554    * Returns diameter of ball discrete element or zero in case of an invalid \a id
555    */
556   CORBA::Double GetBallDiameter(SMESH::smIdType id);
557
558   /*!
559    * Returns bary center for given element
560    */
561   SMESH::double_array* BaryCenter(SMESH::smIdType id);
562
563   /*!
564    * Returns information about imported MED file
565    */
566   virtual SMESH::MedFileInfo* GetMEDFileInfo();
567
568   /*!
569    * Persistence of file info
570    */
571   std::string FileInfoToString();
572   void FileInfoFromString(const std::string& info);
573
574   /*!
575    * Persistence of geometry tick
576    */
577   int& MainShapeTick() { return _mainShapeTick; }
578
579
580   /*!
581    * Sets list of notebook variables used for Mesh operations separated by ":" symbol
582    */
583   void SetParameters (const char* theParameters);
584
585   /*!
586    * Returns list of notebook variables used for Mesh operations separated by ":" symbol
587    */
588   char* GetParameters();
589
590   /*!
591    * Returns list of notebook variables used for last Mesh operation
592    */
593   SMESH::string_array* GetLastParameters();
594
595   /*!
596    * \brief Return \c true if a meshing order not yet set for a concurrent sub-mesh
597    */
598   CORBA::Boolean IsUnorderedSubMesh(CORBA::Long submeshID);
599   /*!
600    * \brief Return submesh objects list in meshing order
601    */
602   virtual SMESH::submesh_array_array* GetMeshOrder();
603   /*!
604    * \brief Set submesh object order
605    */
606   virtual ::CORBA::Boolean SetMeshOrder(const SMESH::submesh_array_array& theSubMeshArray);
607
608
609   /*!
610    * Collect statistic of mesh elements given by iterator
611    */
612   static void CollectMeshInfo(const SMDS_ElemIteratorPtr theItr,
613                               SMESH::smIdType_array&     theInfo);
614   /*!
615    * \brief Return iterator on elements of given type in given object
616    */
617   static SMDS_ElemIteratorPtr GetElements(SMESH::SMESH_IDSource_ptr obj,
618                                           SMESH::ElementType        type);
619
620   // =========================
621   // SMESH_IDSource interface
622   // =========================
623
624   virtual SMESH::smIdType_array* GetIDs();
625   /*!
626    * Returns number of mesh elements of each \a EntityType
627    * Result array of number of elements per \a EntityType
628    * Inherited from SMESH_IDSource
629    */
630   virtual SMESH::smIdType_array* GetMeshInfo();
631   /*!
632    * Returns number of mesh elements of each \a ElementType
633    */
634   virtual SMESH::smIdType_array* GetNbElementsByType();
635   /*!
636    * Returns types of elements it contains
637    */
638   virtual SMESH::array_of_ElementType* GetTypes();
639   /*!
640    * Returns self
641    */
642   virtual SMESH::SMESH_Mesh_ptr GetMesh();
643   /*!
644    * Returns false if GetMeshInfo() returns incorrect information that may
645    * happen if mesh data is not yet fully loaded from the file of study.
646    */
647   bool IsMeshInfoCorrect();
648   /*!
649    * Returns mesh unstructed grid information.
650    */
651   virtual SALOMEDS::TMPFile* GetVtkUgStream();
652
653
654   std::map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
655   std::map<int, ::SMESH_subMesh*> _mapSubMesh;   //NRI
656
657 public:
658   std::string generateMeshName( );
659   std::string prepareMeshNameAndGroups( const char* file, CORBA::Boolean overwrite );
660   /*
661    * Write GEOM fields to MED file
662    */
663   void exportMEDFields( DriverMED_W_Field &       writer,
664                         SMESHDS_Mesh*             meshDS,
665                         const GEOM::ListOfFields& fields,
666                         const char*               geomAssocFields);
667 private:
668   /*!
669    * Check and correct names of mesh groups
670    */
671   void checkGroupNames();
672
673   /*!
674    * Convert submesh ids into submesh interfaces
675    */
676   void convertMeshOrder(const TListOfListOfInt&     theIdsOrder,
677                         SMESH::submesh_array_array& theSubMeshOrder,
678                         const bool                  theIsDump);
679
680   /*!
681    * \brief Finds concurrent sub-meshes
682    */
683   TListOfListOfInt findConcurrentSubMeshes();
684
685  protected:
686   ::SMESH_Mesh* _impl;        // :: force no namespace here
687  private:
688
689   static int    _idGenerator;
690   SMESH_Gen_i*  _gen_i;
691   int           _id;          // id given by creator (unique within the creator instance)
692   int           _nbInvalidHypos;
693   std::map<int, SMESH::SMESH_subMesh_ptr>    _mapSubMeshIor;
694   std::map<int, SMESH::SMESH_GroupBase_ptr>  _mapGroups;
695   std::map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;
696   SMESH_MeshEditor_i*    _editor;
697   SMESH_MeshEditor_i*    _previewEditor;
698   SMESH::MedFileInfo_var _medFileInfo;
699   SMESH_PreMeshInfo*     _preMeshInfo; // mesh info before full loading from study file
700
701   SMESH_PreMeshInfo* & changePreMeshInfo() { return _preMeshInfo; }
702   friend class SMESH_PreMeshInfo;
703
704 private:
705
706   // Data used to track changes of GEOM groups
707   struct TGeomGroupData {
708     // keep study entry but not ior because GEOM_Object actually changes if
709     // number of items in a group varies (1) <-> (>1)
710     std::string       _groupEntry;
711     std::set<int>     _indices; // indices of group items within group's main shape
712     CORBA::Object_var _smeshObject; // SMESH object depending on GEOM group
713   };
714   std::list<TGeomGroupData> _geomGroupData;
715   int                       _mainShapeTick; // to track modifications of the meshed shape
716
717   /*!
718    * Remember GEOM group data
719    */
720   void addGeomGroupData(GEOM::GEOM_Object_ptr theGeomObj,
721                         CORBA::Object_ptr     theSmeshObj);
722   /*!
723    * Remove GEOM group data relating to removed smesh object
724    */
725   void removeGeomGroupData(CORBA::Object_ptr theSmeshObj);
726   /*!
727    * Return new group contents if it has been changed and update group data
728    */
729   TopoDS_Shape newGroupShape( TGeomGroupData & groupData, int how );
730
731 };
732
733 #endif