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