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