Version: 9.16.0
SMESH_MeshEditor.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
6// This library is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 2.1 of the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23// File : SMESH_MeshEditor.hxx
24// Created : Mon Apr 12 14:56:19 2004
25// Author : Edward AGAPOV (eap)
26// Module : SMESH
27//
28#ifndef SMESH_MeshEditor_HeaderFile
29#define SMESH_MeshEditor_HeaderFile
30
31#include "SMESH_SMESH.hxx"
32
33#include "SMESH_Controls.hxx"
34#include "SMESH_TypeDefs.hxx"
36#include "SMDS_VolumeTool.hxx"
37
38#include <utilities.h>
39
40#include <TColStd_HSequenceOfReal.hxx>
41#include <gp_Dir.hxx>
42
43#include <list>
44#include <map>
45#include <set>
46
48class SMDS_MeshFace;
49class SMDS_MeshNode;
50class SMESHDS_Group;
51class SMESHDS_Mesh;
52class SMESHDS_SubMesh;
54class SMESH_Group;
55class SMESH_Mesh;
58class SMESH_subMesh;
59class TopoDS_Edge;
60class TopoDS_Shape;
61class TopoDS_Vertex;
62class gp_Ax1;
63class gp_Pnt;
64class gp_Vec;
65class SMDS_VolumeTool;
66
67// ============================================================
71// ============================================================
72
74{
75public:
76
77 SMESH_MeshEditor( SMESH_Mesh* theMesh );
78
79 SMESH_Mesh * GetMesh() { return myMesh; }
80 SMESHDS_Mesh * GetMeshDS();
81
82 const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
83 const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
84 void ClearLastCreated();
85 SMESH_ComputeErrorPtr & GetError() { return myError; }
86
87 // --------------------------------------------------------------------------------
89 {
91 bool myIsPoly, myIsQuad;
92 smIdType myID;
94 std::vector<int> myPolyhedQuantities;
95 std::vector<const SMDS_MeshNode*> myNodes; // not managed by ElemFeatures
96
97 SMESH_EXPORT ElemFeatures( SMDSAbs_ElementType type=SMDSAbs_All, bool isPoly=false, bool isQuad=false )
98 :myType( type ), myIsPoly(isPoly), myIsQuad(isQuad), myID(-1), myBallDiameter(0) {}
99
100 SMESH_EXPORT ElemFeatures& Init( SMDSAbs_ElementType type, bool isPoly=false, bool isQuad=false )
101 { myType = type; myIsPoly = isPoly; myIsQuad = isQuad; return *this; }
102
103 SMESH_EXPORT ElemFeatures& Init( const SMDS_MeshElement* elem, bool basicOnly=true );
104
105 SMESH_EXPORT ElemFeatures& Init( double diameter )
106 { myType = SMDSAbs_Ball; myBallDiameter = diameter; return *this; }
107
108 SMESH_EXPORT ElemFeatures& Init( std::vector<int>& quanities, bool isQuad=false )
109 { myType = SMDSAbs_Volume; myIsPoly = 1; myIsQuad = isQuad;
110 myPolyhedQuantities.swap( quanities ); return *this; }
111
112 SMESH_EXPORT ElemFeatures& Init( const std::vector<int>& quanities, bool isQuad=false )
113 { myType = SMDSAbs_Volume; myIsPoly = 1; myIsQuad = isQuad;
114 myPolyhedQuantities = quanities; return *this; }
115
116 SMESH_EXPORT ElemFeatures& SetPoly(bool isPoly) { myIsPoly = isPoly; return *this; }
117 SMESH_EXPORT ElemFeatures& SetQuad(bool isQuad) { myIsQuad = isQuad; return *this; }
118 SMESH_EXPORT ElemFeatures& SetID (smIdType ID) { myID = ID; return *this; }
119 };
120
124 SMDS_MeshElement* AddElement(const std::vector<const SMDS_MeshNode*> & nodes,
125 const ElemFeatures& features);
129 SMDS_MeshElement* AddElement(const std::vector<smIdType> & nodeIDs,
130 const ElemFeatures& features);
134 void RemoveNodeWithReconnection( const SMDS_MeshNode* node );
135
136 smIdType Remove (const std::list< smIdType >& theElemIDs, const bool isNodes);
137 // Remove a node or an element.
138 // Modify a compute state of sub-meshes which become empty
139
140 void Create0DElementsOnAllNodes( const TIDSortedElemSet& elements,
141 TIDSortedElemSet& all0DElems,
142 const bool duplicateElements);
143 // Create 0D elements on all nodes of the given. \a all0DElems returns
144 // all 0D elements found or created on nodes of \a elements
145
146 bool InverseDiag (const SMDS_MeshElement * theTria1,
147 const SMDS_MeshElement * theTria2 );
148 // Replace two neighbour triangles with ones built on the same 4 nodes
149 // but having other common link.
150 // Return False if args are improper
151
152 bool InverseDiag (const SMDS_MeshNode * theNode1,
153 const SMDS_MeshNode * theNode2 );
154 // Replace two neighbour triangles sharing theNode1-theNode2 link
155 // with ones built on the same 4 nodes but having other common link.
156 // Return false if proper faces not found
157
158 bool DeleteDiag (const SMDS_MeshNode * theNode1,
159 const SMDS_MeshNode * theNode2 );
160 // Replace two neighbour triangles sharing theNode1-theNode2 link
161 // with a quadrangle built on the same 4 nodes.
162 // Return false if proper faces not found
163
164 void SplitEdge (const SMDS_MeshNode * theNode1,
165 const SMDS_MeshNode * theNode2,
166 double thePosition);
167 // Replace each triangle bound by theNode1-theNode2 link
168 // with two triangles by connecting a node made on the link with a node opposite to the link.
169
170 void SplitFace (const SMDS_MeshElement * theFace,
171 double theX,
172 double theY,
173 double theZ );
174 // Split a face into triangles each formed by two nodes of the face and a new node added
175 // at the given coordinates.
176
177
178 bool Reorient (const SMDS_MeshElement * theElement);
179 // Reverse theElement orientation
180
181 int Reorient2D (TIDSortedElemSet & theFaces,
182 const gp_Vec& theDirection,
183 TIDSortedElemSet & theRefFaces,
184 bool theAllowNonManifold);
185 // Reverse theFaces whose orientation to be same as that of theRefFaces
186 // optionally oriented according to theDirection. Return nb of reoriented faces
187
188 int Reorient2DBy3D (TIDSortedElemSet & theFaces,
189 TIDSortedElemSet & theVolumes,
190 const bool theOutsideNormal);
191 // Reorient faces basing on orientation of adjacent volumes.
192 // Return nb of reoriented faces
193
202 bool TriToQuad (TIDSortedElemSet & theElems,
204 const double theMaxAngle);
211 bool QuadToTri (TIDSortedElemSet & theElems,
219 bool QuadToTri (TIDSortedElemSet & theElems,
220 const bool the13Diag);
225 void QuadTo4Tri (TIDSortedElemSet & theElems);
226
233 int BestSplit (const SMDS_MeshElement* theQuad,
235
236
237 typedef std::map < const SMDS_MeshElement*, int, TIDCompare > TFacetOfElem;
238
240 enum SplitVolumToTetraFlags { HEXA_TO_5 = 1, // split into tetrahedra
243 HEXA_TO_2_PRISMS, // split into prisms
244 HEXA_TO_4_PRISMS };
253 void SplitVolumes (const TFacetOfElem & theElems,
254 const int theMethodFlags,
255 const bool avoidOverConstrainedVolumes = false );
256
264 void GetHexaFacetsToSplit( TIDSortedElemSet& theHexas,
265 const gp_Ax1& theFacetNormal,
266 TFacetOfElem & theFacets);
267
277 void SplitBiQuadraticIntoLinear(TIDSortedElemSet& theElems);
278
283 bool isVariantOverConstrained(SMDS_VolumeTool& vol, const int* connVariants);
284
285 enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL };
286
287 void Smooth (TIDSortedElemSet & theElements,
288 std::set<const SMDS_MeshNode*> & theFixedNodes,
289 const SmoothMethod theSmoothMethod,
290 const int theNbIterations,
291 double theTgtAspectRatio = 1.0,
292 const bool the2D = true);
293 // Smooth theElements using theSmoothMethod during theNbIterations
294 // or until a worst element has aspect ratio <= theTgtAspectRatio.
295 // Aspect Ratio varies in range [1.0, inf].
296 // If theElements is empty, the whole mesh is smoothed.
297 // theFixedNodes contains additionally fixed nodes. Nodes built
298 // on edges and boundary nodes are always fixed.
299 // If the2D, smoothing is performed using UV parameters of nodes
300 // on geometrical faces
301
303 typedef std::map < const SMDS_MeshElement*,
304 std::list<const SMDS_MeshElement*>, TElemSort > TTElemOfElemListMap;
305 typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
306 typedef TNodeOfNodeListMap::iterator TNodeOfNodeListMapItr;
307 typedef std::vector<TNodeOfNodeListMapItr> TVecOfNnlmiMap;
308 typedef std::map<const SMDS_MeshElement*, TVecOfNnlmiMap, TElemSort > TElemOfVecOfNnlmiMap;
309 typedef std::unique_ptr< std::list< int > > PGroupIDs;
310
311 PGroupIDs RotationSweep (TIDSortedElemSet theElements[2],
312 const gp_Ax1& theAxis,
313 const double theAngle,
314 const int theNbSteps,
315 const double theToler,
316 const bool theMakeGroups,
317 const bool theMakeWalls=true);
318 // Generate new elements by rotation of theElements around theAxis
319 // by theAngle by theNbSteps
320
336 EXTRUSION_FLAG_GROUPS = 0x04,
337 EXTRUSION_FLAG_BY_AVG_NORMAL = 0x08,
338 EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY = 0x10,
339 EXTRUSION_FLAG_SCALE_LINEAR_VARIATION = 0x20,
340 EXTRUSION_FLAG_ANGLE_LINEAR_VARIATION = 0x40
341 };
342
347 {
348 public:
351 {
352 gp_Pnt myPnt;
353 gp_Dir myTgt;
354 double myAngle, myScale;
355 PathPoint(): myPnt(99., 99., 99.), myTgt(1.,0.,0.), myAngle(0), myScale(0) {}
356 };
357
358 ExtrusParam( const gp_Vec& theStep,
359 const int theNbSteps,
360 const std::list<double>& theScales,
361 const std::list<double>& theAngles,
362 const gp_XYZ* theBaseP,
363 const int theFlags = 0,
364 const double theTolerance = 1e-6);
365 ExtrusParam( const gp_Dir& theDir,
366 Handle(TColStd_HSequenceOfReal) theSteps,
367 const int theFlags = 0,
368 const double theTolerance = 1e-6);
369 ExtrusParam( const double theStep,
370 const int theNbSteps,
371 const int theFlags,
372 const int theDim); // for extrusion by normal
373 ExtrusParam( const std::vector< PathPoint >& thePoints,
374 const gp_Pnt* theBaseP,
375 const std::list<double>& theScales,
376 const bool theMakeGroups); // for extrusion along path
377
378 SMESH_SequenceOfNode& ChangeNodes() { return myNodes; }
379 int& Flags() { return myFlags; }
380 bool ToMakeBoundary() const { return myFlags & EXTRUSION_FLAG_BOUNDARY; }
381 bool ToMakeGroups() const { return myFlags & EXTRUSION_FLAG_GROUPS; }
382 bool ToUseInpElemsOnly() const { return myFlags & EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY; }
383 bool IsScaleVariation() const { return myFlags & EXTRUSION_FLAG_SCALE_LINEAR_VARIATION; }
384 bool IsAngleVariation() const { return myFlags & EXTRUSION_FLAG_ANGLE_LINEAR_VARIATION; }
385 int NbSteps() const {
386 return mySteps.IsNull() ? (int)myPathPoints.size() - 1: mySteps->Length();
387 }
388 // stores elements to use for extrusion by normal, depending on
389 // state of EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY flag;
390 // define myBaseP for scaling
391 void SetElementsToUse( const TIDSortedElemSet& elems, const TIDSortedElemSet& nodes );
392
393 // creates nodes and returns number of nodes added in \a newNodes
395 const SMDS_MeshNode* srcNode,
396 std::list<const SMDS_MeshNode*> & newNodes,
397 const bool makeMediumNodes)
398 {
399 return (this->*myMakeNodesFun)( mesh, srcNode, newNodes, makeMediumNodes );
400 }
401 private:
402
403 gp_Dir myDir; // direction of extrusion
404 Handle(TColStd_HSequenceOfReal) mySteps; // magnitudes for each step
405 std::vector<double> myScales;// scale factors
406 std::vector<double> myAngles;// angles
407 gp_XYZ myBaseP; // scaling/rotation center
408 SMESH_SequenceOfNode myNodes; // nodes for using in sewing
409 int myFlags; // see ExtrusionFlags
410 double myTolerance; // tolerance for sewing nodes
411 const TIDSortedElemSet* myElemsToUse; // elements to use for extrusion by normal
412 std::vector< PathPoint > myPathPoints; // points along a path
413 int (ExtrusParam::* myMakeNodesFun)(SMESHDS_Mesh*, // function of extrusion method
414 const SMDS_MeshNode*,
415 std::list<const SMDS_MeshNode*> &,
416 const bool);
417 int makeNodesByDir( SMESHDS_Mesh* mesh,
418 const SMDS_MeshNode* srcNode,
419 std::list<const SMDS_MeshNode*> & newNodes,
420 const bool makeMediumNodes);
421 int makeNodesByDirAndSew( SMESHDS_Mesh* mesh,
422 const SMDS_MeshNode* srcNode,
423 std::list<const SMDS_MeshNode*> & newNodes,
424 const bool makeMediumNodes);
425 int makeNodesByNormal2D( SMESHDS_Mesh* mesh,
426 const SMDS_MeshNode* srcNode,
427 std::list<const SMDS_MeshNode*> & newNodes,
428 const bool makeMediumNodes);
429 int makeNodesByNormal1D( SMESHDS_Mesh* mesh,
430 const SMDS_MeshNode* srcNode,
431 std::list<const SMDS_MeshNode*> & newNodes,
432 const bool makeMediumNodes);
433 int makeNodesAlongTrack( SMESHDS_Mesh* mesh,
434 const SMDS_MeshNode* srcNode,
435 std::list<const SMDS_MeshNode*> & newNodes,
436 const bool makeMediumNodes);
437 // step iteration
438 void beginStepIter( bool withMediumNodes );
439 bool moreSteps();
440 double nextStep();
441 std::vector< double > myCurSteps;
444 };
445
458 PGroupIDs ExtrusionSweep (TIDSortedElemSet theElems[2],
459 const gp_Vec& theStep,
460 const int theNbSteps,
461 TTElemOfElemListMap& newElemsMap,
462 const int theFlags,
463 const double theTolerance = 1.e-6);
464
475 PGroupIDs ExtrusionSweep (TIDSortedElemSet theElems[2],
476 ExtrusParam& theParams,
477 TTElemOfElemListMap& newElemsMap);
478
479
480 // Generate new elements by extrusion of theElements
481 // by theStep by theNbSteps
482
490 EXTR_CANT_GET_TANGENT
491 };
492
493 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet theElements[2],
494 SMESH_Mesh* theTrackMesh,
495 SMDS_ElemIteratorPtr theTrackIterator,
496 const SMDS_MeshNode* theNodeStart,
497 std::list<double>& theAngles,
498 const bool theAngleVariation,
499 std::list<double>& theScales,
500 const bool theScaleVariation,
501 const gp_Pnt* theRefPoint,
502 const bool theMakeGroups);
503 // Generate new elements by extrusion of theElements along path given by theTrackIterator,
504 // theHasAngles are the rotation angles, base point can be given by theRefPoint
505
506 PGroupIDs Transform (TIDSortedElemSet & theElements,
507 const gp_Trsf& theTrsf,
508 const bool theCopy,
509 const bool theMakeGroups,
510 SMESH_Mesh* theTargetMesh=0);
511 // Move or copy theElements applying theTrsf to their nodes
512
513 PGroupIDs Offset( TIDSortedElemSet & theElements,
514 const double theValue,
515 SMESH_Mesh* theTgtMesh,
516 const bool theMakeGroups,
517 const bool theCopyElements,
518 const bool theFixSelfIntersection);
519 // Make an offset mesh from a source 2D mesh
520
521 typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
522
523 void FindCoincidentNodes (TIDSortedNodeSet & theNodes,
524 const double theTolerance,
525 TListOfListOfNodes & theGroupsOfNodes,
526 bool theSeparateCornersAndMedium);
527 // Return list of group of nodes close to each other within theTolerance.
528 // Search among theNodes or in the whole mesh if theNodes is empty.
529
530 void MergeNodes (TListOfListOfNodes & theNodeGroups,
531 const bool theAvoidMakingHoles = false);
532 // In each group, the cdr of nodes are substituted by the first one
533 // in all elements.
534
535 typedef std::list< std::list< smIdType > > TListOfListOfElementsID;
536
537 void FindEqualElements(TIDSortedElemSet & theElements,
538 TListOfListOfElementsID & theGroupsOfElementsID);
539 // Return list of group of elements build on the same nodes.
540 // Search among theElements or in the whole mesh if theElements is empty.
541
542 void MergeElements(TListOfListOfElementsID & theGroupsOfElementsID);
543 // In each group remove all but first of elements.
544
545 void MergeEqualElements();
546 // Remove all but one of elements built on the same nodes.
547 // Return nb of successfully merged groups.
548
549 int SimplifyFace (const std::vector<const SMDS_MeshNode *>& faceNodes,
550 std::vector<const SMDS_MeshNode *>& poly_nodes,
551 std::vector<int>& quantities) const;
552 // Split face, defined by <faceNodes>, into several faces by repeating nodes.
553 // Is used by MergeNodes()
554
555 static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1,
556 const SMDS_MeshNode* theNode2,
557 const SMDS_MeshNode* theNode3 = 0);
558 // Return true if the three nodes are on a free border
559
560 static bool FindFreeBorder (const SMDS_MeshNode* theFirstNode,
561 const SMDS_MeshNode* theSecondNode,
562 const SMDS_MeshNode* theLastNode,
563 std::list< const SMDS_MeshNode* > & theNodes,
564 std::list< const SMDS_MeshElement* >& theFaces);
565 // Return nodes and faces of a free border if found
566
569 // for SewFreeBorder()
575 // for SewSideElements()
580 SEW_INTERNAL_ERROR
581 };
582
583
584 Sew_Error SewFreeBorder (const SMDS_MeshNode* theBorderFirstNode,
585 const SMDS_MeshNode* theBorderSecondNode,
586 const SMDS_MeshNode* theBorderLastNode,
587 const SMDS_MeshNode* theSide2FirstNode,
588 const SMDS_MeshNode* theSide2SecondNode,
589 const SMDS_MeshNode* theSide2ThirdNode = 0,
590 const bool theSide2IsFreeBorder = true,
591 const bool toCreatePolygons = false,
592 const bool toCreatePolyedrs = false);
593 // Sew the free border to the side2 by replacing nodes in
594 // elements on the free border with nodes of the elements
595 // of the side 2. If nb of links in the free border and
596 // between theSide2FirstNode and theSide2LastNode are different,
597 // additional nodes are inserted on a link provided that no
598 // volume elements share the split link.
599 // The side 2 is a free border if theSide2IsFreeBorder == true.
600 // Sewing is performed between the given first, second and last
601 // nodes on the sides.
602 // theBorderFirstNode is merged with theSide2FirstNode.
603 // if (!theSide2IsFreeBorder) then theSide2SecondNode gives
604 // the last node on the side 2, which will be merged with
605 // theBorderLastNode.
606 // if (theSide2IsFreeBorder) then theSide2SecondNode will
607 // be merged with theBorderSecondNode.
608 // if (theSide2IsFreeBorder && theSide2ThirdNode == 0) then
609 // the 2 free borders are sewn link by link and no additional
610 // nodes are inserted.
611 // Return false, if sewing failed.
612
613 Sew_Error SewSideElements (TIDSortedElemSet& theSide1,
614 TIDSortedElemSet& theSide2,
615 const SMDS_MeshNode* theFirstNode1ToMerge,
616 const SMDS_MeshNode* theFirstNode2ToMerge,
617 const SMDS_MeshNode* theSecondNode1ToMerge,
618 const SMDS_MeshNode* theSecondNode2ToMerge);
619 // Sew two sides of a mesh. Nodes belonging to theSide1 are
620 // merged with nodes of elements of theSide2.
621 // Number of elements in theSide1 and in theSide2 must be
622 // equal and they should have similar node connectivity.
623 // The nodes to merge should belong to side s borders and
624 // the first node should be linked to the second.
625
626 void InsertNodesIntoLink(const SMDS_MeshElement* theFace,
627 const SMDS_MeshNode* theBetweenNode1,
628 const SMDS_MeshNode* theBetweenNode2,
629 std::list<const SMDS_MeshNode*>& theNodesToInsert,
630 const bool toCreatePoly = false);
631 // insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2.
632 // If toCreatePoly is true, replace theFace by polygon, else split theFace.
633
634 void UpdateVolumes (const SMDS_MeshNode* theBetweenNode1,
635 const SMDS_MeshNode* theBetweenNode2,
636 std::list<const SMDS_MeshNode*>& theNodesToInsert);
637 // insert theNodesToInsert into all volumes, containing link
638 // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
639
640 void ConvertToQuadratic(const bool theForce3d, const bool theToBiQuad);
641 void ConvertToQuadratic(const bool theForce3d,
642 TIDSortedElemSet& theElements, const bool theToBiQuad);
643 // Converts all mesh to quadratic or bi-quadratic one, deletes old elements,
644 // replacing them with quadratic or bi-quadratic ones with the same id.
645 // If theForce3d = 1; this results in the medium node lying at the
646 // middle of the line segments connecting start and end node of a mesh element.
647 // If theForce3d = 0; this results in the medium node lying at the
648 // geometrical edge from which the mesh element is built.
649
650 bool ConvertFromQuadratic();
651 void ConvertFromQuadratic(TIDSortedElemSet& theElements);
652 // Converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing
653 // them with ordinary mesh elements with the same id.
654 // Returns true in case of success, false otherwise.
655
656 static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
657 const SMDS_MeshElement* elemInGroups,
658 SMESHDS_Mesh * aMesh);
659 // Add elemToAdd to the all groups the elemInGroups belongs to
660
661 static void RemoveElemFromGroups (const SMDS_MeshElement* element,
662 SMESHDS_Mesh * aMesh);
663 // remove element from the all groups
664
665 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
666 const SMDS_MeshElement* elemToAdd,
667 SMESHDS_Mesh * aMesh);
668 // replace elemToRm by elemToAdd in the all groups
669
670 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
671 const std::vector<const SMDS_MeshElement*>& elemToAdd,
672 SMESHDS_Mesh * aMesh);
673 // replace elemToRm by elemToAdd in the all groups
674
678 static void GetLinkedNodes( const SMDS_MeshNode* node,
679 TIDSortedElemSet & linkedNodes,
681
693 static Sew_Error FindMatchingNodes(std::set<const SMDS_MeshElement*>& theSide1,
694 std::set<const SMDS_MeshElement*>& theSide2,
695 const SMDS_MeshNode* theFirstNode1,
696 const SMDS_MeshNode* theFirstNode2,
697 const SMDS_MeshNode* theSecondNode1,
698 const SMDS_MeshNode* theSecondNode2,
699 TNodeNodeMap & theNodeReplaceMap);
700
707 static bool IsMedium(const SMDS_MeshNode* node,
708 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
709
710 int FindShape (const SMDS_MeshElement * theElem);
711 // Return an index of the shape theElem is on
712 // or zero if a shape not found
713
714 void DoubleElements( const TIDSortedElemSet& theElements );
715
716 bool DoubleNodes( const std::list< int >& theListOfNodes,
717 const std::list< int >& theListOfModifiedElems );
718
719 bool DoubleNodes( const TIDSortedElemSet& theElems,
720 const TIDSortedElemSet& theNodesNot,
721 const TIDSortedElemSet& theAffectedElems );
722
723 bool AffectedElemGroupsInRegion( const TIDSortedElemSet& theElems,
724 const TIDSortedElemSet& theNodesNot,
725 const TopoDS_Shape& theShape,
726 TIDSortedElemSet& theAffectedElems);
727
728 bool DoubleNodesInRegion( const TIDSortedElemSet& theElems,
729 const TIDSortedElemSet& theNodesNot,
730 const TopoDS_Shape& theShape );
731
732 double OrientedAngle(const gp_Pnt& p0, const gp_Pnt& p1, const gp_Pnt& g1, const gp_Pnt& g2);
733
734 bool DoubleNodesOnGroupBoundaries( const std::vector<TIDSortedElemSet>& theElems,
735 bool createJointElems,
736 bool onAllBoundaries);
737
738 bool CreateFlatElementsOnFacesGroups( const std::vector<TIDSortedElemSet>& theElems );
739
740 void CreateHoleSkin(double radius,
741 const TopoDS_Shape& theShape,
743 const char* groupName,
744 std::vector<double>& nodesCoords,
745 std::vector<std::vector<int> >& listOfListOfNodes);
746
752 bool Make2DMeshFrom3D();
753
755
756 int MakeBoundaryMesh(const TIDSortedElemSet& elements,
757 Bnd_Dimension dimension,
758 SMESH_Group* group = 0,
759 SMESH_Mesh* targetMesh = 0,
760 bool toCopyElements = false,
761 bool toCopyExistingBondary = false,
762 bool toAddExistingBondary = false,
763 bool aroundElements = false,
764 bool toCreateAllElements= false);
765
766 private:
767
772 smIdType convertElemToQuadratic(SMESHDS_SubMesh * theSm,
773 SMESH_MesherHelper& theHelper,
774 const bool theForce3d);
775
780 smIdType removeQuadElem( SMESHDS_SubMesh * theSm,
782 const int theShapeID);
791 PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
792 const SMESH_SequenceOfElemPtr& elemGens,
793 const std::string& postfix,
794 SMESH_Mesh* targetMesh=0,
795 const bool topPresent=true);
804 void sweepElement(const SMDS_MeshElement* elem,
805 const std::vector<TNodeOfNodeListMapItr> & newNodesItVec,
806 std::list<const SMDS_MeshElement*>& newElems,
807 const size_t nbSteps,
808 SMESH_SequenceOfElemPtr& srcElements);
809
820 bool applyMerge( const SMDS_MeshElement* elems,
821 std::vector< ElemFeatures >& newElemDefs,
822 TNodeNodeMap& nodeNodeMap,
823 const bool avoidMakingHoles );
833 void makeWalls (TNodeOfNodeListMap & mapNewNodes,
834 TTElemOfElemListMap & newElemsMap,
835 TElemOfVecOfNnlmiMap & elemNewNodesMap,
836 TIDSortedElemSet& elemSet,
837 const int nbSteps,
838 SMESH_SequenceOfElemPtr& srcElements);
839
840 static void linearAngleVariation(const int NbSteps,
841 std::list<double>& theAngles);
842 static void linearScaleVariation(const int NbSteps,
843 std::list<double>& theScales);
844
845 bool doubleNodes( SMESHDS_Mesh* theMeshDS,
846 const TIDSortedElemSet& theElems,
847 const TIDSortedElemSet& theNodesNot,
848 TNodeNodeMap& theNodeNodeMap,
849 const bool theIsDoubleElem );
850
851 void copyPosition( const SMDS_MeshNode* from,
852 const SMDS_MeshNode* to );
853
854private:
855
857
858 // Nodes and elements created during last operation
860
861 // Description of error/warning occurred during last operation
863};
864
865#endif
Handle(SALOME_InteractiveObject) GeomSelectionTools
Return the first selected Salome Interactive Object (Handle(Salome_InteractiveObject))
Definition: GeomSelectionTools.cxx:97
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
Definition: SMDSAbs_ElementType.hxx:34
@ SMDSAbs_All
Definition: SMDSAbs_ElementType.hxx:35
@ SMDSAbs_Volume
Definition: SMDSAbs_ElementType.hxx:39
@ SMDSAbs_Ball
Definition: SMDSAbs_ElementType.hxx:41
boost::shared_ptr< SMDS_Iterator< const SMDS_MeshElement * > > SMDS_ElemIteratorPtr
Definition: SMDS_ElemIterator.hxx:43
boost::shared_ptr< SMESH_ComputeError > SMESH_ComputeErrorPtr
Definition: SMESH_ComputeError.hxx:38
std::set< const SMDS_MeshNode *, TIDCompare > TIDSortedNodeSet
Definition: SMESH_OctreeNode.hxx:51
#define SMESH_EXPORT
Definition: SMESH_SMESH.hxx:37
NCollection_Sequence< SMDS_MeshNodePtr > SMESH_SequenceOfNode
Definition: SMESH_TypeDefs.hxx:305
std::map< const SMDS_MeshNode *, const SMDS_MeshNode *, TIDCompare > TNodeNodeMap
Set of elements sorted by ID, to be used to assure predictability of edition.
Definition: SMESH_TypeDefs.hxx:55
std::set< const SMDS_MeshElement *, TIDCompare > TIDSortedElemSet
Definition: SMESH_TypeDefs.hxx:58
std::vector< const SMDS_MeshElement * > SMESH_SequenceOfElemPtr
Definition: SMESH_TypeDefs.hxx:299
Base class for elements.
Definition: SMDS_MeshElement.hxx:56
Mesh face.
Definition: SMDS_MeshFace.hxx:41
Definition: SMDS_MeshNode.hxx:36
Definition: SMDS_VolumeTool.hxx:53
Definition: SMESHDS_Group.hxx:40
Definition: SMESHDS_Mesh.hxx:98
Definition: SMESHDS_SubMesh.hxx:48
Definition: SMESH_Group.hxx:43
Generator of nodes for extrusion functionality.
Definition: SMESH_MeshEditor.hxx:347
bool ToMakeBoundary() const
Definition: SMESH_MeshEditor.hxx:380
const TIDSortedElemSet * myElemsToUse
Definition: SMESH_MeshEditor.hxx:411
SMESH_SequenceOfNode & ChangeNodes()
Definition: SMESH_MeshEditor.hxx:378
int MakeNodes(SMESHDS_Mesh *mesh, const SMDS_MeshNode *srcNode, std::list< const SMDS_MeshNode * > &newNodes, const bool makeMediumNodes)
Definition: SMESH_MeshEditor.hxx:394
bool ToUseInpElemsOnly() const
Definition: SMESH_MeshEditor.hxx:382
bool myWithMediumNodes
Definition: SMESH_MeshEditor.hxx:442
std::vector< double > myScales
Definition: SMESH_MeshEditor.hxx:405
bool IsScaleVariation() const
Definition: SMESH_MeshEditor.hxx:383
gp_Dir myDir
Definition: SMESH_MeshEditor.hxx:403
int NbSteps() const
Definition: SMESH_MeshEditor.hxx:385
gp_XYZ myBaseP
Definition: SMESH_MeshEditor.hxx:407
bool ToMakeGroups() const
Definition: SMESH_MeshEditor.hxx:381
SMESH_SequenceOfNode myNodes
Definition: SMESH_MeshEditor.hxx:408
std::vector< double > myCurSteps
Definition: SMESH_MeshEditor.hxx:441
std::vector< PathPoint > myPathPoints
Definition: SMESH_MeshEditor.hxx:412
int & Flags()
Definition: SMESH_MeshEditor.hxx:379
std::vector< double > myAngles
Definition: SMESH_MeshEditor.hxx:406
int myNextStep
Definition: SMESH_MeshEditor.hxx:443
bool IsAngleVariation() const
Definition: SMESH_MeshEditor.hxx:384
int myFlags
Definition: SMESH_MeshEditor.hxx:409
double myTolerance
Definition: SMESH_MeshEditor.hxx:410
Handle(TColStd_HSequenceOfReal) mySteps
Editor of a mesh.
Definition: SMESH_MeshEditor.hxx:74
std::unique_ptr< std::list< int > > PGroupIDs
Definition: SMESH_MeshEditor.hxx:309
Extrusion_Error
Definition: SMESH_MeshEditor.hxx:483
@ EXTR_NO_ELEMENTS
Definition: SMESH_MeshEditor.hxx:485
@ EXTR_BAD_STARTING_NODE
Definition: SMESH_MeshEditor.hxx:488
@ EXTR_PATH_NOT_EDGE
Definition: SMESH_MeshEditor.hxx:486
@ EXTR_OK
Definition: SMESH_MeshEditor.hxx:484
@ EXTR_BAD_PATH_SHAPE
Definition: SMESH_MeshEditor.hxx:487
@ EXTR_BAD_ANGLES_NUMBER
Definition: SMESH_MeshEditor.hxx:489
SMESH_ComputeErrorPtr myError
Definition: SMESH_MeshEditor.hxx:862
SMESH_Mesh * GetMesh()
Definition: SMESH_MeshEditor.hxx:79
std::map< const SMDS_MeshElement *, TVecOfNnlmiMap, TElemSort > TElemOfVecOfNnlmiMap
Definition: SMESH_MeshEditor.hxx:308
Bnd_Dimension
Definition: SMESH_MeshEditor.hxx:754
TIDTypeCompare TElemSort
Definition: SMESH_MeshEditor.hxx:302
ExtrusionFlags
Flags of extrusion.
Definition: SMESH_MeshEditor.hxx:333
std::list< std::list< smIdType > > TListOfListOfElementsID
Definition: SMESH_MeshEditor.hxx:535
std::list< std::list< const SMDS_MeshNode * > > TListOfListOfNodes
Definition: SMESH_MeshEditor.hxx:521
SplitVolumToTetraFlags
Definition: SMESH_MeshEditor.hxx:240
@ HEXA_TO_6
Definition: SMESH_MeshEditor.hxx:241
@ HEXA_TO_2_PRISMS
Definition: SMESH_MeshEditor.hxx:243
@ HEXA_TO_24
Definition: SMESH_MeshEditor.hxx:242
SMESH_Mesh * myMesh
Definition: SMESH_MeshEditor.hxx:856
SMESH_SequenceOfElemPtr myLastCreatedElems
Definition: SMESH_MeshEditor.hxx:859
SMESH_ComputeErrorPtr & GetError()
Definition: SMESH_MeshEditor.hxx:85
std::map< const SMDS_MeshNode *, std::list< const SMDS_MeshNode * > > TNodeOfNodeListMap
Definition: SMESH_MeshEditor.hxx:305
std::map< const SMDS_MeshElement *, std::list< const SMDS_MeshElement * >, TElemSort > TTElemOfElemListMap
Definition: SMESH_MeshEditor.hxx:304
const SMESH_SequenceOfElemPtr & GetLastCreatedNodes() const
Definition: SMESH_MeshEditor.hxx:82
TNodeOfNodeListMap::iterator TNodeOfNodeListMapItr
Definition: SMESH_MeshEditor.hxx:306
std::map< const SMDS_MeshElement *, int, TIDCompare > TFacetOfElem
2nd arg of SplitVolumes()
Definition: SMESH_MeshEditor.hxx:237
bool isVariantOverConstrained(SMDS_VolumeTool &vol, const int *connVariants)
Return true if one of the tetras included in the variant will be an overconstrained tetra.
std::vector< TNodeOfNodeListMapItr > TVecOfNnlmiMap
Definition: SMESH_MeshEditor.hxx:307
Sew_Error
Definition: SMESH_MeshEditor.hxx:567
@ SEW_DIFF_NB_OF_ELEMENTS
Definition: SMESH_MeshEditor.hxx:576
@ SEW_BAD_SIDE1_NODES
Definition: SMESH_MeshEditor.hxx:578
@ SEW_TOPO_DIFF_SETS_OF_ELEMENTS
Definition: SMESH_MeshEditor.hxx:577
@ SEW_VOLUMES_TO_SPLIT
Definition: SMESH_MeshEditor.hxx:574
@ SEW_OK
Definition: SMESH_MeshEditor.hxx:568
@ SEW_BOTH_BORDERS_NOT_FOUND
Definition: SMESH_MeshEditor.hxx:572
@ SEW_BORDER2_NOT_FOUND
Definition: SMESH_MeshEditor.hxx:571
@ SEW_BAD_SIDE_NODES
Definition: SMESH_MeshEditor.hxx:573
@ SEW_BAD_SIDE2_NODES
Definition: SMESH_MeshEditor.hxx:579
@ SEW_BORDER1_NOT_FOUND
Definition: SMESH_MeshEditor.hxx:570
SmoothMethod
Definition: SMESH_MeshEditor.hxx:285
const SMESH_SequenceOfElemPtr & GetLastCreatedElems() const
Definition: SMESH_MeshEditor.hxx:83
Definition: SMESH_Mesh.hxx:80
It helps meshers to add elements and provides other utilities.
Definition: SMESH_MesherHelper.hxx:84
Definition: SMESH_subMesh.hxx:61
static SMESH_NodeSearcher * theNodeSearcher
Definition: SMESH_MeshEditor_i.cxx:176
boost::shared_ptr< NumericalFunctor > NumericalFunctorPtr
Definition: SMESH_Controls.hxx:64
Bnd_Dimension
Definition: SMESH_MeshEditor.idl:35
@ BND_1DFROM2D
Definition: SMESH_MeshEditor.idl:35
@ BND_1DFROM3D
Definition: SMESH_MeshEditor.idl:35
@ BND_2DFROM3D
Definition: SMESH_MeshEditor.idl:35
const long EXTRUSION_FLAG_BOUNDARY
Auxiliary flags for advanced extrusion.
Definition: SMESH_Mesh.idl:264
const long EXTRUSION_FLAG_SEW
Definition: SMESH_Mesh.idl:265
Searcher for elements.
Definition: SMESH_MeshAlgos.hxx:75
< Features of element to create
Definition: SMESH_MeshEditor.hxx:89
bool myIsPoly
Definition: SMESH_MeshEditor.hxx:91
ElemFeatures & Init(double diameter)
Definition: SMESH_MeshEditor.hxx:105
ElemFeatures & SetID(smIdType ID)
Definition: SMESH_MeshEditor.hxx:118
std::vector< const SMDS_MeshNode * > myNodes
Definition: SMESH_MeshEditor.hxx:95
ElemFeatures & SetQuad(bool isQuad)
Definition: SMESH_MeshEditor.hxx:117
ElemFeatures & SetPoly(bool isPoly)
Definition: SMESH_MeshEditor.hxx:116
std::vector< int > myPolyhedQuantities
Definition: SMESH_MeshEditor.hxx:94
ElemFeatures & Init(const std::vector< int > &quanities, bool isQuad=false)
Definition: SMESH_MeshEditor.hxx:112
ElemFeatures & Init(SMDSAbs_ElementType type, bool isPoly=false, bool isQuad=false)
Definition: SMESH_MeshEditor.hxx:100
SMDSAbs_ElementType myType
Definition: SMESH_MeshEditor.hxx:90
ElemFeatures(SMDSAbs_ElementType type=SMDSAbs_All, bool isPoly=false, bool isQuad=false)
Definition: SMESH_MeshEditor.hxx:97
ElemFeatures & Init(std::vector< int > &quanities, bool isQuad=false)
Definition: SMESH_MeshEditor.hxx:108
double myBallDiameter
Definition: SMESH_MeshEditor.hxx:93
smIdType myID
Definition: SMESH_MeshEditor.hxx:92
Point on extrusion path.
Definition: SMESH_MeshEditor.hxx:351
gp_Pnt myPnt
Definition: SMESH_MeshEditor.hxx:352
gp_Dir myTgt
Definition: SMESH_MeshEditor.hxx:353
PathPoint()
Definition: SMESH_MeshEditor.hxx:355
double myAngle
Definition: SMESH_MeshEditor.hxx:354
Searcher for the node closest to a point.
Definition: SMESH_MeshAlgos.hxx:59
Comparator of elements by ID for usage in std containers.
Definition: SMDS_MeshElement.hxx:202