How to get mesh naked edges with c++

Hi;
I am try to get mesh naked edges by:

	CRhinoGetObject go;
	go.SetCommandPrompt(L"Select open mesh");
	go.EnableSubObjectSelect(false);
	go.GetObjects(1, 1);
	if (go.CommandResult() != CRhinoCommand::success)
		return go.CommandResult();
	ON_SimpleArray<ON_2dex> ed;
	unsigned int edge_list_partition[6];
	if (go.Object(0).Mesh()->GetMeshEdgeList(ed, true, edge_list_partition) > 0)
	{
		ON_3dPointArray vertices;
		for (int n = 0; n < ed.Count(); n++)
		{
			if (edge_list_partition[3] <= n < edge_list_partition[4])
			{
				ON_Line edgeline(go.Object(0).Mesh()->m_V[ed[n].i], 
                                go.Object(0).Mesh()->m_V[ed[n].j]);
				RhinoApp().ActiveDoc()->AddCurveObject(edgeline);
			}
		}
	}
	context.m_doc.Redraw();
	return CRhinoCommand::success;

But it get all edges of mesh to me, what is wrong in my code?

Hi @suc_kiet,

Look for topological edges that have a single topological face.

CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
{
  CRhinoGetObject go;
  go.SetCommandPrompt(L"Select open mesh");
  go.SetGeometryFilter(CRhinoGetObject::mesh_object);
  go.SetGeometryAttributeFilter(CRhinoGetObject::open_mesh);
  go.GetObjects(1, 1);
  if (go.CommandResult() != CRhinoCommand::success)
    return go.CommandResult();

  const ON_Mesh* mesh = go.Object(0).Mesh();
  if (nullptr == mesh)
    return CRhinoCommand::failure;

  const ON_MeshTopology& mesh_top = mesh->Topology();
  if (0 == mesh_top.TopEdgeCount())
    return CRhinoCommand::failure;

  int naked_edge_count = 0;
  for(int ei = 0; ei < mesh_top.m_tope.Count(); ei++)
  {
    const ON_MeshTopologyEdge& tope = mesh_top.m_tope[ei];
    if (1 == tope.m_topf_count)
      naked_edge_count++;
  }

  RhinoApp().Print(L"Selected mesh has %d naked edge(s)\n", naked_edge_count);

  return CRhinoCommand::success;
}

– Dale

Hi@dale,
Thank you :grinning: