Datasets:
Download code/robohome/src/paper_eval/traversability/dump_walls.py from RoboParty/RoboHome: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/paper_eval/traversability/dump_walls.py
- Command line
-
hf download hf://datasets/RoboParty/RoboHome/code/robohome/src/paper_eval/traversability/dump_walls.py
-
curl -L -o dump_walls.py https://huggingface.co/datasets/RoboParty/RoboHome/resolve/main/code/robohome/src/paper_eval/traversability/dump_walls.py
1.48 kB
| import bpy, bmesh, json, sys | |
| args = sys.argv[sys.argv.index("--") + 1:]; scenes = json.load(open(args[0])); out = {} | |
| def label_of(o): | |
| cur = o | |
| while cur is not None: | |
| ks = cur.keys() | |
| if "structural_object_id" in ks: return "structure:" + str(cur["structural_object_id"]) | |
| if "portal_id" in ks: return "portal:" + str(cur["portal_id"]) | |
| cur = cur.parent | |
| return None | |
| for s in scenes: | |
| blend = [b for b in s["blends"] if "/generated/" in b][-1] | |
| bpy.ops.wm.open_mainfile(filepath=blend, load_ui=False) | |
| dg = bpy.context.evaluated_depsgraph_get(); segs = []; nw = 0 | |
| for o in bpy.context.scene.objects: | |
| if o.type != "MESH": continue | |
| lab = label_of(o) | |
| if not lab or not lab.startswith("structure:wall"): continue | |
| nw += 1; oe = o.evaluated_get(dg); me = oe.to_mesh() | |
| bm = bmesh.new(); bm.from_mesh(me); bm.transform(o.matrix_world) | |
| res = bmesh.ops.bisect_plane(bm, geom=bm.verts[:] + bm.edges[:] + bm.faces[:], plane_co=(0, 0, 0.5), plane_no=(0, 0, 1)) | |
| for e in res["geom_cut"]: | |
| if isinstance(e, bmesh.types.BMEdge): | |
| a, b = e.verts[0].co, e.verts[1].co; segs.append([[round(a.x, 4), round(a.y, 4)], [round(b.x, 4), round(b.y, 4)]]) | |
| bm.free(); oe.to_mesh_clear() | |
| out[s["seed"]] = {"blend": blend, "wall_objects": nw, "segments": segs} | |
| print("scene", s["seed"], "walls", nw, "cut segments", len(segs)) | |
| json.dump(out, open(args[1], "w")) | |