Merge remote-tracking branch 'remotes/origin/master' into pymod

Provides fixes for issue #166 and #172.
This commit is contained in:
Matthias Koefferlein
2018-09-26 21:15:08 +02:00
16 changed files with 145 additions and 33 deletions
+4 -4
View File
@@ -112,7 +112,7 @@ struct cut_polygon_edge
{
typedef typename PointType::coord_type coord_type;
typedef typename db::edge<coord_type> edge_type;
typedef typename db::coord_traits<coord_type>::area_type projection_type;
typedef double projection_type;
cut_polygon_edge ()
: contour (-1), index (0), projected (0), point (), last_point ()
@@ -179,7 +179,7 @@ public:
bool operator< (const loose_end_struct<CuttingEdgeType> &other) const
{
if (proj () != other.proj ()) {
if (! db::coord_traits<double>::equal (proj (), other.proj ())) {
return proj () < other.proj ();
} else {
return db::vprod_sign (edge (), other.edge ()) > 0;
@@ -196,13 +196,13 @@ static bool _cut_polygon_internal (const PolygonType &input, const Edge &line, C
typedef db::edge<coord_type> edge_type;
typedef cut_polygon_edge<point_type> cut_polygon_edge_type;
typedef cut_polygon_segment<cut_polygon_edge_type> cutting_segment_type;
typedef typename db::coord_traits<coord_type>::area_type projection_type;
bool do_hole_assignment = (input.holes () > 0);
std::vector <PolygonType> hull_polygons;
std::vector <PolygonType> hole_polygons;
std::vector<cutting_segment_type> cutting_segments;
double line_length = line.double_length ();
for (unsigned int nc = 0; nc < input.holes () + 1; ++nc) {
@@ -229,7 +229,7 @@ static bool _cut_polygon_internal (const PolygonType &input, const Edge &line, C
int s1 = line.side_of (e.p1 ());
int s2 = line.side_of (e.p2 ());
projection_type p = db::sprod (ip.second - line.p1 (), line.p2 () - line.p1 ());
double p = line_length * double (db::vprod (e.p1 () - line.p1 (), e.d ())) / double (db::vprod (line.d (), e.d ()));
if (s1 < 0 && s2 >= 0) {
// right -> left or on edge
+17
View File
@@ -2241,3 +2241,20 @@ TEST(403)
EXPECT_EQ (right_of.size (), size_t (0));
}
}
// issue 166
TEST(404)
{
db::Polygon poly;
std::string s ("(390,0;438,936;176,874;0,832;438,937;541,961;821,102)");
tl::Extractor ex (s.c_str ());
ex.read (poly);
std::vector<db::Polygon> sp;
db::split_polygon (poly, sp);
EXPECT_EQ (sp.size (), size_t (2));
if (sp.size () >= 2) {
EXPECT_EQ (sp[0].to_string (), "(390,0;438,936;390,925;438,937;541,961;821,102)");
EXPECT_EQ (sp[1].to_string (), "(0,832;176,874;390,925)");
}
}
@@ -1145,3 +1145,11 @@ TEST(121)
opt.max_vertex_count = 4;
run_test (_this, "t121.oas.gz", "t121_au.gds.gz", true, opt);
}
// Extreme fracturing by max. points
TEST(166)
{
db::GDS2WriterOptions opt;
opt.max_vertex_count = 4;
run_test (_this, "t166.oas.gz", "t166_au.gds.gz", false, opt);
}
@@ -70,17 +70,6 @@ DEFImporter::get_orient (bool optional)
}
}
/**
* @brief A structure describing a via
*/
struct ViaDesc
{
ViaDesc () : cell (0) { }
db::Cell *cell;
std::string m1, m2;
};
void
DEFImporter::read_polygon (db::Polygon &poly, double scale)
{
@@ -153,7 +142,7 @@ DEFImporter::do_read (db::Layout &layout)
double dbu_mic = 1000.0;
double scale = 1.0 / (dbu_mic * layout.dbu ());
std::map<int, db::Polygon> styles;
std::map<std::string, ViaDesc> via_desc;
std::map<std::string, ViaDesc> via_desc = m_lef_importer.vias ();
std::map<std::string, std::vector<db::Polygon> > regions;
std::list<Group> groups;
std::list<std::pair<std::string, db::CellInstArray> > instances;
@@ -533,6 +533,24 @@ private:
const LEFDEFReaderOptions *mp_tech_comp;
};
/**
* @brief A structure describing a via
*/
struct EXT_PUBLIC ViaDesc
{
ViaDesc () : cell (0) { }
/**
* @brief The cell representing the via
*/
db::Cell *cell;
/**
* @brief The names of bottom and top metal respectively
*/
std::string m1, m2;
};
/**
* @brief The LEF importer object
*/
@@ -458,6 +458,9 @@ LEFImporter::do_read (db::Layout &layout)
std::string cellname = "VIA_" + n;
db::Cell &cell = layout.cell (layout.add_cell (cellname.c_str ()));
ViaDesc &via_desc = m_vias[n];
via_desc.cell = &cell;
while (test ("DEFAULT") || test ("TOPOFSTACKONLY"))
;
test (";");
@@ -543,9 +546,9 @@ LEFImporter::do_read (db::Layout &layout)
} else if (test ("LAYERS")) {
geometry[0].first = get ();
via_desc.m1 = geometry[0].first = get ();
geometry[1].first = get ();
geometry[2].first = get ();
via_desc.m2 = geometry[2].first = get ();
test (";");
@@ -86,6 +86,16 @@ public:
*/
double layer_ext (const std::string &layer, double def_ext = 0.0) const;
/**
* @brief Gets a map of the vias defined in this LEF file
*
* The map maps the via name to the via description.
*/
const std::map<std::string, ViaDesc> &vias () const
{
return m_vias;
}
protected:
void do_read (db::Layout &layout);
@@ -95,6 +105,7 @@ private:
std::map<std::string, double> m_default_ext;
std::map<std::string, db::Cell *> m_macros_by_name;
std::map<std::string, db::Box> m_macro_bboxes_by_name;
std::map<std::string, ViaDesc> m_vias;
std::vector <db::Trans> get_iteration (db::Layout &layout);
void read_geometries (db::Layout &layout, db::Cell &cell, LayerPurpose purpose, std::map<std::string, db::Box> *collect_bboxes = 0);
@@ -30,7 +30,7 @@
#include <cstdlib>
static void run_test (tl::TestBase *_this, const char *lef_dir, const char *filename, const char *au)
static void run_test (tl::TestBase *_this, const char *lef_dir, const char *filename, const char *au, bool priv = true)
{
db::LEFDEFReaderOptions tc;
tc.set_via_geometry_datatype (0);
@@ -60,7 +60,7 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file
if (ex.test ("def:")) {
std::string fn (tl::testsrc_private ());
std::string fn (priv ? tl::testsrc_private () : tl::testsrc ());
fn += "/testdata/lefdef/";
fn += lef_dir;
fn += "/";
@@ -73,7 +73,7 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file
} else if (ex.test ("lef:")) {
std::string fn (tl::testsrc_private ());
std::string fn (priv ? tl::testsrc_private () : tl::testsrc ());
fn += "/testdata/lefdef/";
fn += lef_dir;
fn += "/";
@@ -118,7 +118,7 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file
if (au) {
std::string fn (tl::testsrc_private ());
std::string fn (priv ? tl::testsrc_private () : tl::testsrc ());
fn += "/testdata/lefdef/";
fn += lef_dir;
fn += "/";
@@ -233,3 +233,8 @@ TEST(19)
run_test (_this, "def10", "def:in.def", "au.oas.gz");
}
TEST(20)
{
run_test (_this, "issue-172", "lef:in.lef+def:in.def", "au.oas.gz", false);
}