Salome HOME
NPAL14921 ( memory limitation and Salome freeze )
[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 class SMESH_MeshEditor;
38
39 class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
40 {
41  public:
42   SMESH_MeshEditor_i(SMESH_Mesh * theMesh, bool isPreview);
43
44   virtual ~ SMESH_MeshEditor_i();
45
46   // --- CORBA
47   CORBA::Boolean RemoveElements(const SMESH::long_array & IDsOfElements);
48   CORBA::Boolean RemoveNodes(const SMESH::long_array & IDsOfNodes);
49
50   /*!
51    * Methods for creation new elements.
52    * Returns ID of created element or 0 if element not created
53    */
54   CORBA::Long AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z);
55   CORBA::Long AddEdge(const SMESH::long_array & IDsOfNodes);
56   CORBA::Long AddFace(const SMESH::long_array & IDsOfNodes);
57   CORBA::Long AddPolygonalFace(const SMESH::long_array & IDsOfNodes);
58   CORBA::Long AddVolume(const SMESH::long_array & IDsOfNodes);
59   CORBA::Long AddPolyhedralVolume(const SMESH::long_array & IDsOfNodes,
60                                   const SMESH::long_array & Quantities);
61   CORBA::Long AddPolyhedralVolumeByFaces(const SMESH::long_array & IdsOfFaces);
62
63   CORBA::Boolean MoveNode(CORBA::Long NodeID,
64                           CORBA::Double x, CORBA::Double y, CORBA::Double z);
65
66   CORBA::Boolean InverseDiag(CORBA::Long NodeID1, CORBA::Long NodeID2);
67   CORBA::Boolean DeleteDiag(CORBA::Long NodeID1, CORBA::Long NodeID2);
68   CORBA::Boolean Reorient(const SMESH::long_array & IDsOfElements);
69   CORBA::Boolean ReorientObject(SMESH::SMESH_IDSource_ptr theObject);
70
71   // Split/Join faces
72   CORBA::Boolean TriToQuad       (const SMESH::long_array &   IDsOfElements,
73                                   SMESH::NumericalFunctor_ptr Criterion,
74                                   CORBA::Double               MaxAngle);
75   CORBA::Boolean TriToQuadObject (SMESH::SMESH_IDSource_ptr   theObject,
76                                   SMESH::NumericalFunctor_ptr Criterion,
77                                   CORBA::Double               MaxAngle);
78   CORBA::Boolean QuadToTri       (const SMESH::long_array &   IDsOfElements,
79                                   SMESH::NumericalFunctor_ptr Criterion);
80   CORBA::Boolean QuadToTriObject (SMESH::SMESH_IDSource_ptr   theObject,
81                                   SMESH::NumericalFunctor_ptr Criterion);
82   CORBA::Boolean SplitQuad       (const SMESH::long_array &   IDsOfElements,
83                                   CORBA::Boolean              Diag13);
84   CORBA::Boolean SplitQuadObject (SMESH::SMESH_IDSource_ptr   theObject,
85                                   CORBA::Boolean              Diag13);
86   CORBA::Long    BestSplit       (CORBA::Long                 IDOfQuad,
87                                   SMESH::NumericalFunctor_ptr Criterion);
88
89   CORBA::Boolean Smooth(const SMESH::long_array &              IDsOfElements,
90                         const SMESH::long_array &              IDsOfFixedNodes,
91                         CORBA::Long                            MaxNbOfIterations,
92                         CORBA::Double                          MaxAspectRatio,
93                         SMESH::SMESH_MeshEditor::Smooth_Method Method);
94   CORBA::Boolean SmoothObject(SMESH::SMESH_IDSource_ptr              theObject,
95                               const SMESH::long_array &              IDsOfFixedNodes,
96                               CORBA::Long                            MaxNbOfIterations,
97                               CORBA::Double                          MaxAspectRatio,
98                               SMESH::SMESH_MeshEditor::Smooth_Method Method);
99   CORBA::Boolean SmoothParametric(const SMESH::long_array &              IDsOfElements,
100                                   const SMESH::long_array &              IDsOfFixedNodes,
101                                   CORBA::Long                            MaxNbOfIterations,
102                                   CORBA::Double                          MaxAspectRatio,
103                                   SMESH::SMESH_MeshEditor::Smooth_Method Method);
104   CORBA::Boolean SmoothParametricObject(SMESH::SMESH_IDSource_ptr              theObject,
105                                         const SMESH::long_array &              IDsOfFixedNodes,
106                                         CORBA::Long                            MaxNbOfIterations,
107                                         CORBA::Double                          MaxAspectRatio,
108                                         SMESH::SMESH_MeshEditor::Smooth_Method Method);
109   CORBA::Boolean smooth(const SMESH::long_array &              IDsOfElements,
110                         const SMESH::long_array &              IDsOfFixedNodes,
111                         CORBA::Long                            MaxNbOfIterations,
112                         CORBA::Double                          MaxAspectRatio,
113                         SMESH::SMESH_MeshEditor::Smooth_Method Method,
114                         bool                                   IsParametric);
115   CORBA::Boolean smoothObject(SMESH::SMESH_IDSource_ptr              theObject,
116                               const SMESH::long_array &              IDsOfFixedNodes,
117                               CORBA::Long                            MaxNbOfIterations,
118                               CORBA::Double                          MaxAspectRatio,
119                               SMESH::SMESH_MeshEditor::Smooth_Method Method,
120                               bool                                   IsParametric);
121
122
123   void ConvertToQuadratic(CORBA::Boolean Force3d);
124   CORBA::Boolean ConvertFromQuadratic();
125
126   void RenumberNodes();
127   void RenumberElements();
128
129   void RotationSweep(const SMESH::long_array & IDsOfElements,
130                      const SMESH::AxisStruct & Axis,
131                      CORBA::Double             AngleInRadians,
132                      CORBA::Long               NbOfSteps,
133                      CORBA::Double             Tolerance);
134   void RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
135                            const SMESH::AxisStruct & Axis,
136                            CORBA::Double             AngleInRadians,
137                            CORBA::Long               NbOfSteps,
138                            CORBA::Double             Tolerance);
139
140   void ExtrusionSweep(const SMESH::long_array & IDsOfElements,
141                       const SMESH::DirStruct &  StepVector,
142                       CORBA::Long               NbOfSteps);
143   void ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
144                             const SMESH::DirStruct &  StepVector,
145                             CORBA::Long               NbOfSteps);
146   void ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
147                               const SMESH::DirStruct &  StepVector,
148                               CORBA::Long               NbOfSteps);
149   void ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
150                               const SMESH::DirStruct &  StepVector,
151                               CORBA::Long               NbOfSteps);
152   void AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
153                          const SMESH::DirStruct &  theStepVector,
154                          CORBA::Long               theNbOfSteps,
155                          CORBA::Long               theExtrFlags,
156                          CORBA::Double             theSewTolerance);
157
158   SMESH::SMESH_MeshEditor::Extrusion_Error
159     ExtrusionAlongPath(const SMESH::long_array &   IDsOfElements,
160                        SMESH::SMESH_Mesh_ptr       PathMesh,
161                        GEOM::GEOM_Object_ptr       PathShape,
162                        CORBA::Long                 NodeStart,
163                        CORBA::Boolean              HasAngles,
164                        const SMESH::double_array & Angles,
165                        CORBA::Boolean              HasRefPoint,
166                        const SMESH::PointStruct &  RefPoint);
167
168   SMESH::SMESH_MeshEditor::Extrusion_Error
169     ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr   theObject,
170                              SMESH::SMESH_Mesh_ptr       PathMesh,
171                              GEOM::GEOM_Object_ptr       PathShape,
172                              CORBA::Long                 NodeStart,
173                              CORBA::Boolean              HasAngles,
174                              const SMESH::double_array & Angles,
175                              CORBA::Boolean              HasRefPoint,
176                              const SMESH::PointStruct &  RefPoint);
177
178   SMESH::double_array* LinearAnglesVariation(SMESH::SMESH_Mesh_ptr       PathMesh,
179                                              GEOM::GEOM_Object_ptr       PathShape,
180                                              const SMESH::double_array & Angles);
181
182   void Mirror(const SMESH::long_array &           IDsOfElements,
183               const SMESH::AxisStruct &           Axis,
184               SMESH::SMESH_MeshEditor::MirrorType MirrorType,
185               CORBA::Boolean                      Copy);
186   void MirrorObject(SMESH::SMESH_IDSource_ptr           theObject,
187                     const SMESH::AxisStruct &           Axis,
188                     SMESH::SMESH_MeshEditor::MirrorType MirrorType,
189                     CORBA::Boolean                      Copy);
190   void Translate(const SMESH::long_array & IDsOfElements,
191                  const SMESH::DirStruct &   Vector,
192                  CORBA::Boolean            Copy);
193   void TranslateObject(SMESH::SMESH_IDSource_ptr  theObject,
194                        const SMESH::DirStruct &   Vector,
195                        CORBA::Boolean             Copy);
196   void Rotate(const SMESH::long_array & IDsOfElements,
197               const SMESH::AxisStruct &  Axis,
198               CORBA::Double             Angle,
199               CORBA::Boolean            Copy);
200   void RotateObject(SMESH::SMESH_IDSource_ptr  theObject,
201                     const SMESH::AxisStruct &  Axis,
202                     CORBA::Double              Angle,
203                     CORBA::Boolean             Copy);
204
205   void FindCoincidentNodes (CORBA::Double                  Tolerance,
206                             SMESH::array_of_long_array_out GroupsOfNodes);
207   void FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr      theObject,
208                                  CORBA::Double                  Tolerance,
209                                  SMESH::array_of_long_array_out GroupsOfNodes);
210   void MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes);
211   void FindEqualElements(SMESH::SMESH_IDSource_ptr      theObject,
212                          SMESH::array_of_long_array_out GroupsOfElementsID);
213   void MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID);
214   void MergeEqualElements();
215   CORBA::Long MoveClosestNodeToPoint(CORBA::Double x,
216                                      CORBA::Double y,
217                                      CORBA::Double z,
218                                      CORBA::Long   nodeID);
219
220
221
222   SMESH::SMESH_MeshEditor::Sew_Error
223     SewFreeBorders(CORBA::Long FirstNodeID1,
224                    CORBA::Long SecondNodeID1,
225                    CORBA::Long LastNodeID1,
226                    CORBA::Long FirstNodeID2,
227                    CORBA::Long SecondNodeID2,
228                    CORBA::Long LastNodeID2,
229                    CORBA::Boolean CreatePolygons,
230                    CORBA::Boolean CreatePolyedrs);
231   SMESH::SMESH_MeshEditor::Sew_Error
232     SewConformFreeBorders(CORBA::Long FirstNodeID1,
233                           CORBA::Long SecondNodeID1,
234                           CORBA::Long LastNodeID1,
235                           CORBA::Long FirstNodeID2,
236                           CORBA::Long SecondNodeID2);
237   SMESH::SMESH_MeshEditor::Sew_Error
238     SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
239                     CORBA::Long SecondNodeIDOnFreeBorder,
240                     CORBA::Long LastNodeIDOnFreeBorder,
241                     CORBA::Long FirstNodeIDOnSide,
242                     CORBA::Long LastNodeIDOnSide,
243                     CORBA::Boolean CreatePolygons,
244                     CORBA::Boolean CreatePolyedrs);
245   SMESH::SMESH_MeshEditor::Sew_Error
246     SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
247                     const SMESH::long_array& IDsOfSide2Elements,
248                     CORBA::Long NodeID1OfSide1ToMerge,
249                     CORBA::Long NodeID1OfSide2ToMerge,
250                     CORBA::Long NodeID2OfSide1ToMerge,
251                     CORBA::Long NodeID2OfSide2ToMerge);
252
253   /*!
254    * Set new nodes for given element.
255    * If number of nodes is not corresponded to type of
256    * element - returns false
257    */
258   CORBA::Boolean ChangeElemNodes(CORBA::Long ide, const SMESH::long_array& newIDs);
259   
260   /*!
261    * Return data of mesh edition preview
262    */
263   SMESH::MeshPreviewStruct* GetPreviewData();
264
265   /*!
266    * If during last operation of MeshEditor some nodes were
267    * created this method returns list of it's IDs, if new nodes
268    * not creared - returns empty list
269    */
270   SMESH::long_array* GetLastCreatedNodes();
271
272   /*!
273    * If during last operation of MeshEditor some elements were
274    * created this method returns list of it's IDs, if new elements
275    * not creared - returns empty list
276    */
277   SMESH::long_array* GetLastCreatedElems();
278
279   //
280   // Internal methods
281   //
282
283   /*!
284    * \brief Update myLastCreated* or myPreviewData
285     * \param anEditor - it contains edition results
286    */
287   void StoreResult(::SMESH_MeshEditor& anEditor);
288
289   /*!
290    * \brief Return edited mesh ID
291     * \retval int - mesh ID
292    */
293   int GetMeshId() const { return myMesh->GetId(); }
294
295  private:
296
297   SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
298   void initData();
299
300   SMESH_Mesh *          myMesh;
301
302   SMESH::long_array_var myLastCreatedElems;
303   SMESH::long_array_var myLastCreatedNodes;
304
305   SMESH::MeshPreviewStruct_var myPreviewData;
306   bool                         myPreviewMode;
307 };
308
309 #endif