From 2c8f4c513e0fed76a7f0331542e520e315740aa4 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 10 Oct 2012 10:48:10 +0000 Subject: [PATCH] Try to use length of edges for association in case of a 2-edges wire --- src/StdMeshers/StdMeshers_ProjectionUtils.cxx | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx index d0f29a54b..8d198fe69 100644 --- a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx @@ -1237,6 +1237,7 @@ int StdMeshers_ProjectionUtils::FindFaceAssociation(const TopoDS_Face& face1, { bool OK = false; list< int > nbEInW1, nbEInW2; + list< TopoDS_Edge >::iterator edgeIt; int i_ok_wire_algo = -1; for ( int outer_wire_algo = 0; outer_wire_algo < 2 && !OK; ++outer_wire_algo ) { @@ -1257,7 +1258,6 @@ int StdMeshers_ProjectionUtils::FindFaceAssociation(const TopoDS_Face& face1, bool reverse = false; - list< TopoDS_Edge >::iterator edgeIt; if ( !VV1[1].IsSame( TopExp::LastVertex( edges1.front(), true ))) { reverse = true; edgeIt = --edges1.end(); @@ -1367,6 +1367,27 @@ int StdMeshers_ProjectionUtils::FindFaceAssociation(const TopoDS_Face& face1, } } + const int nbEdges = nbEInW1.front(); + if ( OK && nbEdges == 2 ) + { + // if a wire includes 2 edges, it's impossible to associate them using + // topological information only. Try to use length of edges for association. + double l1[2], l2[2]; + edgeIt = edges1.begin(); + l1[0] = SMESH_Algo::EdgeLength( *edgeIt++ ); + l1[1] = SMESH_Algo::EdgeLength( *edgeIt++ ); + if ( Abs( l1[0] - l1[1] ) > 0.1 * Max( l1[0], l1[1] ) ) + { + edgeIt = edges2.begin(); + l2[0] = SMESH_Algo::EdgeLength( *edgeIt++ ); + l2[1] = SMESH_Algo::EdgeLength( *edgeIt++ ); + if (( l1[0] < l1[1] ) != ( l2[0] < l2[1] )) + { + Reverse( edges2, nbEdges ); + } + } + } + return OK ? nbEInW1.front() : 0; }