Skip to content

Commit 96d64d4

Browse files
committed
Add -morphooptiini ori and id
It is now possible to assign orientations and ids to the initial seeds, using -morphooptiini. To retain the orientations, `-ori initial` must also be used.
1 parent 17033ae commit 96d64d4

File tree

31 files changed

+248
-135
lines changed

31 files changed

+248
-135
lines changed

VERSIONS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
New in 4.8.2-8 (25 Mar 2024):
2-
- module -T: added -transform "cut(cube)", improved -transform "cut(cubei)",
3-
made minor fixes and improvements.
1+
New in 4.8.2-9 (25 Mar 2024):
2+
- module -T: added -transform "cut(cube)", added -morphooptiini ori and id,
3+
improved -transform "cut(cubei)", made minor fixes and improvements.
44
- module -M: made minor improvements.
55

66
New in 4.8.1 (02 Feb 2024):

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import sphinx_rtd_theme
1212

1313
project = u'Neper'
14-
version = u'4.8.2-8'
15-
release = u'4.8.2-8'
14+
version = u'4.8.2-9'
15+
release = u'4.8.2-9'
1616
author = u'Romain Quey'
1717
copyright = u'Romain Quey'
1818
language = 'en'

doc/neper_t.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ These options can be used to set the cell morphology.
257257

258258
.. option:: -morphooptiini <seed_attributes>
259259

260-
Specify the initial positions and/or weights of the seeds.
260+
Specify the initial positions, weights, orientations and/or ids of the seeds.
261261

262-
The general form of the argument is :data:`coo:\<coo_definition\>,weight:\<weight_definition\>`. Different values of :data:`<coo_definition>` and :data:`<weight_definition>` are available, depending on the value of option :option:`-morpho`:
262+
The general form of the argument is :data:`coo:\<coo_definition\>,weight:\<weight_definition\>,...`. Different values of :data:`<coo_definition>` and :data:`<weight_definition>` are available, depending on the value of option :option:`-morpho`:
263263

264264
- :data:`<coo_definition>` can be:
265265

@@ -278,6 +278,16 @@ These options can be used to set the cell morphology.
278278

279279
The default depends on the value of option :data:`-morpho`: for :data:`voronoi`, it is :data:`0`, for a cell-size statistical distribution, it is :data:`avradeq`, and for cell-based size values (including :data:`-morpho tesr`) , it is :data:`radeq`.
280280

281+
It is also possible to load orientations or ids using :data:`ori:\<ori_definition\>` and :data:`id:\<id_definition\>`:
282+
283+
- :data:`<ori_definition>` can be:
284+
285+
- :data:`file(<file_name>[,des=<descriptor>])`: discrete orientations to be read from a :ref:`data_file` written using a specific descriptor (see :ref:`rotations_and_orientations`, default :data:`rodrigues`).
286+
287+
- :data:`<id_definition>` can be:
288+
289+
- :data:`file(<file_name>)`: values from a :ref:`data_file`.
290+
281291
Alternatively, :data:`file(<file_name>)` can be used to load the seed coordinates and weights from a unique :ref:`tess_file` (thereby replicating the tessellation).
282292

283293
**Default value**: :data:`default`.
@@ -483,6 +493,8 @@ Crystal Orientation Options
483493

484494
- :data:`file(<file_name>[,des=<descriptor>])`: discrete orientations to be read from a :ref:`data_file` written using a specific descriptor (see :ref:`rotations_and_orientations`, default :data:`rodrigues`).
485495

496+
- :data:`from_morpho`: discrete orientations read from :option:`-morphooptiini`:data:`ori`.
497+
486498
For :option:`-ori`:data:`<orientation>` and :option:`-ori`:data:`parent`, the optional distributions are:
487499

488500
- :data:`normal(<var>=<val>)`: a 3-variate normal distribution, where :data:`<var>` can be:

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(POLICY CMP0077)
77
cmake_policy(SET CMP0077 NEW)
88
endif()
99

10-
set(NEPER_VERSION \"4.8.2-8\")
10+
set(NEPER_VERSION \"4.8.2-9\")
1111
project(neper)
1212

1313
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1)

src/neper_t/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ add_library(neper_t
183183
./net_stat/net_stat2.c
184184
./net_res/net_res_ori/net_res_ori1.c
185185
./net_tess/net_tess_opt/net_tess_opt_init/net_tess_opt_init_sset/net_tess_opt_init_sset_ori/net_tess_opt_init_sset_ori1.c
186+
./net_tess/net_tess_opt/net_tess_opt_init/net_tess_opt_init_sset/net_tess_opt_init_sset_id/net_tess_opt_init_sset_id1.c
186187
./net_ori/net_ori1.c
187188
./net_ori/net_ori2.c
188189
./net_ori/net_ori3.c

src/neper_t/net_ori/net_ori.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern "C"
2626
extern void net_ori_random (long random, struct OL_SET *pOSet);
2727

2828
extern void net_ori_file (char *label, struct OL_SET *pOSet);
29+
extern void net_ori_memcpy (struct OL_SET OSet, struct SEEDSET *pSSet);
2930

3031
extern void net_ori_post (struct TESR *pTesr);
3132

src/neper_t/net_ori/net_ori1.c

Lines changed: 95 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -38,104 +38,116 @@ net_ori (struct IN_T In, int level, struct MTESS MTess, struct TESS *Tess,
3838

3939
net_ori_mtess_params (In, level, MTess, Tess, dtess, dcell, &ori, &orisampling, &orispread, &oricrysym);
4040

41-
OSet = ol_set_alloc ((*pSSet).N, oricrysym);
41+
if (!strcmp (ori, "from_morpho"))
42+
{
43+
// oris already in *pSSet
44+
}
45+
else
46+
{
47+
OSet = ol_set_alloc ((*pSSet).N, oricrysym);
4248

43-
ut_list_break (ori, "+", &parts, &partqty);
49+
ut_list_break (ori, "+", &parts, &partqty);
4450

45-
net_ori_qty (pSSet, parts, partqty, &qty);
51+
net_ori_qty (pSSet, parts, partqty, &qty);
4652

47-
OSets = malloc (partqty * sizeof (struct OL_SET));
48-
size = ut_alloc_1d_int (partqty);
49-
for (i = 0; i < partqty; i++)
50-
OSets[i] = ol_set_alloc (qty[i], oricrysym);
53+
OSets = malloc (partqty * sizeof (struct OL_SET));
54+
size = ut_alloc_1d_int (partqty);
55+
for (i = 0; i < partqty; i++)
56+
OSets[i] = ol_set_alloc (qty[i], oricrysym);
5157

52-
for (i = 0; i < partqty; i++)
53-
{
54-
if (!strcmp (parts[i], "random") || strstr (In.orioptiini[level], "ori=random"))
58+
for (i = 0; i < partqty; i++)
5559
{
56-
if (!strcmp (In.orisampling[level], "random"))
57-
net_ori_random ((*pSSet).Random, OSets + i);
58-
59-
else if (!strcmp (In.orisampling[level], "uniform"))
60-
net_ori_uniform (In, level, MTess, Tess, dtess, dcell, (*pSSet).Random,
61-
OSets + i, verbositylevel);
60+
if (!strcmp (parts[i], "from_morpho"))
61+
{
62+
63+
}
64+
65+
else if (!strcmp (parts[i], "random") || strstr (In.orioptiini[level], "ori=random"))
66+
{
67+
if (!strcmp (In.orisampling[level], "random"))
68+
net_ori_random ((*pSSet).Random, OSets + i);
69+
70+
else if (!strcmp (In.orisampling[level], "uniform"))
71+
net_ori_uniform (In, level, MTess, Tess, dtess, dcell, (*pSSet).Random,
72+
OSets + i, verbositylevel);
73+
74+
else
75+
ut_print_message (2, 3, "Failed to process `%s'.\n", In.orisampling[level]);
76+
}
77+
78+
else if (!strncmp (parts[i], "fiber", 5))
79+
net_ori_fiber (SSet, dtess, dcell, (*pSSet).Random, parts[i], OSets + i);
80+
81+
else if (!strncmp (ori, "file(", 5))
82+
{
83+
net_ori_file (ori, OSets + i);
84+
ut_string_string (oricrysym, &(OSets[i].crysym));
85+
}
86+
87+
else if (strstr (In.orioptiini[level], "ori="))
88+
{
89+
int qty, *qty1 = NULL;
90+
char ***parts = NULL;
91+
ut_list_break2 (In.orioptiini[level], ",", "=", &parts, &qty1, &qty);
92+
for (j = 0; j < qty; j++)
93+
if (!strcmp (parts[j][0], "ori"))
94+
net_ori_file (parts[j][1], OSets + i);
95+
ut_string_string (oricrysym, &(OSets[i].crysym));
96+
97+
ut_free_3d_char (&parts, qty, 2);
98+
ut_free_1d_int (&qty1);
99+
}
100+
101+
else if (!strncmp (parts[i], "odf", 3))
102+
net_ori_odf ((*pSSet).Random, parts[i], OSets + i);
62103

63104
else
64-
ut_print_message (2, 3, "Failed to process `%s'.\n", In.orisampling[level]);
105+
net_ori_label (parts[i], SSet, dtess, dcell, OSets + i);
106+
107+
if (strstr (In.orioptiini[level], "weight="))
108+
{
109+
int qty, *qty1 = NULL;
110+
char ***parts = NULL;
111+
ut_list_break2 (In.orioptiini[level], ",", "=", &parts, &qty1, &qty);
112+
113+
OSets[i].weight = ut_alloc_1d (OSets[i].size);
114+
for (j = 0; j < qty; j++)
115+
if (!strcmp (parts[j][0], "weight"))
116+
ut_array_1d_fnscanf_wcard (parts[j][1], OSets[i].weight, OSets[i].size, "numeral", "r");
117+
}
118+
119+
if (strstr (In.orioptiini[level], "theta="))
120+
{
121+
int qty, *qty1 = NULL;
122+
char ***parts = NULL;
123+
ut_list_break2 (In.orioptiini[level], ",", "=", &parts, &qty1, &qty);
124+
125+
OSets[i].theta = ut_alloc_1d (OSets[i].size);
126+
for (j = 0; j < qty; j++)
127+
if (!strcmp (parts[j][0], "theta"))
128+
{
129+
ut_array_1d_fnscanf_wcard (parts[j][1], OSets[i].theta, OSets[i].size, "numeral", "r");
130+
ut_array_1d_scale (OSets[i].theta, OSets[i].size, M_PI / 180);
131+
}
132+
}
65133
}
66134

67-
else if (!strncmp (parts[i], "fiber", 5))
68-
net_ori_fiber (SSet, dtess, dcell, (*pSSet).Random, parts[i], OSets + i);
69-
70-
else if (!strncmp (ori, "file(", 5))
71-
{
72-
net_ori_file (ori, OSets + i);
73-
ut_string_string (oricrysym, &(OSets[i].crysym));
74-
}
75-
76-
else if (strstr (In.orioptiini[level], "ori="))
77-
{
78-
int qty, *qty1 = NULL;
79-
char ***parts = NULL;
80-
ut_list_break2 (In.orioptiini[level], ",", "=", &parts, &qty1, &qty);
81-
for (j = 0; j < qty; j++)
82-
if (!strcmp (parts[j][0], "ori"))
83-
net_ori_file (parts[j][1], OSets + i);
84-
ut_string_string (oricrysym, &(OSets[i].crysym));
85-
86-
ut_free_3d_char (&parts, qty, 2);
87-
ut_free_1d_int (&qty1);
88-
}
135+
ol_set_cat (OSets, partqty, &OSet);
136+
for (i = 0; i < partqty; i++)
137+
size[i] = OSets[i].size;
89138

90-
else if (!strncmp (parts[i], "odf", 3))
91-
net_ori_odf ((*pSSet).Random, parts[i], OSets + i);
139+
if (ut_array_1d_int_sum (size, partqty) > ut_array_1d_int_max (size, partqty))
140+
ol_set_shuf (&OSet, (*pSSet).Random);
92141

93-
else
94-
net_ori_label (parts[i], SSet, dtess, dcell, OSets + i);
142+
for (i = 0; i < partqty; i++)
143+
ol_set_free (OSets + i);
144+
free (OSets);
95145

96-
if (strstr (In.orioptiini[level], "weight="))
97-
{
98-
int qty, *qty1 = NULL;
99-
char ***parts = NULL;
100-
ut_list_break2 (In.orioptiini[level], ",", "=", &parts, &qty1, &qty);
101-
102-
OSets[i].weight = ut_alloc_1d (OSets[i].size);
103-
for (j = 0; j < qty; j++)
104-
if (!strcmp (parts[j][0], "weight"))
105-
ut_array_1d_fnscanf_wcard (parts[j][1], OSets[i].weight, OSets[i].size, "numeral", "r");
106-
}
146+
net_ori_oricrysym (&OSet);
107147

108-
if (strstr (In.orioptiini[level], "theta="))
109-
{
110-
int qty, *qty1 = NULL;
111-
char ***parts = NULL;
112-
ut_list_break2 (In.orioptiini[level], ",", "=", &parts, &qty1, &qty);
113-
114-
OSets[i].theta = ut_alloc_1d (OSets[i].size);
115-
for (j = 0; j < qty; j++)
116-
if (!strcmp (parts[j][0], "theta"))
117-
{
118-
ut_array_1d_fnscanf_wcard (parts[j][1], OSets[i].theta, OSets[i].size, "numeral", "r");
119-
ut_array_1d_scale (OSets[i].theta, OSets[i].size, M_PI / 180);
120-
}
121-
}
148+
net_ori_memcpy (OSet, pSSet);
122149
}
123150

124-
ol_set_cat (OSets, partqty, &OSet);
125-
for (i = 0; i < partqty; i++)
126-
size[i] = OSets[i].size;
127-
128-
if (ut_array_1d_int_sum (size, partqty) > ut_array_1d_int_max (size, partqty))
129-
ol_set_shuf (&OSet, (*pSSet).Random);
130-
131-
for (i = 0; i < partqty; i++)
132-
ol_set_free (OSets + i);
133-
free (OSets);
134-
135-
net_ori_oricrysym (&OSet);
136-
137-
net_ori_memcpy (OSet, pSSet);
138-
139151
// processing -orispread
140152
net_ori_orispread (orispread, pSSet);
141153

src/neper_t/net_ori/net_ori_.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ extern void net_ori_mtess_params (struct IN_T In, int level, struct MTESS MTess,
3939

4040
extern int net_ori_mtess_randseed_rand (int *N, int *id, int *poly, int levelqty);
4141

42-
extern void net_ori_memcpy (struct OL_SET OSet, struct SEEDSET *pSSet);
43-
4442
extern void net_ori_orispread (char *orispread, struct SEEDSET *pSSet);
4543

4644
extern void net_orispread_file (char *orispread, struct SEEDSET *pSSet);

src/neper_t/net_tess/net_tess_opt/net_tess_opt_init/net_tess_opt_init_sset/net_tess_opt_init_sset1.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,36 @@ net_tess_opt_init_sset (struct IN_T In, int level, struct MTESS MTess,
1212
int pos;
1313
int *qty = ut_alloc_1d_int ((*pTOpt).CellQty + 1);
1414
double *rad = ut_alloc_1d ((*pTOpt).CellQty + 1);
15-
char *var = NULL, *cooexpr = NULL, *weightexpr = NULL;
15+
char *var = NULL, *cooexpr = NULL, *weightexpr = NULL, *idexpr = NULL, *oriexpr = NULL;
1616

1717
if (!strcmp ((*pTOpt).optitype, "morpho"))
1818
ut_print_message (0, 2, "Setting seeds... ");
1919

2020
net_tess_opt_init_sset_pre (In, level, MTess, Tess, dtess, dcell, SSet, &var,
21-
&pos, &weightexpr, &cooexpr, pTOpt);
21+
&pos, &weightexpr, &cooexpr, &idexpr, &oriexpr, pTOpt);
2222

2323
if (!strcmp ((*pTOpt).optitype, "morpho"))
24+
{
2425
net_tess_opt_init_sset_weight (MTess, Tess, dtess, dcell, *pTOpt, var, pos,
2526
weightexpr, rad);
26-
else
27-
ut_array_1d_set (rad + 1, (*pTOpt).CellQty, 1);
2827

29-
net_tess_opt_init_sset_multiseed (In, level, *pTOpt, var, rad, qty);
28+
net_tess_opt_init_sset_multiseed (In, level, *pTOpt, var, rad, qty);
3029

31-
if (!strcmp ((*pTOpt).optitype, "morpho"))
3230
net_tess_opt_init_sset_coo (MTess, Tess, dtess, dcell, pTOpt, var, pos,
3331
cooexpr, rad, qty);
3432

35-
if (!strcmp ((*pTOpt).optitype, "ori"))
36-
net_tess_opt_init_sset_ori (TessId, SSet, pTOpt);
33+
if (oriexpr)
34+
net_tess_opt_init_sset_ori (TessId, SSet, oriexpr, pTOpt);
35+
36+
if (idexpr)
37+
net_tess_opt_init_sset_id (TessId, SSet, idexpr, pTOpt);
38+
}
39+
40+
else if (!strcmp ((*pTOpt).optitype, "ori"))
41+
{
42+
ut_array_1d_set (rad + 1, (*pTOpt).CellQty, 1);
43+
net_tess_opt_init_sset_ori (TessId, SSet, oriexpr, pTOpt);
44+
}
3745

3846
net_tess_opt_init_sset_post (In, level, Tess[dtess], dcell, pTOpt);
3947

@@ -42,6 +50,8 @@ net_tess_opt_init_sset (struct IN_T In, int level, struct MTESS MTess,
4250
ut_free_1d_char (&var);
4351
ut_free_1d_char (&cooexpr);
4452
ut_free_1d_char (&weightexpr);
53+
ut_free_1d_char (&idexpr);
54+
ut_free_1d_char (&oriexpr);
4555

4656
return;
4757
}

src/neper_t/net_tess/net_tess_opt/net_tess_opt_init/net_tess_opt_init_sset/net_tess_opt_init_sset_.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
#include "net_tess_opt_init_sset_coo/net_tess_opt_init_sset_coo.h"
2424
#include "net_tess_opt_init_sset_multiseed/net_tess_opt_init_sset_multiseed.h"
2525
#include "net_tess_opt_init_sset_ori/net_tess_opt_init_sset_ori.h"
26+
#include "net_tess_opt_init_sset_id/net_tess_opt_init_sset_id.h"
2627
#include "net_tess_opt_init_sset_post/net_tess_opt_init_sset_post.h"
2728
#include "net_tess_opt_init_sset_pre/net_tess_opt_init_sset_pre.h"

0 commit comments

Comments
 (0)