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