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