NormalizedLengthParameter for points on curve gives zero for each point parameter on curve.
One of past post by @menno, I saw that, I will need to use Curve.RemoveShortSegments(tolarance)
I have used tolarance=0.0001 and also tried with 0.0. It did not work.
What should be the tolerance for Curve.RemoveShortSegments(…) ?
FYI, this is the extension method that we use for normalized length parameters to work around some of the issues.
public static double[] NormalizedLengthParameters2([NotNull] this Curve curve, double[] fractions, double absoluteTolerance, double fractionalTolerance = 1e-8)
{
if (curve == null) throw new ArgumentNullException("curve");
if (null == fractions) throw new ArgumentNullException("fractions");
if (absoluteTolerance < 0) throw new ArgumentException("absoluteTolerance < 0");
if (fractionalTolerance < 0) throw new ArgumentException("fractionalTolerance < 0");
double[] t = curve.NormalizedLengthParameters(fractions, absoluteTolerance, fractionalTolerance);
if (null == t)
{
NurbsCurve copy = curve.ToNurbsCurve();
if (null == copy)
return null;
using (copy)
{
if (copy.RemoveShortSegments(absoluteTolerance))
{
t = copy.NormalizedLengthParameters(fractions, absoluteTolerance, fractionalTolerance);
}
if (copy.IsShort(absoluteTolerance))
return fractions;
if (null != t)
return t;
t = new double[fractions.Length];
for (int i = 0; i < fractions.Length; i++)
{
double f = fractions[i];
if (!copy.NormalizedLengthParameter(f, out t[i], fractionalTolerance))
{
Logger.Error("Could not get normalized length parameters for curve.");
t = null;
break;
}
}
}
}
return t;
}
1 Like