From 53b3b75be62cefa5c23a1adda94eda2668597d50 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 28 Jan 2013 08:31:47 +0000 Subject: [PATCH] 0021893: EDF 2133 SMESH : Improvement of 3D extrusion algorithm arg theFirstVertex of SMESH_Block::GetOrderedEdges() became optional StdMeshers_ProjectionUtils::Count() moved to SMESH_MesherHelper::Count() --- src/StdMeshers/StdMeshers_ProjectionUtils.cxx | 78 +++++++------------ src/StdMeshers/StdMeshers_ProjectionUtils.hxx | 13 +--- src/StdMeshers/StdMeshers_Projection_2D.cxx | 36 ++++----- 3 files changed, 45 insertions(+), 82 deletions(-) diff --git a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx index 13e2962da..805915b56 100644 --- a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx @@ -215,13 +215,12 @@ namespace { list subMeshes = tgtMesh1->GetGroupSubMeshesContaining(tgtShape); list::iterator sm = subMeshes.begin(); int type, last = TopAbs_SHAPE; - StdMeshers_ProjectionUtils util; for ( ; sm != subMeshes.end(); ++sm ) { const TopoDS_Shape & group = (*sm)->GetSubShape(); // check if group is similar to srcGroup for ( type = srcGroup.ShapeType(); type < last; ++type) - if ( util.Count( srcGroup, (TopAbs_ShapeEnum)type, 0) != - util.Count( group, (TopAbs_ShapeEnum)type, 0)) + if ( SMESH_MesherHelper::Count( srcGroup, (TopAbs_ShapeEnum)type, 0) != + SMESH_MesherHelper::Count( group, (TopAbs_ShapeEnum)type, 0)) break; if ( type == last ) return group; @@ -285,7 +284,7 @@ namespace { // get edges of the face TopoDS_Edge edgeGr1, edgeGr2, verticEdge2; list< TopoDS_Edge > edges; list< int > nbEdgesInWire; - SMESH_Block::GetOrderedEdges( face, v1, edges, nbEdgesInWire); + SMESH_Block::GetOrderedEdges( face, edges, nbEdgesInWire, v1); if ( nbEdgesInWire.front() != 4 ) return _StoreBadShape( face ); list< TopoDS_Edge >::iterator edge = edges.begin(); @@ -713,7 +712,7 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the // Maybe groups contain only one member TopoDS_Iterator it1( theShape1 ), it2( theShape2 ); TopAbs_ShapeEnum memberType = it1.Value().ShapeType(); - int nbMembers = Count( theShape1, memberType, true ); + int nbMembers = SMESH_MesherHelper::Count( theShape1, memberType, true ); if ( nbMembers == 0 ) return true; if ( nbMembers == 1 ) { return FindSubShapeAssociation( it1.Value(), theMesh1, it2.Value(), theMesh2, theMap ); @@ -762,7 +761,8 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the if ( groupEdges[ is2ndGroup ].Contains( f.Current() )) if ( ++nbGroupEdges > 1 ) break; - bool add = (nbGroupEdges > 1 || Count( face, TopAbs_EDGE, true ) == 1 ); + bool add = (nbGroupEdges > 1 || + SMESH_MesherHelper::Count( face, TopAbs_EDGE, true ) == 1 ); if ( !add ) { add = true; for ( TopExp_Explorer v( face, TopAbs_VERTEX ); add && v.More(); v.Next()) @@ -779,8 +779,8 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the } // Associate shells // - int nbFaces1 = Count( shell1, TopAbs_FACE, 0 ); - int nbFaces2 = Count( shell2, TopAbs_FACE, 0 ); + int nbFaces1 = SMESH_MesherHelper:: Count( shell1, TopAbs_FACE, 0 ); + int nbFaces2 = SMESH_MesherHelper:: Count( shell2, TopAbs_FACE, 0 ); if ( nbFaces1 != nbFaces2 ) RETURN_BAD_RESULT("Different nb of faces found for shells"); if ( nbFaces1 > 0 ) { @@ -997,16 +997,22 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the if ( face2.Orientation() >= TopAbs_INTERNAL ) face2.Orientation( TopAbs_FORWARD ); TopoDS_Edge edge1, edge2; // get outer edge of theShape1 - edge1 = TopoDS::Edge( OuterShape( face1, TopAbs_EDGE )); - // find out if any edge of face2 is a propagation edge of outer edge1 + TopoDS_Shape wire = OuterShape( face1, TopAbs_WIRE ); + //edge1 = TopoDS::Edge( OuterShape( face1, TopAbs_EDGE )); map propag_edges; // use map to find the closest propagation edge - for ( TopExp_Explorer exp( face2, TopAbs_EDGE ); exp.More(); exp.Next() ) { - 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 ( step_edge.first == 1 ) break; // most close found + for ( TopoDS_Iterator edgeIt( wire ); edgeIt.More(); edgeIt.Next() ) + { + edge1 = TopoDS::Edge( edgeIt.Value() ); + // find out if any edge of face2 is a propagation edge of outer edge1 + for ( TopExp_Explorer exp( face2, TopAbs_EDGE ); exp.More(); exp.Next() ) { + 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 ( step_edge.first == 1 ) break; // most close found + } } + if ( !propag_edges.empty() && propag_edges.begin()->first == 1 ) break; } if ( !propag_edges.empty() ) // propagation found { @@ -1119,8 +1125,8 @@ bool StdMeshers_ProjectionUtils::FindSubShapeAssociation(const TopoDS_Shape& the if ( vMap1.Extent() != vMap2.Extent() ) { - if ( HERE::Count( theShape1, TopAbs_EDGE, /*ignoreSame=*/false ) != - HERE::Count( theShape2, TopAbs_EDGE, /*ignoreSame=*/false )) + if ( SMESH_MesherHelper:: Count( theShape1, TopAbs_EDGE, /*ignoreSame=*/false ) != + SMESH_MesherHelper:: Count( theShape2, TopAbs_EDGE, /*ignoreSame=*/false )) RETURN_BAD_RESULT("Different nb of vertices"); } @@ -1285,8 +1291,8 @@ int StdMeshers_ProjectionUtils::FindFaceAssociation(const TopoDS_Face& face1, edges1.clear(); edges2.clear(); - if ( SMESH_Block::GetOrderedEdges( face1, VV1[0], edges1, nbEInW1, outer_wire_algo) != - SMESH_Block::GetOrderedEdges( face2, VV2[0], edges2, nbEInW2, outer_wire_algo) ) + if ( SMESH_Block::GetOrderedEdges( face1, edges1, nbEInW1, VV1[0], outer_wire_algo) != + SMESH_Block::GetOrderedEdges( face2, edges2, nbEInW2, VV2[0], outer_wire_algo) ) CONT_BAD_RESULT("Different number of wires in faces "); if ( nbEInW1 != nbEInW2 && outer_wire_algo == 0 && @@ -1368,8 +1374,8 @@ int StdMeshers_ProjectionUtils::FindFaceAssociation(const TopoDS_Face& face1, { edges1.clear(); edges2.clear(); - SMESH_Block::GetOrderedEdges( face1, VV1[0], edges1, nbEInW1, i_ok_wire_algo); - SMESH_Block::GetOrderedEdges( face2, VV2[0], edges2, nbEInW2, i_ok_wire_algo); + SMESH_Block::GetOrderedEdges( face1, edges1, nbEInW1, VV1[0], i_ok_wire_algo); + SMESH_Block::GetOrderedEdges( face2, edges2, nbEInW2, VV2[0], i_ok_wire_algo); } gp_XY dUV = v0f2UV.XY() - v0f1UV.XY(); // UV shift between 2 faces // @@ -2103,33 +2109,7 @@ bool StdMeshers_ProjectionUtils::MakeComputed(SMESH_subMesh * sm, const int iter //================================================================================ /*! - * \brief Count nb of sub-shapes - * \param shape - the shape - * \param type - the type of sub-shapes to count - * \retval int - the calculated number - */ -//================================================================================ - -int StdMeshers_ProjectionUtils::Count(const TopoDS_Shape& shape, - const TopAbs_ShapeEnum type, - const bool ignoreSame) -{ - if ( ignoreSame ) { - TopTools_IndexedMapOfShape map; - TopExp::MapShapes( shape, type, map ); - return map.Extent(); - } - else { - int nb = 0; - for ( TopExp_Explorer exp( shape, type ); exp.More(); exp.Next() ) - ++nb; - return nb; - } -} - -//================================================================================ -/*! - * \brief Return a boundary EDGE of edgeContainer + * \brief Return a boundary EDGE (or all boundary EDGEs) of edgeContainer */ //================================================================================ diff --git a/src/StdMeshers/StdMeshers_ProjectionUtils.hxx b/src/StdMeshers/StdMeshers_ProjectionUtils.hxx index 097b0ac11..97d55ba22 100644 --- a/src/StdMeshers/StdMeshers_ProjectionUtils.hxx +++ b/src/StdMeshers/StdMeshers_ProjectionUtils.hxx @@ -196,17 +196,6 @@ class StdMeshers_ProjectionUtils */ static bool MakeComputed(SMESH_subMesh * sm, const int iterationNb = 0); - /*! - * \brief Count nb of sub-shapes - * \param shape - the shape - * \param type - the type of sub-shapes to count - * \param ignoreSame - if true, use map not to count same shapes, esle use explorer - * \retval int - the calculated number - */ - static int Count(const TopoDS_Shape& shape, - const TopAbs_ShapeEnum type, - const bool ignoreSame); - /*! * \brief Set event listeners to submesh with projection algo * \param subMesh - submesh with projection algo @@ -218,7 +207,7 @@ class StdMeshers_ProjectionUtils SMESH_Mesh* srcMesh); /*! - * \brief Return a boundary EDGE of edgeContainer + * \brief Return a boundary EDGE (or all boundary EDGEs) of edgeContainer */ static TopoDS_Edge GetBoundaryEdge(const TopoDS_Shape& edgeContainer, const SMESH_Mesh& mesh, diff --git a/src/StdMeshers/StdMeshers_Projection_2D.cxx b/src/StdMeshers/StdMeshers_Projection_2D.cxx index 115249a5e..7467a19f9 100644 --- a/src/StdMeshers/StdMeshers_Projection_2D.cxx +++ b/src/StdMeshers/StdMeshers_Projection_2D.cxx @@ -396,8 +396,8 @@ namespace { // make any local coord systems of src and tgt faces vector srcPP, tgtPP; // 3 points on face boundaries to make axes of CS - bool sameNbVert = ( TAssocTool::Count( tgtFace, TopAbs_VERTEX, /*ignoreSame=*/true ) == - TAssocTool::Count( srcFace, TopAbs_VERTEX, /*ignoreSame=*/true )); + int tgtNbVert = SMESH_MesherHelper::Count( tgtFace, TopAbs_VERTEX, /*ignoreSame=*/true ); + int srcNbVert = SMESH_MesherHelper::Count( srcFace, TopAbs_VERTEX, /*ignoreSame=*/true ); SMESH_subMesh * srcSM = srcMesh->GetSubMesh( srcFace ); SMESH_subMeshIteratorPtr smIt = srcSM->getDependsOnIterator(/*includeSelf=*/false,false); srcSM = smIt->next(); // sm of a vertex @@ -435,7 +435,7 @@ namespace { if ( tgtShape.ShapeType() == TopAbs_VERTEX ) { tgtP = BRep_Tool::Pnt( TopoDS::Vertex( tgtShape )); - if ( sameNbVert || tgtPP.empty() ) + if ( srcNbVert == tgtNbVert || tgtPP.empty() ) pOK = true; else pOK = (( tgtP.Distance( tgtPP[0] ) > tol*tol ) && @@ -806,8 +806,8 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& { if ( srcShape.ShapeType() == TopAbs_FACE ) { - int nbE1 = TAssocTool::Count( tgtFace, TopAbs_EDGE, /*ignoreSame=*/true ); - int nbE2 = TAssocTool::Count( srcShape, TopAbs_EDGE, /*ignoreSame=*/true ); + int nbE1 = SMESH_MesherHelper::Count( tgtFace, TopAbs_EDGE, /*ignoreSame=*/true ); + int nbE2 = SMESH_MesherHelper::Count( srcShape, TopAbs_EDGE, /*ignoreSame=*/true ); if ( nbE1 != nbE2 ) return error(COMPERR_BAD_SHAPE, SMESH_Comment("Different number of edges in source and target faces: ") @@ -903,8 +903,8 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& } list< TopoDS_Edge > tgtEdges, srcEdges; list< int > nbEdgesInWires; - SMESH_Block::GetOrderedEdges( tgtFace, tgtV1, tgtEdges, nbEdgesInWires ); - SMESH_Block::GetOrderedEdges( srcFace, srcV1, srcEdges, nbEdgesInWires ); + SMESH_Block::GetOrderedEdges( tgtFace, tgtEdges, nbEdgesInWires, tgtV1 ); + SMESH_Block::GetOrderedEdges( srcFace, srcEdges, nbEdgesInWires, srcV1 ); if ( nbEdgesInWires.front() > 1 ) // possible to find out orientation { @@ -976,7 +976,7 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& // Make groups of nodes to merge - // loop on edge and vertex submeshes of a target face + // loop on EDGE and VERTEX sub-meshes of a target FACE smIt = tgtSubMesh->getDependsOnIterator(/*includeSelf=*/false,/*complexShapeFirst=*/false); while ( smIt->more() ) { @@ -1002,7 +1002,7 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& groupsOfNodes.back().push_back( nIt->next() ); } } - continue; // do not treate sm of degen VERTEX + continue; // do not treat sm of degen VERTEX } // Sort new and old nodes of a submesh separately @@ -1075,23 +1075,16 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& u2nodesOnSeam.size() > 0 && seam.ShapeType() == TopAbs_EDGE ) { - int nbE1 = TAssocTool::Count( tgtFace, TopAbs_EDGE, /*ignoreSame=*/true ); - int nbE2 = TAssocTool::Count( srcFace, TopAbs_EDGE, /*ignoreSame=*/true ); + int nbE1 = SMESH_MesherHelper::Count( tgtFace, TopAbs_EDGE, /*ignoreSame=*/true ); + int nbE2 = SMESH_MesherHelper::Count( srcFace, TopAbs_EDGE, /*ignoreSame=*/true ); if ( nbE1 != nbE2 ) // 2 EDGEs are mapped to a seam EDGE { // find the 2 EDGEs of srcFace TopTools_DataMapIteratorOfDataMapOfShapeShape src2tgtIt( shape2ShapeMap._map2to1 ); for ( ; src2tgtIt.More(); src2tgtIt.Next() ) if ( seam.IsSame( src2tgtIt.Value() )) - { - const TopoDS_Shape& tgtEdge = src2tgtIt.Key(); - if ( SMESHDS_SubMesh* tgtSM = srcMesh->GetMeshDS()->MeshElements( tgtEdge )) - { - SMDS_NodeIteratorPtr nIt = tgtSM->GetNodes(); - while ( nIt->more() ) - SMESH_Algo::addBadInputElement( nIt->next() ); - } - } + SMESH_Algo::addBadInputElements + ( srcMesh->GetMeshDS()->MeshElements( src2tgtIt.Key() )); return error( COMPERR_BAD_INPUT_MESH, "Different number of nodes on two edges projected to a seam edge" ); } @@ -1120,7 +1113,8 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& groupsOfNodes.back().push_back( u_newNode->second ); groupsOfNodes.back().push_back( u_newOnSeam->second ); } - } + + } // loop on EDGE and VERTEX submeshes of a target FACE // Merge -- 2.39.2