From: eap Date: Wed, 18 Mar 2020 16:02:52 +0000 (+0300) Subject: small optimization X-Git-Tag: V9_5_0a2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=896ab9bad6fa746d7b1e9d7c8bca7f1719ce67de small optimization --- diff --git a/src/SMDS/SMDS_MeshCell.cxx b/src/SMDS/SMDS_MeshCell.cxx index 3628aafe3..36c3d800a 100644 --- a/src/SMDS/SMDS_MeshCell.cxx +++ b/src/SMDS/SMDS_MeshCell.cxx @@ -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; } diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 732ed654d..abd2e90ea 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -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; diff --git a/src/SMESHUtils/SMESH_MeshAlgos.cxx b/src/SMESHUtils/SMESH_MeshAlgos.cxx index 1af84d598..b7593a8b6 100644 --- a/src/SMESHUtils/SMESH_MeshAlgos.cxx +++ b/src/SMESHUtils/SMESH_MeshAlgos.cxx @@ -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 diff --git a/src/SMESHUtils/SMESH_MeshAlgos.hxx b/src/SMESHUtils/SMESH_MeshAlgos.hxx index 830dffebb..3633d50c6 100644 --- a/src/SMESHUtils/SMESH_MeshAlgos.hxx +++ b/src/SMESHUtils/SMESH_MeshAlgos.hxx @@ -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 */ diff --git a/src/SMESHUtils/SMESH_Offset.cxx b/src/SMESHUtils/SMESH_Offset.cxx index 9ad02dd2b..4b4924b9a 100644 --- a/src/SMESHUtils/SMESH_Offset.cxx +++ b/src/SMESHUtils/SMESH_Offset.cxx @@ -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 ) diff --git a/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx b/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx index f0d50dc0f..38e75aad4 100644 --- a/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx +++ b/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx @@ -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 ); } }