1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
23 // File : SMESH_MeshEditor_i.hxx
24 // Author : Nicolas REJNERI
28 #ifndef _SMESH_MESHEDITOR_I_HXX_
29 #define _SMESH_MESHEDIOTR_I_HXX_
33 #include <SALOMEconfig.h>
34 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
36 #include "SMESH_Mesh.hxx"
37 #include "SMESH_PythonDump.hxx"
40 class SMESH_MeshEditor;
43 class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
46 SMESH_MeshEditor_i(SMESH_Mesh_i * theMesh, bool isPreview);
48 virtual ~ SMESH_MeshEditor_i();
51 CORBA::Boolean RemoveElements(const SMESH::long_array & IDsOfElements);
52 CORBA::Boolean RemoveNodes(const SMESH::long_array & IDsOfNodes);
55 * Methods for creation new elements.
56 * Returns ID of created element or 0 if element not created
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);
68 * \brief Bind a node to a vertex
69 * \param NodeID - node ID
70 * \param VertexID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
72 void SetNodeOnVertex(CORBA::Long NodeID, CORBA::Long VertexID)
73 throw (SALOME::SALOME_Exception);
75 * \brief Store node position on an edge
76 * \param NodeID - node ID
77 * \param EdgeID - edge ID available through GEOM_Object.GetSubShapeIndices()[0]
78 * \param paramOnEdge - parameter on edge where the node is located
80 void SetNodeOnEdge(CORBA::Long NodeID, CORBA::Long EdgeID,
81 CORBA::Double paramOnEdge)
82 throw (SALOME::SALOME_Exception);
84 * \brief Store node position on a face
85 * \param NodeID - node ID
86 * \param FaceID - face ID available through GEOM_Object.GetSubShapeIndices()[0]
87 * \param u - U parameter on face where the node is located
88 * \param v - V parameter on face where the node is located
90 void SetNodeOnFace(CORBA::Long NodeID, CORBA::Long FaceID,
91 CORBA::Double u, CORBA::Double v)
92 throw (SALOME::SALOME_Exception);
94 * \brief Bind a node to a solid
95 * \param NodeID - node ID
96 * \param SolidID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
98 void SetNodeInVolume(CORBA::Long NodeID, CORBA::Long SolidID)
99 throw (SALOME::SALOME_Exception);
101 * \brief Bind an element to a shape
102 * \param ElementID - element ID
103 * \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
105 void SetMeshElementOnShape(CORBA::Long ElementID, CORBA::Long ShapeID)
106 throw (SALOME::SALOME_Exception);
109 CORBA::Boolean MoveNode(CORBA::Long NodeID,
110 CORBA::Double x, CORBA::Double y, CORBA::Double z);
112 CORBA::Boolean InverseDiag(CORBA::Long NodeID1, CORBA::Long NodeID2);
113 CORBA::Boolean DeleteDiag(CORBA::Long NodeID1, CORBA::Long NodeID2);
114 CORBA::Boolean Reorient(const SMESH::long_array & IDsOfElements);
115 CORBA::Boolean ReorientObject(SMESH::SMESH_IDSource_ptr theObject);
118 CORBA::Boolean TriToQuad (const SMESH::long_array & IDsOfElements,
119 SMESH::NumericalFunctor_ptr Criterion,
120 CORBA::Double MaxAngle);
121 CORBA::Boolean TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
122 SMESH::NumericalFunctor_ptr Criterion,
123 CORBA::Double MaxAngle);
124 CORBA::Boolean QuadToTri (const SMESH::long_array & IDsOfElements,
125 SMESH::NumericalFunctor_ptr Criterion);
126 CORBA::Boolean QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
127 SMESH::NumericalFunctor_ptr Criterion);
128 CORBA::Boolean SplitQuad (const SMESH::long_array & IDsOfElements,
129 CORBA::Boolean Diag13);
130 CORBA::Boolean SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
131 CORBA::Boolean Diag13);
132 CORBA::Long BestSplit (CORBA::Long IDOfQuad,
133 SMESH::NumericalFunctor_ptr Criterion);
135 CORBA::Boolean Smooth(const SMESH::long_array & IDsOfElements,
136 const SMESH::long_array & IDsOfFixedNodes,
137 CORBA::Long MaxNbOfIterations,
138 CORBA::Double MaxAspectRatio,
139 SMESH::SMESH_MeshEditor::Smooth_Method Method);
140 CORBA::Boolean SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
141 const SMESH::long_array & IDsOfFixedNodes,
142 CORBA::Long MaxNbOfIterations,
143 CORBA::Double MaxAspectRatio,
144 SMESH::SMESH_MeshEditor::Smooth_Method Method);
145 CORBA::Boolean SmoothParametric(const SMESH::long_array & IDsOfElements,
146 const SMESH::long_array & IDsOfFixedNodes,
147 CORBA::Long MaxNbOfIterations,
148 CORBA::Double MaxAspectRatio,
149 SMESH::SMESH_MeshEditor::Smooth_Method Method);
150 CORBA::Boolean SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject,
151 const SMESH::long_array & IDsOfFixedNodes,
152 CORBA::Long MaxNbOfIterations,
153 CORBA::Double MaxAspectRatio,
154 SMESH::SMESH_MeshEditor::Smooth_Method Method);
155 CORBA::Boolean smooth(const SMESH::long_array & IDsOfElements,
156 const SMESH::long_array & IDsOfFixedNodes,
157 CORBA::Long MaxNbOfIterations,
158 CORBA::Double MaxAspectRatio,
159 SMESH::SMESH_MeshEditor::Smooth_Method Method,
161 CORBA::Boolean smoothObject(SMESH::SMESH_IDSource_ptr theObject,
162 const SMESH::long_array & IDsOfFixedNodes,
163 CORBA::Long MaxNbOfIterations,
164 CORBA::Double MaxAspectRatio,
165 SMESH::SMESH_MeshEditor::Smooth_Method Method,
169 void ConvertToQuadratic(CORBA::Boolean Force3d);
170 CORBA::Boolean ConvertFromQuadratic();
172 void RenumberNodes();
173 void RenumberElements();
175 void RotationSweep(const SMESH::long_array & IDsOfElements,
176 const SMESH::AxisStruct & Axis,
177 CORBA::Double AngleInRadians,
178 CORBA::Long NbOfSteps,
179 CORBA::Double Tolerance);
180 void RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
181 const SMESH::AxisStruct & Axis,
182 CORBA::Double AngleInRadians,
183 CORBA::Long NbOfSteps,
184 CORBA::Double Tolerance);
186 void ExtrusionSweep(const SMESH::long_array & IDsOfElements,
187 const SMESH::DirStruct & StepVector,
188 CORBA::Long NbOfSteps);
189 void ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
190 const SMESH::DirStruct & StepVector,
191 CORBA::Long NbOfSteps);
192 void ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
193 const SMESH::DirStruct & StepVector,
194 CORBA::Long NbOfSteps);
195 void ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
196 const SMESH::DirStruct & StepVector,
197 CORBA::Long NbOfSteps);
198 void AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
199 const SMESH::DirStruct & theStepVector,
200 CORBA::Long theNbOfSteps,
201 CORBA::Long theExtrFlags,
202 CORBA::Double theSewTolerance);
204 SMESH::SMESH_MeshEditor::Extrusion_Error
205 ExtrusionAlongPath(const SMESH::long_array & IDsOfElements,
206 SMESH::SMESH_Mesh_ptr PathMesh,
207 GEOM::GEOM_Object_ptr PathShape,
208 CORBA::Long NodeStart,
209 CORBA::Boolean HasAngles,
210 const SMESH::double_array & Angles,
211 CORBA::Boolean HasRefPoint,
212 const SMESH::PointStruct & RefPoint);
214 SMESH::SMESH_MeshEditor::Extrusion_Error
215 ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
216 SMESH::SMESH_Mesh_ptr PathMesh,
217 GEOM::GEOM_Object_ptr PathShape,
218 CORBA::Long NodeStart,
219 CORBA::Boolean HasAngles,
220 const SMESH::double_array & Angles,
221 CORBA::Boolean HasRefPoint,
222 const SMESH::PointStruct & RefPoint);
224 SMESH::double_array* LinearAnglesVariation(SMESH::SMESH_Mesh_ptr PathMesh,
225 GEOM::GEOM_Object_ptr PathShape,
226 const SMESH::double_array & Angles);
228 void Mirror(const SMESH::long_array & IDsOfElements,
229 const SMESH::AxisStruct & Axis,
230 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
231 CORBA::Boolean Copy);
232 void MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
233 const SMESH::AxisStruct & Axis,
234 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
235 CORBA::Boolean Copy);
236 void Translate(const SMESH::long_array & IDsOfElements,
237 const SMESH::DirStruct & Vector,
238 CORBA::Boolean Copy);
239 void TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
240 const SMESH::DirStruct & Vector,
241 CORBA::Boolean Copy);
242 void Rotate(const SMESH::long_array & IDsOfElements,
243 const SMESH::AxisStruct & Axis,
245 CORBA::Boolean Copy);
246 void RotateObject(SMESH::SMESH_IDSource_ptr theObject,
247 const SMESH::AxisStruct & Axis,
249 CORBA::Boolean Copy);
251 SMESH::ListOfGroups* RotationSweepMakeGroups(const SMESH::long_array& IDsOfElements,
252 const SMESH::AxisStruct& Axix,
253 CORBA::Double AngleInRadians,
254 CORBA::Long NbOfSteps,
255 CORBA::Double Tolerance);
256 SMESH::ListOfGroups* RotationSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
257 const SMESH::AxisStruct& Axix,
258 CORBA::Double AngleInRadians,
259 CORBA::Long NbOfSteps,
260 CORBA::Double Tolerance);
261 SMESH::ListOfGroups* ExtrusionSweepMakeGroups(const SMESH::long_array& IDsOfElements,
262 const SMESH::DirStruct& StepVector,
263 CORBA::Long NbOfSteps);
264 SMESH::ListOfGroups* AdvancedExtrusionMakeGroups(const SMESH::long_array& IDsOfElements,
265 const SMESH::DirStruct& StepVector,
266 CORBA::Long NbOfSteps,
267 CORBA::Long ExtrFlags,
268 CORBA::Double SewTolerance);
269 SMESH::ListOfGroups* ExtrusionSweepObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
270 const SMESH::DirStruct& StepVector,
271 CORBA::Long NbOfSteps);
272 SMESH::ListOfGroups* ExtrusionSweepObject1DMakeGroups(SMESH::SMESH_IDSource_ptr Object,
273 const SMESH::DirStruct& StepVector,
274 CORBA::Long NbOfSteps);
275 SMESH::ListOfGroups* ExtrusionSweepObject2DMakeGroups(SMESH::SMESH_IDSource_ptr Object,
276 const SMESH::DirStruct& StepVector,
277 CORBA::Long NbOfSteps);
278 SMESH::ListOfGroups* ExtrusionAlongPathMakeGroups(const SMESH::long_array& IDsOfElements,
279 SMESH::SMESH_Mesh_ptr PathMesh,
280 GEOM::GEOM_Object_ptr PathShape,
281 CORBA::Long NodeStart,
282 CORBA::Boolean HasAngles,
283 const SMESH::double_array& Angles,
284 CORBA::Boolean HasRefPoint,
285 const SMESH::PointStruct& RefPoint,
286 SMESH::SMESH_MeshEditor::Extrusion_Error& Error);
287 SMESH::ListOfGroups* ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
288 SMESH::SMESH_Mesh_ptr PathMesh,
289 GEOM::GEOM_Object_ptr PathShape,
290 CORBA::Long NodeStart,
291 CORBA::Boolean HasAngles,
292 const SMESH::double_array& Angles,
293 CORBA::Boolean HasRefPoint,
294 const SMESH::PointStruct& RefPoint,
295 SMESH::SMESH_MeshEditor::Extrusion_Error& Error);
296 SMESH::ListOfGroups* MirrorMakeGroups(const SMESH::long_array& IDsOfElements,
297 const SMESH::AxisStruct& Mirror,
298 SMESH::SMESH_MeshEditor::MirrorType MirrorType);
299 SMESH::ListOfGroups* MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
300 const SMESH::AxisStruct& Mirror,
301 SMESH::SMESH_MeshEditor::MirrorType MirrorType);
302 SMESH::ListOfGroups* TranslateMakeGroups(const SMESH::long_array& IDsOfElements,
303 const SMESH::DirStruct& Vector);
304 SMESH::ListOfGroups* TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
305 const SMESH::DirStruct& Vector);
306 SMESH::ListOfGroups* RotateMakeGroups(const SMESH::long_array& IDsOfElements,
307 const SMESH::AxisStruct& Axis,
308 CORBA::Double AngleInRadians);
309 SMESH::ListOfGroups* RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
310 const SMESH::AxisStruct& Axis,
311 CORBA::Double AngleInRadians);
313 SMESH::SMESH_Mesh_ptr MirrorMakeMesh(const SMESH::long_array& IDsOfElements,
314 const SMESH::AxisStruct& Mirror,
315 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
316 CORBA::Boolean CopyGroups,
317 const char* MeshName);
318 SMESH::SMESH_Mesh_ptr MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr Object,
319 const SMESH::AxisStruct& Mirror,
320 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
321 CORBA::Boolean CopyGroups,
322 const char* MeshName);
323 SMESH::SMESH_Mesh_ptr TranslateMakeMesh(const SMESH::long_array& IDsOfElements,
324 const SMESH::DirStruct& Vector,
325 CORBA::Boolean CopyGroups,
326 const char* MeshName);
327 SMESH::SMESH_Mesh_ptr TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr Object,
328 const SMESH::DirStruct& Vector,
329 CORBA::Boolean CopyGroups,
330 const char* MeshName);
331 SMESH::SMESH_Mesh_ptr RotateMakeMesh(const SMESH::long_array& IDsOfElements,
332 const SMESH::AxisStruct& Axis,
333 CORBA::Double AngleInRadians,
334 CORBA::Boolean CopyGroups,
335 const char* MeshName);
336 SMESH::SMESH_Mesh_ptr RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr Object,
337 const SMESH::AxisStruct& Axis,
338 CORBA::Double AngleInRadians,
339 CORBA::Boolean CopyGroups,
340 const char* MeshName);
342 void FindCoincidentNodes (CORBA::Double Tolerance,
343 SMESH::array_of_long_array_out GroupsOfNodes);
344 void FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr Object,
345 CORBA::Double Tolerance,
346 SMESH::array_of_long_array_out GroupsOfNodes);
347 void MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes);
348 void FindEqualElements(SMESH::SMESH_IDSource_ptr Object,
349 SMESH::array_of_long_array_out GroupsOfElementsID);
350 void MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID);
351 void MergeEqualElements();
352 CORBA::Long MoveClosestNodeToPoint(CORBA::Double x,
359 SMESH::SMESH_MeshEditor::Sew_Error
360 SewFreeBorders(CORBA::Long FirstNodeID1,
361 CORBA::Long SecondNodeID1,
362 CORBA::Long LastNodeID1,
363 CORBA::Long FirstNodeID2,
364 CORBA::Long SecondNodeID2,
365 CORBA::Long LastNodeID2,
366 CORBA::Boolean CreatePolygons,
367 CORBA::Boolean CreatePolyedrs);
368 SMESH::SMESH_MeshEditor::Sew_Error
369 SewConformFreeBorders(CORBA::Long FirstNodeID1,
370 CORBA::Long SecondNodeID1,
371 CORBA::Long LastNodeID1,
372 CORBA::Long FirstNodeID2,
373 CORBA::Long SecondNodeID2);
374 SMESH::SMESH_MeshEditor::Sew_Error
375 SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder,
376 CORBA::Long SecondNodeIDOnFreeBorder,
377 CORBA::Long LastNodeIDOnFreeBorder,
378 CORBA::Long FirstNodeIDOnSide,
379 CORBA::Long LastNodeIDOnSide,
380 CORBA::Boolean CreatePolygons,
381 CORBA::Boolean CreatePolyedrs);
382 SMESH::SMESH_MeshEditor::Sew_Error
383 SewSideElements(const SMESH::long_array& IDsOfSide1Elements,
384 const SMESH::long_array& IDsOfSide2Elements,
385 CORBA::Long NodeID1OfSide1ToMerge,
386 CORBA::Long NodeID1OfSide2ToMerge,
387 CORBA::Long NodeID2OfSide1ToMerge,
388 CORBA::Long NodeID2OfSide2ToMerge);
391 * Set new nodes for given element.
392 * If number of nodes is not corresponded to type of
393 * element - returns false
395 CORBA::Boolean ChangeElemNodes(CORBA::Long ide, const SMESH::long_array& newIDs);
398 * Return data of mesh edition preview
400 SMESH::MeshPreviewStruct* GetPreviewData();
403 * If during last operation of MeshEditor some nodes were
404 * created this method returns list of it's IDs, if new nodes
405 * not creared - returns empty list
407 SMESH::long_array* GetLastCreatedNodes();
410 * If during last operation of MeshEditor some elements were
411 * created this method returns list of it's IDs, if new elements
412 * not creared - returns empty list
414 SMESH::long_array* GetLastCreatedElems();
417 * \brief Return edited mesh ID
418 * \retval int - mesh ID
420 int GetMeshId() const { return myMesh->GetId(); }
423 private: //!< private methods
425 SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
428 * \brief Update myLastCreated* or myPreviewData
429 * \param anEditor - it contains edition results
431 void storeResult(::SMESH_MeshEditor& anEditor);
433 * \brief Clear myLastCreated* or myPreviewData
438 * \brief Return groups by their IDs
440 SMESH::ListOfGroups* getGroups(const std::list<int>* groupIDs);
442 SMESH::ListOfGroups* rotationSweep(const SMESH::long_array & IDsOfElements,
443 const SMESH::AxisStruct & Axis,
444 CORBA::Double AngleInRadians,
445 CORBA::Long NbOfSteps,
446 CORBA::Double Tolerance,
447 const bool MakeGroups);
448 SMESH::ListOfGroups* extrusionSweep(const SMESH::long_array & IDsOfElements,
449 const SMESH::DirStruct & StepVector,
450 CORBA::Long NbOfSteps,
451 const bool MakeGroups,
452 const SMDSAbs_ElementType ElementType=SMDSAbs_All);
453 SMESH::ListOfGroups* advancedExtrusion(const SMESH::long_array & theIDsOfElements,
454 const SMESH::DirStruct & theStepVector,
455 CORBA::Long theNbOfSteps,
456 CORBA::Long theExtrFlags,
457 CORBA::Double theSewTolerance,
458 const bool MakeGroups);
459 SMESH::ListOfGroups* extrusionAlongPath(const SMESH::long_array & IDsOfElements,
460 SMESH::SMESH_Mesh_ptr PathMesh,
461 GEOM::GEOM_Object_ptr PathShape,
462 CORBA::Long NodeStart,
463 CORBA::Boolean HasAngles,
464 const SMESH::double_array & Angles,
465 CORBA::Boolean HasRefPoint,
466 const SMESH::PointStruct & RefPoint,
467 const bool MakeGroups,
468 SMESH::SMESH_MeshEditor::Extrusion_Error & Error);
469 SMESH::ListOfGroups* mirror(const SMESH::long_array & IDsOfElements,
470 const SMESH::AxisStruct & Axis,
471 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
473 const bool MakeGroups,
474 ::SMESH_Mesh* TargetMesh=0);
475 SMESH::ListOfGroups* translate(const SMESH::long_array & IDsOfElements,
476 const SMESH::DirStruct & Vector,
478 const bool MakeGroups,
479 ::SMESH_Mesh* TargetMesh=0);
480 SMESH::ListOfGroups* rotate(const SMESH::long_array & IDsOfElements,
481 const SMESH::AxisStruct & Axis,
484 const bool MakeGroups,
485 ::SMESH_Mesh* TargetMesh=0);
487 SMESH::SMESH_Mesh_ptr makeMesh(const char* theMeshName);
489 void DumpGroupsList(SMESH::TPythonDump & theDumpPython,
490 const SMESH::ListOfGroups * theGroupList);
494 SMESH_Mesh_i* myMesh_i;
497 SMESH::long_array_var myLastCreatedElems;
498 SMESH::long_array_var myLastCreatedNodes;
500 SMESH::MeshPreviewStruct_var myPreviewData;