Salome HOME
Merge with version on tag OCC-V2_1_0d
[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   typedef sequence<log_block> log_array;
136
137
138   interface SMESH_IDSource
139   {
140     /*!
141      * Returns a sequence of all element IDs
142      */
143     long_array GetIDs();
144   };
145   
146   interface SMESH_GroupBase;
147   interface SMESH_Group;
148   interface SMESH_GroupOnGeom;
149   interface SMESH_subMesh;
150   interface SMESH_MeshEditor;
151   interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource
152   {
153     /*!
154      * Associate a Shape to a Mesh created with NewEmpty
155      */
156
157 //     boolean SetMesh(in GEOM::GEOM_Object anObject)
158 //        raises (SALOME::SALOME_Exception);
159
160     /*!
161      * Get the subMesh object associated to a subShape. The subMesh object
162      * gives access to nodes and elements IDs.
163      * SubMesh will be used instead of SubShape in a next idl version to 
164      * adress a specific subMesh...
165      */
166     SMESH_subMesh GetSubMesh(in GEOM::GEOM_Object aSubObject, in string name)
167       raises (SALOME::SALOME_Exception);
168
169     /*!
170      * Create a subMesh without reference to a subShape
171      */
172 //     SMESH_subMesh NewEmpty()
173 //       raises (SALOME::SALOME_Exception);
174
175     /*!
176      * Get geom shape to mesh. A result may be nil
177      */
178     GEOM::GEOM_Object GetShapeToMesh()
179       raises (SALOME::SALOME_Exception);
180
181     /*!
182      * Remove a submesh
183      */
184     void RemoveSubMesh(in SMESH_subMesh aSubMesh)
185       raises (SALOME::SALOME_Exception);
186
187     /*!
188      * Create a group
189      */
190     SMESH_Group CreateGroup( in ElementType elem_type,
191                              in string name )
192       raises (SALOME::SALOME_Exception);
193
194     /*!
195      * Create a group from geometry group
196      */
197     SMESH_GroupOnGeom CreateGroupFromGEOM( in ElementType elem_type,
198                                           in string name,
199                                           in GEOM::GEOM_Object theGeomObject )
200       raises (SALOME::SALOME_Exception);
201
202     /*!
203      * Remove a group
204      */
205     void RemoveGroup(in SMESH_GroupBase aGroup)
206       raises (SALOME::SALOME_Exception);
207
208      /*!
209      *  Remove group with its contents
210      */
211     void RemoveGroupWithContents( in SMESH_GroupBase aGroup )
212         raises (SALOME::SALOME_Exception);
213
214     /*!
215      * Union of two groups
216      *    New group is created. All mesh elements that are 
217      *    present in initial groups are added to the new one
218      */
219     SMESH_Group UnionGroups (in SMESH_GroupBase aGroup1,
220                              in SMESH_GroupBase aGroup2,
221                              in string          name )
222         raises (SALOME::SALOME_Exception);
223
224     /*!
225      *  Intersection of two groups
226      *  New group is created. All mesh elements that are 
227      *  present in both initial groups are added to the new one.
228      */
229     SMESH_Group IntersectGroups (in SMESH_GroupBase aGroup1,
230                                  in SMESH_GroupBase aGroup2,
231                                  in string          name )
232         raises (SALOME::SALOME_Exception);
233
234       /*!
235        *  Cut of two groups
236        *  New group is created. All mesh elements that are present in 
237        *  main group but do not present in tool group are added to the new one
238        */
239       SMESH_Group CutGroups (in SMESH_GroupBase aMainGroup,
240                              in SMESH_GroupBase aToolGroup,
241                              in string          name )
242           raises (SALOME::SALOME_Exception);
243
244     /*!
245      * Add hypothesis to the mesh, under a particular subShape
246      * (or the main shape itself)
247      * The Add method is only used to prepare the build of the mesh and store
248      * the algorithms and associated parameters.
249      * Actual job of mesh the shape is done by MESH_Gen.
250      * @params
251      * - aSubShape : subShape obtained by a shape explode in GEOM
252      *   (or main shape)
253      * - anHyp : hypothesis object 
254      * @return
255      * - OK if the hypothesis is compatible with the subShape 
256      *   (and all previous hypothesis on the subShape)
257      * - NOK if the hypothesis is not compatible with the subShape
258      *   (or one previous hypothesis on the subShape)
259      * raises exception if hypothesis has not been created
260      */
261     Hypothesis_Status AddHypothesis(in GEOM::GEOM_Object aSubObject,
262                                     in SMESH_Hypothesis anHyp)
263       raises (SALOME::SALOME_Exception);
264 //     boolean AddHypothesis(in SMESH_subMesh aSubMesh, in SMESH_Hypothesis anHyp)
265 //       raises (SALOME::SALOME_Exception);
266
267
268     /*!
269      * Remove an hypothesis previouly added with AddHypothesis.
270      */
271     Hypothesis_Status RemoveHypothesis(in GEOM::GEOM_Object aSubObject,
272                                        in SMESH_Hypothesis anHyp)
273       raises (SALOME::SALOME_Exception);
274 //     boolean RemoveHypothesis(in SMESH_subMesh aSubMesh,
275 //                           in SMESH_Hypothesis anHyp)
276 //       raises (SALOME::SALOME_Exception);
277
278     /*!
279      * Get the list of hypothesis added on a subShape
280      */
281     ListOfHypothesis GetHypothesisList(in GEOM::GEOM_Object aSubObject)
282       raises (SALOME::SALOME_Exception);
283 //     ListOfHypothesis GetHypothesisList(in SMESH_subMesh aSubMesh)
284 //       raises (SALOME::SALOME_Exception);
285
286     /*!
287      * Get the log of nodes and elements added or removed since previous
288      * clear of the log.
289      * @params
290      * - clearAfterGet : log is emptied after Get (safe if concurrents access)
291      */
292     //    string_array GetLog(in boolean clearAfterGet)
293     //      raises (SALOME::SALOME_Exception);
294     log_array GetLog(in boolean clearAfterGet)
295       raises (SALOME::SALOME_Exception);
296
297     /*!
298      * Clear the log of nodes and elements added or removed since previous
299      * clear. Must be used immediately after GetLog if clearAfterGet is false.
300      */
301     void ClearLog()
302       raises (SALOME::SALOME_Exception);
303
304     /*!
305      * Get the internal Id 
306      */
307     long GetId();     
308
309     /*!
310      * Get the study Id 
311      */
312     long GetStudyId();    
313     
314     SMESH_MeshEditor GetMeshEditor() 
315        raises (SALOME::SALOME_Exception);
316
317     /*!
318      * Export Mesh with DAT and MED Formats
319      */
320     void ExportDAT( in string file )
321       raises (SALOME::SALOME_Exception);
322     void ExportMED( in string file, in boolean auto_groups )
323       raises (SALOME::SALOME_Exception);
324     void ExportUNV( in string file )
325       raises (SALOME::SALOME_Exception);
326     void ExportSTL( in string file, in boolean isascii )
327       raises (SALOME::SALOME_Exception);
328
329     /*!
330      * Get MED Mesh
331      */
332     SALOME_MED::MESH GetMEDMesh()
333       raises (SALOME::SALOME_Exception);
334
335     long NbNodes()
336       raises (SALOME::SALOME_Exception);
337
338     long NbEdges()
339       raises (SALOME::SALOME_Exception);
340
341     long NbFaces()
342       raises (SALOME::SALOME_Exception);
343
344     long NbTriangles()
345       raises (SALOME::SALOME_Exception);
346
347     long NbQuadrangles()
348       raises (SALOME::SALOME_Exception);
349
350     long NbVolumes()
351       raises (SALOME::SALOME_Exception);
352
353     long NbTetras()
354       raises (SALOME::SALOME_Exception);
355
356     long NbHexas()
357       raises (SALOME::SALOME_Exception);
358
359     long NbPyramids()
360       raises (SALOME::SALOME_Exception);
361
362     long NbPrisms()
363       raises (SALOME::SALOME_Exception);
364
365     long NbSubMesh()
366       raises (SALOME::SALOME_Exception);
367
368     string Dump();
369   };
370
371   interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource
372   {
373     /*!
374      * 
375      */
376     long GetNumberOfElements()
377       raises (SALOME::SALOME_Exception);
378
379     /*!
380      * 
381      */
382     long GetNumberOfNodes( in boolean all )
383       raises (SALOME::SALOME_Exception);
384
385     /*!
386      * 
387      */
388     long_array GetElementsId()
389       raises (SALOME::SALOME_Exception);
390
391     /*!
392      * 
393      */
394     long_array GetElementsByType( in ElementType theType )
395       raises (SALOME::SALOME_Exception);
396
397     /*!
398      * 
399      */
400     long_array GetNodesId()
401       raises (SALOME::SALOME_Exception);
402
403     /*!
404      * Get geom shape the submesh is dedicated to
405      */
406     GEOM::GEOM_Object GetSubShape()
407       raises (SALOME::SALOME_Exception);
408
409     /*!
410      * Get SMESH_Mesh which stores nodes coordinates & elements definition
411      */
412     SMESH_Mesh GetFather()
413       raises (SALOME::SALOME_Exception);
414
415     /*!
416      * Get the internal Id 
417      */
418     long GetId();    
419
420     /*!
421      * Get MED subMesh
422      */
423     SALOME_MED::FAMILY GetFamily()
424       raises (SALOME::SALOME_Exception);
425   };
426   
427   /* 
428    * This interface makes modifications on the Mesh - removing elements and nodes etc.
429    */
430   interface NumericalFunctor;
431   interface SMESH_MeshEditor {
432
433
434     boolean RemoveElements(in long_array IDsOfElements);
435
436     boolean RemoveNodes(in long_array IDsOfNodes);
437
438     boolean AddNode(in double x, in double y, in double z);
439
440     boolean AddEdge(in long_array IDsOfNodes);
441
442     boolean AddFace(in long_array IDsOfNodes);
443
444     boolean AddVolume(in long_array IDsOfNodes);
445
446     boolean MoveNode(in long NodeID, in double x, in double y, in double z);
447
448     boolean InverseDiag(in long NodeID1, in long NodeID2);
449
450     boolean DeleteDiag(in long NodeID1, in long NodeID2);
451
452     boolean Reorient(in long_array IDsOfElements);
453     
454     boolean ReorientObject(in SMESH_IDSource  theObject);
455
456     boolean TriToQuad(in long_array       IDsOfElements,
457                       in NumericalFunctor Criterion,
458                       in double           MaxAngle);
459     
460     boolean TriToQuadObject(in SMESH_IDSource   theObject,
461                             in NumericalFunctor Criterion,
462                             in double           MaxAngle);
463     
464     boolean QuadToTri(in long_array       IDsOfElements,
465                       in NumericalFunctor Criterion);
466
467     boolean SplitQuad(in long_array IDsOfElements,
468                       in boolean    Diag13);
469
470     boolean SplitQuadObject(in SMESH_IDSource   theObject,
471                             in boolean    Diag13);
472
473     enum Smooth_Method { LAPLACIAN_SMOOTH, CENTROIDAL_SMOOTH };
474
475     boolean Smooth(in long_array    IDsOfElements,
476                    in long_array    IDsOfFixedNodes,
477                    in long          MaxNbOfIterations,
478                    in double        MaxAspectRatio,
479                    in Smooth_Method Method);
480
481     boolean SmoothObject(in SMESH_IDSource  theObject,
482                          in long_array      IDsOfFixedNodes,
483                          in long            MaxNbOfIterations,
484                          in double          MaxAspectRatio,
485                          in Smooth_Method   Method);
486
487     void RenumberNodes();
488
489     void RenumberElements();
490
491     void RotationSweep(in long_array       IDsOfElements,
492                        in AxisStruct       Axix,
493                        in double           AngleInRadians,
494                        in long             NbOfSteps,
495                        in double           Tolerance);
496
497     void RotationSweepObject(in SMESH_IDSource  theObject,
498                              in AxisStruct      Axix,
499                              in double          AngleInRadians,
500                              in long            NbOfSteps,
501                              in double          Tolerance);
502                        
503     void ExtrusionSweep(in long_array      IDsOfElements,
504                         in DirStruct       StepVector,
505                         in long            NbOfSteps);
506
507     void ExtrusionSweepObject(in SMESH_IDSource  theObject,
508                               in DirStruct       StepVector,
509                               in long            NbOfSteps);
510
511     enum MirrorType { POINT, AXIS, PLANE };
512
513     void Mirror (in long_array       IDsOfElements,
514                  in AxisStruct       Mirror,
515                  in MirrorType       theMirrorType,
516                  in boolean          Copy);
517
518     void MirrorObject (in SMESH_IDSource  theObject,
519                        in AxisStruct      Mirror,
520                        in MirrorType      theMirrorType,
521                        in boolean         Copy);
522
523     void Translate (in long_array      IDsOfElements,
524                     in DirStruct       Vector,
525                     in boolean         Copy);
526
527     void TranslateObject (in SMESH_IDSource  theObject,
528                           in DirStruct       Vector,
529                           in boolean         Copy);
530     
531     void Rotate (in long_array       IDsOfElements,
532                  in AxisStruct       Axis,
533                  in double           AngleInRadians,
534                  in boolean          Copy);
535
536     void RotateObject (in SMESH_IDSource  theObject,
537                        in AxisStruct      Axis,
538                        in double          AngleInRadians,
539                        in boolean         Copy);
540     
541     void FindCoincidentNodes (in  double              Tolerance,
542                               out array_of_long_array GroupsOfNodes);
543
544     void MergeNodes (in array_of_long_array GroupsOfNodes);
545
546     void MergeEqualElements();
547
548     enum Sew_Error {
549       SEW_OK,
550       SEW_BORDER1_NOT_FOUND,
551       SEW_BORDER2_NOT_FOUND,
552       SEW_BOTH_BORDERS_NOT_FOUND,
553       SEW_BAD_SIDE_NODES,
554       SEW_VOLUMES_TO_SPLIT,
555       // for SewSideElements() only:
556       SEW_DIFF_NB_OF_ELEMENTS,
557       SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
558       SEW_BAD_SIDE1_NODES,
559       SEW_BAD_SIDE2_NODES
560       };
561
562     Sew_Error SewFreeBorders (in long FirstNodeID1,
563                               in long SecondNodeID1,
564                               in long LastNodeID1,
565                               in long FirstNodeID2,
566                               in long SecondNodeID2,
567                               in long LastNodeID2);
568
569     Sew_Error SewConformFreeBorders (in long FirstNodeID1,
570                                      in long SecondNodeID1,
571                                      in long LastNodeID1,
572                                      in long FirstNodeID2,
573                                      in long SecondNodeID2);
574
575     Sew_Error SewBorderToSide (in long FirstNodeIDOnFreeBorder,
576                                in long SecondNodeIDOnFreeBorder,
577                                in long LastNodeIDOnFreeBorder,
578                                in long FirstNodeIDOnSide,
579                                in long LastNodeIDOnSide);
580
581     Sew_Error SewSideElements (in long_array IDsOfSide1Elements,
582                                in long_array IDsOfSide2Elements,
583                                in long       NodeID1OfSide1ToMerge,
584                                in long       NodeID1OfSide2ToMerge,
585                                in long       NodeID2OfSide1ToMerge,
586                                in long       NodeID2OfSide2ToMerge);
587
588   };
589 };
590
591 #endif