1 // Copyright (C) 2007-2013 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
23 // File : SMESH_MeshEditor.hxx
24 // Created : Mon Apr 12 14:56:19 2004
25 // Author : Edward AGAPOV (eap)
28 #ifndef SMESH_MeshEditor_HeaderFile
29 #define SMESH_MeshEditor_HeaderFile
31 #include "SMESH_SMESH.hxx"
33 #include "SMDS_MeshElement.hxx"
34 #include "SMESH_Controls.hxx"
35 #include "SMESH_Mesh.hxx"
36 #include "SMESH_TypeDefs.hxx"
37 #include "SMESH_ComputeError.hxx"
39 #include <utilities.h>
41 #include <TColStd_HSequenceOfReal.hxx>
53 class SMESH_MesherHelper;
56 //=======================================================================
58 * \brief Searcher for the node closest to point
60 //=======================================================================
61 struct SMESH_NodeSearcher
63 virtual const SMDS_MeshNode* FindClosestTo( const gp_Pnt& pnt ) = 0;
64 virtual void MoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt ) = 0;
67 //=======================================================================
69 * \brief Searcher for elements
71 //=======================================================================
73 struct SMESH_ElementSearcher
76 * \brief Find elements of given type where the given point is IN or ON.
77 * Returns nb of found elements and elements them-selves.
79 * 'ALL' type means elements of any type excluding nodes and 0D elements
81 virtual int FindElementsByPoint(const gp_Pnt& point,
82 SMDSAbs_ElementType type,
83 std::vector< const SMDS_MeshElement* >& foundElems)=0;
85 * \brief Return an element most close to the given point
87 virtual const SMDS_MeshElement* FindClosestTo( const gp_Pnt& point,
88 SMDSAbs_ElementType type) = 0;
90 * \brief Return elements possibly intersecting the line
92 virtual void GetElementsNearLine( const gp_Ax1& line,
93 SMDSAbs_ElementType type,
94 std::vector< const SMDS_MeshElement* >& foundElems)=0;
96 * \brief Find out if the given point is out of closed 2D mesh.
98 virtual TopAbs_State GetPointState(const gp_Pnt& point) = 0;
102 // ============================================================
104 * \brief Editor of a mesh
106 // ============================================================
108 class SMESH_EXPORT SMESH_MeshEditor
112 SMESH_MeshEditor( SMESH_Mesh* theMesh );
114 SMESH_Mesh * GetMesh() { return myMesh; }
115 SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
117 const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
118 const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
119 void CrearLastCreated();
120 SMESH_ComputeErrorPtr & GetError() { return myError; }
125 SMDS_MeshElement* AddElement(const std::vector<const SMDS_MeshNode*> & nodes,
126 const SMDSAbs_ElementType type,
129 const double ballDiameter=0.);
133 SMDS_MeshElement* AddElement(const std::vector<int> & nodeIDs,
134 const SMDSAbs_ElementType type,
138 int Remove (const std::list< int >& theElemIDs, const bool isNodes);
139 // Remove a node or an element.
140 // Modify a compute state of sub-meshes which become empty
142 void Create0DElementsOnAllNodes( const TIDSortedElemSet& elements,
143 TIDSortedElemSet& all0DElems);
144 // Create 0D elements on all nodes of the given object except those
145 // nodes on which a 0D element already exists. \a all0DElems returns
146 // all 0D elements found or created on nodes of \a elements
148 bool InverseDiag (const SMDS_MeshElement * theTria1,
149 const SMDS_MeshElement * theTria2 );
150 // Replace two neighbour triangles with ones built on the same 4 nodes
151 // but having other common link.
152 // Return False if args are improper
154 bool InverseDiag (const SMDS_MeshNode * theNode1,
155 const SMDS_MeshNode * theNode2 );
156 // Replace two neighbour triangles sharing theNode1-theNode2 link
157 // with ones built on the same 4 nodes but having other common link.
158 // Return false if proper faces not found
160 bool DeleteDiag (const SMDS_MeshNode * theNode1,
161 const SMDS_MeshNode * theNode2 );
162 // Replace two neighbour triangles sharing theNode1-theNode2 link
163 // with a quadrangle built on the same 4 nodes.
164 // Return false if proper faces not found
166 bool Reorient (const SMDS_MeshElement * theElement);
167 // Reverse theElement orientation
169 int Reorient2D (TIDSortedElemSet & theFaces,
170 const gp_Dir& theDirection,
171 const SMDS_MeshElement * theFace);
172 // Reverse theFaces whose orientation to be same as that of theFace
173 // oriented according to theDirection. Return nb of reoriented faces
176 * \brief Fuse neighbour triangles into quadrangles.
177 * \param theElems - The triangles to be fused.
178 * \param theCriterion - Is used to choose a neighbour to fuse with.
179 * \param theMaxAngle - Is a max angle between element normals at which fusion
180 * is still performed; theMaxAngle is mesured in radians.
181 * \return bool - Success or not.
183 bool TriToQuad (TIDSortedElemSet & theElems,
184 SMESH::Controls::NumericalFunctorPtr theCriterion,
185 const double theMaxAngle);
188 * \brief Split quadrangles into triangles.
189 * \param theElems - The faces to be splitted.
190 * \param theCriterion - Is used to choose a diagonal for splitting.
191 * \return bool - Success or not.
193 bool QuadToTri (TIDSortedElemSet & theElems,
194 SMESH::Controls::NumericalFunctorPtr theCriterion);
197 * \brief Split quadrangles into triangles.
198 * \param theElems - The faces to be splitted.
199 * \param the13Diag - Is used to choose a diagonal for splitting.
200 * \return bool - Success or not.
202 bool QuadToTri (TIDSortedElemSet & theElems,
203 const bool the13Diag);
206 * \brief Find better diagonal for splitting.
207 * \param theQuad - The face to find better splitting of.
208 * \param theCriterion - Is used to choose a diagonal for splitting.
209 * \return int - 1 for 1-3 diagonal, 2 for 2-4, -1 - for errors.
211 int BestSplit (const SMDS_MeshElement* theQuad,
212 SMESH::Controls::NumericalFunctorPtr theCriterion);
215 enum SplitVolumToTetraFlags { HEXA_TO_5 = 1, HEXA_TO_6 = 2, HEXA_TO_24 = 3 };//!<arg of SplitVolumesIntoTetra()
217 * \brief Split volumic elements into tetrahedra.
219 void SplitVolumesIntoTetra (const TIDSortedElemSet & theElems, const int theMethodFlags);
222 enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL };
224 void Smooth (TIDSortedElemSet & theElements,
225 std::set<const SMDS_MeshNode*> & theFixedNodes,
226 const SmoothMethod theSmoothMethod,
227 const int theNbIterations,
228 double theTgtAspectRatio = 1.0,
229 const bool the2D = true);
230 // Smooth theElements using theSmoothMethod during theNbIterations
231 // or until a worst element has aspect ratio <= theTgtAspectRatio.
232 // Aspect Ratio varies in range [1.0, inf].
233 // If theElements is empty, the whole mesh is smoothed.
234 // theFixedNodes contains additionally fixed nodes. Nodes built
235 // on edges and boundary nodes are always fixed.
236 // If the2D, smoothing is performed using UV parameters of nodes
237 // on geometrical faces
239 typedef std::auto_ptr< std::list<int> > PGroupIDs;
241 PGroupIDs RotationSweep (TIDSortedElemSet & theElements,
242 const gp_Ax1& theAxis,
243 const double theAngle,
244 const int theNbSteps,
245 const double theToler,
246 const bool theMakeGroups,
247 const bool theMakeWalls=true);
248 // Generate new elements by rotation of theElements around theAxis
249 // by theAngle by theNbSteps
252 * Auxilary flag for advanced extrusion.
253 * BOUNDARY: create or not boundary for result of extrusion
254 * SEW: try to use existing nodes or create new nodes in any case
256 enum ExtrusionFlags {
257 EXTRUSION_FLAG_BOUNDARY = 0x01,
258 EXTRUSION_FLAG_SEW = 0x02
262 * special structure for control of extrusion functionality
265 gp_Dir myDir; // direction of extrusion
266 Handle(TColStd_HSequenceOfReal) mySteps; // magnitudes for each step
267 SMESH_SequenceOfNode myNodes; // nodes for using in sewing
271 * Create new node in the mesh with given coordinates
272 * (auxiliary for advanced extrusion)
274 const SMDS_MeshNode* CreateNode(const double x,
277 const double tolnode,
278 SMESH_SequenceOfNode& aNodes);
281 * Generate new elements by extrusion of theElements
282 * It is a method used in .idl file. All functionality
283 * is implemented in the next method (see below) which
284 * is used in the current method.
285 * @param theElems - list of elements for extrusion
286 * @param newElemsMap returns history of extrusion
287 * @param theFlags set flags for performing extrusion (see description
288 * of enum ExtrusionFlags for additional information)
289 * @param theTolerance - uses for comparing locations of nodes if flag
290 * EXTRUSION_FLAG_SEW is set
292 PGroupIDs ExtrusionSweep (TIDSortedElemSet & theElems,
293 const gp_Vec& theStep,
294 const int theNbSteps,
295 TElemOfElemListMap& newElemsMap,
296 const bool theMakeGroups,
297 const int theFlags = EXTRUSION_FLAG_BOUNDARY,
298 const double theTolerance = 1.e-6);
301 * Generate new elements by extrusion of theElements
302 * @param theElems - list of elements for extrusion
303 * @param newElemsMap returns history of extrusion
304 * @param theFlags set flags for performing extrusion (see description
305 * of enum ExtrusionFlags for additional information)
306 * @param theTolerance - uses for comparing locations of nodes if flag
307 * EXTRUSION_FLAG_SEW is set
308 * @param theParams - special structure for manage of extrusion
310 PGroupIDs ExtrusionSweep (TIDSortedElemSet & theElems,
311 ExtrusParam& theParams,
312 TElemOfElemListMap& newElemsMap,
313 const bool theMakeGroups,
315 const double theTolerance);
318 // Generate new elements by extrusion of theElements
319 // by theStep by theNbSteps
321 enum Extrusion_Error {
326 EXTR_BAD_STARTING_NODE,
327 EXTR_BAD_ANGLES_NUMBER,
328 EXTR_CANT_GET_TANGENT
331 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet & theElements,
332 SMESH_subMesh* theTrackPattern,
333 const SMDS_MeshNode* theNodeStart,
334 const bool theHasAngles,
335 std::list<double>& theAngles,
336 const bool theLinearVariation,
337 const bool theHasRefPoint,
338 const gp_Pnt& theRefPoint,
339 const bool theMakeGroups);
340 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet & theElements,
341 SMESH_Mesh* theTrackPattern,
342 const SMDS_MeshNode* theNodeStart,
343 const bool theHasAngles,
344 std::list<double>& theAngles,
345 const bool theLinearVariation,
346 const bool theHasRefPoint,
347 const gp_Pnt& theRefPoint,
348 const bool theMakeGroups);
349 // Generate new elements by extrusion of theElements along path given by theTrackPattern,
350 // theHasAngles are the rotation angles, base point can be given by theRefPoint
352 PGroupIDs Transform (TIDSortedElemSet & theElements,
353 const gp_Trsf& theTrsf,
355 const bool theMakeGroups,
356 SMESH_Mesh* theTargetMesh=0);
357 // Move or copy theElements applying theTrsf to their nodes
360 * \brief Return SMESH_NodeSearcher. The caller is responsible for deleteing it
362 SMESH_NodeSearcher* GetNodeSearcher();
365 * \brief Return SMESH_ElementSearcher. The caller is responsible for deleting it
367 SMESH_ElementSearcher* GetElementSearcher();
368 SMESH_ElementSearcher* GetElementSearcher( SMDS_ElemIteratorPtr elemIt );
370 typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
372 void FindCoincidentNodes (TIDSortedNodeSet & theNodes,
373 const double theTolerance,
374 TListOfListOfNodes & theGroupsOfNodes);
375 // Return list of group of nodes close to each other within theTolerance.
376 // Search among theNodes or in the whole mesh if theNodes is empty.
378 void MergeNodes (TListOfListOfNodes & theNodeGroups);
379 // In each group, the cdr of nodes are substituted by the first one
382 typedef std::list< std::list< int > > TListOfListOfElementsID;
384 void FindEqualElements(TIDSortedElemSet & theElements,
385 TListOfListOfElementsID & theGroupsOfElementsID);
386 // Return list of group of elements build on the same nodes.
387 // Search among theElements or in the whole mesh if theElements is empty.
389 void MergeElements(TListOfListOfElementsID & theGroupsOfElementsID);
390 // In each group remove all but first of elements.
392 void MergeEqualElements();
393 // Remove all but one of elements built on the same nodes.
394 // Return nb of successfully merged groups.
397 * \brief Return true if the point is IN or ON of the element
399 static bool IsOut( const SMDS_MeshElement* element, const gp_Pnt& point, double tol );
401 static double GetDistance( const SMDS_MeshFace* face, const gp_Pnt& point );
403 int SimplifyFace (const std::vector<const SMDS_MeshNode *> faceNodes,
404 std::vector<const SMDS_MeshNode *>& poly_nodes,
405 std::vector<int>& quantities) const;
406 // Split face, defined by <faceNodes>, into several faces by repeating nodes.
407 // Is used by MergeNodes()
409 static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1,
410 const SMDS_MeshNode* theNode2,
411 const SMDS_MeshNode* theNode3 = 0);
412 // Return true if the three nodes are on a free border
414 static bool FindFreeBorder (const SMDS_MeshNode* theFirstNode,
415 const SMDS_MeshNode* theSecondNode,
416 const SMDS_MeshNode* theLastNode,
417 std::list< const SMDS_MeshNode* > & theNodes,
418 std::list< const SMDS_MeshElement* >& theFaces);
419 // Return nodes and faces of a free border if found
423 // for SewFreeBorder()
424 SEW_BORDER1_NOT_FOUND,
425 SEW_BORDER2_NOT_FOUND,
426 SEW_BOTH_BORDERS_NOT_FOUND,
428 SEW_VOLUMES_TO_SPLIT,
429 // for SewSideElements()
430 SEW_DIFF_NB_OF_ELEMENTS,
431 SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
438 Sew_Error SewFreeBorder (const SMDS_MeshNode* theBorderFirstNode,
439 const SMDS_MeshNode* theBorderSecondNode,
440 const SMDS_MeshNode* theBorderLastNode,
441 const SMDS_MeshNode* theSide2FirstNode,
442 const SMDS_MeshNode* theSide2SecondNode,
443 const SMDS_MeshNode* theSide2ThirdNode = 0,
444 const bool theSide2IsFreeBorder = true,
445 const bool toCreatePolygons = false,
446 const bool toCreatePolyedrs = false);
447 // Sew the free border to the side2 by replacing nodes in
448 // elements on the free border with nodes of the elements
449 // of the side 2. If nb of links in the free border and
450 // between theSide2FirstNode and theSide2LastNode are different,
451 // additional nodes are inserted on a link provided that no
452 // volume elements share the splitted link.
453 // The side 2 is a free border if theSide2IsFreeBorder == true.
454 // Sewing is peformed between the given first, second and last
455 // nodes on the sides.
456 // theBorderFirstNode is merged with theSide2FirstNode.
457 // if (!theSide2IsFreeBorder) then theSide2SecondNode gives
458 // the last node on the side 2, which will be merged with
459 // theBorderLastNode.
460 // if (theSide2IsFreeBorder) then theSide2SecondNode will
461 // be merged with theBorderSecondNode.
462 // if (theSide2IsFreeBorder && theSide2ThirdNode == 0) then
463 // the 2 free borders are sewn link by link and no additional
464 // nodes are inserted.
465 // Return false, if sewing failed.
467 Sew_Error SewSideElements (TIDSortedElemSet& theSide1,
468 TIDSortedElemSet& theSide2,
469 const SMDS_MeshNode* theFirstNode1ToMerge,
470 const SMDS_MeshNode* theFirstNode2ToMerge,
471 const SMDS_MeshNode* theSecondNode1ToMerge,
472 const SMDS_MeshNode* theSecondNode2ToMerge);
473 // Sew two sides of a mesh. Nodes belonging to theSide1 are
474 // merged with nodes of elements of theSide2.
475 // Number of elements in theSide1 and in theSide2 must be
476 // equal and they should have similar node connectivity.
477 // The nodes to merge should belong to side s borders and
478 // the first node should be linked to the second.
480 void InsertNodesIntoLink(const SMDS_MeshElement* theFace,
481 const SMDS_MeshNode* theBetweenNode1,
482 const SMDS_MeshNode* theBetweenNode2,
483 std::list<const SMDS_MeshNode*>& theNodesToInsert,
484 const bool toCreatePoly = false);
485 // insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2.
486 // If toCreatePoly is true, replace theFace by polygon, else split theFace.
488 void UpdateVolumes (const SMDS_MeshNode* theBetweenNode1,
489 const SMDS_MeshNode* theBetweenNode2,
490 std::list<const SMDS_MeshNode*>& theNodesToInsert);
491 // insert theNodesToInsert into all volumes, containing link
492 // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
494 void ConvertToQuadratic(const bool theForce3d, const bool theToBiQuad);
495 void ConvertToQuadratic(const bool theForce3d,
496 TIDSortedElemSet& theElements, const bool theToBiQuad);
497 // Converts all mesh to quadratic or bi-quadratic one, deletes old elements,
498 // replacing them with quadratic or bi-quadratic ones with the same id.
499 // If theForce3d = 1; this results in the medium node lying at the
500 // middle of the line segments connecting start and end node of a mesh element.
501 // If theForce3d = 0; this results in the medium node lying at the
502 // geometrical edge from which the mesh element is built.
504 bool ConvertFromQuadratic();
505 void ConvertFromQuadratic(TIDSortedElemSet& theElements);
506 // Converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing
507 // them with ordinary mesh elements with the same id.
508 // Returns true in case of success, false otherwise.
510 static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
511 const SMDS_MeshElement* elemInGroups,
512 SMESHDS_Mesh * aMesh);
513 // Add elemToAdd to the all groups the elemInGroups belongs to
515 static void RemoveElemFromGroups (const SMDS_MeshElement* element,
516 SMESHDS_Mesh * aMesh);
517 // remove element from the all groups
519 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
520 const SMDS_MeshElement* elemToAdd,
521 SMESHDS_Mesh * aMesh);
522 // replace elemToRm by elemToAdd in the all groups
524 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
525 const std::vector<const SMDS_MeshElement*>& elemToAdd,
526 SMESHDS_Mesh * aMesh);
527 // replace elemToRm by elemToAdd in the all groups
530 * \brief Return nodes linked to the given one in elements of the type
532 static void GetLinkedNodes( const SMDS_MeshNode* node,
533 TIDSortedElemSet & linkedNodes,
534 SMDSAbs_ElementType type = SMDSAbs_All );
536 static const SMDS_MeshElement* FindFaceInSet(const SMDS_MeshNode* n1,
537 const SMDS_MeshNode* n2,
538 const TIDSortedElemSet& elemSet,
539 const TIDSortedElemSet& avoidSet,
542 // Return a face having linked nodes n1 and n2 and which is
543 // - not in avoidSet,
544 // - in elemSet provided that !elemSet.empty()
545 // i1 and i2 optionally returns indices of n1 and n2
548 * \brief Find corresponding nodes in two sets of faces
549 * \param theSide1 - first face set
550 * \param theSide2 - second first face
551 * \param theFirstNode1 - a boundary node of set 1
552 * \param theFirstNode2 - a node of set 2 corresponding to theFirstNode1
553 * \param theSecondNode1 - a boundary node of set 1 linked with theFirstNode1
554 * \param theSecondNode2 - a node of set 2 corresponding to theSecondNode1
555 * \param nReplaceMap - output map of corresponding nodes
556 * \return Sew_Error - is a success or not
558 static Sew_Error FindMatchingNodes(std::set<const SMDS_MeshElement*>& theSide1,
559 std::set<const SMDS_MeshElement*>& theSide2,
560 const SMDS_MeshNode* theFirstNode1,
561 const SMDS_MeshNode* theFirstNode2,
562 const SMDS_MeshNode* theSecondNode1,
563 const SMDS_MeshNode* theSecondNode2,
564 TNodeNodeMap & theNodeReplaceMap);
567 * \brief Returns true if given node is medium
568 * \param n - node to check
569 * \param typeToCheck - type of elements containing the node to ask about node status
570 * \return bool - check result
572 static bool IsMedium(const SMDS_MeshNode* node,
573 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
575 int FindShape (const SMDS_MeshElement * theElem);
576 // Return an index of the shape theElem is on
577 // or zero if a shape not found
579 bool DoubleNodes( const std::list< int >& theListOfNodes,
580 const std::list< int >& theListOfModifiedElems );
582 bool DoubleNodes( const TIDSortedElemSet& theElems,
583 const TIDSortedElemSet& theNodesNot,
584 const TIDSortedElemSet& theAffectedElems );
586 bool AffectedElemGroupsInRegion( const TIDSortedElemSet& theElems,
587 const TIDSortedElemSet& theNodesNot,
588 const TopoDS_Shape& theShape,
589 TIDSortedElemSet& theAffectedElems);
591 bool DoubleNodesInRegion( const TIDSortedElemSet& theElems,
592 const TIDSortedElemSet& theNodesNot,
593 const TopoDS_Shape& theShape );
595 double OrientedAngle(const gp_Pnt& p0, const gp_Pnt& p1, const gp_Pnt& g1, const gp_Pnt& g2);
597 bool DoubleNodesOnGroupBoundaries( const std::vector<TIDSortedElemSet>& theElems,
598 bool createJointElems);
600 bool CreateFlatElementsOnFacesGroups( const std::vector<TIDSortedElemSet>& theElems );
602 void CreateHoleSkin(double radius,
603 const TopoDS_Shape& theShape,
604 SMESH_NodeSearcher* theNodeSearcher,
605 const char* groupName,
606 std::vector<double>& nodesCoords,
607 std::vector<std::vector<int> >& listOfListOfNodes);
610 * \brief Generated skin mesh (containing 2D cells) from 3D mesh
611 * The created 2D mesh elements based on nodes of free faces of boundary volumes
612 * \return TRUE if operation has been completed successfully, FALSE otherwise
614 bool Make2DMeshFrom3D();
616 enum Bnd_Dimension { BND_2DFROM3D, BND_1DFROM3D, BND_1DFROM2D };
618 int MakeBoundaryMesh(const TIDSortedElemSet& elements,
619 Bnd_Dimension dimension,
620 SMESH_Group* group = 0,
621 SMESH_Mesh* targetMesh = 0,
622 bool toCopyElements = false,
623 bool toCopyExistingBondary = false,
624 bool toAddExistingBondary = false,
625 bool aroundElements = false);
630 * \brief Convert elements contained in a submesh to quadratic
631 * \return int - nb of checked elements
633 int convertElemToQuadratic(SMESHDS_SubMesh * theSm,
634 SMESH_MesherHelper& theHelper,
635 const bool theForce3d);
638 * \brief Convert quadratic elements to linear ones and remove quadratic nodes
639 * \return nb of checked elements
641 int removeQuadElem( SMESHDS_SubMesh * theSm,
642 SMDS_ElemIteratorPtr theItr,
643 const int theShapeID);
645 * \brief Create groups of elements made during transformation
646 * \param nodeGens - nodes making corresponding myLastCreatedNodes
647 * \param elemGens - elements making corresponding myLastCreatedElems
648 * \param postfix - to append to names of new groups
650 PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
651 const SMESH_SequenceOfElemPtr& elemGens,
652 const std::string& postfix,
653 SMESH_Mesh* targetMesh=0);
656 typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
657 typedef TNodeOfNodeListMap::iterator TNodeOfNodeListMapItr;
658 typedef std::vector<TNodeOfNodeListMapItr> TVecOfNnlmiMap;
659 typedef std::map<const SMDS_MeshElement*, TVecOfNnlmiMap > TElemOfVecOfNnlmiMap;
662 * \brief Create elements by sweeping an element
663 * \param elem - element to sweep
664 * \param newNodesItVec - nodes generated from each node of the element
665 * \param newElems - generated elements
666 * \param nbSteps - number of sweeping steps
667 * \param srcElements - to append elem for each generated element
669 void sweepElement(const SMDS_MeshElement* elem,
670 const std::vector<TNodeOfNodeListMapItr> & newNodesItVec,
671 std::list<const SMDS_MeshElement*>& newElems,
673 SMESH_SequenceOfElemPtr& srcElements);
676 * \brief Create 1D and 2D elements around swept elements
677 * \param mapNewNodes - source nodes and ones generated from them
678 * \param newElemsMap - source elements and ones generated from them
679 * \param elemNewNodesMap - nodes generated from each node of each element
680 * \param elemSet - all swept elements
681 * \param nbSteps - number of sweeping steps
682 * \param srcElements - to append elem for each generated element
684 void makeWalls (TNodeOfNodeListMap & mapNewNodes,
685 TElemOfElemListMap & newElemsMap,
686 TElemOfVecOfNnlmiMap & elemNewNodesMap,
687 TIDSortedElemSet& elemSet,
689 SMESH_SequenceOfElemPtr& srcElements);
691 struct SMESH_MeshEditor_PathPoint
695 double myAngle, myPrm;
697 SMESH_MeshEditor_PathPoint(): myPnt(99., 99., 99.), myTgt(1.,0.,0.), myAngle(0), myPrm(0) {}
698 void SetPnt (const gp_Pnt& aP3D) { myPnt =aP3D; }
699 void SetTangent (const gp_Dir& aTgt) { myTgt =aTgt; }
700 void SetAngle (const double& aBeta) { myAngle=aBeta; }
701 void SetParameter(const double& aPrm) { myPrm =aPrm; }
702 const gp_Pnt& Pnt ()const { return myPnt; }
703 const gp_Dir& Tangent ()const { return myTgt; }
704 double Angle ()const { return myAngle; }
705 double Parameter ()const { return myPrm; }
707 Extrusion_Error MakeEdgePathPoints(std::list<double>& aPrms,
708 const TopoDS_Edge& aTrackEdge,
710 std::list<SMESH_MeshEditor_PathPoint>& aLPP);
711 Extrusion_Error MakeExtrElements(TIDSortedElemSet& theElements,
712 std::list<SMESH_MeshEditor_PathPoint>& theFullList,
713 const bool theHasAngles,
714 std::list<double>& theAngles,
715 const bool theLinearVariation,
716 const bool theHasRefPoint,
717 const gp_Pnt& theRefPoint,
718 const bool theMakeGroups);
719 void LinearAngleVariation(const int NbSteps,
720 list<double>& theAngles);
722 bool doubleNodes( SMESHDS_Mesh* theMeshDS,
723 const TIDSortedElemSet& theElems,
724 const TIDSortedElemSet& theNodesNot,
725 std::map< const SMDS_MeshNode*, const SMDS_MeshNode* >& theNodeNodeMap,
726 const bool theIsDoubleElem );
732 // Nodes and elements created during last operation
733 SMESH_SequenceOfElemPtr myLastCreatedNodes, myLastCreatedElems;
735 // Description of error/warning occured during last operation
736 SMESH_ComputeErrorPtr myError;