Added text support in DRC

- A new constructor for RBA::Region has been provided to
  create text markers from a shape iterator
- The DRC framework has been enhanced with a "text" function
This commit is contained in:
Matthias Koefferlein
2017-07-07 00:02:52 +02:00
parent 801f83f09c
commit 8396463daf
6 changed files with 118 additions and 0 deletions
+10
View File
@@ -1493,6 +1493,16 @@ public:
return db::RecursiveShapeIterator (m_iter).at_end ();
}
/**
* @brief Gets the internal iterator
*
* This method is intended for users who know what they are doing
*/
const db::RecursiveShapeIterator &iter () const
{
return m_iter;
}
/**
* @brief Ensures the region has valid polygons
*
+64
View File
@@ -26,6 +26,9 @@
#include "dbPolygonTools.h"
#include "dbLayoutUtils.h"
#include "dbShapes.h"
#include "tlGlobPattern.h"
#include <memory>
namespace gsi
{
@@ -69,6 +72,43 @@ static db::Region *new_shapes (const db::Shapes &s)
return r;
}
static db::Region *new_si_texts (const db::RecursiveShapeIterator &si_in, const std::string &pat, bool pattern)
{
db::RecursiveShapeIterator si (si_in);
si.shape_flags (db::ShapeIterator::Texts);
tl::GlobPattern glob_pat;
bool all = false;
if (pattern) {
if (pat == "*") {
all = true;
} else {
glob_pat = tl::GlobPattern (pat);
}
}
std::auto_ptr<db::Region> r (new db::Region ());
while (! si.at_end ()) {
if (si.shape ().is_text () &&
(all || (pattern && glob_pat.match (si.shape ().text_string ())) || (!pattern && si.shape ().text_string () == pat))) {
db::Text t;
si.shape ().text (t);
t.transform (si.trans ());
r->insert (db::Box (t.box ().enlarged (db::Vector (1, 1))));
}
si.next ();
}
return r.release ();
}
static db::Region texts (const db::Region *r, const std::string &pat, bool pattern)
{
std::auto_ptr<db::Region> o (new_si_texts (r->iter (), pat, pattern));
return *o;
}
static db::Region *new_si (const db::RecursiveShapeIterator &si)
{
return new db::Region (si);
@@ -595,6 +635,30 @@ Class<db::Region> decl_Region ("Region",
"r = RBA::Region::new(layout.begin_shapes(cell, layer), RBA::ICplxTrans::new(layout.dbu / dbu))\n"
"@/code\n"
) +
constructor ("new", &new_si_texts, gsi::arg("shape_iterator"), gsi::arg ("expr"), gsi::arg ("as_pattern", true),
"@brief Constructor from a text set\n"
"\n"
"@param shape_iterator The iterator from which to derive the texts\n"
"@param expr The selection string\n"
"@param as_pattern If true, the selection string is treated as a glob pattern. Otherwise the match is exact.\n"
"\n"
"This special constructor will create a region from the text objects delivered by the shape iterator. "
"Each text object will deliver a small (non-empty) box that represents the text origin.\n"
"Texts can be selected by their strings - either through a glob pattern or by exact comparison with "
"the given string. The following options are available:\n"
"\n"
"@code\n"
"region = RBA::Region::new(iter, \"*\") # all texts\n"
"region = RBA::Region::new(iter, \"A*\") # all texts starting with an 'A'\n"
"region = RBA::Region::new(iter, \"A*\", false) # all texts exactly matchin 'A*'\n"
"@/code\n"
"\n"
"This method has been introduced in version 0.25."
) +
method_ext ("texts", &texts, gsi::arg ("expr", std::string ("*")), gsi::arg ("as_pattern", true),
"@hide\n"
"This method is provided for DRC implementation only."
) +
method ("merged_semantics=", &db::Region::set_merged_semantics,
"@brief Enables or disables merged semantics\n"
"@args f\n"
+29
View File
@@ -801,6 +801,35 @@ CODE
DRCLayer::new(@engine, @engine._tcmd(@data, 0, RBA::Region, :smoothed, prep_value(d)))
end
# %DRC%
# @name texts
# @brief Selects texts from an original layer
# @synopsis layer.texts
# @synopsis layer.texts(text)
# @synopsis layer.texts(text, true)
# @synopsis layer.texts(text, false)
# This method can be applied to original layers - i.e. ones that have
# been created with \input. It will produce a small box (2x2 DBU) on each
# selected texts.
#
# Texts can be selected either by exact match or pattern match with a
# glob-style pattern. The second argument selects pattern style (true)
# or exact match (false).
#
# @code
# # Selects all texts
# t = input(1, 0).texts
# # Selects all texts beginning with an "A"
# t = input(1, 0).texts("A*")
# t = input(1, 0).texts("A*", true)
# # Selects all texts whose string is "A*"
# t = input(1, 0).texts("A*", false)
# @/code
def texts(expr = "*", as_pattern = true)
DRCLayer::new(@engine, @engine._tcmd(@data, 0, RBA::Region, :texts, expr, as_pattern))
end
# %DRC%
# @name odd_polygons
# @brief Checks for odd polygons (self-overlapping, non-orientable)