# Setting labels for surfaces at time of square3 meshS creation

**URL:** <https://community.freefem.org/t/setting-labels-for-surfaces-at-time-of-square3-meshs-creation/416>\
**Category:** General Discussion\
**Created:** [May 17, 2020, 4:43am UTC](https://community.freefem.org/t/setting-labels-for-surfaces-at-time-of-square3-meshs-creation/416 "2020-05-17T04:43:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaron1d](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aaron1d/32/168_2.png) [@aaron1d](https://community.freefem.org/u/aaron1d)\
**Post date:** [May 17, 2020, 4:43am UTC](https://community.freefem.org/t/setting-labels-for-surfaces-at-time-of-square3-meshs-creation/416/1 "2020-05-17T04:43:30Z")

</div>

I’m making a somewhat complex 3d geometry, with lots of meshS pieces glued together. I can’t seem to find a way to set the label for each surface (needed for some boundary conditions) in the same line that I create the meshS. For example, it seems I have to do this:

int[int] tt1 = [0,2];  
meshS Th1 = square3(4, 5, [x, y, 0], orientation=-1);  
Th1= change(Th1, reftri=tt1);

I would prefer something like this, if possible:

int[int] tt1 = [0,2];  
meshS Th1 = square3(4, 5, [x, y, 0], orientation=-1, reftri=tt1);

to be more succinct, but I can’t figure out what if any other argument to use in the square3 function. As a workaround I tried creating my own function that would combine the two steps into one line, like:

func meshS sq3lab (int &n1, int &n2, func[int] &ff, int &orient, int &tlab) {  
meshS Th = square3(n1, n2, [ff[0], ff[1], ff[2]], orientation=orient);  
Th = change(Th, reftri=tlab);  
return Th;  
}

but “func[int]” is not the right syntax for the transformation vector.

Any ideas on a one-line solution with square3 OR with how to implement my user-defined function arguments? Thanks!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 17, 2020, 6:39am UTC](https://community.freefem.org/t/setting-labels-for-surfaces-at-time-of-square3-meshs-creation/416/2 "2020-05-17T06:39:27Z")

</div>

If you don’t care about type-checking you can simply create a macro instead.

```auto
load "medit"
load "msh3"
macro sq3lab(Th, n1, n2, ff, orient, tlab)
meshS Th = square3(n1, n2, ff, orientation=orient);
Th = change(Th, reftri=tlab);// EOM

int[int] tt1 = [0,2];
sq3lab(ThS1, 4, 5, [x, y, 0], -1, tt1);

```

There is really no shorter way. In your case, I think making the code more concise makes it less understandable, but that’s my personnal opinion 🙂

---

<div class="post-metadata">

**Author:** ![aaron1d](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aaron1d/32/168_2.png) [@aaron1d](https://community.freefem.org/u/aaron1d)\
**Post date:** [May 17, 2020, 6:44am UTC](https://community.freefem.org/t/setting-labels-for-surfaces-at-time-of-square3-meshs-creation/416/3 "2020-05-17T06:44:13Z")

</div>

Thanks for your answer. I can’t believe there’s not another away.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 17, 2020, 6:46am UTC](https://community.freefem.org/t/setting-labels-for-surfaces-at-time-of-square3-meshs-creation/416/4 "2020-05-17T06:46:21Z")

</div>

I’m sorry maybe I misunderstood your question, why don’t you use the `label` parameter (just as with standard `cube` or `square`)?

```auto
load "msh3"
int[int] tt1 = [10,20,30,40];
meshS Th1 = square3(4, 5, [x, y, 0], orientation=-1,label=tt1);

```

---

<div class="post-metadata">

**Author:** ![aaron1d](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aaron1d/32/168_2.png) [@aaron1d](https://community.freefem.org/u/aaron1d)\
**Post date:** [May 17, 2020, 6:54am UTC](https://community.freefem.org/t/setting-labels-for-surfaces-at-time-of-square3-meshs-creation/416/5 "2020-05-17T06:54:25Z")

</div>

I had tried that originally. But it seemed that when I set the label, it seemed to be setting the labels for the surface borders and not for the surface (face) itself. I checked this in two ways:

First, when I run medit, the colors of the surfaces don’t change when the labels are different, but I can see an outline (on the surface borders) toggling on and off as I toggle the “matcolors”. When I use change and reftri, the different reftri labels become different colors.

Second, I get a zero solution when I try setting the labels through the label parameter, but when I use change with reftri, I get the expected solution.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 17, 2020, 7:06am UTC](https://community.freefem.org/t/setting-labels-for-surfaces-at-time-of-square3-meshs-creation/416/6 "2020-05-17T07:06:55Z")

</div>

Ah, my bad, you want to change the triangle label. Then, no, there is no dedicated one-liner, just as there is no dedicated one-liner for creating _and_ setting the region of the tetrahedra or triangles in a 2D or 3D mesh.

---

<div class="post-metadata">

**Author:** ![aaron1d](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aaron1d/32/168_2.png) [@aaron1d](https://community.freefem.org/u/aaron1d)\
**Post date:** [May 17, 2020, 7:08am UTC](https://community.freefem.org/t/setting-labels-for-surfaces-at-time-of-square3-meshs-creation/416/7 "2020-05-17T07:08:51Z")

</div>

Yeah… OK. Thanks a lot for your responses!
