X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Import_1D2D.cxx;h=04d9035088dd04dbeae6e114312a624785b2339a;hp=e0e2df6664e4181ebdf98d7e3cc4fc5f1133c272;hb=0fc0831670e27a5611b941c52dc152fd63964515;hpb=bd7477efc255f965c479d88d1be1ee3dbf4aa760 diff --git a/src/StdMeshers/StdMeshers_Import_1D2D.cxx b/src/StdMeshers/StdMeshers_Import_1D2D.cxx index e0e2df666..04d903508 100644 --- a/src/StdMeshers/StdMeshers_Import_1D2D.cxx +++ b/src/StdMeshers/StdMeshers_Import_1D2D.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SMESH SMESH : implementaion of SMESH idl descriptions +// SMESH SMESH : implementation of SMESH idl descriptions // File : StdMeshers_Import_1D2D.cxx // Module : SMESH // @@ -34,11 +34,13 @@ #include "SMESHDS_Group.hxx" #include "SMESHDS_Mesh.hxx" #include "SMESH_Comment.hxx" +#include "SMESH_ControlsDef.hxx" #include "SMESH_Gen.hxx" #include "SMESH_Group.hxx" #include "SMESH_Mesh.hxx" #include "SMESH_MesherHelper.hxx" #include "SMESH_OctreeNode.hxx" +#include "SMESH_MeshEditor.hxx" #include "SMESH_subMesh.hxx" #include "Utils_SALOME_Exception.hxx" @@ -47,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -187,8 +190,8 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & SMESHDS_Mesh* tgtMesh = theMesh.GetMeshDS(); const TopoDS_Face& geomFace = TopoDS::Face( theShape ); - const double faceTol = helper.MaxTolerance( geomFace ); - const int shapeID = tgtMesh->ShapeToIndex( geomFace ); + const double faceTol = helper.MaxTolerance( geomFace ); + const int shapeID = tgtMesh->ShapeToIndex( geomFace ); const bool toCheckOri = (helper.NbAncestors( geomFace, theMesh, TopAbs_SOLID ) == 1 ); @@ -198,7 +201,8 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & gp_Pnt p; gp_Vec du, dv; // BRepClass_FaceClassifier is most time consuming, so minimize its usage - BRepClass_FaceClassifier classifier; + const double clsfTol = 10 * BRep_Tool::Tolerance( geomFace ); + BRepTopAdaptor_FClass2d classifier( geomFace, clsfTol ); //Brimless_FaceClassifier classifier; Bnd_B2d bndBox2d; Bnd_Box bndBox3d; { @@ -269,12 +273,25 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & map::iterator link2Nb; double minGroupTol = Precision::Infinite(); + SMESH::Controls::ElementsOnShape onEdgeClassifier; + if ( helper.HasSeam() ) + { + TopoDS_Compound edgesCompound; + BRep_Builder builder; + builder.MakeCompound( edgesCompound ); + for ( size_t iE = 0; iE < edges.size(); ++iE ) + builder.Add( edgesCompound, edges[ iE ]); + onEdgeClassifier.SetShape( edgesCompound, SMDSAbs_Node ); + } + // ========================= // Import faces from groups // ========================= StdMeshers_Import_1D::TNodeNodeMap* n2n; StdMeshers_Import_1D::TElemElemMap* e2e; + StdMeshers_Import_1D::TNodeNodeMap::iterator n2nIt; + pair< StdMeshers_Import_1D::TNodeNodeMap::iterator, bool > it_isnew; vector nodeState; vector newNodes; // of a face set bndNodes; // nodes classified ON @@ -292,13 +309,15 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & const double groupTol = 0.5 * sqrt( getMinElemSize2( srcGroup )); minGroupTol = std::min( groupTol, minGroupTol ); + // clsfTol is 2D tolerance of a probe line //GeomAdaptor_Surface S( surface ); // const double clsfTol = Min( S.UResolution( 0.1 * groupTol ), -- issue 0023092 // S.VResolution( 0.1 * groupTol )); - const double clsfTol = BRep_Tool::Tolerance( geomFace ); + // another idea: try to use max tol of all edges + //const double clsfTol = 10 * BRep_Tool::Tolerance( geomFace ); // 0.1 * groupTol; - StdMeshers_Import_1D::TNodeNodeMap::iterator n2nIt; - pair< StdMeshers_Import_1D::TNodeNodeMap::iterator, bool > it_isnew; + if ( helper.HasSeam() ) + onEdgeClassifier.SetMesh( srcMesh->GetMeshDS() ); SMDS_ElemIteratorPtr srcElems = srcGroup->GetElements(); while ( srcElems->more() ) // loop on group contents @@ -356,11 +375,21 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & gp_XY uv( Precision::Infinite(), 0 ); isOut = ( !helper.CheckNodeUV( geomFace, *node, uv, groupTol, /*force=*/true ) || bndBox2d.IsOut( uv )); + //int iCoo; if ( !isOut && !isIn ) // classify { - classifier.Perform( geomFace, uv, clsfTol ); - nodeState[i] = classifier.State(); + nodeState[i] = classifier.Perform( uv ); //classifier.Perform( geomFace, uv, clsfTol ); + //nodeState[i] = classifier.State(); isOut = ( nodeState[i] == TopAbs_OUT ); + if ( isOut && helper.IsOnSeam( uv ) && onEdgeClassifier.IsSatisfy( (*node)->GetID() )) + { + // uv.SetCoord( iCoo, helper.GetOtherParam( uv.Coord( iCoo ))); + // classifier.Perform( geomFace, uv, clsfTol ); + // nodeState[i] = classifier.State(); + // isOut = ( nodeState[i] == TopAbs_OUT ); + nodeState[i] = TopAbs_ON; + isOut = false; + } } if ( !isOut ) // create a new node { @@ -374,13 +403,14 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & } if ( nodeState[i] == TopAbs_ON ) bndNodes.insert( *node ); - else + else if ( nodeState[i] != TopAbs_UNKNOWN ) isNodeIn[ newNode->GetID() ] = isIn = true; } } if ( !(newNodes[i] = newNode ) || isOut ) break; - } + + } // loop on face nodes if ( !newNodes.back() ) continue; // not all nodes of the face lie on theShape @@ -392,8 +422,8 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & { if ( nodeState[i] != TopAbs_UNKNOWN ) continue; gp_XY uv = helper.GetNodeUV( geomFace, newNodes[i] ); - classifier.Perform( geomFace, uv, clsfTol ); - nodeState[i] = classifier.State(); + nodeState[i] = classifier.Perform( uv ); //geomFace, uv, clsfTol ); + //nodeState[i] = classifier.State(); isIn = ( nodeState[i] == TopAbs_IN ); } if ( !isIn ) // classify face center @@ -411,11 +441,12 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & proj.Perform( gc ); if ( !proj.IsDone() || proj.NbPoints() < 1 ) continue; - Quantity_Parameter U,V; + Standard_Real U,V; proj.LowerDistanceParameters(U,V); gp_XY uv( U,V ); - classifier.Perform( geomFace, uv, clsfTol ); - if ( classifier.State() != TopAbs_IN ) + //classifier.Perform( geomFace, uv, clsfTol ); + TopAbs_State state = classifier.Perform( uv ); + if ( state != TopAbs_IN ) continue; } } @@ -491,23 +522,32 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & medium = newNodes[i+nbCorners]; link2Nb = linkCount.insert( make_pair( TLink( n1, n2, medium ), 0)).first; ++link2Nb->second; - // if ( link2Nb->second == 1 ) - // { - // // measure link length - // double len2 = SMESH_TNodeXYZ( n1 ).SquareDistance( n2 ); - // if ( len2 < minGroupTol ) - // minGroupTol = len2; - // } } - } + } // loop on group contents + // Remove OUT nodes from n2n map for ( n2nIt = n2n->begin(); n2nIt != n2n->end(); ) if ( !n2nIt->second ) n2n->erase( n2nIt++ ); else ++n2nIt; - } + } // loop on src groups + + // remove free nodes created on EDGEs + { + set::iterator node = bndNodes.begin(); + for ( ; node != bndNodes.end(); ++node ) + { + n2nIt = n2n->find( *node ); + const SMDS_MeshNode* newNode = n2nIt->second; + if ( newNode && newNode->NbInverseElements() == 0 ) + { + tgtMesh->RemoveFreeNode( newNode, 0, false ); + n2n->erase( n2nIt ); + } + } + } // ========================================================== // Put nodes on geom edges and create edges on them; @@ -547,7 +587,7 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & if ( Abs(u-f) < 2 * faceTol || Abs(u-l) < 2 * faceTol ) // duplicated node on vertex return error("Source elements overlap one another"); - tgtFaceSM->RemoveNode( n, /*isNodeDeleted=*/false ); + tgtFaceSM->RemoveNode( n ); tgtMesh->SetNodeOnEdge( n, edges[iE], u ); break; } @@ -600,7 +640,7 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & TopoDS_Edge geomEdge = TopoDS::Edge(bndShapes.back()); helper.CheckNodeU( geomEdge, link._medium, u, projTol, /*force=*/true ); - tgtFaceSM->RemoveNode( link._medium, /*isNodeDeleted=*/false ); + tgtFaceSM->RemoveNode( link._medium ); tgtMesh->SetNodeOnEdge( (SMDS_MeshNode*)link._medium, geomEdge, u ); } else @@ -713,7 +753,7 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & seamHelper.AddEdge( node1, node2 ); if ( node2->getshapeId() == helper.GetSubShapeID() ) { - tgtFaceSM->RemoveNode( node2, /*isNodeDeleted=*/false ); + tgtFaceSM->RemoveNode( node2 ); tgtMesh->SetNodeOnEdge( const_cast( node2 ), seamEdge, n2->first ); } }