repetition related fixup
This commit is contained in:
parent
bab40474a0
commit
794ebb6b37
11 changed files with 112 additions and 68 deletions
|
|
@ -299,14 +299,14 @@ def _subpatterns_to_refs(block: Union[ezdxf.layouts.BlockLayout, ezdxf.layouts.M
|
|||
rotated_a = rotation_matrix_2d(-subpat.rotation) @ a
|
||||
rotated_b = rotation_matrix_2d(-subpat.rotation) @ b
|
||||
if rotated_a[1] == 0 and rotated_b[0] == 0:
|
||||
attribs['column_count'] = subpat.a_count
|
||||
attribs['row_count'] = subpat.b_count
|
||||
attribs['column_count'] = rep.a_count
|
||||
attribs['row_count'] = rep.b_count
|
||||
attribs['column_spacing'] = rotated_a[0]
|
||||
attribs['row_spacing'] = rotated_b[1]
|
||||
block.add_blockref(encoded_name, subpat.offset, dxfattribs=attribs)
|
||||
elif rotated_a[0] == 0 and rotated_b[1] == 0:
|
||||
attribs['column_count'] = subpat.b_count
|
||||
attribs['row_count'] = subpat.a_count
|
||||
attribs['column_count'] = rep.b_count
|
||||
attribs['row_count'] = rep.a_count
|
||||
attribs['column_spacing'] = rotated_b[0]
|
||||
attribs['row_spacing'] = rotated_a[1]
|
||||
block.add_blockref(encoded_name, subpat.offset, dxfattribs=attribs)
|
||||
|
|
|
|||
|
|
@ -365,8 +365,8 @@ def _ref_to_subpat(element: Union[gdsii.elements.SRef,
|
|||
if isinstance(element, gdsii.elements.ARef):
|
||||
a_count = element.cols
|
||||
b_count = element.rows
|
||||
a_vector = (element.xy[1] - offset) / counts[0]
|
||||
b_vector = (element.xy[2] - offset) / counts[1]
|
||||
a_vector = (element.xy[1] - offset) / a_count
|
||||
b_vector = (element.xy[2] - offset) / b_count
|
||||
repetition = Grid(a_vector=a_vector, b_vector=b_vector,
|
||||
a_count=a_count, b_count=b_count)
|
||||
|
||||
|
|
@ -389,9 +389,10 @@ def _subpatterns_to_refs(subpatterns: List[SubPattern]
|
|||
|
||||
# Note: GDS mirrors first and rotates second
|
||||
mirror_across_x, extra_angle = normalize_mirror(subpat.mirrored)
|
||||
ref: Union[gdsii.elements.SRef, gdsii.elements.ARef]
|
||||
|
||||
rep = subpat.repetition
|
||||
|
||||
new_refs: List[Union[gdsii.elements.SRef, gdsii.elements.ARef]]
|
||||
ref: Union[gdsii.elements.SRef, gdsii.elements.ARef]
|
||||
if isinstance(rep, Grid):
|
||||
xy = numpy.array(subpat.offset) + [
|
||||
[0, 0],
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ def _placement_to_subpat(placement: fatrec.Placement) -> SubPattern:
|
|||
'identifier': (name,),
|
||||
}
|
||||
|
||||
mrep: Repetition
|
||||
mrep: Optional[Repetition]
|
||||
rep = placement.repetition
|
||||
if isinstance(rep, fatamorgana.GridRepetition):
|
||||
mrep = Grid(a_vector=rep.a_vector,
|
||||
|
|
@ -477,8 +477,10 @@ def _placement_to_subpat(placement: fatrec.Placement) -> SubPattern:
|
|||
a_count=rep.a_count,
|
||||
b_count=rep.b_count)
|
||||
elif isinstance(rep, fatamorgana.ArbitraryRepetition):
|
||||
mrep = Arbitrary(numpy.cumsum(numpy.column_stack((rep.x_displacements,
|
||||
rep.y_displacements))))
|
||||
displacements = numpy.cumsum(numpy.column_stack((rep.x_displacements,
|
||||
rep.y_displacements)))
|
||||
displacements = numpy.vstack(([0, 0], displacements))
|
||||
mrep = Arbitrary(displacements)
|
||||
elif rep is None:
|
||||
mrep = None
|
||||
|
||||
|
|
@ -510,8 +512,10 @@ def _subpatterns_to_refs(subpatterns: List[SubPattern]
|
|||
b_count=numpy.round(rep.b_count).astype(int))
|
||||
elif isinstance(rep, Arbitrary):
|
||||
diffs = numpy.diff(rep.displacements, axis=0)
|
||||
args['repetition'] = fatamorgana.ArbitraryRepetition(
|
||||
numpy.round(diffs).astype(int))
|
||||
diff_ints = numpy.round(diffs).astype(int)
|
||||
args['repetition'] = fatamorgana.ArbitraryRepetition(diff_ints[:, 0], diff_ints[:, 1])
|
||||
args['x'] += rep.displacements[0, 0]
|
||||
args['y'] += rep.displacements[0, 1]
|
||||
else:
|
||||
assert(rep is None)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue