def create_elements(self, elems): xpts = list(self.shape.x_coords) ypts = list(self.shape.y_coords) n = len(xpts) xpts.append(xpts[0]) ypts.append(ypts[0]) clockwise = 0 for i in range(0, n): clockwise += ((xpts[i + 1] - xpts[i]) * (ypts[i + 1] + ypts[i])) if self.layer.name == 'BBOX': bbox = True else: bbox = False for i in range(0, n): name = '{}_e{}'.format(self.layer.name, i) x = np.sign(clockwise) * (xpts[i + 1] - xpts[i]) y = np.sign(clockwise) * (ypts[i] - ypts[i + 1]) orientation = (np.arctan2(x, y) * constants.RAD2DEG) + 90 midpoint = [(xpts[i + 1] + xpts[i]) / 2, (ypts[i + 1] + ypts[i]) / 2] width = np.abs( np.sqrt((xpts[i + 1] - xpts[i])**2 + (ypts[i + 1] - ypts[i])**2)) layer = RDD.GDSII.IMPORT_LAYER_MAP[self.layer] extend = RDD[layer.process.symbol].MIN_SIZE T = Rotation(orientation) + Translation(midpoint) layer = PLayer(process=layer.process, purpose=RDD.PURPOSE.PORT.OUTSIDE_EDGE_DISABLED) shape = shapes.BoxShape(width=width, height=extend) # elems += EdgeSymmetric(width=width, extend=extend, process=layer.process, transformation=T) elems += Edge(shape=shape, layer=layer, width=width, extend=extend, transformation=T) return elems
def Box(layer, width=1, height=1, center=(0, 0), alias=None, transformation=None): """ Creates a box shape that can be used in GDSII format as a polygon object. Example ------- >>> p = spira.Box(p1=(0,0), p2=(10,0), layer=RDD.PLAYER.M6) >>> [SPiRA: Rectangle] () """ shape = shapes.BoxShape(width=width, height=height, center=center) return Polygon(alias=alias, shape=shape, layer=layer, transformation=transformation)
def create_elements(self, elems): shape = shapes.BoxShape(width=self.width, height=self.height) elems += spira.Polygon(shape=shape, layer=self.layer) return elems
def EdgeSymmetric(width=1, extend=1, process=None, transformation=None): """ """ layer = PLayer(process=process, purpose=RDD.PURPOSE.PORT.INSIDE_EDGE_DISABLED) shape = shapes.BoxShape(width=width, height=2*extend) return Edge(shape=shape, layer=layer, width=width, extend=2*extend, transformation=transformation)