Salome HOME
PAL19802 A "Clear Mesh data" method for SMESH.Mesh objects
[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   };
146
147   /*!
148    * Enumeration for DriverMED read status (used by ImportMEDFile() method)
149    */
150   enum DriverMED_ReadStatus // in the order of severity
151   {
152     DRS_OK,
153     DRS_EMPTY,          // a MED file contains no mesh with the given name
154     DRS_WARN_RENUMBER,  // a MED file has overlapped ranges of element numbers,
155                         // so the numbers from the file are ignored
156     DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data
157     DRS_FAIL            // general failure (exception etc.)
158   };
159
160   /*!
161    * Enumeration for DriverMED (used by Perform() method)
162    */
163   enum MED_VERSION // in the order of severity
164   {
165     MED_V2_1,
166     MED_V2_2
167   };
168
169   typedef sequence<log_block> log_array;
170
171
172   /*!
173    * Auxilary flags for advanced extrusion.
174    * BOUNDARY: create or not boundary for result of extrusion
175    * SEW:      try to use existing nodes or create new nodes in any case
176    */
177   const long EXTRUSION_FLAG_BOUNDARY = 1;
178   const long EXTRUSION_FLAG_SEW = 2;
179   
180   interface SMESH_IDSource
181   {
182     /*!
183      * Returns a sequence of all element IDs
184      */
185     long_array GetIDs();
186   };
187
188   interface SMESH_Group;
189   interface SMESH_GroupOnGeom;
190   interface SMESH_subMesh;
191   interface SMESH_MeshEditor;
192   interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource
193   {
194     /*!
195      * Return true if there is a geometry to be meshed
196      */
197     boolean HasShapeToMesh()
198       raises (SALOME::SALOME_Exception);
199
200     /*!
201      * Get geom shape to mesh. A result sould not be nil. Use HasShapeToMesh()
202      * to know if a returned shape 
203      */
204     GEOM::GEOM_Object GetShapeToMesh()
205       raises (SALOME::SALOME_Exception);
206
207     /*!
208      * Remove all nodes and elements
209      */
210     void Clear()
211       raises (SALOME::SALOME_Exception);
212
213     /*!
214      * Get the subMesh object associated to a subShape. The subMesh object
215      * gives access to nodes and elements IDs.
216      * SubMesh will be used instead of SubShape in a next idl version to
217      * adress a specific subMesh...
218      */
219     SMESH_subMesh GetSubMesh(in GEOM::GEOM_Object aSubObject, in string name)
220       raises (SALOME::SALOME_Exception);
221
222     /*!
223      * Remove a submesh
224      */
225     void RemoveSubMesh(in SMESH_subMesh aSubMesh)
226       raises (SALOME::SALOME_Exception);
227
228
229     /*!
230      * Create a group
231      */
232     SMESH_Group CreateGroup( in ElementType elem_type,
233                              in string name )
234       raises (SALOME::SALOME_Exception);
235
236     /*!
237      * Create a group from geometry group
238      */
239     SMESH_GroupOnGeom CreateGroupFromGEOM( in ElementType elem_type,
240                                           in string name,
241                                           in GEOM::GEOM_Object theGeomObject )
242       raises (SALOME::SALOME_Exception);
243
244     /*!
245      * Remove a group
246      */
247     void RemoveGroup(in SMESH_GroupBase aGroup)
248       raises (SALOME::SALOME_Exception);
249
250     /*!
251      *  Remove group with its contents
252      */
253     void RemoveGroupWithContents( in SMESH_GroupBase aGroup )
254       raises (SALOME::SALOME_Exception);
255
256     /*!
257      *  Get the list of groups existing in the mesh
258      */
259     ListOfGroups GetGroups()
260       raises (SALOME::SALOME_Exception);
261
262     /*!
263      *  Get number of groups existing in the mesh
264      */
265     long NbGroups()
266       raises (SALOME::SALOME_Exception);
267
268     /*!
269      * Union of two groups
270      *    New group is created. All mesh elements that are
271      *    present in initial groups are added to the new one
272      */
273     SMESH_Group UnionGroups (in SMESH_GroupBase aGroup1,
274                              in SMESH_GroupBase aGroup2,
275                              in string          name )
276       raises (SALOME::SALOME_Exception);
277
278     /*!
279      *  Intersection of two groups
280      *  New group is created. All mesh elements that are
281      *  present in both initial groups are added to the new one.
282      */
283     SMESH_Group IntersectGroups (in SMESH_GroupBase aGroup1,
284                                  in SMESH_GroupBase aGroup2,
285                                  in string          name )
286       raises (SALOME::SALOME_Exception);
287
288     /*!
289      *  Cut of two groups
290      *  New group is created. All mesh elements that are present in
291      *  main group but do not present in tool group are added to the new one
292      */
293     SMESH_Group CutGroups (in SMESH_GroupBase aMainGroup,
294                            in SMESH_GroupBase aToolGroup,
295                            in string          name )
296       raises (SALOME::SALOME_Exception);
297
298     /*!
299      * Add hypothesis to the mesh, under a particular subShape
300      * (or the main shape itself)
301      * The Add method is only used to prepare the build of the mesh and store
302      * the algorithms and associated parameters.
303      * Actual job of mesh the shape is done by MESH_Gen.
304      * @params
305      * - aSubShape : subShape obtained by a shape explode in GEOM
306      *   (or main shape)
307      * - anHyp : hypothesis object
308      * @return
309      * - OK if the hypothesis is compatible with the subShape
310      *   (and all previous hypothesis on the subShape)
311      * - NOK if the hypothesis is not compatible with the subShape
312      *   (or one previous hypothesis on the subShape)
313      * raises exception if hypothesis has not been created
314      */
315     Hypothesis_Status AddHypothesis(in GEOM::GEOM_Object aSubObject,
316                                     in SMESH_Hypothesis anHyp)
317       raises (SALOME::SALOME_Exception);
318 //     boolean AddHypothesis(in SMESH_subMesh aSubMesh, in SMESH_Hypothesis anHyp)
319 //       raises (SALOME::SALOME_Exception);
320
321     /*!
322      * Remove an hypothesis previouly added with AddHypothesis.
323      */
324     Hypothesis_Status RemoveHypothesis(in GEOM::GEOM_Object aSubObject,
325                                        in SMESH_Hypothesis anHyp)
326       raises (SALOME::SALOME_Exception);
327 //     boolean RemoveHypothesis(in SMESH_subMesh aSubMesh,
328 //                           in SMESH_Hypothesis anHyp)
329 //       raises (SALOME::SALOME_Exception);
330
331     /*!
332      * Get the list of hypothesis added on a subShape
333      */
334     ListOfHypothesis GetHypothesisList(in GEOM::GEOM_Object aSubObject)
335       raises (SALOME::SALOME_Exception);
336 //     ListOfHypothesis GetHypothesisList(in SMESH_subMesh aSubMesh)
337 //       raises (SALOME::SALOME_Exception);
338
339     /*!
340      * Get the log of nodes and elements added or removed since previous
341      * clear of the log.
342      * @params
343      * - clearAfterGet : log is emptied after Get (safe if concurrents access)
344      */
345     //    string_array GetLog(in boolean clearAfterGet)
346     //      raises (SALOME::SALOME_Exception);
347     log_array GetLog(in boolean clearAfterGet)
348       raises (SALOME::SALOME_Exception);
349
350     /*!
351      * Clear the log of nodes and elements added or removed since previous
352      * clear. Must be used immediately after GetLog if clearAfterGet is false.
353      */
354     void ClearLog()
355       raises (SALOME::SALOME_Exception);
356
357     /*!
358      * Toggle auto color mode on the object.
359      * @params
360      * - theAutoColor : flag which toggles auto color mode.
361      */
362     void SetAutoColor(in boolean theAutoColor)
363       raises (SALOME::SALOME_Exception);
364
365     /*!
366      * Get flag of object's auto color mode.
367      */
368     boolean GetAutoColor()
369       raises (SALOME::SALOME_Exception);
370
371     /*!
372      * Get the internal Id
373      */
374     long GetId();
375
376     /*!
377      * Get the study Id
378      */
379     long GetStudyId();
380
381     /*!
382      * Obtain instance of SMESH_MeshEditor
383      */
384     SMESH_MeshEditor GetMeshEditor()
385       raises (SALOME::SALOME_Exception);
386
387     /*!
388      * Return SMESH_MeshEditor that would not modify the mesh but
389      * fill MeshPreviewStruct
390      */
391     SMESH_MeshEditor GetMeshEditPreviewer()
392       raises (SALOME::SALOME_Exception);
393
394     /*! Check group names for duplications.
395      *  Consider maximum group name length stored in MED file.
396      */
397     boolean HasDuplicatedGroupNamesMED();
398
399     /*!
400      * Export Mesh to different MED Formats
401      * @params
402      * - auto_groups : boolean parameter for creating/not creating
403      *   the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
404      *   the typical use is auto_groups=false.
405      * - theVersion : define the version of format of MED file, that will be created
406      */
407     void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion )
408       raises (SALOME::SALOME_Exception);
409
410     /*!
411      * Export Mesh to MED_V2_1 MED format
412      * Works, just the same as ExportToMED, with MED_VERSION parameter equal to MED_V2_1.
413      * The method is kept in order to support old functionality
414      */
415     void ExportMED( in string file, in boolean auto_groups )
416       raises (SALOME::SALOME_Exception);
417
418     /*!
419      * Return string representation of a MED file version comprising nbDigits
420      */
421     string GetVersionString(in MED_VERSION version, in short nbDigits);
422
423     /*!
424      * Export Mesh to DAT, UNV and STL Formats
425      * (UNV supported version is I-DEAS 10)
426      */
427     void ExportDAT( in string file )
428       raises (SALOME::SALOME_Exception);
429     void ExportUNV( in string file )
430       raises (SALOME::SALOME_Exception);
431     void ExportSTL( in string file, in boolean isascii )
432       raises (SALOME::SALOME_Exception);
433
434     /*!
435      * Get MED Mesh
436      */
437     SALOME_MED::MESH GetMEDMesh()
438       raises (SALOME::SALOME_Exception);
439
440     /*!
441      * Get informations about mesh contents
442      */
443     long NbNodes()
444       raises (SALOME::SALOME_Exception);
445
446     long NbElements()
447       raises (SALOME::SALOME_Exception);
448
449     long NbEdges()
450       raises (SALOME::SALOME_Exception);
451
452     long NbEdgesOfOrder(in ElementOrder order)
453       raises (SALOME::SALOME_Exception);
454
455     long NbFaces()
456       raises (SALOME::SALOME_Exception);
457
458     long NbFacesOfOrder(in ElementOrder order)
459       raises (SALOME::SALOME_Exception);
460
461     long NbTriangles()
462       raises (SALOME::SALOME_Exception);
463
464     long NbTrianglesOfOrder(in ElementOrder order)
465       raises (SALOME::SALOME_Exception);
466
467     long NbQuadrangles()
468       raises (SALOME::SALOME_Exception);
469
470     long NbQuadranglesOfOrder(in ElementOrder order)
471       raises (SALOME::SALOME_Exception);
472
473     long NbPolygons()
474       raises (SALOME::SALOME_Exception);
475
476     long NbVolumes()
477       raises (SALOME::SALOME_Exception);
478
479     long NbVolumesOfOrder(in ElementOrder order)
480       raises (SALOME::SALOME_Exception);
481
482     long NbTetras()
483       raises (SALOME::SALOME_Exception);
484
485     long NbTetrasOfOrder(in ElementOrder order)
486       raises (SALOME::SALOME_Exception);
487
488     long NbHexas()
489       raises (SALOME::SALOME_Exception);
490
491     long NbHexasOfOrder(in ElementOrder order)
492       raises (SALOME::SALOME_Exception);
493
494     long NbPyramids()
495       raises (SALOME::SALOME_Exception);
496
497     long NbPyramidsOfOrder(in ElementOrder order)
498       raises (SALOME::SALOME_Exception);
499
500     long NbPrisms()
501       raises (SALOME::SALOME_Exception);
502
503     long NbPrismsOfOrder(in ElementOrder order)
504       raises (SALOME::SALOME_Exception);
505
506     long NbPolyhedrons()
507       raises (SALOME::SALOME_Exception);
508
509     long NbSubMesh()
510       raises (SALOME::SALOME_Exception);
511
512     long_array GetElementsId()
513       raises (SALOME::SALOME_Exception);
514
515     long_array GetElementsByType( in ElementType theType )
516       raises (SALOME::SALOME_Exception);
517
518     long_array GetNodesId()
519       raises (SALOME::SALOME_Exception);
520     
521     /*!
522      * Returns type of mesh element
523      */    
524     ElementType GetElementType( in long id, in boolean iselem )
525       raises (SALOME::SALOME_Exception);
526
527     long_array GetSubMeshElementsId(in long ShapeID)
528       raises (SALOME::SALOME_Exception);
529
530     long_array GetSubMeshNodesId(in long ShapeID, in boolean all )
531       raises (SALOME::SALOME_Exception);
532     
533     ElementType GetSubMeshElementType(in long ShapeID)
534       raises (SALOME::SALOME_Exception);
535
536     /*!
537      * Get mesh description
538      */
539     string Dump();
540
541     /*!
542      * Get mesh pointer
543      */
544     long long GetMeshPtr();
545
546     /*!
547      * Get XYZ coordinates of node as list of double
548      * If there is not node for given ID - returns empty list
549      */
550     double_array GetNodeXYZ(in long id);
551
552     /*!
553      * For given node returns list of IDs of inverse elements
554      * If there is not node for given ID - returns empty list
555      */
556     long_array GetNodeInverseElements(in long id);
557
558     /*!
559      * \brief Return position of a node on shape
560      */
561     NodePosition GetNodePosition(in long NodeID);
562
563     /*!
564      * If given element is node returns IDs of shape from position
565      * If there is not node for given ID - returns -1
566      */
567     long GetShapeID(in long id);
568
569     /*!
570      * For given element returns ID of result shape after 
571      * ::FindShape() from SMESH_MeshEditor
572      * If there is not element for given ID - returns -1
573      */
574     long GetShapeIDForElem(in long id);
575
576     /*!
577      * Returns number of nodes for given element
578      * If there is not element for given ID - returns -1
579      */
580     long GetElemNbNodes(in long id);
581
582     /*!
583      * Returns IDs of nodes of given element
584      */
585     long_array GetElemNodes(in long id);
586
587     /*!
588      * Returns ID of node by given index for given element
589      * If there is not element for given ID - returns -1
590      * If there is not node for given index - returns -2
591      */
592     long GetElemNode(in long id, in long index);
593
594     /*!
595      * Returns true if given node is medium node
596      * in given quadratic element
597      */
598     boolean IsMediumNode(in long ide, in long idn);
599
600     /*!
601      * Returns true if given node is medium node
602      * in one of quadratic elements
603      */
604     boolean IsMediumNodeOfAnyElem(in long idn, in ElementType elem_type);
605
606     /*!
607      * Returns number of edges for given element
608      */
609     long ElemNbEdges(in long id);
610
611     /*!
612      * Returns number of faces for given element
613      */
614     long ElemNbFaces(in long id);
615
616     /*!
617      * Returns true if given element is polygon
618      */
619     boolean IsPoly(in long id);
620
621     /*!
622      * Returns true if given element is quadratic
623      */
624     boolean IsQuadratic(in long id);
625
626     /*!
627      * Returns XYZ coordinates of bary center for given element
628      * as list of double
629      * If there is not element for given ID - returns empty list
630      */
631     double_array BaryCenter(in long id);
632
633   };
634
635   interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
636   {
637     /*!
638      *
639      */
640     long GetNumberOfElements()
641       raises (SALOME::SALOME_Exception);
642
643     /*!
644      *
645      */
646     long GetNumberOfNodes( in boolean all )
647       raises (SALOME::SALOME_Exception);
648
649     /*!
650      *
651      */
652     long_array GetElementsId()
653       raises (SALOME::SALOME_Exception);
654
655     /*!
656      *
657      */
658     long_array GetElementsByType( in ElementType theType )
659       raises (SALOME::SALOME_Exception);
660     
661     /*!
662      * Return type of submesh element
663      */
664     ElementType GetElementType( in long id, in boolean iselem )
665       raises (SALOME::SALOME_Exception);
666
667     /*!
668      *
669      */
670     long_array GetNodesId()
671       raises (SALOME::SALOME_Exception);
672
673     /*!
674      * Get geom shape the submesh is dedicated to
675      */
676     GEOM::GEOM_Object GetSubShape()
677       raises (SALOME::SALOME_Exception);
678
679     /*!
680      * Get SMESH_Mesh which stores nodes coordinates & elements definition
681      */
682     SMESH_Mesh GetFather()
683       raises (SALOME::SALOME_Exception);
684
685     /*!
686      * Get the internal Id
687      */
688     long GetId();
689
690     /*!
691      * Get MED subMesh
692      */
693     SALOME_MED::FAMILY GetFamily()
694       raises (SALOME::SALOME_Exception);
695   };
696
697 };
698
699 #endif