From 04b4c21e8244464c0aecc3e9503462e74227c8bf Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 24 Jan 2018 21:21:02 +0100 Subject: [PATCH] Fixed #68 (OASIS reader issue with degenerated shapes) --- src/db/db/dbOASIS.cc | 6 ++++++ src/db/db/dbOASIS.h | 10 +++++++++- src/db/db/dbOASISReader.cc | 39 ++++++++++++-------------------------- src/db/db/dbOASISReader.h | 2 +- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/db/db/dbOASIS.cc b/src/db/db/dbOASIS.cc index 6aa97f3a7..b0d7e178e 100644 --- a/src/db/db/dbOASIS.cc +++ b/src/db/db/dbOASIS.cc @@ -396,6 +396,12 @@ Repetition::set_base (RepetitionBase *base) mp_base = base; } +size_t +Repetition::size () const +{ + return mp_base ? mp_base->size () : 1; +} + bool Repetition::is_regular (db::Vector &a, db::Vector &b, size_t &n, size_t &m) const { diff --git a/src/db/db/dbOASIS.h b/src/db/db/dbOASIS.h index 13fc23748..23aaacbf2 100644 --- a/src/db/db/dbOASIS.h +++ b/src/db/db/dbOASIS.h @@ -171,6 +171,11 @@ public: return !operator== (d); } + /** + * @brief Gets the number of elements in this repetition + */ + size_t size () const; + /** * @brief Check, if the repetition is an repetition at all * @@ -183,7 +188,7 @@ public: } /** - * @brief Check, if the repetition is a regular one + * @brief Checks, if the repetition is a regular one * * This method returns true, if the repetition is regular. It * returns true, if the repetition can be represented as a @@ -251,6 +256,7 @@ public: virtual bool equals (const RepetitionBase *) const = 0; virtual bool less (const RepetitionBase *) const = 0; virtual bool is_regular (db::Vector &a, db::Vector &b, size_t &n, size_t &m) const = 0; + virtual size_t size () const = 0; virtual const std::vector *is_iterated () const = 0; virtual unsigned int type () = 0; }; @@ -294,6 +300,7 @@ public: virtual bool is_regular (db::Vector &a, db::Vector &b, size_t &n, size_t &m) const; virtual const std::vector *is_iterated () const; virtual unsigned int type () { return 1; } + virtual size_t size () const { return m_n * m_m; } private: friend class RegularRepetitionIterator; @@ -336,6 +343,7 @@ public: virtual bool is_regular (db::Vector &a, db::Vector &b, size_t &n, size_t &m) const; virtual const std::vector *is_iterated () const; virtual unsigned int type () { return 2; } + virtual size_t size () const { return m_points.size () + 1; } void reserve (size_t n) { diff --git a/src/db/db/dbOASISReader.cc b/src/db/db/dbOASISReader.cc index 7c5f0fd86..1edcec995 100644 --- a/src/db/db/dbOASISReader.cc +++ b/src/db/db/dbOASISReader.cc @@ -1702,7 +1702,7 @@ OASISReader::read_pointlist (modal_variable > &pointlis pointlist.set_initialized (); } -void +bool OASISReader::read_repetition () { unsigned char type = get_uint (); @@ -1834,6 +1834,7 @@ OASISReader::read_repetition () error (tl::sprintf (tl::to_string (QObject::tr ("Invalid repetition type %d")), type)); } + return mm_repetition.get ().size () > 1; } void @@ -1980,9 +1981,7 @@ OASISReader::do_read_placement (unsigned char r, db::Vector pos (mm_placement_x.get (), mm_placement_y.get ()); - if (m & 0x8) { - - read_repetition (); + if ((m & 0x8) && read_repetition ()) { std::pair pp = read_element_properties (layout.properties_repository (), false); @@ -2135,9 +2134,7 @@ OASISReader::do_read_text (bool xy_absolute, ll = open_dl (layout, LDPair (mm_textlayer.get (), mm_texttype.get ()), m_create_layers); } - if (m & 0x4) { - - read_repetition (); + if ((m & 0x4) && read_repetition ()) { // TODO: should not read properties if layer is not enabled! std::pair pp = read_element_properties (layout.properties_repository (), false); @@ -2278,9 +2275,7 @@ OASISReader::do_read_rectangle (bool xy_absolute, std::pair ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()), m_create_layers); - if (m & 0x4) { - - read_repetition (); + if ((m & 0x4) && read_repetition ()) { std::pair pp = read_element_properties (layout.properties_repository (), false); @@ -2394,9 +2389,7 @@ OASISReader::do_read_polygon (bool xy_absolute, db::cell_index_type cell_index, std::pair ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()), m_create_layers); - if (m & 0x4) { - - read_repetition (); + if ((m & 0x4) && read_repetition ()) { std::pair pp = read_element_properties (layout.properties_repository (), false); @@ -2563,9 +2556,7 @@ OASISReader::do_read_path (bool xy_absolute, db::cell_index_type cell_index, db: std::pair ll = open_dl (layout, LDPair (mm_layer.get (), mm_datatype.get ()), m_create_layers); - if (m & 0x4) { - - read_repetition (); + if ((m & 0x4) && read_repetition ()) { std::pair pp = read_element_properties (layout.properties_repository (), false); @@ -2740,9 +2731,7 @@ OASISReader::do_read_trapezoid (unsigned char r, bool xy_absolute,db::cell_index pts [3] = db::Point (-std::min (delta_a, db::Coord (0)), db::Coord (0)); } - if (m & 0x4) { - - read_repetition (); + if ((m & 0x4) && read_repetition ()) { std::pair pp = read_element_properties (layout.properties_repository (), false); @@ -3102,9 +3091,7 @@ OASISReader::do_read_ctrapezoid (bool xy_absolute,db::cell_index_type cell_index --npts; } - if (m & 0x4) { - - read_repetition (); + if ((m & 0x4) && read_repetition ()) { std::pair pp = read_element_properties (layout.properties_repository (), false); @@ -3239,9 +3226,7 @@ OASISReader::do_read_circle (bool xy_absolute, db::cell_index_type cell_index, d ll.first = false; } - if (m & 0x4) { - - read_repetition (); + if ((m & 0x4) && read_repetition ()) { std::pair pp = read_element_properties (layout.properties_repository (), false); @@ -3506,8 +3491,8 @@ OASISReader::do_read_cell (db::cell_index_type cell_index, db::Layout &layout) } } - if (m & 0x4) { - read_repetition (); + if ((m & 0x4) && read_repetition ()) { + // later: handle XGEOMETRY with repetition } read_element_properties (layout.properties_repository (), true); diff --git a/src/db/db/dbOASISReader.h b/src/db/db/dbOASISReader.h index 1d1967020..60f04aeda 100644 --- a/src/db/db/dbOASISReader.h +++ b/src/db/db/dbOASISReader.h @@ -297,7 +297,7 @@ private: void mark_start_table (); void read_offset_table (); - void read_repetition (); + bool read_repetition (); void read_pointlist (modal_variable > &pointlist, bool for_polygon); void read_properties (db::PropertiesRepository &rep); void store_last_properties (db::PropertiesRepository &rep, db::PropertiesRepository::properties_set &properties, bool ignore_special);