Skip to main content
4 of 5
added 89 characters in body
kirma
  • 19.1k
  • 1
  • 55
  • 95

I'm not entirely sure if your problem is fully defined, but here's one approach to start with, discretizing boundaries of finite components and showing them:

With[{lines = 
       ArrayMesh[{{1, 1, 0, 1}, {1, 1, 1, 1}, {0, 1, 0, 1}}] // 
        MeshPrimitives[#, 1] &},
     RegionDifference[FullRegion[2], 
        RegionUnion[Rationalize[lines, 0]]] // 
       Refine[RegionMember[#, {x, y}], Element[x | y, Reals]] & // 
      CylindricalDecomposition[#, {x, y}, "Components"] &] // 
    Map[ImplicitRegion[#, {x, y}] &] // Select[BoundedRegionQ] // 
  Map[Quiet@*BoundaryDiscretizeRegion] // Show

enter image description here

With[{lines = {Line[{{0., 92.2227}, {431.147, 750.}}], 
        Line[{{301.72, 750.}, {446.159, 0.}}], 
        Line[{{123.934, 750.}, {390.253, 0.}}], 
        Line[{{494., 432.03}, {0.470817, 750.}}], 
        Line[{{0., 388.081}, {494., 308.166}}]}},
     RegionDifference[FullRegion[2], 
        RegionUnion[Rationalize[lines, 0]]] // 
       Refine[RegionMember[#, {x, y}], Element[x | y, Reals]] & // 
      CylindricalDecomposition[#, {x, y}, "Components"] &] // 
    Map[ImplicitRegion[#, {x, y}] &] // Select[BoundedRegionQ] // 
  Map[Quiet@*BoundaryDiscretizeRegion] // Show

enter image description here

You can also replace FullRegion[2] with Quiet@BoundingRegion[RegionUnion[Rationalize[lines, 0]]] in the latter case (Quiet is for surpressing a strange, spurious error message) for getting tiles which would otherwise seem to be part of the unbounded exterior:

enter image description here

One might ask why this implicit bounding rectangle would be assumed. One could also consider, for instance, in this case a convex hull (like ConvexHullRegion[Join @@ Rationalize[lines[[All, 1]], 0]]):

enter image description here

kirma
  • 19.1k
  • 1
  • 55
  • 95