I am using Mathematica to draw regions and export them to use in Clewin, a layout program used in lithographic processes for microfabrication. Clewin is rather simple and basically uses polygons to draw any region. So, in Mathematica, I plot the regions and then extract the boundary to be converted in polygons. Recently, I have also been using Mathematica to convert characters into regions, for example:

reg = BoundaryDiscretizeGraphics[
        Text[Style["T", FontFamily -> "Tahoma"]], _Text

and then extract the points that make up the boundary for further processing:

puntos=First@MeshPrimitives[reg, 2][[1]];

However, this method does not work with characters like "0" or "B" since the resulting regions have inner empty spaces. In this case the boundary cannot be written as polygons. My idea was to divide the resulting region in two using HalfPlane, like this:

reg = BoundaryDiscretizeGraphics[
        Text[Style["B", FontFamily -> "Tahoma"]], _Text
centro = RegionCentroid[reg];
hp1 = HalfPlane[centro, {0, 1}, {1, 0}];
hp2 = HalfPlane[centro, {0, 1}, {-1, 0}];
reg1 = RegionDifference[reg, hp1];
reg2 = RegionDifference[reg, hp2];

and then extract the boundaries of the resulting regions. To my surprise, RegionDifference is not working. When I plot this I get the message that the resulting region cannot be discretized. Any ideas?

  • $\begingroup$ I just realized that if I discretize my half plane first, then I can apply RegionDiference. I still do not grasp completely when to discretize an object or not. $\endgroup$ – Patricio Mar 20 '18 at 10:15
  • 2
    $\begingroup$ Does this help: reg = DiscretizeGraphics[ Text[Style["Ö", FontFamily -> "Tahoma"]], _Text]; RegionBoundary[reg] $\endgroup$ – user21 Mar 20 '18 at 10:17

Your Answer

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

Browse other questions tagged or ask your own question.