@brief: Given a list of sorted vertices which belong to a histogram bin, check that a particular component (x, y, or z) of their coordinates is not the same amongst two or more vertices */
| 1144 | particular component (x, y, or z) of their coordinates is not the same amongst two or more vertices |
| 1145 | */ |
| 1146 | bool have_same_coordinate( |
| 1147 | const std::vector<std::pair<vd_t, vec3>>& bin_vertices_sorted, |
| 1148 | const int coordinate_index = 0 // 0 = x, 1 = y, 2 = z component |
| 1149 | ) |
| 1150 | { |
| 1151 | // for each vertex, compare to all others in vector (compare by given component) |
| 1152 | bool is_duplicate = false; |
| 1153 | for (std::vector<std::pair<vd_t, vec3>>::const_iterator i = bin_vertices_sorted.begin(); i != bin_vertices_sorted.end(); ++i) { |
| 1154 | const vec3& vertex_i_coordinates = i->second; |
| 1155 | const double vertex_i_coordinate = vertex_i_coordinates[coordinate_index]; |
| 1156 | bool vertex_i_coordinate_is_duplicate = false; |
| 1157 | |
| 1158 | for (std::vector<std::pair<vd_t, vec3>>::const_iterator j = bin_vertices_sorted.begin(); j != bin_vertices_sorted.end(); ++j) { |
| 1159 | if (j == i) { |
| 1160 | continue; // same vertex, skip |
| 1161 | } |
| 1162 | |
| 1163 | const vec3& vertex_j_coordinates = j->second; |
| 1164 | const double vertex_j_coordinate = vertex_j_coordinates[coordinate_index]; |
| 1165 | vertex_i_coordinate_is_duplicate = (vertex_i_coordinate == vertex_j_coordinate); |
| 1166 | |
| 1167 | if (vertex_i_coordinate_is_duplicate) { |
| 1168 | is_duplicate = true; |
| 1169 | break; |
| 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | if (is_duplicate) { |
| 1174 | break; |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | return is_duplicate; |
| 1179 | } |
| 1180 | |
| 1181 | // TODO: replace code parts that use "m0_ivtx_to_intersection_registry_entry" with calls to this |
| 1182 | // function which is much cheaper |