If your non-convex polygon is as you've shown it (i.e. the union of a set of quadrilateral elements) all you have to do is find the edges of the quadrilaterals that lie on the boundary.
This can be achieved by noting that these "external" edges only appear in one element, while the "internal" edges are common to two adjacent elements. This implies the following simple algorithm:
edge_list = {}
for (i = all elements in mesh)
for (j = all edges in element(i))
edge_list <- push jth edge of ith element
endfor
endfor
edge_list <- sort
edge_list <- remove_duplicates
The remaining unique edges form the external contour of your polygon. This simple algorithm runs in O(N*log(N))
time.
You can improve the complexity by making use of a suitable hash table for the edge comparisons, reducing the complexity to O(N)
.