def create_radiance_srf(occface, srfname, srfmat, rad):
    bface_pts = fetch.pyptlist_frm_occface(occface)
    py2radiance.RadSurface(srfname, bface_pts, srfmat, rad)
def surfaces2radiance(id, surface, rad):
    py2radiance.RadSurface("terrain_srf" + str(id), surface, "reflectance0.2", rad)
def geometry2radiance(rad, ageometry_table, citygml_reader):
    bldg_dict_list = []

    #translate the terrain into radiance surface 
    gmlterrains = citygml_reader.get_relief_feature()
    pytri_list = citygml_reader.get_pytriangle_list(gmlterrains[0])
    for id, pytri in enumerate(pytri_list):
        py2radiance.RadSurface("terrain_srf"+ str(id), pytri, "reflectance0.2", rad)

    #translate buildings into radiance surface
    bldg_of_interest_name_list = ageometry_table.index.values
    gmlbldgs = citygml_reader.get_buildings()
    eligible_bldgs, n_eligible_bldgs = filter_bldgs_of_interest(gmlbldgs, bldg_of_interest_name_list, citygml_reader)

    ## for the surrounding buildings
    for n_gmlbldg in n_eligible_bldgs:
        pypolgon_list = citygml_reader.get_pypolygon_list(n_gmlbldg)
        for id, pypolygon in enumerate(pypolgon_list):
            py2radiance.RadSurface("surroundingbldgs"+ str(id), pypolygon, "reflectance0.2", rad)

    ## for the
    for bcnt, gmlbldg in enumerate(eligible_bldgs):
        bldg_dict = {}
        window_list = []
        
        bldg_name = citygml_reader.get_gml_id(gmlbldg)
        print "adding windows to building: ", bldg_name
        pypolgon_list = citygml_reader.get_pypolygon_list(gmlbldg)
        geo_solid = construct.make_occsolid_frm_pypolygons(pypolgon_list)
        facade_list, roof_list, footprint_list = gml3dmodel.identify_building_surfaces(geo_solid)
        wall_list = []
        wwr = ageometry_table["win_wall"][bldg_name]

        for fcnt, surface_facade in enumerate(facade_list):
            ref_pypt = calculate.face_midpt(surface_facade)

            # offset the facade to create a window according to the wwr
            if 0.0 < wwr < 1.0:
                window = create_windows(surface_facade, wwr, ref_pypt)
                create_radiance_srf(window, "win"+str(bcnt)+str(fcnt), "win" + str(ageometry_table['type_win'][bldg_name]), rad)
                window_list.append(window)

                # triangulate the wall with hole
                hollowed_facade, hole_facade = create_hollowed_facade(surface_facade, window) #accounts for hole created by window
                wall_list.append(hole_facade)

                # check the elements of the wall do not have 0 area and send to radiance
                for triangle in hollowed_facade:
                    tri_area = calculate.face_area(triangle)
                    if tri_area > 1E-3:
                        create_radiance_srf(triangle, "wall"+str(bcnt)+str(fcnt),
                                            "wall" + str(ageometry_table['type_wall'][bldg_name]), rad)

            elif wwr == 1.0:
                create_radiance_srf(surface_facade, "win"+str(bcnt)+str(fcnt), "win" + str(ageometry_table['type_win'][bldg_name]), rad)
                window_list.append(surface_facade)
            else:
                create_radiance_srf(surface_facade, "wall"+str(bcnt)+str(fcnt), "wall" + str(ageometry_table['type_wall'][bldg_name]), rad)
                wall_list.append(surface_facade)

        for rcnt, roof in enumerate(roof_list):
            create_radiance_srf(roof, "roof"+str(bcnt)+str(rcnt), "roof" + str(ageometry_table['type_roof'][bldg_name]), rad)
            
        bldg_dict["name"] = bldg_name
        bldg_dict["windows"] = window_list
        bldg_dict["walls"] = wall_list
        bldg_dict["roofs"] = roof_list
        bldg_dict["footprints"] = footprint_list
        bldg_dict_list.append(bldg_dict)
        
    return bldg_dict_list