def _get_free_paths(self, cutter, models, p1, p2): if self.physics: return get_free_paths_ode(self.physics, p1, p2, depth=self._physics_maxdepth) else: return get_free_paths_triangles(models, cutter, p1, p2)
def _process_one_line((p1, p2, depth, models, cutter, physics)): #prof = cProfile.Profile() #prof.enable() if physics: points = get_free_paths_ode(physics, p1, p2, depth=depth) else: #points = prof.runcall(get_free_paths_triangles, *(models, cutter, p1, p2)) points = get_free_paths_triangles(models, cutter, p1, p2) #prof.disable() #prof.print_stats(2) return points
def GenerateToolPathLinePush(self, pa, line, z, previous_z, draw_callback=None): if previous_z <= line.minz: # the line is completely above the previous level pass elif line.minz < z < line.maxz: # Split the line at the point at z level and do the calculation # for both point pairs. factor = (z - line.p1.z) / (line.p2.z - line.p1.z) plane_point = line.p1.add(line.vector.mul(factor)) self.GenerateToolPathLinePush(pa, Line(line.p1, plane_point), z, previous_z, draw_callback=draw_callback) self.GenerateToolPathLinePush(pa, Line(plane_point, line.p2), z, previous_z, draw_callback=draw_callback) elif line.minz < previous_z < line.maxz: plane = Plane(Point(0, 0, previous_z), Vector(0, 0, 1)) cp = plane.intersect_point(line.dir, line.p1)[0] # we can be sure that there is an intersection if line.p1.z > previous_z: p1, p2 = cp, line.p2 else: p1, p2 = line.p1, cp self.GenerateToolPathLinePush(pa, Line(p1, p2), z, previous_z, draw_callback=draw_callback) else: if line.maxz <= z: # the line is completely below z p1 = Point(line.p1.x, line.p1.y, z) p2 = Point(line.p2.x, line.p2.y, z) elif line.minz >= z: p1 = line.p1 p2 = line.p2 else: log.warn("Unexpected condition EC_GTPLP: %s / %s / %s / %s" % \ (line.p1, line.p2, z, previous_z)) return # no model -> no possible obstacles # model is completely below z (e.g. support bridges) -> no obstacles relevant_models = [m for m in self.models if m.maxz >= z] if not relevant_models: points = [p1, p2] elif self.physics: points = get_free_paths_ode(self.physics, p1, p2) else: points = get_free_paths_triangles(relevant_models, self.cutter, p1, p2) if points: for point in points: pa.append(point) if draw_callback: draw_callback(tool_position=points[-1], toolpath=pa.paths)
def _process_one_line((p1, p2, depth, models, cutter, physics)): if physics: points = get_free_paths_ode(physics, p1, p2, depth=depth) else: points = get_free_paths_triangles(models, cutter, p1, p2) return points