From: eap Date: Mon, 18 Jun 2007 13:44:24 +0000 (+0000) Subject: PAL16217 (3D Extrusion produces degenerated hexahedrons) X-Git-Tag: V3_2_7~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=92f303e8d0ccb645dd38b9dba53721da782cdbab;p=modules%2Fsmesh.git PAL16217 (3D Extrusion produces degenerated hexahedrons) fix face association in a block (avoid taking far propagation edge) --- diff --git a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx index 25f2399cd..1452599ed 100644 --- a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx @@ -160,7 +160,7 @@ namespace { { 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; @@ -382,7 +382,7 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the 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]; @@ -415,40 +415,46 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the { 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 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 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 @@ -772,23 +778,25 @@ TopoDS_Face StdMeshers_ProjectionUtils::GetNextFace( SMESH_Mesh* mesh, * \param aMesh - mesh * \param theEdge - edge to find by propagation * \param fromEdge - start edge for propagation - * \retval TopoDS_Edge - found edge + * \retval pair - propagation step and found edge */ //================================================================================ -TopoDS_Edge StdMeshers_ProjectionUtils::GetPropagationEdge( SMESH_Mesh* aMesh, - const TopoDS_Edge& theEdge, - const TopoDS_Edge& fromEdge) +pair +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; @@ -833,7 +841,7 @@ TopoDS_Edge StdMeshers_ProjectionUtils::GetPropagationEdge( SMESH_Mesh* a 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); } @@ -845,7 +853,7 @@ TopoDS_Edge StdMeshers_ProjectionUtils::GetPropagationEdge( SMESH_Mesh* a listPrevEdges = listCurEdges; } // while (listPrevEdges.Extent() > 0) - return TopoDS_Edge(); + return make_pair( INT_MAX, TopoDS_Edge()); } //================================================================================ diff --git a/src/StdMeshers/StdMeshers_ProjectionUtils.hxx b/src/StdMeshers/StdMeshers_ProjectionUtils.hxx index 5071209cd..2990e533f 100644 --- a/src/StdMeshers/StdMeshers_ProjectionUtils.hxx +++ b/src/StdMeshers/StdMeshers_ProjectionUtils.hxx @@ -137,11 +137,11 @@ class StdMeshers_ProjectionUtils * \brief Return an oriented propagation edge * \param aMesh - mesh * \param fromEdge - start edge for propagation - * \retval TopoDS_Edge - found edge + * \retval pair - propagation step and found edge */ - static TopoDS_Edge GetPropagationEdge( SMESH_Mesh* aMesh, - const TopoDS_Edge& anEdge, - const TopoDS_Edge& fromEdge); + static std::pair GetPropagationEdge( SMESH_Mesh* aMesh, + const TopoDS_Edge& anEdge, + const TopoDS_Edge& fromEdge); /*! * \brief Find corresponding nodes on two faces