Salome HOME
Bug PAL7222( DEVELOPMENT : Info on mesh and export MED File ).
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
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
32 module GEOM
33 {
34   interface GEOM_Object;
35 };
36
37
38 module SALOME_MED
39 {
40   interface MESH;
41   interface FAMILY;
42 };
43
44
45 module SMESH
46 {
47   interface SMESH_Hypothesis;
48   typedef sequence<SMESH_Hypothesis> ListOfHypothesis;
49
50   typedef sequence<double> double_array ;
51   typedef sequence<long> long_array ;
52   typedef sequence<string> string_array ;
53   typedef sequence<long_array> array_of_long_array ;
54
55   enum log_command
56     {
57       ADD_NODE,
58       ADD_EDGE,
59       ADD_TRIANGLE,
60       ADD_QUADRANGLE,
61       ADD_TETRAHEDRON,
62       ADD_PYRAMID,
63       ADD_PRISM,
64       ADD_HEXAHEDRON,
65       REMOVE_NODE,
66       REMOVE_ELEMENT,
67       MOVE_NODE,
68       CHANGE_ELEMENT_NODES,
69       RENUMBER
70     };
71
72   struct log_block
73   {
74     long commandType;
75     long number;
76     double_array coords;
77     long_array indexes;
78   };
79
80   struct PointStruct { double x; 
81                        double y; 
82                        double z; } ; 
83   struct DirStruct   { PointStruct PS ; } ;          // analog to Occ Direction
84    
85   struct AxisStruct  { double x;
86                        double y;
87                        double z;
88                        double vx;
89                        double vy;
90                        double vz; } ;
91
92   
93   /*!
94    * Enumeration for element type, like in SMDS
95    */
96   enum ElementType
97   {
98     ALL,
99     NODE,
100     EDGE,
101     FACE,
102     VOLUME
103   };
104   
105   /*!
106    * Enumeration for hypothesis status (used by AddHypothesis() and RemoveHypothesis() methods) 
107    */  
108   enum Hypothesis_Status // in the order of severity
109   {
110     HYP_OK,
111     HYP_MISSING,      // algo misses a hypothesis
112     HYP_CONCURENT,    // several applicable hypotheses
113     HYP_BAD_PARAMETER,// hypothesis has a bad parameter value
114     HYP_UNKNOWN_FATAL,//  --- all statuses below should be considered as fatal
115                       //      for Add/RemoveHypothesis operations
116     HYP_INCOMPATIBLE, // hypothesis does not fit algo
117     HYP_NOTCONFORM,   // not conform mesh is produced appling a hypothesis
118     HYP_ALREADY_EXIST,// such hypothesis already exist
119     HYP_BAD_DIM       // bad dimension
120   }; 
121   
122   /*!
123    * Enumeration for DriverMED read status (used by ImportMEDFile() method)
124    */  
125   enum DriverMED_ReadStatus // in the order of severity
126   {
127     DRS_OK,
128     DRS_EMPTY,          // a MED file contains no mesh with the given name
129     DRS_WARN_RENUMBER,  // a MED file has overlapped ranges of element numbers,
130                         // so the numbers from the file are ignored
131     DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data
132     DRS_FAIL            // general failure (exception etc.)
133   }; 
134
135   /*!
136    * Enumeration for DriverMED (used by Perform() method)
137    */  
138   enum MED_VERSION // in the order of severity
139   {
140     MED_V2_1,
141     MED_V2_2
142   };
143
144   typedef sequence<log_block> log_array;
145
146
147   interface SMESH_IDSource
148   {
149     /*!
150      * Returns a sequence of all element IDs
151      */
152     long_array GetIDs();
153   };
154   
155   interface SMESH_GroupBase;
156   interface SMESH_Group;
157   interface SMESH_GroupOnGeom;
158   interface SMESH_subMesh;
159   interface SMESH_MeshEditor;
160   interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource
161   {
162     /*!
163      * Associate a Shape to a Mesh created with NewEmpty
164      */
165
166 //     boolean SetMesh(in GEOM::GEOM_Object anObject)
167 //        raises (SALOME::SALOME_Exception);
168
169     /*!
170      * Get the subMesh object associated to a subShape. The subMesh object
171      * gives access to nodes and elements IDs.
172      * SubMesh will be used instead of SubShape in a next idl version to 
173      * adress a specific subMesh...
174      */
175     SMESH_subMesh GetSubMesh(in GEOM::GEOM_Object aSubObject, in string name)
176       raises (SALOME::SALOME_Exception);
177
178     /*!
179      * Create a subMesh without reference to a subShape
180      */
181 //     SMESH_subMesh NewEmpty()
182 //       raises (SALOME::SALOME_Exception);
183
184     /*!
185      * Get geom shape to mesh. A result may be nil
186      */
187     GEOM::GEOM_Object GetShapeToMesh()
188       raises (SALOME::SALOME_Exception);
189
190     /*!
191      * Remove a submesh
192      */
193     void RemoveSubMesh(in SMESH_subMesh aSubMesh)
194       raises (SALOME::SALOME_Exception);
195
196     /*!
197      * Create a group
198      */
199     SMESH_Group CreateGroup( in ElementType elem_type,
200                              in string name )
201       raises (SALOME::SALOME_Exception);
202
203     /*!
204      * Create a group from geometry group
205      */
206     SMESH_GroupOnGeom CreateGroupFromGEOM( in ElementType elem_type,
207                                           in string name,
208                                           in GEOM::GEOM_Object theGeomObject )
209       raises (SALOME::SALOME_Exception);
210
211     /*!
212      * Remove a group
213      */
214     void RemoveGroup(in SMESH_GroupBase aGroup)
215       raises (SALOME::SALOME_Exception);
216
217      /*!
218      *  Remove group with its contents
219      */
220     void RemoveGroupWithContents( in SMESH_GroupBase aGroup )
221         raises (SALOME::SALOME_Exception);
222
223     /*!
224      * Union of two groups
225      *    New group is created. All mesh elements that are 
226      *    present in initial groups are added to the new one
227      */
228     SMESH_Group UnionGroups (in SMESH_GroupBase aGroup1,
229                              in SMESH_GroupBase aGroup2,
230                              in string          name )
231         raises (SALOME::SALOME_Exception);
232
233     /*!
234      *  Intersection of two groups
235      *  New group is created. All mesh elements that are 
236      *  present in both initial groups are added to the new one.
237      */
238     SMESH_Group IntersectGroups (in SMESH_GroupBase aGroup1,
239                                  in SMESH_GroupBase aGroup2,
240                                  in string          name )
241         raises (SALOME::SALOME_Exception);
242
243       /*!
244        *  Cut of two groups
245        *  New group is created. All mesh elements that are present in 
246        *  main group but do not present in tool group are added to the new one
247        */
248       SMESH_Group CutGroups (in SMESH_GroupBase aMainGroup,
249                              in SMESH_GroupBase aToolGroup,
250                              in string          name )
251           raises (SALOME::SALOME_Exception);
252
253     /*!
254      * Add hypothesis to the mesh, under a particular subShape
255      * (or the main shape itself)
256      * The Add method is only used to prepare the build of the mesh and store
257      * the algorithms and associated parameters.
258      * Actual job of mesh the shape is done by MESH_Gen.
259      * @params
260      * - aSubShape : subShape obtained by a shape explode in GEOM
261      *   (or main shape)
262      * - anHyp : hypothesis object 
263      * @return
264      * - OK if the hypothesis is compatible with the subShape 
265      *   (and all previous hypothesis on the subShape)
266      * - NOK if the hypothesis is not compatible with the subShape
267      *   (or one previous hypothesis on the subShape)
268      * raises exception if hypothesis has not been created
269      */
270     Hypothesis_Status AddHypothesis(in GEOM::GEOM_Object aSubObject,
271                                     in SMESH_Hypothesis anHyp)
272       raises (SALOME::SALOME_Exception);
273 //     boolean AddHypothesis(in SMESH_subMesh aSubMesh, in SMESH_Hypothesis anHyp)
274 //       raises (SALOME::SALOME_Exception);
275
276
277     /*!
278      * Remove an hypothesis previouly added with AddHypothesis.
279      */
280     Hypothesis_Status RemoveHypothesis(in GEOM::GEOM_Object aSubObject,
281                                        in SMESH_Hypothesis anHyp)
282       raises (SALOME::SALOME_Exception);
283 //     boolean RemoveHypothesis(in SMESH_subMesh aSubMesh,
284 //                           in SMESH_Hypothesis anHyp)
285 //       raises (SALOME::SALOME_Exception);
286
287     /*!
288      * Get the list of hypothesis added on a subShape
289      */
290     ListOfHypothesis GetHypothesisList(in GEOM::GEOM_Object aSubObject)
291       raises (SALOME::SALOME_Exception);
292 //     ListOfHypothesis GetHypothesisList(in SMESH_subMesh aSubMesh)
293 //       raises (SALOME::SALOME_Exception);
294
295     /*!
296      * Get the log of nodes and elements added or removed since previous
297      * clear of the log.
298      * @params
299      * - clearAfterGet : log is emptied after Get (safe if concurrents access)
300      */
301     //    string_array GetLog(in boolean clearAfterGet)
302     //      raises (SALOME::SALOME_Exception);
303     log_array GetLog(in boolean clearAfterGet)
304       raises (SALOME::SALOME_Exception);
305
306     /*!
307      * Clear the log of nodes and elements added or removed since previous
308      * clear. Must be used immediately after GetLog if clearAfterGet is false.
309      */
310     void ClearLog()
311       raises (SALOME::SALOME_Exception);
312
313     /*!
314      * Get the internal Id 
315      */
316     long GetId();     
317
318     /*!
319      * Get the study Id 
320      */
321     long GetStudyId();    
322     
323     SMESH_MeshEditor GetMeshEditor() 
324        raises (SALOME::SALOME_Exception);
325
326     /*!
327      * Export Mesh to MED Formats
328      * @params
329      * - auto_groups : boolean parameter for creating/not creating
330      *   the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
331      *   the typical use is auto_groups=false.
332      */
333     void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion )
334       raises (SALOME::SALOME_Exception);
335     void ExportMED( in string file, in boolean auto_groups )
336       raises (SALOME::SALOME_Exception);
337
338     /*!
339      * Export Mesh to DAT, UNV and STL Formats
340      */
341     void ExportDAT( in string file )
342       raises (SALOME::SALOME_Exception);
343     void ExportUNV( in string file )
344       raises (SALOME::SALOME_Exception);
345     void ExportSTL( in string file, in boolean isascii )
346       raises (SALOME::SALOME_Exception);
347
348     /*!
349      * Get MED Mesh
350      */
351     SALOME_MED::MESH GetMEDMesh()
352       raises (SALOME::SALOME_Exception);
353
354     long NbNodes()
355       raises (SALOME::SALOME_Exception);
356
357     long NbElements()
358       raises (SALOME::SALOME_Exception);
359
360     long NbEdges()
361       raises (SALOME::SALOME_Exception);
362
363     long NbFaces()
364       raises (SALOME::SALOME_Exception);
365
366     long NbTriangles()
367       raises (SALOME::SALOME_Exception);
368
369     long NbQuadrangles()
370       raises (SALOME::SALOME_Exception);
371
372     long NbVolumes()
373       raises (SALOME::SALOME_Exception);
374
375     long NbTetras()
376       raises (SALOME::SALOME_Exception);
377
378     long NbHexas()
379       raises (SALOME::SALOME_Exception);
380
381     long NbPyramids()
382       raises (SALOME::SALOME_Exception);
383
384     long NbPrisms()
385       raises (SALOME::SALOME_Exception);
386
387     long NbSubMesh()
388       raises (SALOME::SALOME_Exception);
389
390     long_array GetElementsId()
391       raises (SALOME::SALOME_Exception);
392
393     long_array GetElementsByType( in ElementType theType )
394       raises (SALOME::SALOME_Exception);
395
396     long_array GetNodesId()
397       raises (SALOME::SALOME_Exception);
398
399     string Dump();
400   };
401
402   interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
403   {
404     /*!
405      * 
406      */
407     long GetNumberOfElements()
408       raises (SALOME::SALOME_Exception);
409
410     /*!
411      * 
412      */
413     long GetNumberOfNodes( in boolean all )
414       raises (SALOME::SALOME_Exception);
415
416     /*!
417      * 
418      */
419     long_array GetElementsId()
420       raises (SALOME::SALOME_Exception);
421
422     /*!
423      * 
424      */
425     long_array GetElementsByType( in ElementType theType )
426       raises (SALOME::SALOME_Exception);
427
428     /*!
429      * 
430      */
431     long_array GetNodesId()
432       raises (SALOME::SALOME_Exception);
433
434     /*!
435      * Get geom shape the submesh is dedicated to
436      */
437     GEOM::GEOM_Object GetSubShape()
438       raises (SALOME::SALOME_Exception);
439
440     /*!
441      * Get SMESH_Mesh which stores nodes coordinates & elements definition
442      */
443     SMESH_Mesh GetFather()
444       raises (SALOME::SALOME_Exception);
445
446     /*!
447      * Get the internal Id 
448      */
449     long GetId();    
450
451     /*!
452      * Get MED subMesh
453      */
454     SALOME_MED::FAMILY GetFamily()
455       raises (SALOME::SALOME_Exception);
456   };
457   
458   /* 
459    * This interface makes modifications on the Mesh - removing elements and nodes etc.
460    */
461   interface NumericalFunctor;
462   interface SMESH_MeshEditor {
463
464
465     boolean RemoveElements(in long_array IDsOfElements);
466
467     boolean RemoveNodes(in long_array IDsOfNodes);
468
469     boolean AddNode(in double x, in double y, in double z);
470
471     boolean AddEdge(in long_array IDsOfNodes);
472
473     boolean AddFace(in long_array IDsOfNodes);
474
475     boolean AddVolume(in long_array IDsOfNodes);
476
477     boolean MoveNode(in long NodeID, in double x, in double y, in double z);
478
479     boolean InverseDiag(in long NodeID1, in long NodeID2);
480
481     boolean DeleteDiag(in long NodeID1, in long NodeID2);
482
483     boolean Reorient(in long_array IDsOfElements);
484     
485     boolean ReorientObject(in SMESH_IDSource  theObject);
486
487     boolean TriToQuad(in long_array       IDsOfElements,
488                       in NumericalFunctor Criterion,
489                       in double           MaxAngle);
490     
491     boolean TriToQuadObject(in SMESH_IDSource   theObject,
492                             in NumericalFunctor Criterion,
493                             in double           MaxAngle);
494     
495     boolean QuadToTri(in long_array       IDsOfElements,
496                       in NumericalFunctor Criterion);
497
498     boolean SplitQuad(in long_array IDsOfElements,
499                       in boolean    Diag13);
500
501     boolean SplitQuadObject(in SMESH_IDSource   theObject,
502                             in boolean    Diag13);
503
504     enum Smooth_Method { LAPLACIAN_SMOOTH, CENTROIDAL_SMOOTH };
505
506     boolean Smooth(in long_array    IDsOfElements,
507                    in long_array    IDsOfFixedNodes,
508                    in long          MaxNbOfIterations,
509                    in double        MaxAspectRatio,
510                    in Smooth_Method Method);
511
512     boolean SmoothObject(in SMESH_IDSource  theObject,
513                          in long_array      IDsOfFixedNodes,
514                          in long            MaxNbOfIterations,
515                          in double          MaxAspectRatio,
516                          in Smooth_Method   Method);
517
518     void RenumberNodes();
519
520     void RenumberElements();
521
522     void RotationSweep(in long_array       IDsOfElements,
523                        in AxisStruct       Axix,
524                        in double           AngleInRadians,
525                        in long             NbOfSteps,
526                        in double           Tolerance);
527
528     void RotationSweepObject(in SMESH_IDSource  theObject,
529                              in AxisStruct      Axix,
530                              in double          AngleInRadians,
531                              in long            NbOfSteps,
532                              in double          Tolerance);
533                        
534     void ExtrusionSweep(in long_array      IDsOfElements,
535                         in DirStruct       StepVector,
536                         in long            NbOfSteps);
537
538     void ExtrusionSweepObject(in SMESH_IDSource  theObject,
539                               in DirStruct       StepVector,
540                               in long            NbOfSteps);
541
542     enum Extrusion_Error {
543       EXTR_OK,
544       EXTR_NO_ELEMENTS, 
545       EXTR_PATH_NOT_EDGE,
546       EXTR_BAD_PATH_SHAPE,
547       EXTR_BAD_STARTING_NODE,
548       EXTR_BAD_ANGLES_NUMBER,
549       EXTR_CANT_GET_TANGENT
550       };
551
552     Extrusion_Error ExtrusionAlongPath(in long_array        IDsOfElements,
553                                        in SMESH_Mesh        PathMesh,
554                                        in GEOM::GEOM_Object PathShape,
555                                        in long              NodeStart,
556                                        in boolean           HasAngles,
557                                        in double_array      Angles,
558                                        in boolean           HasRefPoint,
559                                        in PointStruct       RefPoint);
560
561     Extrusion_Error ExtrusionAlongPathObject(in SMESH_IDSource    theObject,
562                                              in SMESH_Mesh        PathMesh,
563                                              in GEOM::GEOM_Object PathShape,
564                                              in long              NodeStart,
565                                              in boolean           HasAngles,
566                                              in double_array      Angles,
567                                              in boolean           HasRefPoint,
568                                              in PointStruct       RefPoint);
569
570     enum MirrorType { POINT, AXIS, PLANE };
571
572     void Mirror (in long_array       IDsOfElements,
573                  in AxisStruct       Mirror,
574                  in MirrorType       theMirrorType,
575                  in boolean          Copy);
576
577     void MirrorObject (in SMESH_IDSource  theObject,
578                        in AxisStruct      Mirror,
579                        in MirrorType      theMirrorType,
580                        in boolean         Copy);
581
582     void Translate (in long_array      IDsOfElements,
583                     in DirStruct       Vector,
584                     in boolean         Copy);
585
586     void TranslateObject (in SMESH_IDSource  theObject,
587                           in DirStruct       Vector,
588                           in boolean         Copy);
589     
590     void Rotate (in long_array       IDsOfElements,
591                  in AxisStruct       Axis,
592                  in double           AngleInRadians,
593                  in boolean          Copy);
594
595     void RotateObject (in SMESH_IDSource  theObject,
596                        in AxisStruct      Axis,
597                        in double          AngleInRadians,
598                        in boolean         Copy);
599     
600     void FindCoincidentNodes (in  double              Tolerance,
601                               out array_of_long_array GroupsOfNodes);
602
603     void MergeNodes (in array_of_long_array GroupsOfNodes);
604
605     void MergeEqualElements();
606
607     enum Sew_Error {
608       SEW_OK,
609       SEW_BORDER1_NOT_FOUND,
610       SEW_BORDER2_NOT_FOUND,
611       SEW_BOTH_BORDERS_NOT_FOUND,
612       SEW_BAD_SIDE_NODES,
613       SEW_VOLUMES_TO_SPLIT,
614       // for SewSideElements() only:
615       SEW_DIFF_NB_OF_ELEMENTS,
616       SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
617       SEW_BAD_SIDE1_NODES,
618       SEW_BAD_SIDE2_NODES
619       };
620
621     Sew_Error SewFreeBorders (in long FirstNodeID1,
622                               in long SecondNodeID1,
623                               in long LastNodeID1,
624                               in long FirstNodeID2,
625                               in long SecondNodeID2,
626                               in long LastNodeID2);
627
628     Sew_Error SewConformFreeBorders (in long FirstNodeID1,
629                                      in long SecondNodeID1,
630                                      in long LastNodeID1,
631                                      in long FirstNodeID2,
632                                      in long SecondNodeID2);
633
634     Sew_Error SewBorderToSide (in long FirstNodeIDOnFreeBorder,
635                                in long SecondNodeIDOnFreeBorder,
636                                in long LastNodeIDOnFreeBorder,
637                                in long FirstNodeIDOnSide,
638                                in long LastNodeIDOnSide);
639
640     Sew_Error SewSideElements (in long_array IDsOfSide1Elements,
641                                in long_array IDsOfSide2Elements,
642                                in long       NodeID1OfSide1ToMerge,
643                                in long       NodeID1OfSide2ToMerge,
644                                in long       NodeID2OfSide1ToMerge,
645                                in long       NodeID2OfSide2ToMerge);
646
647   };
648 };
649
650 #endif