| 143 | } |
| 144 | |
| 145 | void TilerEngine::remove_duplicated_vertices(WireNetwork& wire_network, Float tol) { |
| 146 | const size_t num_input_vertices = wire_network.get_num_vertices(); |
| 147 | |
| 148 | DuplicatedVertexRemoval remover(wire_network.get_vertices(), wire_network.get_edges()); |
| 149 | remover.run(tol); |
| 150 | MatrixFr vertices = remover.get_vertices(); |
| 151 | MatrixIr edges = remover.get_faces(); |
| 152 | VectorI index_map = remover.get_index_map(); |
| 153 | assert(num_input_vertices == index_map.size()); |
| 154 | |
| 155 | wire_network.set_vertices(vertices); |
| 156 | wire_network.set_edges(edges); |
| 157 | |
| 158 | const size_t num_output_vertices = wire_network.get_num_vertices(); |
| 159 | std::vector<std::string> attr_names = wire_network.get_attribute_names(); |
| 160 | for (auto itr : attr_names) { |
| 161 | const std::string& name = itr; |
| 162 | if (wire_network.is_vertex_attribute(name)) { |
| 163 | MatrixFr values = wire_network.get_attribute(name); |
| 164 | MatrixFr updated_values = MatrixFr::Zero(num_output_vertices, values.cols()); |
| 165 | VectorF count = VectorF::Zero(num_output_vertices); |
| 166 | for (size_t i=0; i<num_input_vertices; i++) { |
| 167 | size_t j = index_map[i]; |
| 168 | updated_values.row(j) += values.row(i); |
| 169 | count[j] += 1; |
| 170 | } |
| 171 | |
| 172 | for (size_t i=0; i<num_output_vertices; i++) { |
| 173 | assert(count[i] > 0); |
| 174 | updated_values.row(i) /= count[i]; |
| 175 | } |
| 176 | wire_network.set_attribute(name, updated_values); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | void TilerEngine::remove_duplicated_edges(WireNetwork& wire_network) { |
| 182 | const MatrixIr& edges = wire_network.get_edges(); |
nothing calls this directly
no test coverage detected