text
stringlengths
1
93.6k
# estimate radius for rolling ball
distances = pcd.compute_nearest_neighbor_distance()
avg_dist = np.mean(distances)
radius = 1.5 * avg_dist
mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(
pcd,
o3d.utility.DoubleVector([radius, radius * 2]))
# create the triangular mesh with the vertices and faces from open3d
tri_mesh = trimesh.Trimesh(np.asarray(mesh.vertices), np.asarray(mesh.triangles),
vertex_normals=np.asarray(mesh.vertex_normals))
trimesh.convex.is_convex(tri_mesh)
ply_path = os.path.join(data_dir, f'{scene}_mesh.ply')
trimesh.exchange.export.export_mesh(tri_mesh, ply_path)
if __name__ == '__main__':
globals()['run_' + args.type]()
# <FILESEP>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import time
import json
import fcntl
import signal
import argparse
try:
import tkinter
except ImportError:
import Tkinter as tkinter
import i3ipc
KEY_MAPPING = {
# i3-to-Tk key mapping
'Mod1': 'Alt_L',
'Mod4': 'Super_L',
'Control': 'Control_L',
'Shift': 'Shift_L',
}
class Workspace(object):
def __init__(self, id, name):
self.id = id
self.name = name
def __hash__(self):
return self.id
def __eq__(self, other):
return self.id == other.id
@classmethod
def from_container(cls, container):
return cls(id=container.id, name=container.name)
class HistoryJSONEncoder(json.JSONEncoder):
def default(self, obj):
return obj.name
class EventListener(object):
def __init__(self, i3, history_file_path, size=None, keep_empty=False):
i3.on('workspace', self.dispatch_event)
self.i3 = i3
self.history_file_path = history_file_path
self.size = size if isinstance(size, int) and size > 1 else None
self.keep_empty = keep_empty
self.history = []
def run(self):
try:
os.unlink(self.history_file_path)
except OSError:
pass
self.i3.main()
def run_forever(self):
while True:
try:
self.run()
except Exception:
time.sleep(1)
self.history = []
def write_history(self):
with open(self.history_file_path, 'w') as history_file_obj:
json.dump(self.history, history_file_obj, cls=HistoryJSONEncoder)