Salome HOME
Fix compilation problems under windows.
[modules/smesh.git] / src / SMESH_I / SMESH_MeshEditor_i.hxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
24 //  File   : SMESH_MeshEditor_i.hxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //
28 #ifndef _SMESH_MESHEDITOR_I_HXX_
29 #define _SMESH_MESHEDIOTR_I_HXX_
30
31 #include "SMESH.hxx"
32
33 #include <SALOMEconfig.h>
34 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
35
36 #include "SMESH_Mesh.hxx"
37 #include "SMESH_PythonDump.hxx"
38 #include "SMESH_MeshEditor.hxx"
39 #include <list>
40 #include <string>
41
42 class SMESH_Mesh_i;
43
44 namespace MeshEditor_I {
45   struct TPreviewMesh;
46   struct ExtrusionParams;
47 }
48
49 class SMESH_I_EXPORT SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
50 {
51 public:
52   SMESH_MeshEditor_i(SMESH_Mesh_i * theMesh, bool isPreview);
53
54   virtual ~ SMESH_MeshEditor_i();
55   /*!
56    * \brief Return edited mesh ID
57    * \retval int - mesh ID
58    */
59   int GetMeshId() const { return myMesh->GetId(); }
60
61   SMESH::SMESH_Mesh_ptr GetMesh();
62
63   // --- CORBA
64
65   /*!
66    * Return data of mesh edition preview
67    */
68   SMESH::MeshPreviewStruct* GetPreviewData();
69   /*!
70    * If during last operation of MeshEditor some nodes were
71    * created this method returns list of their IDs, if new nodes
72    * not created - returns an empty list
73    */
74   SMESH::smIdType_array* GetLastCreatedNodes();
75   /*!
76    * If during last operation of MeshEditor some elements were
77    * created this method returns list of their IDs, if new elements
78    * not created - returns an empty list
79    */
80   SMESH::smIdType_array* GetLastCreatedElems();
81   /*!
82    * \brief Clears sequences of last created elements and nodes 
83    */
84   void ClearLastCreated();
85   /*!
86    * \brief Returns description of an error/warning occurred during the last operation
87    */
88   SMESH::ComputeError* GetLastError();
89
90   /*!
91    * \brief Wrap a sequence of ids in a SMESH_IDSource
92    */
93   SMESH::SMESH_IDSource_ptr MakeIDSource(const SMESH::smIdType_array& IDsOfElements,
94                                          SMESH::ElementType           type);
95   static bool               IsTemporaryIDSource( SMESH::SMESH_IDSource_ptr& idSource );
96   static SMESH::smIdType*       GetTemporaryIDs( SMESH::SMESH_IDSource_ptr& idSource, SMESH::smIdType& nbIds );
97
98   /*!
99    * \brief Generates the unique group name
100    */
101   std::string GenerateGroupName(const std::string& thePrefix);
102
103   CORBA::Boolean RemoveElements(const SMESH::smIdType_array & IDsOfElements);
104   CORBA::Boolean RemoveNodes   (const SMESH::smIdType_array & IDsOfNodes);
105   SMESH::smIdType    RemoveOrphanNodes();
106
107   /*!
108    * Methods for creation new elements.
109    * Returns ID of created element or 0 if element not created
110    */
111   SMESH::smIdType AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z);
112   SMESH::smIdType Add0DElement(SMESH::smIdType IDOfNode, CORBA::Boolean DuplicateElements);
113   SMESH::smIdType AddBall(SMESH::smIdType IDOfNodem, CORBA::Double diameter);
114   SMESH::smIdType AddEdge(const SMESH::smIdType_array & IDsOfNodes);
115   SMESH::smIdType AddFace(const SMESH::smIdType_array & IDsOfNodes);
116   SMESH::smIdType AddPolygonalFace(const SMESH::smIdType_array & IDsOfNodes);
117   SMESH::smIdType AddQuadPolygonalFace(const SMESH::smIdType_array & IDsOfNodes);
118   SMESH::smIdType AddVolume(const SMESH::smIdType_array & IDsOfNodes);
119   SMESH::smIdType AddPolyhedralVolume(const SMESH::smIdType_array & IDsOfNodes,
120                                   const SMESH::long_array & Quantities);
121   SMESH::smIdType AddPolyhedralVolumeByFaces(const SMESH::smIdType_array & IdsOfFaces);
122
123   /*!
124    * \brief Create 0D elements on all nodes of the given object except those 
125    *        nodes on which a 0D element already exists.
126    *  \param theObject object on whose nodes 0D elements will be created.
127    *  \param theGroupName optional name of a group to add 0D elements created
128    *         and/or found on nodes of \a theObject.
129    *  \param theDuplicateElements to add one more 0D element to a node or not
130    *  \return an object (a new group or a temporary SMESH_IDSource) holding
131    *          ids of new and/or found 0D elements.
132    */
133   SMESH::SMESH_IDSource_ptr Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObject,
134                                                        const char*               theGroupName,
135                                                        CORBA::Boolean            theDuplicateElements);
136
137   /*!
138    * \brief Bind a node to a vertex
139    * \param NodeID - node ID
140    * \param VertexID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
141    */
142   void SetNodeOnVertex(SMESH::smIdType NodeID, CORBA::Long VertexID);
143   /*!
144    * \brief Store node position on an edge
145    * \param NodeID - node ID
146    * \param EdgeID - edge ID available through GEOM_Object.GetSubShapeIndices()[0]
147    * \param paramOnEdge - parameter on edge where the node is located
148    */
149   void SetNodeOnEdge(SMESH::smIdType NodeID, CORBA::Long EdgeID,
150                      CORBA::Double paramOnEdge);
151   /*!
152    * \brief Store node position on a face
153    * \param NodeID - node ID
154    * \param FaceID - face ID available through GEOM_Object.GetSubShapeIndices()[0]
155    * \param u - U parameter on face where the node is located
156    * \param v - V parameter on face where the node is located
157    */
158   void SetNodeOnFace(SMESH::smIdType NodeID, CORBA::Long FaceID,
159                      CORBA::Double u, CORBA::Double v);
160   /*!
161    * \brief Bind a node to a solid
162    * \param NodeID - node ID
163    * \param SolidID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
164    */
165   void SetNodeInVolume(SMESH::smIdType NodeID, CORBA::Long SolidID);
166   /*!
167    * \brief Bind an element to a shape
168    * \param ElementID - element ID
169    * \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
170    */
171   void SetMeshElementOnShape(SMESH::smIdType ElementID, CORBA::Long ShapeID);
172
173
174   CORBA::Boolean MoveNode(SMESH::smIdType NodeID,
175                           CORBA::Double x, CORBA::Double y, CORBA::Double z);
176
177   CORBA::Boolean InverseDiag(SMESH::smIdType NodeID1, SMESH::smIdType NodeID2);
178   CORBA::Boolean DeleteDiag(SMESH::smIdType NodeID1, SMESH::smIdType NodeID2);
179   CORBA::Boolean Reorient(const SMESH::smIdType_array & IDsOfElements);
180   CORBA::Boolean ReorientObject(SMESH::SMESH_IDSource_ptr theObject);
181
182   /*!
183    * \brief Reorient faces contained in \a the2Dgroup.
184    * \param the2Dgroup - the mesh or its part to reorient
185    * \param theDirection - desired direction of normal of \a theFace
186    * \param theFace - ID of face whose orientation is checked.
187    *        It can be < 1 then \a thePoint is used to find a face.
188    * \param thePoint - is used to find a face if \a theFace < 1.
189    * \return number of reoriented elements.
190    */
191   CORBA::Long Reorient2D(SMESH::SMESH_IDSource_ptr the2Dgroup,
192                          const SMESH::DirStruct&   theDirection,
193                          CORBA::Long               theFace,
194                          const SMESH::PointStruct& thePoint);
195   /*!
196    * \brief Reorient faces basing on orientation of adjacent volumes.
197    * \param faces - a list of objects containing face to reorient
198    * \param volumes - an object containing volumes.
199    * \param outsideNormal - to orient faces to have their normal
200    *        pointing either \a outside or \a inside the adjacent volumes.
201    * \return number of reoriented faces.
202    */
203   CORBA::Long Reorient2DBy3D(const SMESH::ListOfIDSources & faces,
204                              SMESH::SMESH_IDSource_ptr      volumes,
205                              CORBA::Boolean                 outsideNormal);
206
207   // Split/Join
208   CORBA::Boolean TriToQuad       (const SMESH::smIdType_array & IDsOfElements,
209                                   SMESH::NumericalFunctor_ptr   Criterion,
210                                   CORBA::Double                 MaxAngle);
211   CORBA::Boolean TriToQuadObject (SMESH::SMESH_IDSource_ptr     theObject,
212                                   SMESH::NumericalFunctor_ptr   Criterion,
213                                   CORBA::Double                 MaxAngle);
214   CORBA::Boolean QuadToTri       (const SMESH::smIdType_array & IDsOfElements,
215                                   SMESH::NumericalFunctor_ptr   Criterion);
216   CORBA::Boolean QuadToTriObject (SMESH::SMESH_IDSource_ptr     theObject,
217                                   SMESH::NumericalFunctor_ptr   Criterion);
218   void           QuadTo4Tri      (SMESH::SMESH_IDSource_ptr     theObject);
219   CORBA::Boolean SplitQuad       (const SMESH::smIdType_array & IDsOfElements,
220                                   CORBA::Boolean                Diag13);
221   CORBA::Boolean SplitQuadObject (SMESH::SMESH_IDSource_ptr     theObject,
222                                   CORBA::Boolean                Diag13);
223   CORBA::Long    BestSplit       (CORBA::Long                   IDOfQuad,
224                                   SMESH::NumericalFunctor_ptr   Criterion);
225   void           SplitVolumesIntoTetra(SMESH::SMESH_IDSource_ptr elems,
226                                        CORBA::Short             methodFlags);
227   void           SplitHexahedraIntoPrisms(SMESH::SMESH_IDSource_ptr  elems,
228                                           const SMESH::PointStruct & startHexPoint,
229                                           const SMESH::DirStruct&    facetToSplitNormal,
230                                           CORBA::Short               methodFlags,
231                                           CORBA::Boolean             allDomains);
232   void           SplitBiQuadraticIntoLinear(const SMESH::ListOfIDSources& elems);
233
234   CORBA::Boolean Smooth(const SMESH::smIdType_array &          IDsOfElements,
235                         const SMESH::smIdType_array &          IDsOfFixedNodes,
236                         CORBA::Short                           MaxNbOfIterations,
237                         CORBA::Double                          MaxAspectRatio,
238                         SMESH::SMESH_MeshEditor::Smooth_Method Method);
239   CORBA::Boolean SmoothObject(SMESH::SMESH_IDSource_ptr              theObject,
240                               const SMESH::smIdType_array &          IDsOfFixedNodes,
241                               CORBA::Short                           MaxNbOfIterations,
242                               CORBA::Double                          MaxAspectRatio,
243                               SMESH::SMESH_MeshEditor::Smooth_Method Method);
244   CORBA::Boolean SmoothParametric(const SMESH::smIdType_array &          IDsOfElements,
245                                   const SMESH::smIdType_array &          IDsOfFixedNodes,
246                                   CORBA::Short                           MaxNbOfIterations,
247                                   CORBA::Double                          MaxAspectRatio,
248                                   SMESH::SMESH_MeshEditor::Smooth_Method Method) ;
249   CORBA::Boolean SmoothParametricObject(SMESH::SMESH_IDSource_ptr              theObject,
250                                         const SMESH::smIdType_array &          IDsOfFixedNodes,
251                                         CORBA::Short                           MaxNbOfIterations,
252                                         CORBA::Double                          MaxAspectRatio,
253                                         SMESH::SMESH_MeshEditor::Smooth_Method Method);
254   CORBA::Boolean smooth(const SMESH::smIdType_array &          IDsOfElements,
255                         const SMESH::smIdType_array &          IDsOfFixedNodes,
256                         CORBA::Short                           MaxNbOfIterations,
257                         CORBA::Double                          MaxAspectRatio,
258                         SMESH::SMESH_MeshEditor::Smooth_Method Method,
259                         bool                                   IsParametric);
260   CORBA::Boolean smoothObject(SMESH::SMESH_IDSource_ptr              theObject,
261                               const SMESH::smIdType_array &          IDsOfFixedNodes,
262                               CORBA::Short                           MaxNbOfIterations,
263                               CORBA::Double                          MaxAspectRatio,
264                               SMESH::SMESH_MeshEditor::Smooth_Method Method,
265                               bool                                   IsParametric);
266
267   CORBA::Boolean ConvertFromQuadratic();
268   void           ConvertFromQuadraticObject(SMESH::SMESH_IDSource_ptr theObject);
269   void           ConvertToQuadratic(CORBA::Boolean Force3d);
270   void           ConvertToQuadraticObject(CORBA::Boolean            theForce3d,
271                                           SMESH::SMESH_IDSource_ptr theObject);
272   void           ConvertToBiQuadratic(CORBA::Boolean            theForce3d,
273                                       SMESH::SMESH_IDSource_ptr theObject);
274
275   void RenumberNodes();
276   void RenumberElements();
277
278   SMESH::ListOfGroups* RotationSweepObjects(const SMESH::ListOfIDSources & Nodes,
279                                             const SMESH::ListOfIDSources & Edges,
280                                             const SMESH::ListOfIDSources & Faces,
281                                             const SMESH::AxisStruct &      Axis,
282                                             CORBA::Double                  AngleInRadians,
283                                             CORBA::Long                    NbOfSteps,
284                                             CORBA::Double                  Tolerance,
285                                             CORBA::Boolean                 ToMakeGroups);
286
287   SMESH::ListOfGroups* ExtrusionSweepObjects(const SMESH::ListOfIDSources & Nodes,
288                                              const SMESH::ListOfIDSources & Edges,
289                                              const SMESH::ListOfIDSources & Faces,
290                                              const SMESH::DirStruct &       StepVector,
291                                              CORBA::Long                    NbOfSteps,
292                                              CORBA::Boolean                 ToMakeGroups,
293                                              const SMESH::double_array &    ScaleFactors,
294                                              CORBA::Boolean                 ScalesVariation,
295                                              const SMESH::double_array &    BasePoint,
296                                              const SMESH::double_array &    Angles,
297                                              CORBA::Boolean                 AnglesVariation);
298
299   SMESH::ListOfGroups* ExtrusionByNormal(const SMESH::ListOfIDSources& objects,
300                                          CORBA::Double                 stepSize,
301                                          CORBA::Long                   nbOfSteps,
302                                          CORBA::Boolean                byAverageNormal,
303                                          CORBA::Boolean                useInputElemsOnly,
304                                          CORBA::Boolean                makeGroups,
305                                          CORBA::Short                  dim);
306   SMESH::ListOfGroups*  AdvancedExtrusion(const SMESH::smIdType_array & theIDsOfElements,
307                                           const SMESH::DirStruct &      theStepVector,
308                                           CORBA::Long                   theNbOfSteps,
309                                           CORBA::Long                   theExtrFlags,
310                                           CORBA::Double                 theSewTolerance,
311                                           CORBA::Boolean                theMakeGroups);
312
313   SMESH::ListOfGroups*
314     ExtrusionAlongPathObjects(const SMESH::ListOfIDSources & Nodes,
315                               const SMESH::ListOfIDSources & Edges,
316                               const SMESH::ListOfIDSources & Faces,
317                               SMESH::SMESH_IDSource_ptr      PathMesh,
318                               GEOM::GEOM_Object_ptr          PathShape,
319                               SMESH::smIdType                NodeStart,
320                               CORBA::Boolean                 HasAngles,
321                               const SMESH::double_array &    Angles,
322                               CORBA::Boolean                 AnglesVariation,
323                               CORBA::Boolean                 HasRefPoint,
324                               const SMESH::PointStruct &     RefPoint,
325                               bool                           MakeGroups,
326                               const SMESH::double_array &    ScaleFactors,
327                               CORBA::Boolean                 ScalesVariation,
328                               SMESH::SMESH_MeshEditor::Extrusion_Error& Error);
329
330   SMESH::double_array* LinearAnglesVariation(SMESH::SMESH_Mesh_ptr       PathMesh,
331                                                GEOM::GEOM_Object_ptr       PathShape,
332                                                const SMESH::double_array & Angles);
333
334   void Mirror(const SMESH::smIdType_array &       IDsOfElements,
335               const SMESH::AxisStruct &           Axis,
336               SMESH::SMESH_MeshEditor::MirrorType MirrorType,
337               CORBA::Boolean                      Copy);
338   void MirrorObject(SMESH::SMESH_IDSource_ptr           theObject,
339                     const SMESH::AxisStruct &           Axis,
340                     SMESH::SMESH_MeshEditor::MirrorType MirrorType,
341                     CORBA::Boolean                      Copy);
342   void Translate(const SMESH::smIdType_array & IDsOfElements,
343                  const SMESH::DirStruct &      Vector,
344                  CORBA::Boolean                Copy);
345   void TranslateObject(SMESH::SMESH_IDSource_ptr  theObject,
346                        const SMESH::DirStruct &   Vector,
347                        CORBA::Boolean             Copy);
348   void Rotate(const SMESH::smIdType_array & IDsOfElements,
349               const SMESH::AxisStruct &     Axis,
350               CORBA::Double                 Angle,
351               CORBA::Boolean                Copy);
352   void RotateObject(SMESH::SMESH_IDSource_ptr  theObject,
353                     const SMESH::AxisStruct &  Axis,
354                     CORBA::Double              Angle,
355                     CORBA::Boolean             Copy);
356
357   SMESH::ListOfGroups* MirrorMakeGroups(const SMESH::smIdType_array&        IDsOfElements,
358                                         const SMESH::AxisStruct&            Mirror,
359                                         SMESH::SMESH_MeshEditor::MirrorType MirrorType);
360   SMESH::ListOfGroups* MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr           Object,
361                                               const SMESH::AxisStruct&            Mirror,
362                                               SMESH::SMESH_MeshEditor::MirrorType MirrorType);
363   SMESH::ListOfGroups* TranslateMakeGroups(const SMESH::smIdType_array& IDsOfElements,
364                                            const SMESH::DirStruct&      Vector);
365   SMESH::ListOfGroups* TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
366                                                  const SMESH::DirStruct&   Vector);
367   SMESH::ListOfGroups* RotateMakeGroups(const SMESH::smIdType_array& IDsOfElements,
368                                         const SMESH::AxisStruct&     Axis,
369                                         CORBA::Double                AngleInRadians);
370   SMESH::ListOfGroups* RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
371                                               const SMESH::AxisStruct&  Axis,
372                                               CORBA::Double             AngleInRadians);
373
374   SMESH::SMESH_Mesh_ptr MirrorMakeMesh(const SMESH::smIdType_array&        IDsOfElements,
375                                        const SMESH::AxisStruct&            Mirror,
376                                        SMESH::SMESH_MeshEditor::MirrorType MirrorType,
377                                        CORBA::Boolean                      CopyGroups,
378                                        const char*                         MeshName);
379   SMESH::SMESH_Mesh_ptr MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr           Object,
380                                              const SMESH::AxisStruct&            Mirror,
381                                              SMESH::SMESH_MeshEditor::MirrorType MirrorType,
382                                              CORBA::Boolean                      CopyGroups,
383                                              const char*                         MeshName);
384   SMESH::SMESH_Mesh_ptr TranslateMakeMesh(const SMESH::smIdType_array& IDsOfElements,
385                                           const SMESH::DirStruct&      Vector,
386                                           CORBA::Boolean               CopyGroups,
387                                           const char*                  MeshName);
388   SMESH::SMESH_Mesh_ptr TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr Object,
389                                                 const SMESH::DirStruct&   Vector,
390                                                 CORBA::Boolean            CopyGroups,
391                                                 const char*               MeshName);
392   SMESH::SMESH_Mesh_ptr RotateMakeMesh(const SMESH::smIdType_array& IDsOfElements,
393                                        const SMESH::AxisStruct&     Axis,
394                                        CORBA::Double                AngleInRadians,
395                                        CORBA::Boolean               CopyGroups,
396                                        const char*                  MeshName);
397   SMESH::SMESH_Mesh_ptr RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr Object,
398                                              const SMESH::AxisStruct&  Axis,
399                                              CORBA::Double             AngleInRadians,
400                                              CORBA::Boolean            CopyGroups,
401                                              const char*               MeshName);
402
403   void Scale(SMESH::SMESH_IDSource_ptr  theObject,
404              const SMESH::PointStruct&  thePoint,
405              const SMESH::double_array& theScaleFact,
406              CORBA::Boolean             theCopy);
407
408   SMESH::ListOfGroups* ScaleMakeGroups(SMESH::SMESH_IDSource_ptr  theObject,
409                                        const SMESH::PointStruct&  thePoint,
410                                        const SMESH::double_array& theScaleFact);
411
412   SMESH::SMESH_Mesh_ptr ScaleMakeMesh(SMESH::SMESH_IDSource_ptr  Object,
413                                       const SMESH::PointStruct&  Point,
414                                       const SMESH::double_array& theScaleFact,
415                                       CORBA::Boolean             CopyGroups,
416                                       const char*                MeshName);
417
418   SMESH::SMESH_Mesh_ptr Offset( SMESH::SMESH_IDSource_ptr theObject,
419                                 CORBA::Double             Value,
420                                 CORBA::Boolean            CopyGroups,
421                                 CORBA::Boolean            CopyElements,
422                                 const char*               MeshName,
423                                 SMESH::ListOfGroups_out   Groups);
424
425   void FindCoincidentNodes (CORBA::Double                  Tolerance,
426                             SMESH::array_of_long_array_out GroupsOfNodes,
427                             CORBA::Boolean                 SeparateCornersAndMedium);
428   void FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr      Object,
429                                  CORBA::Double                  Tolerance,
430                                  SMESH::array_of_long_array_out GroupsOfNodes,
431                                  CORBA::Boolean                 SeparateCornersAndMedium);
432   void FindCoincidentNodesOnPartBut(const SMESH::ListOfIDSources&  Objects,
433                                     CORBA::Double                  Tolerance,
434                                     SMESH::array_of_long_array_out GroupsOfNodes,
435                                     const SMESH::ListOfIDSources&  ExceptSubMeshOrGroups,
436                                     CORBA::Boolean                 SeparateCornersAndMedium);
437   void MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes,
438                    const SMESH::ListOfIDSources&     NodesToKeep,
439                    CORBA::Boolean                    AvoidMakingHoles );
440   void FindEqualElements(const SMESH::ListOfIDSources&  Objects,
441                          const SMESH::ListOfIDSources&  ExceptSubMeshOrGroups,
442                          SMESH::array_of_long_array_out GroupsOfElementsID);
443   void MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID,
444                      const SMESH::ListOfIDSources&     ElementsToKeep);
445   void MergeEqualElements();
446   SMESH::smIdType MoveClosestNodeToPoint(CORBA::Double   x,
447                                          CORBA::Double   y,
448                                          CORBA::Double   z,
449                                          SMESH::smIdType nodeID);
450   /*!
451    * \brief Return ID of node closest to a given point
452    */
453   SMESH::smIdType FindNodeClosestTo(CORBA::Double x,
454                                 CORBA::Double y,
455                                 CORBA::Double z);
456   /*!
457    * Return elements of given type where the given point is IN or ON.
458    * 'ALL' type means elements of any type excluding nodes
459    */
460   SMESH::smIdType_array* FindElementsByPoint(CORBA::Double      x,
461                                          CORBA::Double      y,
462                                          CORBA::Double      z,
463                                          SMESH::ElementType type);
464   /*!
465    * Searching among the given elements, return elements of given type
466    * where the given point is IN or ON.
467    * 'ALL' type means elements of any type excluding nodes
468    */
469   SMESH::smIdType_array* FindAmongElementsByPoint(SMESH::SMESH_IDSource_ptr elements,
470                                               CORBA::Double             x,
471                                               CORBA::Double             y,
472                                               CORBA::Double             z,
473                                               SMESH::ElementType        type);
474
475   /*!
476    * Project a point to a mesh object.
477    * Return ID of an element of given type where the given point is projected
478    * and coordinates of the projection point.
479    * In the case if nothing found, return -1 and []
480    */
481   SMESH::smIdType ProjectPoint(CORBA::Double             x,
482                            CORBA::Double             y,
483                            CORBA::Double             z,
484                            SMESH::ElementType        type,
485                            SMESH::SMESH_IDSource_ptr meshObject,
486                            SMESH::double_array_out   projecton);
487
488   /*!
489    * Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
490    * TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
491    */
492   CORBA::Short GetPointState(CORBA::Double x, CORBA::Double y, CORBA::Double z);
493
494   /*!
495    * Check if a 2D mesh is manifold
496    */
497   CORBA::Boolean IsManifold();
498
499   /*!
500    * Check if orientation of 2D elements is coherent
501    */
502   CORBA::Boolean IsCoherentOrientation2D();
503
504   /*!
505    * Partition given 1D elements into groups of contiguous edges.
506    * A node where number of meeting edges != 2 is a group end.
507    * An optional startNode is used to orient groups it belongs to.
508    * \return a list of edge groups and a list of corresponding node groups.
509    *         If a group is closed, the first and last nodes of the group are same.
510    */
511   SMESH::array_of_long_array* Get1DBranches( SMESH::SMESH_IDSource_ptr      edges,
512                                              SMESH::smIdType                startNode,
513                                              SMESH::array_of_long_array_out nodeGroups);
514
515   /*!
516    * Return sharp edges of faces and non-manifold ones. Optionally adds existing edges.
517    */
518   SMESH::ListOfEdges* FindSharpEdges(CORBA::Double angle, CORBA::Boolean addExisting);
519
520   /*!
521    * Returns all or only closed FreeBorder's.
522    */
523   SMESH::ListOfFreeBorders* FindFreeBorders(CORBA::Boolean closedOnly);
524
525   /*!
526    * Fill with 2D elements a hole defined by a FreeBorder.
527    * Optionally add new faces to a given group, which is returned
528    */
529   SMESH::SMESH_Group_ptr FillHole(const SMESH::FreeBorder& hole,
530                                   const char*              groupName);
531
532   SMESH::CoincidentFreeBorders* FindCoincidentFreeBorders(CORBA::Double tolerance);
533   CORBA::Short SewCoincidentFreeBorders(const SMESH::CoincidentFreeBorders& freeBorders,
534                                         CORBA::Boolean                      createPolygons,
535                                         CORBA::Boolean                      createPolyedrs);
536
537   SMESH::SMESH_MeshEditor::Sew_Error
538     SewFreeBorders(SMESH::smIdType FirstNodeID1,
539                    SMESH::smIdType SecondNodeID1,
540                    SMESH::smIdType LastNodeID1,
541                    SMESH::smIdType FirstNodeID2,
542                    SMESH::smIdType SecondNodeID2,
543                    SMESH::smIdType LastNodeID2,
544                    CORBA::Boolean  CreatePolygons,
545                    CORBA::Boolean  CreatePolyedrs);
546   SMESH::SMESH_MeshEditor::Sew_Error
547     SewConformFreeBorders(SMESH::smIdType FirstNodeID1,
548                           SMESH::smIdType SecondNodeID1,
549                           SMESH::smIdType LastNodeID1,
550                           SMESH::smIdType FirstNodeID2,
551                           SMESH::smIdType SecondNodeID2);
552   SMESH::SMESH_MeshEditor::Sew_Error
553     SewBorderToSide(SMESH::smIdType FirstNodeIDOnFreeBorder,
554                     SMESH::smIdType SecondNodeIDOnFreeBorder,
555                     SMESH::smIdType LastNodeIDOnFreeBorder,
556                     SMESH::smIdType FirstNodeIDOnSide,
557                     SMESH::smIdType LastNodeIDOnSide,
558                     CORBA::Boolean CreatePolygons,
559                     CORBA::Boolean CreatePolyedrs);
560   SMESH::SMESH_MeshEditor::Sew_Error
561     SewSideElements(const SMESH::smIdType_array& IDsOfSide1Elements,
562                     const SMESH::smIdType_array& IDsOfSide2Elements,
563                     SMESH::smIdType NodeID1OfSide1ToMerge,
564                     SMESH::smIdType NodeID1OfSide2ToMerge,
565                     SMESH::smIdType NodeID2OfSide1ToMerge,
566                     SMESH::smIdType NodeID2OfSide2ToMerge);
567
568   /*!
569    * Set new nodes for given element.
570    * If number of nodes is not corresponded to type of
571    * element - returns false
572    */
573   CORBA::Boolean ChangeElemNodes(SMESH::smIdType ide, const SMESH::smIdType_array& newIDs);
574
575   SMESH::SMESH_Group_ptr DoubleElements(SMESH::SMESH_IDSource_ptr theElements,
576                                         const char*               theGroupName);
577
578   CORBA::Boolean DoubleNodes( const SMESH::smIdType_array& theNodes,
579                               const SMESH::smIdType_array& theModifiedElems );
580
581   CORBA::Boolean DoubleNode( SMESH::smIdType theNodeId,
582                              const SMESH::smIdType_array& theModifiedElems );
583
584   CORBA::Boolean DoubleNodeGroup( SMESH::SMESH_GroupBase_ptr theNodes,
585                                   SMESH::SMESH_GroupBase_ptr theModifiedElems );
586
587   /*!
588    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
589    * Works as DoubleNodeGroup(), but returns a new group with newly created nodes.
590    * \param theNodes - group of nodes to be doubled.
591    * \param theModifiedElems - group of elements to be updated.
592    * \return a new group with newly created nodes
593    * \sa DoubleNodeGroup()
594    */
595   SMESH::SMESH_Group_ptr DoubleNodeGroupNew( SMESH::SMESH_GroupBase_ptr theNodes,
596                                              SMESH::SMESH_GroupBase_ptr theModifiedElems );
597
598   CORBA::Boolean DoubleNodeGroups( const SMESH::ListOfGroups& theNodes,
599                                    const SMESH::ListOfGroups& theModifiedElems );
600
601   SMESH::SMESH_Group_ptr DoubleNodeGroupsNew( const SMESH::ListOfGroups& theNodes,
602                                               const SMESH::ListOfGroups& theModifiedElems );
603
604   /*!
605    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
606    * \param theElems - the list of elements (edges or faces) to be replicated
607    *       The nodes for duplication could be found from these elements
608    * \param theNodesNot - list of nodes to NOT replicate
609    * \param theAffectedElems - the list of elements (cells and edges) to which the 
610    *       replicated nodes should be associated to.
611    * \return TRUE if operation has been completed successfully, FALSE otherwise
612    * \sa DoubleNodeGroup(), DoubleNodeGroups()
613    */
614   CORBA::Boolean DoubleNodeElem( const SMESH::smIdType_array& theElems, 
615                                  const SMESH::smIdType_array& theNodesNot,
616                                  const SMESH::smIdType_array& theAffectedElems );
617
618   /*!
619    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
620    * \param theElems - the list of elements (edges or faces) to be replicated
621    *        The nodes for duplication could be found from these elements
622    * \param theNodesNot - list of nodes to NOT replicate
623    * \param theShape - shape to detect affected elements (element which geometric center
624    *        located on or inside shape).
625    *        The replicated nodes should be associated to affected elements.
626    * \return TRUE if operation has been completed successfully, FALSE otherwise
627    * \sa DoubleNodeGroupInRegion(), DoubleNodeGroupsInRegion()
628    */
629   CORBA::Boolean DoubleNodeElemInRegion( const SMESH::smIdType_array& theElems, 
630                                          const SMESH::smIdType_array& theNodesNot,
631                                          GEOM::GEOM_Object_ptr        theShape );
632
633   /*!
634    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
635    * \param theElems - group of of elements (edges or faces) to be replicated
636    * \param theNodesNot - group of nodes not to replicated
637    * \param theAffectedElems - group of elements to which the replicated nodes
638    *        should be associated to.
639    * \return TRUE if operation has been completed successfully, FALSE otherwise
640    * \sa DoubleNodes(), DoubleNodeGroups(), DoubleNodeElemGroupNew()
641    */
642   CORBA::Boolean DoubleNodeElemGroup( SMESH::SMESH_GroupBase_ptr theElems,
643                                       SMESH::SMESH_GroupBase_ptr theNodesNot,
644                                       SMESH::SMESH_GroupBase_ptr theAffectedElems );
645
646   /*!
647    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
648    * Works as DoubleNodeElemGroup(), but returns a new group with newly created elements.
649    * \param theElems - group of of elements (edges or faces) to be replicated
650    * \param theNodesNot - group of nodes not to replicated
651    * \param theAffectedElems - group of elements to which the replicated nodes
652    *        should be associated to.
653    * \return a new group with newly created elements
654    * \sa DoubleNodeElemGroup()
655    */
656   SMESH::SMESH_Group_ptr DoubleNodeElemGroupNew( SMESH::SMESH_GroupBase_ptr theElems,
657                                                  SMESH::SMESH_GroupBase_ptr theNodesNot,
658                                                  SMESH::SMESH_GroupBase_ptr theAffectedElems );
659
660   SMESH::ListOfGroups*   DoubleNodeElemGroup2New(SMESH::SMESH_GroupBase_ptr theElems,
661                                                  SMESH::SMESH_GroupBase_ptr theNodesNot,
662                                                  SMESH::SMESH_GroupBase_ptr theAffectedElems,
663                                                  CORBA::Boolean             theElemGroupNeeded,
664                                                  CORBA::Boolean             theNodeGroupNeeded);
665   
666   /*!
667    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
668    * \param theElems - group of of elements (edges or faces) to be replicated
669    * \param theNodesNot - group of nodes not to replicated
670    * \param theShape - shape to detect affected elements (element which geometric center
671    *        located on or inside shape).
672    *        The replicated nodes should be associated to affected elements.
673    * \return TRUE if operation has been completed successfully, FALSE otherwise
674    * \sa DoubleNodesInRegion(), DoubleNodeGroupsInRegion()
675    */
676   CORBA::Boolean DoubleNodeElemGroupInRegion( SMESH::SMESH_GroupBase_ptr theElems,
677                                               SMESH::SMESH_GroupBase_ptr theNodesNot,
678                                               GEOM::GEOM_Object_ptr      theShape );
679
680   /*!
681    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
682    * This method provided for convenience works as DoubleNodes() described above.
683    * \param theElems - list of groups of elements (edges or faces) to be replicated
684    * \param theNodesNot - list of groups of nodes not to replicated
685    * \param theAffectedElems - group of elements to which the replicated nodes
686    *        should be associated to.
687    * \return TRUE if operation has been completed successfully, FALSE otherwise
688    * \sa DoubleNodeGroup(), DoubleNodes(), DoubleNodeElemGroupsNew()
689    */
690   CORBA::Boolean DoubleNodeElemGroups( const SMESH::ListOfGroups& theElems,
691                                        const SMESH::ListOfGroups& theNodesNot,
692                                        const SMESH::ListOfGroups& theAffectedElems );
693
694   /*!
695    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
696    * Works as DoubleNodeElemGroups(), but returns a new group with newly created elements.
697    * \param theElems - list of groups of elements (edges or faces) to be replicated
698    * \param theNodesNot - list of groups of nodes not to replicated
699    * \param theAffectedElems - group of elements to which the replicated nodes
700    *        should be associated to.
701    * \return a new group with newly created elements
702    * \sa DoubleNodeElemGroups()
703    */
704   SMESH::SMESH_Group_ptr DoubleNodeElemGroupsNew( const SMESH::ListOfGroups& theElems,
705                                                   const SMESH::ListOfGroups& theNodesNot,
706                                                   const SMESH::ListOfGroups& theAffectedElems );
707
708   SMESH::ListOfGroups*   DoubleNodeElemGroups2New(const SMESH::ListOfGroups& theElems,
709                                                   const SMESH::ListOfGroups& theNodesNot,
710                                                   const SMESH::ListOfGroups& theAffectedElems,
711                                                   CORBA::Boolean             theElemGroupNeeded,
712                                                   CORBA::Boolean             theNodeGroupNeeded);
713
714   /*!
715    * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
716    * This method provided for convenience works as DoubleNodes() described above.
717    * \param theElems - list of groups of elements (edges or faces) to be replicated
718    * \param theNodesNot - list of groups of nodes not to replicated
719    * \param theShape - shape to detect affected elements (element which geometric center
720    *        located on or inside shape).
721    *        The replicated nodes should be associated to affected elements.
722    * \return TRUE if operation has been completed successfully, FALSE otherwise
723    * \sa DoubleNodeGroupInRegion(), DoubleNodesInRegion()
724    */
725   CORBA::Boolean DoubleNodeElemGroupsInRegion( const SMESH::ListOfGroups& theElems,
726                                                const SMESH::ListOfGroups& theNodesNot,
727                                                GEOM::GEOM_Object_ptr      theShape );
728
729   /*!
730    * \brief Identify the elements that will be affected by node duplication (actual duplication is not performed.
731    * This method is the first step of DoubleNodeElemGroupsInRegion.
732    * \param theElems - list of groups of elements (edges or faces) to be replicated
733    * \param theNodesNot - list of groups of nodes not to replicated
734    * \param theShape - shape to detect affected elements (element which geometric center
735    *        located on or inside shape).
736    *        The replicated nodes should be associated to affected elements.
737    * \return groups of affected elements
738    * \sa DoubleNodeElemGroupsInRegion()
739    */
740   SMESH::ListOfGroups* AffectedElemGroupsInRegion( const SMESH::ListOfGroups& theElems,
741                                                    const SMESH::ListOfGroups& theNodesNot,
742                                                    GEOM::GEOM_Object_ptr      theShape );
743
744   /*!
745    * \brief Double nodes on shared faces between groups of volumes and create flat elements on demand.
746    * The list of groups must describe a partition of the mesh volumes.
747    * The nodes of the internal faces at the boundaries of the groups are doubled.
748    * In option, the internal faces are replaced by flat elements.
749    * Triangles are transformed in prisms, and quadrangles in hexahedrons.
750    * \param theDomains - list of groups of volumes
751    * \param createJointElems - if TRUE, create the elements
752    * \param onAllBoundaries - if TRUE, the nodes and elements are also create on
753    *        the boundary between \a theDomains and the rest mesh
754    * \return TRUE if operation has been completed successfully, FALSE otherwise
755    */
756   CORBA::Boolean DoubleNodesOnGroupBoundaries( const SMESH::ListOfGroups& theDomains,
757                                                CORBA::Boolean             createJointElems,
758                                                CORBA::Boolean             onAllBoundaries );
759   /*!
760    * \brief Double nodes on some external faces and create flat elements.
761    * Flat elements are mainly used by some types of mechanic calculations.
762    *
763    * Each group of the list must be constituted of faces.
764    * Triangles are transformed in prisms, and quadrangles in hexahedrons.
765    * @param theGroupsOfFaces - list of groups of faces
766    * @return TRUE if operation has been completed successfully, FALSE otherwise
767    */
768   CORBA::Boolean CreateFlatElementsOnFacesGroups( const SMESH::ListOfGroups& theGroupsOfFaces );
769
770   /*!
771    *  \brief identify all the elements around a geom shape, get the faces delimiting the hole
772    *  Build groups of volume to remove, groups of faces to replace on the skin of the object,
773    *  groups of faces to remove insidethe object, (idem edges).
774    *  Build ordered list of nodes at the border of each group of faces to replace (to be used to build a geom subshape)
775    */
776   void CreateHoleSkin(CORBA::Double radius,
777                       GEOM::GEOM_Object_ptr theShape,
778                       const char* groupName,
779                       const SMESH::double_array& theNodesCoords,
780                       SMESH::array_of_long_array_out GroupsOfNodes);
781
782   /*!
783    * \brief Generated skin mesh (containing 2D cells) from 3D mesh
784    * The created 2D mesh elements based on nodes of free faces of boundary volumes
785    * \return TRUE if operation has been completed successfully, FALSE otherwise
786    */
787   CORBA::Boolean Make2DMeshFrom3D();
788
789   SMESH::SMESH_Mesh_ptr MakeBoundaryMesh(SMESH::SMESH_IDSource_ptr elements,
790                                          SMESH::Bnd_Dimension      dimension,
791                                          const char*               groupName,
792                                          const char*               meshName,
793                                          CORBA::Boolean            toCopyElements,
794                                          CORBA::Boolean            toCopyMissingBondary,
795                                          SMESH::SMESH_Group_out    group);
796
797   CORBA::Long MakeBoundaryElements(SMESH::Bnd_Dimension dimension,
798                                    const char* groupName,
799                                    const char* meshName,
800                                    CORBA::Boolean toCopyAll,
801                                    const SMESH::ListOfIDSources& groups,
802                                    SMESH::SMESH_Mesh_out mesh,
803                                    SMESH::SMESH_Group_out group);
804
805   /*!
806    * \brief Create a polyline consisting of 1D mesh elements each lying on a 2D element of
807    *        the initial mesh. Positions of new nodes are found by cutting the mesh by the
808    *        plane passing through pairs of points specified by each PolySegment structure.
809    *        If there are several paths connecting a pair of points, the shortest path is
810    *        selected by the module. Position of the cutting plane is defined by the two
811    *        points and an optional vector lying on the plane specified by a PolySegment.
812    *        By default the vector is defined by Mesh module as following. A middle point
813    *        of the two given points is computed. The middle point is projected to the mesh.
814    *        The vector goes from the middle point to the projection point. In case of planar
815    *        mesh, the vector is normal to the mesh.
816    *  \param [inout] segments - PolySegment's defining positions of cutting planes.
817    *        Return the used vector and position of the middle point.
818    *  \param [in] groupName - optional name of a group where created mesh segments will
819    *        be added.
820    */
821   void MakePolyLine(SMESH::ListOfPolySegments& segments,
822                     const char*                groupName);
823
824   /*!
825    * \brief Create a slot of given width around given 1D elements lying on a triangle mesh.
826    *        The slot is constructed by cutting faces by cylindrical surfaces made
827    *        around each segment. Segments are expected to be created by MakePolyLine().
828    * \return Edges located at the slot boundary
829    */
830   SMESH::ListOfEdges* MakeSlot(SMESH::SMESH_GroupBase_ptr segments,
831                                CORBA::Double              width);
832
833
834  private: //!< private methods
835
836   ::SMESH_MeshEditor& getEditor();
837
838   SMESHDS_Mesh * getMeshDS() { return myMesh->GetMeshDS(); }
839
840   MeshEditor_I::TPreviewMesh * getPreviewMesh( SMDSAbs_ElementType previewType = SMDSAbs_All );
841
842   void declareMeshModified( bool isReComputeSafe );
843
844   /*!
845    * \brief Clear myLastCreated* or myPreviewData
846    */
847   void initData(bool deleteSearchers=true);
848
849   /*!
850    * \brief Return groups by their IDs
851    */
852   SMESH::ListOfGroups* getGroups(const std::list<int>* groupIDs);
853
854   SMESH::ListOfGroups* mirror(TIDSortedElemSet &                  IDsOfElements,
855                               const SMESH::AxisStruct &           Axis,
856                               SMESH::SMESH_MeshEditor::MirrorType MirrorType,
857                               CORBA::Boolean                      Copy,
858                               bool                                MakeGroups,
859                               ::SMESH_Mesh*                       TargetMesh=0);
860   SMESH::ListOfGroups* translate(TIDSortedElemSet        & IDsOfElements,
861                                  const SMESH::DirStruct &  Vector,
862                                  CORBA::Boolean            Copy,
863                                  bool                      MakeGroups,
864                                  ::SMESH_Mesh*             TargetMesh=0);
865   SMESH::ListOfGroups* rotate(TIDSortedElemSet &           IDsOfElements,
866                               const SMESH::AxisStruct &  Axis,
867                               CORBA::Double             Angle,
868                               CORBA::Boolean            Copy,
869                               bool                      MakeGroups,
870                               ::SMESH_Mesh*             TargetMesh=0);
871
872   SMESH::ListOfGroups* scale(SMESH::SMESH_IDSource_ptr   theObject,
873                              const SMESH::PointStruct&   thePoint,
874                              const SMESH::double_array&  theScaleFact,
875                              CORBA::Boolean              theCopy,
876                              bool                        theMakeGroups,
877                              ::SMESH_Mesh*               theTargetMesh=0);
878
879   void convertToQuadratic(CORBA::Boolean            theForce3d,
880                           CORBA::Boolean            theToBiQuad,
881                           SMESH::SMESH_IDSource_ptr theObject = SMESH::SMESH_IDSource::_nil());
882
883   SMESH::SMESH_Mesh_ptr makeMesh(const char* theMeshName);
884
885   void dumpGroupsList(SMESH::TPythonDump &        theDumpPython,
886                       const SMESH::ListOfGroups * theGroupList);
887
888   void prepareIdSource(SMESH::SMESH_IDSource_ptr theObject);
889
890
891   enum IDSource_Error { IDSource_OK, IDSource_INVALID, IDSource_EMPTY };
892
893   bool idSourceToSet(SMESH::SMESH_IDSource_ptr  theIDSource,
894                      const SMESHDS_Mesh*        theMeshDS,
895                      TIDSortedElemSet&          theElemSet,
896                      const SMDSAbs_ElementType  theType,
897                      const bool                 emptyIfIsMesh = false,
898                      IDSource_Error*            error = 0);
899
900   void findCoincidentNodes( TIDSortedNodeSet &             Nodes,
901                             CORBA::Double                  Tolerance,
902                             SMESH::array_of_long_array_out GroupsOfNodes,
903                             CORBA::Boolean                 SeparateCornersAndMedium);
904
905
906
907  private: //!< fields
908
909   SMESH_Mesh_i*                myMesh_i;
910   SMESH_Mesh *                 myMesh;
911   ::SMESH_MeshEditor           myEditor;
912
913   bool                         myIsPreviewMode;
914   MeshEditor_I::TPreviewMesh * myPreviewMesh;
915   ::SMESH_MeshEditor *         myPreviewEditor;
916   SMESH::MeshPreviewStruct_var myPreviewData;
917
918   // temporary IDSources
919   struct _IDSource;
920 };
921
922 #endif