75int main(
int argc,
char* argv[])
77 typedef double phi_type;
79 openfpm_init(&argc, &argv);
83 const std::string path_output = cwd +
"/output_3D_sphere";
89 const std::string path_input =
"input";
90 const std::string path_to_zstack = path_input +
"/sphere.bin";
91 const std::string path_to_size = path_input +
"/size_sphere.csv";
95 const unsigned int grid_dim = 3;
100 const size_t Phi_0_grid = 0;
101 const size_t Phi_SDF_grid = 1;
103 const size_t Phi_SDF_vd = 0;
104 const size_t Phi_grad_vd = 1;
105 const size_t Phi_magnOfGrad_vd = 2;
124 const phi_type refinement [] = {1.0, 1.0, 1.0};
145 std::vector<int> stack_size =
get_size(path_to_size);
146 auto & v_cl = create_vcluster();
147 if (v_cl.rank() == 0)
149 for(std::vector<int>::size_type i = 0; i != stack_size.size(); i++)
151 std::cout <<
"#Pixel in dimension " << i <<
" = " << stack_size[i] << std::endl;
152 std::cout <<
"original refinement in dimension " << i <<
" = " << refinement[i] << std::endl;
158 const size_t sz[grid_dim] = {(size_t)std::round(stack_size[x] * refinement[x]), (size_t)std::round(stack_size[y] * refinement[y]), (size_t)std::round(stack_size[z] * refinement[z])};
182 grid_in_type g_dist(sz, box, ghost);
183 g_dist.setPropNames({
"Phi_0",
"Phi_SDF"});
186 init_grid_and_ghost<Phi_0_grid>(g_dist, -1.0);
189 load_pixel_onto_grid<Phi_0_grid>(g_dist, path_to_zstack, stack_size);
190 g_dist.write(path_output +
"/grid_from_images_initial", FORMAT_BINARY);
198 redist_options.min_iter = 1e3;
199 redist_options.max_iter = 1e4;
201 redist_options.convTolChange.value = 1e-7;
202 redist_options.convTolChange.check =
true;
203 redist_options.convTolResidual.value = 1e-6;
204 redist_options.convTolResidual.check =
false;
206 redist_options.interval_check_convergence = 1e3;
207 redist_options.width_NB_in_grid_points = 10;
208 redist_options.print_current_iterChangeResidual =
true;
209 redist_options.print_steadyState_iter =
true;
210 redist_options.save_temp_grid =
true;
215 redist_obj.run_redistancing<Phi_0_grid, Phi_SDF_grid>();
217 g_dist.write(path_output +
"/grid_images_post_redistancing", FORMAT_BINARY);
221 size_t bc[grid_dim] = {NON_PERIODIC, NON_PERIODIC, NON_PERIODIC};
229 vd_type vd_narrow_band(0, box, bc, ghost_vd);
230 vd_narrow_band.setPropNames({
"Phi_SDF",
"Phi_grad",
"Phi_magnOfGrad"});
242 narrowBand.get_narrow_band<Phi_SDF_grid, Phi_SDF_vd, Phi_grad_vd, Phi_magnOfGrad_vd>(g_dist, vd_narrow_band);
244 vd_narrow_band.write(path_output +
"/vd_narrow_band_images", FORMAT_BINARY);
Header file containing functions for loading pixel values from 2D image or 3D image stack (volume) st...
std::vector< int > get_size(const std::string &path_to_file)
Read the number of pixels per dimension from a csv-file in order to create a grid with the same size.
Class for getting the narrow band around the interface.
Header file containing functions for creating files and folders.
static void create_directory_if_not_exist(std::string path, bool silent=0)
Creates a directory if not already existent.
static std::string get_cwd()
Gets the current working directory and returns path as string.
Class for reinitializing a level-set function into a signed distance function using Sussman redistanc...
This class represent an N-dimensional box.
Class for getting the narrow band around the interface.
Class for reinitializing a level-set function into a signed distance function using Sussman redistanc...
This is a distributed grid.
Structure to bundle options for redistancing.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...