How could identify the completed cell after clip a part of gds by the tool strmclip?

edited September 2012 in General
Hi, Matthias,

When I clip a part of gds by klayout strmclip, and the clipping part contains some cells which are incompleted or completed.
No matter incompleted or completed cells are named with original cell name with "$#", and one of them would be named as just the original cell name.
Is there any rule to identify the completed cell with their new cell name after clip process?

Thank you in advance for any advice.

Regards,
Canny

Comments

  • edited September 2012

    Hi Canny,

    I guess that the complete cells keep their names while the incomplete clip variants are named "$1", "..$2" etc. So it may be possible to identify clipped variants by looking for a "$" in their name (unless they had one before, then there is no good rule).

    But I have not tried that myself yet.

    If you need to explicitly identify clip variants, you could patch the code. For example to prepend
    a "CLIP_" before the clipped cell name for the incomplete cells, you could patch dbClip.cc around line 547:

      //  need for a new cell
      v->second = target_layout.add_cell ((std::string ("CLIP_") + layout.cell_name (v->first.first)).c_str ());
    

    Regards,

    Matthias

  • edited 12:58AM
    Hi, Matthias,

    Thanks for the advice.

    Base on the experience I tried, the complete cell also can be named as "<original cell>$1", "..$2" etc.
    If the complet cell keeps their name and incomplete clip named as "<original cell>$1", "..$2" etc. is also a good rule to identify.
    If there is possible way to modify the code with the above rule?

    We tried the patch, but it showed the error message as following.
    Could you kindly give the hint again?

    /klayout-0.21.19/src/dbClip.cc: In function 'void db::make_clip_variants(const db::Layout&, db::Layout&, std::map<std::pair<db::cell_index_type, db::Box>, db::cell_index_type, std::less<std::pair<db::cell_index_type, db::Box> >, std::allocator<std::pair<const std::pair<db::cell_index_type, db::Box>, db::cell_index_type> > >&)':
    /klayout-0.21.19/src/dbClip.cc:546: error: no matching function for call to 'db::Layout::add_cell(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
    /klayout-0.21.19/src/dbLayout.h:645: note: candidates are: db::cell_index_type db::Layout::add_cell(const char*)


    Regards,
    Canny
  • edited September 2012

    Hi Canny,

    sorry, the patch was incorrect. I have corrected it above. This one should work now.

    Regarding the naming: I was quite sure the name of the original cell should stay the same. But I can't rule out there is a chance that this would not be the case. If the patch turns out to be be useful, I'd consider adding an option for specifying the clipped cell prefix to the clip dialog.

    Best regards,

    Matthias

  • edited 12:58AM
    Hi, Matthias,

    Thanks for your help.

    I tried the new patch of the strmclip tool, the cells of the result gds were added with "Clip", no matter complete or incomplete cell.

    I confirm with the original strmclip tool, I still can't find the naming rule you mention.

    Could you kindly to help it again?

    Regards,
    Canny
  • edited 12:58AM

    Hi canny,

    sorry for that. I guess I have to look deeper into the code. I was pretty sure that was the place although I did not try myself.

    I'll try it out and hopefully I am able to give you some better advice soon.

    Regards,

    Matthias

  • edited September 2012

    Hi Canny,

    I have had a look into the code. For the interactive clip function (Edit/Utilities/Clip) the complete cell will keep it's name or the "CLIP_" prefix is not added with the patch described above. But strmclip behaves differently because it does a clip into a new layout object. To give the clip variants a different name in that case, the following patch should do the job:

    Replace this section (line 546 of dbClip.cc):

     if (v->first.second != layout.cell (v->first.first).bbox () || &layout != &target_layout) {
       //  need for a new cell
       v->second = target_layout.add_cell (layout.cell_name (v->first.first));
     } else {
       v->second = v->first.first;
     }
    

    with this:

      if (v->first.second != layout.cell (v->first.first).bbox ()) {
        //  need for a new cell with a new name (incomplete cell)
        v->second = target_layout.add_cell ((std::string ("CLIP_") + layout.cell_name (v->first.first)).c_str ());
      } else if (&layout != &target_layout) {
        //  need for a new cell, but with the original name
        v->second = target_layout.add_cell (layout.cell_name (v->first.first));
      } else {
        v->second = v->first.first;
      }
    

    The explanation is that in the strmclip case "&layout != &target_layout" is always true and the name prefixing was always happening.

    Hope this one works.

    Regards,

    Matthias

  • edited 12:58AM
    Hi, Matthias,

    Thank you and new patch works very well.
    It does great help.

    Regards,
    Canny
Sign In or Register to comment.