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