Salome HOME
Implememtation of evaluation for improvement 0019296.
[modules/smesh.git] / src / SMESH / SMESH_MeshEditor.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, 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.
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 //  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)
26 // Module    : SMESH
27 //
28 #ifndef SMESH_MeshEditor_HeaderFile
29 #define SMESH_MeshEditor_HeaderFile
30
31 #include "SMESH_SMESH.hxx"
32
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"
38
39 #include <TColStd_HSequenceOfReal.hxx>
40 #include <gp_Dir.hxx>
41
42 #include <list>
43 #include <map>
44
45 class SMDS_MeshFace;
46 class SMDS_MeshNode;
47 class gp_Ax1;
48 class gp_Vec;
49 class gp_Pnt;
50 class SMESH_MesherHelper;
51
52
53 typedef std::map<const SMDS_MeshElement*,
54                  std::list<const SMDS_MeshElement*> >        TElemOfElemListMap;
55 typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
56
57  //!< Set of elements sorted by ID, to be used to assure predictability of edition
58 typedef std::set< const SMDS_MeshElement*, TIDCompare >      TIDSortedElemSet;
59
60 typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* >   NLink;
61
62
63 //=======================================================================
64 /*!
65  * \brief A sorted pair of nodes
66  */
67 //=======================================================================
68
69 struct SMESH_TLink: public NLink
70 {
71   SMESH_TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
72   { if ( n1->GetID() < n2->GetID() ) std::swap( first, second ); }
73   SMESH_TLink(const NLink& link ):NLink( link )
74   { if ( first->GetID() < second->GetID() ) std::swap( first, second ); }
75   const SMDS_MeshNode* node1() const { return first; }
76   const SMDS_MeshNode* node2() const { return second; }
77 };
78
79 // ============================================================
80 /*!
81  * \brief Searcher for the node closest to point
82  */
83 // ============================================================
84
85 struct SMESH_NodeSearcher
86 {
87   virtual const SMDS_MeshNode* FindClosestTo( const gp_Pnt& pnt ) = 0;
88 };
89
90
91 //=======================================================================
92 /*!
93  * auxiliary class
94  */
95 //=======================================================================
96 class SMESH_MeshEditor_PathPoint {
97 public:
98   SMESH_MeshEditor_PathPoint() {
99     myPnt.SetCoord(99., 99., 99.);
100     myTgt.SetCoord(1.,0.,0.);
101     myAngle=0.;
102     myPrm=0.;
103   }
104   void SetPnt(const gp_Pnt& aP3D){
105     myPnt=aP3D;
106   }
107   void SetTangent(const gp_Dir& aTgt){
108     myTgt=aTgt;
109   }
110   void SetAngle(const double& aBeta){
111     myAngle=aBeta;
112   }
113   void SetParameter(const double& aPrm){
114     myPrm=aPrm;
115   }
116   const gp_Pnt& Pnt()const{
117     return myPnt;
118   }
119   const gp_Dir& Tangent()const{
120     return myTgt;
121   }
122   double Angle()const{
123     return myAngle;
124   }
125   double Parameter()const{
126     return myPrm;
127   }
128
129 protected:
130   gp_Pnt myPnt;
131   gp_Dir myTgt;
132   double myAngle;
133   double myPrm;
134 };
135
136
137 // ============================================================
138 /*!
139  * \brief Editor of a mesh
140  */
141 // ============================================================
142
143 class SMESH_EXPORT SMESH_MeshEditor {
144
145 public:
146
147   SMESH_MeshEditor( SMESH_Mesh* theMesh );
148
149   /*!
150    * \brief Add element
151    */
152   SMDS_MeshElement* AddElement(const std::vector<const SMDS_MeshNode*> & nodes,
153                                const SMDSAbs_ElementType                 type,
154                                const bool                                isPoly,
155                                const int                                 ID = 0);
156   /*!
157    * \brief Add element
158    */
159   SMDS_MeshElement* AddElement(const std::vector<int>  & nodeIDs,
160                                const SMDSAbs_ElementType type,
161                                const bool                isPoly,
162                                const int                 ID = 0);
163
164   bool Remove (const std::list< int >& theElemIDs, const bool isNodes);
165   // Remove a node or an element.
166   // Modify a compute state of sub-meshes which become empty
167
168   bool InverseDiag (const SMDS_MeshElement * theTria1,
169                     const SMDS_MeshElement * theTria2 );
170   // Replace two neighbour triangles with ones built on the same 4 nodes
171   // but having other common link.
172   // Return False if args are improper
173
174   bool InverseDiag (const SMDS_MeshNode * theNode1,
175                     const SMDS_MeshNode * theNode2 );
176   // Replace two neighbour triangles sharing theNode1-theNode2 link
177   // with ones built on the same 4 nodes but having other common link.
178   // Return false if proper faces not found
179
180   bool DeleteDiag (const SMDS_MeshNode * theNode1,
181                    const SMDS_MeshNode * theNode2 );
182   // Replace two neighbour triangles sharing theNode1-theNode2 link
183   // with a quadrangle built on the same 4 nodes.
184   // Return false if proper faces not found
185
186   bool Reorient (const SMDS_MeshElement * theElement);
187   // Reverse theElement orientation
188
189
190   /*!
191    * \brief Fuse neighbour triangles into quadrangles.
192    * \param theElems     - The triangles to be fused.
193    * \param theCriterion - Is used to choose a neighbour to fuse with.
194    * \param theMaxAngle  - Is a max angle between element normals at which fusion
195    *                       is still performed; theMaxAngle is mesured in radians.
196    * \retval bool - Success or not.
197    */
198   bool TriToQuad (TIDSortedElemSet &                   theElems,
199                   SMESH::Controls::NumericalFunctorPtr theCriterion,
200                   const double                         theMaxAngle);
201
202   /*!
203    * \brief Split quadrangles into triangles.
204    * \param theElems     - The faces to be splitted.
205    * \param theCriterion - Is used to choose a diagonal for splitting.
206    * \retval bool - Success or not.
207    */
208   bool QuadToTri (TIDSortedElemSet &                   theElems,
209                   SMESH::Controls::NumericalFunctorPtr theCriterion);
210
211   /*!
212    * \brief Split quadrangles into triangles.
213    * \param theElems  - The faces to be splitted.
214    * \param the13Diag - Is used to choose a diagonal for splitting.
215    * \retval bool - Success or not.
216    */
217   bool QuadToTri (TIDSortedElemSet & theElems,
218                   const bool         the13Diag);
219
220   /*!
221    * \brief Find better diagonal for splitting.
222    * \param theQuad      - The face to find better splitting of.
223    * \param theCriterion - Is used to choose a diagonal for splitting.
224    * \retval int - 1 for 1-3 diagonal, 2 for 2-4, -1 - for errors.
225    */
226   int BestSplit (const SMDS_MeshElement*              theQuad,
227                  SMESH::Controls::NumericalFunctorPtr theCriterion);
228
229
230   enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL };
231
232   void Smooth (TIDSortedElemSet &               theElements,
233                std::set<const SMDS_MeshNode*> & theFixedNodes,
234                const SmoothMethod               theSmoothMethod,
235                const int                        theNbIterations,
236                double                           theTgtAspectRatio = 1.0,
237                const bool                       the2D = true);
238   // Smooth theElements using theSmoothMethod during theNbIterations
239   // or until a worst element has aspect ratio <= theTgtAspectRatio.
240   // Aspect Ratio varies in range [1.0, inf].
241   // If theElements is empty, the whole mesh is smoothed.
242   // theFixedNodes contains additionally fixed nodes. Nodes built
243   // on edges and boundary nodes are always fixed.
244   // If the2D, smoothing is performed using UV parameters of nodes
245   // on geometrical faces
246
247   typedef std::auto_ptr< std::list<int> > PGroupIDs;
248
249   PGroupIDs RotationSweep (TIDSortedElemSet & theElements,
250                            const gp_Ax1&      theAxis,
251                            const double       theAngle,
252                            const int          theNbSteps,
253                            const double       theToler,
254                            const bool         theMakeGroups,
255                            const bool         theMakeWalls=true);
256   // Generate new elements by rotation of theElements around theAxis
257   // by theAngle by theNbSteps
258
259   /*!
260    * Auxilary flag for advanced extrusion.
261    * BOUNDARY: create or not boundary for result of extrusion
262    * SEW:      try to use existing nodes or create new nodes in any case
263    */
264   enum ExtrusionFlags {
265     EXTRUSION_FLAG_BOUNDARY = 0x01,
266     EXTRUSION_FLAG_SEW = 0x02
267   };
268   
269   /*!
270    * special structire for control of extrusion functionality
271    */
272   struct ExtrusParam {
273     gp_Dir myDir; // direction of extrusion
274     Handle(TColStd_HSequenceOfReal) mySteps; // magnitudes for each step
275     SMESH_SequenceOfNode myNodes; // nodes for using in sewing
276   };
277
278   /*!
279    * Create new node in the mesh with given coordinates
280    * (auxilary for advanced extrusion)
281    */
282   const SMDS_MeshNode* CreateNode(const double x,
283                                   const double y,
284                                   const double z,
285                                   const double tolnode,
286                                   SMESH_SequenceOfNode& aNodes);
287
288   /*!
289    * Generate new elements by extrusion of theElements
290    * It is a method used in .idl file. All functionality
291    * is implemented in the next method (see below) which
292    * is used in the cuurent method.
293    * param theElems - list of elements for extrusion
294    * param newElemsMap returns history of extrusion
295    * param theFlags set flags for performing extrusion (see description
296    *   of enum ExtrusionFlags for additional information)
297    * param theTolerance - uses for comparing locations of nodes if flag
298    *   EXTRUSION_FLAG_SEW is set
299    */
300   PGroupIDs ExtrusionSweep (TIDSortedElemSet &  theElems,
301                             const gp_Vec&       theStep,
302                             const int           theNbSteps,
303                             TElemOfElemListMap& newElemsMap,
304                             const bool          theMakeGroups,
305                             const int           theFlags = EXTRUSION_FLAG_BOUNDARY,
306                             const double        theTolerance = 1.e-6);
307   
308   /*!
309    * Generate new elements by extrusion of theElements
310    * param theElems - list of elements for extrusion
311    * param newElemsMap returns history of extrusion
312    * param theFlags set flags for performing extrusion (see description
313    *   of enum ExtrusionFlags for additional information)
314    * param theTolerance - uses for comparing locations of nodes if flag
315    *   EXTRUSION_FLAG_SEW is set
316    * param theParams - special structure for manage of extrusion
317    */
318   PGroupIDs ExtrusionSweep (TIDSortedElemSet &  theElems,
319                             ExtrusParam&        theParams,
320                             TElemOfElemListMap& newElemsMap,
321                             const bool          theMakeGroups,
322                             const int           theFlags,
323                             const double        theTolerance);
324
325
326   // Generate new elements by extrusion of theElements 
327   // by theStep by theNbSteps
328
329   enum Extrusion_Error {
330     EXTR_OK,
331     EXTR_NO_ELEMENTS, 
332     EXTR_PATH_NOT_EDGE,
333     EXTR_BAD_PATH_SHAPE,
334     EXTR_BAD_STARTING_NODE,
335     EXTR_BAD_ANGLES_NUMBER,
336     EXTR_CANT_GET_TANGENT
337     };
338   
339   Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet &   theElements,
340                                        SMESH_subMesh*       theTrackPattern,
341                                        const SMDS_MeshNode* theNodeStart,
342                                        const bool           theHasAngles,
343                                        std::list<double>&   theAngles,
344                                        const bool           theLinearVariation,
345                                        const bool           theHasRefPoint,
346                                        const gp_Pnt&        theRefPoint,
347                                        const bool           theMakeGroups);
348   Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet &   theElements,
349                                        SMESH_Mesh*          theTrackPattern,
350                                        const SMDS_MeshNode* theNodeStart,
351                                        const bool           theHasAngles,
352                                        std::list<double>&   theAngles,
353                                        const bool           theLinearVariation,
354                                        const bool           theHasRefPoint,
355                                        const gp_Pnt&        theRefPoint,
356                                        const bool           theMakeGroups);
357   // Generate new elements by extrusion of theElements along path given by theTrackPattern,
358   // theHasAngles are the rotation angles, base point can be given by theRefPoint
359
360   PGroupIDs Transform (TIDSortedElemSet & theElements,
361                        const gp_Trsf&     theTrsf,
362                        const bool         theCopy,
363                        const bool         theMakeGroups,
364                        SMESH_Mesh*        theTargetMesh=0);
365   // Move or copy theElements applying theTrsf to their nodes
366
367   typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
368
369   void FindCoincidentNodes (std::set<const SMDS_MeshNode*> & theNodes,
370                             const double                     theTolerance,
371                             TListOfListOfNodes &             theGroupsOfNodes);
372   // Return list of group of nodes close to each other within theTolerance.
373   // Search among theNodes or in the whole mesh if theNodes is empty.
374
375   /*!
376    * \brief Return SMESH_NodeSearcher
377    */
378   SMESH_NodeSearcher* GetNodeSearcher();
379
380   int SimplifyFace (const std::vector<const SMDS_MeshNode *> faceNodes,
381                     std::vector<const SMDS_MeshNode *>&      poly_nodes,
382                     std::vector<int>&                        quantities) const;
383   // Split face, defined by <faceNodes>, into several faces by repeating nodes.
384   // Is used by MergeNodes()
385
386   void MergeNodes (TListOfListOfNodes & theNodeGroups);
387   // In each group, the cdr of nodes are substituted by the first one
388   // in all elements.
389
390   typedef std::list< std::list< int > > TListOfListOfElementsID;
391
392   void FindEqualElements(std::set<const SMDS_MeshElement*> & theElements,
393                          TListOfListOfElementsID &           theGroupsOfElementsID);
394   // Return list of group of elements build on the same nodes.
395   // Search among theElements or in the whole mesh if theElements is empty.
396
397   void MergeElements(TListOfListOfElementsID & theGroupsOfElementsID);
398   // In each group remove all but first of elements.
399
400   void MergeEqualElements();
401   // Remove all but one of elements built on the same nodes.
402   // Return nb of successfully merged groups.
403
404   static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1,
405                                    const SMDS_MeshNode* theNode2,
406                                    const SMDS_MeshNode* theNode3 = 0);
407   // Return true if the three nodes are on a free border
408
409   static bool FindFreeBorder (const SMDS_MeshNode*                  theFirstNode,
410                               const SMDS_MeshNode*                  theSecondNode,
411                               const SMDS_MeshNode*                  theLastNode,
412                               std::list< const SMDS_MeshNode* > &   theNodes,
413                               std::list< const SMDS_MeshElement* >& theFaces);
414   // Return nodes and faces of a free border if found 
415
416   enum Sew_Error {
417     SEW_OK,
418     // for SewFreeBorder()
419     SEW_BORDER1_NOT_FOUND,
420     SEW_BORDER2_NOT_FOUND,
421     SEW_BOTH_BORDERS_NOT_FOUND,
422     SEW_BAD_SIDE_NODES,
423     SEW_VOLUMES_TO_SPLIT,
424     // for SewSideElements()
425     SEW_DIFF_NB_OF_ELEMENTS,
426     SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
427     SEW_BAD_SIDE1_NODES,
428     SEW_BAD_SIDE2_NODES,
429     SEW_INTERNAL_ERROR
430     };
431     
432
433   Sew_Error SewFreeBorder (const SMDS_MeshNode* theBorderFirstNode,
434                            const SMDS_MeshNode* theBorderSecondNode,
435                            const SMDS_MeshNode* theBorderLastNode,
436                            const SMDS_MeshNode* theSide2FirstNode,
437                            const SMDS_MeshNode* theSide2SecondNode,
438                            const SMDS_MeshNode* theSide2ThirdNode = 0,
439                            const bool           theSide2IsFreeBorder = true,
440                            const bool           toCreatePolygons = false,
441                            const bool           toCreatePolyedrs = false);
442   // Sew the free border to the side2 by replacing nodes in
443   // elements on the free border with nodes of the elements
444   // of the side 2. If nb of links in the free border and
445   // between theSide2FirstNode and theSide2LastNode are different,
446   // additional nodes are inserted on a link provided that no
447   // volume elements share the splitted link.
448   // The side 2 is a free border if theSide2IsFreeBorder == true.
449   // Sewing is peformed between the given first, second and last
450   // nodes on the sides.
451   // theBorderFirstNode is merged with theSide2FirstNode.
452   // if (!theSide2IsFreeBorder) then theSide2SecondNode gives
453   // the last node on the side 2, which will be merged with
454   // theBorderLastNode.
455   // if (theSide2IsFreeBorder) then theSide2SecondNode will
456   // be merged with theBorderSecondNode.
457   // if (theSide2IsFreeBorder && theSide2ThirdNode == 0) then
458   // the 2 free borders are sewn link by link and no additional
459   // nodes are inserted.
460   // Return false, if sewing failed.
461
462   Sew_Error SewSideElements (TIDSortedElemSet&    theSide1,
463                              TIDSortedElemSet&    theSide2,
464                              const SMDS_MeshNode* theFirstNode1ToMerge,
465                              const SMDS_MeshNode* theFirstNode2ToMerge,
466                              const SMDS_MeshNode* theSecondNode1ToMerge,
467                              const SMDS_MeshNode* theSecondNode2ToMerge);
468   // Sew two sides of a mesh. Nodes belonging to theSide1 are
469   // merged with nodes of elements of theSide2.
470   // Number of elements in theSide1 and in theSide2 must be
471   // equal and they should have similar node connectivity.
472   // The nodes to merge should belong to side s borders and
473   // the first node should be linked to the second.
474
475   void InsertNodesIntoLink(const SMDS_MeshElement*          theFace,
476                            const SMDS_MeshNode*             theBetweenNode1,
477                            const SMDS_MeshNode*             theBetweenNode2,
478                            std::list<const SMDS_MeshNode*>& theNodesToInsert,
479                            const bool                       toCreatePoly = false);
480   // insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2.
481   // If toCreatePoly is true, replace theFace by polygon, else split theFace.
482
483   void UpdateVolumes (const SMDS_MeshNode*             theBetweenNode1,
484                       const SMDS_MeshNode*             theBetweenNode2,
485                       std::list<const SMDS_MeshNode*>& theNodesToInsert);
486   // insert theNodesToInsert into all volumes, containing link
487   // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
488
489   void ConvertToQuadratic(const bool theForce3d);
490   //converts all mesh to quadratic one, deletes old elements, replacing 
491   //them with quadratic ones with the same id.
492
493   bool ConvertFromQuadratic();
494   //converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing 
495   //them with ordinary mesh elements with the same id.
496
497
498 //  static int SortQuadNodes (const SMDS_Mesh * theMesh,
499 //                            int               theNodeIds[] );
500 //  // Set 4 nodes of a quadrangle face in a good order.
501 //  // Swap 1<->2 or 2<->3 nodes and correspondingly return
502 //  // 1 or 2 else 0.
503 //
504 //  static bool SortHexaNodes (const SMDS_Mesh * theMesh,
505 //                             int               theNodeIds[] );
506 //  // Set 8 nodes of a hexahedron in a good order.
507 //  // Return success status
508
509   static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
510                                const SMDS_MeshElement* elemInGroups,
511                                SMESHDS_Mesh *          aMesh);
512   // Add elemToAdd to the all groups the elemInGroups belongs to
513
514   static void RemoveElemFromGroups (const SMDS_MeshElement* element,
515                                     SMESHDS_Mesh *          aMesh);
516   // remove element from the all groups
517
518   static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
519                                    const SMDS_MeshElement* elemToAdd,
520                                    SMESHDS_Mesh *          aMesh);
521   // replace elemToRm by elemToAdd in the all groups
522
523   /*!
524    * \brief Return nodes linked to the given one in elements of the type
525    */
526   static void GetLinkedNodes( const SMDS_MeshNode* node,
527                               TIDSortedElemSet &   linkedNodes,
528                               SMDSAbs_ElementType  type = SMDSAbs_All );
529
530   static const SMDS_MeshElement*
531     FindFaceInSet(const SMDS_MeshNode*    n1,
532                   const SMDS_MeshNode*    n2,
533                   const TIDSortedElemSet& elemSet,
534                   const TIDSortedElemSet& avoidSet);
535   // Return a face having linked nodes n1 and n2 and which is
536   // - not in avoidSet,
537   // - in elemSet provided that !elemSet.empty()
538
539   /*!
540    * \brief Find corresponding nodes in two sets of faces 
541     * \param theSide1 - first face set
542     * \param theSide2 - second first face
543     * \param theFirstNode1 - a boundary node of set 1
544     * \param theFirstNode2 - a node of set 2 corresponding to theFirstNode1
545     * \param theSecondNode1 - a boundary node of set 1 linked with theFirstNode1
546     * \param theSecondNode2 - a node of set 2 corresponding to theSecondNode1
547     * \param nReplaceMap - output map of corresponding nodes
548     * \retval Sew_Error  - is a success or not
549    */
550   static Sew_Error FindMatchingNodes(std::set<const SMDS_MeshElement*>& theSide1,
551                                      std::set<const SMDS_MeshElement*>& theSide2,
552                                      const SMDS_MeshNode*          theFirstNode1,
553                                      const SMDS_MeshNode*          theFirstNode2,
554                                      const SMDS_MeshNode*          theSecondNode1,
555                                      const SMDS_MeshNode*          theSecondNode2,
556                                      TNodeNodeMap &                nReplaceMap);
557
558   /*!
559    * \brief Returns true if given node is medium
560     * \param n - node to check
561     * \param typeToCheck - type of elements containing the node to ask about node status
562     * \retval bool - check result
563    */
564   static bool IsMedium(const SMDS_MeshNode*      node,
565                        const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
566
567   int FindShape (const SMDS_MeshElement * theElem);
568   // Return an index of the shape theElem is on
569   // or zero if a shape not found
570
571   SMESH_Mesh * GetMesh() { return myMesh; }
572
573   SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
574
575   const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
576
577   const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
578   
579   bool DoubleNodes( const std::list< int >& theListOfNodes, 
580                     const std::list< int >& theListOfModifiedElems );
581
582 private:
583
584   /*!
585    * \brief Convert elements contained in a submesh to quadratic
586     * \retval int - nb of checked elements
587    */
588   int convertElemToQuadratic(SMESHDS_SubMesh *   theSm,
589                              SMESH_MesherHelper& theHelper,
590                              const bool          theForce3d);
591
592   /*!
593    * \brief Convert quadratic elements to linear ones and remove quadratic nodes
594     * \retval int - nb of checked elements
595    */
596   int removeQuadElem( SMESHDS_SubMesh *    theSm,
597                       SMDS_ElemIteratorPtr theItr,
598                       const int            theShapeID);
599   /*!
600    * \brief Create groups of elements made during transformation
601    * \param nodeGens - nodes making corresponding myLastCreatedNodes
602    * \param elemGens - elements making corresponding myLastCreatedElems
603    * \param postfix - to append to names of new groups
604    */
605   PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
606                            const SMESH_SequenceOfElemPtr& elemGens,
607                            const std::string&             postfix,
608                            SMESH_Mesh*                    targetMesh=0);
609
610
611   typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
612   typedef TNodeOfNodeListMap::iterator                                     TNodeOfNodeListMapItr;
613   typedef std::vector<TNodeOfNodeListMapItr>                               TVecOfNnlmiMap;
614   typedef std::map<const SMDS_MeshElement*, TVecOfNnlmiMap >               TElemOfVecOfNnlmiMap;
615
616   /*!
617    * \brief Create elements by sweeping an element
618     * \param elem - element to sweep
619     * \param newNodesItVec - nodes generated from each node of the element
620     * \param newElems - generated elements
621     * \param nbSteps - number of sweeping steps
622     * \param srcElements - to append elem for each generated element
623    */
624   void sweepElement(const SMDS_MeshElement*                    elem,
625                     const std::vector<TNodeOfNodeListMapItr> & newNodesItVec,
626                     std::list<const SMDS_MeshElement*>&        newElems,
627                     const int                                  nbSteps,
628                     SMESH_SequenceOfElemPtr&                   srcElements);
629
630   /*!
631    * \brief Create 1D and 2D elements around swept elements
632     * \param mapNewNodes - source nodes and ones generated from them
633     * \param newElemsMap - source elements and ones generated from them
634     * \param elemNewNodesMap - nodes generated from each node of each element
635     * \param elemSet - all swept elements
636     * \param nbSteps - number of sweeping steps
637     * \param srcElements - to append elem for each generated element
638    */
639   void makeWalls (TNodeOfNodeListMap &     mapNewNodes,
640                   TElemOfElemListMap &     newElemsMap,
641                   TElemOfVecOfNnlmiMap &   elemNewNodesMap,
642                   TIDSortedElemSet&        elemSet,
643                   const int                nbSteps,
644                   SMESH_SequenceOfElemPtr& srcElements);
645
646   /*!
647    * auxilary for ExtrusionAlongTrack
648    */
649   Extrusion_Error MakeEdgePathPoints(std::list<double>& aPrms,
650                                      const TopoDS_Edge& aTrackEdge,
651                                      bool FirstIsStart,
652                                      list<SMESH_MeshEditor_PathPoint>& LPP);
653   Extrusion_Error MakeExtrElements(TIDSortedElemSet& theElements,
654                                    list<SMESH_MeshEditor_PathPoint>& fullList,
655                                    const bool theHasAngles,
656                                    list<double>& theAngles,
657                                    const bool theLinearVariation,
658                                    const bool theHasRefPoint,
659                                    const gp_Pnt& theRefPoint,
660                                    const bool theMakeGroups);
661   void LinearAngleVariation(const int NbSteps,
662                             list<double>& theAngles);
663
664 private:
665
666   SMESH_Mesh * myMesh;
667
668   /*!
669    * Sequence for keeping nodes created during last operation
670    */
671   SMESH_SequenceOfElemPtr myLastCreatedNodes;
672
673   /*!
674    * Sequence for keeping elements created during last operation
675    */
676   SMESH_SequenceOfElemPtr myLastCreatedElems;
677
678 };
679
680 #endif