How do you identify hard (faceted) edges in an ON_Mesh?

I’m walking a ON_Mesh and I have a ON_MeshTopology but don’t see how I can test each edge to check whether its hard.

Worse case I could look at face normals either side of an edge, but that sounds pretty scummy.


Hi Adam,

By “hard”, do you mean welded?

If so, then this code sample might help:

bool IsUnweldedEdge(int edgeidx, const ON_MeshTopology& Top)
  const ON_MeshTopologyEdge& edge = Top.m_tope[edgeidx];
  if (1 == edge.m_topf_count)
    return true;

  if (1 == Top.m_topv[edge.m_topvi[0]].m_v_count || 1 == Top.m_topv[edge.m_topvi[1]].m_v_count)
    // If both ends of the edge have to have more than one mesh vertex or they are for sure welded.
    // However having more than 1 vertex at both ends does not necessarily mean it is unwelded.
    return false; 

  return true;

Not exactly. But close I think

I wanted to identify triangles edges that are not part of the ‘interior’ of the surface. So a non-manifold curvy surface would just have some of the triangle edges on the boundary, ones in the middle would not.

A sphere would have no hard edges identified

A cube would have 12 edges…

What you describe is quite different (I think) than what I posted.

For open meshes, it sounds like you trying to find edges that have a single face. If that is the case, then this code will help.

As for closed meshes (e.g. surfaces, boxes, etc.), you won’t find any edges with a single face. So I’m not quite sure what you are looking for. For these shapes, the only think that defines a “hard edge” is the angle between adjacent faces. So I probably still need some clarification here…