Transforming Regions vs. Shapes

Hi,

I wanted to draw a couple shapes in my GDS and then transform (mirror and shift) the combined shapes and have used the following code:

cospath1_l = RBA::DPath::new(path_arr1, width)
cospath2_l = RBA::DPath::new(path_arr2, width)
cospath_wg_l  = RBA::Region::new(cospath1_l) + RBA::Region::new(cospath2_l)
cell.shapes(wg0).insert(cospath_wg_l)

cospath1_r = RBA::Trans::new(2, true, 100000, 0).trans(cospath1_l)
cospath2_r = RBA::Trans::new(2, true, 100000, 0).trans(cospath2_l)
cospath_wg_r  = RBA::Region::new(cospath1_r) + RBA::Region::new(cospath2_r)
cell.shapes(wg0).insert(cospath_tr_r)

Note: I would have preferred to apply the transformation once on the "Region" and do the transformation on the "cospath_wg_l" variable. However, I get an error when I do the transformation on the Region. Hence I have taken the brute force approach and transformed each shape. Is there a way of doing the transformation on the Region?

I would have preferred the following if possible:

cospath1 = RBA::DPath::new(path_arr1, width)
cospath2 = RBA::DPath::new(path_arr2, width)
cospath_wg_l  = RBA::Region::new(cospath1) + RBA::Region::new(cospath2)
cospath_wg_r  = RBA::Trans::new(2, true, 100000, 0).trans(cospath_wg_l)
cell.shapes(wg0).insert(cospath_wg_l)
cell.shapes(wg0).insert(cospath_tr_r)

Please note that in the actual code I am combining a lot of shapes and for the sake of efficiency, I would prefer doing one transformation after combining all the shapes.

Thanks,

Vikas

• edited February 2019

Hi Vikas,

the solution is very simple:

cospath1 = RBA::Path::new(path_arr1, width)
cospath2 = RBA::Path::new(path_arr2, width)
cospath_wg_l  = RBA::Region::new(cospath1) + RBA::Region::new(cospath2)
cospath_tr_r  = cospath_wg_l.transformed(RBA::Trans::new(2, true, 100000, 0))
cell.shapes(wg0).insert(cospath_wg_l)
cell.shapes(wg0).insert(cospath_tr_r)

The "transformed" method will create a transformed copy.

Please note that I changed "DPath" to "Path". For Region, there is no benefit using DPath. In the context of layout objects, the "D" type objects are interpreted as micron-unit objects. Region objects can't perform micron-to-database unit conversions themselves, so DPath and Path are essentially the same thing.

Regards,

Matthias

• Thank you very much Matthias! Clearly I need to do a better job of going through the scripting documentation....