1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
23 // File : SMESH_MeshEditor.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_SequenceOfElemPtr.hxx"
37 #include "SMESH_SequenceOfNode.hxx"
39 #include <utilities.h>
41 #include <TColStd_HSequenceOfReal.hxx>
53 class SMESH_MesherHelper;
56 typedef std::map<const SMDS_MeshElement*,
57 std::list<const SMDS_MeshElement*> > TElemOfElemListMap;
58 typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
60 //!< Set of elements sorted by ID, to be used to assure predictability of edition
61 typedef std::set< const SMDS_MeshElement*, TIDCompare > TIDSortedElemSet;
63 typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* > NLink;
66 //=======================================================================
68 * \brief Searcher for the node closest to point
70 //=======================================================================
71 struct SMESH_NodeSearcher
73 virtual const SMDS_MeshNode* FindClosestTo( const gp_Pnt& pnt ) = 0;
74 virtual void MoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt ) = 0;
77 //=======================================================================
79 * \brief Find elements of given type where the given point is IN or ON.
80 * Returns nb of found elements and elements them-selves.
81 * Another task is to find out if the given point is out of closed 2D mesh.
83 * 'ALL' type means elements of any type excluding nodes and 0D elements
85 //=======================================================================
87 struct SMESH_ElementSearcher
89 virtual int FindElementsByPoint(const gp_Pnt& point,
90 SMDSAbs_ElementType type,
91 std::vector< const SMDS_MeshElement* >& foundElems)=0;
93 virtual TopAbs_State GetPointState(const gp_Pnt& point) = 0;
96 //=======================================================================
98 * \brief A sorted pair of nodes
100 //=======================================================================
102 struct SMESH_TLink: public NLink
104 SMESH_TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
105 { if ( n1->GetID() < n2->GetID() ) std::swap( first, second ); }
106 SMESH_TLink(const NLink& link ):NLink( link )
107 { if ( first->GetID() < second->GetID() ) std::swap( first, second ); }
108 const SMDS_MeshNode* node1() const { return first; }
109 const SMDS_MeshNode* node2() const { return second; }
112 //=======================================================================
114 * \brief SMESH_TLink knowing its orientation
116 //=======================================================================
118 struct SMESH_OrientedLink: public SMESH_TLink
121 SMESH_OrientedLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 )
122 : SMESH_TLink( n1, n2 ), _reversed( n1 != node1() ) {}
125 // ============================================================
127 * \brief Editor of a mesh
129 // ============================================================
131 class SMESH_EXPORT SMESH_MeshEditor
134 //------------------------------------------
136 * \brief SMDS_MeshNode -> gp_XYZ convertor
138 //------------------------------------------
139 struct TNodeXYZ : public gp_XYZ
141 const SMDS_MeshNode* _node;
142 TNodeXYZ( const SMDS_MeshElement* e):gp_XYZ(0,0,0),_node(0) {
144 ASSERT( e->GetType() == SMDSAbs_Node );
145 _node = static_cast<const SMDS_MeshNode*>(e);
146 SetCoord( _node->X(), _node->Y(), _node->Z() );
149 double Distance(const SMDS_MeshNode* n) const { return (TNodeXYZ( n )-*this).Modulus(); }
150 double SquareDistance(const SMDS_MeshNode* n) const { return (TNodeXYZ( n )-*this).SquareModulus(); }
151 bool operator==(const TNodeXYZ& other) const { return _node == other._node; }
156 SMESH_MeshEditor( SMESH_Mesh* theMesh );
161 SMDS_MeshElement* AddElement(const std::vector<const SMDS_MeshNode*> & nodes,
162 const SMDSAbs_ElementType type,
168 SMDS_MeshElement* AddElement(const std::vector<int> & nodeIDs,
169 const SMDSAbs_ElementType type,
173 bool Remove (const std::list< int >& theElemIDs, const bool isNodes);
174 // Remove a node or an element.
175 // Modify a compute state of sub-meshes which become empty
177 bool InverseDiag (const SMDS_MeshElement * theTria1,
178 const SMDS_MeshElement * theTria2 );
179 // Replace two neighbour triangles with ones built on the same 4 nodes
180 // but having other common link.
181 // Return False if args are improper
183 bool InverseDiag (const SMDS_MeshNode * theNode1,
184 const SMDS_MeshNode * theNode2 );
185 // Replace two neighbour triangles sharing theNode1-theNode2 link
186 // with ones built on the same 4 nodes but having other common link.
187 // Return false if proper faces not found
189 bool DeleteDiag (const SMDS_MeshNode * theNode1,
190 const SMDS_MeshNode * theNode2 );
191 // Replace two neighbour triangles sharing theNode1-theNode2 link
192 // with a quadrangle built on the same 4 nodes.
193 // Return false if proper faces not found
195 bool Reorient (const SMDS_MeshElement * theElement);
196 // Reverse theElement orientation
200 * \brief Fuse neighbour triangles into quadrangles.
201 * \param theElems - The triangles to be fused.
202 * \param theCriterion - Is used to choose a neighbour to fuse with.
203 * \param theMaxAngle - Is a max angle between element normals at which fusion
204 * is still performed; theMaxAngle is mesured in radians.
205 * \retval bool - Success or not.
207 bool TriToQuad (TIDSortedElemSet & theElems,
208 SMESH::Controls::NumericalFunctorPtr theCriterion,
209 const double theMaxAngle);
212 * \brief Split quadrangles into triangles.
213 * \param theElems - The faces to be splitted.
214 * \param theCriterion - Is used to choose a diagonal for splitting.
215 * \retval bool - Success or not.
217 bool QuadToTri (TIDSortedElemSet & theElems,
218 SMESH::Controls::NumericalFunctorPtr theCriterion);
221 * \brief Split quadrangles into triangles.
222 * \param theElems - The faces to be splitted.
223 * \param the13Diag - Is used to choose a diagonal for splitting.
224 * \retval bool - Success or not.
226 bool QuadToTri (TIDSortedElemSet & theElems,
227 const bool the13Diag);
230 * \brief Find better diagonal for splitting.
231 * \param theQuad - The face to find better splitting of.
232 * \param theCriterion - Is used to choose a diagonal for splitting.
233 * \retval int - 1 for 1-3 diagonal, 2 for 2-4, -1 - for errors.
235 int BestSplit (const SMDS_MeshElement* theQuad,
236 SMESH::Controls::NumericalFunctorPtr theCriterion);
239 enum SplitVolumToTetraFlags { HEXA_TO_5 = 1, HEXA_TO_6 = 2 };//!<arg of SplitVolumesIntoTetra()
241 * \brief Split volumic elements into tetrahedra.
243 //void SplitVolumesIntoTetra (const TIDSortedElemSet & theElems, const int theMethodFlags);
246 enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL };
248 void Smooth (TIDSortedElemSet & theElements,
249 std::set<const SMDS_MeshNode*> & theFixedNodes,
250 const SmoothMethod theSmoothMethod,
251 const int theNbIterations,
252 double theTgtAspectRatio = 1.0,
253 const bool the2D = true);
254 // Smooth theElements using theSmoothMethod during theNbIterations
255 // or until a worst element has aspect ratio <= theTgtAspectRatio.
256 // Aspect Ratio varies in range [1.0, inf].
257 // If theElements is empty, the whole mesh is smoothed.
258 // theFixedNodes contains additionally fixed nodes. Nodes built
259 // on edges and boundary nodes are always fixed.
260 // If the2D, smoothing is performed using UV parameters of nodes
261 // on geometrical faces
263 typedef std::auto_ptr< std::list<int> > PGroupIDs;
265 PGroupIDs RotationSweep (TIDSortedElemSet & theElements,
266 const gp_Ax1& theAxis,
267 const double theAngle,
268 const int theNbSteps,
269 const double theToler,
270 const bool theMakeGroups,
271 const bool theMakeWalls=true);
272 // Generate new elements by rotation of theElements around theAxis
273 // by theAngle by theNbSteps
276 * Auxilary flag for advanced extrusion.
277 * BOUNDARY: create or not boundary for result of extrusion
278 * SEW: try to use existing nodes or create new nodes in any case
280 enum ExtrusionFlags {
281 EXTRUSION_FLAG_BOUNDARY = 0x01,
282 EXTRUSION_FLAG_SEW = 0x02
286 * special structire for control of extrusion functionality
289 gp_Dir myDir; // direction of extrusion
290 Handle(TColStd_HSequenceOfReal) mySteps; // magnitudes for each step
291 SMESH_SequenceOfNode myNodes; // nodes for using in sewing
295 * Create new node in the mesh with given coordinates
296 * (auxilary for advanced extrusion)
298 const SMDS_MeshNode* CreateNode(const double x,
301 const double tolnode,
302 SMESH_SequenceOfNode& aNodes);
305 * Generate new elements by extrusion of theElements
306 * It is a method used in .idl file. All functionality
307 * is implemented in the next method (see below) which
308 * is used in the cuurent method.
309 * param theElems - list of elements for extrusion
310 * param newElemsMap returns history of extrusion
311 * param theFlags set flags for performing extrusion (see description
312 * of enum ExtrusionFlags for additional information)
313 * param theTolerance - uses for comparing locations of nodes if flag
314 * EXTRUSION_FLAG_SEW is set
316 PGroupIDs ExtrusionSweep (TIDSortedElemSet & theElems,
317 const gp_Vec& theStep,
318 const int theNbSteps,
319 TElemOfElemListMap& newElemsMap,
320 const bool theMakeGroups,
321 const int theFlags = EXTRUSION_FLAG_BOUNDARY,
322 const double theTolerance = 1.e-6);
325 * Generate new elements by extrusion of theElements
326 * param theElems - list of elements for extrusion
327 * param newElemsMap returns history of extrusion
328 * param theFlags set flags for performing extrusion (see description
329 * of enum ExtrusionFlags for additional information)
330 * param theTolerance - uses for comparing locations of nodes if flag
331 * EXTRUSION_FLAG_SEW is set
332 * param theParams - special structure for manage of extrusion
334 PGroupIDs ExtrusionSweep (TIDSortedElemSet & theElems,
335 ExtrusParam& theParams,
336 TElemOfElemListMap& newElemsMap,
337 const bool theMakeGroups,
339 const double theTolerance);
342 // Generate new elements by extrusion of theElements
343 // by theStep by theNbSteps
345 enum Extrusion_Error {
350 EXTR_BAD_STARTING_NODE,
351 EXTR_BAD_ANGLES_NUMBER,
352 EXTR_CANT_GET_TANGENT
355 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet & theElements,
356 SMESH_subMesh* theTrackPattern,
357 const SMDS_MeshNode* theNodeStart,
358 const bool theHasAngles,
359 std::list<double>& theAngles,
360 const bool theLinearVariation,
361 const bool theHasRefPoint,
362 const gp_Pnt& theRefPoint,
363 const bool theMakeGroups);
364 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet & theElements,
365 SMESH_Mesh* theTrackPattern,
366 const SMDS_MeshNode* theNodeStart,
367 const bool theHasAngles,
368 std::list<double>& theAngles,
369 const bool theLinearVariation,
370 const bool theHasRefPoint,
371 const gp_Pnt& theRefPoint,
372 const bool theMakeGroups);
373 // Generate new elements by extrusion of theElements along path given by theTrackPattern,
374 // theHasAngles are the rotation angles, base point can be given by theRefPoint
376 PGroupIDs Transform (TIDSortedElemSet & theElements,
377 const gp_Trsf& theTrsf,
379 const bool theMakeGroups,
380 SMESH_Mesh* theTargetMesh=0);
381 // Move or copy theElements applying theTrsf to their nodes
385 * Generate new elements by extrusion of theElements
386 * param theElems - list of elements for scale
387 * param thePoint - base point for scale
388 * param theScaleFact - scale factors for axises
389 * param theCopy - allows copying the translated elements
390 * param theMakeGroups - forces the generation of new groups from existing ones
391 * param theTargetMesh - the name of the newly created mesh
392 * return instance of Mesh class
394 PGroupIDs Scale (TIDSortedElemSet& theElements,
395 const gp_Pnt& thePoint,
396 const std::list<double>& theScaleFact,
398 const bool theMakeGroups,
399 SMESH_Mesh* theTargetMesh=0);
401 typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
403 void FindCoincidentNodes (std::set<const SMDS_MeshNode*> & theNodes,
404 const double theTolerance,
405 TListOfListOfNodes & theGroupsOfNodes);
406 // Return list of group of nodes close to each other within theTolerance.
407 // Search among theNodes or in the whole mesh if theNodes is empty.
410 * \brief Return SMESH_NodeSearcher
412 SMESH_NodeSearcher* GetNodeSearcher();
415 * \brief Return SMESH_ElementSearcher
417 SMESH_ElementSearcher* GetElementSearcher();
419 * \brief Return true if the point is IN or ON of the element
421 static bool isOut( const SMDS_MeshElement* element, const gp_Pnt& point, double tol );
424 int SimplifyFace (const std::vector<const SMDS_MeshNode *> faceNodes,
425 std::vector<const SMDS_MeshNode *>& poly_nodes,
426 std::vector<int>& quantities) const;
427 // Split face, defined by <faceNodes>, into several faces by repeating nodes.
428 // Is used by MergeNodes()
430 void MergeNodes (TListOfListOfNodes & theNodeGroups);
431 // In each group, the cdr of nodes are substituted by the first one
434 typedef std::list< std::list< int > > TListOfListOfElementsID;
436 void FindEqualElements(std::set<const SMDS_MeshElement*> & theElements,
437 TListOfListOfElementsID & theGroupsOfElementsID);
438 // Return list of group of elements build on the same nodes.
439 // Search among theElements or in the whole mesh if theElements is empty.
441 void MergeElements(TListOfListOfElementsID & theGroupsOfElementsID);
442 // In each group remove all but first of elements.
444 void MergeEqualElements();
445 // Remove all but one of elements built on the same nodes.
446 // Return nb of successfully merged groups.
448 static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1,
449 const SMDS_MeshNode* theNode2,
450 const SMDS_MeshNode* theNode3 = 0);
451 // Return true if the three nodes are on a free border
453 static bool FindFreeBorder (const SMDS_MeshNode* theFirstNode,
454 const SMDS_MeshNode* theSecondNode,
455 const SMDS_MeshNode* theLastNode,
456 std::list< const SMDS_MeshNode* > & theNodes,
457 std::list< const SMDS_MeshElement* >& theFaces);
458 // Return nodes and faces of a free border if found
462 // for SewFreeBorder()
463 SEW_BORDER1_NOT_FOUND,
464 SEW_BORDER2_NOT_FOUND,
465 SEW_BOTH_BORDERS_NOT_FOUND,
467 SEW_VOLUMES_TO_SPLIT,
468 // for SewSideElements()
469 SEW_DIFF_NB_OF_ELEMENTS,
470 SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
477 Sew_Error SewFreeBorder (const SMDS_MeshNode* theBorderFirstNode,
478 const SMDS_MeshNode* theBorderSecondNode,
479 const SMDS_MeshNode* theBorderLastNode,
480 const SMDS_MeshNode* theSide2FirstNode,
481 const SMDS_MeshNode* theSide2SecondNode,
482 const SMDS_MeshNode* theSide2ThirdNode = 0,
483 const bool theSide2IsFreeBorder = true,
484 const bool toCreatePolygons = false,
485 const bool toCreatePolyedrs = false);
486 // Sew the free border to the side2 by replacing nodes in
487 // elements on the free border with nodes of the elements
488 // of the side 2. If nb of links in the free border and
489 // between theSide2FirstNode and theSide2LastNode are different,
490 // additional nodes are inserted on a link provided that no
491 // volume elements share the splitted link.
492 // The side 2 is a free border if theSide2IsFreeBorder == true.
493 // Sewing is peformed between the given first, second and last
494 // nodes on the sides.
495 // theBorderFirstNode is merged with theSide2FirstNode.
496 // if (!theSide2IsFreeBorder) then theSide2SecondNode gives
497 // the last node on the side 2, which will be merged with
498 // theBorderLastNode.
499 // if (theSide2IsFreeBorder) then theSide2SecondNode will
500 // be merged with theBorderSecondNode.
501 // if (theSide2IsFreeBorder && theSide2ThirdNode == 0) then
502 // the 2 free borders are sewn link by link and no additional
503 // nodes are inserted.
504 // Return false, if sewing failed.
506 Sew_Error SewSideElements (TIDSortedElemSet& theSide1,
507 TIDSortedElemSet& theSide2,
508 const SMDS_MeshNode* theFirstNode1ToMerge,
509 const SMDS_MeshNode* theFirstNode2ToMerge,
510 const SMDS_MeshNode* theSecondNode1ToMerge,
511 const SMDS_MeshNode* theSecondNode2ToMerge);
512 // Sew two sides of a mesh. Nodes belonging to theSide1 are
513 // merged with nodes of elements of theSide2.
514 // Number of elements in theSide1 and in theSide2 must be
515 // equal and they should have similar node connectivity.
516 // The nodes to merge should belong to side s borders and
517 // the first node should be linked to the second.
519 void InsertNodesIntoLink(const SMDS_MeshElement* theFace,
520 const SMDS_MeshNode* theBetweenNode1,
521 const SMDS_MeshNode* theBetweenNode2,
522 std::list<const SMDS_MeshNode*>& theNodesToInsert,
523 const bool toCreatePoly = false);
524 // insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2.
525 // If toCreatePoly is true, replace theFace by polygon, else split theFace.
527 void UpdateVolumes (const SMDS_MeshNode* theBetweenNode1,
528 const SMDS_MeshNode* theBetweenNode2,
529 std::list<const SMDS_MeshNode*>& theNodesToInsert);
530 // insert theNodesToInsert into all volumes, containing link
531 // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
533 void ConvertToQuadratic(const bool theForce3d);
534 //converts all mesh to quadratic one, deletes old elements, replacing
535 //them with quadratic ones with the same id.
537 bool ConvertFromQuadratic();
538 //converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing
539 //them with ordinary mesh elements with the same id.
541 static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
542 const SMDS_MeshElement* elemInGroups,
543 SMESHDS_Mesh * aMesh);
544 // Add elemToAdd to the all groups the elemInGroups belongs to
546 static void RemoveElemFromGroups (const SMDS_MeshElement* element,
547 SMESHDS_Mesh * aMesh);
548 // remove element from the all groups
550 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
551 const SMDS_MeshElement* elemToAdd,
552 SMESHDS_Mesh * aMesh);
553 // replace elemToRm by elemToAdd in the all groups
555 // static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
556 // const std::vector<const SMDS_MeshElement*>& elemToAdd,
557 // SMESHDS_Mesh * aMesh);
558 // replace elemToRm by elemToAdd in the all groups
561 * \brief Return nodes linked to the given one in elements of the type
563 static void GetLinkedNodes( const SMDS_MeshNode* node,
564 TIDSortedElemSet & linkedNodes,
565 SMDSAbs_ElementType type = SMDSAbs_All );
567 static const SMDS_MeshElement* FindFaceInSet(const SMDS_MeshNode* n1,
568 const SMDS_MeshNode* n2,
569 const TIDSortedElemSet& elemSet,
570 const TIDSortedElemSet& avoidSet,
573 // Return a face having linked nodes n1 and n2 and which is
574 // - not in avoidSet,
575 // - in elemSet provided that !elemSet.empty()
576 // i1 and i2 optionally returns indices of n1 and n2
579 * \brief Find corresponding nodes in two sets of faces
580 * \param theSide1 - first face set
581 * \param theSide2 - second first face
582 * \param theFirstNode1 - a boundary node of set 1
583 * \param theFirstNode2 - a node of set 2 corresponding to theFirstNode1
584 * \param theSecondNode1 - a boundary node of set 1 linked with theFirstNode1
585 * \param theSecondNode2 - a node of set 2 corresponding to theSecondNode1
586 * \param nReplaceMap - output map of corresponding nodes
587 * \retval Sew_Error - is a success or not
589 static Sew_Error FindMatchingNodes(std::set<const SMDS_MeshElement*>& theSide1,
590 std::set<const SMDS_MeshElement*>& theSide2,
591 const SMDS_MeshNode* theFirstNode1,
592 const SMDS_MeshNode* theFirstNode2,
593 const SMDS_MeshNode* theSecondNode1,
594 const SMDS_MeshNode* theSecondNode2,
595 TNodeNodeMap & theNodeReplaceMap);
598 * \brief Returns true if given node is medium
599 * \param n - node to check
600 * \param typeToCheck - type of elements containing the node to ask about node status
601 * \retval bool - check result
603 static bool IsMedium(const SMDS_MeshNode* node,
604 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
606 int FindShape (const SMDS_MeshElement * theElem);
607 // Return an index of the shape theElem is on
608 // or zero if a shape not found
610 SMESH_Mesh * GetMesh() { return myMesh; }
612 SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
614 const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
616 const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
618 bool DoubleNodes( const std::list< int >& theListOfNodes,
619 const std::list< int >& theListOfModifiedElems );
621 bool DoubleNodes( const TIDSortedElemSet& theElems,
622 const TIDSortedElemSet& theNodesNot,
623 const TIDSortedElemSet& theAffectedElems );
625 bool DoubleNodesInRegion( const TIDSortedElemSet& theElems,
626 const TIDSortedElemSet& theNodesNot,
627 const TopoDS_Shape& theShape );
630 * \brief Generated skin mesh (containing 2D cells) from 3D mesh
631 * The created 2D mesh elements based on nodes of free faces of boundary volumes
632 * \return TRUE if operation has been completed successfully, FALSE otherwise
634 bool Make2DMeshFrom3D();
639 * \brief Convert elements contained in a submesh to quadratic
640 * \retval int - nb of checked elements
642 int convertElemToQuadratic(SMESHDS_SubMesh * theSm,
643 SMESH_MesherHelper& theHelper,
644 const bool theForce3d);
647 * \brief Convert quadratic elements to linear ones and remove quadratic nodes
648 * \retval int - nb of checked elements
650 int removeQuadElem( SMESHDS_SubMesh * theSm,
651 SMDS_ElemIteratorPtr theItr,
652 const int theShapeID);
654 * \brief Create groups of elements made during transformation
655 * \param nodeGens - nodes making corresponding myLastCreatedNodes
656 * \param elemGens - elements making corresponding myLastCreatedElems
657 * \param postfix - to append to names of new groups
659 PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
660 const SMESH_SequenceOfElemPtr& elemGens,
661 const std::string& postfix,
662 SMESH_Mesh* targetMesh=0);
665 typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
666 typedef TNodeOfNodeListMap::iterator TNodeOfNodeListMapItr;
667 typedef std::vector<TNodeOfNodeListMapItr> TVecOfNnlmiMap;
668 typedef std::map<const SMDS_MeshElement*, TVecOfNnlmiMap > TElemOfVecOfNnlmiMap;
671 * \brief Create elements by sweeping an element
672 * \param elem - element to sweep
673 * \param newNodesItVec - nodes generated from each node of the element
674 * \param newElems - generated elements
675 * \param nbSteps - number of sweeping steps
676 * \param srcElements - to append elem for each generated element
678 void sweepElement(const SMDS_MeshElement* elem,
679 const std::vector<TNodeOfNodeListMapItr> & newNodesItVec,
680 std::list<const SMDS_MeshElement*>& newElems,
682 SMESH_SequenceOfElemPtr& srcElements);
685 * \brief Create 1D and 2D elements around swept elements
686 * \param mapNewNodes - source nodes and ones generated from them
687 * \param newElemsMap - source elements and ones generated from them
688 * \param elemNewNodesMap - nodes generated from each node of each element
689 * \param elemSet - all swept elements
690 * \param nbSteps - number of sweeping steps
691 * \param srcElements - to append elem for each generated element
693 void makeWalls (TNodeOfNodeListMap & mapNewNodes,
694 TElemOfElemListMap & newElemsMap,
695 TElemOfVecOfNnlmiMap & elemNewNodesMap,
696 TIDSortedElemSet& elemSet,
698 SMESH_SequenceOfElemPtr& srcElements);
700 struct SMESH_MeshEditor_PathPoint
704 double myAngle, myPrm;
706 SMESH_MeshEditor_PathPoint(): myPnt(99., 99., 99.), myTgt(1.,0.,0.), myAngle(0), myPrm(0) {}
707 void SetPnt (const gp_Pnt& aP3D) { myPnt =aP3D; }
708 void SetTangent (const gp_Dir& aTgt) { myTgt =aTgt; }
709 void SetAngle (const double& aBeta) { myAngle=aBeta; }
710 void SetParameter(const double& aPrm) { myPrm =aPrm; }
711 const gp_Pnt& Pnt ()const { return myPnt; }
712 const gp_Dir& Tangent ()const { return myTgt; }
713 double Angle ()const { return myAngle; }
714 double Parameter ()const { return myPrm; }
716 Extrusion_Error MakeEdgePathPoints(std::list<double>& aPrms,
717 const TopoDS_Edge& aTrackEdge,
719 std::list<SMESH_MeshEditor_PathPoint>& aLPP);
720 Extrusion_Error MakeExtrElements(TIDSortedElemSet& theElements,
721 std::list<SMESH_MeshEditor_PathPoint>& theFullList,
722 const bool theHasAngles,
723 std::list<double>& theAngles,
724 const bool theLinearVariation,
725 const bool theHasRefPoint,
726 const gp_Pnt& theRefPoint,
727 const bool theMakeGroups);
728 void LinearAngleVariation(const int NbSteps,
729 list<double>& theAngles);
731 bool doubleNodes( SMESHDS_Mesh* theMeshDS,
732 const TIDSortedElemSet& theElems,
733 const TIDSortedElemSet& theNodesNot,
734 std::map< const SMDS_MeshNode*, const SMDS_MeshNode* >& theNodeNodeMap,
735 const bool theIsDoubleElem );
742 * Sequence for keeping nodes created during last operation
744 SMESH_SequenceOfElemPtr myLastCreatedNodes;
747 * Sequence for keeping elements created during last operation
749 SMESH_SequenceOfElemPtr myLastCreatedElems;