var size = bbox.getSize(new THREE.Vector3());
var length = (size.x + size.y + size.z) / 24;
+ if (length < 1) length = 1;
+
var material = new THREE.MeshPhongMaterial({
transparent: true,
opacity: 0.75,
var size = bbox.getSize(new THREE.Vector3());
var length = (size.x + size.y + size.z) / 3;
length /= 10;
+
+ if (length < 1) length = 1;
+
var radius = length / 20;
var group = new THREE.Group();
get_model_bounds: function () {
- var bbox = new THREE.Box3();
+ var bbox = new THREE.Box3(new THREE.Vector3(0, 0, 0),
+ new THREE.Vector3(0.00001, 0.00001, 0.00001));
function add(o) {
- if (typeof o != 'undefined') bbox.union(o.geometry.boundingBox);
+ if (typeof o != 'undefined') {
+ var oBBox = new THREE.Box3();
+ oBBox.setFromObject(o);
+ bbox.union(oBBox);
+ }
}
add(this.pathView);
elif isinstance(o, int): yield str(o)
elif isinstance(o, float):
- if o != o: yield 'NaN'
- elif o == float('inf'): yield 'Infinity'
- elif o == float('-inf'): yield '-Infinity'
+ if o != o: yield '"NaN"'
+ elif o == float('inf'): yield '"Infinity"'
+ elif o == float('-inf'): yield '"-Infinity"'
else: yield format(o, '.2f')
elif isinstance(o, (list, tuple)):
buf = f.read(1024 * 1024)
if not buf: break
h.update(buf)
+ time.sleep(0.001) # Yield some time
return h.hexdigest()
def invalidate(self, filename):
with self.lock:
if filename in self.plans:
+ self.plans[filename][0].cancel()
del self.plans[filename]
def invalidate_all(self):
- with self.lock: self.plans = {}
+ with self.lock:
+ for filename, plan in self.plans.items():
+ plan[0].cancel()
+ self.plans = {}
def delete_all_plans(self):
bounds = dict(min = {}, max = {})
messages = []
count = 0
- cancelled = False
# Initialized axis states and bounds
for axis in 'xyzabc':
bounds['min'][axis] = math.inf
bounds['max'][axis] = -math.inf
+
def add_to_bounds(axis, value):
if value < bounds['min'][axis]: bounds['min'][axis] = value
if bounds['max'][axis] < value: bounds['max'][axis] = value
if update_speed(s):
m = compute_move(startPos, unit, d)
- m['s'] = cur
- moves.append(m)
+ if cur is not None:
+ m['s'] = cur
+ moves.append(m)
move['s'] = s
moves.append(move)
elif cmd['type'] == 'dwell': totalTime += cmd['seconds']
if not self._progress(filename, maxLine / totalLines):
- cancelled = True
- raise Exception('Plan canceled.')
+ return # Plan cancelled
if self.max_preplan_time < time.time() - start:
raise Exception('Max planning time (%d sec) exceeded.' %
except Exception as e:
log_cb('error', str(e), filename, line, 0)
- self._progress(filename, 1)
+ if not self._progress(filename, 1): return # Cancelled
# Remove infinity from bounds
for axis in 'xyzabc':
meta_comp = gzip.compress(dump_json(meta).encode('utf8'))
# Save plan & meta data
- if not cancelled:
- with open(plan_path, 'wb') as f: f.write(data)
- with open(meta_path, 'wb') as f: f.write(meta_comp)
+ with open(plan_path, 'wb') as f: f.write(data)
+ with open(meta_path, 'wb') as f: f.write(meta_comp)
return (data, meta)