Finding the faces and edges?

I try to figure out how to find the faces and edges with certain search parameters.

Assuming I have one object/mesh:

  1. How I can check, to which face certain edge belongs?
    I.E. Edge1 belongs to the FaceA.

  2. How I can check, which edges belog to the certain face?
    I.E. FaceA = edge1, edge2, edge3.

check if the verts in the edge are also in the face.

Faces know which vertices belong to them. So do edges.

By using this fact, you could iterate through edges to find verts that are the interesting ones. Then use these verts to find the faces.

To check which edges belong to each face you could get their verts and then iterate edges and pick ones that have those verts.

One interesting possibility is to construct a data structure that is easy to check out. I did something like that in my FindPoles script (http://blenderartists.org/forum/showthread.php?t=71317). By using vert->edges information, you can iterate through faces to find verts attached to them to find all edges. Then you have to pick the edges that are shared by two vertices. This will give you edges related to each face.

You don’t need to cook up your own function doing that. In the bpymodules directory in the scripts folder is
a module called BPyMesh, which has two functions
edge_face_users(Mesh) and
face_edges(Mesh)
which return lists which give you the edges of a face and vice versa.