+//================================================================================
+/*!
+ * \brief Finds shapes preferable over _shape due to sub-mesh order
+ */
+//================================================================================
+
+void SMESH_HypoFilter::IsMoreLocalThanPredicate::findPreferable()
+{
+ const int shapeID = _mesh.GetMeshDS()->ShapeToIndex( _shape );
+ const TListOfListOfInt& listOfShapeIDList = _mesh.GetMeshOrder();
+ TListOfListOfInt::const_iterator listsIt = listOfShapeIDList.begin();
+ for ( ; listsIt != listOfShapeIDList.end(); ++listsIt )
+ {
+ const TListOfInt& idList = *listsIt;
+ TListOfInt::const_iterator idIt =
+ std::find( idList.begin(), idList.end(), shapeID );
+ if ( idIt != idList.end() && *idIt != idList.front() )
+ {
+ for ( --idIt; true; --idIt )
+ {
+ const TopoDS_Shape& shape = _mesh.GetMeshDS()->IndexToShape( *idIt );
+ if ( !shape.IsNull())
+ _preferableShapes.Add( shape );
+
+ if ( idIt == idList.begin() )
+ break;
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : IsMoreLocalThanPredicate::IsOk
+//purpose :
+//=======================================================================
+
+bool SMESH_HypoFilter::IsMoreLocalThanPredicate::IsOk(const SMESH_Hypothesis* aHyp,
+ const TopoDS_Shape& aShape) const
+{
+ if ( aShape.IsSame( _mesh.GetShapeToMesh() ) || // aHyp is global
+ aShape.IsSame( _shape ))
+ return false;
+
+ if ( SMESH_MesherHelper::IsSubShape( aShape, /*mainShape=*/_shape ))
+ return true;
+
+ if ( aShape.ShapeType() == TopAbs_COMPOUND &&
+ !SMESH_MesherHelper::IsSubShape( _shape, /*mainShape=*/aShape)) // issue 0020963
+ {
+ for ( int type = TopAbs_SOLID; type < TopAbs_SHAPE; ++type )
+ if ( aHyp->GetDim() == SMESH_Gen::GetShapeDim( TopAbs_ShapeEnum( type )))
+ for ( TopExp_Explorer exp( aShape, TopAbs_ShapeEnum( type )); exp.More(); exp.Next())
+ if ( SMESH_MesherHelper::IsSubShape( exp.Current(), /*mainShape=*/_shape ))
+ return true;
+ }
+
+ if ( _preferableShapes.Contains( aShape ))
+ return true; // issue 21559, Mesh_6
+
+ return false;
+}
+