Difference between these ON_Brep edges?


(NathanM) #1

Hi,

Whenever I select an object of type edge_object, if it’s an edge shared among two brep faces I can choose among 2 options:

If I call

const CRhinoObjRef& objref = go.Object(0);
const ON_BrepEdge* pEdge = objref.Edge();
int indEdge = pEdge->EdgeCurveIndexOf();

indEdge will be the same for the 2 options, so what’s the index/info that tells me the difference? I need the face index I’m referring to through the arrows.

Thx
Nathan


(Dale Fugier) #2

Hi @NathanM1994,

Can you provide the sample code you are using to pick the edge curves?

– Dale


(NathanM) #3

Hi @dale ,

CRhinoGetObject go;
go.SetCommandPrompt(L"Select edges");
go.SetGeometryFilter(CRhinoGetObject::edge_object); //edge_object
go.EnableSubObjectSelect( TRUE );
go.GetObjects(1, 1);
if (go.CommandResult() != CRhinoCommand::success) return go.CommandResult();

const CRhinoObjRef& objref = go.Object(0);

const ON_BrepEdge* pEdge = objref.Edge();
if (!pEdge) return CRhinoCommand::failure;

int indEdge = pEdge->EdgeCurveIndexOf();
RhinoApp().Print("EdgeCurveIndexOf:	%d\n", indEdge);

Should I use another geometry filter instead of edge_object?

Nathan


(Dale Fugier) #4

Hi @NathanM1994,

It turns out, there a number of ways to setup a CRhinoGetObject object to pick surface edges. Your code is one way.

An ON_BrepEdge is connector for joining ON_BrepTrim objects and representing a 3-D location of the seam they form. An edge can connect one or more trims. In the case of a simple “joined edge” there will be 2 trims, one from each adjacent face.

For example:

CRhinoGetObject go;
go.SetCommandPrompt(L"Select edges");
go.SetGeometryFilter(CRhinoGetObject::edge_object);
go.GetObjects(1, 0);
if (go.CommandResult() == CRhinoCommand::success)
{
  for (int i = 0; i < go.ObjectCount(); i++)
  {
    const CRhinoObjRef& obj_ref = go.Object(i);
    const ON_BrepEdge* edge = obj_ref.Edge();
    const ON_BrepTrim* trim = obj_ref.Trim();
    if (nullptr != edge && nullptr != trim)
    {
      const ON_BrepFace* face = trim->Face();
      if (nullptr != face)
      {
        RhinoApp().Print(L"Edge = %d, Trim = %d, Face = %d\n",
          edge->m_edge_index,
          trim->m_trim_index,
          face->m_face_index
        );
      }
    }
  }
}

Does this help?

– Dale


(NathanM) #5

I see, so I was confusing edges with trims. This is very useful, thank you!

Nathan