Salome HOME
0021543: EDF 1978 SMESH: Viscous layer for 2D meshes
authoreap <eap@opencascade.com>
Mon, 15 Oct 2012 13:01:00 +0000 (13:01 +0000)
committereap <eap@opencascade.com>
Mon, 15 Oct 2012 13:01:00 +0000 (13:01 +0000)
-void FindEqualElements(set<const SMDS_MeshElement*> & theElements,
+void FindEqualElements(TIDSortedElemSet &        theElements,
                        TListOfListOfElementsID & theGroupsOfElementsID)

src/SMESH/SMESH_MeshEditor.cxx
src/SMESH/SMESH_MeshEditor.hxx

index 8cff3be1a85e8aa2b25b011abdd9f8c4fb92c9ac..9c75f7975c357adaf2e4e243428ef8a53add488b 100644 (file)
@@ -6103,7 +6103,7 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher
         }
         else if ( tree->NbNodes() ) // put a tree to the treeMap
         {
-          const Bnd_B3d& box = tree->getBox();
+          const Bnd_B3d& box = *tree->getBox();
           double sqDist = thePnt.SquareDistance( 0.5 * ( box.CornerMin() + box.CornerMax() ));
           pair<TDistTreeMap::iterator,bool> it_in = treeMap.insert( make_pair( sqDist, tree ));
           if ( !it_in.second ) // not unique distance to box center
@@ -6115,7 +6115,7 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher
       TDistTreeMap::iterator sqDist_tree = treeMap.begin();
       if ( treeMap.size() > 5 ) {
         SMESH_OctreeNode* closestTree = sqDist_tree->second;
-        const Bnd_B3d& box = closestTree->getBox();
+        const Bnd_B3d& box = *closestTree->getBox();
         double limit = sqrt( sqDist_tree->first ) + sqrt ( box.SquareExtent() );
         sqLimit = limit * limit;
       }
@@ -6200,7 +6200,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
 
   protected:
     ElementBndBoxTree():_size(0) {}
-    SMESH_Octree* allocateOctreeChild() const { return new ElementBndBoxTree; }
+    SMESH_Octree* newChild() const { return new ElementBndBoxTree; }
     void          buildChildrenData();
     Bnd_B3d*      buildRootBox();
   private:
@@ -6222,7 +6222,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
   //================================================================================
 
   ElementBndBoxTree::ElementBndBoxTree(const SMDS_Mesh& mesh, SMDSAbs_ElementType elemType, SMDS_ElemIteratorPtr theElemIt, double tolerance)
-    :SMESH_Octree( new SMESH_Octree::Limit( MaxLevel, /*minSize=*/0. ))
+    :SMESH_Octree( new SMESH_TreeLimit( MaxLevel, /*minSize=*/0. ))
   {
     int nbElems = mesh.GetMeshInfo().NbElements( elemType );
     _elements.reserve( nbElems );
@@ -6273,7 +6273,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
     {
       for (int j = 0; j < 8; j++)
       {
-        if ( !_elements[i]->IsOut( myChildren[j]->getBox() ))
+        if ( !_elements[i]->IsOut( *myChildren[j]->getBox() ))
         {
           _elements[i]->_refCount++;
           ((ElementBndBoxTree*)myChildren[j])->_elements.push_back( _elements[i]);
@@ -6304,7 +6304,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
   void ElementBndBoxTree::getElementsNearPoint( const gp_Pnt&     point,
                                                 TIDSortedElemSet& foundElems)
   {
-    if ( getBox().IsOut( point.XYZ() ))
+    if ( getBox()->IsOut( point.XYZ() ))
       return;
 
     if ( isLeaf() )
@@ -6329,7 +6329,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
   void ElementBndBoxTree::getElementsNearLine( const gp_Ax1&     line,
                                                TIDSortedElemSet& foundElems)
   {
-    if ( getBox().IsOut( line ))
+    if ( getBox()->IsOut( line ))
       return;
 
     if ( isLeaf() )
@@ -6355,7 +6355,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint()
                                                 const double      radius,
                                                 TIDSortedElemSet& foundElems)
   {
-    if ( getBox().IsOut( center, radius ))
+    if ( getBox()->IsOut( center, radius ))
       return;
 
     if ( isLeaf() )
@@ -6737,10 +6737,10 @@ SMESH_ElementSearcherImpl::FindClosestTo( const gp_Pnt&       point,
 
     if ( suspectElems.empty() && _ebbTree->maxSize() > 0 )
     {
-      gp_Pnt boxCenter = 0.5 * ( _ebbTree->getBox().CornerMin() +
-                                 _ebbTree->getBox().CornerMax() );
+      gp_Pnt boxCenter = 0.5 * ( _ebbTree->getBox()->CornerMin() +
+                                 _ebbTree->getBox()->CornerMax() );
       double radius;
-      if ( _ebbTree->getBox().IsOut( point.XYZ() ))
+      if ( _ebbTree->getBox()->IsOut( point.XYZ() ))
         radius = point.Distance( boxCenter ) - 0.5 * _ebbTree->maxSize();
       else
         radius = _ebbTree->maxSize() / pow( 2., _ebbTree->getHeight()) / 2;
@@ -8156,32 +8156,28 @@ private:
 //purpose  : Return list of group of elements built on the same nodes.
 //           Search among theElements or in the whole mesh if theElements is empty
 //=======================================================================
-void SMESH_MeshEditor::FindEqualElements(set<const SMDS_MeshElement*> & theElements,
-                                         TListOfListOfElementsID &      theGroupsOfElementsID)
+void SMESH_MeshEditor::FindEqualElements(TIDSortedElemSet &        theElements,
+                                         TListOfListOfElementsID & theGroupsOfElementsID)
 {
   myLastCreatedElems.Clear();
   myLastCreatedNodes.Clear();
 
-  typedef set<const SMDS_MeshElement*> TElemsSet;
   typedef map< SortableElement, int > TMapOfNodeSet;
   typedef list<int> TGroupOfElems;
 
-  TElemsSet elems;
   if ( theElements.empty() )
   { // get all elements in the mesh
     SMDS_ElemIteratorPtr eIt = GetMeshDS()->elementsIterator();
     while ( eIt->more() )
-      elems.insert( elems.end(), eIt->next());
+      theElements.insert( theElements.end(), eIt->next());
   }
-  else
-    elems = theElements;
 
   vector< TGroupOfElems > arrayOfGroups;
   TGroupOfElems groupOfElems;
   TMapOfNodeSet mapOfNodeSet;
 
-  TElemsSet::iterator elemIt = elems.begin();
-  for ( int i = 0, j=0; elemIt != elems.end(); ++elemIt, ++j ) {
+  TIDSortedElemSet::iterator elemIt = theElements.begin();
+  for ( int i = 0, j=0; elemIt != theElements.end(); ++elemIt, ++j ) {
     const SMDS_MeshElement* curElem = *elemIt;
     SortableElement SE(curElem);
     int ind = -1;
@@ -8254,8 +8250,8 @@ void SMESH_MeshEditor::MergeElements(TListOfListOfElementsID & theGroupsOfElemen
 
 void SMESH_MeshEditor::MergeEqualElements()
 {
-  set<const SMDS_MeshElement*> aMeshElements; /* empty input -
-                                                 to merge equal elements in the whole mesh */
+  TIDSortedElemSet aMeshElements; /* empty input ==
+                                     to merge equal elements in the whole mesh */
   TListOfListOfElementsID aGroupsOfElementsID;
   FindEqualElements(aMeshElements, aGroupsOfElementsID);
   MergeElements(aGroupsOfElementsID);
index 1874360a79fdda983309e0359d18dea871d32e7e..26240938810e8f3e2e19c5d483ce0a252365569e 100644 (file)
@@ -350,15 +350,6 @@ public:
                        SMESH_Mesh*        theTargetMesh=0);
   // Move or copy theElements applying theTrsf to their nodes
 
-
-  typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
-
-  void FindCoincidentNodes (TIDSortedNodeSet &   theNodes,
-                            const double         theTolerance,
-                            TListOfListOfNodes & theGroupsOfNodes);
-  // Return list of group of nodes close to each other within theTolerance.
-  // Search among theNodes or in the whole mesh if theNodes is empty.
-
   /*!
    * \brief Return SMESH_NodeSearcher. The caller is responsible for deleteing it
    */
@@ -369,18 +360,14 @@ public:
    */
   SMESH_ElementSearcher* GetElementSearcher();
   SMESH_ElementSearcher* GetElementSearcher( SMDS_ElemIteratorPtr elemIt );
-  /*!
-   * \brief Return true if the point is IN or ON of the element
-   */
-  static bool IsOut( const SMDS_MeshElement* element, const gp_Pnt& point, double tol );
 
-  static double GetDistance( const SMDS_MeshFace* face, const gp_Pnt& point );
+  typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
 
-  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()
+  void FindCoincidentNodes (TIDSortedNodeSet &   theNodes,
+                            const double         theTolerance,
+                            TListOfListOfNodes & theGroupsOfNodes);
+  // Return list of group of nodes close to each other within theTolerance.
+  // Search among theNodes or in the whole mesh if theNodes is empty.
 
   void MergeNodes (TListOfListOfNodes & theNodeGroups);
   // In each group, the cdr of nodes are substituted by the first one
@@ -388,8 +375,8 @@ public:
 
   typedef std::list< std::list< int > > TListOfListOfElementsID;
 
-  void FindEqualElements(std::set<const SMDS_MeshElement*> & theElements,
-                         TListOfListOfElementsID &           theGroupsOfElementsID);
+  void FindEqualElements(TIDSortedElemSet &        theElements,
+                         TListOfListOfElementsID & theGroupsOfElementsID);
   // Return list of group of elements build on the same nodes.
   // Search among theElements or in the whole mesh if theElements is empty.
 
@@ -400,6 +387,19 @@ public:
   // Remove all but one of elements built on the same nodes.
   // Return nb of successfully merged groups.
 
+  /*!
+   * \brief Return true if the point is IN or ON of the element
+   */
+  static bool IsOut( const SMDS_MeshElement* element, const gp_Pnt& point, double tol );
+
+  static double GetDistance( const SMDS_MeshFace* face, const gp_Pnt& point );
+
+  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()
+
   static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1,
                                    const SMDS_MeshNode* theNode2,
                                    const SMDS_MeshNode* theNode3 = 0);