From: Christophe Bourcier Date: Mon, 28 Aug 2023 13:00:51 +0000 (+0200) Subject: Fix test MESH_BLSURF_00_A3. Don't add an enforced vertex if it is already on the... X-Git-Tag: V9_12_0a1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ce134533bb9155786bb02b76e6a63b4efae4f0d0;p=plugins%2Fblsurfplugin.git Fix test MESH_BLSURF_00_A3. Don't add an enforced vertex if it is already on the shape (except for internal vertices) --- diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 5d93c26..94e8065 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -515,12 +515,45 @@ TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry) return S; } +// Check if a point is already on the shape. +// if faceShape is defined, we use it +// else we use the sub-shape of the mesh +bool _doVertexAlreadyExists(const TopoDS_Face& faceShape, + const gp_Pnt& aPnt) +{ + // If the point is already on the shape, no need to add it + TopExp_Explorer ex; + TopoDS_Shape shapeToCheckVertices(faceShape); + bool alreadyExists(false); + if (faceShape.IsNull()) + shapeToCheckVertices = theHelper->GetSubShape(); + for (ex.Init(shapeToCheckVertices, TopAbs_VERTEX); ex.More(); ex.Next()) + { + TopoDS_Vertex vertex = TopoDS::Vertex(ex.Current()); + double tol = BRep_Tool::Tolerance( vertex ); + gp_Pnt p = BRep_Tool::Pnt(vertex); + if ( p.IsEqual( aPnt, tol)) + { + MESSAGE("The enforced vertex is already on the shape => No need to add it."); + alreadyExists = true; + break; + } + } + return alreadyExists; +} + void _createEnforcedVertexOnFace(TopoDS_Face faceShape, const gp_Pnt& aPnt, - BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex) + BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex, + bool checkVertexAlreadyExists=true) { BLSURFPlugin_Hypothesis::TEnfVertexCoords enf_coords, coords, s_coords; + // checkVertexAlreadyExists only for non internal vertices. + // For them we set checkVertexAlreadyExists=false as we do have to add them + if (checkVertexAlreadyExists && _doVertexAlreadyExists(faceShape, aPnt)) + return; + // Find the face and get the (u,v) values of the enforced vertex on the face BLSURFPlugin_BLSURF::projectionPoint projPnt = BLSURFPlugin_BLSURF::getProjectionPoint( faceShape, aPnt, /*allowStateON=*/true ); @@ -1372,7 +1405,8 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, enfVertex->geomEntry = ""; enfVertex->grpName = grpName; enfVertex->vertex = TopoDS::Vertex( exp_face.Current() ); - _createEnforcedVertexOnFace( TopoDS::Face(exp.Current()), aPnt, enfVertex); + _createEnforcedVertexOnFace( TopoDS::Face(exp.Current()), aPnt, enfVertex, + /*checkVertexAlreadyExists*/false); HasSizeMapOnFace = true; } }