Salome HOME
PAL7912. Fix SaveTo(ostream)
[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 different 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      * - theVersion : define the version of format of MED file, that will be created
333      */
334     void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion )
335       raises (SALOME::SALOME_Exception);
336     /*!
337      * Export Mesh to MED_V2_1 MED format
338      * Works, just the same as ExportToMED, with MED_VERSION parameter equal to MED_V2_1.
339      * The method is kept in order to support old functionality
340      */
341     void ExportMED( in string file, in boolean auto_groups )
342       raises (SALOME::SALOME_Exception);
343
344     /*!
345      * Export Mesh to DAT, UNV and STL Formats
346      */
347     void ExportDAT( in string file )
348       raises (SALOME::SALOME_Exception);
349     void ExportUNV( in string file )
350       raises (SALOME::SALOME_Exception);
351     void ExportSTL( in string file, in boolean isascii )
352       raises (SALOME::SALOME_Exception);
353
354     /*!
355      * Get MED Mesh
356      */
357     SALOME_MED::MESH GetMEDMesh()
358       raises (SALOME::SALOME_Exception);
359
360     long NbNodes()
361       raises (SALOME::SALOME_Exception);
362
363     long NbElements()
364       raises (SALOME::SALOME_Exception);
365
366     long NbEdges()
367       raises (SALOME::SALOME_Exception);
368
369     long NbFaces()
370       raises (SALOME::SALOME_Exception);
371
372     long NbTriangles()
373       raises (SALOME::SALOME_Exception);
374
375     long NbQuadrangles()
376       raises (SALOME::SALOME_Exception);
377
378     long NbVolumes()
379       raises (SALOME::SALOME_Exception);
380
381     long NbTetras()
382       raises (SALOME::SALOME_Exception);
383
384     long NbHexas()
385       raises (SALOME::SALOME_Exception);
386
387     long NbPyramids()
388       raises (SALOME::SALOME_Exception);
389
390     long NbPrisms()
391       raises (SALOME::SALOME_Exception);
392
393     long NbSubMesh()
394       raises (SALOME::SALOME_Exception);
395
396     long_array GetElementsId()
397       raises (SALOME::SALOME_Exception);
398
399     long_array GetElementsByType( in ElementType theType )
400       raises (SALOME::SALOME_Exception);
401
402     long_array GetNodesId()
403       raises (SALOME::SALOME_Exception);
404
405     string Dump();
406   };
407
408   interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
409   {
410     /*!
411      * 
412      */
413     long GetNumberOfElements()
414       raises (SALOME::SALOME_Exception);
415
416     /*!
417      * 
418      */
419     long GetNumberOfNodes( in boolean all )
420       raises (SALOME::SALOME_Exception);
421
422     /*!
423      * 
424      */
425     long_array GetElementsId()
426       raises (SALOME::SALOME_Exception);
427
428     /*!
429      * 
430      */
431     long_array GetElementsByType( in ElementType theType )
432       raises (SALOME::SALOME_Exception);
433
434     /*!
435      * 
436      */
437     long_array GetNodesId()
438       raises (SALOME::SALOME_Exception);
439
440     /*!
441      * Get geom shape the submesh is dedicated to
442      */
443     GEOM::GEOM_Object GetSubShape()
444       raises (SALOME::SALOME_Exception);
445
446     /*!
447      * Get SMESH_Mesh which stores nodes coordinates & elements definition
448      */
449     SMESH_Mesh GetFather()
450       raises (SALOME::SALOME_Exception);
451
452     /*!
453      * Get the internal Id 
454      */
455     long GetId();    
456
457     /*!
458      * Get MED subMesh
459      */
460     SALOME_MED::FAMILY GetFamily()
461       raises (SALOME::SALOME_Exception);
462   };
463   
464   /* 
465    * This interface makes modifications on the Mesh - removing elements and nodes etc.
466    */
467   interface NumericalFunctor;
468   interface SMESH_MeshEditor {
469
470
471     boolean RemoveElements(in long_array IDsOfElements);
472
473     boolean RemoveNodes(in long_array IDsOfNodes);
474
475     boolean AddNode(in double x, in double y, in double z);
476
477     boolean AddEdge(in long_array IDsOfNodes);
478
479     boolean AddFace(in long_array IDsOfNodes);
480
481     boolean AddVolume(in long_array IDsOfNodes);
482
483     boolean MoveNode(in long NodeID, in double x, in double y, in double z);
484
485     boolean InverseDiag(in long NodeID1, in long NodeID2);
486
487     boolean DeleteDiag(in long NodeID1, in long NodeID2);
488
489     boolean Reorient(in long_array IDsOfElements);
490     
491     boolean ReorientObject(in SMESH_IDSource  theObject);
492
493     boolean TriToQuad(in long_array       IDsOfElements,
494                       in NumericalFunctor Criterion,
495                       in double           MaxAngle);
496     
497     boolean TriToQuadObject(in SMESH_IDSource   theObject,
498                             in NumericalFunctor Criterion,
499                             in double           MaxAngle);
500     
501     boolean QuadToTri(in long_array       IDsOfElements,
502                       in NumericalFunctor Criterion);
503
504     boolean SplitQuad(in long_array IDsOfElements,
505                       in boolean    Diag13);
506
507     boolean SplitQuadObject(in SMESH_IDSource   theObject,
508                             in boolean    Diag13);
509
510     enum Smooth_Method { LAPLACIAN_SMOOTH, CENTROIDAL_SMOOTH };
511
512     boolean Smooth(in long_array    IDsOfElements,
513                    in long_array    IDsOfFixedNodes,
514                    in long          MaxNbOfIterations,
515                    in double        MaxAspectRatio,
516                    in Smooth_Method Method);
517
518     boolean SmoothObject(in SMESH_IDSource  theObject,
519                          in long_array      IDsOfFixedNodes,
520                          in long            MaxNbOfIterations,
521                          in double          MaxAspectRatio,
522                          in Smooth_Method   Method);
523
524     void RenumberNodes();
525
526     void RenumberElements();
527
528     void RotationSweep(in long_array       IDsOfElements,
529                        in AxisStruct       Axix,
530                        in double           AngleInRadians,
531                        in long             NbOfSteps,
532                        in double           Tolerance);
533
534     void RotationSweepObject(in SMESH_IDSource  theObject,
535                              in AxisStruct      Axix,
536                              in double          AngleInRadians,
537                              in long            NbOfSteps,
538                              in double          Tolerance);
539                        
540     void ExtrusionSweep(in long_array      IDsOfElements,
541                         in DirStruct       StepVector,
542                         in long            NbOfSteps);
543
544     void ExtrusionSweepObject(in SMESH_IDSource  theObject,
545                               in DirStruct       StepVector,
546                               in long            NbOfSteps);
547
548     enum Extrusion_Error {
549       EXTR_OK,
550       EXTR_NO_ELEMENTS, 
551       EXTR_PATH_NOT_EDGE,
552       EXTR_BAD_PATH_SHAPE,
553       EXTR_BAD_STARTING_NODE,
554       EXTR_BAD_ANGLES_NUMBER,
555       EXTR_CANT_GET_TANGENT
556       };
557
558     Extrusion_Error ExtrusionAlongPath(in long_array        IDsOfElements,
559                                        in SMESH_Mesh        PathMesh,
560                                        in GEOM::GEOM_Object PathShape,
561                                        in long              NodeStart,
562                                        in boolean           HasAngles,
563                                        in double_array      Angles,
564                                        in boolean           HasRefPoint,
565                                        in PointStruct       RefPoint);
566
567     Extrusion_Error ExtrusionAlongPathObject(in SMESH_IDSource    theObject,
568                                              in SMESH_Mesh        PathMesh,
569                                              in GEOM::GEOM_Object PathShape,
570                                              in long              NodeStart,
571                                              in boolean           HasAngles,
572                                              in double_array      Angles,
573                                              in boolean           HasRefPoint,
574                                              in PointStruct       RefPoint);
575
576     enum MirrorType { POINT, AXIS, PLANE };
577
578     void Mirror (in long_array       IDsOfElements,
579                  in AxisStruct       Mirror,
580                  in MirrorType       theMirrorType,
581                  in boolean          Copy);
582
583     void MirrorObject (in SMESH_IDSource  theObject,
584                        in AxisStruct      Mirror,
585                        in MirrorType      theMirrorType,
586                        in boolean         Copy);
587
588     void Translate (in long_array      IDsOfElements,
589                     in DirStruct       Vector,
590                     in boolean         Copy);
591
592     void TranslateObject (in SMESH_IDSource  theObject,
593                           in DirStruct       Vector,
594                           in boolean         Copy);
595     
596     void Rotate (in long_array       IDsOfElements,
597                  in AxisStruct       Axis,
598                  in double           AngleInRadians,
599                  in boolean          Copy);
600
601     void RotateObject (in SMESH_IDSource  theObject,
602                        in AxisStruct      Axis,
603                        in double          AngleInRadians,
604                        in boolean         Copy);
605     
606     void FindCoincidentNodes (in  double              Tolerance,
607                               out array_of_long_array GroupsOfNodes);
608
609     void MergeNodes (in array_of_long_array GroupsOfNodes);
610
611     void MergeEqualElements();
612
613     enum Sew_Error {
614       SEW_OK,
615       SEW_BORDER1_NOT_FOUND,
616       SEW_BORDER2_NOT_FOUND,
617       SEW_BOTH_BORDERS_NOT_FOUND,
618       SEW_BAD_SIDE_NODES,
619       SEW_VOLUMES_TO_SPLIT,
620       // for SewSideElements() only:
621       SEW_DIFF_NB_OF_ELEMENTS,
622       SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
623       SEW_BAD_SIDE1_NODES,
624       SEW_BAD_SIDE2_NODES
625       };
626
627     Sew_Error SewFreeBorders (in long FirstNodeID1,
628                               in long SecondNodeID1,
629                               in long LastNodeID1,
630                               in long FirstNodeID2,
631                               in long SecondNodeID2,
632                               in long LastNodeID2);
633
634     Sew_Error SewConformFreeBorders (in long FirstNodeID1,
635                                      in long SecondNodeID1,
636                                      in long LastNodeID1,
637                                      in long FirstNodeID2,
638                                      in long SecondNodeID2);
639
640     Sew_Error SewBorderToSide (in long FirstNodeIDOnFreeBorder,
641                                in long SecondNodeIDOnFreeBorder,
642                                in long LastNodeIDOnFreeBorder,
643                                in long FirstNodeIDOnSide,
644                                in long LastNodeIDOnSide);
645
646     Sew_Error SewSideElements (in long_array IDsOfSide1Elements,
647                                in long_array IDsOfSide2Elements,
648                                in long       NodeID1OfSide1ToMerge,
649                                in long       NodeID1OfSide2ToMerge,
650                                in long       NodeID2OfSide1ToMerge,
651                                in long       NodeID2OfSide2ToMerge);
652
653   };
654 };
655
656 #endif