Edge interval

We use the following code to get the edge interval and whether the curve and the loop lying on the specified face have the same direction (sense).

const ON_BrepEdge * prnEdge = ...;
const ON_Curve* prnCurve = ON_Curve::Cast(prnEdge);
ON_Interval rnCurveInterval = prnCurve->Domain();
const ON_BrepTrim * prnTrim = prnEdge->Trim(0);
bCurveSenseInFace = !(prnTrim->m_bRev3d);
  1. Would prnCurve->Domain() return the edge interval? (A curve can be used by multiple edges.)

  2. rnCurveInterval.MakeIncreasing(). Does it simply swap the interval to make the interval increasing? (If so, it means that MakeIncreasing() actually “reverse” the curve and the bCurveSenseInFace would be wrong.)

  3. bCurveSenseInFace = !(prnTrim->m_bRev3d). Is it the correct method to check whether the curve and the loop lying on the specified face have the same direction (sense).

Many thanks.

Hi @XNurbs,

1.) ON_BrepEdge inherits from ON_Curve. So you can just do this:

const ON_BrepEdge * pEdge = ...;
ON_Interval edge_domain = pEdge->Domain();

2.) Here is the definition of ON_Interval::MakeIncreasing:

bool ON_Interval::MakeIncreasing()
  if (IsDecreasing())
    return true;
  return IsIncreasing();

3.) If ON_Brep::m_bRev3d is true, then the 2d trim and 3d edge have opposite orientations.

– dale

Thank you for the ON_Interval::MakeIncreasing code, and the code helps us fix a bug. It does “reverse” the curve.

Does ON_BrepEdge::Domain() just call ON_Curve::Domain()? If so, it may actually return the curve interval, which would be a bug (I cannot find ON_BrepEdge::Domain() in the head file.)

Hi @XNurbs,

ON_Curve::Domain() is a virtual function, declared in opennurbs_curve.h. You won’t find it declared on ON_BrepEdge, as it is declared on the base class.

– Dale