Salome HOME
PAL16842 (Genertion of groups when a mesh is transformed)
[modules/smesh.git] / src / SMESH_I / SMESH_MeshEditor_i.hxx
1 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
2 //
3 //  Copyright (C) 2003  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.
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 //
24 //  File   : SMESH_MeshEditor_i.hxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef _SMESH_MESHEDITOR_I_HXX_
30 #define _SMESH_MESHEDIOTR_I_HXX_
31
32 #include "SMESH.hxx"
33
34 #include <SALOMEconfig.h>
35 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
36
37 #include "SMESH_Mesh.hxx"
38
39 #include <list>
40
41 class SMESH_MeshEditor;
42 class SMESH_Mesh_i;
43
44 class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
45 {
46  public:
47   SMESH_MeshEditor_i(SMESH_Mesh_i * theMesh, bool isPreview);
48
49   virtual ~ SMESH_MeshEditor_i();
50
51   // --- CORBA
52   CORBA::Boolean RemoveElements(const SMESH::long_array & IDsOfElements);
53   CORBA::Boolean RemoveNodes(const SMESH::long_array & IDsOfNodes);
54
55   /*!
56    * Methods for creation new elements.
57    * Returns ID of created element or 0 if element not created
58    */
59   CORBA::Long AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z);
60   CORBA::Long AddEdge(const SMESH::long_array & IDsOfNodes);
61   CORBA::Long AddFace(const SMESH::long_array & IDsOfNodes);
62   CORBA::Long AddPolygonalFace(const SMESH::long_array & IDsOfNodes);
63   CORBA::Long AddVolume(const SMESH::long_array & IDsOfNodes);
64   CORBA::Long AddPolyhedralVolume(const SMESH::long_array & IDsOfNodes,
65                                   const SMESH::long_array & Quantities);
66   CORBA::Long AddPolyhedralVolumeByFaces(const SMESH::long_array & IdsOfFaces);
67
68   CORBA::Boolean MoveNode(CORBA::Long NodeID,
69                           CORBA::Double x, CORBA::Double y, CORBA::Double z);
70
71   CORBA::Boolean InverseDiag(CORBA::Long NodeID1, CORBA::Long NodeID2);
72   CORBA::Boolean DeleteDiag(CORBA::Long NodeID1, CORBA::Long NodeID2);
73   CORBA::Boolean Reorient(const SMESH::long_array & IDsOfElements);
74   CORBA::Boolean ReorientObject(SMESH::SMESH_IDSource_ptr theObject);
75
76   // Split/Join faces
77   CORBA::Boolean TriToQuad       (const SMESH::long_array &   IDsOfElements,
78                                   SMESH::NumericalFunctor_ptr Criterion,
79                                   CORBA::Double               MaxAngle);
80   CORBA::Boolean TriToQuadObject (SMESH::SMESH_IDSource_ptr   theObject,
81                                   SMESH::NumericalFunctor_ptr Criterion,
82                                   CORBA::Double               MaxAngle);
83   CORBA::Boolean QuadToTri       (const SMESH::long_array &   IDsOfElements,
84                                   SMESH::NumericalFunctor_ptr Criterion);
85   CORBA::Boolean QuadToTriObject (SMESH::SMESH_IDSource_ptr   theObject,
86                                   SMESH::NumericalFunctor_ptr Criterion);
87   CORBA::Boolean SplitQuad       (const SMESH::long_array &   IDsOfElements,
88                                   CORBA::Boolean              Diag13);
89   CORBA::Boolean SplitQuadObject (SMESH::SMESH_IDSource_ptr   theObject,
90                                   CORBA::Boolean              Diag13);
91   CORBA::Long    BestSplit       (CORBA::Long                 IDOfQuad,
92                                   SMESH::NumericalFunctor_ptr Criterion);
93
94   CORBA::Boolean Smooth(const SMESH::long_array &              IDsOfElements,
95                         const SMESH::long_array &              IDsOfFixedNodes,
96                         CORBA::Long                            MaxNbOfIterations,
97                         CORBA::Double                          MaxAspectRatio,
98                         SMESH::SMESH_MeshEditor::Smooth_Method Method);
99   CORBA::Boolean SmoothObject(SMESH::SMESH_IDSource_ptr              theObject,
100                               const SMESH::long_array &              IDsOfFixedNodes,
101                               CORBA::Long                            MaxNbOfIterations,
102                               CORBA::Double                          MaxAspectRatio,
103                               SMESH::SMESH_MeshEditor::Smooth_Method Method);
104   CORBA::Boolean SmoothParametric(const SMESH::long_array &              IDsOfElements,
105                                   const SMESH::long_array &              IDsOfFixedNodes,
106                                   CORBA::Long                            MaxNbOfIterations,
107                                   CORBA::Double                          MaxAspectRatio,
108                                   SMESH::SMESH_MeshEditor::Smooth_Method Method);
109   CORBA::Boolean SmoothParametricObject(SMESH::SMESH_IDSource_ptr              theObject,
110                                         const SMESH::long_array &              IDsOfFixedNodes,
111                                         CORBA::Long                            MaxNbOfIterations,
112                                         CORBA::Double                          MaxAspectRatio,
113                                         SMESH::SMESH_MeshEditor::Smooth_Method Method);
114   CORBA::Boolean smooth(const SMESH::long_array &              IDsOfElements,
115                         const SMESH::long_array &              IDsOfFixedNodes,
116                         CORBA::Long                            MaxNbOfIterations,
117                         CORBA::Double                          MaxAspectRatio,
118                         SMESH::SMESH_MeshEditor::Smooth_Method Method,
119                         bool                                   IsParametric);
120   CORBA::Boolean smoothObject(SMESH::SMESH_IDSource_ptr              theObject,
121                               const SMESH::long_array &              IDsOfFixedNodes,
122                               CORBA::Long                            MaxNbOfIterations,
123                               CORBA::Double                          MaxAspectRatio,
124                               SMESH::SMESH_MeshEditor::Smooth_Method Method,
125                               bool                                   IsParametric);
126
127
128   void ConvertToQuadratic(CORBA::Boolean Force3d);
129   CORBA::Boolean ConvertFromQuadratic();
130
131   void RenumberNodes();
132   void RenumberElements();
133
134   void RotationSweep(const SMESH::long_array & IDsOfElements,
135                      const SMESH::AxisStruct & Axis,
136                      CORBA::Double             AngleInRadians,
137                      CORBA::Long               NbOfSteps,
138                      CORBA::Double             Tolerance);
139   void RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
140                            const SMESH::AxisStruct & Axis,
141                            CORBA::Double             AngleInRadians,
142                            CORBA::Long               NbOfSteps,
143                            CORBA::Double             Tolerance);
144
145   void ExtrusionSweep(const SMESH::long_array & IDsOfElements,
146                       const SMESH::DirStruct &  StepVector,
147                       CORBA::Long               NbOfSteps);
148   void ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
149                             const SMESH::DirStruct &  StepVector,
150                             CORBA::Long               NbOfSteps);
151   void ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
152                               const SMESH::DirStruct &  StepVector,
153                               CORBA::Long               NbOfSteps);
154   void ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
155                               const SMESH::DirStruct &  StepVector,
156                               CORBA::Long               NbOfSteps);
157   void AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
158                          const SMESH::DirStruct &  theStepVector,
159                          CORBA::Long               theNbOfSteps,
160                          CORBA::Long               theExtrFlags,
161                          CORBA::Double             theSewTolerance);
162
163   SMESH::SMESH_MeshEditor::Extrusion_Error
164     ExtrusionAlongPath(const SMESH::long_array &   IDsOfElements,
165                        SMESH::SMESH_Mesh_ptr       PathMesh,
166                        GEOM::GEOM_Object_ptr       PathShape,
167                        CORBA::Long                 NodeStart,
168                        CORBA::Boolean              HasAngles,
169                        const SMESH::double_array & Angles,
170                        CORBA::Boolean              HasRefPoint,
171                        const SMESH::PointStruct &  RefPoint);
172
173   SMESH::SMESH_MeshEditor::Extrusion_Error
174     ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr   theObject,
175                              SMESH::SMESH_Mesh_ptr       PathMesh,
176                              GEOM::GEOM_Object_ptr       PathShape,
177                              CORBA::Long                 NodeStart,
178                              CORBA::Boolean              HasAngles,
179                              const SMESH::double_array & Angles,
180                              CORBA::Boolean              HasRefPoint,
181                              const SMESH::PointStruct &  RefPoint);
182
183   SMESH::double_array* LinearAnglesVariation(SMESH::SMESH_Mesh_ptr       PathMesh,
184                                              GEOM::GEOM_Object_ptr       PathShape,
185                                              const SMESH::double_array & Angles);
186
187   void Mirror(const SMESH::long_array &           IDsOfElements,
188               const SMESH::AxisStruct &           Axis,
189               SMESH::SMESH_MeshEditor::MirrorType MirrorType,
190               CORBA::Boolean                      Copy);
191   void MirrorObject(SMESH::SMESH_IDSource_ptr           theObject,
192                     const SMESH::AxisStruct &           Axis,
193                     SMESH::SMESH_MeshEditor::MirrorType MirrorType,
194                     CORBA::Boolean                      Copy);
195   void Translate(const SMESH::long_array & IDsOfElements,
196                  const SMESH::DirStruct &   Vector,
197                  CORBA::Boolean            Copy);
198   void TranslateObject(SMESH::SMESH_IDSource_ptr  theObject,
199                        const SMESH::DirStruct &   Vector,
200                        CORBA::Boolean             Copy);
201   void Rotate(const SMESH::long_array & IDsOfElements,
202               const SMESH::AxisStruct &  Axis,
203               CORBA::Double             Angle,
204               CORBA::Boolean            Copy);
205   void RotateObject(SMESH::SMESH_IDSource_ptr  theObject,
206                     const SMESH::AxisStruct &  Axis,
207                     CORBA::Double              Angle,
208                     CORBA::Boolean             Copy);
209
210   SMESH::ListOfGroups* RotationSweepMakeGroups(const SMESH::long_array& IDsOfElements,
211                                                const SMESH::AxisStruct& Axix,
212                                                CORBA::Double            AngleInRadians,
213                                                CORBA::Long              NbOfSteps,
214                                                CORBA::Double            Tolerance);
215   SMESH::ListOfGroups* RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
216                                                      const SMESH::AxisStruct&  Axix,
217                                                      CORBA::Double             AngleInRadians,
218                                                      CORBA::Long               NbOfSteps,
219                                                      CORBA::Double             Tolerance);
220   SMESH::ListOfGroups* ExtrusionSweepMakeGroups(const SMESH::long_array& IDsOfElements,
221                                                 const SMESH::DirStruct&  StepVector,
222                                                 CORBA::Long              NbOfSteps);
223   SMESH::ListOfGroups* AdvancedExtrusionMakeGroups(const SMESH::long_array& IDsOfElements,
224                                                    const SMESH::DirStruct&  StepVector,
225                                                    CORBA::Long              NbOfSteps,
226                                                    CORBA::Long              ExtrFlags,
227                                                    CORBA::Double            SewTolerance);
228   SMESH::ListOfGroups* ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
229                                                       const SMESH::DirStruct&   StepVector,
230                                                       CORBA::Long               NbOfSteps);
231   SMESH::ListOfGroups* ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr Object,
232                                                         const SMESH::DirStruct&   StepVector,
233                                                         CORBA::Long               NbOfSteps);
234   SMESH::ListOfGroups* ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr Object,
235                                                         const SMESH::DirStruct&   StepVector,
236                                                         CORBA::Long               NbOfSteps);
237   SMESH::ListOfGroups* ExtrusionAlongPathMakeGroups(const SMESH::long_array&   IDsOfElements,
238                                                     SMESH::SMESH_Mesh_ptr      PathMesh,
239                                                     GEOM::GEOM_Object_ptr      PathShape,
240                                                     CORBA::Long                NodeStart,
241                                                     CORBA::Boolean             HasAngles,
242                                                     const SMESH::double_array& Angles,
243                                                     CORBA::Boolean             HasRefPoint,
244                                                     const SMESH::PointStruct&  RefPoint,
245                                                     SMESH::SMESH_MeshEditor::Extrusion_Error& Error);
246   SMESH::ListOfGroups* ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr  Object,
247                                                           SMESH::SMESH_Mesh_ptr      PathMesh,
248                                                           GEOM::GEOM_Object_ptr      PathShape,
249                                                           CORBA::Long                NodeStart,
250                                                           CORBA::Boolean             HasAngles,
251                                                           const SMESH::double_array& Angles,
252                                                           CORBA::Boolean             HasRefPoint,
253                                                           const SMESH::PointStruct&  RefPoint,
254                                                           SMESH::SMESH_MeshEditor::Extrusion_Error& Error);
255   SMESH::ListOfGroups* MirrorMakeGroups(const SMESH::long_array&            IDsOfElements,
256                                         const SMESH::AxisStruct&            Mirror,
257                                         SMESH::SMESH_MeshEditor::MirrorType MirrorType);
258   SMESH::ListOfGroups* MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr           Object,
259                                               const SMESH::AxisStruct&            Mirror,
260                                               SMESH::SMESH_MeshEditor::MirrorType MirrorType);
261   SMESH::ListOfGroups* TranslateMakeGroups(const SMESH::long_array& IDsOfElements,
262                                            const SMESH::DirStruct&  Vector);
263   SMESH::ListOfGroups* TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
264                                                  const SMESH::DirStruct&   Vector);
265   SMESH::ListOfGroups* RotateMakeGroups(const SMESH::long_array& IDsOfElements,
266                                         const SMESH::AxisStruct& Axis,
267                                         CORBA::Double            AngleInRadians);
268   SMESH::ListOfGroups* RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
269                                               const SMESH::AxisStruct&  Axis,
270                                               CORBA::Double             AngleInRadians);
271
272   void FindCoincidentNodes (CORBA::Double                  Tolerance,
273                             SMESH::array_of_long_array_out GroupsOfNodes);
274   void FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr      Object,
275                                  CORBA::Double                  Tolerance,
276                                  SMESH::array_of_long_array_out GroupsOfNodes);
277   void MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes);
278   void FindEqualElements(SMESH::SMESH_IDSource_ptr      Object,
279                          SMESH::array_of_long_array_out GroupsOfElementsID);
280   void MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID);
281   void MergeEqualElements();
282   CORBA::Long MoveClosestNodeToPoint(CORBA::Double x,
283                                      CORBA::Double y,
284                                      CORBA::Double z,
285                                      CORBA::Long   nodeID);
286
287
288
289   SMESH::SMESH_MeshEditor::Sew_Error
290   SewFreeBorders(CORBA::Long FirstNodeID1,
291                  CORBA::Long SecondNodeID1,
292                  CORBA::Long LastNodeID1,
293                  CORBA::Long FirstNodeID2,
294                  CORBA::Long SecondNodeID2,
295                  CORBA::Long LastNodeID2,
296                  CORBA::Boolean CreatePolygons,
297                  CORBA::Boolean CreatePolyedrs);
298   SMESH::SMESH_MeshEditor::Sew_Error
299   SewConformFreeBorders(CORBA::Long FirstNodeID1,
300                         CORBA::Long SecondNodeID1,
301                         CORBA::Long LastNodeID1,
302                         CORBA::Long FirstNodeID2,
303                         CORBA::Long SecondNodeID2);
304   SMESH::SMESH_MeshEditor::Sew_Error
305   SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
306                   CORBA::Long SecondNodeIDOnFreeBorder,
307                   CORBA::Long LastNodeIDOnFreeBorder,
308                   CORBA::Long FirstNodeIDOnSide,
309                   CORBA::Long LastNodeIDOnSide,
310                   CORBA::Boolean CreatePolygons,
311                   CORBA::Boolean CreatePolyedrs);
312   SMESH::SMESH_MeshEditor::Sew_Error
313   SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
314                   const SMESH::long_array& IDsOfSide2Elements,
315                   CORBA::Long NodeID1OfSide1ToMerge,
316                   CORBA::Long NodeID1OfSide2ToMerge,
317                   CORBA::Long NodeID2OfSide1ToMerge,
318                   CORBA::Long NodeID2OfSide2ToMerge);
319
320   /*!
321    * Set new nodes for given element.
322    * If number of nodes is not corresponded to type of
323    * element - returns false
324    */
325   CORBA::Boolean ChangeElemNodes(CORBA::Long ide, const SMESH::long_array& newIDs);
326   
327   /*!
328    * Return data of mesh edition preview
329    */
330   SMESH::MeshPreviewStruct* GetPreviewData();
331
332   /*!
333    * If during last operation of MeshEditor some nodes were
334    * created this method returns list of it's IDs, if new nodes
335    * not creared - returns empty list
336    */
337   SMESH::long_array* GetLastCreatedNodes();
338
339   /*!
340    * If during last operation of MeshEditor some elements were
341    * created this method returns list of it's IDs, if new elements
342    * not creared - returns empty list
343    */
344   SMESH::long_array* GetLastCreatedElems();
345
346   /*!
347    * \brief Return edited mesh ID
348     * \retval int - mesh ID
349    */
350   int GetMeshId() const { return myMesh->GetId(); }
351
352
353 private: //!< private methods
354
355   SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
356
357   /*!
358    * \brief Update myLastCreated* or myPreviewData
359     * \param anEditor - it contains edition results
360    */
361   void storeResult(::SMESH_MeshEditor& anEditor);
362   /*!
363    * \brief Clear myLastCreated* or myPreviewData
364    */
365   void initData();
366
367   /*!
368    * \brief Return groups by their IDs
369    */
370   SMESH::ListOfGroups* getGroups(const std::list<int>* groupIDs);
371
372   SMESH::ListOfGroups* rotationSweep(const SMESH::long_array & IDsOfElements,
373                                      const SMESH::AxisStruct & Axis,
374                                      CORBA::Double             AngleInRadians,
375                                      CORBA::Long               NbOfSteps,
376                                      CORBA::Double             Tolerance,
377                                      const bool                MakeGroups);
378   SMESH::ListOfGroups* extrusionSweep(const SMESH::long_array & IDsOfElements,
379                                       const SMESH::DirStruct &  StepVector,
380                                       CORBA::Long               NbOfSteps,
381                                       const bool                MakeGroups,
382                                       const SMDSAbs_ElementType ElementType=SMDSAbs_All);
383   SMESH::ListOfGroups* advancedExtrusion(const SMESH::long_array & theIDsOfElements,
384                                          const SMESH::DirStruct &  theStepVector,
385                                          CORBA::Long               theNbOfSteps,
386                                          CORBA::Long               theExtrFlags,
387                                          CORBA::Double             theSewTolerance,
388                                          const bool                MakeGroups);
389   SMESH::ListOfGroups* extrusionAlongPath(const SMESH::long_array &   IDsOfElements,
390                                           SMESH::SMESH_Mesh_ptr       PathMesh,
391                                           GEOM::GEOM_Object_ptr       PathShape,
392                                           CORBA::Long                 NodeStart,
393                                           CORBA::Boolean              HasAngles,
394                                           const SMESH::double_array & Angles,
395                                           CORBA::Boolean              HasRefPoint,
396                                           const SMESH::PointStruct &  RefPoint,
397                                           const bool                  MakeGroups,
398                                           SMESH::SMESH_MeshEditor::Extrusion_Error & Error);
399   SMESH::ListOfGroups* mirror(const SMESH::long_array &           IDsOfElements,
400                               const SMESH::AxisStruct &           Axis,
401                               SMESH::SMESH_MeshEditor::MirrorType MirrorType,
402                               CORBA::Boolean                      Copy,
403                               const bool                          MakeGroups);
404   SMESH::ListOfGroups* translate(const SMESH::long_array & IDsOfElements,
405                                  const SMESH::DirStruct &  Vector,
406                                  CORBA::Boolean            Copy,
407                                  const bool                MakeGroups);
408   SMESH::ListOfGroups* rotate(const SMESH::long_array & IDsOfElements,
409                               const SMESH::AxisStruct &  Axis,
410                               CORBA::Double             Angle,
411                               CORBA::Boolean            Copy,
412                               const bool                MakeGroups);
413
414 private: //!< fields
415
416   SMESH_Mesh_i*         myMesh_i;
417   SMESH_Mesh *          myMesh;
418
419   SMESH::long_array_var myLastCreatedElems;
420   SMESH::long_array_var myLastCreatedNodes;
421
422   SMESH::MeshPreviewStruct_var myPreviewData;
423   bool                         myPreviewMode;
424 };
425
426 #endif