예제 #1
0
 def _create_arrow(self, item):
     layer = PLayer(item.process, RDD.PURPOSE.PORT.DIRECTION)
     w = 0.05
     l = 0.6
     arrow_shape = shapes.ArrowShape(width=w, length=l, head=l * 0.2)
     p = Polygon(shape=arrow_shape, layer=layer)
     T = transformation_from_vector(item)
     p.transform(T)
     return p
예제 #2
0
 def create_block_elements(self, elems):
     for e in self.elements.sref:
         for layer in RDD.get_physical_layers_by_purpose(purposes=['METAL', 'GND']):
             if e.reference.is_layer_in_cell(layer):
                 bbox_shape = e.bbox_info.bounding_box()
                 elems += Polygon(shape=bbox_shape, layer=layer)
     return elems
예제 #3
0
 def intersection(self, other):
     from copy import deepcopy
     s1 = self.shape.transform_copy(self.transformation)
     s2 = other.shape.transform_copy(other.transformation)
     shapes = s1.__and__(s2)
     elems = [Polygon(shape=s, layer=self.layer) for s in shapes]
     return elems
예제 #4
0
    def __and__(self, other):
        el = ElementList()
        for e1 in self.elements:
            for e2 in other.elements:
                # e1 = deepcopy(e1)
                # e2 = deepcopy(e2)
                # shape1 = e1.shape.transform_copy(e1.transformation)
                # shape2 = e2.shape.transform_copy(e2.transformation)
                shape1 = deepcopy(e1.shape).transform(e1.transformation)
                shape2 = deepcopy(e2.shape).transform(e2.transformation)
                # if shape1 != shape2:
                # if e1.shape != e2.shape:
                # if (e1.shape != e2.shape) and (e1.layer == e2.layer):
                # if (e1.shape != e2.shape) and (e1.layer.process == e2.layer.process):
                if (shape1 != shape2) and (e1.layer.process
                                           == e2.layer.process):
                    shapes = shape1 & shape2
                    # print(shape1.points)
                    # print(shape2.points)
                    # print(shapes)
                    # print('')
                    for shape in shapes:
                        el += Polygon(shape=shape, layer=e1.layer)

                    # polygons = e1.intersection(e2)
                    # for p in polygons:
                    #     p.layer.purpose = RDD.PURPOSE.INTERSECTED
                    # for p in polygons:
                    #     el += p
        self.elements = el
        return self
예제 #5
0
 def __or__(self, other):
     if self.layer == other.layer:
         s1 = self.shape.transform_copy(self.transformation)
         s2 = other.shape.transform_copy(other.transformation)
         shapes = s1.__or__(s2)
         elems = [Polygon(shape=s, layer=self.layer) for s in shapes]
         return elems
     return ElementList([self, other])
예제 #6
0
def bbox_info_cell(elem):
    from spira.yevon.gdsii.cell import Cell
    from spira.yevon.gdsii.polygon import Polygon
    bbox_shape = elem.bbox_info.bounding_box()
    bbox_ply = Polygon(shape=bbox_shape)
    D = Cell(name='BBoxCell')
    D += bbox_ply
    return D
예제 #7
0
def reference_metal_blocks(S):
    from copy import deepcopy
    elems = ElementList()
    for layer in RDD.get_physical_layers_by_purpose(purposes=['METAL', 'GND']):
        layer = deepcopy(layer)
        if S.reference.is_layer_in_cell(layer):
            bbox_shape = S.bbox_info.bounding_box()
            layer.purpose = RDD.PURPOSE.BOUNDARY_BOX
            elems += Polygon(shape=bbox_shape, layer=layer)
    return elems
예제 #8
0
def load_aspect():
    """ Mix the aspects into their corresponding classes. """

    Shape.mixin(ShapeClipperAspects)

    Polygon.mixin(PolygonAspects)
    Polygon.mixin(NetlistAspects)
    Polygon.mixin(PolygonPortAspects)
    Polygon.mixin(PolygonClipperAspects)
    Polygon.mixin(OutputPlotlyNetlist)

    SRef.mixin(SRefPortAspects)
    SRef.mixin(NetlistAspects)

    Cell.mixin(CellAspects)
    Cell.mixin(CellPortAspects)
    Cell.mixin(NetlistAspects)
    Cell.mixin(Transformable)
    Cell.mixin(OutputGdsiiAspect)
    Cell.mixin(OutputPlotlyNetlist)
예제 #9
0
 def union(self):
     elems = ElementList()
     if len(self.elements) > 1:
         points = []
         for e in self.elements:
             shape = e.shape.transform(e.transformation).snap_to_grid()
             points.append(shape.points)
         merged_points = clipping.boolean(subj=points, clip_type='or')
         for uid, pts in enumerate(merged_points):
             elems += Polygon(shape=pts, layer=self.layer)
     else:
         elems = self.elements
     self.elements = elems
     return self
예제 #10
0
def get_derived_elements(elements, mapping, store_as_edge=False):
    """ Given a list of elements and a list of tuples (DerivedLayer, PPLayer),
    create new elements according to the boolean operations of the DerivedLayer
    and place these elements on the specified PPLayer. """

    derived_layers = mapping.keys()
    export_layers = mapping.values()
    elems = ElementList()
    for derived_layer, export_layer in zip(derived_layers, export_layers):
        pg = _derived_elements(elems=elements, derived_layer=derived_layer)
        for p in pg.elements:
            if store_as_edge is True:
                elems += Edge(shape=p.shape, layer=deepcopy(export_layer))
            else:
                elems += Polygon(shape=p.shape, layer=deepcopy(export_layer))
    return elems
예제 #11
0
    def __xor__(self, other):
        pts1, pts2 = [], []

        for e in self.elements:
            s1 = e.shape.transform_copy(e.transformation)
            pts1.append(s1.points)
        for e in other.elements:
            s1 = e.shape.transform_copy(e.transformation)
            pts2.append(s1.points)

        self.elements = ElementList()
        if (len(pts1) > 0) and (len(pts2) > 0):
            p1 = gdspy.PolygonSet(polygons=pts1)
            p2 = gdspy.PolygonSet(polygons=pts2)
            ply = gdspy.boolean(p1, p2, operation='not')
            for points in ply.polygons:
                self.elements += Polygon(shape=points, layer=self.layer)

        return self
예제 #12
0
    def __and__(self, other):
        el = ElementList()
        for e1 in self.elements:
            for e2 in other.elements:
                shape1 = e1.shape.transform_copy(e1.transformation)
                shape2 = e2.shape.transform_copy(e2.transformation)

                # if (shape1 != shape2) and (e1.layer.process == e2.layer.process):
                #     shapes = shape1 & shape2
                #     for shape in shapes:
                #         el += Polygon(shape=shape, layer=e1.layer)
                
                # # FIXME: We need this for virtual contact connections.
                # if shape1 != shape2:
                #     shapes = shape1 & shape2
                #     for shape in shapes:
                #         el += Polygon(shape=shape, layer=e1.layer)

                shapes = shape1 & shape2
                for shape in shapes:
                    el += Polygon(shape=shape, layer=e1.layer)

        self.elements = el
        return self
예제 #13
0
def generate_edges(shape, layer, internal_pid, transformation):
    """ Method call for edge generator. """
    edge_gen = EdgeGenerator(shape=shape,
                             layer=layer,
                             internal_pid=internal_pid,
                             transformation=transformation)
    return edge_gen.elements


from spira.yevon.aspects.base import __Aspects__
from spira.core.parameters.descriptor import Parameter


class EdgeAspects(__Aspects__):

    edges = Parameter(fdef_name='create_edges')

    def create_edges(self):
        """ Generate default edges for this polygon.
        These edges can be transformed using adapters. """
        from spira.yevon.geometry.edges.edges import generate_edges
        return generate_edges(shape=self.shape,
                              layer=self.layer,
                              internal_pid=self.id_string(),
                              transformation=self.transformation)


from spira.yevon.gdsii.polygon import Polygon
Polygon.mixin(EdgeAspects)
예제 #14
0
 def filter_Route(self, item):
     edge_ply = Polygon(shape=item.shape,
                        layer=item.layer,
                        transformation=item.transformation)
     return edge_ply