Skip to content

Commit

Permalink
Version 0.5.12
Browse files Browse the repository at this point in the history
* New parameter: relative_point_list for MAKE_COMPONENT function.
* New function: get_point_list() for customized components.
  • Loading branch information
Hideousmon committed Dec 5, 2024
1 parent 28984c2 commit 7eca779
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
6 changes: 5 additions & 1 deletion history.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,8 @@
### Version 0.5.11 (Nov 4, 2024)
* New functions: add_port, reset_ports_source and get_port_transmission for FDTDSimulation.
* Add precision parameter for inversion operations.
* New function: remove_other_cells for Cell.
* New function: remove_other_cells for Cell.

### Version 0.5.12 (Dec 5, 2024)
* New parameter: relative_point_list for MAKE_COMPONENT function.
* New function: get_point_list() for customized components.
2 changes: 1 addition & 1 deletion splayout/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.5.11"
__version__ = "0.5.12"

## Submodules
from . import utils
Expand Down
49 changes: 48 additions & 1 deletion splayout/components/selfdefinecomponent.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from ..utils.utils import *
import numpy as np

## global parameters
SelfDefineCount = -1
SelfDefineComponent_cell_list = []

def MAKE_COMPONENT(filename,rename=None,relative_start_point=Point(0,0),relative_end_point=None,relative_input_point=None,relative_through_point=None,relative_drop_point=None,relative_add_point=None,initial_relative_position = RIGHT):
def MAKE_COMPONENT(filename,rename=None,relative_start_point=Point(0,0), relative_point_list=None, relative_end_point=None,
relative_input_point=None,relative_through_point=None,relative_drop_point=None,
relative_add_point=None,initial_relative_position = RIGHT):
"""
Make an self-defined Class with another gdsii file.
Expand All @@ -16,6 +19,8 @@ def MAKE_COMPONENT(filename,rename=None,relative_start_point=Point(0,0),relative
Name of the cell (default: the filename).
relative_start_point : Point
The start point in the file that contains your component (can be missing).
relative_point_list : List of Point
List of points that contains your component (can be missing).
relative_end_point : Point
The end point in the file that contains your component (can be missing).
relative_input_point : Point
Expand Down Expand Up @@ -65,6 +70,22 @@ def MAKE_COMPONENT(filename,rename=None,relative_start_point=Point(0,0),relative
SelfDefineCount_local = SelfDefineCount

relative_start_point = tuple_to_point(relative_start_point)

if (type(relative_point_list) == np.ndarray):
relative_point_list = relative_point_list.tolist()
point_list = []
for item in relative_point_list:
if type(item) == Point:
point_list.append(item)
elif type(item) == tuple:
point_list.append(Point(item[0], item[1]))
elif type(item) == list:
point_list.append(Point(item[0], item[1]))
elif type(item) == np.ndarray:
point_list.append(Point(item[0], item[1]))
else:
raise Exception("relative_point_list wrong type input!")

relative_end_point = tuple_to_point(relative_end_point)
relative_input_point =tuple_to_point(relative_input_point)
relative_through_point =tuple_to_point(relative_through_point)
Expand Down Expand Up @@ -101,6 +122,26 @@ def __init__(self, start_point, relative_position=RIGHT):
raise Exception("Wrong relative position!")
else:
self.start_point_for_return = None
if not relative_point_list is None:
self.point_list_for_return = []
for item in point_list:
relative_point_transfer = item
if (self.rotate_radian == RIGHT):
point_for_return = self.start_point + relative_point_transfer
elif (self.rotate_radian == UP):
point_for_return = self.start_point + Point(-relative_point_transfer.y,
relative_point_transfer.x)
elif (self.rotate_radian == LEFT):
point_for_return = self.start_point + Point(-relative_point_transfer.x,
- relative_point_transfer.y)
elif (self.rotate_radian == DOWN):
point_for_return = self.start_point + Point(relative_point_transfer.y,
-relative_point_transfer.x)
else:
raise Exception("Wrong relative position!")
self.point_list_for_return.append(point_for_return)
else:
self.point_list_for_return = None
if (type(relative_end_point) != type(None)):
relative_end_point_transfer = relative_end_point
if (self.rotate_radian == RIGHT):
Expand Down Expand Up @@ -194,6 +235,12 @@ def draw(self,cell):
def get_start_point(self):
return self.start_point_for_return

def get_point_list(self):
if self.point_list_for_return is None:
raise Exception("You did not define a relative point list for your component!")
else:
return self.point_list_for_return

def get_end_point(self):
if (type(self.end_point_for_return) == type(None)):
raise Exception("You did not define a relative end point for your component!")
Expand Down

0 comments on commit 7eca779

Please sign in to comment.