コード例 #1
0
def intersection(begin1, end1, begin2, end2):
    """ Gives the intersection between two lines (not sections). """
    A1 = end1[1] - begin1[1]
    B1 = -end1[0] + begin1[0]
    C1 = begin1[1] * B1 + begin1[0] * A1
    A2 = end2[1] - begin2[1]
    B2 = -end2[0] + begin2[0]
    C2 = begin2[1] * B2 + begin2[0] * A2
    if A1 * B2 == A2 * B1:
        LOG.error("Can't intersect parallel lines")
        raise ValueError('Cannot be parallel.')
    x = (C1 * B2 - C2 * B1) / (A1 * B2 - A2 * B1)
    y = (C1 * A2 - C2 * A1) / (B1 * A2 - B2 * A1)
    return Coord(x, y)
コード例 #2
0
ファイル: filter.py プロジェクト: Joshua-Sexton/spira
 def __call__(self, item):
     LOG.debug("Applying all subfilters. Item = %s" % item)
     v = item
     for R in self._sub_filters:
         LOG.debug("** Applying subfilter %s to %s" % (R, v))
         v = R(v)
         LOG.debug("** Result after filtering = %s\n" % v)
     LOG.debug("Finished applying all subfilters. Item = %s" % item)        
     return v
コード例 #3
0
ファイル: virtual.py プロジェクト: Joshua-Sexton/spira
 def _map_derived_edges(self):
     mapping = {}
     for pl in RDD.get_physical_layers_by_purpose(purposes=['METAL']):
         key = pl.process.symbol
         if hasattr(RDD.PLAYER[key], 'EDGE_CONNECTED'):
             derived_layer = RDD.PLAYER[key].EDGE_CONNECTED
             ps_1 = derived_layer.layer1.process.symbol
             ps_2 = derived_layer.layer2.process.symbol
             if ps_1 == ps_2:
                 mapping[derived_layer] = RDD.PLAYER[
                     key].OUTSIDE_EDGE_DISABLED
             else:
                 es = "Error in RDD: Edge process \'{}\' not the same as metal process \'{}\'."
                 raise ValueError(es.format(ps_2, ps_1))
         else:
             LOG.warning(
                 'Edge detection for METAL layer {} ignored.'.format(key))
     return mapping
コード例 #4
0
ファイル: filter.py プロジェクト: Joshua-Sexton/spira
 def _filter(self, item):
     import inspect
     T = type(item)
     if inspect.isclass(T):
         for M in inspect.getmro(T):
             N = '__filter_{}__'.format(M.__name__)
             if hasattr(self, N):
                 LOG.debug("Applying method %s of %s to %s" %(N,self,item))
                 return getattr(self, N)(item)
         return self.__filter_default__(item)
     else:
         N = '__filter_{}'.format(T.__name__)
         if hasattr(self, N):
             expr = 'self.{}(item)'.format(N)
             LOG.debug('Executing {}'.format(expr))
             return eval(expr)
         else:
             return self.__filter_default__(item)
コード例 #5
0
ファイル: filter.py プロジェクト: Joshua-Sexton/spira
 def __call__(self, item):
     LOG.debug("Applying all subfilters. Item = %s" % item)
     v = item
     k = self._filter_status.keys()
     for R in self._sub_filters:
         if R.name not in k or self._filter_status[R.name]:
             LOG.debug("** Applying subfilter %s to %s"  % (R, v))
             v = R(v)
             LOG.debug("** Result after filtering = %s\n" % v)
     LOG.debug("Finished applying all subfilters. Item = %s" % item)        
     return v
コード例 #6
0
    def gdsii_output(self,
                     file_name=None,
                     unit=RDD.GDSII.UNIT,
                     grid=RDD.GDSII.GRID,
                     layer_map=None):
        library = Library(name=self.name, unit=unit, grid=grid)

        D = deepcopy(self)

        F = RDD.FILTERS.OUTPUT.PORTS

        library += F(D)

        if layer_map is None:
            layer_map = RDD.GDSII.EXPORT_LAYER_MAP

        output = OutputGdsii(file_name=file_name, layer_map=layer_map)
        output.write(library)

        LOG.debug("Finished writing structure to GDS2.")
コード例 #7
0
ファイル: empty_filter.py プロジェクト: rubenvanstaden/spira
 def filter_default(self, item):
     if hasattr(item, 'is_empty'):
         if item.is_empty():
             LOG.debug('Emptyfilter is filtering out : {}'.format(item))
             return []
     return [item]
コード例 #8
0
 def filter___LayerElement__(self, item):
     if item.layer in self.purposes:
         return [item]
     else:
         LOG.debug("LayerFilterAllow is filtering out item %s" % item)
         return []
コード例 #9
0
 def filter___LayerElement__(self, item):
     if item.layer in self.layers:
         LOG.debug("LayerFilterDelete is filtering out item %s" % item)
         return []
     else:
         return [item]