# PARTIAL POLYGON REMOBAL

edited March 2010 in General
Hi Matthias,

Thank you for creating such an interesting and versatile GDS tool. I have a question. I created a two dimensional layout from a unit hexagon cell into a honeycomb structure. Then I used a Boolean operation between an irregular structure and that honeycomb structure. It resulted in a large number of additional cells of various shapes and sizes. How can one use Boolean operations or Ruby scripts such that such partial cells are removed and only whole cell elements representing the original structures are left.

Best regards,

Iftikhar

• edited November -1

Hallo,

thanks :-)

Regarding your question: I imagine that you are trying to create a honeycomb fill pattern and you subtracted your layout from the fill pattern. Now, the problem is to remove all fill shapes that are partially cut.

If I understand that correctly, there is at least one way to do this with Ruby. For example, you could select the whole shapes by their area. Only the whole ones will have the whole area - all others will have an area less than that.

If that is what you are looking for, the basic idea would be to copy all shapes with the full area (or all shapes with the maximum area) to another layer which then will contain the whole shapes.

However, that solution is probably pretty slow. I think the limit of usability is somewhat in the order of a million shapes. Right now, there is no packaged function which does that more efficiently.

Best regards,

Matthias

• edited November -1
Hi,

Your understanding of my problem is correct. However, I am not a good programmer of Ruby, so if it is not too much to ask and you could provide the necessary code, I would appreciate it. It may be useful utility for other users too to cleanup unwanted shapes after Boolean operations.

Best regards.

Iftikhar
• edited November -1

Hi,

the following is a script that adds a new function to the "Tools" menu: "Select Whole Shapes" will select all shapes from the current layer that have an area equal to the maximum area found on the layer.

This script will fail therefore if the layer contains other geometry different from the fill shape polygon. For simplicity, it operates only on the top level of the hierarchy. This script is merely a sketch but may serve your purpose.

Best regards,

Matthias

``````class MenuAction < RBA::Action
def initialize( title, shortcut, &action )
self.title = title
self.shortcut = shortcut
@action = action
end
def triggered
@action.call( self )
end
private
@action
end

\$select_whole_shapes = MenuAction.new( "Select Whole Shapes", "" ) do

app = RBA::Application.instance
mw = app.main_window

lv = mw.current_view
if !lv
raise "No view selected"
end

layer = lv.current_layer
if layer.is_null?
raise "No layer selected"
end
if layer.current.layer_index < 0
raise "Invalid layer"
end

cv = lv.cellview(layer.current.cellview)
if ! cv.is_valid?
raise "Invalid layer"
end

shapes = cv.cell.shapes(layer.current.layer_index)

# Begin a transaction for undo/redo
lv.transaction("Select whole shapes");

begin

# Determine the maximum area
a_max = nil
shapes.each do |shape|
if shape.is_path? || shape.is_polygon? || shape.is_box?
a = shape.polygon.area
if !a_max || a > a_max
a_max = a
end
end
end

# Erase all shapes with an area less then the maximum area
shapes.each do |shape|
if shape.is_path? || shape.is_polygon? || shape.is_box?
a = shape.polygon.area
if a < a_max
shapes.erase(shape)
end
end
end

ensure

# Commit the operation
lv.commit

# After that we must cancel all operations since the selection
# is no longer valid.
lv.cancel

end

end

app = RBA::Application.instance
mw = app.main_window