| 10 | using namespace PyMesh; |
| 11 | |
| 12 | void WireConnectivity::compute() { |
| 13 | const size_t num_vertices = m_wire_network->get_num_vertices(); |
| 14 | const size_t num_edges = m_wire_network->get_num_edges(); |
| 15 | std::vector<std::list<size_t> > adjacencies(num_vertices); |
| 16 | |
| 17 | const MatrixIr& edges = m_wire_network->get_edges(); |
| 18 | for (size_t i=0; i<num_edges; i++) { |
| 19 | const VectorI& edge = edges.row(i); |
| 20 | adjacencies[edge[0]].push_back(edge[1]); |
| 21 | adjacencies[edge[1]].push_back(edge[0]); |
| 22 | } |
| 23 | |
| 24 | size_t count=0; |
| 25 | m_vertex_adjacency_index.resize(num_vertices+1); |
| 26 | m_vertex_adjacency_index[0] = 0; |
| 27 | std::list<size_t> all_adjacencies; |
| 28 | for (auto adj : adjacencies) { |
| 29 | m_vertex_adjacency_index[count+1] = |
| 30 | m_vertex_adjacency_index[count] + adj.size(); |
| 31 | all_adjacencies.splice(all_adjacencies.end(), adj); |
| 32 | count++; |
| 33 | } |
| 34 | |
| 35 | m_vertex_adjacencies.resize(all_adjacencies.size()); |
| 36 | std::copy(all_adjacencies.begin(), all_adjacencies.end(), |
| 37 | m_vertex_adjacencies.data()); |
| 38 | } |
| 39 | |
| 40 | void WireConnectivity::reset() { |
| 41 | m_vertex_adjacencies.resize(0); |
no test coverage detected