View Issue Details

IDProjectCategoryView StatusLast Update
0033111CommunityOCCT:Foundation Classespublic2022-08-24 12:04
Reportermukadi Assigned Toabv 
PrioritynormalSeverityminor 
Status newResolutionopen 
Summary0033111: Approx_SameParameter.cxx :: change the calculation of deviation in "ComputeTolReached ( )"
DescriptionThe deviation between subsequent calculation should not be "restricted" as it is desired that it be very small.
Convergence test desires it to be very small. It is wrong to replace it with a large unrelated value as :
                   aDeviation = Max(aDeviation, Precision::Confusion());
That causes the first LOOP in the BUILD to always fail, even when convergence already occurred.
That "Deviation should be let as is ; using Precision::Confusion() is wrong, it causes as waste and failure
to catch convergence. SINCE, geometry has well known sizes,
    (1) "Bnd_Box" and Bnd_Box2D could be used to define the LENGTH-SCALE,
    (2) All tests of proximity or distance conversion Should be relative to that SCALE.
I would recommend the change in the routine "ComputeTolReached ( )"
I would recommend the change everywhere though, if possible.

/*
Surface Filling with these three strait-lines defining a triangle.
Was taking too many points before convergence
we add to investigate and found out the culprit
*/
Point(1 ) = { +1, +1, +1 };
Point(2 ) = { +1, -1, -1 };
Point(3 ) = { -1, +1, -1 };
//+
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 1};

Steps To ReproduceSuggest the change to routine pasted bellow :


//=======================================================================
//function : ComputeTolReached
//purpose :
//=======================================================================
static Standard_Real ComputeTolReached(const Handle(Adaptor3d_Curve)& c3d,
                                       const Adaptor3d_CurveOnSurface& cons,
                                       const Standard_Integer nbp)
{
  Standard_Real d2 = 0.0; // Square max discrete deviation.
  const Standard_Real first = c3d->FirstParameter();
  const Standard_Real last = c3d->LastParameter();
  for(Standard_Integer i = 0; i <= nbp; i++)
  {
    Standard_Real t = IntToReal(i) / IntToReal(nbp);
    Standard_Real u = first * (1.0 - t) + last * t;
    gp_Pnt Pc3d, Pcons;
    try
    {
      Pc3d = c3d->Value(u);
      Pcons = cons.Value(u);
    }
    catch (Standard_Failure const&)
    {
      d2 = Precision::Infinite();
      break;
    }
    if (Precision::IsInfinite(Pcons.X()) ||
        Precision::IsInfinite(Pcons.Y()) ||
        Precision::IsInfinite(Pcons.Z()))
    {
        d2=Precision::Infinite();
        break;
    }
    d2 = Max(d2, Pc3d.SquareDistance(Pcons));
  }

  const Standard_Real aMult = 1. + 0.05; //
  Standard_Real aDeviation = aMult * sqrt(d2);
 //
 // Changed by Samy Mukadi, phD, P.Eng. (Canada) :
  // deviation shoud not be restricted as we are comparing them directly
  // in fact deviation could be zero if the point completely match
  // - The first LOOP in the Build() uses it directly,
  // that's why that first loop always fails to catch the convergence
  // - The second Loop attempt to increased tolerance to catch the convergence, that a total waste
  // - We could use a scaled tolerance instead, as the magnitude of the length is well known through BndBOX
  // Convergence test shoud be :
  // distScale = BndBOX.Diagonal >0.0 ? BndBOX.Diagonal : 1 // <:::> in fact "BndBOX.Diagonal" can't be exact zero
  // if ( aDeviation <= Tol * distScale ) convergence = OK
  // This way the test is independent of Units, as "BndBOX.Diagonal" is an appropriate scale
  //
  // aDeviation = Max(aDeviation, Precision::Confusion()); // Tolerance in modeling space.
  //
  return aDeviation;
}
TagsNo tags attached.
Test case number

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2022-08-24 12:04 mukadi New Issue
2022-08-24 12:04 mukadi Assigned To => abv