Salome HOME
small optimization
authoreap <eap@opencascade.com>
Wed, 18 Mar 2020 16:02:52 +0000 (19:02 +0300)
committereap <eap@opencascade.com>
Wed, 18 Mar 2020 16:02:52 +0000 (19:02 +0300)
src/SMDS/SMDS_MeshCell.cxx
src/SMESH/SMESH_MeshEditor.cxx
src/SMESHUtils/SMESH_MeshAlgos.cxx
src/SMESHUtils/SMESH_MeshAlgos.hxx
src/SMESHUtils/SMESH_Offset.cxx
src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx

index 3628aafe31ec31303989b396e010b60793db9668..36c3d800a2b8a194ddd307f6c99bc2fc22e5a969 100644 (file)
@@ -521,9 +521,7 @@ int SMDS_MeshCell::NbNodes() const
 {
   if ( GetVtkType() == VTK_POLYHEDRON )
     return static_cast< const SMDS_MeshVolume* >( this )->SMDS_MeshVolume::NbNodes();
-  vtkIdType npts;
-  vtkIdType const *pts;
-  getGrid()->GetCellPoints( GetVtkID(), npts, pts );
+  vtkIdType npts = getGrid()->GetCells()->GetCellSize( GetVtkID() );
   return npts;
 }
 
index 732ed654d89654f56bba279dab14cb5400ba33c9..abd2e90ea7d3abb324cb6d4c40ebeeb798f46e80 100644 (file)
@@ -9349,7 +9349,7 @@ void SMESH_MeshEditor::ConvertFromQuadratic(TIDSortedElemSet& theElements)
             const SMDS_MeshElement* eComplex = invIt2->next();
             if ( eComplex->IsQuadratic() && !allMediumNodesIn( eComplex, mediumNodes))
             {
-              int nbCommonNodes = SMESH_MeshAlgos::GetCommonNodes( e, eComplex ).size();
+              int nbCommonNodes = SMESH_MeshAlgos::NbCommonNodes( e, eComplex );
               if ( nbCommonNodes == e->NbNodes())
               {
                 complexFound = true;
index 1af84d5984e8ffff5b36c4c2a25deb6222cf024d..b7593a8b6a62b76baed6f964db39e90ae3337507 100644 (file)
@@ -1098,7 +1098,7 @@ TopAbs_State SMESH_ElementSearcherImpl::GetPointState(const gp_Pnt& point)
             const SMDS_MeshElement* prevFace = u_int1->second._face;
             while ( ok && u_int2->second._coincides )
             {
-              if ( SMESH_MeshAlgos::GetCommonNodes(prevFace , u_int2->second._face).empty() )
+              if ( SMESH_MeshAlgos::NbCommonNodes(prevFace , u_int2->second._face) == 0 )
                 ok = false;
               else
               {
@@ -2210,10 +2210,26 @@ bool SMESH_MeshAlgos::FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool
   return ok;
 }
 
-//=======================================================================
-//function : GetCommonNodes
-//purpose  : Return nodes common to two elements
-//=======================================================================
+//================================================================================
+/*!
+ * \brief Return nodes common to two elements
+ */
+//================================================================================
+
+int SMESH_MeshAlgos::NbCommonNodes(const SMDS_MeshElement* e1,
+                                   const SMDS_MeshElement* e2)
+{
+  int nb = 0;
+  for ( int i = 0 ; i < e1->NbNodes(); ++i )
+    nb += ( e2->GetNodeIndex( e1->GetNode( i )) >= 0 );
+  return nb;
+}
+
+//================================================================================
+/*!
+ * \brief Return nodes common to two elements
+ */
+//================================================================================
 
 std::vector< const SMDS_MeshNode*> SMESH_MeshAlgos::GetCommonNodes(const SMDS_MeshElement* e1,
                                                                    const SMDS_MeshElement* e2)
@@ -2224,6 +2240,7 @@ std::vector< const SMDS_MeshNode*> SMESH_MeshAlgos::GetCommonNodes(const SMDS_Me
       common.push_back( e1->GetNode( i ));
   return common;
 }
+
 //================================================================================
 /*!
  * \brief Return true if node1 encounters first in the face and node2, after
index 830dffebbb4eb242073a3cf76309c55e183e6345..3633d50c6fe60b892a3a4050a72bbbdc46420157 100644 (file)
@@ -187,6 +187,12 @@ namespace SMESH_MeshAlgos
   SMESHUtils_EXPORT
   bool FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool normalized=true);
 
+  /*!
+   * \brief Return number of nodes common to two elements
+   */
+  SMESHUtils_EXPORT
+  int NbCommonNodes(const SMDS_MeshElement* e1,
+                    const SMDS_MeshElement* e2);
   /*!
    * \brief Return nodes common to two elements
    */
index 9ad02dd2b3f34c9b5ed0b209b7dbd69d59499e23..4b4924b9a405e2d27287719608f0fe66b4e2fc77 100644 (file)
@@ -2981,8 +2981,8 @@ namespace
             bool isAdded = checkedCoplanar.insert( myLinks[iE].myFace ).second;
             if ( !isAdded )
               continue;
-            toErase = SMESH_MeshAlgos::GetCommonNodes( myLinks[i ].myFace,
-                                                       myLinks[iE].myFace ).size() < 1;
+            toErase = ( SMESH_MeshAlgos::NbCommonNodes( myLinks[i ].myFace,
+                                                        myLinks[iE].myFace ) < 1 );
           }
         }
       }
@@ -3075,7 +3075,7 @@ namespace
       //check if the faces are connected
       int nbCommonNodes = 0;
       if ( e.myFace && myFace )
-        nbCommonNodes = SMESH_MeshAlgos::GetCommonNodes( e.myFace, myFace ).size();
+        nbCommonNodes = SMESH_MeshAlgos::NbCommonNodes( e.myFace, myFace );
       bool toReplace = (( myIndex == _INTERNAL && nbCommonNodes > 1 ) ||
                         ( myIndex == _COPLANAR && nbCommonNodes < 2 ));
       if ( toReplace )
index f0d50dc0f321a45ae71992d52cff279c1dcab037..38e75aad4adbace669431126a0612b485fd3f69d 100644 (file)
@@ -1369,7 +1369,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh&
       while ( vIt->more() )
       {
         const SMDS_MeshElement* PrmJ = vIt->next();
-        if ( SMESH_MeshAlgos::GetCommonNodes( PrmI, PrmJ ).size() > 1 )
+        if ( SMESH_MeshAlgos::NbCommonNodes( PrmI, PrmJ ) > 1 )
           checkedPyrams.insert( PrmJ );
       }
     }