# Multi region 3dmesh

**URL:** <https://community.freefem.org/t/multi-region-3dmesh/1108>\
**Category:** General Discussion\
**Created:** [July 20, 2021, 12:12pm UTC](https://community.freefem.org/t/multi-region-3dmesh/1108 "2021-07-20T12:12:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![niaa](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@niaa](https://community.freefem.org/u/niaa)\
**Post date:** [July 20, 2021, 12:12pm UTC](https://community.freefem.org/t/multi-region-3dmesh/1108/1 "2021-07-20T12:12:38Z")

</div>

Hello everyone,

I wanna make a mesh with 3 different regions. The region label for two of them is well defined. I need to say for example: if the region is equal to 1 keep it as 1 ; if the region is equal to 2 keep it as 2 ; otherwise change the label region to 3. I know for a mesh with 2 regions we can use " `a ? b : c` is equal to `b` if the `a` is true, `c` otherwise. " operator.

May you help me how can I define it for 3 regions?

Thanks.

---

<div class="post-metadata">

**Author:** ![fivanci](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@fivanci](https://community.freefem.org/u/fivanci)\
**Post date:** [July 23, 2021, 7:00am UTC](https://community.freefem.org/t/multi-region-3dmesh/1108/2 "2021-07-23T07:00:27Z")

</div>

Hi !

You should check the documentation, there are quite a few examples there. E.g. check [Mesh Generation](https://doc.freefem.org/documentation/mesh-generation.html#id4) for function `change`.

An elegant way includes a function `regions(...)` - I cannot find this function in documentation, but, essentially, it extracts the regions of the mesh a saves them in `int[int]` array. Here is a simple idea:

```auto
load "msh3"
mesh3 Th = cube(5,5,5);

int[int] regs = regions(Th);
cout << "region labels: " << regs << endl;

int[int] newRegs = [0,1];
Th=change(Th,region=newRegs);
regs = regions(Th);
cout << "new region labels: " << regs << endl;

```

if
