Пример #1
0
    def generate_border(self, fn):
        '''
        border of the entire device
        since the border is diagonal, it takes some computation ...
        also, in order to improve the cutting time, we need to modify the diagonals,
        so they are not emitted (fn) here.
        '''
        sample_vector = Vector(
            Point(self.bend_length_max, 0),
            Point(self.bend_length_max - self.bend_length_step,
                  self.distance_between_bends))
        left_m = sample_vector.m
        height = (
            self.bend_count - 1
        ) * self.distance_between_bends + self.margin_top + self.margin_bottom
        left_b = height
        left_vector = Vector(Point(0, height), Point((0 - left_b) / left_m, 0))

        # find the ending point of the right side of the first bend
        first_bend_y = self.get_bend_y(0)
        first_bend_start_x = left_vector.x_for_y(first_bend_y)
        first_bend_ending_x = first_bend_start_x + (
            self.margin_sides +
            self.bend_length_min) * 2 + self.resistor_length

        # find the ending point of the right side of the second bend
        next_bend_y = self.get_bend_y(1)
        next_bend_start_x = left_vector.x_for_y(next_bend_y)
        next_bend_ending_x = next_bend_start_x + (
            self.margin_sides + self.bend_length_min +
            self.bend_length_step) * 2 + self.resistor_length

        # now create the vector to calculate the formula
        refv = Vector(Point(first_bend_ending_x, first_bend_y),
                      (Point(next_bend_ending_x, next_bend_y)))
        right_vector = Vector(refv.point_for_y(height), refv.point_for_y(0))

        # upper border
        v = Vector(left_vector.point_for_y(0), right_vector.point_for_y(0))
        fn(v)
        v = Vector(left_vector.point_for_y(height),
                   right_vector.point_for_y(height))
        fn(v)

        self.dim = Point(right_vector.x_for_y(height), height)
        self.left_vector = left_vector
        self.right_vector = right_vector
Пример #2
0
    def generate_border(self, fn):
        '''
        border of the entire device
        since the border is diagonal, it takes some computation ...
        also, in order to improve the cutting time, we need to modify the diagonals,
        so they are not emitted (fn) here.
        '''
        sample_vector = Vector(Point(self.bend_length_max, 0), Point(self.bend_length_max - self.bend_length_step, self.distance_between_bends))
        left_m = sample_vector.m
        height = (self.bend_count - 1) * self.distance_between_bends + self.margin_top + self.margin_bottom
        left_b = height
        left_vector = Vector(Point(0, height), Point((0 - left_b) / left_m, 0))

        # find the ending point of the right side of the first bend
        first_bend_y = self.get_bend_y(0)
        first_bend_start_x = left_vector.x_for_y(first_bend_y)
        first_bend_ending_x = first_bend_start_x + (self.margin_sides + self.bend_length_min) * 2 + self.resistor_length

        # find the ending point of the right side of the second bend
        next_bend_y = self.get_bend_y(1)
        next_bend_start_x = left_vector.x_for_y(next_bend_y)
        next_bend_ending_x = next_bend_start_x + (self.margin_sides + self.bend_length_min + self.bend_length_step) * 2 + self.resistor_length

        # now create the vector to calculate the formula
        refv = Vector(Point(first_bend_ending_x, first_bend_y), (Point(next_bend_ending_x, next_bend_y)))
        right_vector = Vector(refv.point_for_y(height), refv.point_for_y(0))

        # upper border
        v = Vector(left_vector.point_for_y(0), right_vector.point_for_y(0))
        fn(v)
        v = Vector(left_vector.point_for_y(height), right_vector.point_for_y(height))
        fn(v)

        self.dim = Point(right_vector.x_for_y(height), height)
        self.left_vector = left_vector
        self.right_vector = right_vector