plastimatch
Loading...
Searching...
No Matches
src
base
volume_macros.h
Go to the documentation of this file.
1
/* -----------------------------------------------------------------------
2
See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
3
----------------------------------------------------------------------- */
4
#ifndef _volume_macros_h_
5
#define _volume_macros_h_
6
7
#include "
plmbase_config.h
"
8
#include "
plm_int.h
"
9
10
/* -----------------------------------------------------------------------
11
Macros
12
----------------------------------------------------------------------- */
13
static
inline
plm_long
14
volume_index
(
const
plm_long dims[3], plm_long i, plm_long j, plm_long k)
15
{
16
return
i + (dims[0] * (j + dims[1] * k));
17
}
18
19
static
inline
plm_long
20
volume_index
(
const
plm_long dims[3],
const
plm_long ijk[3])
21
{
22
return
ijk[0] + (dims[0] * (ijk[1] + dims[1] * ijk[2]));
23
}
24
25
static
inline
bool
26
index_in_volume
(
const
plm_long dims[3],
const
plm_long ijk[3])
27
{
28
return
ijk[0] >= 0 && ijk[0] < dims[0]
29
&& ijk[1] >= 0 && ijk[1] < dims[1]
30
&& ijk[2] >= 0 && ijk[2] < dims[2];
31
}
32
33
#define COORDS_FROM_INDEX(ijk, idx, dim) \
34
ijk[2] = idx / (dim[0] * dim[1]); \
35
ijk[1] = (idx - (ijk[2] * dim[0] * dim[1])) / dim[0]; \
36
ijk[0] = idx - ijk[2] * dim[0] * dim[1] - (ijk[1] * dim[0]);
37
38
#define LOOP_Z(ijk,fxyz,vol) \
39
for ( \
40
ijk[2] = 0, \
41
fxyz[2] = vol->origin[2]; \
42
ijk[2] < vol->dim[2]; \
43
++ijk[2], \
44
fxyz[2] = vol->origin[2] + ijk[2]*vol->step[2*3+2] \
45
)
46
#define LOOP_Z_OMP(k,vol) \
47
for ( \
48
long k = 0; \
49
k < vol->dim[2]; \
50
++k \
51
)
52
#define LOOP_Y(ijk,fxyz,vol) \
53
for ( \
54
ijk[1] = 0, \
55
fxyz[1] = vol->origin[1] + ijk[2]*vol->step[1*3+2]; \
56
ijk[1] < vol->dim[1]; \
57
++ijk[1], \
58
fxyz[2] = vol->origin[2] + ijk[2]*vol->step[2*3+2] \
59
+ ijk[1]*vol->step[2*3+1], \
60
fxyz[1] = vol->origin[1] + ijk[2]*vol->step[1*3+2] \
61
+ ijk[1]*vol->step[1*3+1] \
62
)
63
#define LOOP_X(ijk,fxyz,vol) \
64
for ( \
65
ijk[0] = 0, \
66
fxyz[0] = vol->origin[0] + ijk[2]*vol->step[0*3+2] \
67
+ ijk[1]*vol->step[0*3+1]; \
68
ijk[0] < vol->dim[0]; \
69
++ijk[0], \
70
fxyz[0] += vol->step[0*3+0], \
71
fxyz[1] += vol->step[1*3+0], \
72
fxyz[2] += vol->step[2*3+0] \
73
)
74
75
#define PROJECT_Z(xyz,proj) \
76
(xyz[0] * proj[2*3+0] + xyz[1] * proj[2*3+1] + xyz[2] * proj[2*3+2])
77
#define PROJECT_Y(xyz,proj) \
78
(xyz[0] * proj[1*3+0] + xyz[1] * proj[1*3+1] + xyz[2] * proj[1*3+2])
79
#define PROJECT_X(xyz,proj) \
80
(xyz[0] * proj[0*3+0] + xyz[1] * proj[0*3+1] + xyz[2] * proj[0*3+2])
81
82
#define POSITION_FROM_COORDS(xyz, ijk, origin, step) \
83
do { \
84
xyz[0] = origin[0] \
85
+ ijk[0]*step[3*0+0] \
86
+ ijk[1]*step[3*0+1] \
87
+ ijk[2]*step[3*0+2]; \
88
xyz[1] = origin[1] \
89
+ ijk[0]*step[3*1+0] \
90
+ ijk[1]*step[3*1+1] \
91
+ ijk[2]*step[3*1+2]; \
92
xyz[2] = origin[2] \
93
+ ijk[0]*step[3*2+0] \
94
+ ijk[1]*step[3*2+1] \
95
+ ijk[2]*step[3*2+2]; \
96
} while (0);
97
98
#endif
plm_int.h
plmbase_config.h
volume_index
static plm_long volume_index(const plm_long dims[3], plm_long i, plm_long j, plm_long k)
Definition
volume_macros.h:14
index_in_volume
static bool index_in_volume(const plm_long dims[3], const plm_long ijk[3])
Definition
volume_macros.h:26
Generated on Wed Oct 30 2024 14:54:42 for plastimatch by
1.11.0