{
list< TopoDS_Edge >::iterator eIt2 = ++edges2.begin(); // 2nd edge of the 2nd face
TopoDS_Edge edge2 =
- StdMeshers_ProjectionUtils::GetPropagationEdge( theMesh1, *eIt2, edges1.front() );
+ StdMeshers_ProjectionUtils::GetPropagationEdge( theMesh1, *eIt2, edges1.front() ).second;
if ( !edge2.IsNull() ) { // propagation found for the second edge
Reverse( edges2, nbEdges );
return true;
TopoDS_Edge edge2 = TopoDS::Edge( theShape2 );
if ( IsPropagationPossible( theMesh1, theMesh2 ))
{
- TopoDS_Edge prpEdge = GetPropagationEdge( theMesh1, edge2, edge1 );
+ TopoDS_Edge prpEdge = GetPropagationEdge( theMesh1, edge2, edge1 ).second;
if ( !prpEdge.IsNull() )
{
TopoDS_Vertex VV1[2], VV2[2];
{
TopoDS_Face face1 = TopoDS::Face(theShape1);
TopoDS_Face face2 = TopoDS::Face(theShape2);
+ TopoDS_Edge edge1, edge2;
// get outer edge of theShape1
- TopoDS_Edge edge1 = TopoDS::Edge( OuterShape( face1, TopAbs_EDGE ));
+ edge1 = TopoDS::Edge( OuterShape( face1, TopAbs_EDGE ));
// find out if any edge of face2 is a propagation edge of outer edge1
+ map<int,TopoDS_Edge> propag_edges; // use map to find the closest propagation edge
for ( TopExp_Explorer exp( face2, TopAbs_EDGE ); exp.More(); exp.Next() ) {
- TopoDS_Edge edge2 = TopoDS::Edge( exp.Current() );
- edge2 = GetPropagationEdge( theMesh1, edge2, edge1 );
- if ( !edge2.IsNull() ) // propagation found
+ edge2 = TopoDS::Edge( exp.Current() );
+ pair<int,TopoDS_Edge> step_edge = GetPropagationEdge( theMesh1, edge2, edge1 );
+ if ( !step_edge.second.IsNull() ) { // propagation found
+ propag_edges.insert( step_edge );
+ }
+ }
+ if ( !propag_edges.empty() ) // propagation found
+ {
+ edge2 = propag_edges.begin()->second;
+ TopoDS_Vertex VV1[2], VV2[2];
+ TopExp::Vertices( edge1, VV1[0], VV1[1], true );
+ TopExp::Vertices( edge2, VV2[0], VV2[1], true );
+ list< TopoDS_Edge > edges1, edges2;
+ int nbE = FindFaceAssociation( face1, VV1, face2, VV2, edges1, edges2 );
+ if ( !nbE ) RETURN_BAD_RESULT("FindFaceAssociation() failed");
+ if ( nbE == 2 ) // only 2 edges
{
- TopoDS_Vertex VV1[2], VV2[2];
- TopExp::Vertices( edge1, VV1[0], VV1[1], true );
- TopExp::Vertices( edge2, VV2[0], VV2[1], true );
- list< TopoDS_Edge > edges1, edges2;
- int nbE = FindFaceAssociation( face1, VV1, face2, VV2, edges1, edges2 );
- if ( !nbE ) RETURN_BAD_RESULT("FindFaceAssociation() failed");
- if ( nbE == 2 ) // only 2 edges
- {
- // take care of proper association of propagated edges
- bool same1 = edge1.IsSame( edges1.front() );
- bool same2 = edge2.IsSame( edges2.front() );
- if ( same1 != same2 )
- Reverse(edges2, nbE);
- }
- // store association
- list< TopoDS_Edge >::iterator eIt1 = edges1.begin();
- list< TopoDS_Edge >::iterator eIt2 = edges2.begin();
- for ( ; eIt1 != edges1.end(); ++eIt1, ++eIt2 )
- {
- InsertAssociation( *eIt1, *eIt2, theMap, bidirect);
- VV1[0] = TopExp::FirstVertex( *eIt1, true );
- VV2[0] = TopExp::FirstVertex( *eIt2, true );
- InsertAssociation( VV1[0], VV2[0], theMap, bidirect);
- }
- return true;
+ // take care of proper association of propagated edges
+ bool same1 = edge1.IsSame( edges1.front() );
+ bool same2 = edge2.IsSame( edges2.front() );
+ if ( same1 != same2 )
+ Reverse(edges2, nbE);
}
+ // store association
+ list< TopoDS_Edge >::iterator eIt1 = edges1.begin();
+ list< TopoDS_Edge >::iterator eIt2 = edges2.begin();
+ for ( ; eIt1 != edges1.end(); ++eIt1, ++eIt2 )
+ {
+ InsertAssociation( *eIt1, *eIt2, theMap, bidirect);
+ VV1[0] = TopExp::FirstVertex( *eIt1, true );
+ VV2[0] = TopExp::FirstVertex( *eIt2, true );
+ InsertAssociation( VV1[0], VV2[0], theMap, bidirect);
+ }
+ return true;
}
}
break; // try by vertex closeness
* \param aMesh - mesh
* \param theEdge - edge to find by propagation
* \param fromEdge - start edge for propagation
- * \retval TopoDS_Edge - found edge
+ * \retval pair<int,TopoDS_Edge> - propagation step and found edge
*/
//================================================================================
-TopoDS_Edge StdMeshers_ProjectionUtils::GetPropagationEdge( SMESH_Mesh* aMesh,
- const TopoDS_Edge& theEdge,
- const TopoDS_Edge& fromEdge)
+pair<int,TopoDS_Edge>
+StdMeshers_ProjectionUtils::GetPropagationEdge( SMESH_Mesh* aMesh,
+ const TopoDS_Edge& theEdge,
+ const TopoDS_Edge& fromEdge)
{
SMESH_IndexedMapOfShape aChain;
- //aChain.Add(fromEdge);
+ int step = 0;
// List of edges, added to chain on the previous cycle pass
TopTools_ListOfShape listPrevEdges;
- listPrevEdges.Append(fromEdge/*.Oriented( TopAbs_FORWARD )*/);
+ listPrevEdges.Append(fromEdge);
// Collect all edges pass by pass
while (listPrevEdges.Extent() > 0) {
+ step++;
// List of edges, added to chain on this cycle pass
TopTools_ListOfShape listCurEdges;
ori = TopAbs::Reverse( ori );
anOppE.Orientation( ori );
if ( anOppE.IsSame( theEdge ))
- return TopoDS::Edge( anOppE );
+ return make_pair( step, TopoDS::Edge( anOppE ));
aChain.Add(anOppE);
listCurEdges.Append(anOppE);
}
listPrevEdges = listCurEdges;
} // while (listPrevEdges.Extent() > 0)
- return TopoDS_Edge();
+ return make_pair( INT_MAX, TopoDS_Edge());
}
//================================================================================