Salome HOME
Imp 19925 - Mesh preview
[modules/smesh.git] / src / SMESH / SMESH_MeshEditor.hxx
index 9b56a1f6c3de6f2c31d83e0dab22ab7a58b533d5..cb3ec69481d9c6fa34b2cbf27c2c6687306c81cc 100644 (file)
@@ -49,6 +49,24 @@ typedef std::map<const SMDS_MeshElement*,
                  std::list<const SMDS_MeshElement*> >        TElemOfElemListMap;
 typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
 
+
+typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* > NLink;
+
+//=======================================================================
+/*!
+ * \brief A sorted pair of nodes
+ */
+//=======================================================================
+
+struct SMESH_TLink: public NLink
+{
+  SMESH_TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
+  { if ( n1->GetID() < n2->GetID() ) std::swap( first, second ); }
+  SMESH_TLink(const NLink& link ):NLink( link )
+  { if ( first->GetID() < second->GetID() ) std::swap( first, second ); }
+};
+
+
 class SMDS_MeshFace;
 class SMDS_MeshNode;
 class gp_Ax1;
@@ -190,13 +208,15 @@ public:
   // If the2D, smoothing is performed using UV parameters of nodes
   // on geometrical faces
 
+  typedef std::auto_ptr< std::list<int> > PGroupIDs;
 
-  void RotationSweep (TIDSortedElemSet & theElements,
-                      const gp_Ax1&      theAxis,
-                      const double       theAngle,
-                      const int          theNbSteps,
-                      const double       theToler,
-                      const bool         theMakeWalls=true);
+  PGroupIDs RotationSweep (TIDSortedElemSet & theElements,
+                           const gp_Ax1&      theAxis,
+                           const double       theAngle,
+                           const int          theNbSteps,
+                           const double       theToler,
+                           const bool         theMakeGroups,
+                           const bool         theMakeWalls=true);
   // Generate new elements by rotation of theElements around theAxis
   // by theAngle by theNbSteps
 
@@ -241,13 +261,13 @@ public:
    * param theTolerance - uses for comparing locations of nodes if flag
    *   EXTRUSION_FLAG_SEW is set
    */
-  void ExtrusionSweep
-           (TIDSortedElemSet &  theElems,
-            const gp_Vec&       theStep,
-            const int           theNbSteps,
-            TElemOfElemListMap& newElemsMap,
-            const int           theFlags = EXTRUSION_FLAG_BOUNDARY,
-            const double        theTolerance = 1.e-6);
+  PGroupIDs ExtrusionSweep (TIDSortedElemSet &  theElems,
+                            const gp_Vec&       theStep,
+                            const int           theNbSteps,
+                            TElemOfElemListMap& newElemsMap,
+                            const bool          theMakeGroups,
+                            const int           theFlags = EXTRUSION_FLAG_BOUNDARY,
+                            const double        theTolerance = 1.e-6);
   
   /*!
    * Generate new elements by extrusion of theElements
@@ -259,11 +279,12 @@ public:
    *   EXTRUSION_FLAG_SEW is set
    * param theParams - special structure for manage of extrusion
    */
-  void ExtrusionSweep (TIDSortedElemSet &  theElems,
-                       ExtrusParam&        theParams,
-                       TElemOfElemListMap& newElemsMap,
-                       const int           theFlags,
-                       const double        theTolerance);
+  PGroupIDs ExtrusionSweep (TIDSortedElemSet &  theElems,
+                            ExtrusParam&        theParams,
+                            TElemOfElemListMap& newElemsMap,
+                            const bool          theMakeGroups,
+                            const int           theFlags,
+                            const double        theTolerance);
 
 
   // Generate new elements by extrusion of theElements 
@@ -285,13 +306,16 @@ public:
                                        const bool           theHasAngles,
                                        std::list<double>&   theAngles,
                                        const bool           theHasRefPoint,
-                                       const gp_Pnt&        theRefPoint);
+                                       const gp_Pnt&        theRefPoint,
+                                       const bool           theMakeGroups);
   // Generate new elements by extrusion of theElements along path given by theTrackPattern,
   // theHasAngles are the rotation angles, base point can be given by theRefPoint
 
-  void Transform (TIDSortedElemSet & theElements,
-                  const gp_Trsf&     theTrsf,
-                  const bool         theCopy);
+  PGroupIDs Transform (TIDSortedElemSet & theElements,
+                       const gp_Trsf&     theTrsf,
+                       const bool         theCopy,
+                       const bool         theMakeGroups,
+                       SMESH_Mesh*        theTargetMesh=0);
   // Move or copy theElements applying theTrsf to their nodes
 
   typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
@@ -307,9 +331,9 @@ public:
    */
   SMESH_NodeSearcher* GetNodeSearcher();
 
-  int SimplifyFace (const vector<const SMDS_MeshNode *> faceNodes,
-                    vector<const SMDS_MeshNode *>&      poly_nodes,
-                    vector<int>&                        quantities) const;
+  int SimplifyFace (const std::vector<const SMDS_MeshNode *> faceNodes,
+                    std::vector<const SMDS_MeshNode *>&      poly_nodes,
+                    std::vector<int>&                        quantities) const;
   // Split face, defined by <faceNodes>, into several faces by repeating nodes.
   // Is used by MergeNodes()
 
@@ -472,8 +496,8 @@ public:
     * \param nReplaceMap - output map of corresponding nodes
     * \retval Sew_Error  - is a success or not
    */
-  static Sew_Error FindMatchingNodes(set<const SMDS_MeshElement*>& theSide1,
-                                     set<const SMDS_MeshElement*>& theSide2,
+  static Sew_Error FindMatchingNodes(std::set<const SMDS_MeshElement*>& theSide1,
+                                     std::set<const SMDS_MeshElement*>& theSide2,
                                      const SMDS_MeshNode*          theFirstNode1,
                                      const SMDS_MeshNode*          theFirstNode2,
                                      const SMDS_MeshNode*          theSecondNode1,
@@ -500,6 +524,9 @@ public:
   const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
 
   const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
+  
+  bool DoubleNodes( const std::list< int >& theListOfNodes, 
+                    const std::list< int >& theListOfModifiedElems );
 
 private:
 
@@ -507,7 +534,7 @@ private:
    * \brief Convert elements contained in a submesh to quadratic
     * \retval int - nb of checked elements
    */
-  int ConvertElemToQuadratic(SMESHDS_SubMesh *   theSm,
+  int convertElemToQuadratic(SMESHDS_SubMesh *   theSm,
                              SMESH_MesherHelper& theHelper,
                              const bool          theForce3d);
 
@@ -515,11 +542,55 @@ private:
    * \brief Convert quadratic elements to linear ones and remove quadratic nodes
     * \retval int - nb of checked elements
    */
-  int RemoveQuadElem( SMESHDS_SubMesh *    theSm,
+  int removeQuadElem( SMESHDS_SubMesh *    theSm,
                       SMDS_ElemIteratorPtr theItr,
                       const int            theShapeID);
-  //Auxiliary function for "ConvertFromQuadratic" is intended to 
+  /*!
+   * \brief Create groups of elements made during transformation
+   * \param nodeGens - nodes making corresponding myLastCreatedNodes
+   * \param elemGens - elements making corresponding myLastCreatedElems
+   * \param postfix - to append to names of new groups
+   */
+  PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
+                           const SMESH_SequenceOfElemPtr& elemGens,
+                           const std::string&             postfix,
+                           SMESH_Mesh*                    targetMesh=0);
+
 
+  typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
+  typedef TNodeOfNodeListMap::iterator                                     TNodeOfNodeListMapItr;
+  typedef std::vector<TNodeOfNodeListMapItr>                               TVecOfNnlmiMap;
+  typedef std::map<const SMDS_MeshElement*, TVecOfNnlmiMap >               TElemOfVecOfNnlmiMap;
+
+  /*!
+   * \brief Create elements by sweeping an element
+    * \param elem - element to sweep
+    * \param newNodesItVec - nodes generated from each node of the element
+    * \param newElems - generated elements
+    * \param nbSteps - number of sweeping steps
+    * \param srcElements - to append elem for each generated element
+   */
+  void sweepElement(const SMDS_MeshElement*                    elem,
+                    const std::vector<TNodeOfNodeListMapItr> & newNodesItVec,
+                    std::list<const SMDS_MeshElement*>&        newElems,
+                    const int                                  nbSteps,
+                    SMESH_SequenceOfElemPtr&                   srcElements);
+
+  /*!
+   * \brief Create 1D and 2D elements around swept elements
+    * \param mapNewNodes - source nodes and ones generated from them
+    * \param newElemsMap - source elements and ones generated from them
+    * \param elemNewNodesMap - nodes generated from each node of each element
+    * \param elemSet - all swept elements
+    * \param nbSteps - number of sweeping steps
+    * \param srcElements - to append elem for each generated element
+   */
+  void makeWalls (TNodeOfNodeListMap &     mapNewNodes,
+                  TElemOfElemListMap &     newElemsMap,
+                  TElemOfVecOfNnlmiMap &   elemNewNodesMap,
+                  TIDSortedElemSet&        elemSet,
+                  const int                nbSteps,
+                  SMESH_SequenceOfElemPtr& srcElements);
 private:
 
   SMESH_Mesh * myMesh;