//--------------------------------------------------------------------------- //This function finds the corresponding shell sub-region where the point is located. Then it adds the CNT number to the //corresponding vector in the 2D vector shells_cnt (for the quasi-2D network of Ag nanowires ) int Background_vectors::Add_to_shell(const struct Geom_RVE &sample, const Point_3D &point, vector<vector<int> > &shells_cnt)const { //Find the shell based on the x coordinate int shell_x = Find_shell(point.x, sample.origin.x, sample.len_x, sample.win_delt_x, sample.win_min_x, sample.win_max_x, shells_cnt); //Find the shell based on the y coordinate int shell_y = Find_shell(point.y, sample.origin.y, sample.wid_y, sample.win_delt_y, sample.win_min_y, sample.win_max_y, shells_cnt); if(shell_x==-1||shell_y==-1) { hout << "Error: shell_x=" << shell_x << " shell_y=" << shell_y << " calculated by Find_shell() in the Add_to_shell() function."<< endl; return 0; } //The shell to which the CNT of point is the outer-most shell from the three coordinates, that is, the minimum shell number overall int shell = shell_x; //With this if-statement I have shell = min(shell_x, shell_y) if(shell_y<shell) shell = shell_y; //Finally add the CNT on the corresponding sectioned domain //Add the CNT number to the shell sub-region, only if it is empty or if the last CNT is not the current CNT if((!shells_cnt[shell].size()) || (shells_cnt[shell].back() != point.flag)) shells_cnt[shell].push_back(point.flag); return 1; }
//This function finds the shell to which one point belongs to //So it uses three times the function that finds the shell to which one coordinate belongs to int Background_vectors::Find_minimum_shell(const struct Geom_RVE &sample, const Point_3D &point, const int &num_shells)const { //Find the shell based on the x coordinate //hout << "x_in="; int shell_x = Find_shell(point.x, sample.origin.x, sample.len_x, sample.win_delt_x, sample.win_min_x, sample.win_max_x, num_shells); //Find the shell based on the y coordinate //hout << "y_in="; int shell_y = Find_shell(point.y, sample.origin.y, sample.wid_y, sample.win_delt_y, sample.win_min_y, sample.win_max_y, num_shells); //Find the shell based on the z coordinate //hout << "z_in="; int shell_z = Find_shell(point.z, sample.origin.z, sample.hei_z, sample.win_delt_z, sample.win_min_z, sample.win_max_z, num_shells); //The shell to which the CNT of point is the outer-most shell from the three coordinates, that is, the minimum shell number overall int shell = shell_x; //With this if-statement I have shell = min(shell_x, shell_y) if (shell_y < shell) shell = shell_y; //With this if-statement I have shell = min( shell_z, min(shell_x, shell_y)) //And this is the smallest shell value if (shell_z < shell) shell = shell_z; return shell; }