Salome HOME
NPAL18084: add a new simply sample of GEOM/SMESH. Correct error.
[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 theMirrorType,
422                  in boolean    Copy);
423     ListOfGroups MirrorMakeGroups (in long_array IDsOfElements,
424                                    in AxisStruct Mirror,
425                                    in MirrorType theMirrorType);
426
427     void MirrorObject (in SMESH_IDSource theObject,
428                        in AxisStruct     Mirror,
429                        in MirrorType     theMirrorType,
430                        in boolean        Copy);
431     ListOfGroups MirrorObjectMakeGroups (in SMESH_IDSource theObject,
432                                          in AxisStruct     Mirror,
433                                          in MirrorType     theMirrorType);
434
435     void Translate (in long_array IDsOfElements,
436                     in DirStruct  Vector,
437                     in boolean    Copy);
438     ListOfGroups TranslateMakeGroups (in long_array IDsOfElements,
439                                       in DirStruct  Vector);
440
441     void TranslateObject (in SMESH_IDSource theObject,
442                           in DirStruct      Vector,
443                           in boolean        Copy);
444     ListOfGroups TranslateObjectMakeGroups (in SMESH_IDSource theObject,
445                                             in DirStruct      Vector);
446
447     void Rotate (in long_array IDsOfElements,
448                  in AxisStruct Axis,
449                  in double     AngleInRadians,
450                  in boolean    Copy);
451     ListOfGroups RotateMakeGroups (in long_array IDsOfElements,
452                                    in AxisStruct Axis,
453                                    in double     AngleInRadians);
454
455     void RotateObject (in SMESH_IDSource theObject,
456                        in AxisStruct     Axis,
457                        in double         AngleInRadians,
458                        in boolean        Copy);
459     ListOfGroups RotateObjectMakeGroups (in SMESH_IDSource theObject,
460                                          in AxisStruct     Axis,
461                                          in double         AngleInRadians);
462
463     void FindCoincidentNodes (in  double              Tolerance,
464                               out array_of_long_array GroupsOfNodes);
465
466     void FindCoincidentNodesOnPart (in  SMESH_IDSource      SubMeshOrGroup,
467                                     in  double              Tolerance,
468                                     out array_of_long_array GroupsOfNodes);
469
470     void MergeNodes (in array_of_long_array GroupsOfNodes);
471
472     /*!
473      * \brief Find elements built on the same nodes.
474      * \param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching.
475      * \return List of groups of equal elements.
476      */
477     void FindEqualElements (in  SMESH_IDSource      MeshOrSubMeshOrGroup,
478                             out array_of_long_array GroupsOfElementsID);
479
480     /*!
481      * \brief Merge elements in each given group.
482      * \param GroupsOfElementsID Groups of elements for merging.
483      */
484     void MergeElements(in array_of_long_array GroupsOfElementsID);
485
486     /*!
487      * \brief Merge equal elements in the whole mesh.
488      */
489     void MergeEqualElements();
490     
491     /*!
492      * If the given ID is a valid node ID (nodeID > 0), just move this node, else
493      * move the node closest to the point to point's location and return ID of the node
494      */
495     long MoveClosestNodeToPoint(in double x, in double y, in double z, in long nodeID);
496
497     enum Sew_Error {
498       SEW_OK,
499       SEW_BORDER1_NOT_FOUND,
500       SEW_BORDER2_NOT_FOUND,
501       SEW_BOTH_BORDERS_NOT_FOUND,
502       SEW_BAD_SIDE_NODES,
503       SEW_VOLUMES_TO_SPLIT,
504       // for SewSideElements() only:
505       SEW_DIFF_NB_OF_ELEMENTS,
506       SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
507       SEW_BAD_SIDE1_NODES,
508       SEW_BAD_SIDE2_NODES
509       };
510
511     Sew_Error SewFreeBorders (in long FirstNodeID1,
512                               in long SecondNodeID1,
513                               in long LastNodeID1,
514                               in long FirstNodeID2,
515                               in long SecondNodeID2,
516                               in long LastNodeID2,
517                               in boolean CreatePolygons,
518                               in boolean CreatePolyedrs);
519
520     Sew_Error SewConformFreeBorders (in long FirstNodeID1,
521                                      in long SecondNodeID1,
522                                      in long LastNodeID1,
523                                      in long FirstNodeID2,
524                                      in long SecondNodeID2);
525
526     Sew_Error SewBorderToSide (in long FirstNodeIDOnFreeBorder,
527                                in long SecondNodeIDOnFreeBorder,
528                                in long LastNodeIDOnFreeBorder,
529                                in long FirstNodeIDOnSide,
530                                in long LastNodeIDOnSide,
531                                in boolean CreatePolygons,
532                                in boolean CreatePolyedrs);
533
534     Sew_Error SewSideElements (in long_array IDsOfSide1Elements,
535                                in long_array IDsOfSide2Elements,
536                                in long       NodeID1OfSide1ToMerge,
537                                in long       NodeID1OfSide2ToMerge,
538                                in long       NodeID2OfSide1ToMerge,
539                                in long       NodeID2OfSide2ToMerge);
540
541    /*!
542     * Set new nodes for given element.
543     * If number of nodes is not corresponded to type of
544     * element - returns false
545     */
546     boolean ChangeElemNodes(in long ide, in long_array newIDs);
547
548    /*!
549     * Return data of mesh edition preview which is computed provided 
550     * that the editor was obtained trough SMESH_Mesh::GetMeshEditPreviewer()
551     */
552     MeshPreviewStruct GetPreviewData();
553
554    /*!
555     * If during last operation of MeshEditor some nodes were
556     * created this method returns list of it's IDs, if new nodes
557     * not creared - returns empty list
558     */
559     long_array GetLastCreatedNodes();
560
561    /*!
562     * If during last operation of MeshEditor some elements were
563     * created this method returns list of it's IDs, if new elements
564     * not creared - returns empty list
565     */
566     long_array GetLastCreatedElems();
567
568   };
569 };
570
571 #endif