Salome HOME
Issue 0020379: EDF SMESH 1047: Impossible to select pentahedrons when creating mesh...
[modules/smesh.git] / idl / SMESH_Mesh.idl
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SMESH_Mesh.idl
23 //  Author : Paul RASCLE, EDF
24 //  $Header$
25 //
26 #ifndef _SMESH_MESH_IDL_
27 #define _SMESH_MESH_IDL_
28
29 #include "SALOME_Exception.idl"
30 #include "SALOME_GenericObj.idl"
31 #include "GEOM_Gen.idl"
32 #include "MED.idl"
33
34 module SMESH
35 {
36   interface SMESH_Hypothesis;
37   typedef sequence<SMESH_Hypothesis> ListOfHypothesis;
38   interface SMESH_GroupBase;
39   typedef sequence<SMESH_GroupBase> ListOfGroups;
40
41   typedef sequence<double    > double_array ;
42   typedef sequence<long      > long_array ;
43   typedef sequence<string    > string_array ;
44   typedef sequence<long_array> array_of_long_array ;
45
46   enum log_command
47     {
48       ADD_NODE,
49       ADD_EDGE,
50       ADD_TRIANGLE,
51       ADD_QUADRANGLE,
52       ADD_POLYGON,
53       ADD_TETRAHEDRON,
54       ADD_PYRAMID,
55       ADD_PRISM,
56       ADD_HEXAHEDRON,
57       ADD_POLYHEDRON,
58       REMOVE_NODE,
59       REMOVE_ELEMENT,
60       MOVE_NODE,
61       CHANGE_ELEMENT_NODES,
62       CHANGE_POLYHEDRON_NODES,
63       RENUMBER,
64       CLEAR_MESH,
65       ADD_QUADEDGE,
66       ADD_QUADTRIANGLE,
67       ADD_QUADQUADRANGLE,
68       ADD_QUADTETRAHEDRON,
69       ADD_QUADPYRAMID,
70       ADD_QUADPENTAHEDRON,
71       ADD_QUADHEXAHEDRON
72     };
73
74   struct log_block
75   {
76     long commandType;
77     long number;
78     double_array coords;
79     long_array indexes;
80   };
81
82   struct PointStruct { double x;
83                        double y;
84                        double z; } ;
85
86   typedef sequence<PointStruct> nodes_array;
87
88   struct DirStruct   { PointStruct PS ; } ;          // analog to Occ Direction
89
90   struct AxisStruct  { double x;
91                        double y;
92                        double z;
93                        double vx;
94                        double vy;
95                        double vz; } ;
96
97   /*!
98    * Node location on a shape
99    */
100   struct NodePosition {
101     long             shapeID;
102     GEOM::shape_type shapeType;
103     double_array     params; // [U] on EDGE, [U,V] on FACE, [] on the rest shapes
104   };
105
106   /*!
107    * Enumeration for element type, like in SMDS
108    */
109   enum ElementType
110   {
111     ALL,
112     NODE,
113     EDGE,
114     FACE,
115     VOLUME,
116     ELEMENT0D
117   };
118   
119   /*!
120    * ElementOrder points out entities of what order are requested
121    */
122   enum ElementOrder {
123     ORDER_ANY,          /*! entities of any order */
124     ORDER_LINEAR,       /*! entities of 1st order */
125     ORDER_QUADRATIC     /*! entities of 2nd order */
126   };
127
128   /*!
129    * Enumeration for hypothesis status (used by AddHypothesis() and RemoveHypothesis() methods)
130    */
131   enum Hypothesis_Status // in the order of severity
132   {
133     HYP_OK,
134     HYP_MISSING,      // algo misses a hypothesis
135     HYP_CONCURENT,    // several applicable hypotheses
136     HYP_BAD_PARAMETER,// hypothesis has a bad parameter value
137     HYP_HIDDEN_ALGO,  // an algo is hidden by an upper dim algo generating all-dim elements
138     HYP_HIDING_ALGO,  // an algo hides lower dim algos by generating all-dim elements
139     HYP_UNKNOWN_FATAL,//  --- all statuses below should be considered as fatal
140                       //      for Add/RemoveHypothesis operations
141     HYP_INCOMPATIBLE, // hypothesis does not fit algo
142     HYP_NOTCONFORM,   // not conform mesh is produced appling a hypothesis
143     HYP_ALREADY_EXIST,// such hypothesis already exist
144     HYP_BAD_DIM,      // bad dimension
145     HYP_BAD_SUBSHAPE, // shape is neither the main one, nor its subshape, nor a group
146     HYP_BAD_GEOMETRY, // geometry mismatches algorithm's expectation
147     HYP_NEED_SHAPE    // algorithm can work on shape only
148   };
149
150   /*!
151    * Enumeration for DriverMED read status (used by ImportMEDFile() method)
152    */
153   enum DriverMED_ReadStatus // in the order of severity
154   {
155     DRS_OK,
156     DRS_EMPTY,          // a MED file contains no mesh with the given name
157     DRS_WARN_RENUMBER,  // a MED file has overlapped ranges of element numbers,
158                         // so the numbers from the file are ignored
159     DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data
160     DRS_FAIL            // general failure (exception etc.)
161   };
162
163   /*!
164    * Enumeration for DriverMED (used by Perform() method)
165    */
166   enum MED_VERSION // in the order of severity
167   {
168     MED_V2_1,
169     MED_V2_2
170   };
171
172   typedef sequence<log_block> log_array;
173
174
175   /*!
176    * Auxilary flags for advanced extrusion.
177    * BOUNDARY: create or not boundary for result of extrusion
178    * SEW:      try to use existing nodes or create new nodes in any case
179    */
180   const long EXTRUSION_FLAG_BOUNDARY = 1;
181   const long EXTRUSION_FLAG_SEW = 2;
182   
183   /*!
184    * Structure used in mesh edit preview data (MeshPreviewStruct)
185    */
186   struct ElementSubType { ElementType SMDS_ElementType;
187                           boolean     isPoly;
188                           long        nbNodesInElement; };
189
190   typedef sequence<ElementSubType> types_array;
191
192   /*!
193    * Structure containing mesh edit preview data
194    */
195   struct MeshPreviewStruct { nodes_array nodesXYZ;
196                              long_array  elementConnectivities;
197                              types_array elementTypes; };
198
199   interface SMESH_IDSource
200   {
201     /*!
202      * Returns a sequence of all element IDs
203      */
204     long_array GetIDs();
205   };
206
207   interface SMESH_Group;
208   interface SMESH_GroupOnGeom;
209   interface SMESH_subMesh;
210   interface SMESH_MeshEditor;
211   interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource
212   {
213     /*!
214      * Return true if there is a geometry to be meshed
215      */
216     boolean HasShapeToMesh()
217       raises (SALOME::SALOME_Exception);
218
219     /*!
220      * Get geom shape to mesh. A result sould not be nil. Use HasShapeToMesh()
221      * to know if a returned shape 
222      */
223     GEOM::GEOM_Object GetShapeToMesh()
224       raises (SALOME::SALOME_Exception);
225
226     /*!
227      * Remove all nodes and elements
228      */
229     void Clear()
230       raises (SALOME::SALOME_Exception);
231
232     /*!
233      * Get the subMesh object associated to a subShape. The subMesh object
234      * gives access to nodes and elements IDs.
235      * SubMesh will be used instead of SubShape in a next idl version to
236      * adress a specific subMesh...
237      */
238     SMESH_subMesh GetSubMesh(in GEOM::GEOM_Object aSubObject, in string name)
239       raises (SALOME::SALOME_Exception);
240
241     /*!
242      * Remove a submesh
243      */
244     void RemoveSubMesh(in SMESH_subMesh aSubMesh)
245       raises (SALOME::SALOME_Exception);
246
247
248     /*!
249      * Create a group
250      */
251     SMESH_Group CreateGroup( in ElementType elem_type,
252                              in string name )
253       raises (SALOME::SALOME_Exception);
254
255     /*!
256      * Create a group from geometry group
257      */
258     SMESH_GroupOnGeom CreateGroupFromGEOM( in ElementType elem_type,
259                                           in string name,
260                                           in GEOM::GEOM_Object theGeomObject )
261       raises (SALOME::SALOME_Exception);
262
263     /*!
264      * Remove a group
265      */
266     void RemoveGroup(in SMESH_GroupBase aGroup)
267       raises (SALOME::SALOME_Exception);
268
269     /*!
270      *  Remove group with its contents
271      */
272     void RemoveGroupWithContents( in SMESH_GroupBase aGroup )
273       raises (SALOME::SALOME_Exception);
274
275     /*!
276      *  Get the list of groups existing in the mesh
277      */
278     ListOfGroups GetGroups()
279       raises (SALOME::SALOME_Exception);
280
281     /*!
282      *  Get number of groups existing in the mesh
283      */
284     long NbGroups()
285       raises (SALOME::SALOME_Exception);
286
287     /*!
288      * Union of two groups
289      *    New group is created. All mesh elements that are
290      *    present in initial groups are added to the new one
291      */
292     SMESH_Group UnionGroups (in SMESH_GroupBase aGroup1,
293                              in SMESH_GroupBase aGroup2,
294                              in string          name )
295       raises (SALOME::SALOME_Exception);
296
297     /*!
298      *  Intersection of two groups
299      *  New group is created. All mesh elements that are
300      *  present in both initial groups are added to the new one.
301      */
302     SMESH_Group IntersectGroups (in SMESH_GroupBase aGroup1,
303                                  in SMESH_GroupBase aGroup2,
304                                  in string          name )
305       raises (SALOME::SALOME_Exception);
306
307     /*!
308      *  Cut of two groups
309      *  New group is created. All mesh elements that are present in
310      *  main group but do not present in tool group are added to the new one
311      */
312     SMESH_Group CutGroups (in SMESH_GroupBase aMainGroup,
313                            in SMESH_GroupBase aToolGroup,
314                            in string          name )
315       raises (SALOME::SALOME_Exception);
316
317     /*!
318      * Add hypothesis to the mesh, under a particular subShape
319      * (or the main shape itself)
320      * The Add method is only used to prepare the build of the mesh and store
321      * the algorithms and associated parameters.
322      * Actual job of mesh the shape is done by MESH_Gen.
323      * @params
324      * - aSubShape : subShape obtained by a shape explode in GEOM
325      *   (or main shape)
326      * - anHyp : hypothesis object
327      * @return
328      * - OK if the hypothesis is compatible with the subShape
329      *   (and all previous hypothesis on the subShape)
330      * - NOK if the hypothesis is not compatible with the subShape
331      *   (or one previous hypothesis on the subShape)
332      * raises exception if hypothesis has not been created
333      */
334     Hypothesis_Status AddHypothesis(in GEOM::GEOM_Object aSubObject,
335                                     in SMESH_Hypothesis anHyp)
336       raises (SALOME::SALOME_Exception);
337 //     boolean AddHypothesis(in SMESH_subMesh aSubMesh, in SMESH_Hypothesis anHyp)
338 //       raises (SALOME::SALOME_Exception);
339
340     /*!
341      * Remove an hypothesis previouly added with AddHypothesis.
342      */
343     Hypothesis_Status RemoveHypothesis(in GEOM::GEOM_Object aSubObject,
344                                        in SMESH_Hypothesis anHyp)
345       raises (SALOME::SALOME_Exception);
346 //     boolean RemoveHypothesis(in SMESH_subMesh aSubMesh,
347 //                           in SMESH_Hypothesis anHyp)
348 //       raises (SALOME::SALOME_Exception);
349
350     /*!
351      * Get the list of hypothesis added on a subShape
352      */
353     ListOfHypothesis GetHypothesisList(in GEOM::GEOM_Object aSubObject)
354       raises (SALOME::SALOME_Exception);
355 //     ListOfHypothesis GetHypothesisList(in SMESH_subMesh aSubMesh)
356 //       raises (SALOME::SALOME_Exception);
357
358     /*!
359      * Get the log of nodes and elements added or removed since previous
360      * clear of the log.
361      * @params
362      * - clearAfterGet : log is emptied after Get (safe if concurrents access)
363      */
364     //    string_array GetLog(in boolean clearAfterGet)
365     //      raises (SALOME::SALOME_Exception);
366     log_array GetLog(in boolean clearAfterGet)
367       raises (SALOME::SALOME_Exception);
368
369     /*!
370      * Clear the log of nodes and elements added or removed since previous
371      * clear. Must be used immediately after GetLog if clearAfterGet is false.
372      */
373     void ClearLog()
374       raises (SALOME::SALOME_Exception);
375
376     /*!
377      * Toggle auto color mode on the object.
378      * @params
379      * - theAutoColor : flag which toggles auto color mode.
380      */
381     void SetAutoColor(in boolean theAutoColor)
382       raises (SALOME::SALOME_Exception);
383
384     /*!
385      * Get flag of object's auto color mode.
386      */
387     boolean GetAutoColor()
388       raises (SALOME::SALOME_Exception);
389
390     /*!
391      * Get the internal Id
392      */
393     long GetId();
394
395     /*!
396      * Get the study Id
397      */
398     long GetStudyId();
399
400     /*!
401      * Obtain instance of SMESH_MeshEditor
402      */
403     SMESH_MeshEditor GetMeshEditor()
404       raises (SALOME::SALOME_Exception);
405
406     /*!
407      * Return SMESH_MeshEditor that would not modify the mesh but
408      * fill MeshPreviewStruct
409      */
410     SMESH_MeshEditor GetMeshEditPreviewer()
411       raises (SALOME::SALOME_Exception);
412
413     /*! Check group names for duplications.
414      *  Consider maximum group name length stored in MED file.
415      */
416     boolean HasDuplicatedGroupNamesMED();
417
418     /*!
419      * Export Mesh to different MED Formats
420      * @params
421      * - auto_groups : boolean parameter for creating/not creating
422      *   the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
423      *   the typical use is auto_groups=false.
424      * - theVersion : define the version of format of MED file, that will be created
425      */
426     void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion )
427       raises (SALOME::SALOME_Exception);
428
429     /*!
430      * Export Mesh to MED_V2_1 MED format
431      * Works, just the same as ExportToMED, with MED_VERSION parameter equal to MED_V2_1.
432      * The method is kept in order to support old functionality
433      */
434     void ExportMED( in string file, in boolean auto_groups )
435       raises (SALOME::SALOME_Exception);
436
437     /*!
438      * Return string representation of a MED file version comprising nbDigits
439      */
440     string GetVersionString(in MED_VERSION version, in short nbDigits);
441
442     /*!
443      * Export Mesh to DAT, UNV and STL Formats
444      * (UNV supported version is I-DEAS 10)
445      */
446     void ExportDAT( in string file )
447       raises (SALOME::SALOME_Exception);
448     void ExportUNV( in string file )
449       raises (SALOME::SALOME_Exception);
450     void ExportSTL( in string file, in boolean isascii )
451       raises (SALOME::SALOME_Exception);
452
453     /*!
454      * Get MED Mesh
455      */
456     SALOME_MED::MESH GetMEDMesh()
457       raises (SALOME::SALOME_Exception);
458
459     /*!
460      * Get informations about mesh contents
461      */
462     long NbNodes()
463       raises (SALOME::SALOME_Exception);
464
465     long NbElements()
466       raises (SALOME::SALOME_Exception);
467
468     long NbEdges()
469       raises (SALOME::SALOME_Exception);
470
471     long NbEdgesOfOrder(in ElementOrder order)
472       raises (SALOME::SALOME_Exception);
473
474     long NbFaces()
475       raises (SALOME::SALOME_Exception);
476
477     long NbFacesOfOrder(in ElementOrder order)
478       raises (SALOME::SALOME_Exception);
479
480     long NbTriangles()
481       raises (SALOME::SALOME_Exception);
482
483     long NbTrianglesOfOrder(in ElementOrder order)
484       raises (SALOME::SALOME_Exception);
485
486     long NbQuadrangles()
487       raises (SALOME::SALOME_Exception);
488
489     long NbQuadranglesOfOrder(in ElementOrder order)
490       raises (SALOME::SALOME_Exception);
491
492     long NbPolygons()
493       raises (SALOME::SALOME_Exception);
494
495     long NbVolumes()
496       raises (SALOME::SALOME_Exception);
497
498     long NbVolumesOfOrder(in ElementOrder order)
499       raises (SALOME::SALOME_Exception);
500
501     long NbTetras()
502       raises (SALOME::SALOME_Exception);
503
504     long NbTetrasOfOrder(in ElementOrder order)
505       raises (SALOME::SALOME_Exception);
506
507     long NbHexas()
508       raises (SALOME::SALOME_Exception);
509
510     long NbHexasOfOrder(in ElementOrder order)
511       raises (SALOME::SALOME_Exception);
512
513     long NbPyramids()
514       raises (SALOME::SALOME_Exception);
515
516     long NbPyramidsOfOrder(in ElementOrder order)
517       raises (SALOME::SALOME_Exception);
518
519     long NbPrisms()
520       raises (SALOME::SALOME_Exception);
521
522     long NbPrismsOfOrder(in ElementOrder order)
523       raises (SALOME::SALOME_Exception);
524
525     long NbPolyhedrons()
526       raises (SALOME::SALOME_Exception);
527
528     long NbSubMesh()
529       raises (SALOME::SALOME_Exception);
530
531     long_array GetElementsId()
532       raises (SALOME::SALOME_Exception);
533
534     long_array GetElementsByType( in ElementType theType )
535       raises (SALOME::SALOME_Exception);
536
537     long_array GetNodesId()
538       raises (SALOME::SALOME_Exception);
539     
540     /*!
541      * Returns type of mesh element
542      */    
543     ElementType GetElementType( in long id, in boolean iselem )
544       raises (SALOME::SALOME_Exception);
545
546     long_array GetSubMeshElementsId(in long ShapeID)
547       raises (SALOME::SALOME_Exception);
548
549     long_array GetSubMeshNodesId(in long ShapeID, in boolean all )
550       raises (SALOME::SALOME_Exception);
551     
552     ElementType GetSubMeshElementType(in long ShapeID)
553       raises (SALOME::SALOME_Exception);
554
555     /*!
556      * Get mesh description
557      */
558     string Dump();
559
560     /*!
561      * Get mesh pointer
562      */
563     long long GetMeshPtr();
564
565     /*!
566      * Get XYZ coordinates of node as list of double
567      * If there is not node for given ID - returns empty list
568      */
569     double_array GetNodeXYZ(in long id);
570
571     /*!
572      * For given node returns list of IDs of inverse elements
573      * If there is not node for given ID - returns empty list
574      */
575     long_array GetNodeInverseElements(in long id);
576
577     /*!
578      * \brief Return position of a node on shape
579      */
580     NodePosition GetNodePosition(in long NodeID);
581
582     /*!
583      * If given element is node returns IDs of shape from position
584      * If there is not node for given ID - returns -1
585      */
586     long GetShapeID(in long id);
587
588     /*!
589      * For given element returns ID of result shape after 
590      * ::FindShape() from SMESH_MeshEditor
591      * If there is not element for given ID - returns -1
592      */
593     long GetShapeIDForElem(in long id);
594
595     /*!
596      * Returns number of nodes for given element
597      * If there is not element for given ID - returns -1
598      */
599     long GetElemNbNodes(in long id);
600
601     /*!
602      * Returns IDs of nodes of given element
603      */
604     long_array GetElemNodes(in long id);
605
606     /*!
607      * Returns ID of node by given index for given element
608      * If there is not element for given ID - returns -1
609      * If there is not node for given index - returns -2
610      */
611     long GetElemNode(in long id, in long index);
612
613     /*!
614      * Returns true if given node is medium node
615      * in given quadratic element
616      */
617     boolean IsMediumNode(in long ide, in long idn);
618
619     /*!
620      * Returns true if given node is medium node
621      * in one of quadratic elements
622      */
623     boolean IsMediumNodeOfAnyElem(in long idn, in ElementType elem_type);
624
625     /*!
626      * Returns number of edges for given element
627      */
628     long ElemNbEdges(in long id);
629
630     /*!
631      * Returns number of faces for given element
632      */
633     long ElemNbFaces(in long id);
634
635     /*!
636      * Returns true if given element is polygon
637      */
638     boolean IsPoly(in long id);
639
640     /*!
641      * Returns true if given element is quadratic
642      */
643     boolean IsQuadratic(in long id);
644
645     /*!
646      * Returns XYZ coordinates of bary center for given element
647      * as list of double
648      * If there is not element for given ID - returns empty list
649      */
650     double_array BaryCenter(in long id);
651
652     /*! Gets information about imported MED file */
653     SALOME_MED::MedFileInfo GetMEDFileInfo();
654   };
655
656   interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
657   {
658     /*!
659      *
660      */
661     long GetNumberOfElements()
662       raises (SALOME::SALOME_Exception);
663
664     /*!
665      *
666      */
667     long GetNumberOfNodes( in boolean all )
668       raises (SALOME::SALOME_Exception);
669
670     /*!
671      *
672      */
673     long_array GetElementsId()
674       raises (SALOME::SALOME_Exception);
675
676     /*!
677      *
678      */
679     long_array GetElementsByType( in ElementType theType )
680       raises (SALOME::SALOME_Exception);
681     
682     /*!
683      * Return type of submesh element
684      */
685     ElementType GetElementType( in long id, in boolean iselem )
686       raises (SALOME::SALOME_Exception);
687
688     /*!
689      *
690      */
691     long_array GetNodesId()
692       raises (SALOME::SALOME_Exception);
693
694     /*!
695      * Get geom shape the submesh is dedicated to
696      */
697     GEOM::GEOM_Object GetSubShape()
698       raises (SALOME::SALOME_Exception);
699
700     /*!
701      * Get SMESH_Mesh which stores nodes coordinates & elements definition
702      */
703     SMESH_Mesh GetFather()
704       raises (SALOME::SALOME_Exception);
705
706     /*!
707      * Get the internal Id
708      */
709     long GetId();
710
711     /*!
712      * Get MED subMesh
713      */
714     SALOME_MED::FAMILY GetFamily()
715       raises (SALOME::SALOME_Exception);
716   };
717
718 };
719
720 #endif