diff --git a/src/db/db/dbHierProcessor.cc b/src/db/db/dbHierProcessor.cc index 6d7253eb7..d1008dbfd 100644 --- a/src/db/db/dbHierProcessor.cc +++ b/src/db/db/dbHierProcessor.cc @@ -1900,7 +1900,7 @@ template struct scan_shape2shape_same_layer_flat { void - operator () (const generic_shape_iterator &, unsigned int, shape_interactions &, db::Coord) const + operator () (const generic_shape_iterator &, bool, unsigned int, shape_interactions &, db::Coord) const { // cannot have different types on the same layer tl_assert (false); @@ -1911,7 +1911,7 @@ template struct scan_shape2shape_same_layer_flat { void - operator () (const generic_shape_iterator &subjects, unsigned int intruder_layer, shape_interactions &interactions, db::Coord dist) const + operator () (const generic_shape_iterator &subjects, bool needs_isolated_subjects, unsigned int intruder_layer, shape_interactions &interactions, db::Coord dist) const { db::box_scanner scanner; interaction_registration_shape1 rec (&interactions, intruder_layer); @@ -1924,6 +1924,11 @@ struct scan_shape2shape_same_layer_flat const T *shape = is.operator-> (); scanner.insert (shape, id); + // create subject for subject vs. nothing interactions + if (needs_isolated_subjects) { + interactions.add_subject (id, *shape); + } + } scanner.process (rec, dist, db::box_convert ()); @@ -1949,7 +1954,7 @@ template struct scan_shape2shape_different_layers_flat { void - operator () (const generic_shape_iterator &subjects, const generic_shape_iterator &intruders, unsigned int intruder_layer, shape_interactions &interactions, db::Coord dist) const + operator () (const generic_shape_iterator &subjects, const generic_shape_iterator &intruders, bool needs_isolated_subjects, unsigned int intruder_layer, shape_interactions &interactions, db::Coord dist) const { db::box_scanner2 scanner; interaction_registration_shape2shape rec (0 /*layout*/, &interactions, intruder_layer); @@ -1966,14 +1971,46 @@ struct scan_shape2shape_different_layers_flat db::Box common_box = intruders_box & subjects_box; if (common_box.empty ()) { + + if (needs_isolated_subjects) { + for (generic_shape_iterator is = subjects; ! is.at_end (); ++is) { + // create subject for subject vs. nothing interactions + interactions.add_subject (interactions.next_id (), *is); + } + } + return; + } addressable_shape_delivery is; - is = addressable_shape_delivery (subjects.confined (common_box, true)); - for ( ; !is.at_end (); ++is) { - scanner.insert1 (is.operator-> (), interactions.next_id ()); + if (needs_isolated_subjects) { + + box_convert bcs; + + is = addressable_shape_delivery (subjects); + for ( ; !is.at_end (); ++is) { + + unsigned int id = interactions.next_id (); + const TS *shape = is.operator-> (); + + if (bcs (*shape).overlaps (common_box)) { + scanner.insert1 (shape, id); + } + + // create subject for subject vs. nothing interactions + interactions.add_subject (id, *shape); + + } + + } else { + + is = addressable_shape_delivery (subjects.confined (common_box, true)); + for ( ; !is.at_end (); ++is) { + scanner.insert1 (is.operator-> (), interactions.next_id ()); + } + } addressable_shape_delivery ii (intruders.confined (common_box, true)); @@ -2001,15 +2038,16 @@ local_processor::run_flat (const generic_shape_iterator &subject shape_interactions interactions; - if (op->on_empty_intruder_hint () != OnEmptyIntruderHint::Drop) { + bool needs_isolated_subjects = (op->on_empty_intruder_hint () != OnEmptyIntruderHint::Drop); + if (intruders.empty () && needs_isolated_subjects) { add_subjects_vs_nothing_flat () (subjects, interactions); } for (typename std::vector >::const_iterator il = intruders.begin (); il != intruders.end (); ++il) { if (*il == subjects) { - scan_shape2shape_same_layer_flat () (subjects, (unsigned int) (il - intruders.begin ()), interactions, op->dist ()); + scan_shape2shape_same_layer_flat () (subjects, needs_isolated_subjects, (unsigned int) (il - intruders.begin ()), interactions, op->dist ()); } else { - scan_shape2shape_different_layers_flat () (subjects, *il, (unsigned int) (il - intruders.begin ()), interactions, op->dist ()); + scan_shape2shape_different_layers_flat () (subjects, *il, needs_isolated_subjects, (unsigned int) (il - intruders.begin ()), interactions, op->dist ()); } }