0
$\begingroup$

I have a 2D region that is defined by the union of a number of polygons (the list of the polygons is available here). I can easily visualize the region using

Region[RegionUnion @@ data]

In the given example, the region looks something like this:

enter image description here

However, if you evaluate

InputForm@Show@Region[RegionUnion @@ data]

you can see that the Graphics object is still made up of the individual polygons. Because of this, exporting the graphic as a PDF (in the real case, I have a diagram with many regions) generates a relatively large file, which I want to avoid.

Also, if you zoom in on the right end of the region, you can see some artefacts in the region boundary, that could be smoothed out.

I tried

Region[DiscretizeRegion[RegionUnion @@ data, MeshQualityGoal -> "Minimal"]]

without much success. Is there an easy way to get a simple expression (for example, points defining a single polygon) for a smooth region boundary in such a case?

$\endgroup$
2
$\begingroup$

Some reduction can be achieved by using BoundaryDiscretizeRegion[] and careful extraction of the boundary points:

Import["http://pastebin.com/raw/azNJSbVg", "Package"];
bdr = BoundaryDiscretizeRegion[RegionUnion @@ data];

pts = MeshCoordinates[bdr];
polys = Polygon[pts[[#]]] & /@ 
        Map[First, FindCycle[DirectedEdge @@@ (First /@ MeshCells[bdr, 1]), ∞, All], {2}];

{Length[data], Length[polys]}
   {57, 10}

Graphics[{Red, EdgeForm[White], polys}]

some polygon

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.