1 // Copyright (C) 2007-2022 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, or (at your option) any later version.
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
23 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
24 // File : SMESH_MeshEditor_i.hxx
25 // 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"
38 #include "SMESH_MeshEditor.hxx"
44 namespace MeshEditor_I {
46 struct ExtrusionParams;
49 class SMESH_I_EXPORT SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
52 SMESH_MeshEditor_i(SMESH_Mesh_i * theMesh, bool isPreview);
54 virtual ~ SMESH_MeshEditor_i();
56 * \brief Return edited mesh ID
57 * \retval int - mesh ID
59 int GetMeshId() const { return myMesh->GetId(); }
61 SMESH::SMESH_Mesh_ptr GetMesh();
66 * Return data of mesh edition preview
68 SMESH::MeshPreviewStruct* GetPreviewData();
70 * If during last operation of MeshEditor some nodes were
71 * created this method returns list of their IDs, if new nodes
72 * not created - returns an empty list
74 SMESH::smIdType_array* GetLastCreatedNodes();
76 * If during last operation of MeshEditor some elements were
77 * created this method returns list of their IDs, if new elements
78 * not created - returns an empty list
80 SMESH::smIdType_array* GetLastCreatedElems();
82 * \brief Clears sequences of last created elements and nodes
84 void ClearLastCreated();
86 * \brief Returns description of an error/warning occurred during the last operation
88 SMESH::ComputeError* GetLastError();
91 * \brief Wrap a sequence of ids in a SMESH_IDSource
93 SMESH::SMESH_IDSource_ptr MakeIDSource(const SMESH::smIdType_array& IDsOfElements,
94 SMESH::ElementType type);
95 static bool IsTemporaryIDSource( SMESH::SMESH_IDSource_ptr& idSource );
96 static SMESH::smIdType* GetTemporaryIDs( SMESH::SMESH_IDSource_ptr& idSource, SMESH::smIdType& nbIds );
99 * \brief Generates the unique group name
101 std::string GenerateGroupName(const std::string& thePrefix);
103 CORBA::Boolean RemoveElements(const SMESH::smIdType_array & IDsOfElements);
104 CORBA::Boolean RemoveNodes (const SMESH::smIdType_array & IDsOfNodes);
105 SMESH::smIdType RemoveOrphanNodes();
106 void RemoveNodeWithReconnection(SMESH::smIdType nodeID);
109 * Methods for creation new elements.
110 * Returns ID of created element or 0 if element not created
112 SMESH::smIdType AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z);
113 SMESH::smIdType Add0DElement(SMESH::smIdType IDOfNode, CORBA::Boolean DuplicateElements);
114 SMESH::smIdType AddBall(SMESH::smIdType IDOfNodem, CORBA::Double diameter);
115 SMESH::smIdType AddEdge(const SMESH::smIdType_array & IDsOfNodes);
116 SMESH::smIdType AddFace(const SMESH::smIdType_array & IDsOfNodes);
117 SMESH::smIdType AddPolygonalFace(const SMESH::smIdType_array & IDsOfNodes);
118 SMESH::smIdType AddQuadPolygonalFace(const SMESH::smIdType_array & IDsOfNodes);
119 SMESH::smIdType AddVolume(const SMESH::smIdType_array & IDsOfNodes);
120 SMESH::smIdType AddPolyhedralVolume(const SMESH::smIdType_array & IDsOfNodes,
121 const SMESH::long_array & Quantities);
122 SMESH::smIdType AddPolyhedralVolumeByFaces(const SMESH::smIdType_array & IdsOfFaces);
125 * \brief Create 0D elements on all nodes of the given object except those
126 * nodes on which a 0D element already exists.
127 * \param theObject object on whose nodes 0D elements will be created.
128 * \param theGroupName optional name of a group to add 0D elements created
129 * and/or found on nodes of \a theObject.
130 * \param theDuplicateElements to add one more 0D element to a node or not
131 * \return an object (a new group or a temporary SMESH_IDSource) holding
132 * ids of new and/or found 0D elements.
134 SMESH::SMESH_IDSource_ptr Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObject,
135 const char* theGroupName,
136 CORBA::Boolean theDuplicateElements);
139 * \brief Bind a node to a vertex
140 * \param NodeID - node ID
141 * \param VertexID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
143 void SetNodeOnVertex(SMESH::smIdType NodeID, CORBA::Long VertexID);
145 * \brief Store node position on an edge
146 * \param NodeID - node ID
147 * \param EdgeID - edge ID available through GEOM_Object.GetSubShapeIndices()[0]
148 * \param paramOnEdge - parameter on edge where the node is located
150 void SetNodeOnEdge(SMESH::smIdType NodeID, CORBA::Long EdgeID,
151 CORBA::Double paramOnEdge);
153 * \brief Store node position on a face
154 * \param NodeID - node ID
155 * \param FaceID - face ID available through GEOM_Object.GetSubShapeIndices()[0]
156 * \param u - U parameter on face where the node is located
157 * \param v - V parameter on face where the node is located
159 void SetNodeOnFace(SMESH::smIdType NodeID, CORBA::Long FaceID,
160 CORBA::Double u, CORBA::Double v);
162 * \brief Bind a node to a solid
163 * \param NodeID - node ID
164 * \param SolidID - vertex ID available through GEOM_Object.GetSubShapeIndices()[0]
166 void SetNodeInVolume(SMESH::smIdType NodeID, CORBA::Long SolidID);
168 * \brief Bind an element to a shape
169 * \param ElementID - element ID
170 * \param ShapeID - shape ID available through GEOM_Object.GetSubShapeIndices()[0]
172 void SetMeshElementOnShape(SMESH::smIdType ElementID, CORBA::Long ShapeID);
175 * \brief Change node location
177 CORBA::Boolean MoveNode(SMESH::smIdType NodeID,
178 CORBA::Double x, CORBA::Double y, CORBA::Double z);
181 * \brief Swap a diagonal of a quadrangle formed by two adjacent triangles
183 CORBA::Boolean InverseDiag(SMESH::smIdType NodeID1, SMESH::smIdType NodeID2);
185 * \brief Delete a diagonal of a quadrangle formed by two adjacent triangles
186 * so that a new quadrangle appears in place of the triangles
188 CORBA::Boolean DeleteDiag(SMESH::smIdType NodeID1, SMESH::smIdType NodeID2);
190 * \brief Split a diagonal of a quadrangle formed by two adjacent triangles
191 * so that four new triangles appear in place of the two triangles
193 void AddNodeOnSegment(SMESH::smIdType segmentNode1, SMESH::smIdType segmentNode2,
194 CORBA::Double position);
196 * \brief Split a face into triangles by adding a new node onto the face
197 * and connecting the new node with face nodes
199 void AddNodeOnFace(SMESH::smIdType triangle,
200 CORBA::Double x, CORBA::Double y, CORBA::Double z);
203 * \brief Change orientation of cells
205 CORBA::Boolean Reorient(const SMESH::smIdType_array & IDsOfElements);
207 * \brief Change orientation of cells
209 CORBA::Boolean ReorientObject(SMESH::SMESH_IDSource_ptr theObject);
211 * \brief Reorient faces contained in \a the2Dgroup.
212 * \param the2Dgroup - the mesh or its part to reorient
213 * \param theDirection - desired direction of normal of \a theFace
214 * \param theFace - ID of face whose orientation is checked.
215 * It can be < 1 then \a thePoint is used to find a face.
216 * \param thePoint - is used to find a face if \a theFace < 1.
217 * \return number of reoriented elements.
219 CORBA::Long Reorient2D(SMESH::SMESH_IDSource_ptr the2Dgroup,
220 const SMESH::DirStruct& theDirection,
222 const SMESH::PointStruct& thePoint);
224 * \brief Reorient faces contained in a list of \a objectFaces
225 * equally to faces contained in a list of \a referenceFaces.
226 * \param objectFaces - faces to reorient in a list including either
227 * the whole mesh or groups and/or sub-meshes.
228 * \param referenceFaces - correctly oriented faces in a list of groups and/or sub-meshes.
229 * It can be empty, then the 1st face in \a objectFaces is used as the reference.
230 * \return number of reoriented faces.
232 CORBA::Long Reorient2DByNeighbours(const SMESH::ListOfIDSources& objectFaces,
233 const SMESH::ListOfIDSources& referenceFaces);
235 * \brief Reorient faces basing on orientation of adjacent volumes.
236 * \param faces - a list of objects containing face to reorient
237 * \param volumes - an object containing volumes.
238 * \param outsideNormal - to orient faces to have their normal
239 * pointing either \a outside or \a inside the adjacent volumes.
240 * \return number of reoriented faces.
242 CORBA::Long Reorient2DBy3D(const SMESH::ListOfIDSources & faces,
243 SMESH::SMESH_IDSource_ptr volumes,
244 CORBA::Boolean outsideNormal);
247 CORBA::Boolean TriToQuad (const SMESH::smIdType_array & IDsOfElements,
248 SMESH::NumericalFunctor_ptr Criterion,
249 CORBA::Double MaxAngle);
250 CORBA::Boolean TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
251 SMESH::NumericalFunctor_ptr Criterion,
252 CORBA::Double MaxAngle);
253 CORBA::Boolean QuadToTri (const SMESH::smIdType_array & IDsOfElements,
254 SMESH::NumericalFunctor_ptr Criterion);
255 CORBA::Boolean QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
256 SMESH::NumericalFunctor_ptr Criterion);
257 void QuadTo4Tri (SMESH::SMESH_IDSource_ptr theObject);
258 CORBA::Boolean SplitQuad (const SMESH::smIdType_array & IDsOfElements,
259 CORBA::Boolean Diag13);
260 CORBA::Boolean SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
261 CORBA::Boolean Diag13);
262 CORBA::Short BestSplit (SMESH::smIdType IDOfQuad,
263 SMESH::NumericalFunctor_ptr Criterion);
264 void SplitVolumesIntoTetra(SMESH::SMESH_IDSource_ptr elems,
265 CORBA::Short methodFlags);
266 void SplitHexahedraIntoPrisms(SMESH::SMESH_IDSource_ptr elems,
267 const SMESH::PointStruct & startHexPoint,
268 const SMESH::DirStruct& facetToSplitNormal,
269 CORBA::Short methodFlags,
270 CORBA::Boolean allDomains);
271 void SplitBiQuadraticIntoLinear(const SMESH::ListOfIDSources& elems);
273 CORBA::Boolean Smooth(const SMESH::smIdType_array & IDsOfElements,
274 const SMESH::smIdType_array & IDsOfFixedNodes,
275 CORBA::Short MaxNbOfIterations,
276 CORBA::Double MaxAspectRatio,
277 SMESH::SMESH_MeshEditor::Smooth_Method Method);
278 CORBA::Boolean SmoothObject(SMESH::SMESH_IDSource_ptr theObject,
279 const SMESH::smIdType_array & IDsOfFixedNodes,
280 CORBA::Short MaxNbOfIterations,
281 CORBA::Double MaxAspectRatio,
282 SMESH::SMESH_MeshEditor::Smooth_Method Method);
283 CORBA::Boolean SmoothParametric(const SMESH::smIdType_array & IDsOfElements,
284 const SMESH::smIdType_array & IDsOfFixedNodes,
285 CORBA::Short MaxNbOfIterations,
286 CORBA::Double MaxAspectRatio,
287 SMESH::SMESH_MeshEditor::Smooth_Method Method) ;
288 CORBA::Boolean SmoothParametricObject(SMESH::SMESH_IDSource_ptr theObject,
289 const SMESH::smIdType_array & IDsOfFixedNodes,
290 CORBA::Short MaxNbOfIterations,
291 CORBA::Double MaxAspectRatio,
292 SMESH::SMESH_MeshEditor::Smooth_Method Method);
293 CORBA::Boolean smooth(const SMESH::smIdType_array & IDsOfElements,
294 const SMESH::smIdType_array & IDsOfFixedNodes,
295 CORBA::Short MaxNbOfIterations,
296 CORBA::Double MaxAspectRatio,
297 SMESH::SMESH_MeshEditor::Smooth_Method Method,
299 CORBA::Boolean smoothObject(SMESH::SMESH_IDSource_ptr theObject,
300 const SMESH::smIdType_array & IDsOfFixedNodes,
301 CORBA::Short MaxNbOfIterations,
302 CORBA::Double MaxAspectRatio,
303 SMESH::SMESH_MeshEditor::Smooth_Method Method,
306 CORBA::Boolean ConvertFromQuadratic();
307 void ConvertFromQuadraticObject(SMESH::SMESH_IDSource_ptr theObject);
308 void ConvertToQuadratic(CORBA::Boolean Force3d);
309 void ConvertToQuadraticObject(CORBA::Boolean theForce3d,
310 SMESH::SMESH_IDSource_ptr theObject);
311 void ConvertToBiQuadratic(CORBA::Boolean theForce3d,
312 SMESH::SMESH_IDSource_ptr theObject);
314 void RenumberNodes();
315 void RenumberElements();
317 SMESH::ListOfGroups* RotationSweepObjects(const SMESH::ListOfIDSources & Nodes,
318 const SMESH::ListOfIDSources & Edges,
319 const SMESH::ListOfIDSources & Faces,
320 const SMESH::AxisStruct & Axis,
321 CORBA::Double AngleInRadians,
322 CORBA::Long NbOfSteps,
323 CORBA::Double Tolerance,
324 CORBA::Boolean ToMakeGroups);
326 SMESH::ListOfGroups* ExtrusionSweepObjects(const SMESH::ListOfIDSources & Nodes,
327 const SMESH::ListOfIDSources & Edges,
328 const SMESH::ListOfIDSources & Faces,
329 const SMESH::DirStruct & StepVector,
330 CORBA::Long NbOfSteps,
331 CORBA::Boolean ToMakeGroups,
332 const SMESH::double_array & ScaleFactors,
333 CORBA::Boolean ScalesVariation,
334 const SMESH::double_array & BasePoint,
335 const SMESH::double_array & Angles,
336 CORBA::Boolean AnglesVariation);
338 SMESH::ListOfGroups* ExtrusionByNormal(const SMESH::ListOfIDSources& objects,
339 CORBA::Double stepSize,
340 CORBA::Long nbOfSteps,
341 CORBA::Boolean byAverageNormal,
342 CORBA::Boolean useInputElemsOnly,
343 CORBA::Boolean makeGroups,
345 SMESH::ListOfGroups* AdvancedExtrusion(const SMESH::smIdType_array & theIDsOfElements,
346 const SMESH::DirStruct & theStepVector,
347 CORBA::Long theNbOfSteps,
348 CORBA::Long theExtrFlags,
349 CORBA::Double theSewTolerance,
350 CORBA::Boolean theMakeGroups);
353 ExtrusionAlongPathObjects(const SMESH::ListOfIDSources & Nodes,
354 const SMESH::ListOfIDSources & Edges,
355 const SMESH::ListOfIDSources & Faces,
356 SMESH::SMESH_IDSource_ptr PathMesh,
357 GEOM::GEOM_Object_ptr PathShape,
358 SMESH::smIdType NodeStart,
359 CORBA::Boolean HasAngles,
360 const SMESH::double_array & Angles,
361 CORBA::Boolean AnglesVariation,
362 CORBA::Boolean HasRefPoint,
363 const SMESH::PointStruct & RefPoint,
365 const SMESH::double_array & ScaleFactors,
366 CORBA::Boolean ScalesVariation,
367 SMESH::SMESH_MeshEditor::Extrusion_Error& Error);
369 SMESH::double_array* LinearAnglesVariation(SMESH::SMESH_Mesh_ptr PathMesh,
370 GEOM::GEOM_Object_ptr PathShape,
371 const SMESH::double_array & Angles);
373 void Mirror(const SMESH::smIdType_array & IDsOfElements,
374 const SMESH::AxisStruct & Axis,
375 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
376 CORBA::Boolean Copy);
377 void MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
378 const SMESH::AxisStruct & Axis,
379 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
380 CORBA::Boolean Copy);
381 void Translate(const SMESH::smIdType_array & IDsOfElements,
382 const SMESH::DirStruct & Vector,
383 CORBA::Boolean Copy);
384 void TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
385 const SMESH::DirStruct & Vector,
386 CORBA::Boolean Copy);
387 void Rotate(const SMESH::smIdType_array & IDsOfElements,
388 const SMESH::AxisStruct & Axis,
390 CORBA::Boolean Copy);
391 void RotateObject(SMESH::SMESH_IDSource_ptr theObject,
392 const SMESH::AxisStruct & Axis,
394 CORBA::Boolean Copy);
396 SMESH::ListOfGroups* MirrorMakeGroups(const SMESH::smIdType_array& IDsOfElements,
397 const SMESH::AxisStruct& Mirror,
398 SMESH::SMESH_MeshEditor::MirrorType MirrorType);
399 SMESH::ListOfGroups* MirrorObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
400 const SMESH::AxisStruct& Mirror,
401 SMESH::SMESH_MeshEditor::MirrorType MirrorType);
402 SMESH::ListOfGroups* TranslateMakeGroups(const SMESH::smIdType_array& IDsOfElements,
403 const SMESH::DirStruct& Vector);
404 SMESH::ListOfGroups* TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
405 const SMESH::DirStruct& Vector);
406 SMESH::ListOfGroups* RotateMakeGroups(const SMESH::smIdType_array& IDsOfElements,
407 const SMESH::AxisStruct& Axis,
408 CORBA::Double AngleInRadians);
409 SMESH::ListOfGroups* RotateObjectMakeGroups(SMESH::SMESH_IDSource_ptr Object,
410 const SMESH::AxisStruct& Axis,
411 CORBA::Double AngleInRadians);
413 SMESH::SMESH_Mesh_ptr MirrorMakeMesh(const SMESH::smIdType_array& IDsOfElements,
414 const SMESH::AxisStruct& Mirror,
415 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
416 CORBA::Boolean CopyGroups,
417 const char* MeshName);
418 SMESH::SMESH_Mesh_ptr MirrorObjectMakeMesh(SMESH::SMESH_IDSource_ptr Object,
419 const SMESH::AxisStruct& Mirror,
420 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
421 CORBA::Boolean CopyGroups,
422 const char* MeshName);
423 SMESH::SMESH_Mesh_ptr TranslateMakeMesh(const SMESH::smIdType_array& IDsOfElements,
424 const SMESH::DirStruct& Vector,
425 CORBA::Boolean CopyGroups,
426 const char* MeshName);
427 SMESH::SMESH_Mesh_ptr TranslateObjectMakeMesh(SMESH::SMESH_IDSource_ptr Object,
428 const SMESH::DirStruct& Vector,
429 CORBA::Boolean CopyGroups,
430 const char* MeshName);
431 SMESH::SMESH_Mesh_ptr RotateMakeMesh(const SMESH::smIdType_array& IDsOfElements,
432 const SMESH::AxisStruct& Axis,
433 CORBA::Double AngleInRadians,
434 CORBA::Boolean CopyGroups,
435 const char* MeshName);
436 SMESH::SMESH_Mesh_ptr RotateObjectMakeMesh(SMESH::SMESH_IDSource_ptr Object,
437 const SMESH::AxisStruct& Axis,
438 CORBA::Double AngleInRadians,
439 CORBA::Boolean CopyGroups,
440 const char* MeshName);
442 void Scale(SMESH::SMESH_IDSource_ptr theObject,
443 const SMESH::PointStruct& thePoint,
444 const SMESH::double_array& theScaleFact,
445 CORBA::Boolean theCopy);
447 SMESH::ListOfGroups* ScaleMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
448 const SMESH::PointStruct& thePoint,
449 const SMESH::double_array& theScaleFact);
451 SMESH::SMESH_Mesh_ptr ScaleMakeMesh(SMESH::SMESH_IDSource_ptr Object,
452 const SMESH::PointStruct& Point,
453 const SMESH::double_array& theScaleFact,
454 CORBA::Boolean CopyGroups,
455 const char* MeshName);
457 SMESH::SMESH_Mesh_ptr Offset( SMESH::SMESH_IDSource_ptr theObject,
459 CORBA::Boolean CopyGroups,
460 CORBA::Boolean CopyElements,
461 const char* MeshName,
462 SMESH::ListOfGroups_out Groups);
464 void FindCoincidentNodes (CORBA::Double Tolerance,
465 SMESH::array_of_long_array_out GroupsOfNodes,
466 CORBA::Boolean SeparateCornersAndMedium);
467 void FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr Object,
468 CORBA::Double Tolerance,
469 SMESH::array_of_long_array_out GroupsOfNodes,
470 CORBA::Boolean SeparateCornersAndMedium);
471 void FindCoincidentNodesOnPartBut(const SMESH::ListOfIDSources& Objects,
472 CORBA::Double Tolerance,
473 SMESH::array_of_long_array_out GroupsOfNodes,
474 const SMESH::ListOfIDSources& ExceptSubMeshOrGroups,
475 CORBA::Boolean SeparateCornersAndMedium);
476 void MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes,
477 const SMESH::ListOfIDSources& NodesToKeep,
478 CORBA::Boolean AvoidMakingHoles );
479 void FindEqualElements(const SMESH::ListOfIDSources& Objects,
480 const SMESH::ListOfIDSources& ExceptSubMeshOrGroups,
481 SMESH::array_of_long_array_out GroupsOfElementsID);
482 void MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID,
483 const SMESH::ListOfIDSources& ElementsToKeep);
484 void MergeEqualElements();
485 SMESH::smIdType MoveClosestNodeToPoint(CORBA::Double x,
488 SMESH::smIdType nodeID);
490 * \brief Return ID of node closest to a given point
492 SMESH::smIdType FindNodeClosestTo(CORBA::Double x,
496 * Return elements of given type where the given point is IN or ON.
497 * 'ALL' type means elements of any type excluding nodes
499 SMESH::smIdType_array* FindElementsByPoint(CORBA::Double x,
502 SMESH::ElementType type);
504 * Searching among the given elements, return elements of given type
505 * where the given point is IN or ON.
506 * 'ALL' type means elements of any type excluding nodes
508 SMESH::smIdType_array* FindAmongElementsByPoint(SMESH::SMESH_IDSource_ptr elements,
512 SMESH::ElementType type);
515 * Project a point to a mesh object.
516 * Return ID of an element of given type where the given point is projected
517 * and coordinates of the projection point.
518 * In the case if nothing found, return -1 and []
520 SMESH::smIdType ProjectPoint(CORBA::Double x,
523 SMESH::ElementType type,
524 SMESH::SMESH_IDSource_ptr meshObject,
525 SMESH::double_array_out projecton);
528 * Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
529 * TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
531 CORBA::Short GetPointState(CORBA::Double x, CORBA::Double y, CORBA::Double z);
534 * Check if a 2D mesh is manifold
536 CORBA::Boolean IsManifold();
539 * Check if orientation of 2D elements is coherent
541 CORBA::Boolean IsCoherentOrientation2D();
544 * Partition given 1D elements into groups of contiguous edges.
545 * A node where number of meeting edges != 2 is a group end.
546 * An optional startNode is used to orient groups it belongs to.
547 * \return a list of edge groups and a list of corresponding node groups.
548 * If a group is closed, the first and last nodes of the group are same.
550 SMESH::array_of_long_array* Get1DBranches( SMESH::SMESH_IDSource_ptr edges,
551 SMESH::smIdType startNode,
552 SMESH::array_of_long_array_out nodeGroups);
555 * Return sharp edges of faces and non-manifold ones. Optionally adds existing edges.
557 SMESH::ListOfEdges* FindSharpEdges(CORBA::Double angle, CORBA::Boolean addExisting);
560 * Returns all or only closed FreeBorder's.
562 SMESH::ListOfFreeBorders* FindFreeBorders(CORBA::Boolean closedOnly);
565 * Fill with 2D elements a hole defined by a FreeBorder.
566 * Optionally add new faces to a given group, which is returned
568 SMESH::SMESH_Group_ptr FillHole(const SMESH::FreeBorder& hole,
569 const char* groupName);
571 SMESH::CoincidentFreeBorders* FindCoincidentFreeBorders(CORBA::Double tolerance);
572 CORBA::Short SewCoincidentFreeBorders(const SMESH::CoincidentFreeBorders& freeBorders,
573 CORBA::Boolean createPolygons,
574 CORBA::Boolean createPolyedrs);
576 SMESH::SMESH_MeshEditor::Sew_Error
577 SewFreeBorders(SMESH::smIdType FirstNodeID1,
578 SMESH::smIdType SecondNodeID1,
579 SMESH::smIdType LastNodeID1,
580 SMESH::smIdType FirstNodeID2,
581 SMESH::smIdType SecondNodeID2,
582 SMESH::smIdType LastNodeID2,
583 CORBA::Boolean CreatePolygons,
584 CORBA::Boolean CreatePolyedrs);
585 SMESH::SMESH_MeshEditor::Sew_Error
586 SewConformFreeBorders(SMESH::smIdType FirstNodeID1,
587 SMESH::smIdType SecondNodeID1,
588 SMESH::smIdType LastNodeID1,
589 SMESH::smIdType FirstNodeID2,
590 SMESH::smIdType SecondNodeID2);
591 SMESH::SMESH_MeshEditor::Sew_Error
592 SewBorderToSide(SMESH::smIdType FirstNodeIDOnFreeBorder,
593 SMESH::smIdType SecondNodeIDOnFreeBorder,
594 SMESH::smIdType LastNodeIDOnFreeBorder,
595 SMESH::smIdType FirstNodeIDOnSide,
596 SMESH::smIdType LastNodeIDOnSide,
597 CORBA::Boolean CreatePolygons,
598 CORBA::Boolean CreatePolyedrs);
599 SMESH::SMESH_MeshEditor::Sew_Error
600 SewSideElements(const SMESH::smIdType_array& IDsOfSide1Elements,
601 const SMESH::smIdType_array& IDsOfSide2Elements,
602 SMESH::smIdType NodeID1OfSide1ToMerge,
603 SMESH::smIdType NodeID1OfSide2ToMerge,
604 SMESH::smIdType NodeID2OfSide1ToMerge,
605 SMESH::smIdType NodeID2OfSide2ToMerge);
608 * Set new nodes for given element.
609 * If number of nodes is not corresponded to type of
610 * element - returns false
612 CORBA::Boolean ChangeElemNodes(SMESH::smIdType ide, const SMESH::smIdType_array& newIDs);
614 SMESH::SMESH_Group_ptr DoubleElements(SMESH::SMESH_IDSource_ptr theElements,
615 const char* theGroupName);
617 CORBA::Boolean DoubleNodes( const SMESH::smIdType_array& theNodes,
618 const SMESH::smIdType_array& theModifiedElems );
620 CORBA::Boolean DoubleNode( SMESH::smIdType theNodeId,
621 const SMESH::smIdType_array& theModifiedElems );
623 CORBA::Boolean DoubleNodeGroup( SMESH::SMESH_GroupBase_ptr theNodes,
624 SMESH::SMESH_GroupBase_ptr theModifiedElems );
627 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
628 * Works as DoubleNodeGroup(), but returns a new group with newly created nodes.
629 * \param theNodes - group of nodes to be doubled.
630 * \param theModifiedElems - group of elements to be updated.
631 * \return a new group with newly created nodes
632 * \sa DoubleNodeGroup()
634 SMESH::SMESH_Group_ptr DoubleNodeGroupNew( SMESH::SMESH_GroupBase_ptr theNodes,
635 SMESH::SMESH_GroupBase_ptr theModifiedElems );
637 CORBA::Boolean DoubleNodeGroups( const SMESH::ListOfGroups& theNodes,
638 const SMESH::ListOfGroups& theModifiedElems );
640 SMESH::SMESH_Group_ptr DoubleNodeGroupsNew( const SMESH::ListOfGroups& theNodes,
641 const SMESH::ListOfGroups& theModifiedElems );
644 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
645 * \param theElems - the list of elements (edges or faces) to be replicated
646 * The nodes for duplication could be found from these elements
647 * \param theNodesNot - list of nodes to NOT replicate
648 * \param theAffectedElems - the list of elements (cells and edges) to which the
649 * replicated nodes should be associated to.
650 * \return TRUE if operation has been completed successfully, FALSE otherwise
651 * \sa DoubleNodeGroup(), DoubleNodeGroups()
653 CORBA::Boolean DoubleNodeElem( const SMESH::smIdType_array& theElems,
654 const SMESH::smIdType_array& theNodesNot,
655 const SMESH::smIdType_array& theAffectedElems );
658 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
659 * \param theElems - the list of elements (edges or faces) to be replicated
660 * The nodes for duplication could be found from these elements
661 * \param theNodesNot - list of nodes to NOT replicate
662 * \param theShape - shape to detect affected elements (element which geometric center
663 * located on or inside shape).
664 * The replicated nodes should be associated to affected elements.
665 * \return TRUE if operation has been completed successfully, FALSE otherwise
666 * \sa DoubleNodeGroupInRegion(), DoubleNodeGroupsInRegion()
668 CORBA::Boolean DoubleNodeElemInRegion( const SMESH::smIdType_array& theElems,
669 const SMESH::smIdType_array& theNodesNot,
670 GEOM::GEOM_Object_ptr theShape );
673 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
674 * \param theElems - group of of elements (edges or faces) to be replicated
675 * \param theNodesNot - group of nodes not to replicated
676 * \param theAffectedElems - group of elements to which the replicated nodes
677 * should be associated to.
678 * \return TRUE if operation has been completed successfully, FALSE otherwise
679 * \sa DoubleNodes(), DoubleNodeGroups(), DoubleNodeElemGroupNew()
681 CORBA::Boolean DoubleNodeElemGroup( SMESH::SMESH_GroupBase_ptr theElems,
682 SMESH::SMESH_GroupBase_ptr theNodesNot,
683 SMESH::SMESH_GroupBase_ptr theAffectedElems );
686 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
687 * Works as DoubleNodeElemGroup(), but returns a new group with newly created elements.
688 * \param theElems - group of of elements (edges or faces) to be replicated
689 * \param theNodesNot - group of nodes not to replicated
690 * \param theAffectedElems - group of elements to which the replicated nodes
691 * should be associated to.
692 * \return a new group with newly created elements
693 * \sa DoubleNodeElemGroup()
695 SMESH::SMESH_Group_ptr DoubleNodeElemGroupNew( SMESH::SMESH_GroupBase_ptr theElems,
696 SMESH::SMESH_GroupBase_ptr theNodesNot,
697 SMESH::SMESH_GroupBase_ptr theAffectedElems );
699 SMESH::ListOfGroups* DoubleNodeElemGroup2New(SMESH::SMESH_GroupBase_ptr theElems,
700 SMESH::SMESH_GroupBase_ptr theNodesNot,
701 SMESH::SMESH_GroupBase_ptr theAffectedElems,
702 CORBA::Boolean theElemGroupNeeded,
703 CORBA::Boolean theNodeGroupNeeded);
706 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
707 * \param theElems - group of of elements (edges or faces) to be replicated
708 * \param theNodesNot - group of nodes not to replicated
709 * \param theShape - shape to detect affected elements (element which geometric center
710 * located on or inside shape).
711 * The replicated nodes should be associated to affected elements.
712 * \return TRUE if operation has been completed successfully, FALSE otherwise
713 * \sa DoubleNodesInRegion(), DoubleNodeGroupsInRegion()
715 CORBA::Boolean DoubleNodeElemGroupInRegion( SMESH::SMESH_GroupBase_ptr theElems,
716 SMESH::SMESH_GroupBase_ptr theNodesNot,
717 GEOM::GEOM_Object_ptr theShape );
720 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
721 * This method provided for convenience works as DoubleNodes() described above.
722 * \param theElems - list of groups of elements (edges or faces) to be replicated
723 * \param theNodesNot - list of groups of nodes not to replicated
724 * \param theAffectedElems - group of elements to which the replicated nodes
725 * should be associated to.
726 * \return TRUE if operation has been completed successfully, FALSE otherwise
727 * \sa DoubleNodeGroup(), DoubleNodes(), DoubleNodeElemGroupsNew()
729 CORBA::Boolean DoubleNodeElemGroups( const SMESH::ListOfGroups& theElems,
730 const SMESH::ListOfGroups& theNodesNot,
731 const SMESH::ListOfGroups& theAffectedElems );
734 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
735 * Works as DoubleNodeElemGroups(), but returns a new group with newly created elements.
736 * \param theElems - list of groups of elements (edges or faces) to be replicated
737 * \param theNodesNot - list of groups of nodes not to replicated
738 * \param theAffectedElems - group of elements to which the replicated nodes
739 * should be associated to.
740 * \return a new group with newly created elements
741 * \sa DoubleNodeElemGroups()
743 SMESH::SMESH_Group_ptr DoubleNodeElemGroupsNew( const SMESH::ListOfGroups& theElems,
744 const SMESH::ListOfGroups& theNodesNot,
745 const SMESH::ListOfGroups& theAffectedElems );
747 SMESH::ListOfGroups* DoubleNodeElemGroups2New(const SMESH::ListOfGroups& theElems,
748 const SMESH::ListOfGroups& theNodesNot,
749 const SMESH::ListOfGroups& theAffectedElems,
750 CORBA::Boolean theElemGroupNeeded,
751 CORBA::Boolean theNodeGroupNeeded);
754 * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
755 * This method provided for convenience works as DoubleNodes() described above.
756 * \param theElems - list of groups of elements (edges or faces) to be replicated
757 * \param theNodesNot - list of groups of nodes not to replicated
758 * \param theShape - shape to detect affected elements (element which geometric center
759 * located on or inside shape).
760 * The replicated nodes should be associated to affected elements.
761 * \return TRUE if operation has been completed successfully, FALSE otherwise
762 * \sa DoubleNodeGroupInRegion(), DoubleNodesInRegion()
764 CORBA::Boolean DoubleNodeElemGroupsInRegion( const SMESH::ListOfGroups& theElems,
765 const SMESH::ListOfGroups& theNodesNot,
766 GEOM::GEOM_Object_ptr theShape );
769 * \brief Identify the elements that will be affected by node duplication (actual duplication is not performed.
770 * This method is the first step of DoubleNodeElemGroupsInRegion.
771 * \param theElems - list of groups of elements (edges or faces) to be replicated
772 * \param theNodesNot - list of groups of nodes not to replicated
773 * \param theShape - shape to detect affected elements (element which geometric center
774 * located on or inside shape).
775 * The replicated nodes should be associated to affected elements.
776 * \return groups of affected elements
777 * \sa DoubleNodeElemGroupsInRegion()
779 SMESH::ListOfGroups* AffectedElemGroupsInRegion( const SMESH::ListOfGroups& theElems,
780 const SMESH::ListOfGroups& theNodesNot,
781 GEOM::GEOM_Object_ptr theShape );
784 * \brief Double nodes on shared faces between groups of volumes and create flat elements on demand.
785 * The list of groups must describe a partition of the mesh volumes.
786 * The nodes of the internal faces at the boundaries of the groups are doubled.
787 * In option, the internal faces are replaced by flat elements.
788 * Triangles are transformed in prisms, and quadrangles in hexahedrons.
789 * \param theDomains - list of groups of volumes
790 * \param createJointElems - if TRUE, create the elements
791 * \param onAllBoundaries - if TRUE, the nodes and elements are also create on
792 * the boundary between \a theDomains and the rest mesh
793 * \return TRUE if operation has been completed successfully, FALSE otherwise
795 CORBA::Boolean DoubleNodesOnGroupBoundaries( const SMESH::ListOfGroups& theDomains,
796 CORBA::Boolean createJointElems,
797 CORBA::Boolean onAllBoundaries );
799 * \brief Double nodes on some external faces and create flat elements.
800 * Flat elements are mainly used by some types of mechanic calculations.
802 * Each group of the list must be constituted of faces.
803 * Triangles are transformed in prisms, and quadrangles in hexahedrons.
804 * @param theGroupsOfFaces - list of groups of faces
805 * @return TRUE if operation has been completed successfully, FALSE otherwise
807 CORBA::Boolean CreateFlatElementsOnFacesGroups( const SMESH::ListOfGroups& theGroupsOfFaces );
810 * \brief identify all the elements around a geom shape, get the faces delimiting the hole
811 * Build groups of volume to remove, groups of faces to replace on the skin of the object,
812 * groups of faces to remove insidethe object, (idem edges).
813 * Build ordered list of nodes at the border of each group of faces to replace (to be used to build a geom subshape)
815 void CreateHoleSkin(CORBA::Double radius,
816 GEOM::GEOM_Object_ptr theShape,
817 const char* groupName,
818 const SMESH::double_array& theNodesCoords,
819 SMESH::array_of_long_array_out GroupsOfNodes);
822 * \brief Generated skin mesh (containing 2D cells) from 3D mesh
823 * The created 2D mesh elements based on nodes of free faces of boundary volumes
824 * \return TRUE if operation has been completed successfully, FALSE otherwise
826 CORBA::Boolean Make2DMeshFrom3D();
828 SMESH::SMESH_Mesh_ptr MakeBoundaryMesh(SMESH::SMESH_IDSource_ptr elements,
829 SMESH::Bnd_Dimension dimension,
830 const char* groupName,
831 const char* meshName,
832 CORBA::Boolean toCopyElements,
833 CORBA::Boolean toCopyMissingBondary,
834 SMESH::SMESH_Group_out group);
836 CORBA::Long MakeBoundaryElements(SMESH::Bnd_Dimension dimension,
837 const char* groupName,
838 const char* meshName,
839 CORBA::Boolean toCopyAll,
840 const SMESH::ListOfIDSources& groups,
841 SMESH::SMESH_Mesh_out mesh,
842 SMESH::SMESH_Group_out group);
845 * \brief Create a polyline consisting of 1D mesh elements each lying on a 2D element of
846 * the initial mesh. Positions of new nodes are found by cutting the mesh by the
847 * plane passing through pairs of points specified by each PolySegment structure.
848 * If there are several paths connecting a pair of points, the shortest path is
849 * selected by the module. Position of the cutting plane is defined by the two
850 * points and an optional vector lying on the plane specified by a PolySegment.
851 * By default the vector is defined by Mesh module as following. A middle point
852 * of the two given points is computed. The middle point is projected to the mesh.
853 * The vector goes from the middle point to the projection point. In case of planar
854 * mesh, the vector is normal to the mesh.
855 * \param [inout] segments - PolySegment's defining positions of cutting planes.
856 * Return the used vector and position of the middle point.
857 * \param [in] groupName - optional name of a group where created mesh segments will
860 void MakePolyLine(SMESH::ListOfPolySegments& segments,
861 const char* groupName);
864 * \brief Create a slot of given width around given 1D elements lying on a triangle mesh.
865 * The slot is constructed by cutting faces by cylindrical surfaces made
866 * around each segment. Segments are expected to be created by MakePolyLine().
867 * \return Edges located at the slot boundary
869 SMESH::ListOfEdges* MakeSlot(SMESH::SMESH_GroupBase_ptr segments,
870 CORBA::Double width);
873 private: //!< private methods
875 ::SMESH_MeshEditor& getEditor();
877 SMESHDS_Mesh * getMeshDS() { return myMesh->GetMeshDS(); }
879 MeshEditor_I::TPreviewMesh * getPreviewMesh( SMDSAbs_ElementType previewType = SMDSAbs_All );
881 void declareMeshModified( bool isReComputeSafe );
884 * \brief Clear myLastCreated* or myPreviewData
886 void initData(bool deleteSearchers=true);
889 * \brief Return groups by their IDs
891 SMESH::ListOfGroups* getGroups(const std::list<int>* groupIDs);
893 SMESH::ListOfGroups* mirror(TIDSortedElemSet & IDsOfElements,
894 const SMESH::AxisStruct & Axis,
895 SMESH::SMESH_MeshEditor::MirrorType MirrorType,
898 ::SMESH_Mesh* TargetMesh=0);
899 SMESH::ListOfGroups* translate(TIDSortedElemSet & IDsOfElements,
900 const SMESH::DirStruct & Vector,
903 ::SMESH_Mesh* TargetMesh=0);
904 SMESH::ListOfGroups* rotate(TIDSortedElemSet & IDsOfElements,
905 const SMESH::AxisStruct & Axis,
909 ::SMESH_Mesh* TargetMesh=0);
911 SMESH::ListOfGroups* scale(SMESH::SMESH_IDSource_ptr theObject,
912 const SMESH::PointStruct& thePoint,
913 const SMESH::double_array& theScaleFact,
914 CORBA::Boolean theCopy,
916 ::SMESH_Mesh* theTargetMesh=0);
918 void convertToQuadratic(CORBA::Boolean theForce3d,
919 CORBA::Boolean theToBiQuad,
920 SMESH::SMESH_IDSource_ptr theObject = SMESH::SMESH_IDSource::_nil());
922 SMESH::SMESH_Mesh_ptr makeMesh(const char* theMeshName);
924 void dumpGroupsList(SMESH::TPythonDump & theDumpPython,
925 const SMESH::ListOfGroups * theGroupList);
927 void prepareIdSource(SMESH::SMESH_IDSource_ptr theObject);
930 enum IDSource_Error { IDSource_OK, IDSource_INVALID, IDSource_EMPTY };
932 bool idSourceToSet(SMESH::SMESH_IDSource_ptr theIDSource,
933 const SMESHDS_Mesh* theMeshDS,
934 TIDSortedElemSet& theElemSet,
935 const SMDSAbs_ElementType theType,
936 const bool emptyIfIsMesh = false,
937 IDSource_Error* error = 0);
939 void findCoincidentNodes( TIDSortedNodeSet & Nodes,
940 CORBA::Double Tolerance,
941 SMESH::array_of_long_array_out GroupsOfNodes,
942 CORBA::Boolean SeparateCornersAndMedium);
948 SMESH_Mesh_i* myMesh_i;
950 ::SMESH_MeshEditor myEditor;
952 bool myIsPreviewMode;
953 MeshEditor_I::TPreviewMesh * myPreviewMesh;
954 ::SMESH_MeshEditor * myPreviewEditor;
955 SMESH::MeshPreviewStruct_var myPreviewData;
957 // temporary IDSources