WIP: debugging

This commit is contained in:
Matthias Koefferlein 2020-12-25 16:27:24 +01:00
parent 4974a81af6
commit 19508f96e9
1 changed files with 47 additions and 9 deletions

View File

@ -1900,7 +1900,7 @@ template <class TS, class TI>
struct scan_shape2shape_same_layer_flat
{
void
operator () (const generic_shape_iterator<TS> &, unsigned int, shape_interactions<TS, TI> &, db::Coord) const
operator () (const generic_shape_iterator<TS> &, bool, unsigned int, shape_interactions<TS, TI> &, db::Coord) const
{
// cannot have different types on the same layer
tl_assert (false);
@ -1911,7 +1911,7 @@ template <class T>
struct scan_shape2shape_same_layer_flat<T, T>
{
void
operator () (const generic_shape_iterator<T> &subjects, unsigned int intruder_layer, shape_interactions<T, T> &interactions, db::Coord dist) const
operator () (const generic_shape_iterator<T> &subjects, bool needs_isolated_subjects, unsigned int intruder_layer, shape_interactions<T, T> &interactions, db::Coord dist) const
{
db::box_scanner<T, int> scanner;
interaction_registration_shape1<T, T> rec (&interactions, intruder_layer);
@ -1924,6 +1924,11 @@ struct scan_shape2shape_same_layer_flat<T, T>
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<T> ());
@ -1949,7 +1954,7 @@ template <class TS, class TI>
struct scan_shape2shape_different_layers_flat
{
void
operator () (const generic_shape_iterator<TS> &subjects, const generic_shape_iterator<TI> &intruders, unsigned int intruder_layer, shape_interactions<TS, TI> &interactions, db::Coord dist) const
operator () (const generic_shape_iterator<TS> &subjects, const generic_shape_iterator<TI> &intruders, bool needs_isolated_subjects, unsigned int intruder_layer, shape_interactions<TS, TI> &interactions, db::Coord dist) const
{
db::box_scanner2<TS, int, TI, int> scanner;
interaction_registration_shape2shape<TS, TI> 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<TS> is = subjects; ! is.at_end (); ++is) {
// create subject for subject vs. nothing interactions
interactions.add_subject (interactions.next_id (), *is);
}
}
return;
}
addressable_shape_delivery<TS> is;
is = addressable_shape_delivery<TS> (subjects.confined (common_box, true));
for ( ; !is.at_end (); ++is) {
scanner.insert1 (is.operator-> (), interactions.next_id ());
if (needs_isolated_subjects) {
box_convert<TS> bcs;
is = addressable_shape_delivery<TS> (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<TS> (subjects.confined (common_box, true));
for ( ; !is.at_end (); ++is) {
scanner.insert1 (is.operator-> (), interactions.next_id ());
}
}
addressable_shape_delivery<TI> ii (intruders.confined (common_box, true));
@ -2001,15 +2038,16 @@ local_processor<TS, TI, TR>::run_flat (const generic_shape_iterator<TS> &subject
shape_interactions<TS, TI> 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<TS, TI> () (subjects, interactions);
}
for (typename std::vector<generic_shape_iterator<TI> >::const_iterator il = intruders.begin (); il != intruders.end (); ++il) {
if (*il == subjects) {
scan_shape2shape_same_layer_flat<TS, TI> () (subjects, (unsigned int) (il - intruders.begin ()), interactions, op->dist ());
scan_shape2shape_same_layer_flat<TS, TI> () (subjects, needs_isolated_subjects, (unsigned int) (il - intruders.begin ()), interactions, op->dist ());
} else {
scan_shape2shape_different_layers_flat<TS, TI> () (subjects, *il, (unsigned int) (il - intruders.begin ()), interactions, op->dist ());
scan_shape2shape_different_layers_flat<TS, TI> () (subjects, *il, needs_isolated_subjects, (unsigned int) (il - intruders.begin ()), interactions, op->dist ());
}
}