def extension_point_test(self): A = Point3D(Ax, 0, 0) B = Point3D(Bx, 10, 10) signature = [ Edge3D(Point3D(0, 10, 10), Point3D(10, 10, 10)), Edge3D(Point3D(5, 10, 20), Point3D(5, 20, 20)), Edge3D(Point3D(10, 20, 25), Point3D(10, 20, 35)) ] s = Segment(A, B) path_segs = [s] path_pts = [A, B] e1 = signature[0] for e2 in signature[1:]: ext_point = compute_extension_point(s, e1, e2.asLineAxis3D()) if not ext_point: print "failed to compute ext point at", s, e1, e2 break s = Segment(B, ext_point) B = ext_point path_pts.append(s.b) path_segs.append(s) self.data.append((util.flat_segments(path_segs), GL_LINES, 1, 1, 0)) self.data.append((util.flat_points(path_pts), GL_POINTS, 1, 1, 1)) # self.data.append((util.flat_points((A,B)), GL_POINTS, 1, 1, 1)) self.data.append((util.flat_segments(signature), GL_LINES, 1, 0, 0))
def make_interval_3D(self, p_min, p_max, step, interval3D=None): self.interval3D = gen.generate_interval3D(p_min, p_max, step, self.degenerate) \ if not interval3D else interval3D #self.data = [(util.flat_segments(self.interval3D.segments), GL_LINES, 1, 1, 1)] typed_edges = { Edge3D.CONVEX: [], Edge3D.CONCAVE1: [], Edge3D.CONCAVE2: [] } for s in self.interval3D.segments: typed_edges[s.type].append(s) # concave_edges = typed_edges[Edge3D.CONCAVE2]+typed_edges[Edge3D.CONCAVE1] # concave_edges = sorted(concave_edges, cmp=Edge3D.same_coordinates) # g = 0 # for e in concave_edges: # g += 1.0 / len(concave_edges) # self.data.append(([e.a.get(),e.b.get()], GL_LINES, 1, g, 0)) self.data.append((util.flat_segments(typed_edges[Edge3D.CONVEX] ), GL_LINES, 1, 1, 1)) self.data.append((util.flat_segments(typed_edges[Edge3D.CONCAVE1]), GL_LINES, 1, 1, 0)) self.data.append((util.flat_segments(typed_edges[Edge3D.CONCAVE2]), GL_LINES, 1, 0, 1)) # self.data.append((util.flat_points((p_min,p_max)), GL_POINTS, 1, 0, 0)) #path_points = shortest_path_from_signature(p_min, p_max, typed_edges[Edge3D.CONCAVE2]+typed_edges[Edge3D.CONCAVE1]) #self.data.append((util.flat_points(path_points), GL_LINE_STRIP, 1, 0, 0)) # interval2Ds (projections of Interval3D) self.int2Ds = [self.interval3D.int_xy, self.interval3D.int_zx, self.interval3D.int_yz] for i in xrange(len(self.int2Ds)): self.int2Ds[i] = (util.flat_points(self.int2Ds[i].points), GL_LINE_LOOP, 1, 0, 0)