Example #1
0
def _get_tikz_pane_tree(tree_sample):
    """
    @return: a tikz text string
    """
    min_gridsize = 0.001
    strokes = _get_scene(tree_sample)
    # rotate every control point in every bchunk in each curve
    for stroke in strokes:
        stroke.transform(interlacesample.rotate_to_view)
    # get the intersection times
    time_lists = bezintersect.get_intersection_times(strokes, project_to_2d, min_gridsize, 3 * min_gridsize)
    # shatter the strokes, tracking the times of interest and the styles
    shattered_strokes = []
    for time_list, stroke in zip(time_lists, strokes):
        shattered_strokes.extend(stroke.shatter(time_list))
    depth_stroke_pairs = []
    for stroke in shattered_strokes:
        x, y, z = stroke.evaluate(stroke.characteristic_time)
        depth_stroke_pairs.append((x, stroke))
    ordered_strokes = [s for d, s in sorted(depth_stroke_pairs)]
    # draw the depth sorted strokes and patches
    arr = []
    for stroke in ordered_strokes:
        line = "\\draw[%s]" % stroke.style
        arr.append(line)
        arr.append(get_tikz_bezier(stroke))
    return "\n".join(arr)
Example #2
0
def _get_tikz_pane_tree(tree_sample):
    """
    @return: a tikz text string
    """
    min_gridsize = 0.001
    strokes = _get_scene(tree_sample)
    # rotate every control point in every bchunk in each curve
    for stroke in strokes:
        stroke.transform(interlacesample.rotate_to_view)
    # get the intersection times
    time_lists = bezintersect.get_intersection_times(strokes, project_to_2d,
                                                     min_gridsize,
                                                     3 * min_gridsize)
    # shatter the strokes, tracking the times of interest and the styles
    shattered_strokes = []
    for time_list, stroke in zip(time_lists, strokes):
        shattered_strokes.extend(stroke.shatter(time_list))
    depth_stroke_pairs = []
    for stroke in shattered_strokes:
        x, y, z = stroke.evaluate(stroke.characteristic_time)
        depth_stroke_pairs.append((x, stroke))
    ordered_strokes = [s for d, s in sorted(depth_stroke_pairs)]
    # draw the depth sorted strokes and patches
    arr = []
    for stroke in ordered_strokes:
        line = '\\draw[%s]' % stroke.style
        arr.append(line)
        arr.append(get_tikz_bezier(stroke))
    return '\n'.join(arr)
Example #3
0
def get_tikz_pane(sample):
    """
    At this point the tikz styles main-style and axis-style have been defined.
    @param sample: an interlacesample.Sample object
    @return: a tikz text string
    """
    min_gridsize = 0.001
    strokes = get_scene(sample)
    # rotate every control point in every bchunk in each curve
    for stroke in strokes:
        stroke.transform(rotate_to_view)
    # get the intersection times
    time_lists = bezintersect.get_intersection_times(strokes, project_to_2d, min_gridsize, 3 * min_gridsize)
    # shatter the strokes, tracking the times of interest and the styles
    shattered_strokes = []
    for time_list, stroke in zip(time_lists, strokes):
        shattered_strokes.extend(stroke.shatter(time_list))
    depth_stroke_pairs = []
    for stroke in shattered_strokes:
        x, y, z = stroke.evaluate(stroke.characteristic_time)
        depth_stroke_pairs.append((x, stroke))
    ordered_strokes = [s for d, s in sorted(depth_stroke_pairs)]
    # get the patches, tracking the times of interest and the styles
    patches = []
    for time_list, stroke in zip(time_lists, strokes):
        for patch in stroke.get_patches(time_list):
            if stroke.style == STYLE_MAIN:
                patch.style = STYLE_MAIN_PATCH
            elif stroke.style == STYLE_AXIS:
                patch.style = STYLE_AXIS_PATCH
            patches.append(patch)
    depth_patch_pairs = []
    for patch in patches:
        x, y, z = patch.evaluate(patch.characteristic_time)
        depth_patch_pairs.append((x, patch))
    ordered_patches = [s for d, s in sorted(depth_patch_pairs)]
    # draw the depth sorted strokes and patches
    arr = []
    for stroke in ordered_strokes + ordered_patches:
        # draw a linear curve or a bezier curve
        if len(stroke.bchunks) == 1 and stroke.bchunks[0].is_almost_linear():
            p0 = stroke.bchunks[0].p0
            p3 = stroke.bchunks[0].p3
            line = "\\draw[%s] %s -- %s;" % (
                stroke.style,
                tikz.point_to_tikz(stroke.bchunks[0].p0[1:]),
                tikz.point_to_tikz(stroke.bchunks[0].p3[1:]),
            )
            arr.append(line)
        else:
            line = "\\draw[%s]" % stroke.style
            arr.append(line)
            arr.append(get_tikz_bezier(stroke))
    return "\n".join(arr)
Example #4
0
def get_tikz_pane(sample):
    """
    At this point the tikz styles main-style and axis-style have been defined.
    @param sample: an interlacesample.Sample object
    @return: a tikz text string
    """
    min_gridsize = 0.001
    strokes = get_scene(sample)
    # rotate every control point in every bchunk in each curve
    for stroke in strokes:
        stroke.transform(rotate_to_view)
    # get the intersection times
    time_lists = bezintersect.get_intersection_times(strokes, project_to_2d,
                                                     min_gridsize,
                                                     3 * min_gridsize)
    # shatter the strokes, tracking the times of interest and the styles
    shattered_strokes = []
    for time_list, stroke in zip(time_lists, strokes):
        shattered_strokes.extend(stroke.shatter(time_list))
    depth_stroke_pairs = []
    for stroke in shattered_strokes:
        x, y, z = stroke.evaluate(stroke.characteristic_time)
        depth_stroke_pairs.append((x, stroke))
    ordered_strokes = [s for d, s in sorted(depth_stroke_pairs)]
    # get the patches, tracking the times of interest and the styles
    patches = []
    for time_list, stroke in zip(time_lists, strokes):
        for patch in stroke.get_patches(time_list):
            if stroke.style == STYLE_MAIN:
                patch.style = STYLE_MAIN_PATCH
            elif stroke.style == STYLE_AXIS:
                patch.style = STYLE_AXIS_PATCH
            patches.append(patch)
    depth_patch_pairs = []
    for patch in patches:
        x, y, z = patch.evaluate(patch.characteristic_time)
        depth_patch_pairs.append((x, patch))
    ordered_patches = [s for d, s in sorted(depth_patch_pairs)]
    # draw the depth sorted strokes and patches
    arr = []
    for stroke in ordered_strokes + ordered_patches:
        # draw a linear curve or a bezier curve
        if len(stroke.bchunks) == 1 and stroke.bchunks[0].is_almost_linear():
            p0 = stroke.bchunks[0].p0
            p3 = stroke.bchunks[0].p3
            line = '\\draw[%s] %s -- %s;' % (
                stroke.style, tikz.point_to_tikz(stroke.bchunks[0].p0[1:]),
                tikz.point_to_tikz(stroke.bchunks[0].p3[1:]))
            arr.append(line)
        else:
            line = '\\draw[%s]' % stroke.style
            arr.append(line)
            arr.append(get_tikz_bezier(stroke))
    return '\n'.join(arr)
Example #5
0
def get_tikz_lines(fs):
    """
    @param fs: user input
    @return: a sequence of tikz lines
    """
    lines = []
    min_gridsize = 0.001
    half_axis_radii = (
            fs.x_rad_pos, fs.x_rad_neg,
            fs.y_rad_pos, fs.y_rad_neg,
            fs.z_rad_pos, fs.z_rad_neg)
    strokes = get_scene(
            fs.root_a, fs.root_b, fs.root_c,
            fs.initial_t, fs.final_t,
            fs.circle_radius, half_axis_radii)
    # rotate every control point in every bchunk in each curve
    for stroke in strokes:
        stroke.transform(rotate_to_view)
    # get the intersection times
    time_lists = bezintersect.get_intersection_times(
            strokes, project_to_2d, min_gridsize, 3*min_gridsize)
    # shatter the strokes, tracking the times of interest and the styles
    shattered_strokes = []
    for time_list, stroke in zip(time_lists, strokes):
        shattered_strokes.extend(stroke.shatter(time_list))
    # sort the strokes according to depth order
    depth_stroke_pairs = []
    for stroke in shattered_strokes:
        x, y, z = stroke.evaluate(stroke.characteristic_time)
        depth_stroke_pairs.append((x, stroke))
    # draw the curves
    for x, stroke in sorted(depth_stroke_pairs):
        # draw a linear curve or a bezier curve
        c = g_style_colors[stroke.style]
        if len(stroke.bchunks)==1 and stroke.bchunks[0].is_almost_linear():
            p0 = stroke.bchunks[0].p0
            p3 = stroke.bchunks[0].p3
            line = '\\draw[draw=white,double=%s,thick] %s -- %s;' % (
                    c,
                    tikz.point_to_tikz(stroke.bchunks[0].p0[1:]),
                    tikz.point_to_tikz(stroke.bchunks[0].p3[1:]))
            lines.append(line)
        else:
            line = '\\draw[draw=white,double=%s,thick]' % c
            lines.append(line)
            lines.append(get_tikz_bezier(stroke))
    return lines
Example #6
0
def get_tikz_lines(fs):
    """
    @param fs: user input
    @return: a sequence of tikz lines
    """
    lines = []
    min_gridsize = 0.001
    half_axis_radii = (fs.x_rad_pos, fs.x_rad_neg, fs.y_rad_pos, fs.y_rad_neg,
                       fs.z_rad_pos, fs.z_rad_neg)
    strokes = get_scene(fs.root_a, fs.root_b, fs.root_c, fs.initial_t,
                        fs.final_t, fs.circle_radius, half_axis_radii)
    # rotate every control point in every bchunk in each curve
    for stroke in strokes:
        stroke.transform(rotate_to_view)
    # get the intersection times
    time_lists = bezintersect.get_intersection_times(strokes, project_to_2d,
                                                     min_gridsize,
                                                     3 * min_gridsize)
    # shatter the strokes, tracking the times of interest and the styles
    shattered_strokes = []
    for time_list, stroke in zip(time_lists, strokes):
        shattered_strokes.extend(stroke.shatter(time_list))
    # sort the strokes according to depth order
    depth_stroke_pairs = []
    for stroke in shattered_strokes:
        x, y, z = stroke.evaluate(stroke.characteristic_time)
        depth_stroke_pairs.append((x, stroke))
    # draw the curves
    for x, stroke in sorted(depth_stroke_pairs):
        # draw a linear curve or a bezier curve
        c = g_style_colors[stroke.style]
        if len(stroke.bchunks) == 1 and stroke.bchunks[0].is_almost_linear():
            p0 = stroke.bchunks[0].p0
            p3 = stroke.bchunks[0].p3
            line = '\\draw[draw=white,double=%s,thick] %s -- %s;' % (
                c, tikz.point_to_tikz(stroke.bchunks[0].p0[1:]),
                tikz.point_to_tikz(stroke.bchunks[0].p3[1:]))
            lines.append(line)
        else:
            line = '\\draw[draw=white,double=%s,thick]' % c
            lines.append(line)
            lines.append(get_tikz_bezier(stroke))
    return lines