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