diff --git a/src/db/db/dbDeepRegion.cc b/src/db/db/dbDeepRegion.cc index a86e2ef4a..aaa6e5fb3 100644 --- a/src/db/db/dbDeepRegion.cc +++ b/src/db/db/dbDeepRegion.cc @@ -1054,12 +1054,7 @@ DeepRegion::xor_with (const Region &other, db::PropertyConstraint property_const { const DeepRegion *other_deep = dynamic_cast (other.delegate ()); - if (empty ()) { - - // Nothing to do - return other.delegate ()->clone (); - - } else if (other.empty ()) { + if (other.empty ()) { // Nothing to do return clone (); @@ -1068,6 +1063,18 @@ DeepRegion::xor_with (const Region &other, db::PropertyConstraint property_const return AsIfFlatRegion::xor_with (other, property_constraint); + } else if (empty ()) { + + // Nothing to do, but to maintain the normal behavior, we have to map the other + // input to our layout if neccessary + if (&other_deep->deep_layer ().layout () == &deep_layer ().layout ()) { + return other.delegate ()->clone (); + } else { + std::unique_ptr other_deep_mapped (dynamic_cast (clone ())); + other_deep_mapped->deep_layer ().add_from (other_deep->deep_layer ()); + return other_deep_mapped.release (); + } + } else if (other_deep->deep_layer () == deep_layer () && pc_skip (property_constraint)) { return new DeepRegion (deep_layer ().derived ());