Move StdMeshers_ProjectionUtils::IsSubShape() to SMESH_MesherHelper

This commit is contained in:
eap 2010-03-23 14:33:16 +00:00
parent 8951a46238
commit c3b2640450
5 changed files with 41 additions and 84 deletions

View File

@ -1283,44 +1283,6 @@ bool StdMeshers_ProjectionUtils::InsertAssociation( const TopoDS_Shape& theShape
return false;
}
//=======================================================================
//function : IsSubShape
//purpose :
//=======================================================================
bool StdMeshers_ProjectionUtils::IsSubShape( const TopoDS_Shape& shape,
SMESH_Mesh* aMesh )
{
if ( shape.IsNull() || !aMesh )
return false;
return
aMesh->GetMeshDS()->ShapeToIndex( shape ) ||
// PAL16202
shape.ShapeType() == TopAbs_COMPOUND && aMesh->GetMeshDS()->IsGroupOfSubShapes( shape );
}
//=======================================================================
//function : IsSubShape
//purpose :
//=======================================================================
bool StdMeshers_ProjectionUtils::IsSubShape( const TopoDS_Shape& shape,
const TopoDS_Shape& mainShape )
{
if ( !shape.IsNull() && !mainShape.IsNull() )
{
for ( TopExp_Explorer exp( mainShape, shape.ShapeType());
exp.More();
exp.Next() )
if ( shape.IsSame( exp.Current() ))
return true;
}
SCRUTE((shape.IsNull()));
SCRUTE((mainShape.IsNull()));
return false;
}
//=======================================================================
/*!
* \brief Finds an edge by its vertices in a main shape of the mesh
@ -1536,7 +1498,7 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1,
if ( !assocMap.IsBound( e2 ))
RETURN_BAD_RESULT("Association not found for edge " << meshDS2->ShapeToIndex( e2 ));
TopoDS_Edge e1 = TopoDS::Edge( assocMap( e2 ));
if ( !IsSubShape( e1, face1 ))
if ( !helper1.IsSubShape( e1, face1 ))
RETURN_BAD_RESULT("Wrong association, edge " << meshDS1->ShapeToIndex( e1 ) <<
" isn't a subshape of face " << meshDS1->ShapeToIndex( face1 ));
// check that there are nodes on edges

View File

@ -111,10 +111,6 @@ class StdMeshers_ProjectionUtils
TShapeShapeMap & theAssociationMap,
const bool theBidirectional=true);
static bool IsSubShape( const TopoDS_Shape& shape, SMESH_Mesh* aMesh );
static bool IsSubShape( const TopoDS_Shape& shape, const TopoDS_Shape& mainShape );
/*!
* \brief Finds an edge by its vertices in a main shape of the mesh
*/

View File

@ -128,25 +128,25 @@ bool StdMeshers_Projection_1D::CheckHypothesis(SMESH_Mesh&
if ( _sourceHypo->HasVertexAssociation() )
{
// source and target vertices
if ( !TAssocTool::IsSubShape( _sourceHypo->GetSourceVertex(), srcMesh ) ||
!TAssocTool::IsSubShape( _sourceHypo->GetTargetVertex(), tgtMesh ) ||
!TAssocTool::IsSubShape( _sourceHypo->GetSourceVertex(),
_sourceHypo->GetSourceEdge() ))
if ( !SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSourceVertex(), srcMesh ) ||
!SMESH_MesherHelper::IsSubShape( _sourceHypo->GetTargetVertex(), tgtMesh ) ||
!SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSourceVertex(),
_sourceHypo->GetSourceEdge() ))
{
aStatus = HYP_BAD_PARAMETER;
SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetSourceVertex(), srcMesh )));
SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetTargetVertex(), tgtMesh )));
SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetSourceVertex(),
_sourceHypo->GetSourceEdge() )));
SCRUTE((SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSourceVertex(), srcMesh )));
SCRUTE((SMESH_MesherHelper::IsSubShape( _sourceHypo->GetTargetVertex(), tgtMesh )));
SCRUTE((SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSourceVertex(),
_sourceHypo->GetSourceEdge() )));
}
// PAL16202
else
else
{
bool isSub = TAssocTool::IsSubShape( _sourceHypo->GetTargetVertex(), aShape );
bool isSub = SMESH_MesherHelper::IsSubShape( _sourceHypo->GetTargetVertex(), aShape );
if ( !_sourceHypo->IsCompoundSource() ) {
if ( !isSub ) {
aStatus = HYP_BAD_PARAMETER;
SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetTargetVertex(), aShape)));
SCRUTE((SMESH_MesherHelper::IsSubShape( _sourceHypo->GetTargetVertex(), aShape)));
}
}
else if ( isSub ) {
@ -159,7 +159,7 @@ bool StdMeshers_Projection_1D::CheckHypothesis(SMESH_Mesh&
{
const TopoDS_Shape& ancestor = ancestIt.Value();
if ( ancestor.ShapeType() == TopAbs_EDGE &&
TAssocTool::IsSubShape( ancestor, _sourceHypo->GetSourceEdge() ))
SMESH_MesherHelper::IsSubShape( ancestor, _sourceHypo->GetSourceEdge() ))
{
if ( sharingEdge.IsNull() || ancestor.IsSame( sharingEdge ))
sharingEdge = ancestor;
@ -175,11 +175,11 @@ bool StdMeshers_Projection_1D::CheckHypothesis(SMESH_Mesh&
}
}
// check source edge
if ( !TAssocTool::IsSubShape( _sourceHypo->GetSourceEdge(), srcMesh ) ||
if ( !SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSourceEdge(), srcMesh ) ||
( srcMesh == tgtMesh && aShape == _sourceHypo->GetSourceEdge() ))
{
aStatus = HYP_BAD_PARAMETER;
SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetSourceEdge(), srcMesh )));
SCRUTE((SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSourceEdge(), srcMesh )));
SCRUTE((srcMesh == tgtMesh));
SCRUTE(( aShape == _sourceHypo->GetSourceEdge() ));
}

View File

@ -130,40 +130,40 @@ bool StdMeshers_Projection_2D::CheckHypothesis(SMESH_Mesh&
TopoDS_Shape edge = TAssocTool::GetEdgeByVertices
( srcMesh, _sourceHypo->GetSourceVertex(1), _sourceHypo->GetSourceVertex(2) );
if ( edge.IsNull() ||
!TAssocTool::IsSubShape( edge, srcMesh ) ||
!TAssocTool::IsSubShape( edge, _sourceHypo->GetSourceFace() ))
!SMESH_MesherHelper::IsSubShape( edge, srcMesh ) ||
!SMESH_MesherHelper::IsSubShape( edge, _sourceHypo->GetSourceFace() ))
{
theStatus = HYP_BAD_PARAMETER;
SCRUTE((edge.IsNull()));
SCRUTE((TAssocTool::IsSubShape( edge, srcMesh )));
SCRUTE((TAssocTool::IsSubShape( edge, _sourceHypo->GetSourceFace() )));
SCRUTE((SMESH_MesherHelper::IsSubShape( edge, srcMesh )));
SCRUTE((SMESH_MesherHelper::IsSubShape( edge, _sourceHypo->GetSourceFace() )));
}
else
{
// target vertices
edge = TAssocTool::GetEdgeByVertices
( tgtMesh, _sourceHypo->GetTargetVertex(1), _sourceHypo->GetTargetVertex(2) );
if ( edge.IsNull() || !TAssocTool::IsSubShape( edge, tgtMesh ))
if ( edge.IsNull() || !SMESH_MesherHelper::IsSubShape( edge, tgtMesh ))
{
theStatus = HYP_BAD_PARAMETER;
SCRUTE((edge.IsNull()));
SCRUTE((TAssocTool::IsSubShape( edge, tgtMesh )));
SCRUTE((SMESH_MesherHelper::IsSubShape( edge, tgtMesh )));
}
// PAL16203
else if ( !_sourceHypo->IsCompoundSource() &&
!TAssocTool::IsSubShape( edge, theShape ))
!SMESH_MesherHelper::IsSubShape( edge, theShape ))
{
theStatus = HYP_BAD_PARAMETER;
SCRUTE((TAssocTool::IsSubShape( edge, theShape )));
SCRUTE((SMESH_MesherHelper::IsSubShape( edge, theShape )));
}
}
}
// check a source face
if ( !TAssocTool::IsSubShape( _sourceHypo->GetSourceFace(), srcMesh ) ||
if ( !SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSourceFace(), srcMesh ) ||
( srcMesh == tgtMesh && theShape == _sourceHypo->GetSourceFace() ))
{
theStatus = HYP_BAD_PARAMETER;
SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetSourceFace(), srcMesh )));
SCRUTE((SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSourceFace(), srcMesh )));
SCRUTE((srcMesh == tgtMesh));
SCRUTE(( theShape == _sourceHypo->GetSourceFace() ));
}
@ -177,12 +177,11 @@ bool StdMeshers_Projection_2D::CheckHypothesis(SMESH_Mesh&
namespace {
//================================================================================
/*!
* \brief define if a node is new or old
* \param node - node to check
* \retval bool - true if the node existed before Compute() is called
* \param node - node to check
* \retval bool - true if the node existed before Compute() is called
*/
//================================================================================
@ -545,9 +544,9 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
RETURN_BAD_RESULT("Not associated vertices, srcV1 " << srcV1.TShape().operator->() );
TopoDS_Vertex tgtV1 = TopoDS::Vertex( shape2ShapeMap( srcV1 ));
if ( !TAssocTool::IsSubShape( srcV1, srcFace ))
if ( !SMESH_MesherHelper::IsSubShape( srcV1, srcFace ))
RETURN_BAD_RESULT("Wrong srcV1 " << srcV1.TShape().operator->());
if ( !TAssocTool::IsSubShape( tgtV1, tgtFace ))
if ( !SMESH_MesherHelper::IsSubShape( tgtV1, tgtFace ))
RETURN_BAD_RESULT("Wrong tgtV1 " << tgtV1.TShape().operator->());
// try to find out orientation by order of edges

View File

@ -141,12 +141,12 @@ bool StdMeshers_Projection_3D::CheckHypothesis(SMESH_Mesh&
TopoDS_Shape edge = TAssocTool::GetEdgeByVertices
( srcMesh, _sourceHypo->GetSourceVertex(1), _sourceHypo->GetSourceVertex(2) );
if ( edge.IsNull() ||
!TAssocTool::IsSubShape( edge, srcMesh ) ||
!TAssocTool::IsSubShape( edge, _sourceHypo->GetSource3DShape() ))
!SMESH_MesherHelper::IsSubShape( edge, srcMesh ) ||
!SMESH_MesherHelper::IsSubShape( edge, _sourceHypo->GetSource3DShape() ))
{
SCRUTE((edge.IsNull()));
SCRUTE((TAssocTool::IsSubShape( edge, srcMesh )));
SCRUTE((TAssocTool::IsSubShape( edge, _sourceHypo->GetSource3DShape() )));
SCRUTE((SMESH_MesherHelper::IsSubShape( edge, srcMesh )));
SCRUTE((SMESH_MesherHelper::IsSubShape( edge, _sourceHypo->GetSource3DShape() )));
aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
}
else
@ -155,21 +155,21 @@ bool StdMeshers_Projection_3D::CheckHypothesis(SMESH_Mesh&
edge = TAssocTool::GetEdgeByVertices
( tgtMesh, _sourceHypo->GetTargetVertex(1), _sourceHypo->GetTargetVertex(2) );
if ( edge.IsNull() ||
!TAssocTool::IsSubShape( edge, tgtMesh ) ||
!TAssocTool::IsSubShape( edge, aShape ))
!SMESH_MesherHelper::IsSubShape( edge, tgtMesh ) ||
!SMESH_MesherHelper::IsSubShape( edge, aShape ))
{
SCRUTE((edge.IsNull()));
SCRUTE((TAssocTool::IsSubShape( edge, tgtMesh )));
SCRUTE((TAssocTool::IsSubShape( edge, aShape )));
SCRUTE((SMESH_MesherHelper::IsSubShape( edge, tgtMesh )));
SCRUTE((SMESH_MesherHelper::IsSubShape( edge, aShape )));
aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
}
}
}
// check a source shape
if ( !TAssocTool::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh ) ||
if ( !SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh ) ||
( srcMesh == tgtMesh && aShape == _sourceHypo->GetSource3DShape()))
{
SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh)));
SCRUTE((SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh)));
SCRUTE((srcMesh == tgtMesh));
SCRUTE((aShape == _sourceHypo->GetSource3DShape()));
aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
@ -266,8 +266,8 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS
return error("Association of subshapes failed" );
srcV000 = TopoDS::Vertex( shape2ShapeMap( tgtV000 ));
srcV100 = TopoDS::Vertex( shape2ShapeMap( tgtV100 ));
if ( !TAssocTool::IsSubShape( srcV000, srcShell ) ||
!TAssocTool::IsSubShape( srcV100, srcShell ))
if ( !SMESH_MesherHelper::IsSubShape( srcV000, srcShell ) ||
!SMESH_MesherHelper::IsSubShape( srcV100, srcShell ))
return error("Incorrect association of subshapes" );
}