using ShapeProcessor

edited July 2015 in Ruby Scripting
Hi,
I am trying to use the ShapeProcessor to perform Boolean operations, in particular:

boolean_to_polygon(Shape[] in_a, Shape[] in_b, int mode, bool resolve_holes, bool min_coherence)

I seem to missing something easy. I have an array of boxes that I want to "in_a" and a single box I want to use for "in_b". I don't know how convert a box to a Shape to construct the Shape[].

Comments

  • edited November -1

    Hi,

    "Shape" is a geometrical shape taken from the layout database. In order to work with the ShapeProcessor, you'll need a layout database (RBA::Layout).

    Since you have basic objects already (RBA::Box, RBA::Polygon etc.), the tool you look for is the EdgeProcessor.

    You can also employ the Region class to do operations between collections of polygons. This is probably the most convenient solution.

    Matthias

  • edited November -1

    Hi Matthias,

    I am writing a script to do some sizing and boolean operations on shapes. It works, but the performance is such that I won't be able to use it on anything more than a test structure. Yet when I access the menu Edit | Selection | Size Shapes, the performance is much faster. I am wondering what the difference between the script and menu is. Perhaps I am not using the correct parameters (or even the correct function!). Examples of my operations:

     pya.ShapeProcessor().size(layout,topcell,layer_in,shapes_high,99,pya.EdgeProcessor.ModeOr,True,True,True)
     pya.ShapeProcessor().size(layout,cell,layer_high, shapes_temp, 1,pya.EdgeProcessor.ModeAnd,True,True,True)
    

    Is there a way to call the Size function that is in the menu via Python script?

    thank you
    Lukas

  • edited November -1

    Hi Lukas,

    are you using selection just on a part of the layout? The ShapeProcessor will run on the full layer always. Are you planning to implement sizing on the selected shapes only?

    ShapeProcessor and EdgeProcessor are somewhat outdated. Region is the more convenient way to run boolean operations and sizing.

    To just capture the selected shapes and compute a sized version into a Region object use code like this:

    lv = RBA::LayoutView::current
    
    r = RBA::Region::new
    lv.each_object_selected do |s|
      if s.shape.is_polygon? || s.shape.is_box? || s.shape.is_path?
        r += s.trans * s.shape.polygon
      end
    end
    
    puts r.sized(100)
    

    Best regards,

    Matthias

  • edited November -1

    Thank you. I am indeed trying to size the entire layout (but selection is a good starting point).

    Is Region what the menu item is using, i.e., will the performance be the same?

    thanks

  • edited December 2017

    Hi Lukas,

    basically the performance of the different approaches should be more or less the same. Region is basically just a convenience wrapper around EdgeProcessor. ShapeProcessor is the same. The

    The performance is roughly O(E*log(E)) where E is the number of edges in the input (flat - i.e. after propagating them to the current cell if they are in a child cell). So I was wondering whether the selection may be much than the total number of shapes of the layer. That could explain the performance difference.

    A simple test is a DRC script:

    layer(1,0).sized(1.um).output(2,0)
    

    will size the layer 1/0 by 1 µm and output the results to layer 2/0. The DRC feature is based on Region and it's performance is equivalent to that of Region.

    If memory is an issue, the DRC feature can make use of a tiling scheme where the layout is cut into rectangular tiles and each tile is computed separately. Technically this is based on the TilingProcessor class. Using tiling allows utilization of multiple cores and reduces memory requirements.

    Best regards,

    Matthias

Sign In or Register to comment.