Hi,

Can somebody help me with the term “Trim tolerance” (and other tolerances ) in openNURBS, please?

If I check the code of ON_Brep::SetTrimTolerance method, it looks like this

```
ON_3dPoint prev_end = prev_trim.PointAtEnd(); //prev_c2->PointAt( prev_trim.m_t[1] );
ON_3dPoint this_start = trim.PointAtStart(); //c2->PointAt( trim.m_t[0] );
ON_3dPoint this_end = trim.PointAtEnd(); // c2->PointAt( trim.m_t[1] );
ON_3dPoint next_start = next_trim.PointAtStart(); //prev_c2->PointAt( next_trim.m_t[0] );
for ( dir = 0; dir < 2; dir++ )
{
if ( trim.m_tolerance[dir] < 0.0 || !bLazy )
{
ds = fabs(prev_end[dir] - this_start[dir] );
de = fabs(this_end[dir] - next_start[dir] );
d = (ds >= de) ? ds : de;
trim.m_tolerance[dir] = ( d > ON_ZERO_TOLERANCE ) ? 1.001*d : 0.0;
}
}
```

This code snippet suggests that the trim tolerance is used to connect 2d parametric curves having end-points within the given trim tolerance value.

However, in the code of ON_Brep::IsValidLoop, there is no trim tolerances encountered during the validity check:

for ( lti = 0; lti < loop_trim_count; lti++ )

{

//double x_tol = ON_ZERO_TOLERANCE;

//double y_tol = ON_ZERO_TOLERANCE;

const ON_BrepTrim& trim0 = m_T[loop.m_ti[lti]];

next_lti = (lti+1)%loop_trim_count;

const ON_BrepTrim& trim1 = m_T[loop.m_ti[next_lti]];

ON_Interval trim0_domain = trim0.Domain();

ON_Interval trim1_domain = trim1.Domain();

ci0 = trim0.m_c2i;

ci1 = trim1.m_c2i;

pC0 = m_C2[ci0];

pC1 = m_C2[ci1];

P0 = pC0->PointAt( trim0_domain[1] ); // end of this 2d trim

P1 = pC1->PointAt( trim1_domain[0] ); // start of next 2d trim

if ( !(P0-P1).IsTiny() )

{

// 16 September 2003 Dale Lear - RR 11319

// Added relative tol check so cases with huge

// coordinate values that agreed to 10 places

// didn’t get flagged as bad.

double xtol = (fabs(P0.x) + fabs(P1.x))*1.0e-10;

double ytol = (fabs(P0.y) + fabs(P1.y))*1.0e-10;

if ( xtol < ON_ZERO_TOLERANCE )

xtol = ON_ZERO_TOLERANCE;

if ( ytol < ON_ZERO_TOLERANCE )

ytol = ON_ZERO_TOLERANCE;

double dx = fabs(P0.x-P1.x);

double dy = fabs(P0.y-P1.y);

if ( dx > xtol || dy > ytol )

{

if ( text_log )

{

text_log->Print(“brep.m_L[%d] loop is not valid.\n”,loop_index);

text_log->PushIndent();

text_log->Print(“end of brep.m_T[loop.m_ti[%d]=%d]=(%g,%g) and start \n”, lti, loop.m_ti[lti],P0.x,P0.y);

text_log->Print(“of brep.m_T[loop.m_ti[%d]=%d]=(%g,%g) do not match.\n”,next_lti, loop.m_ti[next_lti],P1.x,P1.y);

text_log->PopIndent();

}

return ON_BrepIsNotValid();

}

}

}

This is quite confusing…

Can anybody point to a good documentation about how to use different tolerances in openNURBS?

Thank you in advance…