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