You can use QGIS expressions with either Geometry generator or Geometry by expression (see here for details and differences between these two options). Use this expression with Geometry generator (see below for Geometry by expression) and replace @layer
with the name of your polygon layer:
with_variable (
'poly',
array_foreach (
case
when
array_length(
overlay_intersects(
@layer,
$geometry, limit:=-1
)
) = 2
then
overlay_intersects(
@layer,
$geometry, limit:=-1
)
end,
intersection (
$geometry,
@element
)
),
intersection (
array_get (@poly,0),
array_get (@poly,1)
)
)
If you use the expression with Geometry by expression, use this expression, where you have to replace poly
in lines 8 and 14 with the name of your polygon layer:
with_variable (
'poly',
array_foreach (
case
when
array_length(
overlay_intersects(
'poly',
$geometry, limit:=-1
)
) = 3
then
overlay_intersects(
'poly',
$geometry, limit:=-1
)
end,
intersection (
$geometry,
@element
)
),
intersection (
array_get (@poly,1),
array_get (@poly,2)
)
)
Red hached area created with Geometry generator: