@pimms.value<EOL><INDENT>def surface_area(border_triangles, contained_faces, surface, closed):<DEDENT>
if not closed: return None<EOL>contained_faces = surface.tess.index(contained_faces)<EOL>def sarea(srf):<EOL><INDENT>if pimms.is_str(srf): (srf,btris) = (surface.surfaces[srf],border_triangles[srf])<EOL>else: btris = border_triangles<EOL>btris = np.transpose(btris, [<NUM_LIT:0>,<NUM_LIT:2>,<NUM_LIT:1>])<EOL>cxs = np.asarray([srf.coordinates[:,f] for f in contained_faces])<EOL>return np.sum(triangle_area(*cxs)) + np.sum(triangle_area(*btris))<EOL><DEDENT>if isinstance(surface, Topology):<EOL><INDENT>return pimms.lazy_map({k:curry(sarea, k) for k in six.iterkeys(surface.surfaces)})<EOL><DEDENT>else: return sarea(surface)<EOL>
path.surface_area is the surface area of a closed path; if path is not closed, then this
is None.

If path.surface is a topology rather than a mesh, then this is a lazy-map of surface names
whose values are the surface area for the given surface. If the path is not closed, this
remains None.