# Alternative to the DiscretizeRegion?

I have a polygon:

pgn = Polygon[{{0, 0}, {0, 0.018}, {0.155, 0.018}, {0.155 + 0.015,
0.008}, {0.222, 0.008}, {0.222, 0}, {0, 0}}];


here:

RegionPlot[pgn]


and a line intersecting this polygon:

line = {{0.1440048, 0.00283}, {0.14415, 0.0031}, {0.14431,
0.0034}, {0.144, 0.0037}, {0.1446, 0.004}, {0.1449176,
0.00445315}, {0.1452178, 0.00480635}, {0.1455,
0.0051487}, {0.14588, 0.005}, {0.1462372, 0.0058292}, {0.1466,
0.0061}, {0.14703, 0.0065092}, {0.1475198,
0.00691035}, {0.1481, 0.0074}, {0.1487492, 0.0079}};


I create a region that is cut by this line from the polygon as follows:

    f = Interpolation[line, InterpolationOrder -> 1];
ir = ImplicitRegion[y > f[x], {x, y}];
ri = RegionIntersection[pgn, ir]


Here it is:

DiscretizeRegion[ri]


My question: Is there other ways to create a geometric region our of such a composite object, except using the DiscretizeRegion function?

The problem is that this function cannot be styled. It is always blue, which is a problem, if it is necessary to visualize a complex image, consisting of many sub-regions, differently treated.

• @Jason B Yes, I fixed it. – Alexei Boulbitch Feb 10 '16 at 15:32
• Why do you need DiscretizeRegion? You create the region via RegionIntersection, and you can view it with RegionPlot like Show[ RegionPlot[{pgn, ri}], ListLinePlot@line] – Jason B. Feb 10 '16 at 15:34
• Can you use element mesh instead? reference.wolfram.com/language/FEMDocumentation/tutorial/… – bill s Feb 10 '16 at 15:34
• @Jason B Show[ RegionPlot[{pgn, ri}], ListLinePlot@line] does not work for me. I need not only to visualize, but I work with the region in question. It is not shown in my question. In the end I visualize the result together with the region in which it is obtained, another result together with its region and so on. It is, of course, possible, to work with the region, and then to visualize using Show , but it is more comfortable to work and visualize within the same paradigm. I hoped that I missed some useful function. – Alexei Boulbitch Feb 10 '16 at 15:51
• @bill s Using mesh would be a nice idea. I do not see yet, what function do you have in mind to use to create a mesh out of ri ? Could you kindly give a hint? – Alexei Boulbitch Feb 10 '16 at 15:56

I'd say that if the problem is to style the result of DiscretizeRegion, then you don't have a problem :-)

You can use MeshCellStyle to indicate the styles to apply to each category of mesh component, in this format: MeshCellStyle -> {{dimensionality, index} -> style, ...}. Dimensionality is $0$ for mesh vertices, $1$ for mesh cell boundary lines, $2$ for mesh cell surfaces.

DiscretizeRegion[Disk[], MeshCellStyle -> {
(* Mesh cell surface *)
{2, _?(Mod[#, 3] == 1 &)} -> Darker@Green,
{2, _?(Mod[#, 3] == 2 &)} -> LightGray,
{2, _?(Mod[#, 3] == 0 &)} -> Red,

(* Mesh cell boundaries *)
{1, _?EvenQ} -> Directive[Thick, Red], {1, _?OddQ} -> Black,

(* Mesh cell vertices *)
{0, All} -> Transparent}
]
`