@@ -119,23 +119,7 @@ vector<vector<int32_t>> \
119119 vector<vector<int32_t >> triso_distribution (lattice_shape[0 ]*lattice_shape[1 ]*lattice_shape[2 ]);
120120 vector<double > mesh_center (3 );
121121 vector<int > mesh_ind (3 );
122- /*
123- for (int i=0; i<lattice_shape[0]; i++) {
124- for (int j=0; j<lattice_shape[1]; j++) {
125- for (int k=0; k<lattice_shape[2]; k++) {
126- mesh_center[0]=(i+0.5)*lattice_pitch[0]+lattice_lower_left[0];
127- mesh_center[1]=(j+0.5)*lattice_pitch[1]+lattice_lower_left[1];
128- mesh_center[2]=(k+0.5)*lattice_pitch[2]+lattice_lower_left[2];
129- for (int32_t token : cell_rpn) {
130- if (token >= OP_UNION) continue;
131- if (model::surfaces[abs(token) - 1]->triso_in_mesh(mesh_center, lattice_pitch)) {
132- triso_distribution[i+j*lattice_shape[0]+k*lattice_shape[0]*lattice_shape[1]].push_back(token);
133- model::surfaces[abs(token) - 1]->connect_to_triso_base(id, "base");
134- }
135- }
136- }
137- }
138- }*/
122+
139123 for (int32_t token : cell_rpn) {
140124 if (token >= OP_UNION) continue ;
141125 vector<double > triso_center=model::surfaces[abs (token) - 1 ]->get_center ();
@@ -160,11 +144,9 @@ vector<vector<int32_t>> \
160144 }
161145 }
162146
163-
164147 return triso_distribution;
165148}
166149
167-
168150// ==============================================================================
169151// ! Convert infix region specification to Reverse Polish Notation (RPN)
170152// !
@@ -586,7 +568,7 @@ CSGCell::CSGCell(pugi::xml_node cell_node)
586568 } else {
587569 virtual_lattice_ = false ;
588570 }
589-
571+
590572 if (check_for_node (cell_node, " triso_particle" )) {
591573 triso_particle_ = get_node_value_bool (cell_node, " triso_particle" );
592574 } else {
@@ -771,40 +753,6 @@ std::pair<double, int32_t> CSGCell::distance(
771753 double min_dis_vl;
772754 int32_t i_surf_vl;
773755 if (virtual_lattice_) {
774- /*
775- double tol_dis = p.collision_distance();
776- double u_value = sqrt(pow(u.x,2)+pow(u.y,2)+pow(u.z,2)); //don't know if u has been normalized
777- vector<double> norm_u = {u.x/u_value, u.y/u_value, u.z/u_value};
778- vector<double> r_end = {r.x+tol_dis*norm_u[0], r.y+tol_dis*norm_u[1], r.z+tol_dis*norm_u[2]};
779- double temp_pos_x, temp_pos_y, temp_pos_z;
780- vector<vector<int>> passed_lattice={{floor((r.x-vl_lower_left_[0])/vl_pitch_[0]),\
781- floor((r.y-vl_lower_left_[1])/vl_pitch_[1]),\
782- floor((r.z-vl_lower_left_[2])/vl_pitch_[2]), 0}};
783- int index_start;
784- int index_end;
785- for (int i = 0; i < 3; i++){
786- if (passed_lattice[0][i] == vl_shape_[i]) {
787- passed_lattice[0][i] = vl_shape_[i]-1;
788- }
789- }
790-
791- if (u.x > 0) {
792- index_start = ceil((r.x-vl_lower_left_[0])/vl_pitch_[0]);
793- index_end = floor((r_end[0]-vl_lower_left_[0])/vl_pitch_[0]);
794- if (index_start <= index_end && index_start < vl_shape_[0]) {
795- for (int i = index_start; i <= index_end; i++) {
796- if (i >= vl_shape_[0]) break;
797- temp_pos_x = i*vl_pitch_[0]+vl_lower_left_[0];
798- temp_pos_y = (temp_pos_x-r.x)*norm_u[1]/norm_u[0]+r.y;
799- temp_pos_z = (temp_pos_x-r.x)*norm_u[2]/norm_u[0]+r.z;
800- passed_lattice.push_back({i, floor((temp_pos_y-vl_lower_left_[1])/vl_pitch_[1]),\
801- floor((temp_pos_z-vl_lower_left_[2])/vl_pitch_[2]),\
802- (temp_pos_x-r.x)/norm_u[0]})
803- }
804- }
805- }
806- */
807-
808756 double max_dis = p->collision_distance ();
809757 double tol_dis = 0 ;
810758 vector<double > dis_to_bou (3 ), dis_to_bou_max (3 );
@@ -835,14 +783,10 @@ std::pair<double, int32_t> CSGCell::distance(
835783 }
836784
837785 while (true ) {
838-
839-
840-
841786 if (lat_ind[0 ] < 0 || lat_ind[0 ] >= vl_shape_[0 ] ||\
842787 lat_ind[1 ] < 0 || lat_ind[1 ] >= vl_shape_[1 ] ||\
843788 lat_ind[2 ] < 0 || lat_ind[2 ] >= vl_shape_[2 ]) break ;
844789
845-
846790 for (int token : vl_triso_distribution_[lat_ind[0 ]+lat_ind[1 ]*vl_shape_[0 ]+lat_ind[2 ]*vl_shape_[0 ]*vl_shape_[1 ]]) {
847791 bool coincident {std::abs (token) == std::abs (on_surface)};
848792 double d {model::surfaces[abs (token) - 1 ]->distance (r, u, coincident)};
@@ -853,7 +797,6 @@ std::pair<double, int32_t> CSGCell::distance(
853797 }
854798 }
855799 }
856-
857800
858801 int mes_bou_crossed=0 ;
859802 if (dis_to_bou[1 ] < dis_to_bou[0 ]) {
@@ -876,13 +819,13 @@ std::pair<double, int32_t> CSGCell::distance(
876819 }
877820
878821 dis_to_bou[mes_bou_crossed] += dis_to_bou_max[mes_bou_crossed];
879-
822+
880823 if (tol_dis > max_dis) {
881824 break ;
882825 }
883826 }
884827
885-
828+
886829 } else {
887830 for (int32_t token : rpn_) {
888831 // Ignore this token if it corresponds to an operator rather than a region.
@@ -903,7 +846,7 @@ std::pair<double, int32_t> CSGCell::distance(
903846 }
904847 }
905848 }
906-
849+
907850 return {min_dist, i_surf};
908851}
909852
0 commit comments