예제 #1
0
    def stretch_p2c(self, port_name, destination_coord):
        """
        Stretch port to port. Stretch the polygon by moving
        the polygon edge port to the destination port location.

        Note
        ----
        The opposite port position is used as the stretching center.
        This overcomes the issue of distorting the entiry structure.

        Example
        -------
        >>> S.stretch_p2p(port_name='S1:Sr1:E3_R1', destination_coord=(10,0))
        """
        from spira.yevon.gdsii.polygon import Polygon
        from spira.yevon.geometry.bbox_info import bbox_info_opposite_boundary_port
        D = self.expand_flat_copy()

        port = D.ports[port_name]
        destination = D.ports[destination_name]

        for i, e in enumerate(D.reference.elements.polygons):
            if e.id_string() == port.local_pid:
                opposite_port = bbox_info_opposite_boundary_port(e, port)
                T = stretching.stretch_element_by_port(self, opposite_port,
                                                       port, destination)
                T.apply(D.reference.elements[i])
예제 #2
0
 def stretch_port(self, port, destination):
     """ The element by moving the subject port, without 
     distorting the entire element. Note: The opposite 
     port position is used as the stretching center. """
     opposite_port = bbox_info.bbox_info_opposite_boundary_port(self, port)
     T = stretching.stretch_element_by_port(self, opposite_port, port,
                                            destination)
     T.apply(self)
     return self
예제 #3
0
 def stretch_p2p(self, port, destination):
     """
     The element by moving the subject port, without
     distorting the entire element. Note: The opposite
     port position is used as the stretching center.
     """
     from spira.core.transforms import stretching
     from spira.yevon.geometry import bbox_info
     from spira.yevon.gdsii.polygon import Polygon
     opposite_port = bbox_info.bbox_info_opposite_boundary_port(self, port)
     T = stretching.stretch_element_by_port(self, opposite_port, port,
                                            destination)
     if port.bbox is True:
         self = T(self)
     else:
         for i, e in enumerate(self.elements):
             if isinstance(e, Polygon):
                 if e.id_string() == port.local_pid:
                     self.elements[i] = T(e)
     return self
예제 #4
0
    def stretch_p2p(self, port_name, destination_name):
        """
        Stretch port to port. Stretch the polygon by moving
        the polygon edge port to the destination port location.

        Note
        ----
        The opposite port position is used as the stretching center.
        This overcomes the issue of distorting the entiry structure.

        Example
        -------
        >>> S.stretch_p2p(port_name='S1:Sr1:E3_R1', destination_name='S2:Sr2:E1_R1')
        """
        from spira.yevon.gdsii.polygon import Polygon
        from spira.yevon.geometry.ports import PortList
        from spira.yevon.geometry.bbox_info import bbox_info_opposite_boundary_port

        D = self.expand_flat_copy()

        # print(D.ports)
        # print('\n------------------\n')

        # print('\n*************************************')
        ports = PortList()
        for e in D.reference.elements.polygons:
            # print(e.edge_ports)
            ports += e.edge_ports

        port = ports[port_name]
        destination = ports[destination_name]

        # print(port)
        # print(destination)

        for i, e in enumerate(D.reference.elements.polygons):
            if e.id_string() == port.local_pid:
                opposite_port = bbox_info_opposite_boundary_port(e, port)
                T = stretching.stretch_element_by_port(self, opposite_port,
                                                       port, destination)
                T.apply(D.reference.elements[i])