Salome HOME
a080e19d52c9d2691e6096d50b31f56678f9574f
[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     boolean MoveNode(in long NodeID, in double x, in double y, in double z);
110
111     boolean InverseDiag(in long NodeID1, in long NodeID2);
112
113     boolean DeleteDiag(in long NodeID1, in long NodeID2);
114
115     boolean Reorient(in long_array IDsOfElements);
116
117     boolean ReorientObject(in SMESH_IDSource theObject);
118
119     /*!
120      * \brief Fuse neighbour triangles into quadrangles.
121      * \param theElems     The triangles to be fused.
122      * \param theCriterion Is used to choose a neighbour to fuse with.
123      * \param theMaxAngle  Is a max angle between element normals at which fusion
124      *                     is still performed; theMaxAngle is mesured in radians.
125      * \return TRUE in case of success, FALSE otherwise.
126      */
127     boolean TriToQuad (in long_array       IDsOfElements,
128                        in NumericalFunctor Criterion,
129                        in double           MaxAngle);
130
131     /*!
132      * \brief Fuse neighbour triangles into quadrangles.
133      *
134      * Behaves like the above method, taking list of elements from \a theObject
135      */
136     boolean TriToQuadObject (in SMESH_IDSource   theObject,
137                              in NumericalFunctor Criterion,
138                              in double           MaxAngle);
139
140     /*!
141      * \brief Split quadrangles into triangles.
142      * \param theElems     The faces to be splitted.
143      * \param theCriterion Is used to choose a diagonal for splitting.
144      * \return TRUE in case of success, FALSE otherwise.
145      */
146     boolean QuadToTri (in long_array       IDsOfElements,
147                        in NumericalFunctor Criterion);
148
149     /*!
150      * \brief Split quadrangles into triangles.
151      *
152      * Behaves like the above method, taking list of elements from \a theObject
153      */
154     boolean QuadToTriObject (in SMESH_IDSource   theObject,
155                              in NumericalFunctor Criterion);
156
157     /*!
158      * \brief Split quadrangles into triangles.
159      * \param theElems  The faces to be splitted.
160      * \param the13Diag Is used to choose a diagonal for splitting.
161      * \return TRUE in case of success, FALSE otherwise.
162      */
163     boolean SplitQuad (in long_array IDsOfElements,
164                        in boolean    Diag13);
165
166     /*!
167      * \brief Split quadrangles into triangles.
168      *
169      * Behaves like the above method, taking list of elements from \a theObject
170      */
171     boolean SplitQuadObject (in SMESH_IDSource theObject,
172                              in boolean        Diag13);
173
174     /*!
175      *  Find better splitting of the given quadrangle.
176      *  \param IDOfQuad  ID of the quadrangle to be splitted.
177      *  \param Criterion A criterion to choose a diagonal for splitting.
178      *  \return 1 if 1-3 diagonal is better, 2 if 2-4
179      *          diagonal is better, 0 if error occurs.
180      */
181     long BestSplit (in long             IDOfQuad,
182                     in NumericalFunctor Criterion);
183
184     enum Smooth_Method { LAPLACIAN_SMOOTH, CENTROIDAL_SMOOTH };
185
186     boolean Smooth(in long_array    IDsOfElements,
187                    in long_array    IDsOfFixedNodes,
188                    in long          MaxNbOfIterations,
189                    in double        MaxAspectRatio,
190                    in Smooth_Method Method);
191
192     boolean SmoothObject(in SMESH_IDSource  theObject,
193                          in long_array      IDsOfFixedNodes,
194                          in long            MaxNbOfIterations,
195                          in double          MaxAspectRatio,
196                          in Smooth_Method   Method);
197
198     boolean SmoothParametric(in long_array    IDsOfElements,
199                              in long_array    IDsOfFixedNodes,
200                              in long          MaxNbOfIterations,
201                              in double        MaxAspectRatio,
202                              in Smooth_Method Method);
203
204     boolean SmoothParametricObject(in SMESH_IDSource  theObject,
205                                    in long_array      IDsOfFixedNodes,
206                                    in long            MaxNbOfIterations,
207                                    in double          MaxAspectRatio,
208                                    in Smooth_Method   Method);
209
210     void ConvertToQuadratic(in boolean theForce3d);
211
212     boolean ConvertFromQuadratic();
213
214     void RenumberNodes();
215
216     void RenumberElements();
217
218     /*!
219      * \brief Genarate dim+1 elements by rotation of given elements around axis
220      * \param IDsOfElements - elements to ratate
221      * \param Axix - rotation axis
222      * \param AngleInRadians - rotation angle
223      * \param NbOfSteps - number of elements to generate from one element
224      */
225     void RotationSweep(in long_array       IDsOfElements,
226                        in AxisStruct       Axix,
227                        in double           AngleInRadians,
228                        in long             NbOfSteps,
229                        in double           Tolerance);
230     /*!
231      * \brief Same as previous but additionally create groups of elements
232      *  generated from elements belonging to preexisting groups
233      */
234     ListOfGroups RotationSweepMakeGroups(in long_array       IDsOfElements,
235                                          in AxisStruct       Axix,
236                                          in double           AngleInRadians,
237                                          in long             NbOfSteps,
238                                          in double           Tolerance);
239     /*!
240      * \brief Genarate dim+1 elements by rotation of the object around axis
241      * \param theObject - object containing elements to ratate
242      * \param Axix - rotation axis
243      * \param AngleInRadians - rotation angle
244      * \param NbOfSteps - number of elements to generate from one element
245      */
246     void RotationSweepObject(in SMESH_IDSource  theObject,
247                              in AxisStruct      Axix,
248                              in double          AngleInRadians,
249                              in long            NbOfSteps,
250                              in double          Tolerance);
251     /*!
252      * \brief Same as previous but additionally create groups of elements
253      *  generated from elements belonging to preexisting groups
254      */
255     ListOfGroups RotationSweepObjectMakeGroups(in SMESH_IDSource  theObject,
256                                                in AxisStruct      Axix,
257                                                in double          AngleInRadians,
258                                                in long            NbOfSteps,
259                                                in double          Tolerance);
260     /*!
261      * \brief Genarate dim+1 elements by extrusion of elements along vector
262      * \param IDsOfElements - elements to sweep
263      * \param StepVector - vector giving direction and distance of an extrusion step
264      * \param NbOfSteps - number of elements to generate from one element
265      */
266     void ExtrusionSweep(in long_array      IDsOfElements,
267                         in DirStruct       StepVector,
268                         in long            NbOfSteps);
269     /*!
270      * \brief Same as previous but additionally create groups of elements
271      *  generated from elements belonging to preexisting groups
272      */
273     ListOfGroups ExtrusionSweepMakeGroups(in long_array      IDsOfElements,
274                                           in DirStruct       StepVector,
275                                           in long            NbOfSteps);
276    /*!
277     * Generate new elements by extrusion of theElements 
278     * by StepVector by NbOfSteps
279     * param ExtrFlags set flags for performing extrusion
280     * param SewTolerance - uses for comparing locations of nodes if flag
281     *   EXTRUSION_FLAG_SEW is set
282     */
283     void AdvancedExtrusion(in long_array      IDsOfElements,
284                            in DirStruct       StepVector,
285                            in long            NbOfSteps,
286                            in long            ExtrFlags,
287                            in double          SewTolerance);
288     /*!
289      * \brief Same as previous but additionally create groups of elements
290      *  generated from elements belonging to preexisting groups
291      */
292     ListOfGroups AdvancedExtrusionMakeGroups(in long_array      IDsOfElements,
293                                              in DirStruct       StepVector,
294                                              in long            NbOfSteps,
295                                              in long            ExtrFlags,
296                                              in double          SewTolerance);
297
298     void ExtrusionSweepObject(in SMESH_IDSource  theObject,
299                               in DirStruct       StepVector,
300                               in long            NbOfSteps);
301     ListOfGroups ExtrusionSweepObjectMakeGroups(in SMESH_IDSource  theObject,
302                                                 in DirStruct       StepVector,
303                                                 in long            NbOfSteps);
304
305     void ExtrusionSweepObject1D(in SMESH_IDSource theObject,
306                                 in DirStruct      StepVector,
307                                 in long           NbOfSteps);
308     ListOfGroups ExtrusionSweepObject1DMakeGroups(in SMESH_IDSource theObject,
309                                                   in DirStruct      StepVector,
310                                                   in long           NbOfSteps);
311
312     void ExtrusionSweepObject2D(in SMESH_IDSource theObject,
313                                 in DirStruct      StepVector,
314                                 in long           NbOfSteps);
315     ListOfGroups ExtrusionSweepObject2DMakeGroups(in SMESH_IDSource theObject,
316                                                   in DirStruct      StepVector,
317                                                   in long           NbOfSteps);
318
319     enum Extrusion_Error {
320       EXTR_OK,
321       EXTR_NO_ELEMENTS,
322       EXTR_PATH_NOT_EDGE,
323       EXTR_BAD_PATH_SHAPE,
324       EXTR_BAD_STARTING_NODE,
325       EXTR_BAD_ANGLES_NUMBER,
326       EXTR_CANT_GET_TANGENT
327       };
328
329     Extrusion_Error ExtrusionAlongPath(in long_array        IDsOfElements,
330                                        in SMESH_Mesh        PathMesh,
331                                        in GEOM::GEOM_Object PathShape,
332                                        in long              NodeStart,
333                                        in boolean           HasAngles,
334                                        in double_array      Angles,
335                                        in boolean           HasRefPoint,
336                                        in PointStruct       RefPoint);
337     ListOfGroups ExtrusionAlongPathMakeGroups(in long_array        IDsOfElements,
338                                               in SMESH_Mesh        PathMesh,
339                                               in GEOM::GEOM_Object PathShape,
340                                               in long              NodeStart,
341                                               in boolean           HasAngles,
342                                               in double_array      Angles,
343                                               in boolean           HasRefPoint,
344                                               in PointStruct       RefPoint,
345                                               out Extrusion_Error  Error);
346
347     Extrusion_Error ExtrusionAlongPathObject(in SMESH_IDSource    theObject,
348                                              in SMESH_Mesh        PathMesh,
349                                              in GEOM::GEOM_Object PathShape,
350                                              in long              NodeStart,
351                                              in boolean           HasAngles,
352                                              in double_array      Angles,
353                                              in boolean           HasRefPoint,
354                                              in PointStruct       RefPoint);
355     ListOfGroups ExtrusionAlongPathObjectMakeGroups(in SMESH_IDSource    theObject,
356                                                     in SMESH_Mesh        PathMesh,
357                                                     in GEOM::GEOM_Object PathShape,
358                                                     in long              NodeStart,
359                                                     in boolean           HasAngles,
360                                                     in double_array      Angles,
361                                                     in boolean           HasRefPoint,
362                                                     in PointStruct       RefPoint,
363                                                     out Extrusion_Error  Error);
364
365    /*!
366     * Compute rotation angles for ExtrusionAlongPath as linear variation
367     * of given angles along path steps
368     * param PathMesh mesh containing a 1D sub-mesh on the edge, along 
369     *                which proceeds the extrusion
370     * param PathShape is shape(edge); as the mesh can be complex, the edge 
371     *                 is used to define the sub-mesh for the path
372     */
373     double_array LinearAnglesVariation(in SMESH_Mesh        PathMesh,
374                                        in GEOM::GEOM_Object PathShape,
375                                        in double_array      Angles);
376
377     enum MirrorType { POINT, AXIS, PLANE };
378
379     void Mirror (in long_array IDsOfElements,
380                  in AxisStruct Mirror,
381                  in MirrorType theMirrorType,
382                  in boolean    Copy);
383     ListOfGroups MirrorMakeGroups (in long_array IDsOfElements,
384                                    in AxisStruct Mirror,
385                                    in MirrorType theMirrorType);
386
387     void MirrorObject (in SMESH_IDSource theObject,
388                        in AxisStruct     Mirror,
389                        in MirrorType     theMirrorType,
390                        in boolean        Copy);
391     ListOfGroups MirrorObjectMakeGroups (in SMESH_IDSource theObject,
392                                          in AxisStruct     Mirror,
393                                          in MirrorType     theMirrorType);
394
395     void Translate (in long_array IDsOfElements,
396                     in DirStruct  Vector,
397                     in boolean    Copy);
398     ListOfGroups TranslateMakeGroups (in long_array IDsOfElements,
399                                       in DirStruct  Vector);
400
401     void TranslateObject (in SMESH_IDSource theObject,
402                           in DirStruct      Vector,
403                           in boolean        Copy);
404     ListOfGroups TranslateObjectMakeGroups (in SMESH_IDSource theObject,
405                                             in DirStruct      Vector);
406
407     void Rotate (in long_array IDsOfElements,
408                  in AxisStruct Axis,
409                  in double     AngleInRadians,
410                  in boolean    Copy);
411     ListOfGroups RotateMakeGroups (in long_array IDsOfElements,
412                                    in AxisStruct Axis,
413                                    in double     AngleInRadians);
414
415     void RotateObject (in SMESH_IDSource theObject,
416                        in AxisStruct     Axis,
417                        in double         AngleInRadians,
418                        in boolean        Copy);
419     ListOfGroups RotateObjectMakeGroups (in SMESH_IDSource theObject,
420                                          in AxisStruct     Axis,
421                                          in double         AngleInRadians);
422
423     void FindCoincidentNodes (in  double              Tolerance,
424                               out array_of_long_array GroupsOfNodes);
425
426     void FindCoincidentNodesOnPart (in  SMESH_IDSource      SubMeshOrGroup,
427                                     in  double              Tolerance,
428                                     out array_of_long_array GroupsOfNodes);
429
430     void MergeNodes (in array_of_long_array GroupsOfNodes);
431
432     /*!
433      * \brief Find elements built on the same nodes.
434      * \param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching.
435      * \return List of groups of equal elements.
436      */
437     void FindEqualElements (in  SMESH_IDSource      MeshOrSubMeshOrGroup,
438                             out array_of_long_array GroupsOfElementsID);
439
440     /*!
441      * \brief Merge elements in each given group.
442      * \param GroupsOfElementsID Groups of elements for merging.
443      */
444     void MergeElements(in array_of_long_array GroupsOfElementsID);
445
446     /*!
447      * \brief Merge equal elements in the whole mesh.
448      */
449     void MergeEqualElements();
450     
451     /*!
452      * If the given ID is a valid node ID (nodeID > 0), just move this node, else
453      * move the node closest to the point to point's location and return ID of the node
454      */
455     long MoveClosestNodeToPoint(in double x, in double y, in double z, in long nodeID);
456
457     enum Sew_Error {
458       SEW_OK,
459       SEW_BORDER1_NOT_FOUND,
460       SEW_BORDER2_NOT_FOUND,
461       SEW_BOTH_BORDERS_NOT_FOUND,
462       SEW_BAD_SIDE_NODES,
463       SEW_VOLUMES_TO_SPLIT,
464       // for SewSideElements() only:
465       SEW_DIFF_NB_OF_ELEMENTS,
466       SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
467       SEW_BAD_SIDE1_NODES,
468       SEW_BAD_SIDE2_NODES
469       };
470
471     Sew_Error SewFreeBorders (in long FirstNodeID1,
472                               in long SecondNodeID1,
473                               in long LastNodeID1,
474                               in long FirstNodeID2,
475                               in long SecondNodeID2,
476                               in long LastNodeID2,
477                               in boolean CreatePolygons,
478                               in boolean CreatePolyedrs);
479
480     Sew_Error SewConformFreeBorders (in long FirstNodeID1,
481                                      in long SecondNodeID1,
482                                      in long LastNodeID1,
483                                      in long FirstNodeID2,
484                                      in long SecondNodeID2);
485
486     Sew_Error SewBorderToSide (in long FirstNodeIDOnFreeBorder,
487                                in long SecondNodeIDOnFreeBorder,
488                                in long LastNodeIDOnFreeBorder,
489                                in long FirstNodeIDOnSide,
490                                in long LastNodeIDOnSide,
491                                in boolean CreatePolygons,
492                                in boolean CreatePolyedrs);
493
494     Sew_Error SewSideElements (in long_array IDsOfSide1Elements,
495                                in long_array IDsOfSide2Elements,
496                                in long       NodeID1OfSide1ToMerge,
497                                in long       NodeID1OfSide2ToMerge,
498                                in long       NodeID2OfSide1ToMerge,
499                                in long       NodeID2OfSide2ToMerge);
500
501    /*!
502     * Set new nodes for given element.
503     * If number of nodes is not corresponded to type of
504     * element - returns false
505     */
506     boolean ChangeElemNodes(in long ide, in long_array newIDs);
507
508    /*!
509     * Return data of mesh edition preview which is computed provided 
510     * that the editor was obtained trough SMESH_Mesh::GetMeshEditPreviewer()
511     */
512     MeshPreviewStruct GetPreviewData();
513
514    /*!
515     * If during last operation of MeshEditor some nodes were
516     * created this method returns list of it's IDs, if new nodes
517     * not creared - returns empty list
518     */
519     long_array GetLastCreatedNodes();
520
521    /*!
522     * If during last operation of MeshEditor some elements were
523     * created this method returns list of it's IDs, if new elements
524     * not creared - returns empty list
525     */
526     long_array GetLastCreatedElems();
527
528   };
529 };
530
531 #endif