1 // Copyright (C) 2007-2015 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 // 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;
54 class SMESH_NodeSearcher;
56 // ============================================================
58 * \brief Editor of a mesh
60 // ============================================================
62 class SMESH_EXPORT SMESH_MeshEditor
66 SMESH_MeshEditor( SMESH_Mesh* theMesh );
68 SMESH_Mesh * GetMesh() { return myMesh; }
69 SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
71 const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
72 const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
73 void ClearLastCreated();
74 SMESH_ComputeErrorPtr & GetError() { return myError; }
79 SMDS_MeshElement* AddElement(const std::vector<const SMDS_MeshNode*> & nodes,
80 const SMDSAbs_ElementType type,
83 const double ballDiameter=0.);
87 SMDS_MeshElement* AddElement(const std::vector<int> & nodeIDs,
88 const SMDSAbs_ElementType type,
92 int Remove (const std::list< int >& theElemIDs, const bool isNodes);
93 // Remove a node or an element.
94 // Modify a compute state of sub-meshes which become empty
96 void Create0DElementsOnAllNodes( const TIDSortedElemSet& elements,
97 TIDSortedElemSet& all0DElems);
98 // Create 0D elements on all nodes of the given object except those
99 // nodes on which a 0D element already exists. \a all0DElems returns
100 // all 0D elements found or created on nodes of \a elements
102 bool InverseDiag (const SMDS_MeshElement * theTria1,
103 const SMDS_MeshElement * theTria2 );
104 // Replace two neighbour triangles with ones built on the same 4 nodes
105 // but having other common link.
106 // Return False if args are improper
108 bool InverseDiag (const SMDS_MeshNode * theNode1,
109 const SMDS_MeshNode * theNode2 );
110 // Replace two neighbour triangles sharing theNode1-theNode2 link
111 // with ones built on the same 4 nodes but having other common link.
112 // Return false if proper faces not found
114 bool DeleteDiag (const SMDS_MeshNode * theNode1,
115 const SMDS_MeshNode * theNode2 );
116 // Replace two neighbour triangles sharing theNode1-theNode2 link
117 // with a quadrangle built on the same 4 nodes.
118 // Return false if proper faces not found
120 bool Reorient (const SMDS_MeshElement * theElement);
121 // Reverse theElement orientation
123 int Reorient2D (TIDSortedElemSet & theFaces,
124 const gp_Dir& theDirection,
125 const SMDS_MeshElement * theFace);
126 // Reverse theFaces whose orientation to be same as that of theFace
127 // oriented according to theDirection. Return nb of reoriented faces
129 int Reorient2DBy3D (TIDSortedElemSet & theFaces,
130 TIDSortedElemSet & theVolumes,
131 const bool theOutsideNormal);
132 // Reorient faces basing on orientation of adjacent volumes.
133 // Return nb of reoriented faces
136 * \brief Fuse neighbour triangles into quadrangles.
137 * \param theElems - The triangles to be fused.
138 * \param theCriterion - Is used to choose a neighbour to fuse with.
139 * \param theMaxAngle - Is a max angle between element normals at which fusion
140 * is still performed; theMaxAngle is mesured in radians.
141 * \return bool - Success or not.
143 bool TriToQuad (TIDSortedElemSet & theElems,
144 SMESH::Controls::NumericalFunctorPtr theCriterion,
145 const double theMaxAngle);
147 * \brief Split quadrangles into triangles.
148 * \param theElems - The faces to be splitted.
149 * \param theCriterion - Is used to choose a diagonal for splitting.
150 * \return bool - Success or not.
152 bool QuadToTri (TIDSortedElemSet & theElems,
153 SMESH::Controls::NumericalFunctorPtr theCriterion);
155 * \brief Split quadrangles into triangles.
156 * \param theElems - The faces to be splitted.
157 * \param the13Diag - Is used to choose a diagonal for splitting.
158 * \return bool - Success or not.
160 bool QuadToTri (TIDSortedElemSet & theElems,
161 const bool the13Diag);
163 * \brief Split each of given quadrangles into 4 triangles.
164 * \param theElems - The faces to be splitted. If empty all faces are split.
166 void QuadTo4Tri (TIDSortedElemSet & theElems);
169 * \brief Find better diagonal for splitting.
170 * \param theQuad - The face to find better splitting of.
171 * \param theCriterion - Is used to choose a diagonal for splitting.
172 * \return int - 1 for 1-3 diagonal, 2 for 2-4, -1 - for errors.
174 int BestSplit (const SMDS_MeshElement* theQuad,
175 SMESH::Controls::NumericalFunctorPtr theCriterion);
178 typedef std::map < const SMDS_MeshElement*, int, TIDCompare > TFacetOfElem;
180 //!<2nd arg of SplitVolumes()
181 enum SplitVolumToTetraFlags { HEXA_TO_5 = 1, // split into tetrahedra
184 HEXA_TO_2_PRISMS, // split into prisms
187 * \brief Split volumic elements into tetrahedra or prisms.
188 * If facet ID < 0, element is split into tetrahedra,
189 * else a hexahedron is split into prisms so that the given facet is
190 * split into triangles
192 void SplitVolumes (const TFacetOfElem & theElems, const int theMethodFlags);
195 * \brief For hexahedra that will be split into prisms, finds facets to
196 * split into triangles
197 * \param [in,out] theHexas - the hexahedra
198 * \param [in] theFacetNormal - facet normal
199 * \param [out] theFacets - the hexahedra and found facet IDs
201 void GetHexaFacetsToSplit( TIDSortedElemSet& theHexas,
202 const gp_Ax1& theFacetNormal,
203 TFacetOfElem & theFacets);
206 enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL };
208 void Smooth (TIDSortedElemSet & theElements,
209 std::set<const SMDS_MeshNode*> & theFixedNodes,
210 const SmoothMethod theSmoothMethod,
211 const int theNbIterations,
212 double theTgtAspectRatio = 1.0,
213 const bool the2D = true);
214 // Smooth theElements using theSmoothMethod during theNbIterations
215 // or until a worst element has aspect ratio <= theTgtAspectRatio.
216 // Aspect Ratio varies in range [1.0, inf].
217 // If theElements is empty, the whole mesh is smoothed.
218 // theFixedNodes contains additionally fixed nodes. Nodes built
219 // on edges and boundary nodes are always fixed.
220 // If the2D, smoothing is performed using UV parameters of nodes
221 // on geometrical faces
223 typedef TIDTypeCompare TElemSort;
224 typedef std::map < const SMDS_MeshElement*,
225 std::list<const SMDS_MeshElement*>, TElemSort > TTElemOfElemListMap;
226 typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
227 typedef TNodeOfNodeListMap::iterator TNodeOfNodeListMapItr;
228 typedef std::vector<TNodeOfNodeListMapItr> TVecOfNnlmiMap;
229 typedef std::map<const SMDS_MeshElement*, TVecOfNnlmiMap, TElemSort > TElemOfVecOfNnlmiMap;
230 typedef std::auto_ptr< std::list<int> > PGroupIDs;
232 PGroupIDs RotationSweep (TIDSortedElemSet theElements[2],
233 const gp_Ax1& theAxis,
234 const double theAngle,
235 const int theNbSteps,
236 const double theToler,
237 const bool theMakeGroups,
238 const bool theMakeWalls=true);
239 // Generate new elements by rotation of theElements around theAxis
240 // by theAngle by theNbSteps
243 * Flags of extrusion.
244 * BOUNDARY: create or not boundary for result of extrusion
245 * SEW: try to use existing nodes or create new nodes in any case
246 * GROUPS: to create groups
247 * BY_AVG_NORMAL: step size is measured along average normal to elements,
248 * else step size is measured along average normal of any element
249 * USE_INPUT_ELEMS_ONLY: to use only input elements to compute extrusion direction
250 * for ExtrusionByNormal()
252 enum ExtrusionFlags {
253 EXTRUSION_FLAG_BOUNDARY = 0x01,
254 EXTRUSION_FLAG_SEW = 0x02,
255 EXTRUSION_FLAG_GROUPS = 0x04,
256 EXTRUSION_FLAG_BY_AVG_NORMAL = 0x08,
257 EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY = 0x10
261 * Generator of nodes for extrusion functionality
263 class SMESH_EXPORT ExtrusParam {
264 gp_Dir myDir; // direction of extrusion
265 Handle(TColStd_HSequenceOfReal) mySteps; // magnitudes for each step
266 SMESH_SequenceOfNode myNodes; // nodes for using in sewing
267 int myFlags; // see ExtrusionFlags
268 double myTolerance; // tolerance for sewing nodes
269 const TIDSortedElemSet* myElemsToUse; // elements to use for extrusion by normal
271 int (ExtrusParam::*myMakeNodesFun)(SMESHDS_Mesh* mesh,
272 const SMDS_MeshNode* srcNode,
273 std::list<const SMDS_MeshNode*> & newNodes,
274 const bool makeMediumNodes);
277 ExtrusParam( const gp_Vec& theStep,
278 const int theNbSteps,
279 const int theFlags = 0,
280 const double theTolerance = 1e-6);
281 ExtrusParam( const gp_Dir& theDir,
282 Handle(TColStd_HSequenceOfReal) theSteps,
283 const int theFlags = 0,
284 const double theTolerance = 1e-6);
285 ExtrusParam( const double theStep,
286 const int theNbSteps,
288 const int theDim); // for extrusion by normal
290 SMESH_SequenceOfNode& ChangeNodes() { return myNodes; }
291 int& Flags() { return myFlags; }
292 bool ToMakeBoundary() const { return myFlags & EXTRUSION_FLAG_BOUNDARY; }
293 bool ToMakeGroups() const { return myFlags & EXTRUSION_FLAG_GROUPS; }
294 bool ToUseInpElemsOnly() const { return myFlags & EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY; }
295 int NbSteps() const { return mySteps->Length(); }
297 // stores elements to use for extrusion by normal, depending on
298 // state of EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY flag
299 void SetElementsToUse( const TIDSortedElemSet& elems );
301 // creates nodes and returns number of nodes added in \a newNodes
302 int MakeNodes( SMESHDS_Mesh* mesh,
303 const SMDS_MeshNode* srcNode,
304 std::list<const SMDS_MeshNode*> & newNodes,
305 const bool makeMediumNodes)
307 return (this->*myMakeNodesFun)( mesh, srcNode, newNodes, makeMediumNodes );
311 int makeNodesByDir( SMESHDS_Mesh* mesh,
312 const SMDS_MeshNode* srcNode,
313 std::list<const SMDS_MeshNode*> & newNodes,
314 const bool makeMediumNodes);
315 int makeNodesByDirAndSew( SMESHDS_Mesh* mesh,
316 const SMDS_MeshNode* srcNode,
317 std::list<const SMDS_MeshNode*> & newNodes,
318 const bool makeMediumNodes);
319 int makeNodesByNormal2D( SMESHDS_Mesh* mesh,
320 const SMDS_MeshNode* srcNode,
321 std::list<const SMDS_MeshNode*> & newNodes,
322 const bool makeMediumNodes);
323 int makeNodesByNormal1D( SMESHDS_Mesh* mesh,
324 const SMDS_MeshNode* srcNode,
325 std::list<const SMDS_MeshNode*> & newNodes,
326 const bool makeMediumNodes);
328 void beginStepIter( bool withMediumNodes );
331 std::vector< double > myCurSteps;
332 bool myWithMediumNodes;
337 * Generate new elements by extrusion of theElements
338 * It is a method used in .idl file. All functionality
339 * is implemented in the next method (see below) which
340 * is used in the current method.
341 * @param theElems - list of elements for extrusion
342 * @param newElemsMap returns history of extrusion
343 * @param theFlags set flags for performing extrusion (see description
344 * of enum ExtrusionFlags for additional information)
345 * @param theTolerance - uses for comparing locations of nodes if flag
346 * EXTRUSION_FLAG_SEW is set
348 PGroupIDs ExtrusionSweep (TIDSortedElemSet theElems[2],
349 const gp_Vec& theStep,
350 const int theNbSteps,
351 TTElemOfElemListMap& newElemsMap,
353 const double theTolerance = 1.e-6);
356 * Generate new elements by extrusion of theElements
357 * @param theElems - list of elements for extrusion
358 * @param newElemsMap returns history of extrusion
359 * @param theFlags set flags for performing extrusion (see description
360 * of enum ExtrusionFlags for additional information)
361 * @param theTolerance - uses for comparing locations of nodes if flag
362 * EXTRUSION_FLAG_SEW is set
363 * @param theParams - special structure for manage of extrusion
365 PGroupIDs ExtrusionSweep (TIDSortedElemSet theElems[2],
366 ExtrusParam& theParams,
367 TTElemOfElemListMap& newElemsMap);
370 // Generate new elements by extrusion of theElements
371 // by theStep by theNbSteps
373 enum Extrusion_Error {
378 EXTR_BAD_STARTING_NODE,
379 EXTR_BAD_ANGLES_NUMBER,
380 EXTR_CANT_GET_TANGENT
383 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet theElements[2],
384 SMESH_subMesh* theTrackPattern,
385 const SMDS_MeshNode* theNodeStart,
386 const bool theHasAngles,
387 std::list<double>& theAngles,
388 const bool theLinearVariation,
389 const bool theHasRefPoint,
390 const gp_Pnt& theRefPoint,
391 const bool theMakeGroups);
392 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet theElements[2],
393 SMESH_Mesh* theTrackPattern,
394 const SMDS_MeshNode* theNodeStart,
395 const bool theHasAngles,
396 std::list<double>& theAngles,
397 const bool theLinearVariation,
398 const bool theHasRefPoint,
399 const gp_Pnt& theRefPoint,
400 const bool theMakeGroups);
401 // Generate new elements by extrusion of theElements along path given by theTrackPattern,
402 // theHasAngles are the rotation angles, base point can be given by theRefPoint
404 PGroupIDs Transform (TIDSortedElemSet & theElements,
405 const gp_Trsf& theTrsf,
407 const bool theMakeGroups,
408 SMESH_Mesh* theTargetMesh=0);
409 // Move or copy theElements applying theTrsf to their nodes
411 typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
413 void FindCoincidentNodes (TIDSortedNodeSet & theNodes,
414 const double theTolerance,
415 TListOfListOfNodes & theGroupsOfNodes);
416 // Return list of group of nodes close to each other within theTolerance.
417 // Search among theNodes or in the whole mesh if theNodes is empty.
419 void MergeNodes (TListOfListOfNodes & theNodeGroups);
420 // In each group, the cdr of nodes are substituted by the first one
423 typedef std::list< std::list< int > > TListOfListOfElementsID;
425 void FindEqualElements(TIDSortedElemSet & theElements,
426 TListOfListOfElementsID & theGroupsOfElementsID);
427 // Return list of group of elements build on the same nodes.
428 // Search among theElements or in the whole mesh if theElements is empty.
430 void MergeElements(TListOfListOfElementsID & theGroupsOfElementsID);
431 // In each group remove all but first of elements.
433 void MergeEqualElements();
434 // Remove all but one of elements built on the same nodes.
435 // Return nb of successfully merged groups.
437 int SimplifyFace (const std::vector<const SMDS_MeshNode *>& faceNodes,
438 std::vector<const SMDS_MeshNode *>& poly_nodes,
439 std::vector<int>& quantities) const;
440 // Split face, defined by <faceNodes>, into several faces by repeating nodes.
441 // Is used by MergeNodes()
443 static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1,
444 const SMDS_MeshNode* theNode2,
445 const SMDS_MeshNode* theNode3 = 0);
446 // Return true if the three nodes are on a free border
448 static bool FindFreeBorder (const SMDS_MeshNode* theFirstNode,
449 const SMDS_MeshNode* theSecondNode,
450 const SMDS_MeshNode* theLastNode,
451 std::list< const SMDS_MeshNode* > & theNodes,
452 std::list< const SMDS_MeshElement* >& theFaces);
453 // Return nodes and faces of a free border if found
457 // for SewFreeBorder()
458 SEW_BORDER1_NOT_FOUND,
459 SEW_BORDER2_NOT_FOUND,
460 SEW_BOTH_BORDERS_NOT_FOUND,
462 SEW_VOLUMES_TO_SPLIT,
463 // for SewSideElements()
464 SEW_DIFF_NB_OF_ELEMENTS,
465 SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
472 Sew_Error SewFreeBorder (const SMDS_MeshNode* theBorderFirstNode,
473 const SMDS_MeshNode* theBorderSecondNode,
474 const SMDS_MeshNode* theBorderLastNode,
475 const SMDS_MeshNode* theSide2FirstNode,
476 const SMDS_MeshNode* theSide2SecondNode,
477 const SMDS_MeshNode* theSide2ThirdNode = 0,
478 const bool theSide2IsFreeBorder = true,
479 const bool toCreatePolygons = false,
480 const bool toCreatePolyedrs = false);
481 // Sew the free border to the side2 by replacing nodes in
482 // elements on the free border with nodes of the elements
483 // of the side 2. If nb of links in the free border and
484 // between theSide2FirstNode and theSide2LastNode are different,
485 // additional nodes are inserted on a link provided that no
486 // volume elements share the splitted link.
487 // The side 2 is a free border if theSide2IsFreeBorder == true.
488 // Sewing is peformed between the given first, second and last
489 // nodes on the sides.
490 // theBorderFirstNode is merged with theSide2FirstNode.
491 // if (!theSide2IsFreeBorder) then theSide2SecondNode gives
492 // the last node on the side 2, which will be merged with
493 // theBorderLastNode.
494 // if (theSide2IsFreeBorder) then theSide2SecondNode will
495 // be merged with theBorderSecondNode.
496 // if (theSide2IsFreeBorder && theSide2ThirdNode == 0) then
497 // the 2 free borders are sewn link by link and no additional
498 // nodes are inserted.
499 // Return false, if sewing failed.
501 Sew_Error SewSideElements (TIDSortedElemSet& theSide1,
502 TIDSortedElemSet& theSide2,
503 const SMDS_MeshNode* theFirstNode1ToMerge,
504 const SMDS_MeshNode* theFirstNode2ToMerge,
505 const SMDS_MeshNode* theSecondNode1ToMerge,
506 const SMDS_MeshNode* theSecondNode2ToMerge);
507 // Sew two sides of a mesh. Nodes belonging to theSide1 are
508 // merged with nodes of elements of theSide2.
509 // Number of elements in theSide1 and in theSide2 must be
510 // equal and they should have similar node connectivity.
511 // The nodes to merge should belong to side s borders and
512 // the first node should be linked to the second.
514 void InsertNodesIntoLink(const SMDS_MeshElement* theFace,
515 const SMDS_MeshNode* theBetweenNode1,
516 const SMDS_MeshNode* theBetweenNode2,
517 std::list<const SMDS_MeshNode*>& theNodesToInsert,
518 const bool toCreatePoly = false);
519 // insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2.
520 // If toCreatePoly is true, replace theFace by polygon, else split theFace.
522 void UpdateVolumes (const SMDS_MeshNode* theBetweenNode1,
523 const SMDS_MeshNode* theBetweenNode2,
524 std::list<const SMDS_MeshNode*>& theNodesToInsert);
525 // insert theNodesToInsert into all volumes, containing link
526 // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
528 void ConvertToQuadratic(const bool theForce3d, const bool theToBiQuad);
529 void ConvertToQuadratic(const bool theForce3d,
530 TIDSortedElemSet& theElements, const bool theToBiQuad);
531 // Converts all mesh to quadratic or bi-quadratic one, deletes old elements,
532 // replacing them with quadratic or bi-quadratic ones with the same id.
533 // If theForce3d = 1; this results in the medium node lying at the
534 // middle of the line segments connecting start and end node of a mesh element.
535 // If theForce3d = 0; this results in the medium node lying at the
536 // geometrical edge from which the mesh element is built.
538 bool ConvertFromQuadratic();
539 void ConvertFromQuadratic(TIDSortedElemSet& theElements);
540 // Converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing
541 // them with ordinary mesh elements with the same id.
542 // Returns true in case of success, false otherwise.
544 static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
545 const SMDS_MeshElement* elemInGroups,
546 SMESHDS_Mesh * aMesh);
547 // Add elemToAdd to the all groups the elemInGroups belongs to
549 static void RemoveElemFromGroups (const SMDS_MeshElement* element,
550 SMESHDS_Mesh * aMesh);
551 // remove element from the all groups
553 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
554 const SMDS_MeshElement* elemToAdd,
555 SMESHDS_Mesh * aMesh);
556 // replace elemToRm by elemToAdd in the all groups
558 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
559 const std::vector<const SMDS_MeshElement*>& elemToAdd,
560 SMESHDS_Mesh * aMesh);
561 // replace elemToRm by elemToAdd in the all groups
564 * \brief Return nodes linked to the given one in elements of the type
566 static void GetLinkedNodes( const SMDS_MeshNode* node,
567 TIDSortedElemSet & linkedNodes,
568 SMDSAbs_ElementType type = SMDSAbs_All );
571 * \brief Find corresponding nodes in two sets of faces
572 * \param theSide1 - first face set
573 * \param theSide2 - second first face
574 * \param theFirstNode1 - a boundary node of set 1
575 * \param theFirstNode2 - a node of set 2 corresponding to theFirstNode1
576 * \param theSecondNode1 - a boundary node of set 1 linked with theFirstNode1
577 * \param theSecondNode2 - a node of set 2 corresponding to theSecondNode1
578 * \param nReplaceMap - output map of corresponding nodes
579 * \return Sew_Error - is a success or not
581 static Sew_Error FindMatchingNodes(std::set<const SMDS_MeshElement*>& theSide1,
582 std::set<const SMDS_MeshElement*>& theSide2,
583 const SMDS_MeshNode* theFirstNode1,
584 const SMDS_MeshNode* theFirstNode2,
585 const SMDS_MeshNode* theSecondNode1,
586 const SMDS_MeshNode* theSecondNode2,
587 TNodeNodeMap & theNodeReplaceMap);
590 * \brief Returns true if given node is medium
591 * \param n - node to check
592 * \param typeToCheck - type of elements containing the node to ask about node status
593 * \return bool - check result
595 static bool IsMedium(const SMDS_MeshNode* node,
596 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
598 int FindShape (const SMDS_MeshElement * theElem);
599 // Return an index of the shape theElem is on
600 // or zero if a shape not found
602 void DoubleElements( const TIDSortedElemSet& theElements );
604 bool DoubleNodes( const std::list< int >& theListOfNodes,
605 const std::list< int >& theListOfModifiedElems );
607 bool DoubleNodes( const TIDSortedElemSet& theElems,
608 const TIDSortedElemSet& theNodesNot,
609 const TIDSortedElemSet& theAffectedElems );
611 bool AffectedElemGroupsInRegion( const TIDSortedElemSet& theElems,
612 const TIDSortedElemSet& theNodesNot,
613 const TopoDS_Shape& theShape,
614 TIDSortedElemSet& theAffectedElems);
616 bool DoubleNodesInRegion( const TIDSortedElemSet& theElems,
617 const TIDSortedElemSet& theNodesNot,
618 const TopoDS_Shape& theShape );
620 double OrientedAngle(const gp_Pnt& p0, const gp_Pnt& p1, const gp_Pnt& g1, const gp_Pnt& g2);
622 bool DoubleNodesOnGroupBoundaries( const std::vector<TIDSortedElemSet>& theElems,
623 bool createJointElems,
624 bool onAllBoundaries);
626 bool CreateFlatElementsOnFacesGroups( const std::vector<TIDSortedElemSet>& theElems );
628 void CreateHoleSkin(double radius,
629 const TopoDS_Shape& theShape,
630 SMESH_NodeSearcher* theNodeSearcher,
631 const char* groupName,
632 std::vector<double>& nodesCoords,
633 std::vector<std::vector<int> >& listOfListOfNodes);
636 * \brief Generated skin mesh (containing 2D cells) from 3D mesh
637 * The created 2D mesh elements based on nodes of free faces of boundary volumes
638 * \return TRUE if operation has been completed successfully, FALSE otherwise
640 bool Make2DMeshFrom3D();
642 enum Bnd_Dimension { BND_2DFROM3D, BND_1DFROM3D, BND_1DFROM2D };
644 int MakeBoundaryMesh(const TIDSortedElemSet& elements,
645 Bnd_Dimension dimension,
646 SMESH_Group* group = 0,
647 SMESH_Mesh* targetMesh = 0,
648 bool toCopyElements = false,
649 bool toCopyExistingBondary = false,
650 bool toAddExistingBondary = false,
651 bool aroundElements = false);
656 * \brief Convert elements contained in a submesh to quadratic
657 * \return int - nb of checked elements
659 int convertElemToQuadratic(SMESHDS_SubMesh * theSm,
660 SMESH_MesherHelper& theHelper,
661 const bool theForce3d);
664 * \brief Convert quadratic elements to linear ones and remove quadratic nodes
665 * \return nb of checked elements
667 int removeQuadElem( SMESHDS_SubMesh * theSm,
668 SMDS_ElemIteratorPtr theItr,
669 const int theShapeID);
671 * \brief Create groups of elements made during transformation
672 * \param nodeGens - nodes making corresponding myLastCreatedNodes
673 * \param elemGens - elements making corresponding myLastCreatedElems
674 * \param postfix - to append to names of new groups
675 * \param targetMesh - mesh to create groups in
676 * \param topPresent - is there "top" elements that are created by sweeping
678 PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
679 const SMESH_SequenceOfElemPtr& elemGens,
680 const std::string& postfix,
681 SMESH_Mesh* targetMesh=0,
682 const bool topPresent=true);
684 * \brief Create elements by sweeping an element
685 * \param elem - element to sweep
686 * \param newNodesItVec - nodes generated from each node of the element
687 * \param newElems - generated elements
688 * \param nbSteps - number of sweeping steps
689 * \param srcElements - to append elem for each generated element
691 void sweepElement(const SMDS_MeshElement* elem,
692 const std::vector<TNodeOfNodeListMapItr> & newNodesItVec,
693 std::list<const SMDS_MeshElement*>& newElems,
695 SMESH_SequenceOfElemPtr& srcElements);
698 * \brief Create 1D and 2D elements around swept elements
699 * \param mapNewNodes - source nodes and ones generated from them
700 * \param newElemsMap - source elements and ones generated from them
701 * \param elemNewNodesMap - nodes generated from each node of each element
702 * \param elemSet - all swept elements
703 * \param nbSteps - number of sweeping steps
704 * \param srcElements - to append elem for each generated element
706 void makeWalls (TNodeOfNodeListMap & mapNewNodes,
707 TTElemOfElemListMap & newElemsMap,
708 TElemOfVecOfNnlmiMap & elemNewNodesMap,
709 TIDSortedElemSet& elemSet,
711 SMESH_SequenceOfElemPtr& srcElements);
713 struct SMESH_MeshEditor_PathPoint
717 double myAngle, myPrm;
719 SMESH_MeshEditor_PathPoint(): myPnt(99., 99., 99.), myTgt(1.,0.,0.), myAngle(0), myPrm(0) {}
720 void SetPnt (const gp_Pnt& aP3D) { myPnt =aP3D; }
721 void SetTangent (const gp_Dir& aTgt) { myTgt =aTgt; }
722 void SetAngle (const double& aBeta) { myAngle=aBeta; }
723 void SetParameter(const double& aPrm) { myPrm =aPrm; }
724 const gp_Pnt& Pnt ()const { return myPnt; }
725 const gp_Dir& Tangent ()const { return myTgt; }
726 double Angle ()const { return myAngle; }
727 double Parameter ()const { return myPrm; }
729 Extrusion_Error MakeEdgePathPoints(std::list<double>& aPrms,
730 const TopoDS_Edge& aTrackEdge,
732 std::list<SMESH_MeshEditor_PathPoint>& aLPP);
733 Extrusion_Error MakeExtrElements(TIDSortedElemSet theElements[2],
734 std::list<SMESH_MeshEditor_PathPoint>& theFullList,
735 const bool theHasAngles,
736 std::list<double>& theAngles,
737 const bool theLinearVariation,
738 const bool theHasRefPoint,
739 const gp_Pnt& theRefPoint,
740 const bool theMakeGroups);
741 void LinearAngleVariation(const int NbSteps,
742 list<double>& theAngles);
744 bool doubleNodes( SMESHDS_Mesh* theMeshDS,
745 const TIDSortedElemSet& theElems,
746 const TIDSortedElemSet& theNodesNot,
747 std::map< const SMDS_MeshNode*, const SMDS_MeshNode* >& theNodeNodeMap,
748 const bool theIsDoubleElem );
750 void copyPosition( const SMDS_MeshNode* from,
751 const SMDS_MeshNode* to );
757 // Nodes and elements created during last operation
758 SMESH_SequenceOfElemPtr myLastCreatedNodes, myLastCreatedElems;
760 // Description of error/warning occured during last operation
761 SMESH_ComputeErrorPtr myError;