X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBLSURFPlugin%2FBLSURFPlugin_BLSURF.cxx;h=94e8065769ef2d2afaf6da97c51990370d6a739c;hb=ce134533bb9155786bb02b76e6a63b4efae4f0d0;hp=6c7f12bf505905080f511a27520bd74cf0778900;hpb=6c456d792d4c1e25a9d2ded8141acae9f2c0b9bf;p=plugins%2Fblsurfplugin.git diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 6c7f12b..94e8065 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D +// Copyright (C) 2007-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -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 ); @@ -1312,7 +1345,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, ++theNbAttractors; } else{ - MESSAGE("Wrong shape type !!") + MESSAGE("Wrong shape type !!"); } } @@ -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; } } @@ -3080,7 +3114,8 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelpe } std::string errorTxt; - if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( msh, errorTxt )) + + if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( msh, "cadsurf", errorTxt )) return error( "Problem with library SalomeMeshGemsKeyGenerator: " + errorTxt ); ret = cadsurf_set_mesh(css, msh);