+//=======================================================================
+//function : GetHypothesis
+//purpose :
+//=======================================================================
+
+const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubShape,
+ const SMESH_HypoFilter& aFilter,
+ const bool andAncestors) const
+{
+ {
+ const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
+ list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
+ for ( ; hyp != hypList.end(); hyp++ ) {
+ const SMESH_Hypothesis * h = static_cast<const SMESH_Hypothesis*>( *hyp );
+ if ( aFilter.IsOk( h, aSubShape))
+ return h;
+ }
+ }
+ if ( andAncestors )
+ {
+ TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
+ for (; it.More(); it.Next() )
+ {
+ const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
+ list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
+ for ( ; hyp != hypList.end(); hyp++ ) {
+ const SMESH_Hypothesis * h = static_cast<const SMESH_Hypothesis*>( *hyp );
+ if (aFilter.IsOk( h, it.Value() ))
+ return h;
+ }
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : GetHypotheses
+//purpose :
+//=======================================================================
+
+bool SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
+ const SMESH_HypoFilter& aFilter,
+ list <const SMESHDS_Hypothesis * >& aHypList,
+ const bool andAncestors) const
+{
+ int nbHyp = 0;
+ {
+ const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
+ list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
+ for ( ; hyp != hypList.end(); hyp++ )
+ if ( aFilter.IsOk (static_cast<const SMESH_Hypothesis*>( *hyp ), aSubShape)) {
+ aHypList.push_back( *hyp );
+ nbHyp++;
+ }
+ }
+ // get hypos from shape of one type only: if any hypo is found on edge, do
+ // not look up on faces
+ if ( !nbHyp && andAncestors )
+ {
+ TopTools_MapOfShape map;
+ TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
+ int shapeType = it.More() ? it.Value().ShapeType() : TopAbs_SHAPE;
+ for (; it.More(); it.Next() )
+ {
+ if ( nbHyp && shapeType != it.Value().ShapeType() )
+ break;
+ shapeType = it.Value().ShapeType();
+ if ( !map.Add( it.Value() ))
+ continue;
+ const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
+ list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
+ for ( ; hyp != hypList.end(); hyp++ )
+ if (aFilter.IsOk( static_cast<const SMESH_Hypothesis*>( *hyp ), it.Value() )) {
+ aHypList.push_back( *hyp );
+ nbHyp++;
+ }
+ }
+ }
+ return nbHyp;
+}
+