Salome HOME
A patch by Paul RASCLE for ASTER cluster (64 bits).
[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 MergeEqualElements();
212   CORBA::Long MoveClosestNodeToPoint(CORBA::Double x,
213                                      CORBA::Double y,
214                                      CORBA::Double z,
215                                      CORBA::Long   nodeID);
216
217
218
219   SMESH::SMESH_MeshEditor::Sew_Error
220     SewFreeBorders(CORBA::Long FirstNodeID1,
221                    CORBA::Long SecondNodeID1,
222                    CORBA::Long LastNodeID1,
223                    CORBA::Long FirstNodeID2,
224                    CORBA::Long SecondNodeID2,
225                    CORBA::Long LastNodeID2,
226                    CORBA::Boolean CreatePolygons,
227                    CORBA::Boolean CreatePolyedrs);
228   SMESH::SMESH_MeshEditor::Sew_Error
229     SewConformFreeBorders(CORBA::Long FirstNodeID1,
230                           CORBA::Long SecondNodeID1,
231                           CORBA::Long LastNodeID1,
232                           CORBA::Long FirstNodeID2,
233                           CORBA::Long SecondNodeID2);
234   SMESH::SMESH_MeshEditor::Sew_Error
235     SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
236                     CORBA::Long SecondNodeIDOnFreeBorder,
237                     CORBA::Long LastNodeIDOnFreeBorder,
238                     CORBA::Long FirstNodeIDOnSide,
239                     CORBA::Long LastNodeIDOnSide,
240                     CORBA::Boolean CreatePolygons,
241                     CORBA::Boolean CreatePolyedrs);
242   SMESH::SMESH_MeshEditor::Sew_Error
243     SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
244                     const SMESH::long_array& IDsOfSide2Elements,
245                     CORBA::Long NodeID1OfSide1ToMerge,
246                     CORBA::Long NodeID1OfSide2ToMerge,
247                     CORBA::Long NodeID2OfSide1ToMerge,
248                     CORBA::Long NodeID2OfSide2ToMerge);
249
250   /*!
251    * Set new nodes for given element.
252    * If number of nodes is not corresponded to type of
253    * element - returns false
254    */
255   CORBA::Boolean ChangeElemNodes(CORBA::Long ide, const SMESH::long_array& newIDs);
256   
257   /*!
258    * Return data of mesh edition preview
259    */
260   SMESH::MeshPreviewStruct* GetPreviewData();
261
262   /*!
263    * If during last operation of MeshEditor some nodes were
264    * created this method returns list of it's IDs, if new nodes
265    * not creared - returns empty list
266    */
267   SMESH::long_array* GetLastCreatedNodes();
268
269   /*!
270    * If during last operation of MeshEditor some elements were
271    * created this method returns list of it's IDs, if new elements
272    * not creared - returns empty list
273    */
274   SMESH::long_array* GetLastCreatedElems();
275
276   //
277   // Internal methods
278   //
279
280   /*!
281    * \brief Update myLastCreated* or myPreviewData
282     * \param anEditor - it contains edition results
283    */
284   void StoreResult(::SMESH_MeshEditor& anEditor);
285
286   /*!
287    * \brief Return edited mesh ID
288     * \retval int - mesh ID
289    */
290   int GetMeshId() const { return myMesh->GetId(); }
291
292  private:
293
294   SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
295   void initData();
296
297   SMESH_Mesh *          myMesh;
298
299   SMESH::long_array_var myLastCreatedElems;
300   SMESH::long_array_var myLastCreatedNodes;
301
302   SMESH::MeshPreviewStruct_var myPreviewData;
303   bool                         myPreviewMode;
304 };
305
306 #endif