From 67a1b3a99ffdb8c2092748f384d33529fd1aac5c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 14 Mar 2021 02:40:12 +0100 Subject: [PATCH] WIP: fill + DRC, experimental. --- src/drc/drc/built-in-macros/_drc_engine.rb | 22 ++++- src/drc/drc/built-in-macros/_drc_layer.rb | 57 +++++++++++ src/drc/drc/built-in-macros/_drc_tags.rb | 110 +++++++++++++++++++++ 3 files changed, 188 insertions(+), 1 deletion(-) diff --git a/src/drc/drc/built-in-macros/_drc_engine.rb b/src/drc/drc/built-in-macros/_drc_engine.rb index 8cb066c0b..d84f3f9e3 100644 --- a/src/drc/drc/built-in-macros/_drc_engine.rb +++ b/src/drc/drc/built-in-macros/_drc_engine.rb @@ -93,7 +93,7 @@ module DRC def transparent DRCShielded::new(false) end - + def projection_limits(*args) self._context("projection_limits") do if args.size == 0 @@ -210,6 +210,26 @@ module DRC DRCAreaAndPerimeter::new(r, 1.0, f) end end + + def fill_cell(name) + DRCFillCell::new(name) + end + + def hstep(x, y = nil) + DRCFillStep(true, x, y) + end + + def vstep(x, y = nil) + DRCFillStep(false, x, y) + end + + def auto_origin + DRCFillOrigin::new + end + + def origin(x, y) + DRCFillOrigin::new(x, y) + end # %DRC% # @brief Defines SPICE output format (with options) diff --git a/src/drc/drc/built-in-macros/_drc_layer.rb b/src/drc/drc/built-in-macros/_drc_layer.rb index b5fa7a3df..9f50b664e 100644 --- a/src/drc/drc/built-in-macros/_drc_layer.rb +++ b/src/drc/drc/built-in-macros/_drc_layer.rb @@ -3892,6 +3892,63 @@ CODE @engine._context("output") do @engine._vcmd(@engine, :_output, self.data, *args) end + end + + # Experimental + + def fill(*args) + + m = "fill" + + source = @engine.source + row_step = nil + column_step = nil + pattern = nil + origin = RBA::DPoint::new + + args.each_with_index do |a,ai| + if a.is_a?(DRCSource) + if source + raise("Duplicate source specification for '#{m}' at argument ##{ai+1}") + end + source = a + elsif a.is_a?(DRCFillCell) + if pattern + raise("Duplicate fill pattern specification for '#{m}' at argument ##{ai+1}") + end + pattern = a + elsif a.is_a?(DRCFillStep) + if a.for_row + if row_step + raise("Duplicate hstep specification for '#{m}' at argument ##{ai+1}") + end + row_step = a + else + if column_step + raise("Duplicate vstep specification for '#{m}' at argument ##{ai+1}") + end + column_step = a + end + elsif a.is_a?(DRCFillOrigin) + origin = a.origin + else + raise("Argument ##{ai+1} not understood for '#{m}'") + end + end + + if !pattern + raise("No fill pattern given for '#{m}'") + end + + if !row_step + row_step = RBA::DVector::new(pattern.bbox.width, 0) + end + if !column_step + column_step = RBA::DVector::new(0, pattern.bbox.height) + end + + + end # %DRC% diff --git a/src/drc/drc/built-in-macros/_drc_tags.rb b/src/drc/drc/built-in-macros/_drc_tags.rb index fb9c051fc..b49d1ce7d 100644 --- a/src/drc/drc/built-in-macros/_drc_tags.rb +++ b/src/drc/drc/built-in-macros/_drc_tags.rb @@ -180,6 +180,116 @@ module DRC @value end end + + # A wrapper for the fill cell definition + class DRCFillCell + + def initialize(name) + @cell_name = name + @shapes = [] + @origin = RBA::DVector::new + end + + def shape(*args) + + layer = nil + datatype = nil + name = nil + shapes = [] + + args.each_with_index do |a,ai| + if a.is_a?(1.class) + if !layer + layer = a + datatype = 0 + elsif !datatype + datatype = a + else + raise("Argument ##{ai+1} not understood for FillCell#shape") + end + elsif a.is_a?(String) + if !name + name = a + else + raise("Argument ##{ai+1} not understood for FillCell#shape") + end + elsif a.is_a?(RBA::DBox) || a.is_a?(RBA::DPath) || a.is_a?(RBA::DPolygon) || a.is_a?(RBA::DText) + shapes << a + else + raise("Argument ##{ai+1} not understood for FillCell#shape (needs to one of: number, string or box, path, polygon or text)") + end + end + + if !shapes.empty? + + li = RBA::LayerInfo::new + layer && li.layer = layer + datatype && li.datatype = datatype + name && li.name = name + + @shapes << [ li, shapes ] + + end + + end + + def origin(x, y) + if !x.is_a?(1.class) && !x.is_a?(1.0.class) + raise("x argument not numeric FillCell#origin") + end + if !y.is_a?(1.class) && !y.is_a?(1.0.class) + raise("y argument not numeric FillCell#origin") + end + @origin = RBA::DVector::new(x, y) + end + + end + # A wrapper for the fill step definition + class DRCFillStep + def initialize(for_row, x, y = nil) + @for_row = for_row + if !x.is_a?(1.class) && !x.is_a?(1.0.class) + raise("x argument not numeric in fill step") + end + if y && !y.is_a?(1.class) && !y.is_a?(1.0.class) + raise("y argument not numeric in fill step") + end + if y + @step = RBA::DVector::new(x, y) + elsif for_row + @step = RBA::DVector::new(x, 0) + else + @step = RBA::DVector::new(0, x) + end + end + def for_row + @for_row + end + def step + @step + end + end + + # A wrapper for the fill origin definition + class DRCFillOrigin + def initialize(x = nil, y = nil) + if !x && !y + @origin = nil + else + if !x.is_a?(1.class) && !x.is_a?(1.0.class) + raise("x argument not numeric in fill origin") + end + if !y.is_a?(1.class) && !y.is_a?(1.0.class) + raise("y argument not numeric in fill origin") + end + @origin = RBA::DVector::new(x, y) + end + end + def origin + @origin + end + end + end