Curve interval

Dale,

When calling “ON_Interval rnCurveInterval = prnCurve->Domain();”, we want to make sure “rnCurveInterval.m_t[1] > rnCurveInterval.m_t[0]”. Would switching the two values work? (The curve may be periodic, so switching the two values may not get the right interval.)

@XNurbs, in RhinoCommon there is an Interval.MakeIncreasing() method, not sure if this helps.

_
c.

Hi @XNurbs,

You can use ON_Interval::IsIncreasing to test if ON_Interval::m_t[0] < ON_Interval::m_t[1].

To safely swap ON_Interval::m_t[0] and ON_Interval::m_t[1], use ON_Interval::MakeIncreasing.

– Dale

Dale,

We change the code to
ON_Interval rnCurveInterval = prnCurve->Domain();
rnCurveInterval.MakeIncreasing();

Would it ensure (rnCurveInterval.m_t[1] > rnCurveInterval.m_t[0])? or still need to swap ON_Interval::m_t[0] and ON_Interval::m_t[1]?

ON_Interval::MakeIncreasing says “returns true if resulting interval IsIncreasing()”. If it returns false, then what?

Many thanks.

ON_Interval::MakeIncreasing ensures the interval is increasing. If the interval is already in creasing, then nothing is done.

– Dale