Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/smesh.git] / idl / SMESH_MeshEditor.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_MeshEditor.idl
23 //  $Header$
24
25 #ifndef _SMESH_MESHEDITOR_IDL_
26 #define _SMESH_MESHEDITOR_IDL_
27
28 #include "SMESH_Mesh.idl"
29
30 module SMESH
31 {
32   /*!
33    * Structure used in mesh edit preview data
34    */
35   struct ElementSubType { ElementType SMDS_ElementType;
36                           boolean     isPoly;
37                           long        nbNodesInElement; };
38
39   typedef sequence<ElementSubType> types_array;
40
41   /*!
42    * Structure containing mesh edit preview data
43    */
44   struct MeshPreviewStruct { nodes_array nodesXYZ;
45                              long_array  elementConnectivities;
46                              types_array elementTypes; };
47
48   /*!
49    * This interface makes modifications on the Mesh - removing elements and nodes etc.
50    */
51   interface NumericalFunctor;
52   interface SMESH_MeshEditor
53   {
54     boolean RemoveElements(in long_array IDsOfElements);
55
56     boolean RemoveNodes(in long_array IDsOfNodes);
57
58     long AddNode(in double x, in double y, in double z);
59
60     /*!
61      *  Create edge, either linear and quadratic (this is determed
62      *  by number of given nodes).
63      *  \param IdsOfNodes List of node IDs for creation of element.
64      *  Needed order of nodes in this list corresponds to description
65      *  of MED. This description is located by the following link:
66      *   http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
67      */
68     long AddEdge(in long_array IDsOfNodes);
69
70     /*!
71      *  Create face, either linear and quadratic (this is determed
72      *  by number of given nodes).
73      *  \param IdsOfNodes List of node IDs for creation of element.
74      *  Needed order of nodes in this list corresponds to description
75      *  of MED. This description is located by the following link:
76      *   http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
77      */
78     long AddFace(in long_array IDsOfNodes);
79
80     long AddPolygonalFace(in long_array IdsOfNodes);
81
82     /*!
83      *  Create volume, either linear and quadratic (this is determed
84      *  by number of given nodes).
85      *  \param IdsOfNodes List of node IDs for creation of element.
86      *  Needed order of nodes in this list corresponds to description
87      *  of MED. This description is located by the following link:
88      *   http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
89      */
90     long AddVolume(in long_array IDsOfNodes);
91
92     /*!
93      *  Create volume of many faces, giving nodes for each face.
94      *  \param IdsOfNodes List of node IDs for volume creation face by face.
95      *  \param Quantities List of integer values, Quantities[i]
96      *         gives quantity of nodes in face number i.
97      */
98     long AddPolyhedralVolume (in long_array IdsOfNodes,
99                               in long_array Quantities);
100
101     /*!
102      *  Create volume of many faces, giving IDs of existing faces.
103      *  \param IdsOfFaces List of face IDs for volume creation.
104      *  \note The created volume will refer only to nodes
105      *        of the given faces, not to the faces itself.
106      */
107     long AddPolyhedralVolumeByFaces (in long_array IdsOfFaces);
108
109     /*!
110      * \brief Bind a node to a vertex
111       * \param NodeID - node ID
112       * \param VertexID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
113      */
114     void SetNodeOnVertex(in long NodeID, in long VertexID)
115       raises (SALOME::SALOME_Exception);
116     /*!
117      * \brief Store node position on an edge
118       * \param NodeID - node ID
119       * \param EdgeID - edge ID available through GEOM_Object.GetSubShapeIndices()[0]
120       * \param paramOnEdge - parameter on edge where the node is located
121      */
122     void SetNodeOnEdge(in long NodeID, in long EdgeID, in double paramOnEdge)
123       raises (SALOME::SALOME_Exception);
124     /*!
125      * \brief Store node position on a face
126       * \param NodeID - node ID
127       * \param FaceID - face ID available through GEOM_Object.GetSubShapeIndices()[0]
128       * \param u - U parameter on face where the node is located
129       * \param v - V parameter on face where the node is located
130      */
131     void SetNodeOnFace(in long NodeID, in long FaceID, in double u, in double v)
132       raises (SALOME::SALOME_Exception);
133     /*!
134      * \brief Bind a node to a solid
135       * \param NodeID - node ID
136       * \param SolidID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
137      */
138     void SetNodeInVolume(in long NodeID, in long SolidID)
139       raises (SALOME::SALOME_Exception);
140     /*!
141      * \brief Bind an element to a shape
142       * \param ElementID - element ID
143       * \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
144      */
145     void SetMeshElementOnShape(in long ElementID, in long ShapeID)
146       raises (SALOME::SALOME_Exception);
147
148
149     boolean MoveNode(in long NodeID, in double x, in double y, in double z);
150
151     boolean InverseDiag(in long NodeID1, in long NodeID2);
152
153     boolean DeleteDiag(in long NodeID1, in long NodeID2);
154
155     boolean Reorient(in long_array IDsOfElements);
156
157     boolean ReorientObject(in SMESH_IDSource theObject);
158
159     /*!
160      * \brief Fuse neighbour triangles into quadrangles.
161      * \param theElems     The triangles to be fused.
162      * \param theCriterion Is used to choose a neighbour to fuse with.
163      * \param theMaxAngle  Is a max angle between element normals at which fusion
164      *                     is still performed; theMaxAngle is mesured in radians.
165      * \return TRUE in case of success, FALSE otherwise.
166      */
167     boolean TriToQuad (in long_array       IDsOfElements,
168                        in NumericalFunctor Criterion,
169                        in double           MaxAngle);
170
171     /*!
172      * \brief Fuse neighbour triangles into quadrangles.
173      *
174      * Behaves like the above method, taking list of elements from \a theObject
175      */
176     boolean TriToQuadObject (in SMESH_IDSource   theObject,
177                              in NumericalFunctor Criterion,
178                              in double           MaxAngle);
179
180     /*!
181      * \brief Split quadrangles into triangles.
182      * \param theElems     The faces to be splitted.
183      * \param theCriterion Is used to choose a diagonal for splitting.
184      * \return TRUE in case of success, FALSE otherwise.
185      */
186     boolean QuadToTri (in long_array       IDsOfElements,
187                        in NumericalFunctor Criterion);
188
189     /*!
190      * \brief Split quadrangles into triangles.
191      *
192      * Behaves like the above method, taking list of elements from \a theObject
193      */
194     boolean QuadToTriObject (in SMESH_IDSource   theObject,
195                              in NumericalFunctor Criterion);
196
197     /*!
198      * \brief Split quadrangles into triangles.
199      * \param theElems  The faces to be splitted.
200      * \param the13Diag Is used to choose a diagonal for splitting.
201      * \return TRUE in case of success, FALSE otherwise.
202      */
203     boolean SplitQuad (in long_array IDsOfElements,
204                        in boolean    Diag13);
205
206     /*!
207      * \brief Split quadrangles into triangles.
208      *
209      * Behaves like the above method, taking list of elements from \a theObject
210      */
211     boolean SplitQuadObject (in SMESH_IDSource theObject,
212                              in boolean        Diag13);
213
214     /*!
215      *  Find better splitting of the given quadrangle.
216      *  \param IDOfQuad  ID of the quadrangle to be splitted.
217      *  \param Criterion A criterion to choose a diagonal for splitting.
218      *  \return 1 if 1-3 diagonal is better, 2 if 2-4
219      *          diagonal is better, 0 if error occurs.
220      */
221     long BestSplit (in long             IDOfQuad,
222                     in NumericalFunctor Criterion);
223
224     enum Smooth_Method { LAPLACIAN_SMOOTH, CENTROIDAL_SMOOTH };
225
226     boolean Smooth(in long_array    IDsOfElements,
227                    in long_array    IDsOfFixedNodes,
228                    in long          MaxNbOfIterations,
229                    in double        MaxAspectRatio,
230                    in Smooth_Method Method);
231
232     boolean SmoothObject(in SMESH_IDSource  theObject,
233                          in long_array      IDsOfFixedNodes,
234                          in long            MaxNbOfIterations,
235                          in double          MaxAspectRatio,
236                          in Smooth_Method   Method);
237
238     boolean SmoothParametric(in long_array    IDsOfElements,
239                              in long_array    IDsOfFixedNodes,
240                              in long          MaxNbOfIterations,
241                              in double        MaxAspectRatio,
242                              in Smooth_Method Method);
243
244     boolean SmoothParametricObject(in SMESH_IDSource  theObject,
245                                    in long_array      IDsOfFixedNodes,
246                                    in long            MaxNbOfIterations,
247                                    in double          MaxAspectRatio,
248                                    in Smooth_Method   Method);
249
250     void ConvertToQuadratic(in boolean theForce3d);
251
252     boolean ConvertFromQuadratic();
253
254     void RenumberNodes();
255
256     void RenumberElements();
257
258     /*!
259      * \brief Genarate dim+1 elements by rotation of given elements around axis
260      * \param IDsOfElements - elements to ratate
261      * \param Axix - rotation axis
262      * \param AngleInRadians - rotation angle
263      * \param NbOfSteps - number of elements to generate from one element
264      */
265     void RotationSweep(in long_array       IDsOfElements,
266                        in AxisStruct       Axix,
267                        in double           AngleInRadians,
268                        in long             NbOfSteps,
269                        in double           Tolerance);
270     /*!
271      * \brief Same as previous but additionally create groups of elements
272      *  generated from elements belonging to preexisting groups
273      */
274     ListOfGroups RotationSweepMakeGroups(in long_array       IDsOfElements,
275                                          in AxisStruct       Axix,
276                                          in double           AngleInRadians,
277                                          in long             NbOfSteps,
278                                          in double           Tolerance);
279     /*!
280      * \brief Genarate dim+1 elements by rotation of the object around axis
281      * \param theObject - object containing elements to ratate
282      * \param Axix - rotation axis
283      * \param AngleInRadians - rotation angle
284      * \param NbOfSteps - number of elements to generate from one element
285      */
286     void RotationSweepObject(in SMESH_IDSource  theObject,
287                              in AxisStruct      Axix,
288                              in double          AngleInRadians,
289                              in long            NbOfSteps,
290                              in double          Tolerance);
291     /*!
292      * \brief Same as previous but additionally create groups of elements
293      *  generated from elements belonging to preexisting groups
294      */
295     ListOfGroups RotationSweepObjectMakeGroups(in SMESH_IDSource  theObject,
296                                                in AxisStruct      Axix,
297                                                in double          AngleInRadians,
298                                                in long            NbOfSteps,
299                                                in double          Tolerance);
300     /*!
301      * \brief Genarate dim+1 elements by extrusion of elements along vector
302      * \param IDsOfElements - elements to sweep
303      * \param StepVector - vector giving direction and distance of an extrusion step
304      * \param NbOfSteps - number of elements to generate from one element
305      */
306     void ExtrusionSweep(in long_array      IDsOfElements,
307                         in DirStruct       StepVector,
308                         in long            NbOfSteps);
309     /*!
310      * \brief Same as previous but additionally create groups of elements
311      *  generated from elements belonging to preexisting groups
312      */
313     ListOfGroups ExtrusionSweepMakeGroups(in long_array      IDsOfElements,
314                                           in DirStruct       StepVector,
315                                           in long            NbOfSteps);
316    /*!
317     * Generate new elements by extrusion of theElements 
318     * by StepVector by NbOfSteps
319     * param ExtrFlags set flags for performing extrusion
320     * param SewTolerance - uses for comparing locations of nodes if flag
321     *   EXTRUSION_FLAG_SEW is set
322     */
323     void AdvancedExtrusion(in long_array      IDsOfElements,
324                            in DirStruct       StepVector,
325                            in long            NbOfSteps,
326                            in long            ExtrFlags,
327                            in double          SewTolerance);
328     /*!
329      * \brief Same as previous but additionally create groups of elements
330      *  generated from elements belonging to preexisting groups
331      */
332     ListOfGroups AdvancedExtrusionMakeGroups(in long_array      IDsOfElements,
333                                              in DirStruct       StepVector,
334                                              in long            NbOfSteps,
335                                              in long            ExtrFlags,
336                                              in double          SewTolerance);
337
338     void ExtrusionSweepObject(in SMESH_IDSource  theObject,
339                               in DirStruct       StepVector,
340                               in long            NbOfSteps);
341     ListOfGroups ExtrusionSweepObjectMakeGroups(in SMESH_IDSource  theObject,
342                                                 in DirStruct       StepVector,
343                                                 in long            NbOfSteps);
344
345     void ExtrusionSweepObject1D(in SMESH_IDSource theObject,
346                                 in DirStruct      StepVector,
347                                 in long           NbOfSteps);
348     ListOfGroups ExtrusionSweepObject1DMakeGroups(in SMESH_IDSource theObject,
349                                                   in DirStruct      StepVector,
350                                                   in long           NbOfSteps);
351
352     void ExtrusionSweepObject2D(in SMESH_IDSource theObject,
353                                 in DirStruct      StepVector,
354                                 in long           NbOfSteps);
355     ListOfGroups ExtrusionSweepObject2DMakeGroups(in SMESH_IDSource theObject,
356                                                   in DirStruct      StepVector,
357                                                   in long           NbOfSteps);
358
359     enum Extrusion_Error {
360       EXTR_OK,
361       EXTR_NO_ELEMENTS,
362       EXTR_PATH_NOT_EDGE,
363       EXTR_BAD_PATH_SHAPE,
364       EXTR_BAD_STARTING_NODE,
365       EXTR_BAD_ANGLES_NUMBER,
366       EXTR_CANT_GET_TANGENT
367       };
368
369     Extrusion_Error ExtrusionAlongPath(in long_array        IDsOfElements,
370                                        in SMESH_Mesh        PathMesh,
371                                        in GEOM::GEOM_Object PathShape,
372                                        in long              NodeStart,
373                                        in boolean           HasAngles,
374                                        in double_array      Angles,
375                                        in boolean           HasRefPoint,
376                                        in PointStruct       RefPoint);
377     ListOfGroups ExtrusionAlongPathMakeGroups(in long_array        IDsOfElements,
378                                               in SMESH_Mesh        PathMesh,
379                                               in GEOM::GEOM_Object PathShape,
380                                               in long              NodeStart,
381                                               in boolean           HasAngles,
382                                               in double_array      Angles,
383                                               in boolean           HasRefPoint,
384                                               in PointStruct       RefPoint,
385                                               out Extrusion_Error  Error);
386
387     Extrusion_Error ExtrusionAlongPathObject(in SMESH_IDSource    theObject,
388                                              in SMESH_Mesh        PathMesh,
389                                              in GEOM::GEOM_Object PathShape,
390                                              in long              NodeStart,
391                                              in boolean           HasAngles,
392                                              in double_array      Angles,
393                                              in boolean           HasRefPoint,
394                                              in PointStruct       RefPoint);
395     ListOfGroups ExtrusionAlongPathObjectMakeGroups(in SMESH_IDSource    theObject,
396                                                     in SMESH_Mesh        PathMesh,
397                                                     in GEOM::GEOM_Object PathShape,
398                                                     in long              NodeStart,
399                                                     in boolean           HasAngles,
400                                                     in double_array      Angles,
401                                                     in boolean           HasRefPoint,
402                                                     in PointStruct       RefPoint,
403                                                     out Extrusion_Error  Error);
404
405    /*!
406     * Compute rotation angles for ExtrusionAlongPath as linear variation
407     * of given angles along path steps
408     * param PathMesh mesh containing a 1D sub-mesh on the edge, along 
409     *                which proceeds the extrusion
410     * param PathShape is shape(edge); as the mesh can be complex, the edge 
411     *                 is used to define the sub-mesh for the path
412     */
413     double_array LinearAnglesVariation(in SMESH_Mesh        PathMesh,
414                                        in GEOM::GEOM_Object PathShape,
415                                        in double_array      Angles);
416
417     enum MirrorType { POINT, AXIS, PLANE };
418
419     void Mirror (in long_array IDsOfElements,
420                  in AxisStruct Mirror,
421                  in MirrorType Type,
422                  in boolean    Copy);
423     ListOfGroups MirrorMakeGroups (in long_array IDsOfElements,
424                                    in AxisStruct Mirror,
425                                    in MirrorType Type);
426     SMESH_Mesh MirrorMakeMesh (in long_array IDsOfElements,
427                                in AxisStruct Mirror,
428                                in MirrorType Type,
429                                in boolean    CopyGroups,
430                                in string     MeshName);
431
432     void MirrorObject (in SMESH_IDSource theObject,
433                        in AxisStruct     Mirror,
434                        in MirrorType     Type,
435                        in boolean        Copy);
436     ListOfGroups MirrorObjectMakeGroups (in SMESH_IDSource theObject,
437                                          in AxisStruct     Mirror,
438                                          in MirrorType     Type);
439     SMESH_Mesh MirrorObjectMakeMesh (in SMESH_IDSource theObject,
440                                      in AxisStruct     Mirror,
441                                      in MirrorType     Type,
442                                      in boolean        CopyGroups,
443                                      in string         MeshName);
444
445     void Translate (in long_array IDsOfElements,
446                     in DirStruct  Vector,
447                     in boolean    Copy);
448     ListOfGroups TranslateMakeGroups (in long_array IDsOfElements,
449                                       in DirStruct  Vector);
450     SMESH_Mesh TranslateMakeMesh (in long_array IDsOfElements,
451                                   in DirStruct  Vector,
452                                   in boolean    CopyGroups,
453                                   in string     MeshName);
454
455     void TranslateObject (in SMESH_IDSource theObject,
456                           in DirStruct      Vector,
457                           in boolean        Copy);
458     ListOfGroups TranslateObjectMakeGroups (in SMESH_IDSource theObject,
459                                             in DirStruct      Vector);
460     SMESH_Mesh TranslateObjectMakeMesh (in SMESH_IDSource theObject,
461                                         in DirStruct      Vector,
462                                         in boolean        CopyGroups,
463                                         in string         MeshName);
464
465     void Rotate (in long_array IDsOfElements,
466                  in AxisStruct Axis,
467                  in double     AngleInRadians,
468                  in boolean    Copy);
469     ListOfGroups RotateMakeGroups (in long_array IDsOfElements,
470                                    in AxisStruct Axis,
471                                    in double     AngleInRadians);
472     SMESH_Mesh RotateMakeMesh (in long_array IDsOfElements,
473                                in AxisStruct Axis,
474                                in double     AngleInRadians,
475                                in boolean    CopyGroups,
476                                in string     MeshName);
477
478     void RotateObject (in SMESH_IDSource theObject,
479                        in AxisStruct     Axis,
480                        in double         AngleInRadians,
481                        in boolean        Copy);
482     ListOfGroups RotateObjectMakeGroups (in SMESH_IDSource theObject,
483                                          in AxisStruct     Axis,
484                                          in double         AngleInRadians);
485     SMESH_Mesh RotateObjectMakeMesh (in SMESH_IDSource theObject,
486                                      in AxisStruct     Axis,
487                                      in double         AngleInRadians,
488                                      in boolean        CopyGroups,
489                                      in string         MeshName);
490
491     void FindCoincidentNodes (in  double              Tolerance,
492                               out array_of_long_array GroupsOfNodes);
493
494     void FindCoincidentNodesOnPart (in  SMESH_IDSource      SubMeshOrGroup,
495                                     in  double              Tolerance,
496                                     out array_of_long_array GroupsOfNodes);
497
498     void MergeNodes (in array_of_long_array GroupsOfNodes);
499
500     /*!
501      * \brief Find elements built on the same nodes.
502      * \param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching.
503      * \return List of groups of equal elements.
504      */
505     void FindEqualElements (in  SMESH_IDSource      MeshOrSubMeshOrGroup,
506                             out array_of_long_array GroupsOfElementsID);
507
508     /*!
509      * \brief Merge elements in each given group.
510      * \param GroupsOfElementsID Groups of elements for merging.
511      */
512     void MergeElements(in array_of_long_array GroupsOfElementsID);
513
514     /*!
515      * \brief Merge equal elements in the whole mesh.
516      */
517     void MergeEqualElements();
518     
519     /*!
520      * If the given ID is a valid node ID (nodeID > 0), just move this node, else
521      * move the node closest to the point to point's location and return ID of the node
522      */
523     long MoveClosestNodeToPoint(in double x, in double y, in double z, in long nodeID);
524
525     enum Sew_Error {
526       SEW_OK,
527       SEW_BORDER1_NOT_FOUND,
528       SEW_BORDER2_NOT_FOUND,
529       SEW_BOTH_BORDERS_NOT_FOUND,
530       SEW_BAD_SIDE_NODES,
531       SEW_VOLUMES_TO_SPLIT,
532       // for SewSideElements() only:
533       SEW_DIFF_NB_OF_ELEMENTS,
534       SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
535       SEW_BAD_SIDE1_NODES,
536       SEW_BAD_SIDE2_NODES
537       };
538
539     Sew_Error SewFreeBorders (in long FirstNodeID1,
540                               in long SecondNodeID1,
541                               in long LastNodeID1,
542                               in long FirstNodeID2,
543                               in long SecondNodeID2,
544                               in long LastNodeID2,
545                               in boolean CreatePolygons,
546                               in boolean CreatePolyedrs);
547
548     Sew_Error SewConformFreeBorders (in long FirstNodeID1,
549                                      in long SecondNodeID1,
550                                      in long LastNodeID1,
551                                      in long FirstNodeID2,
552                                      in long SecondNodeID2);
553
554     Sew_Error SewBorderToSide (in long FirstNodeIDOnFreeBorder,
555                                in long SecondNodeIDOnFreeBorder,
556                                in long LastNodeIDOnFreeBorder,
557                                in long FirstNodeIDOnSide,
558                                in long LastNodeIDOnSide,
559                                in boolean CreatePolygons,
560                                in boolean CreatePolyedrs);
561
562     Sew_Error SewSideElements (in long_array IDsOfSide1Elements,
563                                in long_array IDsOfSide2Elements,
564                                in long       NodeID1OfSide1ToMerge,
565                                in long       NodeID1OfSide2ToMerge,
566                                in long       NodeID2OfSide1ToMerge,
567                                in long       NodeID2OfSide2ToMerge);
568
569    /*!
570     * Set new nodes for given element.
571     * If number of nodes is not corresponded to type of
572     * element - returns false
573     */
574     boolean ChangeElemNodes(in long ide, in long_array newIDs);
575
576    /*!
577     * Return data of mesh edition preview which is computed provided 
578     * that the editor was obtained trough SMESH_Mesh::GetMeshEditPreviewer()
579     */
580     MeshPreviewStruct GetPreviewData();
581
582    /*!
583     * If during last operation of MeshEditor some nodes were
584     * created this method returns list of it's IDs, if new nodes
585     * not creared - returns empty list
586     */
587     long_array GetLastCreatedNodes();
588
589    /*!
590     * If during last operation of MeshEditor some elements were
591     * created this method returns list of it's IDs, if new elements
592     * not creared - returns empty list
593     */
594     long_array GetLastCreatedElems();
595
596   };
597 };
598
599 #endif