[bos #35094] [EDF] (2023-T1) X,Y,Z to U,V. Consider face tolerance.

This commit is contained in:
jfa 2023-06-26 17:56:13 +01:00
parent 9473f01eac
commit e8fc8b6907
3 changed files with 35 additions and 26 deletions

View File

@ -3032,8 +3032,8 @@ Handle(TColStd_HArray1OfReal) GEOMImpl_IMeasureOperations::XYZtoUV
}
// Face tolerance
Standard_Real squareTolerance = BRep_Tool::Tolerance(F);
squareTolerance = squareTolerance * squareTolerance;
Standard_Real aTol = BRep_Tool::Tolerance(F);
Standard_Real squareTolerance = aTol * aTol;
// Compute parameters
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
@ -3049,8 +3049,9 @@ Handle(TColStd_HArray1OfReal) GEOMImpl_IMeasureOperations::XYZtoUV
gp_Pnt aP (theXYZlist->Value(iCLower + iP * 3),
theXYZlist->Value(iCLower + iP * 3 + 1),
theXYZlist->Value(iCLower + iP * 3 + 2));
try { // as GEOMUtils::ProjectPointOnFace can throw exceptions
Standard_Real U, V;
gp_Pnt aPonF = GEOMUtils::ProjectPointOnFace(aP, F, U, V);
gp_Pnt aPonF = GEOMUtils::ProjectPointOnFace(aP, F, U, V, aTol);
if (aP.SquareDistance(aPonF) < squareTolerance) {
if (isNormalized) {
// Normalize parameters to be in [0, 1]
@ -3065,6 +3066,11 @@ Handle(TColStd_HArray1OfReal) GEOMImpl_IMeasureOperations::XYZtoUV
return aRet;
}
}
catch (Standard_Failure& aFail) {
SetErrorCode(aFail.GetMessageString());
return aRet;
}
}
SetErrorCode(OK);
return aRet;

View File

@ -1032,7 +1032,8 @@ Standard_Real GEOMUtils::GetMinDistance
//=======================================================================
gp_Pnt GEOMUtils::ProjectPointOnFace(const gp_Pnt& thePoint,
const TopoDS_Shape& theFace,
double& theU, double& theV)
double& theU, double& theV,
const double theTol)
{
if (theFace.IsNull() || theFace.ShapeType() != TopAbs_FACE)
Standard_TypeMismatch::Raise
@ -1044,7 +1045,7 @@ gp_Pnt GEOMUtils::ProjectPointOnFace(const gp_Pnt& thePoint,
BRepTools::UVBounds(aFace, U1, U2, V1, V2);
// projector
Standard_Real tol = 1.e-4;
Standard_Real tol = Max(theTol, 1.e-4);
GeomAPI_ProjectPointOnSurf proj;
proj.Init(surface, U1, U2, V1, V2, tol);
proj.Perform(thePoint);

View File

@ -222,11 +222,13 @@ namespace GEOMUtils
* \param theFace the face shape
* \param theU the output U parameter of the point on the face
* \param theV the output V parameter of the point on the face
* \param theTol the tolerance value. Maximum of theTol and 1e-04 will be used for calculation.
* \retval the projection (3d point) if found, throws an exception otherwise
*/
Standard_EXPORT gp_Pnt ProjectPointOnFace(const gp_Pnt& thePoint,
const TopoDS_Shape& theFace,
double& theU, double& theV);
double& theU, double& theV,
const double theTol = 1e-04);
/*!
* \brief Returns the point clicked in 3D view.