def getTexcoordToImgMapping(mesh):

    #get a list of all texture coordinate sets
    all_texcoords = {}
    for geom in mesh.geometries:
        for prim_index, prim in enumerate(geom.primitives):
            inputs = prim.getInputList().getList()
            texindex = 0
            for offset, semantic, srcid, setid in inputs:
                if semantic == 'TEXCOORD':
                    try: setid = int(setid)
                    except (__HOLE__, TypeError): setid = 0
                    texset = TexcoordSet(geom.id, prim_index, texindex, setid)
                    texindex += 1
                    all_texcoords[texset] = []
    
    #create a mapping between each texcoordset and the images they get bound to by traversing scenes
    for scene in mesh.scenes:
        for boundobj in itertools.chain(scene.objects('geometry'), scene.objects('controller')):
            if isinstance(boundobj, collada.geometry.BoundGeometry):
                boundgeom = boundobj
            else:
                boundgeom = boundobj.geometry
            geom_id = boundgeom.original.id
            for prim_index, boundprim in enumerate(boundgeom.primitives()):
                if boundprim.material is not None:
                    effect = boundprim.material.effect
                    inputmap = boundprim.inputmap
                    for prop in itertools.chain(effect.supported, ['bumpmap']):
                        propval = getattr(effect, prop)
                        if type(propval) is collada.material.Map:
                            if propval.texcoord in inputmap:
                                cimg = propval.sampler.surface.image
                                semantic, setid = inputmap[propval.texcoord]
                                if not setid: setid = 0
                                else:
                                    try: setid = int(setid)
                                    except (ValueError, TypeError): setid = 0
                                if semantic == 'TEXCOORD':
                                    texset = TexcoordSet(geom_id, prim_index, -1, setid)
                                    if texset in all_texcoords:
                                        if cimg.path not in all_texcoords[texset]:
                                            all_texcoords[texset].append(cimg.path)
    
    #remove any texture coordinates that dont get mapped to textures
    all_texcoords = dict( (texset, imglist)
                          for texset, imglist in all_texcoords.iteritems()
                          if len(imglist) > 0 )
    
    return all_texcoords
dataset/ETHPy150Open pycollada/meshtool/meshtool/filters/atlas_filters/make_atlases.py/getTexcoordToImgMapping