I am thinking something like this would work, although it doesn’t take welded edges into account.

```
static int FindAdjacentFaces(
const ON_Mesh* mesh,
int face_index,
ON_SimpleArray<int>& adjacent_faces
)
{
if (mesh && mesh->IsValid())
{
if (face_index >= 0 && face_index < mesh->FaceCount())
{
const ON_MeshTopology& top = mesh->Topology();
if (top.IsValid())
{
ON_COMPONENT_INDEX ci(ON_COMPONENT_INDEX::mesh_face, face_index);
const ON_MeshFaceRef& face_ref = top.FaceRef(ci);
const ON_MeshTopologyFace* face = face_ref.MeshTopologyFace();
if (face)
{
for (int i = 0; i < (face->IsQuad() ? 4 : 3); i++)
{
const ON_MeshTopologyEdge& edge = top.m_tope[face->m_topei[i]];
if (1 != edge.m_topf_count)
{
for (int j = 0; j < edge.m_topf_count; j++)
adjacent_faces.Append(edge.m_topfi[j]);
}
}
adjacent_faces.QuickSort(&ON_CompareIncreasing<int>);
int index = *adjacent_faces.Last();
for (int i = adjacent_faces.Count() - 2; i >= 0; i-- )
{
if (index == adjacent_faces[i])
adjacent_faces.Remove(i);
else
index = adjacent_faces[i];
}
adjacent_faces.Shrink();
}
}
}
}
return adjacent_faces.Count();
}
```