diff --git a/src/db/db/dbShapes.cc b/src/db/db/dbShapes.cc index 5f6003757..bb4aae1a1 100644 --- a/src/db/db/dbShapes.cc +++ b/src/db/db/dbShapes.cc @@ -727,9 +727,6 @@ Shapes::shape_type Shapes::replace_prop_id (const Shapes::shape_type &ref, db::properties_id_type prop_id) { tl_assert (! ref.is_array_member ()); - if (! is_editable ()) { - throw tl::Exception (tl::to_string (tr ("Function 'replace_prop_id' is permitted only in editable mode"))); - } if (ref.has_prop_id ()) { @@ -810,6 +807,10 @@ Shapes::replace_prop_id (const Shapes::shape_type &ref, db::properties_id_type p } else { + if (! is_editable ()) { + throw tl::Exception (tl::to_string (tr ("Function 'replace_prop_id' is permitted only in editable mode when going to property-less shapes to some with properties"))); + } + switch (ref.m_type) { case shape_type::Null: return ref; @@ -1253,9 +1254,6 @@ void Shapes::replace_prop_id (const Sh *pos, db::properties_id_type prop_id) { if (pos->properties_id () != prop_id) { - if (! is_editable ()) { - throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode"))); - } if (manager () && manager ()->transacting ()) { check_is_editable_for_undo_redo (); db::layer_op::queue_or_append (manager (), this, false /*not insert*/, *pos); @@ -1272,10 +1270,6 @@ template Shapes::shape_type Shapes::replace_prop_id_iter (typename db::object_tag, const Iter &iter, db::properties_id_type prop_id) { - if (! is_editable ()) { - throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode"))); - } - if (manager () && manager ()->transacting ()) { check_is_editable_for_undo_redo (); db::layer_op::queue_or_append (manager (), this, false /*not insert*/, *iter); @@ -1293,10 +1287,6 @@ template Shapes::shape_type Shapes::reinsert_member_with_props (typename db::object_tag, const shape_type &ref, const Sh2 &sh) { - if (! is_editable ()) { - throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode"))); - } - // the shape types are not equal - resolve into erase and insert (of new) if (! ref.has_prop_id ()) { erase_shape (ref); @@ -1312,10 +1302,6 @@ template Shapes::shape_type Shapes::replace_member_with_props (typename db::object_tag, const shape_type &ref, const Sh2 &sh) { - if (! is_editable ()) { - throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode"))); - } - // the shape types are not equal - resolve into erase and insert (of new) if (! ref.has_prop_id ()) { erase_shape (ref); @@ -1363,10 +1349,6 @@ Shapes::replace_member_with_props (typename db::object_tag tag, const shape_ } else { - if (! is_editable ()) { - throw tl::Exception (tl::to_string (tr ("Function 'replace' is permitted only in editable mode"))); - } - if (! ref.has_prop_id ()) { if (manager () && manager ()->transacting ()) { diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc index a34eec3d7..b190fef74 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc @@ -1089,32 +1089,66 @@ OASISReader::do_read (db::Layout &layout) // Resolve forward references for stored shape and instance prop_ids. // This makes these shape and instance property IDs valid - for (auto p = m_forward_properties_for_instances.begin (); p != m_forward_properties_for_instances.end (); ++p) { + { + std::map replaced_prop_ids; + std::set instances_set; - db::PropertiesSet props = forward_properties (p->first); - resolve_forward_references (props); + for (auto p = m_forward_properties_for_instances.begin (); p != m_forward_properties_for_instances.end (); ++p) { + + db::PropertiesSet props = forward_properties (p->first); + resolve_forward_references (props); + + replaced_prop_ids.insert (std::make_pair (p->first, db::properties_id (props))); + + instances_set.insert (p->second.begin (), p->second.end ()); - db::properties_id_type pid = db::properties_id (props); - for (auto i = p->second.begin (); i != p->second.end (); ++i) { - if (i->instances ()) { - i->instances ()->replace_prop_id (*i, pid); - } } + for (auto i = instances_set.begin (); i != instances_set.end (); ++i) { + + for (auto ii = (*i)->begin (); ! ii.at_end (); ++ii) { + auto pm = replaced_prop_ids.find (ii->prop_id ()); + if (pm != replaced_prop_ids.end ()) { + (*i)->replace_prop_id (*ii, pm->second); + } + } + + } } - for (auto p = m_forward_properties_for_shapes.begin (); p != m_forward_properties_for_shapes.end (); ++p) { + { + std::map replaced_prop_ids; + std::set shapes_set; - db::PropertiesSet props = forward_properties (p->first); - resolve_forward_references (props); + for (auto p = m_forward_properties_for_shapes.begin (); p != m_forward_properties_for_shapes.end (); ++p) { + + db::PropertiesSet props = forward_properties (p->first); + resolve_forward_references (props); + + replaced_prop_ids.insert (std::make_pair (p->first, db::properties_id (props))); + + shapes_set.insert (p->second.begin (), p->second.end ()); - db::properties_id_type pid = db::properties_id (props); - for (auto i = p->second.begin (); i != p->second.end (); ++i) { - if (i->shapes ()) { - i->shapes ()-> replace_prop_id (*i, pid); - } } + for (auto i = shapes_set.begin (); i != shapes_set.end (); ++i) { + + for (auto ii = (*i)->begin (db::ShapeIterator::All); ! ii.at_end (); ) { + auto pm = replaced_prop_ids.find (ii->prop_id ()); + if (ii.in_array ()) { + if (pm != replaced_prop_ids.end ()) { + (*i)->replace_prop_id (ii.array (), pm->second); + } + ii.finish_array (); + } else { + if (pm != replaced_prop_ids.end ()) { + (*i)->replace_prop_id (*ii, pm->second); + } + ++ii; + } + } + + } } // Resolve forward cell properties and extract context strings @@ -1266,13 +1300,13 @@ OASISReader::forward_properties (properties_id_type id) const void OASISReader::register_forward_property_for_shape (const db::Shape &shape) { - m_forward_properties_for_shapes [shape.prop_id ()].push_back (shape); + m_forward_properties_for_shapes [shape.prop_id ()].insert (shape.shapes ()); } void OASISReader::register_forward_property_for_instance (const db::Instance &instance) { - m_forward_properties_for_instances [instance.prop_id ()].push_back (instance); + m_forward_properties_for_instances [instance.prop_id ()].insert (instance.instances ()); } void diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h index 674ac150a..dbcac008c 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h @@ -180,8 +180,8 @@ private: std::map m_propname_forward_references; std::map m_propvalue_forward_references; - std::map > m_forward_properties_for_shapes; - std::map > m_forward_properties_for_instances; + std::map > m_forward_properties_for_shapes; + std::map > m_forward_properties_for_instances; std::map m_future_cell_properties; std::list m_fwd_properties; db::property_names_id_type m_s_gds_property_name_id;