32 static bool firstCall =
true;
35 static const double ideltax = 1.0 / deltax;
42 auto i = (size_t)
round(fabs(x) * ideltax);
43 if (
i >=
XSIZE(table))
return 0;
61 for (i = (
int)
XX(corner1); i <= (int)
XX(corner2); i++)
62 for (j = (
int)
YY(corner1); j <= (int)
YY(corner2); j++)
63 for (k = (
int)
ZZ(corner1); k <= (int)
ZZ(corner2); k++)
86 XX(global_aux) =
XX(global_r) + alpha *
XX(global_u);
87 YY(global_aux) =
YY(global_r) + alpha *
YY(global_u);
88 ZZ(global_aux) =
ZZ(global_r) + alpha *
ZZ(global_u);
116 double x_sign =
SGN(
XX(ur));
117 double y_sign =
SGN(
YY(ur));
118 double z_sign =
SGN(
ZZ(ur));
121 double alpha_xmin = (-2 -
XX(r)) /
XX(ur);
122 double alpha_xmax = (2 -
XX(r)) /
XX(ur);
123 double alpha_ymin = (-2 -
YY(r)) /
YY(ur);
124 double alpha_ymax = (2 -
YY(r)) /
YY(ur);
125 double alpha_zmin = (-2 -
ZZ(r)) /
ZZ(ur);
126 double alpha_zmax = (2 -
ZZ(r)) /
ZZ(ur);
137 std::cout <<
"Pixel: " << r.
transpose() << std::endl
138 <<
"Dir: " << ur.
transpose() << std::endl
139 <<
"Alpha x:" << alpha_xmin <<
" " << alpha_xmax << std::endl
140 <<
" " << (r + alpha_xmin*ur).
transpose() << std::endl
141 <<
" " << (r + alpha_xmax*ur).
transpose() << std::endl
142 <<
"Alpha y:" << alpha_ymin <<
" " << alpha_ymax << std::endl
143 <<
" " << (r + alpha_ymin*ur).
transpose() << std::endl
144 <<
" " << (r + alpha_ymax*ur).
transpose() << std::endl
145 <<
"Alpha z:" << alpha_zmin <<
" " << alpha_zmax << std::endl
146 <<
" " << (r + alpha_zmin*ur).
transpose() << std::endl
147 <<
" " << (r + alpha_zmax*ur).
transpose() << std::endl
148 <<
"alpha :" << alpha_min <<
" " << alpha_max << std::endl
158 std::cout <<
"First entry point: " << v.
transpose() << std::endl;
159 std::cout <<
" Alpha_min: " << alpha_min << std::endl;
163 double alpha = alpha_min;
167 double alpha_x = (
XX(v) + x_sign -
XX(r)) /
XX(ur);
168 double alpha_y = (
YY(v) + y_sign -
YY(r)) /
YY(ur);
169 double alpha_z = (
ZZ(v) + z_sign -
ZZ(r)) /
ZZ(ur);
173 double diffx =
ABS(alpha - alpha_x);
174 double diffy =
ABS(alpha - alpha_y);
175 double diffz =
ABS(alpha - alpha_z);
183 XX(v) += diff_alpha *
XX(ur);
184 YY(v) += diff_alpha *
YY(ur);
185 ZZ(v) += diff_alpha *
ZZ(ur);
188 std::cout <<
"Alpha x,y,z: " << alpha_x <<
" " << alpha_y
189 <<
" " << alpha_z <<
" ---> " << alpha << std::endl;
191 std::cout <<
" Next entry point: " << v.
transpose() << std::endl
192 <<
" diff_alpha: " << diff_alpha << std::endl
193 <<
" ray_sum: " << ray_sum << std::endl
194 <<
" Alfa tot: " << alpha <<
"alpha_max: " << alpha_max <<
223 double spline_radius = 2 *
sqrt(3.0);
226 #define x0 STARTINGX(*vol_voxels) 227 #define xF FINISHINGX(*vol_voxels) 228 #define y0 STARTINGY(*vol_voxels) 229 #define yF FINISHINGY(*vol_voxels) 230 #define z0 STARTINGZ(*vol_voxels) 231 #define zF FINISHINGZ(*vol_voxels) 234 bool condition =
true;
235 (*vol_voxels)().printShape();
236 std::cout << std::endl;
237 std::cout <<
"x0= " <<
x0 <<
" xF= " <<
xF << std::endl;
238 std::cout <<
"y0= " <<
y0 <<
" yF= " <<
yF << std::endl;
239 std::cout <<
"z0= " <<
z0 <<
" zF= " <<
zF << std::endl;
249 for (k = (
int)
ZZ(grid.lowest); k <= (
int)
ZZ(grid.highest); k++)
253 for (i = (
int)
YY(grid.lowest); i <= (
int)
YY(grid.highest); i++)
257 for (j = (
int)
XX(grid.lowest); j <= (
int)
XX(grid.highest); j++)
263 printf(
"Dealing spline at (%d,%d,%d) = %f\n", j, i, k,
A3D_ELEM(vol_splines, k, i, j));
264 std::cout <<
"Center of the blob " 271 if (
XX(act_coord) >=
xF) process =
false;
272 if (
YY(act_coord) >=
yF) process =
false;
273 if (
ZZ(act_coord) >=
zF) process =
false;
274 if (
XX(act_coord) <=
x0) process =
false;
275 if (
YY(act_coord) <=
y0) process =
false;
276 if (
ZZ(act_coord) <=
z0) process =
false;
278 if (!process && condition) std::cout <<
" It is outside output volume\n";
280 if (!grid.is_interesting(act_coord))
283 if (process && condition) std::cout <<
" It is not interesting\n";
290 V3_PLUS_CT(corner1, act_coord, -spline_radius);
291 V3_PLUS_CT(corner2, act_coord, spline_radius);
295 std::cout <<
"Corner 1 for this point " << corner1.
transpose() << std::endl;
296 std::cout <<
"Corner 2 for this point " << corner2.
transpose() << std::endl;
310 std::cout <<
"Clipped and rounded Corner 1 " << corner1.
transpose() << std::endl;
311 std::cout <<
"Clipped and rounded Corner 2 " << corner2.
transpose() << std::endl;
316 for (
int iz =
ZZ(corner1); iz <=
ZZ(corner2); iz++)
319 for (
int iy =
YY(corner1); iy <=
YY(corner2); iy++)
322 for (
int ix =
XX(corner1); ix <=
XX(corner2); ix++)
324 if (vol_mask !=
nullptr)
325 if (!
A3D_ELEM(*vol_mask, iz, iy, ix))
continue;
329 VECTOR_R3(gcurrent, static_cast<double>(intx),
330 static_cast<double>(inty), static_cast<double>(intz));
336 std::cout <<
"At (" << intx <<
"," 337 << inty <<
"," << intz <<
") value=" 344 A3D_ELEM(*vol_voxels, iz, iy, ix) +=
345 A3D_ELEM(vol_splines, k, i, j) * spline_value;
349 std::cout <<
" adding " <<
A3D_ELEM(vol_splines, k, i, j)
350 <<
" * " << value_spline <<
" = " 352 value_spline << std::endl;
362 XX(act_coord) =
XX(act_coord) + grid.relative_size * grid.basis(0, 0);
363 YY(act_coord) =
YY(act_coord) + grid.relative_size * grid.basis(1, 0);
364 ZZ(act_coord) =
ZZ(act_coord) + grid.relative_size * grid.basis(2, 0);
366 XX(beginY) =
XX(beginY) + grid.relative_size * grid.basis(0, 1);
367 YY(beginY) =
YY(beginY) + grid.relative_size * grid.basis(1, 1);
368 ZZ(beginY) =
ZZ(beginY) + grid.relative_size * grid.basis(2, 1);
370 XX(beginZ) =
XX(beginZ) + grid.relative_size * grid.basis(0, 2);
371 YY(beginZ) =
YY(beginZ) + grid.relative_size * grid.basis(1, 2);
372 ZZ(beginZ) =
ZZ(beginZ) + grid.relative_size * grid.basis(2, 2);
390 if (Zdim == 0 || Ydim == 0 || Xdim == 0)
402 (*vol_voxels).initZeros(Zdim, Ydim, Xdim);
403 (*vol_voxels).setXmippOrigin();
412 std::cout <<
"Spline grid no " <<
i <<
" stats: ";
413 vol_splines(i)().printStats();
414 std::cout << std::endl;
415 std::cout <<
"So far vol stats: ";
416 (*vol_voxels).printStats();
417 std::cout << std::endl;
419 save() = *vol_voxels;
433 double R2 = (R - 6) * (R - 6);
436 double min_val =
A3D_ELEM(*vol_voxels, 0, 0, 0);
438 if (
j*
j +
i*
i +
k*
k <= R2 - 4)
442 R2 = (R - 2) * (R - 2);
444 if (
j*
j +
i*
i +
k*
k >= R2)
void universe2grid(const Matrix1D< double > &uv, Matrix1D< double > &gv) const
Matrix1D< double > highest
double spatial_Bspline03_integralf(double alpha)
#define V3_PLUS_CT(a, b, c)
void grid2universe(const Matrix1D< double > &gv, Matrix1D< double > &uv) const
void sqrt(Image< double > &op)
Matrix1D< double > vectorR3(double x, double y, double z)
double sum_spatial_Bspline03_SimpleGrid(const SimpleGrid &grid)
#define V3_MINUS_V3(a, b, c)
double spatial_Bspline03LUT(const Matrix1D< double > &r)
double spatial_Bspline03(const Matrix1D< double > &r)
double spatial_Bspline03_integral(const Matrix1D< double > &r, const Matrix1D< double > &u, double alpha0, double alphaF)
String integerToString(int I, int _width, char fill_with)
Matrix1D< double > lowest
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
Matrix1D< T > transpose() const
double integrateNewtonCotes(double(*f)(double), double a, double b, int N)
#define A3D_ELEM(V, k, i, j)
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
#define V3_BY_CT(a, b, c)
void transpose(double *array, int size)
#define XMIPP_EQUAL_ACCURACY
void write(const FileName &fn) const
double Bspline03(double Argument)
void spatial_Bspline032voxels_SimpleGrid(const MultidimArray< double > &vol_splines, const SimpleGrid &grid, MultidimArray< double > *vol_voxels, const MultidimArray< double > *vol_mask=nullptr)
const int BSPLINE03_SUBSAMPLING
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
void spatial_Bspline032voxels(const GridVolume &vol_splines, MultidimArray< double > *vol_voxels, int Zdim, int Ydim, int Xdim)
const SimpleGrid & grid(size_t n) const
#define VECTOR_R3(v, x, y, z)
double sum_spatial_Bspline03_Grid(const Grid &grid)
double spatial_Bspline03_proj(const Matrix1D< double > &r, const Matrix1D< double > &u)
double get_interest_radius() const
Get reconstruction radius.
double Bspline03LUT(double x)
#define V3_PLUS_V3(a, b, c)