示例#1
0
    def get_elements_from_shape(self, shape, termination_offsets=[], **kwargs):
        elems = super(PathTraceWindow, self).get_elements_from_shape(
            shape, termination_offsets=termination_offsets, **kwargs)

        elems = i3.ElementList([
            i3.Path(layer=el.layer,
                    shape=el.centerline_shape,
                    line_width=el.path_line_width)
            if el.path_line_width == 0 else el for el in elems
        ])

        # print([(el.layer, getattr(el, 'line_width', None), type(el)) for el in elems])
        return elems
示例#2
0
 def _generate_elements(self, elems):
     elems = super(LinearWindowWaveguideTransition.Layout,
                   self)._generate_elements(elems)
     # shape_shift = ShapeOffset(original_shape=elems.shape, offset=self.offset)
     fbms_line = i3.ElementList()
     for el in elems:
         if el.layer == i3.TECH.PPLAYER.WG.CLADDING:
             el_shape = el.shape
             el_shape.open()
             fbms_line += [
                 i3.Path(layer=el.layer, shape=el_shape, line_width=0.0)
             ]
     return elems + fbms_line
示例#3
0
def merge_path(paths):

    ## firstly expand the transformation
    for path in paths:
        path.expand_transform()

    lines = []
    layer = i3.TECH.PPLAYER.NONE.DOC
    paths_in_loop = paths[:]

    for path0 in paths:
        if path0 not in paths_in_loop:
            pass

        else:

            finish_flag = 0
            line = path0.shape.points[:]
            rtol = 0
            atol = 2e-04

            while finish_flag == 0:
                finish_flag = 1
                for path in paths:
                    if path not in paths_in_loop:
                        pass

                    elif np.array_equal(line, path.shape.points[:]):
                        # np.array_equal(line, path.shape.points):
                        # print "enter1"
                        # print path
                        paths_in_loop.remove(path)
                        finish_flag = 0

                    elif np.allclose(line[-1],
                                     path.shape.points[0],
                                     atol=atol,
                                     rtol=rtol):
                        # print "enter3"
                        # print line
                        line = np.concatenate((line, path.shape.points[1:]))
                        # print path.shape.points
                        # print line
                        paths_in_loop.remove(path)
                        finish_flag = 0

                    elif np.allclose(line[0],
                                     path.shape.points[-1],
                                     atol=atol,
                                     rtol=rtol):
                        # print "enter2"
                        # print line
                        line = np.concatenate((path.shape.points[:-1], line))
                        # print path.shape.points
                        # print line
                        paths_in_loop.remove(path)
                        finish_flag = 0

                    elif np.allclose(line[0],
                                     path.shape.points[0],
                                     atol=atol,
                                     rtol=rtol):
                        # print "enter4"
                        line = line[::-1]
                        # print path.shape.points
                        # print line
                        line = np.concatenate((line, path.shape.points[1:]))
                        # print line
                        paths_in_loop.remove(path)
                        finish_flag = 0

                    elif np.allclose(line[-1],
                                     path.shape.points[-1],
                                     atol=atol,
                                     rtol=rtol):
                        # print "enter5"
                        line = line[::-1]
                        # print path.shape.points
                        # print line
                        line = np.concatenate((path.shape.points[:-1], line))
                        # print line
                        paths_in_loop.remove(path)
                        finish_flag = 0

                    else:
                        pass

            lines.append(line)

    merged_path = i3.ElementList()
    for l in lines:
        merged_path += [i3.Path(layer=layer, line_width=0, shape=l)]

    return merged_path