Salome HOME
Temporary rollback ASCII load/save for smesh
[modules/smesh.git] / src / SMESH / SMESH_MeshEditor.hxx
index d09fb2de4b5595fb0ad006c2184b80ba36b4c23f..d7a79328e9fc0b49b2f214bec1a60e9b5bfb86e6 100644 (file)
@@ -17,7 +17,7 @@
 //  License along with this library; if not, write to the Free Software 
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -30,6 +30,8 @@
 #ifndef SMESH_MeshEditor_HeaderFile
 #define SMESH_MeshEditor_HeaderFile
 
+#include "SMESH_SMESH.hxx"
+
 #include "SMESH_Mesh.hxx"
 #include "SMESH_Controls.hxx"
 #include "SMESH_SequenceOfNode.hxx"
 #include "gp_Dir.hxx"
 #include "TColStd_HSequenceOfReal.hxx"
 #include "SMESH_MesherHelper.hxx"
+#include "SMDS_MeshElement.hxx"
 
 #include <list>
 #include <map>
 
 typedef map<const SMDS_MeshElement*,
             list<const SMDS_MeshElement*> > TElemOfElemListMap;
+typedef map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
 
-typedef map<const SMDS_MeshNode*, SMESHDS_SubMesh*> RemoveQuadNodeMap;
+typedef map<const SMDS_MeshNode*, SMESHDS_SubMesh*>           RemoveQuadNodeMap;
 typedef map<const SMDS_MeshNode*, SMESHDS_SubMesh*>::iterator ItRemoveQuadNodeMap;
 
-class SMDS_MeshElement;
 class SMDS_MeshFace;
 class SMDS_MeshNode;
 class gp_Ax1;
 class gp_Vec;
 class gp_Pnt;
 
-class SMESH_MeshEditor {
- public:
+class SMESH_EXPORT SMESH_MeshEditor {
+public:
+
+  // define a set of elements sorted by ID, to be used to assure
+  // predictability of edition
+  struct TIDCompare {
+    bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2)
+    { return e1->GetID() < e2->GetID(); }
+  };
+  typedef set< const SMDS_MeshElement*, TIDCompare > TIDSortedElemSet;
+
+  /*!
+   * \brief Insert element in a map of elements sorted by ID
+    * \param elem - element to insert
+    * \param elemMap - the map to fill in
+   */
+  static void Insert(const SMDS_MeshElement*                 elem,
+                     std::map<int,const SMDS_MeshElement*> & elemMap) {
+    elemMap.insert( make_pair( elem->GetID(), elem ));
+  }
+  
+public:
 
   SMESH_MeshEditor( SMESH_Mesh* theMesh );
 
@@ -272,6 +295,13 @@ class SMESH_MeshEditor {
                                    const SMDS_MeshNode* theNode3 = 0);
   // Return true if the three nodes are on a free border
 
+  static bool FindFreeBorder (const SMDS_MeshNode*                  theFirstNode,
+                              const SMDS_MeshNode*                  theSecondNode,
+                              const SMDS_MeshNode*                  theLastNode,
+                              std::list< const SMDS_MeshNode* > &   theNodes,
+                              std::list< const SMDS_MeshElement* >& theFaces);
+  // Return nodes and faces of a free border if found 
+
   enum Sew_Error {
     SEW_OK,
     // for SewFreeBorder()
@@ -284,7 +314,8 @@ class SMESH_MeshEditor {
     SEW_DIFF_NB_OF_ELEMENTS,
     SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
     SEW_BAD_SIDE1_NODES,
-    SEW_BAD_SIDE2_NODES
+    SEW_BAD_SIDE2_NODES,
+    SEW_INTERNAL_ERROR
     };
     
 
@@ -382,6 +413,25 @@ class SMESH_MeshEditor {
   // - not in avoidSet,
   // - in elemSet provided that !elemSet.empty()
 
+  /*!
+   * \brief Find corresponding nodes in two sets of faces 
+    * \param theSide1 - first face set
+    * \param theSide2 - second first face
+    * \param theFirstNode1 - a boundary node of set 1
+    * \param theFirstNode2 - a node of set 2 corresponding to theFirstNode1
+    * \param theSecondNode1 - a boundary node of set 1 linked with theFirstNode1
+    * \param theSecondNode2 - a node of set 2 corresponding to theSecondNode1
+    * \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,
+                                     const SMDS_MeshNode*          theFirstNode1,
+                                     const SMDS_MeshNode*          theFirstNode2,
+                                     const SMDS_MeshNode*          theSecondNode1,
+                                     const SMDS_MeshNode*          theSecondNode2,
+                                     TNodeNodeMap &                nReplaceMap);
+
   /*!
    * \brief Returns true if given node is medium
     * \param n - node to check